[tasque] Finish Rtm backend implementation



commit 9a6bf4e2e87cacf090bfbe8f80fbd2398e6b2202
Author: Antonius Riha <antoniusriha gmail com>
Date:   Mon Mar 18 08:54:10 2013 +0100

    Finish Rtm backend implementation

 src/Addins/Backends/Rtm/Extensions.cs            |    2 ++
 src/Addins/Backends/Rtm/RtmNoteRepository.cs     |   22 ++++++----------------
 src/Addins/Backends/Rtm/RtmTaskListRepository.cs |    7 ++++++-
 src/Addins/Backends/Rtm/RtmTaskRepository.cs     |   14 ++++++++++++--
 src/Gtk.Tasque/PreferencesDialog.cs              |    2 +-
 src/Gtk.Tasque/RemoteControl.cs                  |    8 ++++----
 src/Gtk.Tasque/TaskWindow.cs                     |   11 ++++++-----
 7 files changed, 37 insertions(+), 29 deletions(-)
---
diff --git a/src/Addins/Backends/Rtm/Extensions.cs b/src/Addins/Backends/Rtm/Extensions.cs
index 19623a2..d15b639 100644
--- a/src/Addins/Backends/Rtm/Extensions.cs
+++ b/src/Addins/Backends/Rtm/Extensions.cs
@@ -36,6 +36,7 @@ namespace Tasque.Backends.Rtm
                                throw new NullReferenceException ("source");
 
                        switch (source.Priority) {
+                       default:
                        case "N":
                                return TaskPriority.None;
                        case "1":
@@ -53,6 +54,7 @@ namespace Tasque.Backends.Rtm
                                throw new NullReferenceException ("source");
 
                        switch (source.Priority) {
+                       default:
                        case TaskPriority.None:
                                return "N";
                        case TaskPriority.High:
diff --git a/src/Addins/Backends/Rtm/RtmNoteRepository.cs b/src/Addins/Backends/Rtm/RtmNoteRepository.cs
index 879dce1..0d55e11 100644
--- a/src/Addins/Backends/Rtm/RtmNoteRepository.cs
+++ b/src/Addins/Backends/Rtm/RtmNoteRepository.cs
@@ -39,31 +39,21 @@ namespace Tasque.Backends.Rtm
 
                public string UpdateTitle (INoteCore note, string title)
                {
-                       throw new NotImplementedException ();
+                       UpdateNote (note, title, note.Text);
+                       return note.Title;
                }
 
                string INoteRepository.UpdateText (INoteCore note, string text)
                {
-
+                       UpdateNote (note, note.Title, text);
+                       return note.Text;
                }
 
                void UpdateNote (INoteCore note, string title, string text)
                {
                        var rtmNote = backend.Rtm.NotesEdit (backend.Timeline, note.Id, note.Title, 
note.Text);
-                       note.Title =
-               }
-
-               internal void SaveNote (RtmTask rtmTask, RtmNote note)
-               {
-                       if (rtm != null) {
-                               try {
-                                       rtm.NotesEdit (timeline, note.ID, String.Empty, note.Text);
-                               } catch (Exception e) {
-                                       Logger.Debug ("RtmBackend.SaveNote: Unable to save note");
-                                       Logger.Debug (e.ToString ());
-                               }
-                       } else
-                               throw new Exception ("Unable to communicate with Remember The Milk");
+                       note.Title = rtmNote.Title;
+                       note.Text = rtmNote.Text;
                }
 
                RtmBackend backend;
diff --git a/src/Addins/Backends/Rtm/RtmTaskListRepository.cs 
b/src/Addins/Backends/Rtm/RtmTaskListRepository.cs
index f90972e..163a426 100644
--- a/src/Addins/Backends/Rtm/RtmTaskListRepository.cs
+++ b/src/Addins/Backends/Rtm/RtmTaskListRepository.cs
@@ -65,6 +65,10 @@ namespace Tasque.Backends.Rtm
                        throw new NotSupportedException (
                                "Cannot change the name of a task list.");
                }
+               
+               bool ITaskListTaskCollectionRepo.SupportsSharingItemsWithOtherCollections {
+                       get { return false; }
+               }
 
                IEnumerable<ITaskCore> ITaskListTaskCollectionRepo.GetAll (
                        ITaskListCore container)
@@ -90,6 +94,7 @@ namespace Tasque.Backends.Rtm
                                        task.Priority = rtmTask.GetTaskPriority ();
 
                                        CacheNotes (rtmTaskSeries);
+                                       yield return task;
                                }
                        }
                }
