From: Randy Baumgarte Date: Mon, 28 Mar 2011 16:30:02 +0000 (-0400) Subject: Cleanup public linked notebook table logic. X-Git-Tag: version0.1.1~171 X-Git-Url: http://git.sourceforge.jp/view?p=neighbornote%2FNeighborNote.git;a=commitdiff_plain;h=a50ca2ca2082718484449be607f9a554337230b5 Cleanup public linked notebook table logic. --- diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index d712f56..3b55dc0 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -2299,6 +2299,7 @@ public class NeverNote extends QMainWindow{ } // Merge tags + @SuppressWarnings("unused") private void mergeTags() { List tags = new ArrayList(); List selections = tagTree.selectedItems(); diff --git a/src/cx/fbn/nevernote/threads/SyncRunner.java b/src/cx/fbn/nevernote/threads/SyncRunner.java index c5e96b4..f2e1cae 100644 --- a/src/cx/fbn/nevernote/threads/SyncRunner.java +++ b/src/cx/fbn/nevernote/threads/SyncRunner.java @@ -1833,15 +1833,22 @@ public class SyncRunner extends QObject implements Runnable { THttpClient linkedNoteStoreTrans = new THttpClient(linkedNoteStoreUrl); TBinaryProtocol linkedNoteStoreProt = new TBinaryProtocol(linkedNoteStoreTrans); Client linkedNoteStore = new NoteStore.Client(linkedNoteStoreProt, linkedNoteStoreProt); - - linkedAuthResult = linkedNoteStore.authenticateToSharedNotebook(books.get(i).getShareKey(), authToken); + + linkedAuthResult = null; + if (books.get(i).getShareKey() != null) + linkedAuthResult = linkedNoteStore.authenticateToSharedNotebook(books.get(i).getShareKey(), authToken); + else { + linkedAuthResult = new AuthenticationResult(); + linkedAuthResult.setAuthenticationToken(""); + } SyncState linkedSyncState = linkedNoteStore.getLinkedNotebookSyncState(linkedAuthResult.getAuthenticationToken(), books.get(i)); if (linkedSyncState.getUpdateCount() > lastSequenceNumber) { if (lastSyncDate < linkedSyncState.getFullSyncBefore()) { lastSequenceNumber = 0; } - syncLinkedNotebook(linkedNoteStore, books.get(i), lastSequenceNumber, linkedSyncState.getUpdateCount()); + syncLinkedNotebook(linkedNoteStore, books.get(i), + lastSequenceNumber, linkedSyncState.getUpdateCount(), linkedAuthResult.getAuthenticationToken()); } // Synchronize local changes @@ -1873,7 +1880,7 @@ public class SyncRunner extends QObject implements Runnable { //************************************************************** //* Linked notebook contents (from someone else's account) //************************************************************* - private void syncLinkedNotebook(Client linkedNoteStore, LinkedNotebook book, int usn, int highSequence) { + private void syncLinkedNotebook(Client linkedNoteStore, LinkedNotebook book, int usn, int highSequence, String token) { if (ignoreLinkedNotebooks.contains(book.getGuid())) return; List dirtyNotes = conn.getNoteTable().getDirtyLinkedNotes(); @@ -1886,11 +1893,12 @@ public class SyncRunner extends QObject implements Runnable { boolean fullSync = false; if (usn == 0) fullSync = true; - while (usn < highSequence) { + boolean syncError = false; + while (usn < highSequence && !syncError) { refreshNeeded = true; try { SyncChunk chunk = - linkedNoteStore.getLinkedNotebookSyncChunk(authToken, book, usn, 10, fullSync); + linkedNoteStore.getLinkedNotebookSyncChunk(token, book, usn, 10, fullSync); // Expunge notes syncExpungedNotes(chunk); @@ -1902,8 +1910,9 @@ public class SyncRunner extends QObject implements Runnable { syncRemoteResource(linkedNoteStore, chunk.getResources().get(i), linkedAuthResult.getAuthenticationToken()); } syncRemoteLinkedNotebooks(linkedNoteStore, chunk.getNotebooks(), false, book); - SharedNotebook s = linkedNoteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken()); - syncLinkedTags(chunk.getTags(), s.getNotebookGuid()); +// SharedNotebook s = linkedNoteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken()); +// syncLinkedTags(chunk.getTags(), s.getNotebookGuid()); + syncLinkedTags(chunk.getTags(), book.getGuid()); // Go through & signal any notes that have changed so we can refresh the user's view for (int i=0; i