OSDN Git Service

Add Linked notebooks to the ignore sync process.
authorRandy Baumgarte <randy@fbn.cx>
Fri, 31 Dec 2010 15:27:48 +0000 (10:27 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Sat, 1 Jan 2011 23:40:57 +0000 (18:40 -0500)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/dialog/IgnoreSync.java
src/cx/fbn/nevernote/sql/NoteTable.java
src/cx/fbn/nevernote/threads/SyncRunner.java

index 2d51697..b9f098d 100644 (file)
@@ -4880,9 +4880,11 @@ public class NeverNote extends QMainWindow{
        // Get a list of valid notebooks
        List<Notebook> notebooks = null; 
        List<Tag> tags = null;
        // Get a list of valid notebooks
        List<Notebook> notebooks = null; 
        List<Tag> tags = null;
+       List<LinkedNotebook> linkedNotebooks = null;
        try {
                        notebooks = syncRunner.noteStore.listNotebooks(syncRunner.authToken);
                        tags = syncRunner.noteStore.listTags(syncRunner.authToken);
        try {
                        notebooks = syncRunner.noteStore.listNotebooks(syncRunner.authToken);
                        tags = syncRunner.noteStore.listTags(syncRunner.authToken);
+                       linkedNotebooks = syncRunner.noteStore.listLinkedNotebooks(syncRunner.authToken);
                } catch (EDAMUserException e) {
                        setMessage("EDAMUserException: " +e.getMessage());
                        return;
                } catch (EDAMUserException e) {
                        setMessage("EDAMUserException: " +e.getMessage());
                        return;
@@ -4892,6 +4894,9 @@ public class NeverNote extends QMainWindow{
                } catch (TException e) {
                        setMessage("EDAMTransactionException: " +e.getMessage());
                        return;
                } catch (TException e) {
                        setMessage("EDAMTransactionException: " +e.getMessage());
                        return;
+               } catch (EDAMNotFoundException e) {
+                       setMessage("EDAMNotFoundException: " +e.getMessage());
+                       return;
                }
        
                // Split up notebooks into synchronized & non-synchronized
                }
        
                // Split up notebooks into synchronized & non-synchronized
@@ -4920,7 +4925,20 @@ public class NeverNote extends QMainWindow{
                }
        }
        
                }
        }
        
-               IgnoreSync ignore = new IgnoreSync(notebooks, ignoredBooks, tags, ignoredTags);
+       // split up linked notebooks into synchronized & non-synchronized
+       List<LinkedNotebook> ignoredLinkedNotebooks = new ArrayList<LinkedNotebook>();
+       List<String> dbIgnoredLinkedNotebooks = conn.getSyncTable().getIgnoreRecords("LINKEDNOTEBOOK");
+       for (int i=linkedNotebooks.size()-1; i>=0; i--) {
+               String notebookGuid = linkedNotebooks.get(i).getGuid();
+               for (int j=0; j<dbIgnoredLinkedNotebooks.size(); j++) {
+                       if (notebookGuid.equalsIgnoreCase(dbIgnoredLinkedNotebooks.get(j))) {
+                               ignoredLinkedNotebooks.add(linkedNotebooks.get(i));
+                               j=dbIgnoredLinkedNotebooks.size();
+                       }
+               }
+       }
+       
+               IgnoreSync ignore = new IgnoreSync(notebooks, ignoredBooks, tags, ignoredTags, linkedNotebooks, ignoredLinkedNotebooks);
                ignore.exec();
                if (!ignore.okClicked())
                        return;
                ignore.exec();
                if (!ignore.okClicked())
                        return;
@@ -4965,7 +4983,26 @@ public class NeverNote extends QMainWindow{
                        }
                }
                
                        }
                }
                
