// Main entry point
public static void main(String[] args) {
log.setLevel(Level.FATAL);
QApplication.initialize(args);
QPixmap pixmap = new QPixmap("classpath:cx/fbn/nevernote/icons/splash_logo.png");
QSplashScreen splash = new QSplashScreen(pixmap);
boolean showSplash;
DatabaseConnection dbConn;
try {
initializeGlobalSettings(args);
showSplash = Global.isWindowVisible("SplashScreen");
if (showSplash)
splash.show();
dbConn = setupDatabaseConnection();
// Must be last stage of setup - only safe once DB is open hence we know we are the only instance running
Global.getFileManager().purgeResDirectory(true);
} catch (InitializationException e) {
// Fatal
e.printStackTrace();
QMessageBox.critical(null, "Startup error", "Aborting: " + e.getMessage());
return;
}
// Setup proxy crap
String proxyUrl = Global.getProxyValue("url");
String proxyPort = Global.getProxyValue("port");
String proxyUserid = Global.getProxyValue("userid");
String proxyPassword = Global.getProxyValue("password");
boolean proxySet = false;
QNetworkProxy proxy = new QNetworkProxy();
proxy.setType(ProxyType.HttpProxy);
if (!proxyUrl.trim().equals("")) {
System.out.println("Proxy URL found: " +proxyUrl);
proxySet = true;
proxy.setHostName(proxyUrl);
}
if (!proxyPort.trim().equals("")) {
System.out.println("Proxy Port found: " +proxyPort);
proxySet = true;
proxy.setPort(Integer.parseInt(proxyPort));
}
if (!proxyUserid.trim().equals("")) {
System.out.println("Proxy Userid found: " +proxyUserid);
proxySet = true;
proxy.setUser(proxyUserid);
}
if (!proxyPassword.trim().equals("")) {
System.out.println("Proxy URL found: " +proxyPassword);
proxySet = true;
proxy.setPassword(proxyPassword);
}
if (proxySet) {
QNetworkProxy.setApplicationProxy(proxy);
}
NeverNote application = new NeverNote(dbConn);
if (Global.syncOnly) {
System.out.println("Performing synchronization only.");
application.remoteConnect();
if (Global.isConnected) {
application.syncRunner.syncNeeded = true;
application.syncRunner.addWork("SYNC");
application.syncRunner.addWork("STOP");
while(!application.syncRunner.isIdle());
application.closeNeverNote();
}
return;
}
application.setAttribute(WidgetAttribute.WA_DeleteOnClose, true);
if (Global.startMinimized())
application.showMinimized();
else {
if (Global.wasWindowMaximized())
application.showMaximized();
else
application.show();
}
if (showSplash)
splash.finish(application);
QApplication.exec();
System.out.println("Goodbye.");
QApplication.exit();
}