From a24158031124ee631be0aa7bfda1a68a736fd625 Mon Sep 17 00:00:00 2001 From: Randy Baumgarte Date: Tue, 20 Mar 2012 11:29:07 -0400 Subject: [PATCH] Add --sync-only option --- src/cx/fbn/nevernote/Global.java | 3 +++ src/cx/fbn/nevernote/NeverNote.java | 15 +++++++++++++++ src/cx/fbn/nevernote/config/StartupConfig.java | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/src/cx/fbn/nevernote/Global.java b/src/cx/fbn/nevernote/Global.java index d7b7491..e563e46 100644 --- a/src/cx/fbn/nevernote/Global.java +++ b/src/cx/fbn/nevernote/Global.java @@ -182,12 +182,15 @@ public class Global { static Calendar startTraceTime; static Calendar intervalTraceTime; + static boolean syncOnly; + private static FileManager fileManager; // Used to access files & directories // Do initial setup public static void setup(StartupConfig startupConfig) throws InitializationException { settings = new QSettings("fbn.cx", startupConfig.getName()); disableViewing = startupConfig.getDisableViewing(); + syncOnly = startupConfig.isSyncOnly(); fileManager = new FileManager(startupConfig.getHomeDirPath(), startupConfig.getProgramDirPath()); diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index f9df752..53f5607 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -817,6 +817,18 @@ public class NeverNote extends QMainWindow{ } 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()) @@ -976,8 +988,11 @@ public class NeverNote extends QMainWindow{ startupConfig.setHomeDirPath(arg.substring(arg.indexOf('=') + 1)); if (lower.startsWith("--disable-viewing")) startupConfig.setDisableViewing(true); + if (lower.startsWith("--sync-only")) + startupConfig.setSyncOnly(true); } Global.setup(startupConfig); + } // Exit point diff --git a/src/cx/fbn/nevernote/config/StartupConfig.java b/src/cx/fbn/nevernote/config/StartupConfig.java index 07e8d0e..cf936a2 100644 --- a/src/cx/fbn/nevernote/config/StartupConfig.java +++ b/src/cx/fbn/nevernote/config/StartupConfig.java @@ -16,6 +16,7 @@ public class StartupConfig { private String homeDirPath; private String programDirPath; private boolean disableViewing = false; + private boolean syncOnly = false; public String getName() { @@ -76,4 +77,11 @@ public class StartupConfig { return n != null && !n.trim().equals(""); } + public boolean isSyncOnly() { + return syncOnly; + } + + public void setSyncOnly(boolean val) { + syncOnly = val; + } } -- 2.11.0