X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibraryServer.java;h=f4075dd7bf5df4e9fb1d734bc8d47fdb95852b5e;hp=62548d678f2b04c6e59e8bb3e455a578e9f68f8c;hb=fb25273cf02653ac343d5437083b1bc41af5ce23;hpb=67837328c9ded45b23691e2a3ebdb29c75f157f2 diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java index 62548d6..f4075dd 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryServer.java @@ -11,6 +11,7 @@ import java.util.Map; import javax.net.ssl.SSLException; import be.nikiroo.fanfix.Instance; +import be.nikiroo.fanfix.bundles.Config; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; @@ -18,6 +19,7 @@ import be.nikiroo.fanfix.data.Story; import be.nikiroo.utils.Progress; import be.nikiroo.utils.Progress.ProgressListener; import be.nikiroo.utils.StringUtils; +import be.nikiroo.utils.Version; import be.nikiroo.utils.serial.server.ConnectActionServerObject; import be.nikiroo.utils.serial.server.ServerObject; @@ -27,8 +29,12 @@ import be.nikiroo.utils.serial.server.ServerObject; * The available commands are given as arrays of objects (first item is the * command, the rest are the arguments). *
+ * All the commands are always prefixed by the subkey (which can be EMPTY if + * none). + *
*
+ * Note: the key we use here is the encryption key (it must not contain a
+ * subkey).
*
* @param key
* the key that will restrict access to this server
@@ -73,53 +84,109 @@ public class RemoteLibraryServer extends ServerObject {
}
@Override
- protected Object onRequest(ConnectActionServerObject action, Object data,
- long id) throws Exception {
+ protected Object onRequest(ConnectActionServerObject action,
+ Version clientVersion, Object data, long id) throws Exception {
long start = new Date().getTime();
+ // defaults are positive (as previous versions without the feature)
+ boolean rw = true;
+ boolean wl = true;
+
+ String subkey = "";
String command = "";
Object[] args = new Object[0];
if (data instanceof Object[]) {
Object[] dataArray = (Object[]) data;
if (dataArray.length > 0) {
- command = "" + dataArray[0];
+ subkey = "" + dataArray[0];
+ }
+ if (dataArray.length > 1) {
+ command = "" + dataArray[1];
+
+ args = new Object[dataArray.length - 2];
+ for (int i = 2; i < dataArray.length; i++) {
+ args[i - 2] = dataArray[i];
+ }
+ }
+ }
+
+ List