From: Randy Baumgarte Date: Sat, 25 Aug 2012 18:41:17 +0000 (-0400) Subject: - Correct issue with importing when not a premium member. X-Git-Tag: version0.1.1~43 X-Git-Url: http://git.sourceforge.jp/view?p=neighbornote%2FNeighborNote.git;a=commitdiff_plain;h=e565a6dfd9ace9638a7afcfb66f7a2f34c6a82ce - Correct issue with importing when not a premium member. - Added more debugging information to try and fix a sync issue - Removed accounting information that isn't available with OAuth - Prep work for 1.3 build. --- diff --git a/package_scripts/deb/amd64/control b/package_scripts/deb/amd64/control index ad88a3a..d478791 100644 --- a/package_scripts/deb/amd64/control +++ b/package_scripts/deb/amd64/control @@ -4,7 +4,7 @@ Section: x11 Priority: optional Architecture: amd64 Installed-Size: 133120 -Depends: openjdk-6-jre | openjdk-6-jdk | sun-java6-jdk | sun-java6-jre | java6-sdk | java6-runtime | default-jre +Depends: openjdk-6-jre | openjdk-6-jdk | sun-java6-jdk | sun-java6-jre | java6-sdk | java6-runtime | default-jre, libssl (>=0.9.8) Maintainer: Randy Baumgarte Description: Open Source Evernote client. NixNote is a client for the Evernote service (www.evernote.com). It diff --git a/package_scripts/deb/i386/control b/package_scripts/deb/i386/control index 94c86a6..d2cd5c9 100644 --- a/package_scripts/deb/i386/control +++ b/package_scripts/deb/i386/control @@ -4,7 +4,7 @@ Section: x11 Priority: optional Architecture: i386 Installed-Size: 133120 -Depends: openjdk-6-jre | openjdk-6-jdk | sun-java6-jdk | sun-java6-jre | java6-sdk | java6-runtime | default-jre +Depends: openjdk-6-jre | openjdk-6-jdk | sun-java6-jdk | sun-java6-jre | java6-sdk | java6-runtime | default-jre, libssl (>=0.9.8) Maintainer: Randy Baumgarte Description: Open Source Evernote client. NixNote is a client for the Evernote service (www.evernote.com). It diff --git a/src/cx/fbn/nevernote/Global.java b/src/cx/fbn/nevernote/Global.java index 02edff2..e395575 100644 --- a/src/cx/fbn/nevernote/Global.java +++ b/src/cx/fbn/nevernote/Global.java @@ -63,7 +63,7 @@ import cx.fbn.nevernote.utilities.Pair; public class Global { // Set current version and the known versions. - public static String version = "1.2"; + public static String version = "1.3"; public static String[] validVersions = {"1.2", "1.1", "1.0", "0.99", "0.98", "0.97", "0.96"}; public static String username = ""; //public static String password = ""; diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index 2987cf6..5ec756e 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -1137,16 +1137,17 @@ public class NeverNote extends QMainWindow{ public void setMessage(String s) { logger.log(logger.HIGH, "Entering NeverNote.setMessage"); - statusBar.show(); - logger.log(logger.HIGH, "Message: " +s); - statusBar.showMessage(s); - emitLog.add(s); - - - messageTimer.stop(); - messageTimer.setSingleShot(true); - messageTimer.start(); + if (statusBar != null) { + statusBar.show(); + logger.log(logger.HIGH, "Message: " +s); + statusBar.showMessage(s); + emitLog.add(s); + messageTimer.stop(); + messageTimer.setSingleShot(true); + messageTimer.start(); + } + logger.log(logger.HIGH, "Leaving NeverNote.setMessage"); } @@ -2757,8 +2758,8 @@ public class NeverNote extends QMainWindow{ QMessageBox.about(this, tr("About NixNote"), tr("

NixNote


Version ") - //+Global.version - +"1.2.120724" + +Global.version + //+"1.2.120724" +tr("
" +"Open Source Evernote Client.

" +"Licensed under GPL v2.


