- 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 synchronized void delete(final String luid) throws IOException {
+ new ConnectActionClientObject(host, port, true) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ send(new Object[] { md5, "DELETE_STORY", luid });
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+ }.connect();
+ }
+
+ @Override
+ public void setSourceCover(final String source, final String luid) {
+ try {
+ new ConnectActionClientObject(host, port, true) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ send(new Object[] { md5, "SET_SOURCE_COVER", source, luid });
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+ }.connect();
+ } catch (IOException e) {
+ Instance.getTraceHandler().error(e);
+ }
+ }
+
+ @Override
+ // Could work (more slowly) without it
+ public Story imprt(final URL url, Progress pg) throws IOException {
+ // Import the file locally if it is actually a file
+ if (url == null || url.getProtocol().equalsIgnoreCase("file")) {
+ return super.imprt(url, pg);
+ }
+
+ // Import it remotely if it is an URL
+
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ pg.setMinMax(0, 2);
+ Progress pgImprt = new Progress();
+ Progress pgGet = new Progress();
+ pg.addProgress(pgImprt, 1);
+ pg.addProgress(pgGet, 1);
+
+ final Progress pgF = pgImprt;
+ final String[] luid = new String[1];
+
+ try {
+ new ConnectActionClientObject(host, port, true) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ Progress pg = pgF;
+
+ Object rep = send(new Object[] { md5, "IMPORT",
+ url.toString() });
+
+ while (true) {
+ if (!RemoteLibraryServer.updateProgress(pg, rep)) {
+ break;