git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix remote save, better GUI if bad import url
[fanfix.git]
/
src
/
be
/
nikiroo
/
fanfix
/
Main.java
diff --git
a/src/be/nikiroo/fanfix/Main.java
b/src/be/nikiroo/fanfix/Main.java
index 813a9b40320758e42a4244778b5c86971cc95137..671778e60dff4aba78b66a66666be8e285a06653 100644
(file)
--- a/
src/be/nikiroo/fanfix/Main.java
+++ b/
src/be/nikiroo/fanfix/Main.java
@@
-24,8
+24,8
@@
import be.nikiroo.fanfix.supported.BasicSupport;
import be.nikiroo.fanfix.supported.BasicSupport.SupportType;
import be.nikiroo.utils.Progress;
import be.nikiroo.utils.Version;
import be.nikiroo.fanfix.supported.BasicSupport.SupportType;
import be.nikiroo.utils.Progress;
import be.nikiroo.utils.Version;
-import be.nikiroo.utils.serial.
ConnectActionClien
t;
-import be.nikiroo.utils.serial.
Server
;
+import be.nikiroo.utils.serial.
server.ConnectActionClientObjec
t;
+import be.nikiroo.utils.serial.
server.ServerObject
;
/**
* Main program entry point.
/**
* Main program entry point.
@@
-98,8
+98,9
@@
public class Main {
action = MainAction.valueOf(args[i].substring(2)
.toUpperCase().replace("-", "_"));
} catch (Exception e) {
action = MainAction.valueOf(args[i].substring(2)
.toUpperCase().replace("-", "_"));
} catch (Exception e) {
- Instance.syserr(new IllegalArgumentException(
- "Unknown action: " + args[i], e));
+ Instance.getTraceHandler().error(
+ new IllegalArgumentException("Unknown action: "
+ + args[i], e));
exitCode = 255;
}
}
exitCode = 255;
}
}
@@
-272,8
+273,9
@@
public class Main {
break;
case LIST:
if (BasicReader.getReader() == null) {
break;
case LIST:
if (BasicReader.getReader() == null) {
- Instance.syserr(new Exception(
- "No reader type has been configured"));
+ Instance.getTraceHandler()
+ .error(new Exception(
+ "No reader type has been configured"));
exitCode = 10;
break;
}
exitCode = 10;
break;
}
@@
-281,8
+283,9
@@
public class Main {
break;
case READ:
if (BasicReader.getReader() == null) {
break;
case READ:
if (BasicReader.getReader() == null) {
- Instance.syserr(new Exception(
- "No reader type has been configured"));
+ Instance.getTraceHandler()
+ .error(new Exception(
+ "No reader type has been configured"));
exitCode = 10;
break;
}
exitCode = 10;
break;
}
@@
-290,8
+293,9
@@
public class Main {
break;
case READ_URL:
if (BasicReader.getReader() == null) {
break;
case READ_URL:
if (BasicReader.getReader() == null) {
- Instance.syserr(new Exception(
- "No reader type has been configured"));
+ Instance.getTraceHandler()
+ .error(new Exception(
+ "No reader type has been configured"));
exitCode = 10;
break;
}
exitCode = 10;
break;
}
@@
-314,8
+318,9
@@
public class Main {
break;
case START:
if (BasicReader.getReader() == null) {
break;
case START:
if (BasicReader.getReader() == null) {
- Instance.syserr(new Exception(
- "No reader type has been configured"));
+ Instance.getTraceHandler()
+ .error(new Exception(
+ "No reader type has been configured"));
exitCode = 10;
break;
}
exitCode = 10;
break;
}
@@
-327,11
+332,11
@@
public class Main {
break;
}
try {
break;
}
try {
- Server server = new RemoteLibraryServer(key, port);
+ ServerObject server = new RemoteLibraryServer(key, port);
+ server.setTraceHandler(Instance.getTraceHandler());
server.start();
server.start();
- System.out.println("Remote server started on: " + port);
} catch (IOException e) {
} catch (IOException e) {
- Instance.
syser
r(e);
+ Instance.
getTraceHandler().erro
r(e);
}
return;
case STOP_SERVER:
}
return;
case STOP_SERVER:
@@
-342,19
+347,19
@@
public class Main {
try {
final String fkey = key;
try {
final String fkey = key;
- new ConnectActionClient(host, port, true) {
+ new ConnectActionClient
Object
(host, port, true) {
@Override
public void action(Version serverVersion)
throws Exception {
try {
send(new Object[] { fkey, "EXIT" });
} catch (Exception e) {
@Override
public void action(Version serverVersion)
throws Exception {
try {
send(new Object[] { fkey, "EXIT" });
} catch (Exception e) {
- Instance.
syser
r(e);
+ Instance.
getTraceHandler().erro
r(e);
}
}
}.connect();
} catch (IOException e) {
}
}
}.connect();
} catch (IOException e) {
- Instance.
syser
r(e);
+ Instance.
getTraceHandler().erro
r(e);
}
break;
case REMOTE:
}
break;
case REMOTE:
@@
-389,7
+394,7
@@
public class Main {
System.out.println(story.getMeta().getLuid() + ": \""
+ story.getMeta().getTitle() + "\" imported.");
} catch (IOException e) {
System.out.println(story.getMeta().getLuid() + ": \""
+ story.getMeta().getTitle() + "\" imported.");
} catch (IOException e) {
- Instance.
syser
r(e);
+ Instance.
getTraceHandler().erro
r(e);
return 1;
}
return 1;
}
@@
-415,15
+420,15
@@
public class Main {
Progress pg) {
OutputType type = OutputType.valueOfNullOkUC(typeString, null);
if (type == null) {
Progress pg) {
OutputType type = OutputType.valueOfNullOkUC(typeString, null);
if (type == null) {
- Instance.
syserr(new Exception(trans(StringId.OUTPUT_DESC,
- typeString)));
+ Instance.
getTraceHandler().error(
+
new Exception(trans(StringId.OUTPUT_DESC,
typeString)));
return 1;
}
try {
Instance.getLibrary().export(luid, type, target, pg);
} catch (IOException e) {
return 1;
}
try {
Instance.getLibrary().export(luid, type, target, pg);
} catch (IOException e) {
- Instance.
syser
r(e);
+ Instance.
getTraceHandler().erro
r(e);
return 4;
}
return 4;
}
@@
-485,15
+490,16
@@
public class Main {
reader.setChapter(Integer.parseInt(chapString));
reader.read();
} catch (NumberFormatException e) {
reader.setChapter(Integer.parseInt(chapString));
reader.read();
} catch (NumberFormatException e) {
- Instance.syserr(new IOException(
- "Chapter number cannot be parsed: " + chapString, e));
+ Instance.getTraceHandler().error(
+ new IOException("Chapter number cannot be parsed: "
+ + chapString, e));
return 2;
}
} else {
reader.read();
}
} catch (IOException e) {
return 2;
}
} else {
reader.read();
}
} catch (IOException e) {
- Instance.
syser
r(e);
+ Instance.
getTraceHandler().erro
r(e);
return 1;
}
return 1;
}
@@
-531,8
+537,9
@@
public class Main {
OutputType type = OutputType.valueOfAllOkUC(typeString, null);
if (type == null) {
OutputType type = OutputType.valueOfAllOkUC(typeString, null);
if (type == null) {
- Instance.syserr(new IOException(trans(
- StringId.ERR_BAD_OUTPUT_TYPE, typeString)));
+ Instance.getTraceHandler().error(
+ new IOException(trans(StringId.ERR_BAD_OUTPUT_TYPE,
+ typeString)));
exitCode = 2;
} else {
exitCode = 2;
} else {
@@
-554,25
+561,29
@@
public class Main {
BasicOutput.getOutput(type, infoCover).process(
story, target, pgOut);
} catch (IOException e) {
BasicOutput.getOutput(type, infoCover).process(
story, target, pgOut);
} catch (IOException e) {
- Instance.syserr(new IOException(trans(
- StringId.ERR_SAVING, target), e));
+ Instance.getTraceHandler().error(
+ new IOException(trans(StringId.ERR_SAVING,
+ target), e));
exitCode = 5;
}
} else {
exitCode = 5;
}
} else {
- Instance.syserr(new IOException(trans(
- StringId.ERR_NOT_SUPPORTED, source)));
+ Instance.getTraceHandler().error(
+ new IOException(trans(
+ StringId.ERR_NOT_SUPPORTED, source)));
exitCode = 4;
}
} catch (IOException e) {
exitCode = 4;
}
} catch (IOException e) {
- Instance.syserr(new IOException(trans(StringId.ERR_LOADING,
- sourceName), e));
+ Instance.getTraceHandler().error(
+ new IOException(trans(StringId.ERR_LOADING,
+ sourceName), e));
exitCode = 3;
}
}
} catch (MalformedURLException e) {
exitCode = 3;
}
}
} catch (MalformedURLException e) {
- Instance.syserr(new IOException(trans(StringId.ERR_BAD_URL,
- sourceName), e));
+ Instance.getTraceHandler()
+ .error(new IOException(trans(StringId.ERR_BAD_URL,
+ sourceName), e));
exitCode = 1;
}
exitCode = 1;
}
@@
-638,8
+649,9
@@
public class Main {
BasicReader.setDefaultReaderType(readerType);
return 0;
} catch (IllegalArgumentException e) {
BasicReader.setDefaultReaderType(readerType);
return 0;
} catch (IllegalArgumentException e) {
- Instance.syserr(new IOException("Unknown reader type: "
- + readerTypeString, e));
+ Instance.getTraceHandler().error(
+ new IOException("Unknown reader type: " + readerTypeString,
+ e));
return 1;
}
}
return 1;
}
}