@@ -123,7 +128,7 @@ namespace Tasque.Backends.Rtm
                                                         ITaskCore item)
                {
                        string taskSeriesId, taskId;
-                       backend.DecodeTaskId (item.Id, out taskSeriesId, out taskId);
+                       backend.DecodeTaskId (item, out taskSeriesId, out taskId);
                        backend.Rtm.TasksDelete (backend.Timeline, container.Id,
                                                 taskSeriesId, taskId);
                }
diff --git a/src/Addins/Backends/Rtm/RtmTaskRepository.cs b/src/Addins/Backends/Rtm/RtmTaskRepository.cs
index 167e3b1..6a8757d 100644
--- a/src/Addins/Backends/Rtm/RtmTaskRepository.cs
+++ b/src/Addins/Backends/Rtm/RtmTaskRepository.cs
@@ -111,8 +111,10 @@ namespace Tasque.Backends.Rtm
                        var taskList = task.TaskListContainers.First ();
                        string taskSeriesId, taskId;
                        backend.DecodeTaskId (task, out taskSeriesId, out taskId);
-                       backend.Rtm.TasksComplete (backend.Timeline, taskList.Id,
-                                                  taskSeriesId, taskId);
+                       var list = backend.Rtm.TasksComplete (backend.Timeline,
+                           taskList.Id, taskSeriesId, taskId);
+                       var last = list.TaskSeriesCollection [0].TaskCollection.Length - 1;
+                       return list.TaskSeriesCollection [0].TaskCollection [last].Completed;
                }
                
                void ITaskRepository.Discard (ITaskCore task)
@@ -128,6 +130,10 @@ namespace Tasque.Backends.Rtm
                                "This backend supports multiple notes.");
                }
                
+               bool INoteCollectionRepo.SupportsSharingItemsWithOtherCollections {
+                       get { return false; }
+               }
+               
                IEnumerable<INoteCore> INoteCollectionRepo.GetAll (ITaskCore container)
                {
                        var notes = backend.TaskListRepo.Notes;
@@ -174,6 +180,10 @@ namespace Tasque.Backends.Rtm
                #endregion
 
                #region Nested tasks
+               
+               bool ITaskTaskCollectionRepo.SupportsSharingItemsWithOtherCollections {
+                       get { throw new NotSupportedException (NestedTasksErrMsg); }
+               }
 
                IEnumerable<ITaskCore> ITaskTaskCollectionRepo.GetAll (
                        ITaskCore container)
diff --git a/src/Gtk.Tasque/PreferencesDialog.cs b/src/Gtk.Tasque/PreferencesDialog.cs
index 646cfb8..58540cd 100644
--- a/src/Gtk.Tasque/PreferencesDialog.cs
+++ b/src/Gtk.Tasque/PreferencesDialog.cs
@@ -582,7 +582,7 @@ namespace Gtk.Tasque
                        
                        filteredTaskLists = new ListStore (typeof (ITaskList));
                        foreach (var item in application.BackendManager.TaskLists) {
-                               if (!(item == null || item is AllList))
+                               if (!(item == null || item.ListType == TaskListType.Smart))
                                        filteredTaskLists.AppendValues (item);
                        }
                        taskListsTree.Model = filteredTaskLists;
diff --git a/src/Gtk.Tasque/RemoteControl.cs b/src/Gtk.Tasque/RemoteControl.cs
index c2104ac..2fdb45d 100644
--- a/src/Gtk.Tasque/RemoteControl.cs
+++ b/src/Gtk.Tasque/RemoteControl.cs
@@ -198,7 +198,7 @@ namespace Gtk.Tasque
                                return emptyArray;
                        
                        foreach (var item in model) {
-                               if (!(item is AllList))
+                               if (!(item.ListType == TaskListType.Smart))
                                        taskLists.Add (item.Name);
                        }
                        
@@ -283,7 +283,7 @@ namespace Gtk.Tasque
                {
                        var task = GetTaskById (id);
                        var list = application.BackendManager.TaskLists.FirstOrDefault (
-                               l => !(l is AllList) && l.Contains (task));
+                               l => !(l.ListType == TaskListType.Smart) && l.Contains (task));
                        return task != null ? list.Name : string.Empty;
                }
                