-               conn.getNoteTable().expungeIgnoreSynchronizedNotes(newNotebooks, newTags);
+               // Clear out old tags & add new ones
+               List<String> oldIgnoreLinkedNotebooks = conn.getSyncTable().getIgnoreRecords("LINKEDNOTEBOOK");
+               for (int i=0; i<oldIgnoreLinkedNotebooks.size(); i++) {
+                       conn.getSyncTable().deleteRecord("IGNORELINKEDNOTEBOOK-"+oldIgnoreLinkedNotebooks.get(i));
+               }
+               
+               List<String> newLinked = new ArrayList<String>();
+               for (int i=ignore.getIgnoredLinkedNotebookList().count()-1; i>=0; i--) {
+                       String text = ignore.getIgnoredLinkedNotebookList().takeItem(i).text();
+                       for (int j=0; j<linkedNotebooks.size(); j++) {
+                               if (linkedNotebooks.get(j).getShareName().equalsIgnoreCase(text)) {
+                                       LinkedNotebook t = linkedNotebooks.get(j);
+                                       conn.getSyncTable().addRecord("IGNORELINKEDNOTEBOOK-"+t.getGuid(), t.getGuid());
+                                       newLinked.add(t.getGuid());
+                                       j=linkedNotebooks.size();
+                               }
+                       }
+               }
+               
+               conn.getNoteTable().expungeIgnoreSynchronizedNotes(newNotebooks, newTags, newLinked);
                waitCursor(false);
                refreshLists();
     }
                waitCursor(false);
                refreshLists();
     }
index 466a779..7805e7b 100644 (file)
@@ -21,6 +21,7 @@ package cx.fbn.nevernote.dialog;
 \r
 import java.util.List;\r
 \r
 \r
 import java.util.List;\r
 \r
+import com.evernote.edam.type.LinkedNotebook;\r
 import com.evernote.edam.type.Notebook;\r
 import com.evernote.edam.type.Tag;\r
 import com.trolltech.qt.gui.QAbstractItemView;\r
 import com.evernote.edam.type.Notebook;\r
 import com.evernote.edam.type.Tag;\r
 import com.trolltech.qt.gui.QAbstractItemView;\r
