import java.util.ArrayList;
import java.util.List;
+import javax.net.ssl.SSLException;
+
import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Story;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.Progress;
-import be.nikiroo.utils.Version;
import be.nikiroo.utils.serial.server.ConnectActionClientObject;
/**
Instance.getTraceHandler().trace("Getting remote lib status...");
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
- try {
- Object rep = send(new Object[] { "PING" });
-
- if ("PONG".equals(rep)) {
- result[0] = Status.READY;
- } else {
- result[0] = Status.UNAUTORIZED;
- }
- } catch (IllegalArgumentException e) {
+ public void action() throws Exception {
+ Object rep = send(new Object[] { "PING" });
+
+ if ("PONG".equals(rep)) {
+ result[0] = Status.READY;
+ } else {
result[0] = Status.UNAUTORIZED;
}
}
@Override
protected void onError(Exception e) {
- result[0] = Status.UNAVAILABLE;
+ if (e instanceof SSLException) {
+ result[0] = Status.UNAUTORIZED;
+ } else {
+ result[0] = Status.UNAVAILABLE;
+ }
}
}.connect();
} catch (UnknownHostException e) {
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
Object rep = send(new Object[] { "GET_COVER", luid });
result[0] = (Image) rep;
}
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (Exception e) {
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
Object rep = send(new Object[] { "GET_CUSTOM_COVER", type,
source });
result[0] = (Image) rep;
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (Exception e) {
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
Progress pg = pgF;
if (pg == null) {
pg = new Progress();
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (Exception e) {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
Progress pg = pgF;
if (story.getMeta().getWords() <= Integer.MAX_VALUE) {
pg.setMinMax(0, (int) story.getMeta().getWords());
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
public synchronized void delete(final String luid) throws IOException {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
send(new Object[] { "DELETE_STORY", luid });
}
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
}
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
send(new Object[] { "SET_COVER", type, value, luid });
}
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (IOException e) {
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
Progress pg = pgF;
Object rep = send(new Object[] { "IMPORT", url.toString() });
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (IOException e) {
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
Progress pg = pgF;
Object rep = send(new Object[] { "CHANGE_STA", luid,
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (IOException e) {
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
send(new Object[] { "EXIT" });
}
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (IOException e) {
try {
new ConnectActionClientObject(host, port, key) {
@Override
- public void action(Version serverVersion) throws Exception {
+ public void action() throws Exception {
Progress pg = pgF;
if (pg == null) {
pg = new Progress();
@Override
protected void onError(Exception e) {
- Instance.getTraceHandler().error(e);
+ if (e instanceof SSLException) {
+ Instance.getTraceHandler().error(
+ "Connection refused (bad key)");
+ } else {
+ Instance.getTraceHandler().error(e);
+ }
}
}.connect();
} catch (Exception e) {