From: Niki Roo Date: Sat, 25 Nov 2017 21:09:04 +0000 (+0100) Subject: Prepare work on RemoteLibrary X-Git-Tag: fanfix-swing-0.0.1~12^2~418 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=a85e807750081c6e77a7916ca4e79506b5a98537;p=fanfix-swing.git Prepare work on RemoteLibrary --- diff --git a/VERSION b/VERSION index fdd3be6d..8d067cef 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.2 +1.6.2-dev diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 83766396..513849e3 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -16,7 +16,7 @@ import be.nikiroo.utils.serial.ConnectActionClient; /** * This {@link BasicLibrary} will access a remote server to list the available - * stories, and download the one you try to load to the local directory + * stories, and download the ones you try to load to the local directory * specified in the configuration. * * @author niki @@ -137,26 +137,32 @@ public class RemoteLibrary extends BasicLibrary { } @Override - protected int getNextId() { + public synchronized void delete(String luid) throws IOException { throw new java.lang.InternalError( "No write support allowed on remote Libraries"); } @Override - protected void doDelete(String luid) throws IOException { + public void setSourceCover(String source, String luid) { throw new java.lang.InternalError( "No write support allowed on remote Libraries"); } + // All the following methods are only used by Save and Delete in + // BasicLibrary: + @Override - protected Story doSave(Story story, Progress pg) throws IOException { - throw new java.lang.InternalError( - "No write support allowed on remote Libraries"); + protected int getNextId() { + throw new java.lang.InternalError("Should not have been called"); } @Override - public void setSourceCover(String source, String luid) { - throw new java.lang.InternalError( - "No write support allowed on remote Libraries"); + protected void doDelete(String luid) throws IOException { + throw new java.lang.InternalError("Should not have been called"); + } + + @Override + protected Story doSave(Story story, Progress pg) throws IOException { + throw new java.lang.InternalError("Should not have been called"); } } diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java index 566c70fa..661bf54d 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java @@ -9,10 +9,32 @@ import be.nikiroo.utils.Version; import be.nikiroo.utils.serial.ConnectActionServer; import be.nikiroo.utils.serial.Server; +/** + * Create a new remote server that will listen for order on the given port. + *

+ * The available commands are: + *

+ * + * @author niki + */ public class RemoteLibraryServer extends Server { + /** + * Create a new remote server (will not be active until + * {@link RemoteLibraryServer#start()} is called). + * + * @param port + * the port to listen on + * + * @throws IOException + * in case of I/O error + */ public RemoteLibraryServer(int port) throws IOException { - super(Version.getCurrentVersion(), port, true); + super(port, true); } @Override @@ -32,16 +54,16 @@ public class RemoteLibraryServer extends Server { System.out.println(String.format("COMMAND: [%s], ARGS: [%s]", command, args)); - if (command != null) { - if (command.equals("GET_METADATA")) { - if (args != null && args.equals("*")) { - List metas = Instance.getLibrary().getMetas(null); - return metas.toArray(new MetaData[] {}); - } - } else if (command.equals("GET_STORY")) { - if (args != null) { - return Instance.getLibrary().getStory(args, null); - } + // TODO: progress (+send name + %age info back to client) + + if ("GET_METADATA".equals(command)) { + if (args != null && args.equals("*")) { + List metas = Instance.getLibrary().getMetas(null); + return metas.toArray(new MetaData[] {}); + } + } else if ("GET_STORY".equals(command)) { + if (args != null) { + return Instance.getLibrary().getStory(args, null); } }