OSDN Git Service

Correct problem parsing notes where carriage returns did not separate some XML lines...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / Global.java
index 3a124b5..0090c4d 100644 (file)
@@ -28,7 +28,6 @@ import java.util.ArrayList;
 import java.util.Calendar;\r
 import java.util.HashMap;\r
 import java.util.List;\r
-import java.util.concurrent.ArrayBlockingQueue;\r
 \r
 import com.evernote.edam.type.Accounting;\r
 import com.evernote.edam.type.PrivilegeLevel;\r
@@ -47,39 +46,31 @@ import cx.fbn.nevernote.gui.ShortcutKeys;
 import cx.fbn.nevernote.utilities.ApplicationLogger;\r
 \r
 public class Global {\r
-       public static String version = "0.88";\r
+       public static String version = "0.90";\r
     public static String username = ""; \r
     public static String password = "";     \r
     \r
-    public static int mainThreadId=0;\r
-    private static ArrayBlockingQueue<Boolean> mainThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+\r
+    public static final int mainThreadId=0;\r
     \r
-    public static int syncThreadId=1;\r
-    private static ArrayBlockingQueue<Boolean> syncThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int syncThreadId=1;\r
     \r
-    public static int tagCounterThreadId=2;\r
-    private static ArrayBlockingQueue<Boolean> tagCounterThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int tagCounterThreadId=2;\r
     \r
-    public static int trashCounterThreadId=3;   // This should always be the highest thread ID\r
-    private static ArrayBlockingQueue<Boolean> trashCounterThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int trashCounterThreadId=3;   // This should always be the highest thread ID\r
 \r
-    public static int indexThreadId=4;         // Thread for indexing words\r
-    private static ArrayBlockingQueue<Boolean> indexThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int indexThreadId=4;           // Thread for indexing words\r
 \r
-    public static int saveThreadId=5;          // Thread used for processing data to saving content\r
-    private static ArrayBlockingQueue<Boolean> saveThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int saveThreadId=5;    // Thread used for processing data to saving content\r
 \r
-    public static int notebookCounterThreadId=6;   // Notebook Thread\r
-    private static ArrayBlockingQueue<Boolean> notebookCounterThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int notebookCounterThreadId=6;   // Notebook Thread\r
 \r
-    public static int indexThread03Id=7;   // unused\r
-    private static ArrayBlockingQueue<Boolean> indexThread03ThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int indexThread03Id=7;   // unused\r
 \r
-    public static int indexThread04Id=8;   // unused\r
-    private static ArrayBlockingQueue<Boolean> indexThread04ThreadWaiter = new ArrayBlockingQueue<Boolean>(1);\r
+    public static final int indexThread04Id=8;   // unused\r
+    \r
+    public static final int dbThreadId=9;   // This should always be the highest thread ID\r
     \r
-    public static int dbThreadId=9;   // This should always be the highest thread ID\r
-\r
     \r
     public static HashMap<String,String> passwordSafe = new HashMap<String, String>();\r
     public static List<String> passwordRemember = new ArrayList<String>();\r
@@ -121,14 +112,11 @@ public class Global {
        public static String attachmentNameDelimeter = "------";\r
        \r
        public static String    databaseName = new String("NeverNote");\r
-       public static String    indexDatabaseName = new String("IndexDatabase.db");\r
        public static DateAttributeFilterTable createdSinceFilter;\r
        public static DateAttributeFilterTable createdBeforeFilter;\r
        public static DateAttributeFilterTable changedSinceFilter;\r
        public static DateAttributeFilterTable changedBeforeFilter;\r
        public static ContainsAttributeFilterTable containsFilter;\r
-//     public static DBLock                            dbLock;\r
-//     public static DBLock                            indexLock;\r
        public static ApplicationLogger    logger;\r
        PrintStream stdoutStream;\r
        public static QPalette                          originalPalette;\r
@@ -151,14 +139,14 @@ public class Global {
         settings = new QSettings("fbn.cx", startupConfig.getName());\r
         disableViewing = startupConfig.getDisableViewing();\r
 \r
-        fileManager = new FileManager(startupConfig.getHomeDirPath());\r
+        fileManager = new FileManager(startupConfig.getHomeDirPath(), startupConfig.getProgramDirPath());\r
 \r
 \r
                        getServer();\r
                        settings.beginGroup("General");\r
                        String regex = (String) settings.value("regex", "[,\\s]+");\r
                        setWordRegex(regex);\r
-                       String wordString = settings.value("wordLength", "4").toString();\r
+                       String wordString = settings.value("minimumWordLength", "4").toString();\r
                        Integer wordLen = new Integer(wordString);\r
                        Global.minimumWordCount = wordLen;\r
                        settings.endGroup();\r
@@ -170,8 +158,6 @@ public class Global {
                        keepRunning = true;\r
                        disableUploads = disableUploads();\r
                        enableCarriageReturnFix = enableCarriageReturnFix();\r
-//                     dbLock = new DBLock();\r
-//                     indexLock = new DBLock();\r
                        logger = new ApplicationLogger("global.log");\r
                        shortcutKeys = new ShortcutKeys();\r
                        mimicEvernoteInterface = getMimicEvernoteInterface();\r
@@ -517,6 +503,23 @@ public class Global {
                        settings.setValue("pdfPreview", "false");\r
                settings.endGroup();\r
     }\r
+    public static boolean newNoteWithSelectedTags() {\r
+               settings.beginGroup("General");\r
+               String text = (String)settings.value("newNoteWithSelectedTags", "false");\r
+               settings.endGroup();\r
+               if (text.equalsIgnoreCase("true"))\r
+                       return true;\r
+               else\r
+                       return false;\r
+    }\r
+    public static void setNewNoteWithSelectedTags(boolean val) {\r
+               settings.beginGroup("General");\r
+               if (val)\r
+                       settings.setValue("newNoteWithSelectedTags", "true");\r
+               else\r
+                       settings.setValue("newNoteWithSelectedTags", "false");\r
+               settings.endGroup();\r
+    }\r
     public static void setMinimumWordLength(int len) {\r
                settings.beginGroup("General");\r
                settings.setValue("minimumWordLength", len);\r
@@ -898,72 +901,6 @@ public class Global {
                settings.endGroup();\r
     }\r
     \r
-    public static void dbWait() {\r
- //    Global.dbThreadWait.wait(Global.dbThreadWaitMutex);\r
-    }\r
-    public static void dbContinue() {\r
-//     Global.dbThreadWait.wakeAll();\r
-    }\r
-       \r
-    public static synchronized void dbClientWait(int id) {\r
-       if (id == mainThreadId) {\r
-                       try {mainThreadWaiter.take(); } catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == syncThreadId) {\r
-                       try {syncThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == tagCounterThreadId) {\r
-               try {tagCounterThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == trashCounterThreadId) {\r
-               try {trashCounterThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == indexThreadId) {\r
-               try {indexThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == saveThreadId) {\r
-               try {saveThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == notebookCounterThreadId) {\r
-               try {notebookCounterThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == indexThread03Id) {\r
-               try {indexThread03ThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-       if (id == indexThread04Id) {\r
-               try {indexThread04ThreadWaiter.take();} catch (InterruptedException e) {e.printStackTrace();}\r
-       }\r
-    }\r
-    public static void dbClientContinue(int id) {\r
-       if (id == mainThreadId) {\r
-                       try { mainThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-       }\r
-       if (id == syncThreadId) {\r
-                       try { syncThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-       }\r
-               if (id == tagCounterThreadId) { \r
-                       try { tagCounterThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == trashCounterThreadId) { \r
-                       try { trashCounterThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == indexThreadId) { \r
-                       try { indexThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == saveThreadId) { \r
-                       try { saveThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == notebookCounterThreadId) { \r
-                       try { notebookCounterThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == indexThread03Id) { \r
-                       try { indexThread03ThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-               if (id == indexThread04Id) { \r
-                       try { indexThread04ThreadWaiter.put(true); } catch (InterruptedException e) { e.printStackTrace();}\r
-               }\r
-    }\r
-    \r
     public static void saveState(String name, QByteArray state) {\r
                settings.beginGroup("SaveState");\r
                settings.setValue(name, state);\r