OSDN Git Service

Add support for Evernote API 1.20 and attribute contentClass field.
authorRandy Baumgarte <randy@fbn.cx>
Thu, 5 Jan 2012 17:40:01 +0000 (12:40 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Thu, 5 Jan 2012 17:40:01 +0000 (12:40 -0500)
.classpath
lib/evernote-api-1.19.jar [deleted file]
lib/evernote-api-1.20.jar [new file with mode: 0644]
lib/libthrift.jar
nixnote.bat
nixnote.sh
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/sql/DatabaseConnection.java
src/cx/fbn/nevernote/sql/NoteTable.java

index 1c8c489..5240e15 100644 (file)
@@ -2,7 +2,7 @@
 <classpath>\r
        <classpathentry kind="src" path="src"/>\r
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
-       <classpathentry kind="lib" path="lib/evernote-api-1.19.jar"/>\r
+       <classpathentry kind="lib" path="lib/evernote-api-1.20.jar"/>\r
        <classpathentry kind="lib" path="lib/h2-1.3.158.jar"/>\r
        <classpathentry kind="lib" path="lib/libthrift.jar"/>\r
        <classpathentry kind="lib" path="lib/log4j-1.2.14.jar"/>\r
diff --git a/lib/evernote-api-1.19.jar b/lib/evernote-api-1.19.jar
deleted file mode 100644 (file)
index 371d80e..0000000
Binary files a/lib/evernote-api-1.19.jar and /dev/null differ
diff --git a/lib/evernote-api-1.20.jar b/lib/evernote-api-1.20.jar
new file mode 100644 (file)
index 0000000..be4409c
Binary files /dev/null and b/lib/evernote-api-1.20.jar differ
index 543c452..47c3cd3 100644 (file)
Binary files a/lib/libthrift.jar and b/lib/libthrift.jar differ
index ad65f9e..9dfa657 100644 (file)
@@ -83,7 +83,7 @@ set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\commons-codec-1.5.jar
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\commons-compress-1.2.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\commons-lang3-3.0.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\commons-logging-1.1.1.jar\r
-set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\evernote-api-1.19.jar\r
+set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\evernote-api-1.20.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\h2-1.3.158.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\httpclient-4.1.1.jar\r
 set NN_CLASSPATH=%NN_CLASSPATH%;%NIXNOTE%lib\httpcore-4.1.jar\r
index 3466cfd..1f7a173 100755 (executable)
@@ -86,7 +86,7 @@ NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/commons-codec-1.5.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/commons-compress-1.2.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/commons-lang3-3.0.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/commons-logging-1.1.1.jar
-NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/evernote-api-1.19.jar
+NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/evernote-api-1.20.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/h2-1.3.158.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/httpclient-4.1.1.jar
 NN_CLASSPATH=$NN_CLASSPATH:$NIXNOTE/lib/httpcore-4.1.jar
index 9fd697f..8dfb5f3 100644 (file)
@@ -4451,7 +4451,8 @@ public class NeverNote extends QMainWindow{
                if (conn.getNoteTable().isThumbnailNeeded(guid)) {
                        thumbnailHTMLReady(guid, js, Global.calculateThumbnailZoom(js.toString()));
                }
-               if (readOnly || inkNote)
+               if (readOnly || inkNote || 
+                               (note.getAttributes() != null && note.getAttributes().getContentClass() != null && note.getAttributes().getContentClass() != ""))
                        browser.getBrowser().page().setContentEditable(false);  // We don't allow editing of ink notes
                else
                        browser.getBrowser().page().setContentEditable(true);
index 3d69554..f81da8f 100644 (file)
@@ -256,6 +256,10 @@ public class DatabaseConnection {
                        executeSql("alter table note add column pinned integer");
                        executeSql("update note set pinned = 0");
                }
+               if (!dbTableColumnExists("NOTE", "ATTRIBUTECONTENTCLASS")) {
+                       executeSql("alter table note add column attributeContentClass VarChar");
+                       executeSql("update note set attributeContentClass = ''");
+               }
        }
        
        public void executeSql(String sql) {
index 0901a8b..2cfeb45 100644 (file)
@@ -176,6 +176,7 @@ public class NoteTable {
                                        +"created, updated, deleted, active, notebookGuid, "\r
                                        +"attributeSubjectDate, attributeLatitude, attributeLongitude, attributeAltitude, "\r
                                        +"attributeAuthor, attributeSource, attributeSourceUrl, attributeSourceApplication, "\r
+                                       +"attributeContentClass, "\r
                                        +"content, contentHash, contentLength"\r
                                        +" from Note where guid=:guid and isExpunged=false")) {\r
                                                logger.log(logger.EXTREME, "Note SQL select prepare with content has failed.");\r
@@ -189,7 +190,8 @@ public class NoteTable {
                                        +"guid, updateSequenceNumber, title, "\r
                                        +"created, updated, deleted, active, notebookGuid, "\r
                                        +"attributeSubjectDate, attributeLatitude, attributeLongitude, attributeAltitude, "\r
-                                       +"attributeAuthor, attributeSource, attributeSourceUrl, attributeSourceApplication "\r
+                                       +"attributeAuthor, attributeSource, attributeSourceUrl, attributeSourceApplication, "\r
+                                       +"attributeContentClass"\r
                                        +" from Note where guid=:guid and isExpunged=false")) {\r
                                                logger.log(logger.EXTREME, "Note SQL select prepare without content has failed.");\r
                                                logger.log(logger.MEDIUM, getQueryWithoutContent.lastError());\r
@@ -203,7 +205,8 @@ public class NoteTable {
                                +"guid, updateSequenceNumber, title, "\r
                                +"created, updated, deleted, active, notebookGuid, "\r
                                +"attributeSubjectDate, attributeLatitude, attributeLongitude, attributeAltitude, "\r
-                               +"attributeAuthor, attributeSource, attributeSourceUrl, attributeSourceApplication "\r
+                               +"attributeAuthor, attributeSource, attributeSourceUrl, attributeSourceApplication, "\r
+                               +"attributeContentClass "\r
                                +" from Note where isExpunged = false")) {\r
                                logger.log(logger.EXTREME, "Note SQL select prepare without content has failed.");\r
                                        logger.log(logger.MEDIUM, getQueryWithoutContent.lastError());\r
@@ -292,6 +295,7 @@ public class NoteTable {
                na.setSource(query.valueString(13));\r
                na.setSourceURL(query.valueString(14));\r
                na.setSourceApplication(query.valueString(15));\r
+               na.setContentClass(query.valueString(16));\r
                \r
                if (loadTags) {\r
                        n.setTagGuids(noteTagsTable.getNoteTags(n.getGuid()));\r
@@ -308,7 +312,7 @@ public class NoteTable {
                if (loadContent) {\r
                        QTextCodec codec = QTextCodec.codecForLocale();\r
                        codec = QTextCodec.codecForName("UTF-8");\r
-               String unicode =  codec.fromUnicode(query.valueString(16)).toString();\r
+               String unicode =  codec.fromUnicode(query.valueString(17)).toString();\r
 \r
                // This is a hack.  Basically I need to convert HTML Entities to "normal" text, but if I\r
                // convert the &lt; character to < it will mess up the XML parsing.  So, to get around this\r
@@ -316,7 +320,7 @@ public class NoteTable {
                // I'm done I convert it back.\r
                StringBuffer buffer = new StringBuffer(unicode);\r
                if (Global.enableHTMLEntitiesFix && unicode.indexOf("&#") > 0) {\r
-                       unicode = query.valueString(16);\r
+                       unicode = query.valueString(17);\r
                        //System.out.println(unicode);\r
                        //unicode = unicode.replace("&lt;", "&_lt;");\r
                        //unicode = codec.fromUnicode(StringEscapeUtils.unescapeHtml(unicode)).toString();\r
@@ -343,10 +347,10 @@ public class NoteTable {
                n.setContent(unicode);\r
 //                     n.setContent(query.valueString(16).toString());\r
                        \r
-                       String contentHash = query.valueString(17);\r
+                       String contentHash = query.valueString(18);\r
                        if (contentHash != null)\r
                                n.setContentHash(contentHash.getBytes());\r
-                       n.setContentLength(new Integer(query.valueString(18)));\r
+                       n.setContentLength(new Integer(query.valueString(19)));\r
                }\r
                if (loadResources)\r
                        n.setResources(noteResourceTable.getNoteResources(n.getGuid(), loadBinary));\r