" @@ -6106,12 +6107,26 @@ public class NeverNote extends QMainWindow{ // importKeepWatcher.addPath(records.get(i).folder.replace('\\', '/')); for (int i=0; i monitorDelete = importKeepWatcher.directories(); + for (int i=0; i"); + logger.log(logger.EXTREME, "List of directories being watched (delete)..."); + monitorDelete = importDeleteWatcher.directories(); + for (int i=0; i"); + importKeepWatcher.directoryChanged.connect(this, "folderImportKeep(String)"); importDeleteWatcher.directoryChanged.connect(this, "folderImportDelete(String)"); @@ -6128,6 +6143,8 @@ public class NeverNote extends QMainWindow{ } } } + + // Menu folderImport action triggered public void folderImport() { List recs = conn.getWatchFolderTable().getAll(); WatchFolder dialog = new WatchFolder(recs, listManager.getNotebookIndex()); @@ -6161,8 +6178,9 @@ public class NeverNote extends QMainWindow{ setupFolderImports(); } + public void folderImportKeep(String dirName) throws NoSuchAlgorithmException { - + logger.log(logger.LOW, "Inside folderImportKeep"); String whichOS = System.getProperty("os.name"); if (whichOS.contains("Windows")) dirName = dirName.replace('/','\\'); @@ -6174,40 +6192,44 @@ public class NeverNote extends QMainWindow{ String notebook = conn.getWatchFolderTable().getNotebook(dirName); for (int i=0; i guids = new ArrayList(); @@ -709,9 +729,11 @@ public class NoteTable { else expungeNote(guid, false, true); } + logger.log(logger.HIGH, "Leaving NoteTable.expungeAllDeletedNotes"); } // Update the note sequence number public void updateNoteSequence(String guid, int sequence) { + logger.log(logger.HIGH, "Entering NoteTable.updateNoteSequence"); boolean check; NSqlQuery query = new NSqlQuery(db.getConnection()); check = query.prepare("Update Note set updateSequenceNumber=:sequence where guid=:guid"); @@ -724,9 +746,11 @@ public class NoteTable { logger.log(logger.MEDIUM, "Note sequence update failed."); logger.log(logger.MEDIUM, query.lastError()); } + logger.log(logger.HIGH, "Leaving NoteTable.updateNoteSequence"); } // Update the note Guid public void updateNoteGuid(String oldGuid, String newGuid) { + logger.log(logger.HIGH, "Entering NoteTable.updateNoteGuid"); boolean check; NSqlQuery query = new NSqlQuery(db.getConnection()); NSqlQuery resQuery = new NSqlQuery(db.getResourceConnection()); @@ -768,9 +792,11 @@ public class NoteTable { logger.log(logger.MEDIUM, "Note guid update failed for noteresources."); logger.log(logger.MEDIUM, resQuery.lastError()); } + logger.log(logger.HIGH, "Leaving NoteTable.updateNoteGuid"); } // Update a note public void updateNote(Note n) { + logger.log(logger.HIGH, "Entering NoteTable.updateNote"); NoteMetadata meta = getNoteMetaInformation(n.getGuid()); String originalGuid = findAlternateGuid(n.getGuid()); expungeNote(n.getGuid(), true, false); @@ -782,6 +808,7 @@ public class NoteTable { updateNoteGuid(n.getGuid(), originalGuid); updateNoteGuid(originalGuid, n.getGuid()); } + logger.log(logger.HIGH, "Leaving NoteTable.updateNote"); } // Does a note exist? public boolean exists(String guid) { @@ -813,6 +840,7 @@ public class NoteTable { } // This is a convience method to check if a note exists & update/create based upon it public void syncNote(Note note) { + logger.log(logger.HIGH, "Entering NoteTable.syncNote"); // If we got the note from Evernote we use its // metadata instead of the local copy. NoteMetadata meta = null; @@ -834,6 +862,7 @@ public class NoteTable { meta.setGuid(note.getGuid()); updateNoteMetadata(meta); } + logger.log(logger.HIGH, "Leaving NoteTable.syncNote"); } // Get a list of notes that need to be updated public List getDirty() { @@ -861,6 +890,7 @@ public class NoteTable { tempNote = getNote(index.get(i), true,true,false,true,true); notes.add(tempNote); } + logger.log(logger.LOW, "Dirty local notes: " +new Integer(notes.size()).toString()); return notes; } // Get a list of notes that need to be updated @@ -889,6 +919,7 @@ public class NoteTable { tempNote = getNote(index.get(i), true,true,false,true,true); notes.add(tempNote); } + logger.log(logger.LOW, "Dirty linked local notes: " +new Integer(notes.size()).toString()); return notes; } // Get a list of notes that need to be updated @@ -919,6 +950,7 @@ public class NoteTable { tempNote = getNote(index.get(i), true,true,false,true,true); notes.add(tempNote); } + logger.log(logger.LOW, "Dirty local notes for notebook " +notebookGuid +": " +new Integer(notes.size()).toString()); return notes; } // Get a list of notes that need to be updated @@ -966,6 +998,7 @@ public class NoteTable { // Reset the dirty bit public void resetDirtyFlag(String guid) { + logger.log(logger.LOW, "Resetting dirty flag for " +guid); NSqlQuery query = new NSqlQuery(db.getConnection()); query.prepare("Update note set isdirty=false where guid=:guid"); @@ -1021,6 +1054,42 @@ public class NoteTable { query.exec("select count(guid) from note where isDirty=true and isExpunged = false"); query.next(); int returnValue = new Integer(query.valueString(0)); + logger.log(logger.LOW, "dirty count: " +returnValue); + //query.exec("select count(guid) from note where isDirty=true and Active = 0 and isExpunged = false"); + //query.next(); + //logger.log(logger.LOW, "dirty count (active only): " +query.valueString(0)); + //query.exec("Select count(guid) from Note where isDirty = true and isExpunged = false and notebookGuid not in (select guid from notebook where local = true or linked = true)"); + //query.next(); + //logger.log(logger.LOW, "dirty count (no l&l notebooks): " +query.valueString(0)); + //logger.log(logger.LOW, "Beginning stack trace"); + //logger.log(logger.LOW, Thread.currentThread().getStackTrace()); + + //logger.log(logger.LOW, "*************************"); + //logger.log(logger.LOW, "*** DIRTY RECORD DUMP ***"); + //logger.log(logger.LOW, "*************************"); + //List recs = getDirty(); + //for (int i=0; i notes = conn.getNoteTable().getDirty(); @@ -1215,16 +1218,22 @@ public class SyncRunner extends QObject implements Runnable { // 3.) If a copy of the resource is in the local databbase and it is dirty and the hash doesn't match, we ignore it because there // is a conflict. The note conflict should get a copy of the resource at that time. + Note n = conn.getNoteTable().getNote(resource.getNoteGuid(), false, false, false, false, false); + if (n!=null) { + logger.log(logger.HIGH, "Resource for note " +n.getGuid() +" : " +n.getTitle()); + } boolean saveNeeded = false; /* #1 */ Resource r = getEvernoteResource(noteStore, resource.getGuid(), true,true,true, authToken); Resource l = conn.getNoteTable().noteResourceTable.getNoteResource(r.getGuid(), false); if (l == null) { + logger.log(logger.HIGH, "Local resource not found"); saveNeeded = true; } else { /* #2 */ boolean isNoteDirty = conn.getNoteTable().isNoteDirty(r.getNoteGuid()); - if (!isNoteDirty) + if (!isNoteDirty) { + logger.log(logger.HIGH, "Local resource found, but is not dirty"); saveNeeded = true; - else { + } else { /* #3 */ String remoteHash = ""; if (r != null && r.getData() != null && r.getData().getBodyHash() != null) remoteHash = byteArrayToHexString(r.getData().getBodyHash()); @@ -1237,10 +1246,12 @@ public class SyncRunner extends QObject implements Runnable { } } + logger.log(logger.HIGH, "Resource save needed: " +saveNeeded); if (saveNeeded) conn.getNoteTable().noteResourceTable.updateNoteResource(r, false); if (r.getMime().equalsIgnoreCase("application/vnd.evernote.ink")) downloadInkNoteImage(r.getGuid(), authToken); + } // Sync remote notes diff --git a/src/cx/fbn/nevernote/utilities/FileImporter.java b/src/cx/fbn/nevernote/utilities/FileImporter.java index eacdfcc..d041235 100644 --- a/src/cx/fbn/nevernote/utilities/FileImporter.java +++ b/src/cx/fbn/nevernote/utilities/FileImporter.java @@ -65,8 +65,6 @@ public class FileImporter { //******************************************************** public boolean importFile() { if (fileInfo.isFile()) { - if (!validAttachment(fileInfo.completeSuffix())) - return false; if (fileInfo.completeSuffix().equalsIgnoreCase("txt")) return importTextFile(); return importAttachment(); @@ -177,31 +175,6 @@ public class FileImporter { return true; } - //******************************************************** - //* Check if we found a valid file type - //******************************************************** - // Check if the account supports this type of attachment - private boolean validAttachment(String type) { - if (Global.isPremium()) - return true; - if (type.equalsIgnoreCase("JPG")) - return true; - if (type.equalsIgnoreCase("PNG")) - return true; - if (type.equalsIgnoreCase("GIF")) - return true; - if (type.equalsIgnoreCase("MP3")) - return true; - if (type.equalsIgnoreCase("WAV")) - return true; - if (type.equalsIgnoreCase("AMR")) - return true; - if (type.equalsIgnoreCase("PDF")) - return true; - if (type.equalsIgnoreCase("TXT")) - return true; - return false; - } //******************************************************** //* Check if we found an image @@ -265,11 +238,7 @@ public class FileImporter { public boolean isValidType() { if (!checkFileAttachmentSize(fileName)) return false; - if (fileInfo.completeSuffix().equalsIgnoreCase("txt")) - return true; - if (validAttachment(fileInfo.completeSuffix())) - return true; - return false; + return true; } //************************************************************** //* Check the file attachment to be sure it isn't over 25 mb