- public synchronized File getFile(final String luid) {
- File file = lib.getFile(luid);
- if (file == null) {
- final File[] tmp = new File[1];
- try {
- new ConnectActionClient(host, port, true, null) {
- @Override
- public void action(Version serverVersion) throws Exception {
- try {
- Object rep = send("GET_STORY " + luid);
- Story story = (Story) rep;
- if (story != null) {
- lib.save(story, luid, null);
- tmp[0] = lib.getFile(luid);
- }
- } catch (Exception e) {
- Instance.syserr(e);
- }
+ public Image getCover(final String luid) throws IOException {
+ final Image[] result = new Image[1];
+
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ Object rep = action
+ .send(new Object[] { subkey, "GET_COVER", luid });
+ result[0] = (Image) rep;
+ }
+ });
+
+ return result[0];
+ }
+
+ @Override
+ public Image getCustomSourceCover(final String source) throws IOException {
+ return getCustomCover(source, "SOURCE");
+ }
+
+ @Override
+ public Image getCustomAuthorCover(final String author) throws IOException {
+ return getCustomCover(author, "AUTHOR");
+ }
+
+ // type: "SOURCE" or "AUTHOR"
+ private Image getCustomCover(final String source, final String type)
+ throws IOException {
+ final Image[] result = new Image[1];
+
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ Object rep = action.send(new Object[] { subkey,
+ "GET_CUSTOM_COVER", type, source });
+ result[0] = (Image) rep;
+ }
+ });
+
+ return result[0];
+ }
+
+ @Override
+ public synchronized Story getStory(final String luid, Progress pg)
+ throws IOException {
+ final Progress pgF = pg;
+ final Story[] result = new Story[1];
+
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ Progress pg = pgF;
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ Object rep = action
+ .send(new Object[] { subkey, "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());