OSDN Git Service

Add --sync-only option
authorRandy Baumgarte <randy@fbn.cx>
Tue, 20 Mar 2012 15:29:07 +0000 (11:29 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Tue, 20 Mar 2012 15:29:07 +0000 (11:29 -0400)
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/config/StartupConfig.java

index d7b7491..e563e46 100644 (file)
@@ -182,12 +182,15 @@ public class Global {
        static Calendar startTraceTime;   \r
        static Calendar intervalTraceTime;\r
        \r
+       static boolean syncOnly;\r
+       \r
        private static FileManager fileManager;  // Used to access files & directories\r
        \r
     // Do initial setup \r
     public static void setup(StartupConfig startupConfig) throws InitializationException  {\r
         settings = new QSettings("fbn.cx", startupConfig.getName());\r
         disableViewing = startupConfig.getDisableViewing();\r
+        syncOnly = startupConfig.isSyncOnly();\r
 \r
         fileManager = new FileManager(startupConfig.getHomeDirPath(), startupConfig.getProgramDirPath());\r
 \r
index f9df752..53f5607 100644 (file)
@@ -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
index 07e8d0e..cf936a2 100644 (file)
@@ -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;
+    }
 }