@@ -312,7 +312,7 @@ namespace Gtk.Tasque
                        // old model until a general overhaul.
                        var lists = application.BackendManager.TaskLists;
                        var prevList = lists.FirstOrDefault (
-                               l => !(l is AllList) && l.Contains (task));
+                               l => !(l.ListType == TaskListType.Smart) && l.Contains (task));
                        var newList = lists.FirstOrDefault (
                                l => l.Name == listName);
 
@@ -485,7 +485,7 @@ namespace Gtk.Tasque
                                return false;
                        
                        var taskList = application.BackendManager.TaskLists.First (
-                               l => !(l is AllList) && l.Contains (task));
+                               l => !(l.ListType == TaskListType.Smart) && l.Contains (task));
                        taskList.Remove (task);
                        return true;
                }
diff --git a/src/Gtk.Tasque/TaskWindow.cs b/src/Gtk.Tasque/TaskWindow.cs
index dc17061..2bd9eec 100644
--- a/src/Gtk.Tasque/TaskWindow.cs
+++ b/src/Gtk.Tasque/TaskWindow.cs
@@ -710,7 +710,7 @@ namespace Gtk.Tasque
                        Gtk.Menu menu = new Menu ();
                        
                        foreach (var cat in taskListsModel) {
-                               if (cat is AllList)
+                               if (cat.ListType == TaskListType.Smart)
                                        continue;
                                var item = new TaskListMenuItem (cat);
                                item.Activated += OnNewTaskByTaskList;
@@ -973,7 +973,7 @@ namespace Gtk.Tasque
                                        taskListComboBox.Model.GetValue (iter, 0) as ITaskList;
                                
                                // Check to see if "All" is selected
-                               if (selectedTaskList is AllList) {
+                               if (selectedTaskList.ListType == TaskListType.Smart) {
                                        // See if the item.ITaskList is currently being shown in
                                        // the "All" taskList and if not, select the taskList
                                        // specifically.
@@ -1094,7 +1094,8 @@ namespace Gtk.Tasque
 
                                    var filteredTaskLists = new ListStore (typeof (ITaskList));
                                    foreach (var cat in application.BackendManager.TaskLists) {
-                                           if (cat != null && !(cat is AllList) && !cat.Contains 
(clickedTask))
+                                           if (cat != null && !(cat.ListType == TaskListType.Smart)
+                                           && !cat.Contains (clickedTask))
                                                    filteredTaskLists.AppendValues (cat);
                                }
 
@@ -1167,7 +1168,7 @@ namespace Gtk.Tasque
                                return;
                
                        var taskList = application.BackendManager.TaskLists.First (
-                               l => !(l is AllList) && l.Contains (clickedTask));
+                               l => !(l.ListType == TaskListType.Smart) && l.Contains (clickedTask));
                        taskList.Remove (clickedTask);
                        
                        status = Catalog.GetString ("ITask deleted");
@@ -1241,7 +1242,7 @@ namespace Gtk.Tasque
                        // relationship. Now it's many-to-many. However, we stick to the
                        // old model until a general overhaul.
                        var prevList = application.BackendManager.TaskLists.FirstOrDefault (
-                               c => !(c is AllList) && c.Contains (clickedTask));
+                               c => !(c.ListType == TaskListType.Smart) && c.Contains (clickedTask));
                        prevList.Remove (clickedTask);
                        var list = ((TaskListMenuItem)sender).ITaskList;
                        list.Add (clickedTask);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]