- protected List<MetaData> getMetas(Progress pg) {
- // TODO: progress
-
- if (metas == null) {
- metas = new ArrayList<MetaData>();
-
- try {
- new ConnectActionClient(host, port, true, null) {
- @Override
- public void action(Version serverVersion) throws Exception {
- try {
- Object rep = send("GET_METADATA *");
- for (MetaData meta : (MetaData[]) rep) {
- metas.add(meta);
- }
- } catch (Exception e) {
- Instance.syserr(e);
+ public Image getCover(final String luid) {
+ final Image[] result = new Image[1];
+
+ try {
+ new ConnectActionClientObject(host, port, false) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ Object rep = sendCmd(this,
+ new Object[] { "GET_COVER", luid });
+ result[0] = (Image) rep;
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+ }.connect();
+ } catch (Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+
+ return result[0];
+ }
+
+ @Override
+ public Image getCustomSourceCover(final String source) {
+ return getCustomCover(source, "SOURCE");
+ }
+
+ @Override
+ public Image getCustomAuthorCover(final String author) {
+ return getCustomCover(author, "AUTHOR");
+ }
+
+ // type: "SOURCE" or "AUTHOR"
+ private Image getCustomCover(final String source, final String type) {
+ final Image[] result = new Image[1];
+
+ try {
+ new ConnectActionClientObject(host, port, false) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ Object rep = sendCmd(this, new Object[] {
+ "GET_CUSTOM_COVER", type, source });
+ result[0] = (Image) rep;
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+ }.connect();
+ } catch (Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+
+ return result[0];
+ }
+
+ @Override
+ public synchronized Story getStory(final String luid, Progress pg) {
+ final Progress pgF = pg;
+ final Story[] result = new Story[1];
+
+ try {
+ new ConnectActionClientObject(host, port, false) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ Progress pg = pgF;
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ Object rep = sendCmd(this,
+ new Object[] { "GET_STORY", luid });
+
+ MetaData meta = null;
+ if (rep instanceof MetaData) {
+ meta = (MetaData) rep;
+ if (meta.getWords() <= Integer.MAX_VALUE) {
+ pg.setMinMax(0, (int) meta.getWords());