* This {@link BasicLibrary} will access a remote server to list the available
* stories, and download the ones you try to load to the local directory
* specified in the configuration.
+ * <p>
+ * This remote library uses a custom fanfix:// protocol.
*
* @author niki
*/
}
@Override
- public Object send(Object data) throws IOException,
- NoSuchFieldException, NoSuchMethodException,
+ public Object send(Object data)
+ throws IOException, NoSuchFieldException, NoSuchMethodException,
ClassNotFoundException {
Object rep = super.send(data);
if (rep instanceof RemoteLibraryException) {
this.subkey = "";
}
+ if (host.startsWith("fanfix://")) {
+ host = host.substring("fanfix://".length());
+ }
+
this.host = host;
this.port = port;
}
@Override
public String getLibraryName() {
- return (rw ? "[READ-ONLY] " : "") + host + ":" + port;
+ return (rw ? "[READ-ONLY] " : "") + "fanfix://" + host + ":" + port;
}
@Override
public Status getStatus() {
- Instance.getInstance().getTraceHandler().trace("Getting remote lib status...");
+ Instance.getInstance().getTraceHandler()
+ .trace("Getting remote lib status...");
Status status = getStatusDo();
- Instance.getInstance().getTraceHandler().trace("Remote lib status: " + status);
+ Instance.getInstance().getTraceHandler()
+ .trace("Remote lib status: " + status);
return status;
}
@Override
public void action(ConnectActionClientObject action)
throws Exception {
- Object rep = action.send(new Object[] { subkey, "GET_COVER",
- luid });
+ Object rep = action
+ .send(new Object[] { subkey, "GET_COVER", luid });
result[0] = (Image) rep;
}
});
pg = new Progress();
}
- Object rep = action.send(new Object[] { subkey, "GET_STORY",
- luid });
+ Object rep = action
+ .send(new Object[] { subkey, "GET_STORY", luid });
MetaData meta = null;
if (rep instanceof MetaData) {
// Could work (more slowly) without it
public MetaData 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);
}
throws Exception {
Progress pg = pgF;
- Object rep = action.send(new Object[] { subkey, "IMPORT",
- url.toString() });
+ Object rep = action.send(
+ new Object[] { subkey, "IMPORT", url.toString() });
while (true) {
if (!RemoteLibraryServer.updateProgress(pg, rep)) {
* Stop the server.
*
* @throws IOException
- * in case of I/O error (including bad key)
+ * in case of I/O errors
+ * @throws SSLException
+ * when the key was not accepted
*/
- public void exit() throws IOException {
+ public void exit() throws IOException, SSLException {
connectRemoteAction(new RemoteAction() {
@Override
public void action(ConnectActionClientObject action)
pg = new Progress();
}
- Object rep = action.send(new Object[] { subkey, "GET_METADATA",
- luid });
+ Object rep = action
+ .send(new Object[] { subkey, "GET_METADATA", luid });
while (true) {
if (!RemoteLibraryServer.updateProgress(pg, rep)) {