OSDN Git Service

Merge branch 'master' of ssh://nevernote.git.sourceforge.net/gitroot/nevernote/nevern...
authorRandy Baumgarte <randy@fbn.cx>
Sun, 27 May 2012 20:51:31 +0000 (16:51 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 27 May 2012 20:51:31 +0000 (16:51 -0400)
35 files changed:
.classpath
.gitignore
README.txt
build.xml
lib/scribe-1.3.0.jar [new file with mode: 0644]
nixnote-osx
nixnote.bat
nixnote.sh
shortcuts_howto.txt
shortcuts_sample.txt
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/config/StartupConfig.java
src/cx/fbn/nevernote/dialog/ConfigAppearancePage.java
src/cx/fbn/nevernote/dialog/ConfigConnectionPage.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java
src/cx/fbn/nevernote/dialog/LoginDialog.java [deleted file]
src/cx/fbn/nevernote/gui/ColorMenu.java
src/cx/fbn/nevernote/gui/MainMenuBar.java
src/cx/fbn/nevernote/gui/NoteTableModel.java
src/cx/fbn/nevernote/gui/ShortcutKeys.java
src/cx/fbn/nevernote/oauth/NNOAuthNetworkAccessManager.java [new file with mode: 0644]
src/cx/fbn/nevernote/oauth/OAuthTokenizer.java [new file with mode: 0644]
src/cx/fbn/nevernote/oauth/OAuthWindow.java [new file with mode: 0644]
src/cx/fbn/nevernote/sql/NoteResourceTable.java
src/cx/fbn/nevernote/sql/NoteTable.java
src/cx/fbn/nevernote/sql/NoteTagsTable.java
src/cx/fbn/nevernote/sql/NotebookTable.java
src/cx/fbn/nevernote/sql/REnSearch.java
src/cx/fbn/nevernote/threads/IndexRunner.java
src/cx/fbn/nevernote/threads/SyncRunner.java
src/cx/fbn/nevernote/utilities/AESEncrypter.java
src/cx/fbn/nevernote/utilities/ListManager.java
src/cx/fbn/nevernote/xml/ImportData.java
src/cx/fbn/nevernote/xml/ImportEnex.java

index 5240e15..4472bf0 100644 (file)
@@ -8,8 +8,8 @@
        <classpathentry kind="lib" path="lib/log4j-1.2.14.jar"/>\r
        <classpathentry kind="lib" path="lib/commons-lang3-3.0.jar"/>\r
        <classpathentry kind="lib" path="lib/jtidy-r938.jar"/>\r
-       <classpathentry kind="var" path="QT_JAMBI/qtjambi-4.5.0_01.jar"/>\r
-       <classpathentry kind="var" path="QT_JAMBI/qtjambi-win32-msvc2005-4.5.0_01.jar"/>\r
+       <classpathentry kind="var" path="QT_JAMBI/qtjambi-4.5.2_01.jar"/>\r
+       <classpathentry kind="var" path="QT_JAMBI/qtjambi-win32-msvc2005-4.5.2_01.jar"/>\r
        <classpathentry kind="lib" path="lib/poi-scratchpad-3.7-20101029.jar"/>\r
        <classpathentry kind="lib" path="lib/poi-3.7-20101029.jar"/>\r
        <classpathentry kind="lib" path="lib/poi-ooxml-schemas-3.7-20101029.jar"/>\r
@@ -27,5 +27,6 @@
        <classpathentry kind="lib" path="lib/httpcore-4.1.jar"/>\r
        <classpathentry kind="lib" path="lib/httpmime-4.1.1.jar"/>\r
        <classpathentry kind="lib" path="lib/pdfbox-app-1.6.0.jar"/>\r
+       <classpathentry kind="lib" path="C:/repository/nevernote/nixnote/lib/scribe-1.3.0.jar"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
index cecbbea..6c3ab6e 100644 (file)
 
 # Ignore compilation results - no need for these to be under source control
 *.class
+
+#meta files & Eclipse files
+/.metadata/
+/*.classpath
+
+#Local platform binaries
+/lib/*.dll
index 9277c47..d6fdbf8 100644 (file)
@@ -1,6 +1,6 @@
 NixNote:: Evernote client clone for Linux, Mac OS X and Windows 
 
-    Copyright 2009-2010, Randy Baumgarte 
+    Copyright 2009-2012, Randy Baumgarte 
     Licensed under GNU General Public Lisence version 2
 
 This is an incomplete clone of Evernote designed to run on Linux. 
index 5ea02bb..2dca043 100644 (file)
--- a/build.xml
+++ b/build.xml
       <pathelement location="${lib.dir}/poi-ooxml-3.7.jar"/>
       <pathelement location="${lib.dir}/poi-ooxml-schemas-3.7-20101029.jar"/>
       <pathelement location="${lib.dir}/poi-scratchpad-3.7-20101029.jar"/>
+      <pathelement location="${lib.dir}/scribe-1.3.0.jar"/>
       <pathelement location="${lib.dir}/tika.jar"/>
       <pathelement location="${lib.dir}/xmlbeans-2.3.0.jar"/>
       <pathelement location="${lib.dir}/xsdlib-20060615.jar"/>
diff --git a/lib/scribe-1.3.0.jar b/lib/scribe-1.3.0.jar
new file mode 100644 (file)
index 0000000..b49765d
Binary files /dev/null and b/lib/scribe-1.3.0.jar differ
index d4544e5..18a1cd9 100644 (file)
@@ -106,6 +106,7 @@ NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/poi-3.7-20101029.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/poi-ooxml-3.7.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/poi-ooxml-schemas-3.7-20101029.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/poi-scratchpad-3.7-20101029.jar
+NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/scribe-1.3.0.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/tika.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/xmlbeans-2.3.0.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/xsdlib-20060615.jar
@@ -118,7 +119,7 @@ NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/qtjambi-macosx-gcc-4.5.2_01.jar
 ###################
 cd $NIXNOTE
 
-java -Xmx$NN_XMX -Xms$NN_XMS -XX:NewRatio=$NN_NEW_RATIO $NN_GC_OPT $NN_DEBUG -classpath $NN_CLASSPATH cx.fbn.nevernote.NeverNote --name=$NN_NAME -XstartOnFirstThread -d32 -client
+java -Xmx$NN_XMX -Xms$NN_XMS -XX:NewRatio=$NN_NEW_RATIO $NN_GC_OPT $NN_DEBUG -classpath $NN_CLASSPATH cx.fbn.nevernote.NeverNote --sync-only=$NN_SYNCONLY --home=$NN_HOME --name=$NN_NAME -XstartOnFirstThread -d32 -client
 
 cd -
 
index 9dfa657..c2a79f0 100644 (file)
@@ -66,6 +66,7 @@ rem #################################################################
 IF "%1"=="" GOTO Continue\r
 if "%1" == "NN_NAME" set NN_NAME=%2\r
 if "%1" == "NN_HOME" set NN_HOME=%2\r
+if "%1" == "NN_SYNCONLY" set NN_SYNCONLY=%2\r
 if "%1" == "NN_GC_OPT" set NN_GC_OPT=%2\r
 if "%1" == "NN_DEBUG" set NN_DEBUG=%2\r
 shift \r
@@ -98,6 +99,7 @@ set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\poi-3.7-20101029.jar
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\poi-ooxml-3.7.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\poi-ooxml-schemas-3.7-20101029.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\poi-scratchpad-3.7-20101029.jar\r
+set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\scribe-1.3.0.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\tika.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\xmlbeans-2.3.0.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\xsdlib-20060615.jar\r
@@ -113,5 +115,5 @@ rem set NN_CLASSPATH="%NN_CLASSPATH%"
 \r
 rem java -Xmx%NN_XMX% -Xms%NN_XMS%  -XX:NewRatio=%NN_NEW_RATIO% %NN_GC_OPT% %NN_DEBUG%  -classpath "%NN_CLASSPATH%" cx.fbn.nevernote.NeverNote --name=%NN_NAME%\r
 \r
-start /B javaw -Xmx%NN_XMX% -Xms%NN_XMS%  -XX:NewRatio=%NN_NEW_RATIO% %NN_GC_OPT% %NN_DEBUG%  -classpath "%NN_CLASSPATH%" cx.fbn.nevernote.NeverNote --name=%NN_NAME% --home=%NN_HOME%\r
+start /B javaw -Xmx%NN_XMX% -Xms%NN_XMS%  -XX:NewRatio=%NN_NEW_RATIO% %NN_GC_OPT% %NN_DEBUG%  -classpath "%NN_CLASSPATH%" cx.fbn.nevernote.NeverNote --sync-only=%NN_SYNCONLY% --name=%NN_NAME% --home=%NN_HOME%\r
 exit\r
index 1f7a173..eefa460 100755 (executable)
@@ -96,6 +96,7 @@ NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/jazzy.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/jtidy-r938.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/libthrift.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/log4j-1.2.14.jar
+NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/scribe-1.3.0.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/pdfbox-app-1.6.0.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/poi-3.7-20101029.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/poi-ooxml-3.7.jar
@@ -114,5 +115,5 @@ NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/qtjambi-linux64-gcc-4.5.2_01.jar
 # Run the program #
 ###################
 cd $NIXNOTE
-java -Xmx$NN_XMX -Xms$NN_XMS -XX:NewRatio=$NN_NEW_RATIO $NN_GC_OPT $NN_DEBUG -classpath $NN_CLASSPATH cx.fbn.nevernote.NeverNote --name=$NN_NAME
+java -Xmx$NN_XMX -Xms$NN_XMS -XX:NewRatio=$NN_NEW_RATIO $NN_GC_OPT $NN_DEBUG -classpath $NN_CLASSPATH cx.fbn.nevernote.NeverNote --name=$NN_NAME --home=$NN_HOME --sync-only=$NN_SYNCONLY
 cd -
index 1050a57..6147761 100644 (file)
@@ -4,14 +4,15 @@ junk that entails.  So, I chose a text file config instead.  Eventually I
 may change it so the text file can be edited within the running program, but
 I have other things to spend my time on at the moment.
 
-First, you don't need to do this.  NeverNote comes with a default set of 
+First, you don't need to do this.  Nixnote comes with a default set of 
 shortcuts.  If you are happy with those then you don't need to do a thing.
 
 If you want to customize your shortcuts then you need to do a little work.
 
 You should have a shortcuts_sample.txt file.  Copy this to shortcuts.txt 
-in your NeverNote install directory.  This is the file that is read 
-when NeverNote starts.  Any changes to this file only happen at startup
+in your Nixnote home directory (~/.nevernote on Linux & OS-X and your user
+home directory on Windows).  This is the file that is read 
+when Nixnote starts.  Any changes to this file only happen at startup
 so if you change it you need to restart the program to see those changes.
 
 This file has three main columns.  
index 76ac529..270d224 100644 (file)
@@ -44,6 +44,7 @@ Edit_Delete_Table_Column                      // Delete a table row
 
 Edit_Insert_Hyperlink          Ctrl+K          // Insert a hyperlink (Popup menu)
 Edit_Insert_Todo                               // Insert a todo checkbox (Popup menu)
+Edit_Insert_QuickLink                          // Insert a quick link to another note (Popup menu)
 Edit_Encrypt_Text                              // Encrypt selected text (Popup menu)
 Edit_Insert_Table                              // Insert a table into a note (Popup menu)
 
index 59ebe87..2079f5b 100644 (file)
@@ -42,6 +42,7 @@ import com.trolltech.qt.core.QByteArray;
 import com.trolltech.qt.core.QSettings;\r
 import com.trolltech.qt.core.QSize;\r
 import com.trolltech.qt.gui.QPalette;\r
+import com.trolltech.qt.gui.QSystemTrayIcon;\r
 \r
 import cx.fbn.nevernote.config.FileManager;\r
 import cx.fbn.nevernote.config.InitializationException;\r
@@ -65,7 +66,7 @@ public class Global {
        public static String version = "1.2";\r
        public static String[] validVersions = {"1.2", "1.1", "1.0", "0.99", "0.98", "0.97", "0.96"};\r
     public static String username = ""; \r
-    public static String password = "";     \r
+    //public static String password = "";     \r
     \r
 \r
     // Each thread has an ID.  This is used primarily to check the status\r
@@ -182,12 +183,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
@@ -452,7 +456,7 @@ public class Global {
                try {\r
                        String max = (String) settings.value("showTrayIcon", "false");\r
                        settings.endGroup();\r
-                       if (!max.equalsIgnoreCase("true"))\r
+                       if (!max.equalsIgnoreCase("true") || !QSystemTrayIcon.isSystemTrayAvailable())\r
                                return false;\r
                        else\r
                                return true;    \r
@@ -602,31 +606,6 @@ public class Global {
                        settings.setValue("automaticLogin", "false");\r
                settings.endGroup();\r
     }\r
-    \r
-    // Should it save the Evernote password?\r
-    public static boolean rememberPassword() {\r
-       try {\r
-                       settings.beginGroup("General");\r
-                       String text = (String)settings.value("rememberPassword", "false");\r
-                       settings.endGroup();\r
-                       if (text.equalsIgnoreCase("true"))\r
-                               return true;\r
-                       else\r
-                               return false;   \r
-               } catch (java.lang.ClassCastException e) {\r
-                       Boolean value = (Boolean) settings.value("rememberPassword", false);\r
-                       settings.endGroup();\r
-                       return value;\r
-               }\r
-    }\r
-    public static void setRememberPassword(boolean val) {\r
-               settings.beginGroup("General");\r
-               if (val)\r
-                       settings.setValue("rememberPassword", "true");\r
-               else\r
-                       settings.setValue("rememberPassword", "false");\r
-               settings.endGroup();\r
-    }\r
 \r
     // Get/set the Evernote server Url.  \r
     public static void setServer(String server) {\r
@@ -1709,7 +1688,7 @@ public class Global {
                try {\r
                        String text = (String)settings.value("minimizeOnClose", "false");\r
                        settings.endGroup();\r
-                       if (text.equalsIgnoreCase("true"))\r
+                       if (text.equalsIgnoreCase("true") && QSystemTrayIcon.isSystemTrayAvailable())\r
                                return true;\r
                        else\r
                                return false;\r
@@ -2030,5 +2009,22 @@ public class Global {
                settings.setValue("displayRightToLeft", value);\r
                settings.endGroup();    \r
     }\r
+\r
+\r
+    //***********************\r
+    //* Startup Notebook\r
+    //***********************\r
+    public static String getStartupNotebook() {\r
+               settings.beginGroup("General");\r
+               String text = (String)settings.value("startupNotebook", "");\r
+               settings.endGroup();    \r
+               return text;\r
+    }\r
+    public static void setStartupNotebook(String value) {\r
+               settings.beginGroup("General");\r
+               settings.setValue("startupNotebook", value);\r
+               settings.endGroup();    \r
+               databaseCache = value;\r
+    }\r
 }\r
 \r
index 6e48319..af83947 100644 (file)
@@ -21,6 +21,7 @@ import java.awt.Desktop;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.security.MessageDigest;
@@ -148,7 +149,6 @@ import cx.fbn.nevernote.dialog.DatabaseStatus;
 import cx.fbn.nevernote.dialog.FindDialog;
 import cx.fbn.nevernote.dialog.IgnoreSync;
 import cx.fbn.nevernote.dialog.LogFileDialog;
-import cx.fbn.nevernote.dialog.LoginDialog;
 import cx.fbn.nevernote.dialog.NotebookArchive;
 import cx.fbn.nevernote.dialog.NotebookEdit;
 import cx.fbn.nevernote.dialog.OnlineNoteHistory;
@@ -180,6 +180,8 @@ import cx.fbn.nevernote.gui.TagTreeWidget;
 import cx.fbn.nevernote.gui.Thumbnailer;
 import cx.fbn.nevernote.gui.TrashTreeWidget;
 import cx.fbn.nevernote.gui.controls.QuotaProgressBar;
+import cx.fbn.nevernote.oauth.OAuthTokenizer;
+import cx.fbn.nevernote.oauth.OAuthWindow;
 import cx.fbn.nevernote.sql.DatabaseConnection;
 import cx.fbn.nevernote.sql.WatchFolderRecord;
 import cx.fbn.nevernote.threads.IndexRunner;
@@ -332,7 +334,7 @@ public class NeverNote extends QMainWindow{
     boolean                            encryptOnShutdown;                      // should I encrypt when I close?
     boolean                            decryptOnShutdown;                      // should I decrypt on shutdown;
     String                             encryptCipher;                          // What cipher should I use?
-    Signal0                    minimizeToTray;
+    //Signal0                  minimizeToTray;
     boolean                            windowMaximized = false;        // Keep track of the window state for restores
     List<String>               pdfReadyQueue;                          // Queue of PDFs that are ready to be rendered.
     List<QPixmap>              syncIcons;                                      // Array of icons used in sync animation
@@ -709,12 +711,14 @@ public class NeverNote extends QMainWindow{
         tagTree.showAllTags(true);
 
                QIcon appIcon = new QIcon(iconPath+"nevernote.png");
-       setWindowIcon(appIcon);
-       trayIcon.setIcon(appIcon);
-       if (Global.showTrayIcon())
-               trayIcon.show();
-       else
-               trayIcon.hide();
+               if (QSystemTrayIcon.isSystemTrayAvailable()) {
+                       setWindowIcon(appIcon);
+                       trayIcon.setIcon(appIcon);
+                       if (Global.showTrayIcon() || Global.minimizeOnClose())
+                               trayIcon.show();
+                       else
+                               trayIcon.hide();
+               }
        
        scrollToGuid(currentNoteGuid);
        if (Global.automaticLogin()) {
@@ -771,6 +775,18 @@ public class NeverNote extends QMainWindow{
                noteTableView.proxyModel.blocked = false;
                noteTableView.proxyModel.sortChanged.connect(this, "tableSortOrderChanged(Integer,Integer)");
                
+               // Set the startup notebook
+       String defaultNotebook = Global.getStartupNotebook();
+       if (!defaultNotebook.equals("AllNotebooks") && !defaultNotebook.equals("")) {
+               for (int k=0; k<listManager.getNotebookIndex().size(); k++) {
+                       if (listManager.getNotebookIndex().get(k).isDefaultNotebook()) {
+                               notebookTree.clearSelection();
+                               notebookTree.selectGuid(listManager.getNotebookIndex().get(k).getGuid());
+                               notebookTree.selectionSignal.emit();
+                       }
+               }
+       }
+               
                if (Global.checkVersionUpgrade())
                        checkForUpdates();
        }
@@ -805,6 +821,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()) 
@@ -964,14 +992,17 @@ 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=true"))
+                startupConfig.setSyncOnly(true);
         }
         Global.setup(startupConfig);
+        
     }
 
     // Exit point
        @Override
        public void closeEvent(QCloseEvent event) {     
-               if (Global.minimizeOnClose() && !closeAction && Global.showTrayIcon()) {
+               if (Global.minimizeOnClose() && !closeAction) {
                        event.ignore();
                        hide();
                        return;
@@ -1094,7 +1125,7 @@ public class NeverNote extends QMainWindow{
                logger.log(logger.HIGH, "Leaving NeverNote.closeEvent");
        }
 
-       @SuppressWarnings("unused")
+
        private void closeNeverNote() {
                closeAction = true;
                close();
@@ -1218,7 +1249,7 @@ public class NeverNote extends QMainWindow{
         indexRunner.indexNoteTitle = Global.indexNoteTitle();
         indexRunner.specialIndexCharacters = Global.getSpecialIndexCharacters();
         indexRunner.indexImageRecognition = Global.indexImageRecognition();
-        if (Global.showTrayIcon())
+        if (Global.showTrayIcon() || Global.minimizeOnClose())
                trayIcon.show();
         else
                trayIcon.hide();
@@ -2091,9 +2122,12 @@ public class NeverNote extends QMainWindow{
                                if (currentNote != null && currentNote.getTagGuids().contains(guid))
                                        browserWindow.setTag(getTagNamesForNote(currentNote));
                                logger.log(logger.HIGH, "Leaving NeverNote.editTag");
-                               return;
+                               //return;
                        }
                }
+               listManager.reloadNoteTagNames(guid, edit.getTag());
+               noteIndexUpdated(true);
+               refreshEvernoteNote(true);
                browserWindow.setTag(getTagNamesForNote(currentNote));
                logger.log(logger.HIGH, "Leaving NeverNote.editTag...");
        }
@@ -2719,11 +2753,12 @@ public class NeverNote extends QMainWindow{
                QMessageBox.about(this, 
                                                tr("About NixNote"),
                                                tr("<h4><center><b>NixNote</b></center></h4><hr><center>Version ")
-                                               +Global.version
+                                               //+Global.version
+                                               +"1.2.120508"
                                                +tr("<hr>"
                                                                +"Open Source Evernote Client.<br><br>" 
                                                                +"Licensed under GPL v2.  <br><hr><br>"
-                                                               +"</center>Evernote is copyright 2001-2010 by Evernote Corporation<br>"
+                                                               +"</center>Evernote is copyright 2001-2012 by Evernote Corporation<br>"
                                                                +"Jambi and QT are the licensed trademark of Nokia Corporation<br>"
                                                                +"PDFRenderer is licened under the LGPL<br>"
                                                                +"JTidy is copyrighted under the World Wide Web Consortium<br>"
@@ -3348,8 +3383,10 @@ public class NeverNote extends QMainWindow{
        }
        // Do a manual connect/disconnect
     private void remoteConnect() {
+       
        logger.log(logger.HIGH, "Entering NeverNote.remoteConnect");
 
+       // If we are already connected, we just disconnect
        if (Global.isConnected) {
                Global.isConnected = false;
                syncRunner.enDisconnect();
@@ -3358,13 +3395,15 @@ public class NeverNote extends QMainWindow{
                return;
        }
        
+       OAuthTokenizer tokenizer = new OAuthTokenizer();
        AESEncrypter aes = new AESEncrypter();
        try {
-                       aes.decrypt(new FileInputStream(Global.getFileManager().getHomeDirFile("secure.txt")));
+                       aes.decrypt(new FileInputStream(Global.getFileManager().getHomeDirFile("oauth.txt")));
                } catch (FileNotFoundException e) {
                        // File not found, so we'll just get empty strings anyway. 
                }
-
+       
+               
                if (Global.getProxyValue("url").equals("")) {
                        System.setProperty("http.proxyHost","") ;
                        System.setProperty("http.proxyPort", "") ;
@@ -3391,43 +3430,54 @@ public class NeverNote extends QMainWindow{
                syncRunner.userStoreUrl = Global.userStoreUrl;
                syncRunner.noteStoreUrl = Global.noteStoreUrl;
                syncRunner.noteStoreUrlBase = Global.noteStoreUrlBase;
-
-               String userid = aes.getUserid();
-               String password = aes.getPassword();
-               if (!userid.equals("") && !password.equals("")) {
-               Global.username = userid;
-               Global.password = password;
-                       syncRunner.username = Global.username;
-                       syncRunner.password = Global.password;
+               
+               
+               
+               String authString = aes.getString();
+               if (!authString.equals("")) {
+                       tokenizer.tokenize(authString);
+                       syncRunner.authToken = tokenizer.oauth_token;
                syncRunner.enConnect();
                }               
 
                Global.isConnected = syncRunner.isConnected;
                
                if (!Global.isConnected) {
-                       // Show the login dialog box
-                       if (!Global.automaticLogin() || userid.equals("")|| password.equals("")) {
-                               LoginDialog login = new LoginDialog();
-                               login.exec();
-               
-                               if (!login.okPressed()) {
-                                       return;
-                               }
-        
-                               Global.username = login.getUserid();
-                               Global.password = login.getPassword();
+               OAuthWindow window = new OAuthWindow(logger);
+               if (window.error) {
+                       setMessage(window.errorMessage);
+                       return;
+               }
+               window.exec();
+               if (window.error) {
+                       setMessage(window.errorMessage);
+                       return;
+                       }
+               tokenizer.tokenize(window.response);
+               if (tokenizer.oauth_token.equals("")) {
+                       setMessage(tr("Invalid authorization token received."));
+                       return;
+               }
+               aes.setString(window.response);
+               try {
+                               aes.encrypt(new FileOutputStream(Global.getFileManager().getHomeDirFile("oauth.txt")));
+                       } catch (FileNotFoundException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
                        }
-                       syncRunner.username = Global.username;
-                       syncRunner.password = Global.password;
+               syncRunner.authToken = tokenizer.oauth_token;
                        syncRunner.enConnect();
                        Global.isConnected = syncRunner.isConnected;
                }
-               
+               Global.username = syncRunner.username;
+                       
                if (!Global.isConnected)
                        return;
                setupOnlineMenu();
                setupConnectMenuOptions();
                logger.log(logger.HIGH, "Leaving NeverNote.remoteConnect");
+
+
     }
     private void setupConnectMenuOptions() {
        logger.log(logger.HIGH, "entering NeverNote.setupConnectMenuOptions");
@@ -4827,6 +4877,15 @@ public class NeverNote extends QMainWindow{
     @SuppressWarnings("unused")
        private void updateNoteTitle(String guid, String title) {
        listManager.setNoteSynchronized(guid, false);
+       
+       // We do this manually because if we've edited the note in an 
+       // external window we run into the possibility of signal recursion
+       // looping.
+       if (guid.equals(currentNoteGuid)) {
+               browserWindow.titleLabel.blockSignals(true);
+               browserWindow.titleLabel.setText(title);
+               browserWindow.titleLabel.blockSignals(false);
+       }
     }
     // Signal received that note content has changed.  Normally we just need the guid to remove
     // it from the cache.
@@ -5902,6 +5961,15 @@ public class NeverNote extends QMainWindow{
                        else
                                noteReader.setNotebookGuid(listManager.getNotebookIndex().get(0).getGuid());
   
+                       waitCursor(false);
+                       if (QMessageBox.question(this, tr("Confirmation"), 
+                                       tr("Create new tags from import?"),
+                                       QMessageBox.StandardButton.Yes, 
+                                       QMessageBox.StandardButton.No) == StandardButton.Yes.value()) {
+                                                               noteReader.createNewTags = true;
+                       } else
+                               noteReader.createNewTags = false;
+                       waitCursor(true);
                        noteReader.importData(fileName);
        
                        if (noteReader.lastError != 0) {
@@ -6317,15 +6385,17 @@ public class NeverNote extends QMainWindow{
        @Override
        public void changeEvent(QEvent e) {
                if (e.type() == QEvent.Type.WindowStateChange) {
-                       if (isMinimized() && Global.showTrayIcon()) {
-                               e.accept();
-                               QTimer.singleShot(10, this, "hide()");
-                               return;
+                       if (QSystemTrayIcon.isSystemTrayAvailable()) {
+                               if (isMinimized() && (Global.showTrayIcon() || Global.showTrayIcon())) {
+                                       e.accept();
+                                       QTimer.singleShot(10, this, "hide()");
+                                       return;
+                               }
+                               if (isMaximized())
+                                       windowMaximized = true;
+                               else 
+                                       windowMaximized = false;
                        }
-                       if (isMaximized())
-                               windowMaximized = true;
-                       else 
-                               windowMaximized = false;
                }
        }
        
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;
+    }
 }
index 0a65632..75b7369 100644 (file)
@@ -33,6 +33,7 @@ import com.trolltech.qt.gui.QLabel;
 import com.trolltech.qt.gui.QScrollArea;\r
 import com.trolltech.qt.gui.QSpinBox;\r
 import com.trolltech.qt.gui.QStyleFactory;\r
+import com.trolltech.qt.gui.QSystemTrayIcon;\r
 import com.trolltech.qt.gui.QVBoxLayout;\r
 import com.trolltech.qt.gui.QWidget;\r
 \r
@@ -56,6 +57,7 @@ public class ConfigAppearancePage extends QWidget {
        private final QCheckBox minimizeOnClose;\r
        private final QCheckBox includeTagChildren;\r
        private final QCheckBox displayRightToLeft;\r
+       private final QComboBox startupNotebook;\r
        private final QSpinBox autoSaveInterval;\r
        \r
        private final List<String> tformats;\r
@@ -140,7 +142,11 @@ public class ConfigAppearancePage extends QWidget {
                mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));\r
                showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));\r
                showTrayIcon = new QCheckBox(tr("Minimize To Tray"));\r
-               minimizeOnClose = new QCheckBox(tr("Minimize On Close"));\r
+               minimizeOnClose = new QCheckBox(tr("Close To Tray"));\r
+               if (!QSystemTrayIcon.isSystemTrayAvailable()) { \r
+                       showTrayIcon.setEnabled(false);\r
+                       minimizeOnClose.setEnabled(false);\r
+               }\r
                verifyDelete = new QCheckBox(tr("Verify Deletes"));\r
                startMinimized = new QCheckBox(tr("Start Minimized"));\r
                pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));\r
@@ -150,6 +156,15 @@ public class ConfigAppearancePage extends QWidget {
                includeTagChildren = new QCheckBox(tr("Include Children In Tag Selection"));\r
                displayRightToLeft = new QCheckBox(tr("Display Notes Right-To-Left"));\r
                \r
+               QHBoxLayout startupNotebookLayout = new QHBoxLayout();\r
+               startupNotebook = new QComboBox();\r
+               startupNotebook.addItem(tr("All Notebooks"), "AllNotebooks");\r
+               startupNotebook.addItem(tr("Default Notebook"), "DefaultNotebook");\r
+               startupNotebookLayout.addWidget(new QLabel(tr("Startup Notebook")));\r
+               startupNotebookLayout.addWidget(startupNotebook);\r
+               startupNotebookLayout.addStretch();\r
+       \r
+               \r
                QHBoxLayout autoSaveLayout = new QHBoxLayout();\r
                autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));\r
                autoSaveInterval = new QSpinBox();\r
@@ -166,6 +181,7 @@ public class ConfigAppearancePage extends QWidget {
                \r
                QVBoxLayout checkboxLayout = new QVBoxLayout();\r
                checkboxLayout.addWidget(mimicEvernote); \r
+               checkboxLayout.addLayout(startupNotebookLayout);\r
                checkboxLayout.addWidget(showTrayIcon);\r
                checkboxLayout.addWidget(minimizeOnClose);\r
                checkboxLayout.addWidget(startMinimized);\r
@@ -195,15 +211,17 @@ public class ConfigAppearancePage extends QWidget {
                showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");\r
                showTrayIconClicked(showTrayIcon.isChecked());\r
 \r
-\r
        }\r
        \r
        private void showTrayIconClicked(Boolean checked) {\r
-               if (!checked) {\r
-                       minimizeOnClose.setEnabled(false);\r
-                       minimizeOnClose.setChecked(false);\r
-               } else\r
-                       minimizeOnClose.setEnabled(true);\r
+//             if (!checked) {\r
+//                     minimizeOnClose.setEnabled(false);\r
+//                     minimizeOnClose.setChecked(false);\r
+//             } else\r
+//                     if (QSystemTrayIcon.isSystemTrayAvailable()) \r
+//                             minimizeOnClose.setEnabled(true);\r
+//                     else\r
+//                             minimizeOnClose.setEnabled(false);\r
        }\r
 \r
        \r
@@ -440,5 +458,20 @@ public class ConfigAppearancePage extends QWidget {
                displayRightToLeft.setChecked(val);\r
        }\r
 \r
+       \r
+       //**************************************************\r
+       //* Get/Set startup notebook\r
+       //**************************************************\r
+       public void setStartupNotebook(String value) {\r
+               for (int i=0; i<startupNotebook.count(); i++) {\r
+                       String d = startupNotebook.itemData(i).toString();\r
+                       if (d.equals(value))\r
+                               startupNotebook.setCurrentIndex(i);\r
+               }\r
+       }\r
+       public String getStartupNotebook() {\r
+               int index = startupNotebook.currentIndex();\r
+               return startupNotebook.itemData(index).toString();      \r
+       }\r
 \r
 }\r
index 8ec11d6..563a1a2 100644 (file)
@@ -45,9 +45,7 @@ import cx.fbn.nevernote.Global;
 import cx.fbn.nevernote.utilities.SyncTimes;\r
 \r
 public class ConfigConnectionPage extends QWidget {\r
-       private final QLineEdit useridEdit;\r
-       private final QLineEdit passwordEdit;\r
-       private final QCheckBox rememberPassword;\r
+\r
        private final QCheckBox autoLogin;\r
        private final QComboBox syncInterval;\r
        private final SyncTimes syncTimes;\r
@@ -63,22 +61,11 @@ public class ConfigConnectionPage extends QWidget {
                \r
                // Userid settings\r
                QGroupBox useridGroup = new QGroupBox(tr("Connection"));\r
-               QLabel useridLabel = new QLabel(tr("Userid"));\r
-               QLabel passwordLabel = new QLabel(tr("Password"));\r
-\r
-               \r
-               useridEdit = new QLineEdit();\r
-               useridEdit.setText(Global.username);\r
-               \r
-               passwordEdit = new QLineEdit();\r
-               passwordEdit.setText(Global.password);\r
-               passwordEdit.setEchoMode(QLineEdit.EchoMode.Password);\r
                \r
                syncInterval = new QComboBox(this);\r
                syncTimes = new SyncTimes();\r
                syncInterval.addItems(syncTimes.stringValues());\r
                \r
-               rememberPassword = new QCheckBox("Remember Userid & Password");\r
                autoLogin = new QCheckBox("Automatic Connect");\r
                synchronizeDeletedContents = new QCheckBox("Synchronze Deleted Note Content");\r
                synchronizeOnClose = new QCheckBox("Synchronize On Shutdown (only if connected)");\r
@@ -113,13 +100,8 @@ public class ConfigConnectionPage extends QWidget {
                \r
                \r
                QFormLayout useridLayout = new QFormLayout();\r
-               useridLayout.addWidget(useridLabel);\r
-               useridLayout.addWidget(useridEdit);             \r
-               useridLayout.addWidget(passwordLabel);\r
-               useridLayout.addWidget(passwordEdit);\r
                useridLayout.addWidget(new QLabel(tr("Syncronization Interval")));\r
                useridLayout.addWidget(syncInterval);\r
-               useridLayout.addWidget(rememberPassword);\r
                useridLayout.addWidget(autoLogin);\r
                useridLayout.addWidget(synchronizeOnClose);\r
                useridLayout.addWidget(synchronizeDeletedContents);\r
@@ -147,39 +129,6 @@ public class ConfigConnectionPage extends QWidget {
        }\r
 \r
        \r
-       //*****************************************\r
-       //* Userid get/set methods \r
-       //*****************************************\r
-       public void setUserid(String id) {\r
-               useridEdit.setText(id);\r
-       }\r
-       public String getUserid() {\r
-               return useridEdit.text();\r
-       }\r
-       \r
-\r
-       //*****************************************\r
-       //* Password get/set methods \r
-       //*****************************************\r
-       public void setPassword(String id) {\r
-               passwordEdit.setText(id);\r
-       }\r
-       public String getPassword() {\r
-               return passwordEdit.text();\r
-       }\r
-       \r
-\r
-       //*******************************************\r
-       //* Remember Password get/set\r
-       //*******************************************\r
-       public void setRememberPassword(boolean val) {\r
-               rememberPassword.setChecked(val);\r
-       }\r
-       public boolean getRememberPassword() {\r
-               return rememberPassword.isChecked();\r
-       }\r
-       \r
-       \r
        \r
        \r
        //*******************************************\r
index 38c51c3..5e7e7bb 100644 (file)
 \r
 package cx.fbn.nevernote.dialog;\r
 \r
-import java.io.FileInputStream;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-\r
 import com.swabunga.spell.engine.Configuration;\r
 import com.trolltech.qt.core.QSize;\r
 import com.trolltech.qt.core.Qt.AlignmentFlag;\r
@@ -47,7 +43,6 @@ import com.trolltech.qt.gui.QVBoxLayout;
 import com.trolltech.qt.gui.QWidget;\r
 \r
 import cx.fbn.nevernote.Global;\r
-import cx.fbn.nevernote.utilities.AESEncrypter;\r
 public class ConfigDialog extends QDialog {\r
        private final QListWidget                               contentsWidget;\r
        private final ConfigFontPage                    fontPage;\r
@@ -116,8 +111,7 @@ public class ConfigDialog extends QDialog {
        public void okPushed() {\r
                Global.setServer(debugPage.getServer());\r
                Global.setEnableThumbnails(debugPage.getEnableThumbnails());\r
-               AESEncrypter aes = new AESEncrypter();\r
-               aes.setUserid(connectionPage.getUserid().trim());\r
+\r
                \r
                if (debugPage.getDisableUploads())\r
                        Global.disableUploads = true;\r
@@ -157,10 +151,6 @@ public class ConfigDialog extends QDialog {
                Global.setAutoSaveInterval(appearancePage.getAutoSaveInterval());\r
                                                \r
                Global.setAutomaticLogin(connectionPage.getAutomaticLogin());\r
-               Global.setRememberPassword(connectionPage.getRememberPassword());\r
-               if (connectionPage.getRememberPassword()) {     \r
-                       aes.setPassword(connectionPage.getPassword());\r
-               }\r
                Global.setProxyValue("url", connectionPage.getProxyUrl());\r
                Global.setProxyValue("port", connectionPage.getProxyPort());\r
                Global.setProxyValue("userid", connectionPage.getProxyUserid());\r
@@ -181,14 +171,6 @@ public class ConfigDialog extends QDialog {
                Global.setIncludeTagChildren(appearancePage.getIncludeTagChildren());\r
                Global.setDisplayRightToLeft(appearancePage.getDisplayRightToLeft());\r
                \r
-       FileOutputStream out = null;\r
-               try {\r
-                       out = new FileOutputStream(Global.getFileManager().getHomeDirFile("secure.txt"));\r
-               } catch (FileNotFoundException e) {\r
-                       // if it isn't found we'll write it.\r
-               }\r
-               if (out != null)\r
-                       aes.encrypt(out);\r
                Global.userStoreUrl = "https://"+debugPage.getServer()+"/edam/user";\r
                Global.setWordRegex(indexPage.getRegex());\r
                Global.setRecognitionWeight(indexPage.getRecognitionWeight());\r
@@ -214,6 +196,7 @@ public class ConfigDialog extends QDialog {
                        QApplication.setPalette(QApplication.style().standardPalette());\r
                else\r
                        QApplication.setPalette(Global.originalPalette);\r
+               Global.setStartupNotebook(appearancePage.getStartupNotebook());\r
                \r
                String dateFmt = appearancePage.getDateFormat();\r
                String timeFmt = appearancePage.getTimeFormat();\r
@@ -311,26 +294,9 @@ public class ConfigDialog extends QDialog {
                debugPage.setEnableThumbnails(Global.enableThumbnails());\r
 //             if (Global.getUpdateSequenceNumber() > 0)\r
                        debugPage.serverCombo.setEnabled(false);\r
-               \r
-               if (Global.username.equalsIgnoreCase("") || Global.password.equalsIgnoreCase("")) {\r
-               AESEncrypter aes = new AESEncrypter();\r
-               try {\r
-                               aes.decrypt(new FileInputStream(Global.getFileManager().getHomeDirFile("secure.txt")));\r
-                       } catch (FileNotFoundException e) {\r
-                               // File not found, so we'll just get empty strings anyway. \r
-                       }\r
-                       String userid = aes.getUserid();\r
-                       String password = aes.getPassword();\r
-                       if (!userid.equals("") && !password.equals("")) {\r
-                       Global.username = userid;\r
-                       Global.password = password;\r
-                       }                                       \r
-               }\r
+\r
                appearancePage.setAutoSaveInterval(Global.getAutoSaveInterval());\r
-               connectionPage.setUserid(Global.username);\r
-               connectionPage.setPassword(Global.password);\r
                connectionPage.setAutomaticLogin(Global.automaticLogin());\r
-               connectionPage.setRememberPassword(Global.rememberPassword());\r
                appearancePage.setMimicEvernote(Global.getMimicEvernoteInterface());\r
                appearancePage.setShowTrayIcon(Global.showTrayIcon());\r
                connectionPage.setSynchronizeOnClose(Global.synchronizeOnClose());\r
@@ -346,6 +312,7 @@ public class ConfigDialog extends QDialog {
                appearancePage.setMinimizeOnClose(Global.minimizeOnClose());\r
                appearancePage.setIncludeTagChildren(Global.includeTagChildren());\r
                appearancePage.setDisplayRightToLeft(Global.displayRightToLeft());\r
+               appearancePage.setStartupNotebook(Global.getStartupNotebook());\r
                \r
                indexPage.setRegex(Global.getWordRegex());\r
                indexPage.setSleepInterval(Global.getIndexThreadSleepInterval());\r
diff --git a/src/cx/fbn/nevernote/dialog/LoginDialog.java b/src/cx/fbn/nevernote/dialog/LoginDialog.java
deleted file mode 100644 (file)
index 238e96e..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*\r
- * This file is part of NixNote \r
- * Copyright 2009 Randy Baumgarte\r
- * \r
- * This file may be licensed under the terms of of the\r
- * GNU General Public License Version 2 (the ``GPL'').\r
- *\r
- * Software distributed under the License is distributed\r
- * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
- * express or implied. See the GPL for the specific language\r
- * governing rights and limitations.\r
- *\r
- * You should have received a copy of the GPL along with this\r
- * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
- * or write to the Free Software Foundation, Inc.,\r
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
- *\r
-*/\r
-\r
-package cx.fbn.nevernote.dialog;\r
-\r
-//**********************************************\r
-//**********************************************\r
-//* Login to Evernote\r
-//**********************************************\r
-//**********************************************\r
-\r
-import com.trolltech.qt.gui.QDialog;\r
-import com.trolltech.qt.gui.QGridLayout;\r
-import com.trolltech.qt.gui.QIcon;\r
-import com.trolltech.qt.gui.QLabel;\r
-import com.trolltech.qt.gui.QLineEdit;\r
-import com.trolltech.qt.gui.QPushButton;\r
-\r
-import cx.fbn.nevernote.Global;\r
-\r
-public class LoginDialog extends QDialog {\r
-\r
-       private boolean         okPressed;\r
-       private final QLineEdit userid;\r
-       private final QLineEdit password;\r
-       private final QPushButton ok;\r
-       private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
-       \r
-       // Constructor\r
-       public LoginDialog() {\r
-               okPressed = false;\r
-               setWindowTitle(tr("NixNote Login"));\r
-               setWindowIcon(new QIcon(iconPath+"password.png"));\r
-               QGridLayout grid = new QGridLayout();\r
-               setLayout(grid);\r
-               QGridLayout passwordGrid = new QGridLayout();\r
-               QGridLayout buttonGrid = new QGridLayout();\r
-               \r
-               String useridValue = Global.username;\r
-               String passwordValue = Global.password;\r
-               \r
-               userid = new QLineEdit(useridValue);\r
-               password = new QLineEdit(passwordValue);\r
-               password.setEchoMode(QLineEdit.EchoMode.Password);\r
-               \r
-               userid.textChanged.connect(this, "validateInput()");\r
-               password.textChanged.connect(this, "validateInput()");\r
-               \r
-               passwordGrid.addWidget(new QLabel(tr("Userid")), 1,1);\r
-               passwordGrid.addWidget(userid, 1, 2);\r
-               passwordGrid.addWidget(new QLabel(tr("Password")), 2,1);\r
-               passwordGrid.addWidget(password, 2, 2);\r
-               passwordGrid.setContentsMargins(10, 10,  -10, -10);\r
-               grid.addLayout(passwordGrid,1,1);\r
-               \r
-               ok = new QPushButton(tr("OK"));\r
-               ok.clicked.connect(this, "okButtonPressed()");\r
-               QPushButton cancel = new QPushButton(tr("Cancel"));\r
-               cancel.clicked.connect(this, "cancelButtonPressed()");\r
-               buttonGrid.addWidget(ok, 1, 1);\r
-               buttonGrid.addWidget(cancel, 1,2);\r
-               grid.addLayout(buttonGrid,2,1);\r
-       }\r
-       \r
-       // The OK button was pressed\r
-       @SuppressWarnings("unused")\r
-       private void okButtonPressed() {\r
-               okPressed = true;\r
-               close();\r
-       }\r
-       \r
-       // The CANCEL button was pressed\r
-       @SuppressWarnings("unused")\r
-       private void cancelButtonPressed() {\r
-               okPressed = false;\r
-               close();\r
-       }\r
-       \r
-       // Get the userid from the field\r
-       public String getUserid() {\r
-               return userid.text();\r
-       }\r
-       \r
-       // Get the password \r
-       public String getPassword() {\r
-               return password.text();\r
-       }\r
-       \r
-       // Check if the OK button was pressed\r
-       public boolean okPressed() {\r
-               return okPressed;\r
-       }\r
-       \r
-       // Validate user input\r
-       public void validateInput() {\r
-               ok.setEnabled(true);\r
-               if (userid.text().trim().equals("")) {\r
-                       ok.setEnabled(false);\r
-                       return;\r
-               }               if (password.text().trim().equals("")) {\r
-                       ok.setEnabled(false);\r
-                       return;\r
-               }\r
-       }\r
-}\r
index 759b96a..db5ef10 100644 (file)
@@ -54,6 +54,7 @@ public class ColorMenu extends Object {
                        pix.fill(color);\r
                        QAction newAction = new QAction(new QIcon(pix), "", parent);\r
                        newAction.setToolTip(colorNames.get(i));\r
+                       newAction.setText(colorNames.get(i));\r
                        newAction.hovered.connect(this, "itemHovered()");\r
                        menu.addAction(newAction);\r
                }\r
index b1e42db..1bfbe8d 100644 (file)
@@ -673,7 +673,7 @@ public class MainMenuBar extends QMenuBar {
                fileMenu.addAction(restoreAction);\r
                fileMenu.addSeparator();\r
                fileMenu.addAction(selectiveSyncAction);\r
-               fileMenu.addAction(parent.browserWindow.browser.downloadAttachment);\r
+               //fileMenu.addAction(parent.browserWindow.browser.downloadAttachment);\r
                fileMenu.addSeparator();\r
                fileMenu.addAction(emptyTrashAction);\r
                fileMenu.addAction(exitAction);\r
@@ -722,11 +722,11 @@ public class MainMenuBar extends QMenuBar {
                formatMenu.addAction(formatSuperscript);\r
                formatMenu.addAction(formatSubscript);\r
                formatMenu.addSeparator();\r
-               formatMenu.addAction(parent.browserWindow.browser.todoAction);\r
-               formatMenu.addAction(parent.browserWindow.browser.encryptAction);\r
-               formatMenu.addAction(parent.browserWindow.browser.insertLinkAction);\r
-               formatMenu.addAction(parent.browserWindow.browser.insertQuickLinkAction);\r
-               formatMenu.addAction(parent.browserWindow.browser.insertLatexAction);\r
+               //formatMenu.addAction(parent.browserWindow.browser.todoAction);\r
+               //formatMenu.addAction(parent.browserWindow.browser.encryptAction);\r
+               //formatMenu.addAction(parent.browserWindow.browser.insertLinkAction);\r
+               //formatMenu.addAction(parent.browserWindow.browser.insertQuickLinkAction);\r
+               //formatMenu.addAction(parent.browserWindow.browser.insertLatexAction);\r
                formatMenu.addMenu(parent.browserWindow.browser.tableMenu);\r
                formatMenu.addMenu(parent.browserWindow.browser.imageMenu);\r
                formatMenu.addSeparator();\r
index 3b8187e..c92e927 100644 (file)
@@ -1,5 +1,6 @@
 package cx.fbn.nevernote.gui;\r
 \r
+import java.util.ArrayList;\r
 import java.util.Collections;\r
 import java.util.HashMap;\r
 import java.util.List;\r
@@ -154,9 +155,24 @@ public class NoteTableModel extends QAbstractTableModel {
                }\r
                if (col == Global.noteTableTagPosition) {\r
                        String tags = new String();\r
+                       List<String> tagNames = new ArrayList<String>();\r
                        for (int i=0; i<note.getTagNamesSize(); i++) {\r
-                               tags = tags + note.getTagNames().get(i);\r
-                               if (i!=note.getTagNamesSize()-1)\r
+                               tagNames.add(note.getTagNames().get(i));\r
+                       }\r
+                       \r
+                       while (tagNames.size() > 0) {\r
+                               int position = 0;\r
+                               for (int i=0; i<tagNames.size()-1; i++) {\r
+                                       String name1 = tagNames.get(i);\r
+                                       String name2 = tagNames.get(i+1);\r
+                                       if (name1.compareTo(name2) > 0) {\r
+                                               position = i+1;\r
+                                       }\r
+                               }\r
+                               \r
+                               tags = tags + tagNames.get(position);\r
+                               tagNames.remove(position);\r
+                               if (tagNames.size() > 0)\r
                                        tags = tags + ", ";\r
                        }\r
                        return tags;\r
index e7d44ed..913cb57 100644 (file)
@@ -180,7 +180,7 @@ public class ShortcutKeys {
                Format_Strikethrough = new String("Ctrl+-");    // Strikethrough\r
                Format_Horizontal_Line = new String();          // Href line\r
                Format_Superscript = new String("Ctrl+=");      // Set superscript\r
-               Format_Subscript = new String("Ctrl++Shift+="); // Subscript\r
+               Format_Subscript = new String("Ctrl+Shift+=");  // Subscript\r
                Format_Alignment_Left = new String("Ctrl+L");   // Left align text\r
                Format_Alignment_Center = new String("Ctrl+E"); // Center text\r
                Format_Alignment_Right = new String("Ctrl+R");  // Right align text\r
@@ -233,7 +233,7 @@ public class ShortcutKeys {
                loadKey("Edit_Paste_Without_Formatting", Edit_Paste_Without_Formatting);\r
                loadKey("Edit_Insert_Hyperlink", Edit_Insert_Hyperlink);\r
                loadKey("Edit_Insert_Table_Row", Edit_Insert_Table_Row);\r
-               loadKey("Edit_Insert_Table_Row", Edit_Delete_Table_Row);\r
+               loadKey("Edit_Delete_Table_Row", Edit_Delete_Table_Row);\r
                loadKey("Edit_Insert_Todo", Edit_Insert_Todo);\r
                loadKey("Edit_Rotate_Image_Right", Edit_Rotate_Image_Right);\r
                loadKey("Edit_Rotate_Image_Left", Edit_Rotate_Image_Left);\r
diff --git a/src/cx/fbn/nevernote/oauth/NNOAuthNetworkAccessManager.java b/src/cx/fbn/nevernote/oauth/NNOAuthNetworkAccessManager.java
new file mode 100644 (file)
index 0000000..b8c889e
--- /dev/null
@@ -0,0 +1,65 @@
+
+/*
+ * This file is part of NixNote 
+ * Copyright 2012 Randy Baumgarte
+ * 
+ * This file may be licensed under the terms of of the
+ * GNU General Public License Version 2 (the ``GPL'').
+ *
+ * Software distributed under the License is distributed
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the GPL for the specific language
+ * governing rights and limitations.
+ *
+ * You should have received a copy of the GPL along with this
+ * program. If not, go to http://www.gnu.org/licenses/gpl.html
+ * or write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* This class is used to listen to inbound network requests.  It 
+ * examines all of them to look for the OAuth reply.  This reply
+ * is what we need to get access to Evernote.
+ */
+
+package cx.fbn.nevernote.oauth;
+
+import com.trolltech.qt.core.QIODevice;
+import com.trolltech.qt.core.QObject;
+import com.trolltech.qt.network.QNetworkAccessManager;
+import com.trolltech.qt.network.QNetworkReply;
+import com.trolltech.qt.network.QNetworkRequest;
+
+import cx.fbn.nevernote.utilities.ApplicationLogger;
+
+public class NNOAuthNetworkAccessManager extends QNetworkAccessManager {
+       public Signal1<String> tokenFound;
+       private ApplicationLogger logger;
+
+       public NNOAuthNetworkAccessManager(ApplicationLogger l){
+               super();
+               tokenFound = new Signal1<String>();
+               logger = l;
+       }
+
+       public NNOAuthNetworkAccessManager(QObject qObject){
+               super(qObject);
+               tokenFound = new Signal1<String>();
+       }
+
+       @Override
+       protected QNetworkReply createRequest(Operation op,
+                       QNetworkRequest request, QIODevice outgoingData) {
+
+               logger.log(logger.EXTREME,"NNOAuthNetworkAccessManager URL request scheme: " 
+                               +request.url().scheme() + " " + request.url().toString());
+               String searchReq = "nnoauth?oauth_token=";
+               int pos = request.url().toString().indexOf(searchReq);
+               if (pos>0) {
+                       String token = request.url().toString().substring(pos+searchReq.length());
+                       tokenFound.emit(token);
+               }
+               return super.createRequest(op, request, outgoingData);
+       }               
+}
\ No newline at end of file
diff --git a/src/cx/fbn/nevernote/oauth/OAuthTokenizer.java b/src/cx/fbn/nevernote/oauth/OAuthTokenizer.java
new file mode 100644 (file)
index 0000000..505857e
--- /dev/null
@@ -0,0 +1,96 @@
+
+/*
+  * This file is part of NixNote 
+ * Copyright 2012 Randy Baumgarte
+ * 
+ * This file may be licensed under the terms of of the
+ * GNU General Public License Version 2 (the ``GPL'').
+ *
+ * Software distributed under the License is distributed
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the GPL for the specific language
+ * governing rights and limitations.
+ *
+ * You should have received a copy of the GPL along with this
+ * program. If not, go to http://www.gnu.org/licenses/gpl.html
+ * or write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+
+
+/* This class is used to parse out the OAuth reply from Evernote */
+
+package cx.fbn.nevernote.oauth;
+
+import java.util.ArrayList;
+
+public class OAuthTokenizer {
+
+         public String oauth_token;
+         public String edam_shard;
+         public String edam_userId;
+         public String edam_expires;
+         public String edam_noteStoreUrl;
+         public String edam_webApiUrlPrefix;
+         
+         public OAuthTokenizer() {
+                 oauth_token = new String();
+                 edam_shard = new String();
+                 edam_userId = new String();
+                 edam_expires = new String();
+                 edam_noteStoreUrl = new String();
+                 edam_webApiUrlPrefix = new String();
+         }
+       
+         public void tokenize(String decoded) {
+               ArrayList<String> tokens = new ArrayList<String>();
+               for (;decoded!=null && decoded.length()>0;) {
+                       int i=decoded.indexOf("&");
+                       if (i>0) {
+                               tokens.add(decoded.substring(0,i));
+                               decoded=decoded.substring(i+1);
+                       } else {
+                               tokens.add(decoded);
+                               decoded="";
+                       }
+               }
+               System.out.println("Tokens found:" +tokens.size());
+               String oauth_tokenString = "oauth_token=";
+               String edam_shardString = "edam_shard=";
+               String edam_userIdString = "edam_userid=";
+               String edam_expiresString = "edam_expires=";
+               String edam_noteStoreUrlString ="edam_notestoreurl=";
+               String edam_webApiUrlPrefixString = "edam_webapiurlprefix=";
+               oauth_token = "";
+               edam_shard = "";
+               edam_userId = "";
+               edam_expires = "";
+               edam_noteStoreUrl = "";
+               edam_webApiUrlPrefix = "";
+               
+               for (int i=0; i<tokens.size(); i++) {
+                       String token = tokens.get(i);
+                       if (token.toLowerCase().startsWith(oauth_tokenString)) {
+                               oauth_token = token.substring(oauth_tokenString.length());
+                       }
+                       if (token.toLowerCase().startsWith(edam_shardString)) {
+                               edam_shard = token.substring(edam_shardString.length());
+                       }
+                       if (token.toLowerCase().startsWith(edam_userIdString)) {
+                               edam_userId = token.substring(edam_userIdString.length());
+                       }
+                       if (token.toLowerCase().startsWith(edam_expiresString)) {
+                               edam_expires = token.substring(edam_expiresString.length());
+                       }
+                       if (token.toLowerCase().startsWith(edam_noteStoreUrlString)) {
+                               edam_noteStoreUrl = token.substring(edam_noteStoreUrlString.length());
+                       }
+                       if (token.toLowerCase().startsWith(edam_webApiUrlPrefixString)) {
+                               edam_webApiUrlPrefix = token.substring(edam_webApiUrlPrefixString.length());
+                       }
+               }
+
+       }
+}
diff --git a/src/cx/fbn/nevernote/oauth/OAuthWindow.java b/src/cx/fbn/nevernote/oauth/OAuthWindow.java
new file mode 100644 (file)
index 0000000..e033482
--- /dev/null
@@ -0,0 +1,166 @@
+
+/*
+  * This file is part of NixNote 
+ * Copyright 2012 Randy Baumgarte
+ * 
+ * This file may be licensed under the terms of of the
+ * GNU General Public License Version 2 (the ``GPL'').
+ *
+ * Software distributed under the License is distributed
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the GPL for the specific language
+ * governing rights and limitations.
+ *
+ * You should have received a copy of the GPL along with this
+ * program. If not, go to http://www.gnu.org/licenses/gpl.html
+ * or write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+
+/* This method is used to present the user with the web view of Evernote
+ * that they need to grant permission to Nixnote.
+ */
+
+
+package cx.fbn.nevernote.oauth;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+
+import com.trolltech.qt.core.QUrl;
+import com.trolltech.qt.gui.QDialog;
+import com.trolltech.qt.gui.QGridLayout;
+import com.trolltech.qt.gui.QIcon;
+import com.trolltech.qt.network.QSslSocket;
+import com.trolltech.qt.webkit.QWebView;
+
+import cx.fbn.nevernote.Global;
+import cx.fbn.nevernote.utilities.ApplicationLogger;
+
+public class OAuthWindow extends QDialog {
+       private final static String consumerKey = "baumgarr"; 
+       private final static String consumerSecret = "60d4cdedb074b0ac";
+       public String response;
+
+       private final String temporaryCredUrl;    
+       private final String permanentCredUrl;
+
+
+       static final String urlBase = "https://"+Global.getServer();
+
+       public boolean error;
+       public String errorMessage;
+
+       static final String requestTokenUrl = urlBase + "/oauth";
+       static final String accessTokenUrl = urlBase + "/oauth";
+       static final String authorizationUrlBase = urlBase + "/OAuth.action";
+       private final String iconPath = new String("classpath:cx/fbn/nevernote/");
+       private final QWebView tempPage;
+       private final QWebView authPage;
+       private final QGridLayout grid;
+       private NNOAuthNetworkAccessManager manager;
+
+       static final String callbackUrl = "index.jsp?action=callbackReturn";
+       private final ApplicationLogger logger;
+
+
+       // Constructor.
+       public OAuthWindow(ApplicationLogger l) {
+               logger = l;
+               int millis = (int) System.currentTimeMillis();
+               int time = millis / 1000;
+
+
+               // Create the URLs needed for authentication with Evernote
+               temporaryCredUrl = "https://"+Global.getServer() + "/oauth?oauth_consumer_key=" +consumerKey + "&oauth_signature=" +
+                               consumerSecret + "%26&oauth_signature_method=PLAINTEXT&oauth_timestamp="+String.valueOf(time)+
+                               "&oauth_nonce="+String.valueOf(millis) +"&oauth_callback=nnoauth";
+
+               permanentCredUrl = "https://"+Global.getServer() + "/oauth?oauth_consumer_key=" +consumerKey + "&oauth_signature=" +
+                               consumerSecret + "%26&oauth_signature_method=PLAINTEXT&oauth_timestamp="+String.valueOf(time)+
+                               "&oauth_nonce="+String.valueOf(millis) +"&oauth_token=";
+
+
+               // Build the window
+               setWindowTitle(tr("Please Grant Nixnote Access"));
+               setWindowIcon(new QIcon(iconPath+"icons/password.png"));
+               grid = new QGridLayout();
+               setLayout(grid);
+               tempPage = new QWebView();
+               authPage = new QWebView();
+               grid.addWidget(authPage);
+               tempPage.loadFinished.connect(this, "temporaryCredentialsReceived()");
+
+               error = false;
+               errorMessage = "";
+               
+               // Check that SSL sockets are supported
+               logger.log(logger.MEDIUM, "SSL Sockets Supported: " +QSslSocket.supportsSsl());
+               if (!QSslSocket.supportsSsl()) {
+                       errorMessage = new String(tr("SSL Support not found.  Aborting connection"));
+                       error = true;
+               }
+               
+               // Load the temporary URL to start the authentication procesess.  When 
+               // finished, this QWebView will contain the URL to start the
+               // authentication process.
+               QUrl tu = new QUrl(temporaryCredUrl);
+               tempPage.load(tu);
+       }
+
+       
+       // This method is triggered when the temporary credentials are received from Evernote
+       public void temporaryCredentialsReceived() {
+               logger.log(logger.MEDIUM, "Temporary Credentials Received");
+               String contents = tempPage.page().mainFrame().toPlainText();
+               logger.log(logger.MEDIUM, "Temporary Credentials:" +contents);
+               int index = contents.indexOf("&oauth_token_secret");
+               contents = contents.substring(0,index);
+               QUrl accessUrl = new QUrl(urlBase+"/OAuth.action?" +contents);
+               manager = new NNOAuthNetworkAccessManager(logger);
+               authPage.page().setNetworkAccessManager(manager);
+               manager.tokenFound.connect(this, "tokenFound(String)");
+
+               authPage.load(accessUrl);  
+               grid.addWidget(authPage);
+       }
+
+       // This method is signaled when NNOAuthNetworkAccessManager finds an OAuth token
+       // in the network request.
+       public void tokenFound(String token) {
+               logger.log(logger.MEDIUM, "*** TOKEN *** " +token);
+               if (token.indexOf("auth_verifier") <= 0) {
+                       errorMessage = new String(tr("Error receiving authorization"));
+                       error = true;
+                       this.close();
+               }
+               tempPage.disconnect();
+               tempPage.loadFinished.connect(this, "permanentCredentialsReceived()");
+               logger.log(logger.HIGH,"Permanent URL: " +permanentCredUrl+token);
+               tempPage.load(new QUrl(permanentCredUrl+token));
+       }
+
+       
+       // This method is used when the permanent credentials are finally
+       // received to grant access to Evernote.
+       public void permanentCredentialsReceived() {
+               String contents = tempPage.page().mainFrame().toPlainText();
+               if (contents.startsWith("oauth_token=S%3D")) {
+                       logger.log(logger.HIGH, "Permanent Credentials:" +contents);
+                       String decoded;
+                       try {
+                               response = "";
+                               decoded = URLDecoder.decode(contents,"UTF-8");
+                               logger.log(logger.HIGH, "Decoded URL:"+decoded);
+                               response = decoded;
+                       } catch (UnsupportedEncodingException e) {
+                               e.printStackTrace();
+                       }
+
+                       this.close();
+               }
+       }
+
+}
index e22bda8..f32cab7 100644 (file)
@@ -188,9 +188,8 @@ public class NoteResourceTable  {
                        query.bindValue(":guid", r.getGuid());\r
                        query.bindValue(":noteGuid", r.getNoteGuid());\r
                        if (r.getData() != null) {\r
-//                             query.bindValue(":dataHash", new QByteArray(r.getData().getBodyHash()).toHex());\r
-//                             query.bindValue(":dataHash", "");\r
                                query.bindValue(":dataHash", byteArrayToHexString(r.getData().getBodyHash()));\r
+//                             query.bindValue(":dataHash", "c0369123fe9871d675ae456fd056ba33");\r
                                query.bindValue(":dataSize", r.getData().getSize());\r
                                query.bindBlob(":dataBody", r.getData().getBody());\r
                        }\r
index 92cc548..54da38b 100644 (file)
@@ -151,6 +151,16 @@ public class NoteTable {
                        query.bindValue(":attributeSource", n.getAttributes().getSource());\r
                        query.bindValue(":attributeSourceUrl", n.getAttributes().getSourceURL());\r
                        query.bindValue(":attributeSourceApplication", n.getAttributes().getSourceApplication());\r
+               } else {\r
+                       created = new StringBuilder(simple.format(n.getCreated()));     \r
+                       query.bindValue(":attributeSubjectDate", created.toString());\r
+                       query.bindValue(":attributeLatitude", 0.0);\r
+                       query.bindValue(":attributeLongitude", 0.0);\r
+                       query.bindValue(":attributeAltitude", 0.0);\r
+                       query.bindValue(":attributeAuthor", "");\r
+                       query.bindValue(":attributeSource", "");\r
+                       query.bindValue(":attributeSourceUrl", "");\r
+                       query.bindValue(":attributeSourceApplication", "");\r
                }\r
                query.bindValue(":indexNeeded", true);\r
                query.bindValue(":isExpunged", false);\r
@@ -299,18 +309,20 @@ public class NoteTable {
                na.setContentClass(query.valueString(16));\r
                \r
                if (loadTags) {\r
-                       n.setTagGuids(noteTagsTable.getNoteTags(n.getGuid()));\r
+                       List<String> tagGuids = noteTagsTable.getNoteTags(n.getGuid());\r
                        List<String> tagNames = new ArrayList<String>();\r
                        TagTable tagTable = db.getTagTable();\r
-                       for (int i=0; i<n.getTagGuids().size(); i++) {\r
-                               String currentGuid = n.getTagGuids().get(i);\r
+                       for (int i=0; i<tagGuids.size(); i++) {\r
+                               String currentGuid = tagGuids.get(i);\r
                                Tag tag = tagTable.getTag(currentGuid);\r
                                if (tag.getName() != null)\r
                                        tagNames.add(tag.getName());\r
                                else\r
                                        tagNames.add("");\r
                        }\r
+\r
                        n.setTagNames(tagNames);\r
+                       n.setTagGuids(tagGuids);                \r
                }\r
                \r
                if (loadContent) {\r
index 4abd696..71c113d 100644 (file)
@@ -159,10 +159,11 @@ public class NoteTagsTable {
                        logger.log(logger.MEDIUM, "NoteTags Table insert failed.");             \r
                        logger.log(logger.MEDIUM, query.lastError());\r
                }\r
-               check = query.prepare("Update Note set isDirty=1 where guid=:guid");\r
+               check = query.prepare("Update Note set isDirty=true where guid=:guid");\r
                if (!check)\r
                        logger.log(logger.EXTREME, "RNoteTagsTable.saveNoteTag prepare has failed.");\r
                query.bindValue(":guid", noteGuid);\r
+               query.exec();\r
                if (!check) {\r
                        logger.log(logger.MEDIUM, "RNoteTagsTable.saveNoteTag has failed to set note as dirty.");               \r
                        logger.log(logger.MEDIUM, query.lastError());\r
index 6671a52..43cf18b 100644 (file)
@@ -561,10 +561,10 @@ public class NotebookTable {
        public void setDefaultNotebook(String guid) {\r
                NSqlQuery query = new NSqlQuery(db.getConnection());\r
                \r
-               query.prepare("Update "+dbName+" set defaultNotebook=false where linked=false");\r
+               query.prepare("Update "+dbName+" set defaultNotebook=false, isDirty=true where linked=false and defaultNotebook=true");\r
                if (!query.exec())\r
                        logger.log(logger.EXTREME, "Error removing default "+dbName+".");\r
-               query.prepare("Update "+dbName+" set defaultNotebook=true where guid=:guid where linked=false");\r
+               query.prepare("Update "+dbName+" set defaultNotebook=true, isDirty=true where guid=:guid and linked=false");\r
                query.bindValue(":guid", guid);\r
                if (!query.exec())\r
                        logger.log(logger.EXTREME, "Error setting default "+dbName+".");\r
index cec989a..7534d6b 100644 (file)
@@ -130,13 +130,16 @@ public class REnSearch {
                        if (tagNames.size() == 0 && !negative)\r
                                return false;\r
                        \r
+                       boolean matchFound = false;\r
                        for (int i=0; i<tagNames.size(); i++) { \r
                                boolean matches = Pattern.matches(filterName.toLowerCase(),tagNames.get(i).toLowerCase());\r
-                               if (!matches && !negative)\r
-                                       return false;\r
-                               if (matches && negative)\r
-                                       return false;\r
+                               if (matches)\r
+                                       matchFound = true;\r
                        }\r
+                       if (negative) \r
+                               matchFound = !matchFound;\r
+                       if (!matchFound) \r
+                               return false;\r
                }\r
                return true;\r
        }\r
@@ -541,7 +544,7 @@ public class REnSearch {
                                return false;\r
                        boolean returnTodo = false;\r
                        while (pos > -1) {\r
-                               int endPos = n.getContent().indexOf("/>", pos);\r
+                               int endPos = n.getContent().indexOf(">", pos);\r
                                String segment = n.getContent().substring(pos, endPos);\r
                                boolean currentState;\r
                                if (segment.toLowerCase().indexOf("checked=\"true\"") == -1)\r
index f0afc15..6a25802 100644 (file)
@@ -302,36 +302,38 @@ public class IndexRunner extends QObject implements Runnable {
        \r
        private void indexResourceContent(String guid) {\r
                Resource r = conn.getNoteTable().noteResourceTable.getNoteResource(guid, true);\r
-               if (r.getMime().equalsIgnoreCase("application/pdf")) {\r
-                       indexResourcePDF(r);\r
-                       return;\r
-               }\r
-               if (r.getMime().equalsIgnoreCase("application/docx") || \r
-                       r.getMime().equalsIgnoreCase("application/xlsx") || \r
-                       r.getMime().equalsIgnoreCase("application/pptx")) {\r
-                       indexResourceOOXML(r);\r
-                       return;\r
-               }\r
-               if (r.getMime().equalsIgnoreCase("application/vsd") ||\r
-                       r.getMime().equalsIgnoreCase("application/ppt") ||\r
-                       r.getMime().equalsIgnoreCase("application/xls") ||\r
-                       r.getMime().equalsIgnoreCase("application/msg") ||\r
-                       r.getMime().equalsIgnoreCase("application/doc")) {\r
+               if (r != null && r.getMime() != null) {\r
+                       if (r.getMime().equalsIgnoreCase("application/pdf")) {\r
+                               indexResourcePDF(r);\r
+                               return;\r
+                       }\r
+                       if (r.getMime().equalsIgnoreCase("application/docx") || \r
+                               r.getMime().equalsIgnoreCase("application/xlsx") || \r
+                               r.getMime().equalsIgnoreCase("application/pptx")) {\r
+                               indexResourceOOXML(r);\r
+                               return;\r
+                       }\r
+                       if (r.getMime().equalsIgnoreCase("application/vsd") ||\r
+                                       r.getMime().equalsIgnoreCase("application/ppt") ||\r
+                                       r.getMime().equalsIgnoreCase("application/xls") ||\r
+                                       r.getMime().equalsIgnoreCase("application/msg") ||\r
+                                       r.getMime().equalsIgnoreCase("application/doc")) {\r
                                indexResourceOffice(r);\r
                                return;\r
-               }\r
-               if (r.getMime().equalsIgnoreCase("application/rtf")) {\r
+                       }\r
+                       if (r.getMime().equalsIgnoreCase("application/rtf")) {\r
                                        indexResourceRTF(r);\r
                                        return;\r
-               }\r
-               if (r.getMime().equalsIgnoreCase("application/odf") ||\r
-                       r.getMime().equalsIgnoreCase("application/odt") ||\r
-                       r.getMime().equalsIgnoreCase("application/odp") ||\r
-                       r.getMime().equalsIgnoreCase("application/odg") ||\r
-                       r.getMime().equalsIgnoreCase("application/odb") ||\r
-                       r.getMime().equalsIgnoreCase("application/ods")) {\r
-                       indexResourceODF(r);\r
-                       return;\r
+                       }\r
+                       if (r.getMime().equalsIgnoreCase("application/odf") ||\r
+                               r.getMime().equalsIgnoreCase("application/odt") ||\r
+                               r.getMime().equalsIgnoreCase("application/odp") ||\r
+                               r.getMime().equalsIgnoreCase("application/odg") ||\r
+                               r.getMime().equalsIgnoreCase("application/odb") ||\r
+                               r.getMime().equalsIgnoreCase("application/ods")) {\r
+                               indexResourceODF(r);\r
+                               return;\r
+                       }\r
                }\r
        }\r
 \r
index 7526577..d01faf6 100644 (file)
@@ -123,15 +123,15 @@ public class SyncRunner extends QObject implements Runnable {
            public volatile String username = ""; \r
            public volatile String password = ""; \r
                public volatile String userStoreUrl;\r
-           private final static String consumerKey = "baumgarte"; \r
-           private final static String consumerSecret = "eb8b5740e17cb55f";\r
+//         private final static String consumerKey = "baumgarte"; \r
+//         private final static String consumerSecret = "eb8b5740e17cb55f";\r
            public String noteStoreUrlBase;\r
            private THttpClient userStoreTrans;\r
            private TBinaryProtocol userStoreProt;\r
-           private AuthenticationResult authResult;\r
+           //private AuthenticationResult authResult;\r
            private AuthenticationResult linkedAuthResult;\r
            private User user; \r
-           private long authTimeRemaining;\r
+//         private long authTimeRemaining;\r
            public long authRefreshTime;\r
            public long failedRefreshes = 0;\r
            public  THttpClient noteStoreTrans;\r
@@ -205,10 +205,10 @@ public class SyncRunner extends QObject implements Runnable {
                                }\r
                                idle=false;\r
                                error=false;\r
-                               if (authRefreshNeeded == true || !isConnected) {\r
-                                       logger.log(logger.EXTREME, "Refreshing connection");\r
-                                       refreshConnection();\r
-                               }\r
+//                             if (authRefreshNeeded == true || !isConnected) {\r
+//                                     logger.log(logger.EXTREME, "Refreshing connection");\r
+//                                     refreshConnection();\r
+//                             }\r
                                if (syncNeeded) {\r
                                        logger.log(logger.EXTREME, "SyncNeeded is true");\r
                                        refreshNeeded=false;\r
@@ -471,9 +471,9 @@ public class SyncRunner extends QObject implements Runnable {
                boolean error = false;\r
                for (int i=0; i<expunged.size() && keepRunning; i++) {\r
 \r
-                       if (authRefreshNeeded)\r
-                               if (!refreshConnection())\r
-                                       return;\r
+//                     if (authRefreshNeeded)\r
+//                             if (!refreshConnection())\r
+//                                     return;\r
 \r
                        try {\r
                                if (expunged.get(i).type.equalsIgnoreCase("TAG")) {\r
@@ -536,9 +536,9 @@ public class SyncRunner extends QObject implements Runnable {
                // Sync the local notebooks with Evernote's\r
                for (int i=0; i<notes.size() && keepRunning; i++) {\r
                        \r
-                       if (authRefreshNeeded)\r
-                               if (!refreshConnection())\r
-                                       return;\r
+//                     if (authRefreshNeeded)\r
+//                             if (!refreshConnection())\r
+//                                     return;\r
                        \r
                        Note enNote = notes.get(i);\r
                        try {\r
@@ -603,9 +603,9 @@ public class SyncRunner extends QObject implements Runnable {
                logger.log(logger.HIGH, "Entering SyncRunner.syncNotes");\r
                status.message.emit(tr("Sending local notes."));\r
 \r
-               if (authRefreshNeeded)\r
-                       if (!refreshConnection())\r
-                               return;\r
+//             if (authRefreshNeeded)\r
+//                     if (!refreshConnection())\r
+//                             return;\r
                        \r
                if (enNote.isActive()) {\r
                        try {\r
@@ -706,9 +706,9 @@ public class SyncRunner extends QObject implements Runnable {
                // Sync the local notebooks with Evernote's\r
                for (int i=0; i<notebooks.size() && keepRunning; i++) {\r
                        \r
-                       if (authRefreshNeeded)\r
-                               if (!refreshConnection())\r
-                                       return;\r
+//                     if (authRefreshNeeded)\r
+//                             if (!refreshConnection())\r
+//                                     return;\r
                        \r
                        Notebook enNotebook = notebooks.get(i);\r
                        try {\r
@@ -808,9 +808,9 @@ public class SyncRunner extends QObject implements Runnable {
                \r
                while(enTag!=null && loopCount < maxCount) {\r
                        loopCount++;\r
-                       if (authRefreshNeeded)\r
-                               if (!refreshConnection())\r
-                                       return;\r
+//                     if (authRefreshNeeded)\r
+//                             if (!refreshConnection())\r
+//                                     return;\r
 \r
                        try {\r
                                if (enTag.getUpdateSequenceNum() > 0) {\r
@@ -944,9 +944,9 @@ public class SyncRunner extends QObject implements Runnable {
                logger.log(logger.EXTREME, "Beginning to send saved searches");\r
                for (int i=0; i<searches.size() &&  keepRunning; i++) {\r
                        \r
-                       if (authRefreshNeeded)\r
-                               if (!refreshConnection())\r
-                                       return;\r
+//                     if (authRefreshNeeded)\r
+//                             if (!refreshConnection())\r
+//                                     return;\r
                        \r
                        SavedSearch enSearch = searches.get(i);\r
                        try {\r
@@ -1025,9 +1025,9 @@ public class SyncRunner extends QObject implements Runnable {
                \r
                while(more &&  keepRunning) {\r
                        \r
-                       if (authRefreshNeeded)\r
-                               if (!refreshConnection())\r
-                                       return;\r
+//                     if (authRefreshNeeded)\r
+//                             if (!refreshConnection())\r
+//                                     return;\r
                        \r
                        int sequence = updateSequenceNumber;\r
                        try {\r
@@ -1516,9 +1516,10 @@ public class SyncRunner extends QObject implements Runnable {
            userStore = new UserStore.Client(userStoreProt, userStoreProt);\r
            syncSignal.saveUserStore.emit(userStore);\r
            try {\r
-                       authResult = userStore.authenticate(username, password, consumerKey, consumerSecret);\r
+                       //authResult = userStore.authenticate(username, password, consumerKey, consumerSecret);\r
+               user = userStore.getUser(authToken);\r
                } catch (EDAMUserException e) {\r
-                       QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "Error", "Incorrect username/password");\r
+                       QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "Error", "Invalid Authorization");\r
                        mb.exec();\r
                        isConnected = false;\r
                        return false;\r
@@ -1547,9 +1548,9 @@ public class SyncRunner extends QObject implements Runnable {
                System.err.println("Incomatible EDAM client protocol version"); \r
                isConnected = false;\r
            }\r
-           if (authResult != null) {\r
-               user = authResult.getUser(); \r
-               authToken = authResult.getAuthenticationToken(); \r
+           //if (authResult != null) {\r
+               //user = authResult.getUser(); \r
+               //authToken = authResult.getAuthenticationToken(); \r
                noteStoreUrl = noteStoreUrlBase + user.getShardId();\r
                syncSignal.saveAuthToken.emit(authToken);\r
                syncSignal.saveNoteStore.emit(localNoteStore);\r
@@ -1568,9 +1569,9 @@ public class SyncRunner extends QObject implements Runnable {
                localNoteStore = \r
                        new NoteStore.Client(noteStoreProt, noteStoreProt); \r
                isConnected = true;\r
-               authTimeRemaining = authResult.getExpiration() - authResult.getCurrentTime();\r
-               authRefreshTime = authTimeRemaining / 2;\r
-           }\r
+               //authTimeRemaining = authResult.getExpiration() - authResult.getCurrentTime();\r
+               //authRefreshTime = authTimeRemaining / 2;\r
+           //}\r
            \r
                // Get user information\r
                try {\r
@@ -1590,8 +1591,11 @@ public class SyncRunner extends QObject implements Runnable {
     public void enDisconnect() {\r
        isConnected = false;\r
     }\r
+    \r
+    /*\r
     // Refresh the connection\r
     private synchronized boolean refreshConnection() {\r
+       \r
                logger.log(logger.EXTREME, "Entering SyncRunner.refreshConnection()");\r
 //        Calendar cal = Calendar.getInstance();\r
                \r
@@ -1669,6 +1673,8 @@ public class SyncRunner extends QObject implements Runnable {
                return true;\r
     }\r
     \r
+    */\r
+    \r
        public synchronized boolean addWork(String request) {\r
                if (workQueue.offer(request))\r
                        return true;\r
index 0d39afe..18ec06d 100644 (file)
@@ -35,8 +35,7 @@ import javax.crypto.spec.SecretKeySpec;
 public class AESEncrypter\r
 {\r
        private Cipher cipher;\r
-       private String password;\r
-       private String userid;\r
+       private String string;\r
        private final SecretKeySpec skeySpec;\r
        private final AlgorithmParameterSpec paramSpec;\r
        \r
@@ -44,8 +43,7 @@ public class AESEncrypter
        {\r
                String key = "x331aq5wDQ8xO81v";\r
                skeySpec = new SecretKeySpec(key.getBytes(), "AES");\r
-               password = new String("");\r
-               userid = new String("");\r
+               string = new String("");\r
                \r
                // Create an 8-byte initialization vector\r
                byte[] iv = new byte[]\r
@@ -63,18 +61,11 @@ public class AESEncrypter
                        e.printStackTrace();\r
                }\r
        }\r
-               \r
-       public void setPassword(String s) {\r
-               password = s;\r
-       }\r
-       public String getPassword() {\r
-               return password;\r
-       }\r
-       public void setUserid(String s) {\r
-               userid = s;\r
+       public void setString(String s) {\r
+               string = s;\r
        }\r
-       public String getUserid() {\r
-               return userid;\r
+       public String getString() {\r
+               return string;\r
        }\r
        \r
        public void encrypt(OutputStream out)\r
@@ -86,7 +77,7 @@ public class AESEncrypter
 \r
 //                     String u = new String(userid +" " +password);\r
                        StringBuffer u = new StringBuffer(1024);\r
-                       u.append("Userid:" +userid+ " " +password);\r
+                       u.append(string);\r
                        for (int i=u.length(); i<128; i++)\r
                                u.append('\0');\r
 \r
@@ -113,14 +104,7 @@ public class AESEncrypter
                        in = new CipherInputStream(in, cipher);\r
                        if (in.read(buf) >= 0)\r
                        {\r
-                               String line = new String(buf);\r
-                               int offset = line.indexOf(" ");\r
-                               if (offset > 0) {\r
-                                       userid = line.substring(line.indexOf(":")+1, offset);\r
-                                       password = line.substring(offset+1);\r
-                                       password = password.trim();\r
-                               }\r
-                               \r
+                               string = new String(buf);       \r
                        }\r
                        in.close();\r
                } catch (java.io.IOException e) {\r
index 49036c1..7776d4e 100644 (file)
@@ -1255,4 +1255,27 @@ public class ListManager  {
        }\r
        \r
        \r
+       // Reload the note's tag names.  This is called when a tag's name changes by\r
+       // the user.  It updates all notes with that tag to the new tag name.\r
+       public void reloadNoteTagNames(String tagGuid, String newName) {\r
+               \r
+               // Set the master index\r
+               for (int i=0; i<getMasterNoteIndex().size(); i++) {\r
+                       for (int j=0; j<getMasterNoteIndex().get(i).getTagGuids().size(); j++) {\r
+                               if (getMasterNoteIndex().get(i).getTagGuids().get(j).equals(tagGuid)) {\r
+                                       getMasterNoteIndex().get(i).getTagNames().set(j, newName);\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               // Set the current index\r
+               for (int i=0; i<getNoteIndex().size(); i++) {\r
+                       for (int j=0; j<getNoteIndex().get(i).getTagGuids().size(); j++) {\r
+                               if (getNoteIndex().get(i).getTagGuids().get(j).equals(tagGuid)) {\r
+                                       getNoteIndex().get(i).getTagNames().set(j, newName);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       \r
 }\r
index 99d5393..ecb912c 100644 (file)
@@ -302,7 +302,7 @@ public class ImportData {
                                if (reader.name().equalsIgnoreCase("AlternateData")) \r
                                        resource.setAlternateData(processData("AlternateData"));\r
                                if (reader.name().equalsIgnoreCase("RecognitionData")) \r
-                                       resource.setRecognition(processData("NoteResourceAttribute"));\r
+                                       resource.setRecognition(processData("RecognitionData"));\r
                                if (reader.name().equalsIgnoreCase("NoteResourceAttribute")) \r
                                        resource.setAttributes(processResourceAttributes());\r
                        }\r
index 3a9627d..5736545 100644 (file)
@@ -26,13 +26,13 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
 import java.util.Date;\r
+import java.util.List;\r
+\r
+import javax.xml.bind.DatatypeConverter;\r
 \r
 import com.evernote.edam.type.Data;\r
 import com.evernote.edam.type.Note;\r
 import com.evernote.edam.type.NoteAttributes;\r
-import com.evernote.edam.type.NoteSortOrder;\r
-import com.evernote.edam.type.Notebook;\r
-import com.evernote.edam.type.Publishing;\r
 import com.evernote.edam.type.Resource;\r
 import com.evernote.edam.type.ResourceAttributes;\r
 import com.evernote.edam.type.Tag;\r
@@ -40,9 +40,6 @@ import com.trolltech.qt.core.QByteArray;
 import com.trolltech.qt.core.QFile;\r
 import com.trolltech.qt.core.QIODevice;\r
 import com.trolltech.qt.core.QUuid;\r
-import com.trolltech.qt.gui.QIcon;\r
-import com.trolltech.qt.gui.QImage;\r
-import com.trolltech.qt.gui.QPixmap;\r
 import com.trolltech.qt.xml.QXmlStreamReader;\r
 \r
 import cx.fbn.nevernote.sql.DatabaseConnection;\r
@@ -56,26 +53,21 @@ public class ImportEnex {
        DatabaseConnection                                      conn;\r
        QXmlStreamReader                                        reader;\r
        private Note                                            note;\r
-       private Notebook                                        notebook;\r
-       private boolean                                         notebookIsDirty;\r
-       private boolean                                         notebookIsLocal;\r
-       private boolean                                         notebookIsReadOnly;\r
-       private QIcon                                           notebookIcon;\r
-       private Tag                                                     tag;\r
-       private boolean                                         tagIsDirty;\r
        public int                                                      highUpdateSequenceNumber;\r
        public long                                                     lastSequenceDate;\r
        private final ApplicationLogger         logger;\r
-       private final boolean                           backup;\r
        private String                                          notebookGuid;\r
        public final boolean                            importTags = false;\r
        public final boolean                            importNotebooks = false;\r
        private String newGuid;\r
+       List<Tag> tags;\r
+       public boolean createNewTags;\r
        \r
        public ImportEnex(DatabaseConnection c, boolean full) {\r
                logger = new ApplicationLogger("import.log");\r
-               backup = full;\r
                conn = c;\r
+               tags = conn.getTagTable().getAll();\r
+               createNewTags = true;\r
        }\r
        \r
        public void importData(String f) {\r
@@ -108,30 +100,11 @@ public class ImportEnex {
                                        note.getResources().get(i).setUpdateSequenceNum(0);\r
                                }\r
                                note.setActive(true);\r
+                               if (note.getUpdated() == 0) {\r
+                                       note.setUpdated(note.getCreated());\r
+                               }\r
                                conn.getNoteTable().addNote(note, true);\r
                        }\r
-                       if (reader.name().equalsIgnoreCase("notebook") && reader.isStartElement() && (backup || importNotebooks)) {\r
-                               processNotebookNode();\r
-                       String existingGuid = conn.getNotebookTable().findNotebookByName(notebook.getName());\r
-                       if (existingGuid == null) {\r
-                               conn.getNotebookTable().addNotebook(notebook, notebookIsDirty, notebookIsLocal);\r
-                       } else {\r
-                               conn.getNotebookTable().updateNotebookGuid(existingGuid, notebook.getGuid());\r
-                               conn.getNotebookTable().updateNotebook(notebook, notebookIsDirty);\r
-                       }\r
-                       conn.getNotebookTable().setIcon(notebook.getGuid(), notebookIcon, "PNG");\r
-                       conn.getNotebookTable().setReadOnly(notebook.getGuid(), notebookIsReadOnly);\r
-                       }\r
-                       if (reader.name().equalsIgnoreCase("tag") && reader.isStartElement() && (backup || importTags)) {\r
-                               processTagNode();\r
-                               String testGuid = conn.getTagTable().findTagByName(tag.getName());\r
-                       if (testGuid == null)\r
-                               conn.getTagTable().addTag(tag, tagIsDirty);\r
-                       else {\r
-                               conn.getTagTable().updateTagGuid(testGuid, tag.getGuid());\r
-                               conn.getTagTable().updateTag(tag,tagIsDirty);\r
-                       }\r
-                       }\r
                }\r
                xmlFile.close();\r
        }\r
@@ -149,8 +122,34 @@ public class ImportEnex {
                                note.setTitle(textValue());\r
                        if (reader.name().equalsIgnoreCase("Created")) \r
                                note.setCreated(datetimeValue());\r
+                       if (reader.name().equalsIgnoreCase("updated")) \r
+                               note.setCreated(datetimeValue());\r
                        if (reader.name().equalsIgnoreCase("Content")) \r
                                note.setContent(textValue());\r
+                       if (reader.name().equalsIgnoreCase("tag") && createNewTags) {\r
+                               String tag = textValue();\r
+                               Tag noteTag = null;\r
+                               boolean found=false;\r
+                               for (int i=0; i<tags.size(); i++) {\r
+                                       if (tags.get(i).getName().equalsIgnoreCase(tag)) {\r
+                                               found=true;\r
+                                               noteTag = tags.get(i);\r
+                                               i=tags.size();\r
+                                       }\r
+                               }\r
+                               \r
+                               if (!found) {\r
+                                       noteTag = new Tag();\r
+                                       noteTag.setName(tag);\r
+                                       String tagGuid = QUuid.createUuid().toString().replace("{", "").replace("}", "");\r
+                                       noteTag.setGuid(tagGuid);\r
+                                       noteTag.setName(tag);\r
+                                       tags.add(noteTag);\r
+                                       conn.getTagTable().addTag(noteTag, true);\r
+                               }\r
+                               note.addToTagNames(noteTag.getName());\r
+                               note.addToTagGuids(noteTag.getGuid());\r
+                       }\r
                        if (reader.name().equalsIgnoreCase("note-attributes")) \r
                                note.setAttributes(processNoteAttributes());\r
                        if (reader.name().equalsIgnoreCase("resource")) {\r
@@ -166,7 +165,7 @@ public class ImportEnex {
                Resource resource = new Resource();\r
                boolean atEnd = false;\r
                while(!atEnd) {\r
-                       if (reader.isStartElement()) {\r
+                       if (reader.isStartElement() && reader.name().equalsIgnoreCase("resource")) {\r
                                String newResGuid = QUuid.createUuid().toString().replace("{", "").replace("}", "");\r
                                resource.setGuid(newResGuid);\r
                                resource.setNoteGuid(this.newGuid);\r
@@ -179,17 +178,15 @@ public class ImportEnex {
                                resource.setWidth(shortValue());\r
                        if (reader.name().equalsIgnoreCase("data")) \r
                                resource.setData(processData("data"));\r
-//                             if (reader.name().equalsIgnoreCase("recognition")) \r
-//                                     resource.setRecognition(processData("NoteResourceAttribute"));\r
+                       if (reader.name().equalsIgnoreCase("resource-attributes")) \r
+                               resource.setAttributes(processResourceAttributes());\r
+                       if (reader.name().equalsIgnoreCase("recognition")) \r
+                               resource.setRecognition(processRecognition());\r
                        reader.readNext();\r
                        if (reader.name().equalsIgnoreCase("resource") && reader.isEndElement())\r
                                atEnd = true;\r
                }\r
-               resource.setAttributes(new ResourceAttributes());\r
-               resource.getAttributes().setSourceURL("");\r
-               conn.getNoteTable().noteResourceTable.saveNoteResource(resource, true);\r
-\r
-               \r
+               conn.getNoteTable().noteResourceTable.updateNoteResource(resource, true);\r
                return resource;\r
        }\r
        \r
@@ -198,21 +195,24 @@ public class ImportEnex {
                boolean atEnd = false;\r
                while(!atEnd) {\r
                        if (reader.isStartElement()) {\r
+                               try {\r
                                byte[] b = textValue().getBytes();   // data binary\r
                                if (b.length > 0) {\r
                                        QByteArray hexData = new QByteArray(b);\r
-                                       QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));\r
-                                       data.setBody(binData.toByteArray());\r
+                                       String hexString = hexData.toString();\r
+                                       data.setBody(DatatypeConverter.parseBase64Binary(hexString));\r
                                        MessageDigest md;\r
                                        try {\r
                                                md = MessageDigest.getInstance("MD5");\r
-                                               md.update(b);\r
+                                               md.update(data.getBody());\r
                                                data.setBodyHash(md.digest());\r
                                        } catch (NoSuchAlgorithmException e) {\r
                                                // TODO Auto-generated catch block\r
                                                e.printStackTrace();\r
                                        }\r
-                               }\r
+                                       \r
+                               }}\r
+                               catch (Exception e) {};\r
                        }\r
                        if (reader.name().equalsIgnoreCase(nodeName) && reader.isEndElement())\r
                                atEnd = true;\r
@@ -224,138 +224,94 @@ public class ImportEnex {
 \r
        \r
        private NoteAttributes processNoteAttributes() {\r
-       NoteAttributes attributes = new NoteAttributes();\r
+               NoteAttributes attributes = new NoteAttributes();\r
        \r
-       boolean atEnd = false;\r
-       while(!atEnd) {\r
-               if (reader.isStartElement()) {\r
-                       if (reader.name().equalsIgnoreCase("source-url")) \r
-                               attributes.setSourceURL(textValue());\r
-                       if (reader.name().equalsIgnoreCase("source")) \r
-                               attributes.setSource(textValue());\r
-               }\r
-               reader.readNext();\r
-               if (reader.name().equalsIgnoreCase("note-attributes") && reader.isEndElement())\r
-                       atEnd = true;\r
-       }\r
-       \r
-       return attributes;\r
-}\r
-\r
-               \r
-       \r
-\r
-       \r
-\r
-       \r
-       private void processNotebookNode() {\r
-               notebook = new Notebook();\r
-               Publishing p = new Publishing();\r
-               notebook.setPublishing(p);\r
-               notebookIsDirty = false;\r
-               notebookIsLocal = false;\r
-               notebookIsReadOnly = false;\r
-               notebookIcon = null;\r
                boolean atEnd = false;\r
                while(!atEnd) {\r
                        if (reader.isStartElement()) {\r
-                               if (reader.name().equalsIgnoreCase("Guid")) \r
-                                       notebook.setGuid(textValue());\r
-                               if (reader.name().equalsIgnoreCase("Name")) \r
-                                       notebook.setName(textValue());\r
-                               if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
-                                       notebook.setUpdateSequenceNum(intValue());\r
-                               if (reader.name().equalsIgnoreCase("ServiceCreated")) \r
-                                       notebook.setServiceCreated(longValue());\r
-                               if (reader.name().equalsIgnoreCase("ServiceUpdated")) \r
-                                       notebook.setServiceUpdated(longValue());\r
-                               if (reader.name().equalsIgnoreCase("DefaultNotebook")) {\r
-                                       notebook.setDefaultNotebook(booleanValue());\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("Dirty")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsDirty = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("LocalNotebook")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsLocal = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("ReadOnly")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsReadOnly = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingPublicDescription")) {\r
-                                       notebook.getPublishing().setPublicDescription(textValue());\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingUri")) {\r
-                                       notebook.getPublishing().setUri(textValue());\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingOrder")) {\r
-                                       notebook.getPublishing().setOrder(NoteSortOrder.findByValue(intValue()));\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("ReadOnly")) {\r
-                                       if (booleanValue())\r
-                                               notebookIsReadOnly = true;\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("PublishingAscending")) {\r
-                                       if (booleanValue())\r
-                                               notebook.getPublishing().setAscending(true);\r
-                                       else\r
-                                               notebook.getPublishing().setAscending(false);\r
-                               }               \r
-                               if (reader.name().equalsIgnoreCase("Icon")) {\r
-                                       byte[] b = textValue().getBytes();   // data binary\r
-                                       QByteArray hexData = new QByteArray(b);\r
-                                       QByteArray binData = new QByteArray(QByteArray.fromHex(hexData));\r
-                                       notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData)));\r
-                               }\r
-                               if (reader.name().equalsIgnoreCase("Stack"))\r
-                                       notebook.setStack(textValue());\r
+                               if (reader.name().equalsIgnoreCase("source-url")) \r
+                                       attributes.setSourceURL(textValue());\r
+                               if (reader.name().equalsIgnoreCase("source")) \r
+                                       attributes.setSource(textValue());\r
+                               if (reader.name().equalsIgnoreCase("longitude")) \r
+                                       attributes.setLongitude(doubleValue());\r
+                               if (reader.name().equalsIgnoreCase("latitude")) \r
+                                       attributes.setLatitude(doubleValue());\r
+                               if (reader.name().equalsIgnoreCase("altitude")) \r
+                                       attributes.setAltitude(doubleValue());\r
+                               if (reader.name().equalsIgnoreCase("author")) \r
+                                       attributes.setAuthor(textValue());\r
+                               if (reader.name().equalsIgnoreCase("subject-date")) \r
+                                       attributes.setSubjectDate(datetimeValue());\r
                        }\r
                        reader.readNext();\r
-                       if (reader.name().equalsIgnoreCase("notebook") && reader.isEndElement())\r
-                               atEnd = true;\r
+                       if (reader.name().equalsIgnoreCase("note-attributes") && reader.isEndElement())\r
+                       atEnd = true;\r
                }\r
-               return;\r
+       \r
+               return attributes;\r
        }\r
 \r
+               \r
        \r
+       private Data processRecognition() {\r
+               Data reco = new Data();\r
+               reco.setBody(textValue().getBytes());\r
+               MessageDigest md;\r
+               try {\r
+                       md = MessageDigest.getInstance("MD5");\r
+                       md.update(reco.getBody());\r
+                       reco.setBodyHash(md.digest());\r
+                       reco.setSize(reco.getBody().length);\r
+               } catch (NoSuchAlgorithmException e) {\r
+                       // TODO Auto-generated catch block\r
+                       e.printStackTrace();\r
+               }\r
+               return reco;\r
+       }\r
        \r
-       private void processTagNode() {\r
-               tag = new Tag();\r
-               tagIsDirty = false;\r
+       private ResourceAttributes processResourceAttributes() {\r
+               ResourceAttributes attributes = new ResourceAttributes();\r
                boolean atEnd = false;\r
                while(!atEnd) {\r
-                       if (reader.isStartElement()) {                  \r
-                               if (reader.name().equalsIgnoreCase("Guid")) \r
-                                       tag.setGuid(textValue());\r
-                               if (reader.name().equalsIgnoreCase("Name")) \r
-                                       tag.setName(textValue());\r
-                               if (reader.name().equalsIgnoreCase("UpdateSequenceNumber")) \r
-                                       tag.setUpdateSequenceNum(intValue());\r
-                               if (reader.name().equalsIgnoreCase("ParentGuid")) \r
-                                       tag.setParentGuid(textValue());\r
-                               if (reader.name().equalsIgnoreCase("Dirty")) {\r
-                                       if (booleanValue())\r
-                                               tagIsDirty = true;\r
-                               }\r
+                       if (reader.isStartElement()) {\r
+                               if (reader.name().equalsIgnoreCase("CameraMake")) \r
+                                       attributes.setCameraMake(textValue());          \r
+                               if (reader.name().equalsIgnoreCase("CameraModel")) \r
+                                       attributes.setCameraModel(textValue());         \r
+                               if (reader.name().equalsIgnoreCase("FileName")) \r
+                                       attributes.setFileName(textValue());            \r
+                               if (reader.name().equalsIgnoreCase("RecoType")) \r
+                                       attributes.setRecoType(textValue());            \r
+                               if (reader.name().equalsIgnoreCase("CameraModel")) \r
+                                       attributes.setCameraMake(textValue());          \r
+                               if (reader.name().equalsIgnoreCase("SourceURL")) \r
+                                       attributes.setSourceURL(textValue());           \r
+                               if (reader.name().equalsIgnoreCase("Altitude")) \r
+                                       attributes.setAltitude(doubleValue());          \r
+                               if (reader.name().equalsIgnoreCase("Longitude")) \r
+                                       attributes.setLongitude(doubleValue());         \r
+                               if (reader.name().equalsIgnoreCase("Latitude")) \r
+                                       attributes.setLatitude(doubleValue());          \r
+                               if (reader.name().equalsIgnoreCase("Timestamp")) \r
+                                       attributes.setTimestamp(longValue());           \r
+                               if (reader.name().equalsIgnoreCase("Attachment")) \r
+                                       attributes.setAttachment(booleanValue());               \r
+                               if (reader.name().equalsIgnoreCase("ClientWillIndex")) \r
+                                       attributes.setClientWillIndex(booleanValue());          \r
                        }\r
                        reader.readNext();\r
-                       if (reader.name().equalsIgnoreCase("tag") && reader.isEndElement())\r
+                       if (reader.name().equalsIgnoreCase("resource-attributes") && reader.isEndElement())\r
                                atEnd = true;\r
                }\r
-               return;\r
+               \r
+               return attributes;\r
        }\r
        \r
        \r
-       \r
-       \r
        private String textValue() {\r
                return reader.readElementText();\r
        }\r
-       private int intValue() {\r
-               return new Integer(textValue());\r
-       }\r
        private long longValue() {\r
                return new Long(textValue());\r
        }\r
@@ -397,4 +353,8 @@ public class ImportEnex {
        public String getErrorMessage() {\r
                return errorMessage;\r
        }\r
+\r
+       private double doubleValue() {\r
+               return new Double(textValue());\r
+       }\r
 }\r