Beispiel #1
0
        public RtmTask UpdateTaskFromResult(List list)
        {
            TaskSeries ts = list.TaskSeriesCollection[0];

            if (ts != null)
            {
                RtmTask rtmTask = new RtmTask(ts, this, list.ID);
                lock (taskLock)
                {
                    Gtk.Application.Invoke(delegate {
                        if (taskIters.ContainsKey(rtmTask.ID))
                        {
                            Gtk.TreeIter iter = taskIters[rtmTask.ID];
                            taskStore.SetValue(iter, 0, rtmTask);
                        }
                        else
                        {
                            Gtk.TreeIter iter = taskStore.AppendNode();
                            taskIters.Add(rtmTask.ID, iter);
                            taskStore.SetValue(iter, 0, rtmTask);
                        }
                    });
                }
                return(rtmTask);
            }
            return(null);
        }
Beispiel #2
0
        public void DeleteTask(ITask task)
        {
            RtmTask rtmTask = task as RtmTask;

            if (rtm != null)
            {
                try {
                    rtm.TasksDelete(timeline, rtmTask.ListID, rtmTask.SeriesTaskID, rtmTask.TaskTaskID);

                    lock (taskLock)
                    {
                        Gtk.Application.Invoke(delegate {
                            if (taskIters.ContainsKey(rtmTask.ID))
                            {
                                Gtk.TreeIter iter = taskIters[rtmTask.ID];
                                taskStore.Remove(ref iter);
                                taskIters.Remove(rtmTask.ID);
                            }
                        });
                    }
                } catch (Exception e) {
                    Logger.Debug("Unable to delete task: " + task.Name);
                    Logger.Debug(e.ToString());
                }
            }
            else
            {
                throw new Exception("Unable to communicate with Remember The Milk");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Update the model to match what is in RTM
        /// FIXME: This is a lame implementation and needs to be optimized
        /// </summary>
        private void UpdateTasks(Lists lists)
        {
            Logger.Debug("RtmBackend.UpdateTasks was called");

            try {
                foreach (List list in lists.listCollection)
                {
                    Tasks tasks = null;
                    try {
                        tasks = rtm.TasksGetList(list.ID);
                    } catch (Exception tglex) {
                        Logger.Debug("Exception calling TasksGetList(list.ListID) " + tglex.Message);
                    }

                    if (tasks != null)
                    {
                        foreach (List tList in tasks.ListCollection)
                        {
                            if (tList.TaskSeriesCollection == null)
                            {
                                continue;
                            }
                            foreach (TaskSeries ts in tList.TaskSeriesCollection)
                            {
                                RtmTask rtmTask = new RtmTask(ts, this, list.ID);

                                lock (taskLock)
                                {
                                    Gtk.TreeIter iter;

                                    Gtk.Application.Invoke(delegate {
                                        if (taskIters.ContainsKey(rtmTask.ID))
                                        {
                                            iter = taskIters[rtmTask.ID];
                                        }
                                        else
                                        {
                                            iter = taskStore.AppendNode();
                                            taskIters.Add(rtmTask.ID, iter);
                                        }

                                        taskStore.SetValue(iter, 0, rtmTask);
                                    });
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                Logger.Debug("Exception in fetch " + e.Message);
                Logger.Debug(e.ToString());
            }
            Logger.Debug("RtmBackend.UpdateTasks is done");
        }
Beispiel #4
0
 public void UpdateTaskPriority(RtmTask task)
 {
     if (rtm != null)
     {
         try {
             List list = rtm.TasksSetPriority(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID, task.PriorityString);
             UpdateTaskFromResult(list);
         } catch (Exception e) {
             Logger.Debug("Unable to set priority on task: " + task.Name);
             Logger.Debug(e.ToString());
         }
     }
 }
Beispiel #5
0
 public void MoveTaskCategory(RtmTask task, string id)
 {
     if (rtm != null)
     {
         try {
             List list = rtm.TasksMoveTo(timeline, task.ListID, id, task.SeriesTaskID, task.TaskTaskID);
             UpdateTaskFromResult(list);
         } catch (Exception e) {
             Logger.Debug("Unable to set Task as completed: " + task.Name);
             Logger.Debug(e.ToString());
         }
     }
 }
Beispiel #6
0
        public void UpdateTask(RtmTask task)
        {
            lock (taskLock)
            {
                Gtk.TreeIter iter;

                Gtk.Application.Invoke(delegate {
                    if (taskIters.ContainsKey(task.ID))
                    {
                        iter = taskIters[task.ID];
                        taskStore.SetValue(iter, 0, task);
                    }
                });
            }
        }
Beispiel #7
0
 public void DeleteNote(RtmTask rtmTask, RtmNote note)
 {
     if (rtm != null)
     {
         try {
             rtm.NotesDelete(timeline, note.ID);
         } catch (Exception e) {
             Logger.Debug("RtmBackend.DeleteNote: Unable to delete note");
             Logger.Debug(e.ToString());
         }
     }
     else
     {
         throw new Exception("Unable to communicate with Remember The Milk");
     }
 }
Beispiel #8
0
 public 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");
     }
 }
Beispiel #9
0
 public void UpdateTaskActive(RtmTask task)
 {
     if (task.State == TaskState.Completed)
     {
         if (rtm != null)
         {
             try {
                 List list = rtm.TasksUncomplete(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID);
                 UpdateTaskFromResult(list);
             } catch (Exception e) {
                 Logger.Debug("Unable to set Task as completed: " + task.Name);
                 Logger.Debug(e.ToString());
             }
         }
     }
     else
     {
         UpdateTask(task);
     }
 }
Beispiel #10
0
        public ITask CreateTask(string taskName, ICategory category)
        {
            string  categoryID;
            RtmTask rtmTask = null;

            if (category is Tasque.AllCategory)
            {
                categoryID = null;
            }
            else
            {
                categoryID = (category as RtmCategory).ID;
            }

            if (rtm != null)
            {
                try {
                    List list;

                    if (categoryID == null)
                    {
                        list = rtm.TasksAdd(timeline, taskName);
                    }
                    else
                    {
                        list = rtm.TasksAdd(timeline, taskName, categoryID);
                    }

                    rtmTask = UpdateTaskFromResult(list);
                } catch (Exception e) {
                    Logger.Debug("Unable to set create task: " + taskName);
                    Logger.Debug(e.ToString());
                }
            }
            else
            {
                throw new Exception("Unable to communicate with Remember The Milk");
            }

            return(rtmTask);
        }
Beispiel #11
0
 public void UpdateTaskDueDate(RtmTask task)
 {
     if (rtm != null)
     {
         try {
             List list;
             if (task.DueDate == DateTime.MinValue)
             {
                 list = rtm.TasksSetDueDate(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID);
             }
             else
             {
                 list = rtm.TasksSetDueDate(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID, task.DueDateString);
             }
             UpdateTaskFromResult(list);
         } catch (Exception e) {
             Logger.Debug("Unable to set due date on task: " + task.Name);
             Logger.Debug(e.ToString());
         }
     }
 }
Beispiel #12
0
        public RtmNote CreateNote(RtmTask rtmTask, string text)
        {
            RtmNet.Note note    = null;
            RtmNote     rtmNote = null;

            if (rtm != null)
            {
                try {
                    note    = rtm.NotesAdd(timeline, rtmTask.ListID, rtmTask.SeriesTaskID, rtmTask.TaskTaskID, String.Empty, text);
                    rtmNote = new RtmNote(note);
                } catch (Exception e) {
                    Logger.Debug("RtmBackend.CreateNote: Unable to create a new note");
                    Logger.Debug(e.ToString());
                }
            }
            else
            {
                throw new Exception("Unable to communicate with Remember The Milk");
            }

            return(rtmNote);
        }
Beispiel #13
0
 public void UpdateTaskDueDate(RtmTask task)
 {
     if(rtm != null) {
         try {
             List list;
             if(task.DueDate == DateTime.MinValue)
                 list = rtm.TasksSetDueDate(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID);
             else
                 list = rtm.TasksSetDueDate(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID, task.DueDateString);
             UpdateTaskFromResult(list);
         } catch(Exception e) {
             Logger.Debug("Unable to set due date on task: " + task.Name);
             Logger.Debug(e.ToString());
         }
     }
 }
Beispiel #14
0
 public void UpdateTaskCompleteDate(RtmTask task)
 {
     UpdateTask(task);
 }
Beispiel #15
0
 public void UpdateTaskPriority(RtmTask task)
 {
     if(rtm != null) {
         try {
             List list = rtm.TasksSetPriority(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID, task.PriorityString);
             UpdateTaskFromResult(list);
         } catch(Exception e) {
             Logger.Debug("Unable to set priority on task: " + task.Name);
             Logger.Debug(e.ToString());
         }
     }
 }
Beispiel #16
0
 public void UpdateTaskCompleteDate(RtmTask task)
 {
     UpdateTask(task);
 }
Beispiel #17
0
 public void UpdateTaskDeleted(RtmTask task)
 {
     UpdateTask(task);
 }
Beispiel #18
0
 public void UpdateTaskPriority(RtmTask task)
 {
     if (rtm != null) {
         try {
             rtm.TasksSetPriority (timeline, task.ListID, task.SeriesTaskID,
                                   task.TaskTaskID, task.PriorityString);
         } catch (Exception e) {
             Debug.WriteLine ("Unable to set priority on task: " + task.Name);
             Debug.WriteLine (e.ToString ());
         }
     }
 }
Beispiel #19
0
 public void UpdateTaskDueDate(RtmTask task)
 {
     if (rtm != null) {
         try {
             if (task.DueDate == DateTime.MinValue)
                 rtm.TasksSetDueDate (timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID);
             else
                 rtm.TasksSetDueDate (timeline, task.ListID, task.SeriesTaskID,
                                      task.TaskTaskID, task.DueDateString);
         } catch (Exception e) {
             Debug.WriteLine ("Unable to set due date on task: " + task.Name);
             Debug.WriteLine (e.ToString ());
         }
     }
 }
Beispiel #20
0
 public void UpdateTaskDeleted(RtmTask task)
 {
     if (rtm != null) {
         try {
             rtm.TasksDelete (timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID);
         } catch (Exception e) {
             Debug.WriteLine ("Unable to set Task as deleted: " + task.Name);
             Debug.WriteLine (e.ToString ());
         }
     }
 }
Beispiel #21
0
 public void MoveTaskCategory(RtmTask task, string id)
 {
     if (rtm != null) {
         try {
             rtm.TasksMoveTo (timeline, task.ListID, id, task.SeriesTaskID, task.TaskTaskID);
         } catch (Exception e) {
             Debug.WriteLine ("Unable to set Task as completed: " + task.Name);
             Debug.WriteLine (e.ToString ());
         }
     }
 }
Beispiel #22
0
 public void DeleteNote(RtmTask rtmTask, RtmNote note)
 {
     if (rtm != null) {
         try {
             rtm.NotesDelete (timeline, note.ID);
         } catch (Exception e) {
             Debug.WriteLine ("RtmBackend.DeleteNote: Unable to delete note");
             Debug.WriteLine (e.ToString ());
         }
     } else
         throw new Exception ("Unable to communicate with Remember The Milk");
 }
Beispiel #23
0
        /// <summary>
        /// Update the model to match what is in RTM
        /// FIXME: This is a lame implementation and needs to be optimized
        /// </summary>		
        private void UpdateTasks(Lists lists)
        {
            Logger.Debug("RtmBackend.UpdateTasks was called");

            try {
                foreach(List list in lists.listCollection)
                {
                    Tasks tasks = null;
                    try {
                        tasks = rtm.TasksGetList(list.ID);
                    } catch (Exception tglex) {
                        Logger.Debug("Exception calling TasksGetList(list.ListID) " + tglex.Message);
                    }

                    if(tasks != null) {
                        foreach(List tList in tasks.ListCollection)
                        {
                            if (tList.TaskSeriesCollection == null)
                                continue;
                            foreach(TaskSeries ts in tList.TaskSeriesCollection)
                            {
                                RtmTask rtmTask = new RtmTask(ts, this, list.ID);

                                lock(taskLock)
                                {
                                    Gtk.TreeIter iter;

                                    Gtk.Application.Invoke ( delegate {

                                        if(taskIters.ContainsKey(rtmTask.ID)) {
                                            iter = taskIters[rtmTask.ID];
                                        } else {
                                            iter = taskStore.AppendNode ();
                                            taskIters.Add(rtmTask.ID, iter);
                                        }

                                        taskStore.SetValue (iter, 0, rtmTask);
                                    });
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                Logger.Debug("Exception in fetch " + e.Message);
                Logger.Debug(e.ToString());
            }
            Logger.Debug("RtmBackend.UpdateTasks is done");
        }
Beispiel #24
0
 public void UpdateTaskInactive(RtmTask task)
 {
     UpdateTask(task);
 }
Beispiel #25
0
        public void UpdateTask(RtmTask task)
        {
            lock(taskLock)
            {
                Gtk.TreeIter iter;

                Gtk.Application.Invoke ( delegate {
                    if(taskIters.ContainsKey(task.ID)) {
                        iter = taskIters[task.ID];
                        taskStore.SetValue (iter, 0, task);
                    }
                });
            }
        }
Beispiel #26
0
 public void UpdateTaskDeleted(RtmTask task)
 {
     UpdateTask(task);
 }
Beispiel #27
0
        public RtmNote CreateNote(RtmTask rtmTask, string text)
        {
            Note note = null;
            RtmNote rtmNote = null;

            if (rtm != null) {
                try {
                    note = rtm.NotesAdd (timeline, rtmTask.ListID, rtmTask.SeriesTaskID,
                                         rtmTask.TaskTaskID, string.Empty, text);
                    rtmNote = new RtmNote (note);
                    rtmNote.OnTextChangedAction = delegate { SaveNote (rtmTask, rtmNote); };
                } catch (Exception e) {
                    Debug.WriteLine ("RtmBackend.CreateNote: Unable to create a new note");
                    Debug.WriteLine (e.ToString ());
                }
            } else
                throw new Exception ("Unable to communicate with Remember The Milk");

            return rtmNote;
        }
Beispiel #28
0
 public void UpdateTaskCompleted(RtmTask task)
 {
     if(rtm != null) {
         try {
             List list = rtm.TasksComplete(timeline, task.ListID, task.SeriesTaskID, task.TaskTaskID);
             UpdateTaskFromResult(list);
         } catch(Exception e) {
             Logger.Debug("Unable to set Task as completed: " + task.Name);
             Logger.Debug(e.ToString());
         }
     }
 }
Beispiel #29
0
 public RtmTask UpdateTaskFromResult(List list)
 {
     TaskSeries ts = list.TaskSeriesCollection[0];
     if(ts != null) {
         RtmTask rtmTask = new RtmTask(ts, this, list.ID);
         lock(taskLock)
         {
             Gtk.Application.Invoke ( delegate {
                 if(taskIters.ContainsKey(rtmTask.ID)) {
                     Gtk.TreeIter iter = taskIters[rtmTask.ID];
                     taskStore.SetValue (iter, 0, rtmTask);
                 } else {
                     Gtk.TreeIter iter = taskStore.AppendNode();
                     taskIters.Add(rtmTask.ID, iter);
                     taskStore.SetValue (iter, 0, rtmTask);
                 }
             });
         }
         return rtmTask;
     }
     return null;
 }
Beispiel #30
0
 void SaveNote(RtmTask rtmTask, RtmNote note)
 {
     if (rtm != null) {
         try {
             rtm.NotesEdit (timeline, note.ID, string.Empty, note.Text);
         } catch (Exception e) {
             Debug.WriteLine ("RtmBackend.SaveNote: Unable to save note");
             Debug.WriteLine (e.ToString ());
         }
     } else
         throw new Exception ("Unable to communicate with Remember The Milk");
 }
Beispiel #31
0
 public void UpdateTaskInactive(RtmTask task)
 {
     UpdateTask(task);
 }
Beispiel #32
0
        /// <summary>
        /// Update the model to match what is in RTM
        /// FIXME: This is a lame implementation and needs to be optimized
        /// </summary>		
        void UpdateTasks(Lists lists)
        {
            Debug.WriteLine ("RtmBackend.UpdateTasks was called");
            try {
                foreach (var list in lists.listCollection) {
                    Tasks tasks = null;
                    try {
                        tasks = rtm.TasksGetList (list.ID);
                    } catch (Exception tglex) {
                        Debug.WriteLine ("Exception calling TasksGetList(list.ListID) " + tglex.Message);
                    }

                    if (tasks != null) {
                        foreach (var tList in tasks.ListCollection) {
                            if (tList.TaskSeriesCollection == null)
                                continue;

                            foreach (var ts in tList.TaskSeriesCollection) {
                                lock (taskLock) {
                                    Application.Instance.Dispatcher.Invoke (delegate {
                                        if (!Tasks.Any (t => ((RtmTask)t).ID == ts.TaskID)) {

                                            var rtmTask = new RtmTask (ts, this, list.ID);
                                            var cat = Categories.SingleOrDefault (
                                                c => ((RtmCategory)c).ID == list.ID);
                                            if (cat != null)
                                                cat.Add (rtmTask);
                                        }
                                    });
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                Debug.WriteLine ("Exception in fetch " + e.Message);
                Debug.WriteLine (e.ToString ());
            }
            Debug.WriteLine ("RtmBackend.UpdateTasks is done");
        }
Beispiel #33
0
        public RtmNote CreateNote(RtmTask rtmTask, string text)
        {
            RtmNet.Note note = null;
            RtmNote rtmNote = null;

            if(rtm != null) {
                try {
                    note = rtm.NotesAdd(timeline, rtmTask.ListID, rtmTask.SeriesTaskID, rtmTask.TaskTaskID, String.Empty, text);
                    rtmNote = new RtmNote(note);
                } catch(Exception e) {
                    Logger.Debug("RtmBackend.CreateNote: Unable to create a new note");
                    Logger.Debug(e.ToString());
                }
            }
            else
                throw new Exception("Unable to communicate with Remember The Milk");

            return rtmNote;
        }