@@ -39,6 +40,8 @@ public class IgnoreSync extends QDialog {
        private final QListWidget               ignoreBookList;\r
        private final QListWidget               syncTagList;\r
        private final QListWidget               ignoreTagList;\r
        private final QListWidget               ignoreBookList;\r
        private final QListWidget               syncTagList;\r
        private final QListWidget               ignoreTagList;\r
+       private final QListWidget               syncLinkedNotebookList;\r
+       private final QListWidget               ignoreLinkedNotebookList;\r
        private final QPushButton               okButton;\r
        private final QPushButton               cancelButton;\r
        private boolean                                 okClicked;\r
        private final QPushButton               okButton;\r
        private final QPushButton               cancelButton;\r
        private boolean                                 okClicked;\r
@@ -46,10 +49,15 @@ public class IgnoreSync extends QDialog {
        private final QPushButton               rightButton;\r
        private final QPushButton               leftTagButton;\r
        private final QPushButton               rightTagButton;\r
        private final QPushButton               rightButton;\r
        private final QPushButton               leftTagButton;\r
        private final QPushButton               rightTagButton;\r
+       private final QPushButton               leftLinkedNotebookButton;\r
+       private final QPushButton               rightLinkedNotebookButton;\r
+       private final QLabel                    linkedLabelLeft;\r
+       private final QLabel                    linkedLabelRight;\r
        \r
        private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        \r
        private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
-       public IgnoreSync(List<Notebook> allBooks, List<Notebook> archive, List<Tag> allTags, List<Tag> ignoreTags) {\r
+       public IgnoreSync(List<Notebook> allBooks, List<Notebook> archive, List<Tag> allTags, List<Tag> ignoreTags, \r
+                       List<LinkedNotebook> allLinkedNotebooks, List<LinkedNotebook> ignoreLinkedNotebooks) {\r
                setWindowIcon(new QIcon(iconPath+"synchronize.png"));\r
                okClicked = false;\r
                syncBookList = new QListWidget();\r
                setWindowIcon(new QIcon(iconPath+"synchronize.png"));\r
                okClicked = false;\r
                syncBookList = new QListWidget();\r
@@ -60,6 +68,10 @@ public class IgnoreSync extends QDialog {
                syncTagList.setSortingEnabled(true);\r
                syncTagList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
                \r
                syncTagList.setSortingEnabled(true);\r
                syncTagList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
                \r
+               syncLinkedNotebookList = new QListWidget();\r
+               syncLinkedNotebookList.setSortingEnabled(true);\r
+               syncLinkedNotebookList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
+               \r
                okButton = new QPushButton();\r
                okButton.setText(tr("OK"));\r
                okButton.pressed.connect(this, "onClicked()");\r
                okButton = new QPushButton();\r
                okButton.setText(tr("OK"));\r
                okButton.pressed.connect(this, "onClicked()");\r
@@ -76,6 +88,11 @@ public class IgnoreSync extends QDialog {
                openTagLayout.addWidget(new QLabel(tr("Synchronized Tags")));\r
                openTagLayout.addWidget(syncTagList);\r
                \r
                openTagLayout.addWidget(new QLabel(tr("Synchronized Tags")));\r
                openTagLayout.addWidget(syncTagList);\r
                \r
+               QVBoxLayout openLinkedNotebookLayout = new QVBoxLayout();\r
+               linkedLabelLeft = new QLabel(tr("Synchronized Linked Notebooks"));\r
+               openLinkedNotebookLayout.addWidget(linkedLabelLeft);\r
+               openLinkedNotebookLayout.addWidget(syncLinkedNotebookList);\r
+               \r
                rightButton = new QPushButton(this);\r
                rightButton.setIcon(new QIcon(iconPath+"forward.png"));\r
                leftButton = new QPushButton(this);\r
                rightButton = new QPushButton(this);\r
                rightButton.setIcon(new QIcon(iconPath+"forward.png"));\r
                leftButton = new QPushButton(this);\r
@@ -90,6 +107,13 @@ public class IgnoreSync extends QDialog {
                leftTagButton.setEnabled(false);\r
                rightTagButton.setEnabled(false);\r
                \r
                leftTagButton.setEnabled(false);\r
                rightTagButton.setEnabled(false);\r
                \r
+               rightLinkedNotebookButton = new QPushButton(this);\r
+               rightLinkedNotebookButton.setIcon(new QIcon(iconPath+"forward.png"));\r
+               leftLinkedNotebookButton = new QPushButton(this);\r
+               leftLinkedNotebookButton.setIcon(new QIcon(iconPath+"back.png"));\r
+               leftLinkedNotebookButton.setEnabled(false);\r
+               rightLinkedNotebookButton.setEnabled(false);\r
+               \r
                QVBoxLayout middleLayout = new QVBoxLayout();\r
                middleLayout.addSpacerItem(new QSpacerItem(1,1));\r
                middleLayout.addWidget(rightButton);\r
                QVBoxLayout middleLayout = new QVBoxLayout();\r
                middleLayout.addSpacerItem(new QSpacerItem(1,1));\r
                middleLayout.addWidget(rightButton);\r
@@ -101,6 +125,12 @@ public class IgnoreSync extends QDialog {
                middleTagLayout.addWidget(rightTagButton);\r
                middleTagLayout.addWidget(leftTagButton);\r
                middleTagLayout.addSpacerItem(new QSpacerItem(1,1));\r
                middleTagLayout.addWidget(rightTagButton);\r
                middleTagLayout.addWidget(leftTagButton);\r
                middleTagLayout.addSpacerItem(new QSpacerItem(1,1));\r
+               \r
+               QVBoxLayout middleLinkedNotebookLayout = new QVBoxLayout();\r
+               middleLinkedNotebookLayout.addSpacerItem(new QSpacerItem(1,1));\r
+               middleLinkedNotebookLayout.addWidget(rightLinkedNotebookButton);\r
+               middleLinkedNotebookLayout.addWidget(leftLinkedNotebookButton);\r
+               middleLinkedNotebookLayout.addSpacerItem(new QSpacerItem(1,1));\r
 \r
                QVBoxLayout closeLayout = new QVBoxLayout();\r
                closeLayout.addWidget(new QLabel(tr("Non-Synchronized Notebooks")));\r
 \r
                QVBoxLayout closeLayout = new QVBoxLayout();\r
                closeLayout.addWidget(new QLabel(tr("Non-Synchronized Notebooks")));\r
@@ -116,6 +146,14 @@ public class IgnoreSync extends QDialog {
                ignoreTagList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
                closeTagLayout.addWidget(ignoreTagList);\r
                \r
                ignoreTagList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
                closeTagLayout.addWidget(ignoreTagList);\r
                \r
+               QVBoxLayout closeLinkedNotebookLayout = new QVBoxLayout();\r
+               linkedLabelRight = new QLabel(tr("Non-Synchronized Linked Notebooks"));\r
+               closeLinkedNotebookLayout.addWidget(linkedLabelRight);\r
+               ignoreLinkedNotebookList = new QListWidget();\r
+               ignoreLinkedNotebookList.setSortingEnabled(true);\r
+               ignoreLinkedNotebookList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
+               closeLinkedNotebookLayout.addWidget(ignoreLinkedNotebookList);\r
+               \r
                syncBookList.itemSelectionChanged.connect(this, "syncBookSelected()");\r
                ignoreBookList.itemSelectionChanged.connect(this, "ignoreBookSelected()");\r
                leftButton.clicked.connect(this, "toOpenList()");\r
                syncBookList.itemSelectionChanged.connect(this, "syncBookSelected()");\r
                ignoreBookList.itemSelectionChanged.connect(this, "ignoreBookSelected()");\r
                leftButton.clicked.connect(this, "toOpenList()");\r
@@ -126,6 +164,11 @@ public class IgnoreSync extends QDialog {
                leftTagButton.clicked.connect(this, "toOpenTagList()");\r
                rightTagButton.clicked.connect(this, "toClosedTagList()");\r
                \r
                leftTagButton.clicked.connect(this, "toOpenTagList()");\r
                rightTagButton.clicked.connect(this, "toClosedTagList()");\r
                \r
+               syncLinkedNotebookList.itemSelectionChanged.connect(this, "syncLinkedNotebookSelected()");\r
+               ignoreLinkedNotebookList.itemSelectionChanged.connect(this, "ignoreLinkedNotebookSelected()");\r
+               leftLinkedNotebookButton.clicked.connect(this, "toOpenLinkedNotebookList()");\r
+               rightLinkedNotebookButton.clicked.connect(this, "toClosedLinkedNotebookList()");\r
+               \r
                QHBoxLayout buttonLayout = new QHBoxLayout();\r
                buttonLayout.addStretch(1);\r
                buttonLayout.addWidget(okButton);\r
                QHBoxLayout buttonLayout = new QHBoxLayout();\r
                buttonLayout.addStretch(1);\r
                buttonLayout.addWidget(okButton);\r
@@ -142,9 +185,15 @@ public class IgnoreSync extends QDialog {
                tagLayout.addLayout(middleTagLayout);\r
                tagLayout.addLayout(closeTagLayout);\r
                \r
                tagLayout.addLayout(middleTagLayout);\r
                tagLayout.addLayout(closeTagLayout);\r
                \r
+               QHBoxLayout linkedNotebookLayout = new QHBoxLayout();\r
+               linkedNotebookLayout.addLayout(openLinkedNotebookLayout);\r
+               linkedNotebookLayout.addLayout(middleLinkedNotebookLayout);\r
+               linkedNotebookLayout.addLayout(closeLinkedNotebookLayout);\r
+               \r
                QVBoxLayout mainLayout = new QVBoxLayout();\r
                mainLayout.addLayout(upperLayout);\r
                mainLayout.addLayout(tagLayout);\r
                QVBoxLayout mainLayout = new QVBoxLayout();\r
                mainLayout.addLayout(upperLayout);\r
                mainLayout.addLayout(tagLayout);\r
+               mainLayout.addLayout(linkedNotebookLayout);\r
                mainLayout.addSpacing(1);\r
                mainLayout.addLayout(buttonLayout);\r
                setLayout(mainLayout);\r
                mainLayout.addSpacing(1);\r
                mainLayout.addLayout(buttonLayout);\r
                setLayout(mainLayout);\r
@@ -185,14 +234,44 @@ public class IgnoreSync extends QDialog {
                                syncTagList.addItem(item);\r
                        }\r
                }\r
                                syncTagList.addItem(item);\r
                        }\r
                }\r
-               \r
-               setWindowTitle(tr("Ignore Synchronized Notes"));\r
                for (int i=0; i<ignoreTags.size(); i++) {\r
                        QListWidgetItem item = new QListWidgetItem(ignoreTags.get(i).getName());\r
                        item.setSelected(false);\r
                        ignoreTagList.addItem(item);\r
                }\r
                for (int i=0; i<ignoreTags.size(); i++) {\r
                        QListWidgetItem item = new QListWidgetItem(ignoreTags.get(i).getName());\r
                        item.setSelected(false);\r
                        ignoreTagList.addItem(item);\r
                }\r
+               \r
+               for (int i=0; i<allLinkedNotebooks.size(); i++) {\r
+                       boolean found = false;\r
+                       for (int j=0; j<ignoreLinkedNotebooks.size(); j++) {\r
+                               if (ignoreLinkedNotebooks.get(j).getShareName().equalsIgnoreCase(allLinkedNotebooks.get(i).getShareName())) {\r
+                                       found = true;\r
+                                       j=ignoreLinkedNotebooks.size();\r
+                               }\r
+                       }\r
+                       if (!found) {\r
+                               QListWidgetItem item = new QListWidgetItem(allLinkedNotebooks.get(i).getShareName());\r
+                               item.setSelected(false);\r
+                               syncLinkedNotebookList.addItem(item);\r
+                       }\r
+               }\r
+               for (int i=0; i<ignoreLinkedNotebooks.size(); i++) {\r
+                       QListWidgetItem item = new QListWidgetItem(ignoreLinkedNotebooks.get(i).getShareName());\r
+                       item.setSelected(false);\r
+                       ignoreLinkedNotebookList.addItem(item);\r
+               }\r
+\r
+\r
                syncBookList.itemSelectionChanged.connect(this, "itemSelected()");\r
                syncBookList.itemSelectionChanged.connect(this, "itemSelected()");\r
+               setWindowTitle(tr("Ignore Synchronized Notes"));\r
+\r
+               if (allLinkedNotebooks.size() == 0) {\r
+                       linkedLabelLeft.setVisible(false);\r
+                       linkedLabelRight.setVisible(false);\r
+                       rightLinkedNotebookButton.setVisible(false);\r
+                       leftLinkedNotebookButton.setVisible(false);\r
+                       ignoreLinkedNotebookList.setVisible(false);\r
+                       syncLinkedNotebookList.setVisible(false);\r
+               }\r
        }\r
        \r
        @SuppressWarnings("unused")\r
        }\r
        \r
        @SuppressWarnings("unused")\r
@@ -230,8 +309,6 @@ public class IgnoreSync extends QDialog {
                        syncTagList.takeItem(row);\r
                        ignoreTagList.addItem(items.get(i).text());\r
                }\r
                        syncTagList.takeItem(row);\r
                        ignoreTagList.addItem(items.get(i).text());\r
                }\r
-               if (syncTagList.count() == 0)\r
-                       okButton.setEnabled(false);\r
                rightTagButton.setEnabled(false);\r
        }\r
        \r
                rightTagButton.setEnabled(false);\r
        }\r
        \r
@@ -244,10 +321,32 @@ public class IgnoreSync extends QDialog {
                        ignoreTagList.takeItem(row);\r
                        syncTagList.addItem(items.get(i).text());\r
                }\r
                        ignoreTagList.takeItem(row);\r
                        syncTagList.addItem(items.get(i).text());\r
                }\r
-               okButton.setEnabled(true);\r
                leftTagButton.setEnabled(false);\r
        }\r
        \r
                leftTagButton.setEnabled(false);\r
        }\r
        \r
+       @SuppressWarnings("unused")\r
+       private void toClosedLinkedNotebookList() {\r
+               List<QListWidgetItem> items = syncLinkedNotebookList.selectedItems();\r
+               for (int i=items.size()-1; i>=0; i--) {\r
+                       int row = syncLinkedNotebookList.row(items.get(i));\r
+                       syncLinkedNotebookList.takeItem(row);\r
+                       ignoreLinkedNotebookList.addItem(items.get(i).text());\r
+               }\r
+               rightLinkedNotebookButton.setEnabled(false);\r
+       }\r
+       \r
+       \r
+       @SuppressWarnings("unused")\r
+       private void toOpenLinkedNotebookList() {\r
+               List<QListWidgetItem> items = ignoreLinkedNotebookList.selectedItems();\r
+               for (int i=items.size()-1; i>=0; i--) {\r
+                       int row = ignoreLinkedNotebookList.row(items.get(i));\r
+                       ignoreLinkedNotebookList.takeItem(row);\r
+                       syncLinkedNotebookList.addItem(items.get(i).text());\r
+               }\r
+               leftLinkedNotebookButton.setEnabled(false);\r
+       }\r
+       \r
        \r
        @SuppressWarnings("unused")\r
        private void ignoreBookSelected() {\r
        \r
        @SuppressWarnings("unused")\r
        private void ignoreBookSelected() {\r
@@ -282,6 +381,22 @@ public class IgnoreSync extends QDialog {
        }\r
        \r
        @SuppressWarnings("unused")\r
        }\r
        \r
        @SuppressWarnings("unused")\r
+       private void ignoreLinkedNotebookSelected() {\r
+               if (ignoreLinkedNotebookList.selectedItems().size() > 0)\r
+                       leftLinkedNotebookButton.setEnabled(true);\r
+               else\r
+                       leftLinkedNotebookButton.setEnabled(false);\r
+       }\r
+       \r
+       @SuppressWarnings("unused")\r
+       private void syncLinkedNotebookSelected() {\r
+               if (syncLinkedNotebookList.selectedItems().size() > 0)\r
+                       rightLinkedNotebookButton.setEnabled(true);\r
+               else\r
+                       rightLinkedNotebookButton.setEnabled(false);\r
+       }\r
+       \r
+       @SuppressWarnings("unused")\r
        private void onClicked() {\r
                okClicked = true;\r
                close();\r
        private void onClicked() {\r
                okClicked = true;\r
                close();\r
@@ -313,6 +428,14 @@ public class IgnoreSync extends QDialog {
                return ignoreTagList;\r
        }\r
        \r
                return ignoreTagList;\r
        }\r
        \r
+       public QListWidget getSyncLinkedNotebookList() {\r
+               return syncLinkedNotebookList;\r
+       }\r
+       \r
+       public QListWidget getIgnoredLinkedNotebookList() {\r
+               return ignoreLinkedNotebookList;\r
+       }\r
+       \r
        @SuppressWarnings("unused")\r
        private void itemSelected() {\r
                if (syncBookList.selectedItems().size() == syncBookList.count()) {\r
        @SuppressWarnings("unused")\r
        private void itemSelected() {\r
                if (syncBookList.selectedItems().size() == syncBookList.count()) {\r
index 97c0b15..bd2ab8e 100644 (file)
@@ -976,7 +976,7 @@ public class NoteTable {
        }\r
        \r
        // Expunge notes that we don't want to synchronize\r
        }\r
        \r
        // Expunge notes that we don't want to synchronize\r
-       public List<String> expungeIgnoreSynchronizedNotes(List<String> notebooks, List<String>tags) {\r
+       public List<String> expungeIgnoreSynchronizedNotes(List<String> notebooks, List<String>tags, List<String> linked) {\r
                \r
                List<String> noteGuids = new ArrayList<String>();\r
                for (int i=0; i<notebooks.size(); i++) {\r
                \r
                List<String> noteGuids = new ArrayList<String>();\r
                for (int i=0; i<notebooks.size(); i++) {\r
@@ -998,6 +998,23 @@ public class NoteTable {
                                }\r
                        }\r
                }\r
                                }\r
                        }\r
                }\r
+               \r
+               for (int i=0; i<linked.size(); i++) {\r
+                       String notebookGuid = db.getLinkedNotebookTable().getNotebookGuid(linked.get(i));\r
+                       if (notebookGuid != null && !notebookGuid.trim().equals("")) {\r
+                               List<Tag> linkedTags = db.getTagTable().getTagsForNotebook(notebookGuid);\r
+                               for (int j=0; j<linkedTags.size(); j++)\r
+                                       db.getTagTable().expungeTag(linkedTags.get(j).getGuid(), false);\r
+                               \r
+                               List<String> notes = findNotesByNotebook(notebookGuid);\r
+                               for (int j=0; j<notes.size(); j++) {\r
+                                       if (!isNoteDirty(notes.get(j))) {\r
+                                               expungeNote(notes.get(j), true, false);\r
+                                               noteGuids.add(notes.get(j));\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
                return noteGuids;\r
        }\r
        \r
                return noteGuids;\r
        }\r
        \r
index 6a6f37f..1fcc42a 100644 (file)
@@ -140,6 +140,7 @@ public class SyncRunner extends QObject implements Runnable {
                String dbcpswd;\r
                private final TreeSet<String> ignoreTags;\r
                private final TreeSet<String> ignoreNotebooks;\r
                String dbcpswd;\r
                private final TreeSet<String> ignoreTags;\r
                private final TreeSet<String> ignoreNotebooks;\r
+               private final TreeSet<String> ignoreLinkedNotebooks;\r
        \r
                \r
                \r
        \r
                \r
                \r
@@ -172,6 +173,7 @@ public class SyncRunner extends QObject implements Runnable {
                disableUploads = false;\r
                ignoreTags = new TreeSet<String>();\r
                ignoreNotebooks = new TreeSet<String>();\r
                disableUploads = false;\r
                ignoreTags = new TreeSet<String>();\r
                ignoreNotebooks = new TreeSet<String>();\r
+               ignoreLinkedNotebooks = new TreeSet<String>();\r
                \r
 //             setAutoDelete(false);\r
                workQueue=new LinkedBlockingQueue<String>(MAX_QUEUED_WAITING);\r
                \r
 //             setAutoDelete(false);\r
                workQueue=new LinkedBlockingQueue<String>(MAX_QUEUED_WAITING);\r
@@ -268,6 +270,11 @@ public class SyncRunner extends QObject implements Runnable {
                for (int i=0; i<ignore.size(); i++) \r
                        ignoreNotebooks.add(ignore.get(i));\r
                \r
                for (int i=0; i<ignore.size(); i++) \r
                        ignoreNotebooks.add(ignore.get(i));\r
                \r
+               ignore.clear();\r
+               ignore = conn.getSyncTable().getIgnoreRecords("LINKEDNOTEBOOK");\r
+               for (int i=0; i<ignore.size(); i++) \r
+                       ignoreLinkedNotebooks.add(ignore.get(i));\r
+               \r
                ignoreTags.clear();\r
                ignore = conn.getSyncTable().getIgnoreRecords("TAG");\r
                for (int i=0; i<ignore.size(); i++) \r
                ignoreTags.clear();\r
                ignore = conn.getSyncTable().getIgnoreRecords("TAG");\r
                for (int i=0; i<ignore.size(); i++) \r
@@ -412,7 +419,8 @@ public class SyncRunner extends QObject implements Runnable {
                        }\r
                        \r
                        status.message.emit(tr("Cleaning up"));\r
                        }\r
                        \r
                        status.message.emit(tr("Cleaning up"));\r
-                       List<String> notes = conn.getNoteTable().expungeIgnoreSynchronizedNotes(conn.getSyncTable().getIgnoreRecords("NOTEBOOK"), conn.getSyncTable().getIgnoreRecords("TAG"));\r
+                       List<String> notes = conn.getNoteTable().expungeIgnoreSynchronizedNotes(conn.getSyncTable().getIgnoreRecords("NOTEBOOK"), \r
+                                       conn.getSyncTable().getIgnoreRecords("TAG"), conn.getSyncTable().getIgnoreRecords("LINKEDNOTEBOOK"));\r
                        if (notes.size() > 0)\r
                                syncSignal.refreshLists.emit();\r
                        \r
                        if (notes.size() > 0)\r
                                syncSignal.refreshLists.emit();\r
                        \r
@@ -1784,17 +1792,17 @@ public class SyncRunner extends QObject implements Runnable {
        List<LinkedNotebook> books = conn.getLinkedNotebookTable().getAll();\r
        for (int i=0; i<books.size(); i++) {\r
                try {\r
        List<LinkedNotebook> books = conn.getLinkedNotebookTable().getAll();\r
        for (int i=0; i<books.size(); i++) {\r
                try {\r
-                       long lastSyncDate = conn.getLinkedNotebookTable().getLastSequenceDate(books.get(i).getGuid());\r
-                       int lastSequenceNumber = conn.getLinkedNotebookTable().getLastSequenceNumber(books.get(i).getGuid());\r
-                       linkedAuthResult = noteStore.authenticateToSharedNotebook(books.get(i).getShareKey(), authToken);\r
-                       SyncState linkedSyncState = \r
-                               noteStore.getLinkedNotebookSyncState(linkedAuthResult.getAuthenticationToken(), books.get(i));\r
-                       if (linkedSyncState.getUpdateCount() > lastSequenceNumber) {\r
-                               if (lastSyncDate < linkedSyncState.getFullSyncBefore()) {\r
-                                       lastSequenceNumber = 0;\r
-                               }\r
+                               long lastSyncDate = conn.getLinkedNotebookTable().getLastSequenceDate(books.get(i).getGuid());\r
+                               int lastSequenceNumber = conn.getLinkedNotebookTable().getLastSequenceNumber(books.get(i).getGuid());\r
+                               linkedAuthResult = noteStore.authenticateToSharedNotebook(books.get(i).getShareKey(), authToken);\r
+                               SyncState linkedSyncState = \r
+                                       noteStore.getLinkedNotebookSyncState(linkedAuthResult.getAuthenticationToken(), books.get(i));\r
+                               if (linkedSyncState.getUpdateCount() > lastSequenceNumber) {\r
+                                       if (lastSyncDate < linkedSyncState.getFullSyncBefore()) {\r
+                                               lastSequenceNumber = 0;\r
+                                       } \r
                                        syncLinkedNotebook(books.get(i), lastSequenceNumber, linkedSyncState.getUpdateCount());\r
                                        syncLinkedNotebook(books.get(i), lastSequenceNumber, linkedSyncState.getUpdateCount());\r
-                       }\r
+                               }\r
                        \r
                        // Synchronize local changes\r
                        syncLocalLinkedNoteChanges(books.get(i));\r
                        \r
                        // Synchronize local changes\r
                        syncLocalLinkedNoteChanges(books.get(i));\r
@@ -1834,15 +1842,14 @@ public class SyncRunner extends QObject implements Runnable {
                        try {\r
                                SyncChunk chunk = \r
                                        noteStore.getLinkedNotebookSyncChunk(authToken, book, usn, 10, fullSync);\r
                        try {\r
                                SyncChunk chunk = \r
                                        noteStore.getLinkedNotebookSyncChunk(authToken, book, usn, 10, fullSync);\r
-//                                     noteStore.getLinkedNotebookSyncChunk(linkedAuthResult.getAuthenticationToken(), book, usn, 10, fullSync);\r
 \r
 \r
-                               syncRemoteNotes(chunk.getNotes(), fullSync, linkedAuthResult.getAuthenticationToken());\r
+                               if (!ignoreLinkedNotebooks.contains(book.getGuid()))\r
+                                       syncRemoteNotes(chunk.getNotes(), fullSync, linkedAuthResult.getAuthenticationToken());\r
                                findNewLinkedTags(chunk.getNotes(), linkedAuthResult.getAuthenticationToken());\r
                                for (int i=0; i<chunk.getResourcesSize(); i++) {\r
                                        syncRemoteResource(chunk.getResources().get(i), linkedAuthResult.getAuthenticationToken());\r
                                }\r
                                syncRemoteLinkedNotebooks(chunk.getNotebooks(), false, book);\r
                                findNewLinkedTags(chunk.getNotes(), linkedAuthResult.getAuthenticationToken());\r
                                for (int i=0; i<chunk.getResourcesSize(); i++) {\r
                                        syncRemoteResource(chunk.getResources().get(i), linkedAuthResult.getAuthenticationToken());\r
                                }\r
                                syncRemoteLinkedNotebooks(chunk.getNotebooks(), false, book);\r
-//                             String notebookGuid = conn.getLinkedNotebookTable().getNotebookGuid(book.getGuid());\r
                                SharedNotebook s = noteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken());\r
                                syncLinkedTags(chunk.getTags(), s.getNotebookGuid());\r
                                \r
                                SharedNotebook s = noteStore.getSharedNotebookByAuth(linkedAuthResult.getAuthenticationToken());\r
                                syncLinkedTags(chunk.getTags(), s.getNotebookGuid());\r
                                \r