Merge lp://qastaging/~jpds/do-plugins/rtm-listactions into lp://qastaging/~d6g/do-plugins/rtm-1.5

Proposed by Jonathan Davies
Status: Merged
Merged at revision: 588
Proposed branch: lp://qastaging/~jpds/do-plugins/rtm-listactions
Merge into: lp://qastaging/~d6g/do-plugins/rtm-1.5
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~jpds/do-plugins/rtm-listactions
Reviewer Review Type Date Requested Status
Peng Deng Pending
Review via email: mp+4719@code.qastaging.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'RememberTheMilk/Makefile.am'
2--- RememberTheMilk/Makefile.am 2009-03-18 14:24:24 +0000
3+++ RememberTheMilk/Makefile.am 2009-03-20 16:35:27 +0000
4@@ -8,14 +8,17 @@
5 src/Configuration.cs \
6 src/RTM.cs \
7 src/RTMCompleteTask.cs \
8+ src/RTMDeleteList.cs \
9 src/RTMDeleteTask.cs \
10 src/RTMListItem.cs \
11 src/RTMListItemSource.cs \
12 src/RTMMoveTask.cs \
13+ src/RTMNewList.cs \
14 src/RTMNewTask.cs \
15 src/RTMPostponeTask.cs \
16 src/RTMPreferences.cs \
17 src/RTMPriorityItem.cs \
18+ src/RTMRenameList.cs \
19 src/RTMRenameTask.cs \
20 src/RTMSetDue.cs \
21 src/RTMSetUrl.cs \
22@@ -50,6 +53,9 @@
23 RESOURCES = \
24 Resources/RTM.addin.xml \
25 Resources/icons/rtm.png \
26+ Resources/icons/list-add.png \
27+ Resources/icons/list-delete.png \
28+ Resources/icons/list-rename.png \
29 Resources/icons/task-add.png \
30 Resources/icons/task-complete.png \
31 Resources/icons/task-delete.png \
32
33=== modified file 'RememberTheMilk/RTM.mdp'
34--- RememberTheMilk/RTM.mdp 2009-03-18 14:24:24 +0000
35+++ RememberTheMilk/RTM.mdp 2009-03-20 16:35:27 +0000
36@@ -20,12 +20,15 @@
37 <File name="src" subtype="Directory" buildaction="Compile" />
38 <File name="src/RTMCompleteTask.cs" subtype="Code" buildaction="Compile" />
39 <File name="src/RTM.cs" subtype="Code" buildaction="Compile" />
40+ <File name="src/RTMDeleteList.cs" subtype="Code" buildaction="Compile" />
41 <File name="src/RTMDeleteTask.cs" subtype="Code" buildaction="Compile" />
42 <File name="src/RTMListItem.cs" subtype="Code" buildaction="Compile" />
43 <File name="src/RTMListItemSource.cs" subtype="Code" buildaction="Compile" />
44 <File name="src/RTMMoveTask.cs" subtype="Code" buildaction="Compile" />
45+ <File name="src/RTMNewList.cs" subtype="Code" buildaction="Compile" />
46 <File name="src/RTMNewTask.cs" subtype="Code" buildaction="Compile" />
47 <File name="src/RTMPriorityItem.cs" subtype="Code" buildaction="Compile" />
48+ <File name="src/RTMRenameList.cs" subtype="Code" buildaction="Compile" />
49 <File name="src/RTMRenameTask.cs" subtype="Code" buildaction="Compile" />
50 <File name="src/RTMSetDue.cs" subtype="Code" buildaction="Compile" />
51 <File name="src/RTMSetPriority.cs" subtype="Code" buildaction="Compile" />
52@@ -63,6 +66,9 @@
53 <File name="src/RTMPreferences.cs" subtype="Code" buildaction="Compile" />
54 <File name="Resources/RTM.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
55 <File name="Resources/icons/rtm.png" subtype="Code" buildaction="EmbedAsResource" />
56+ <File name="Resources/icons/list-add.png" subtype="Code" buildaction="EmbedAsResource" />
57+ <File name="Resources/icons/list-delete.png" subtype="Code" buildaction="EmbedAsResource" />
58+ <File name="Resources/icons/list-rename.png" subtype="Code" buildaction="EmbedAsResource" />
59 <File name="Resources/icons/task.png" subtype="Code" buildaction="EmbedAsResource" />
60 <File name="Resources/icons/task-add.png" subtype="Code" buildaction="EmbedAsResource" />
61 <File name="Resources/icons/task-complete.png" subtype="Code" buildaction="EmbedAsResource" />
62
63=== modified file 'RememberTheMilk/Resources/RTM.addin.xml'
64--- RememberTheMilk/Resources/RTM.addin.xml 2009-03-16 23:26:24 +0000
65+++ RememberTheMilk/Resources/RTM.addin.xml 2009-03-20 16:35:27 +0000
66@@ -22,12 +22,15 @@
67 </Extension>
68
69 <Extension path="/Do/Action">
70+ <Action type="RememberTheMilk.RTMNewList" />
71 <Action type="RememberTheMilk.RTMNewTask" />
72+ <Action type="RememberTheMilk.RTMDeleteList" />
73 <Action type="RememberTheMilk.RTMDeleteTask" />
74 <Action type="RememberTheMilk.RTMCompleteTask" />
75 <Action type="RememberTheMilk.RTMSetPriority" />
76 <Action type="RememberTheMilk.RTMSetDue" />
77 <Action type="RememberTheMilk.RTMSetUrl" />
78+ <Action type="RememberTheMilk.RTMRenameList" />
79 <Action type="RememberTheMilk.RTMMoveTask" />
80 <Action type="RememberTheMilk.RTMRenameTask" />
81 <Action type="RememberTheMilk.RTMPostponeTask" />
82
83=== added file 'RememberTheMilk/Resources/icons/list-add.png'
84Binary files RememberTheMilk/Resources/icons/list-add.png 1970-01-01 00:00:00 +0000 and RememberTheMilk/Resources/icons/list-add.png 2009-03-20 15:54:23 +0000 differ
85=== added file 'RememberTheMilk/Resources/icons/list-delete.png'
86Binary files RememberTheMilk/Resources/icons/list-delete.png 1970-01-01 00:00:00 +0000 and RememberTheMilk/Resources/icons/list-delete.png 2009-03-20 16:35:27 +0000 differ
87=== added file 'RememberTheMilk/Resources/icons/list-rename.png'
88Binary files RememberTheMilk/Resources/icons/list-rename.png 1970-01-01 00:00:00 +0000 and RememberTheMilk/Resources/icons/list-rename.png 2009-03-20 15:01:31 +0000 differ
89=== modified file 'RememberTheMilk/src/RTM.cs'
90--- RememberTheMilk/src/RTM.cs 2009-03-18 18:45:13 +0000
91+++ RememberTheMilk/src/RTM.cs 2009-03-20 16:35:27 +0000
92@@ -319,6 +319,24 @@
93 UniverseRemoveTask (taskId, listId);
94 UpdateTasks ();
95 }
96+
97+ private static void ActionRoutine (string title, string body, string listId)
98+ {
99+ if (Preferences.ActionNotification) {
100+ Do.Platform.Services.Notifications.Notify( new Do.Platform.Notification( title, body,
101+ "rtm.png@" + typeof(RTMTaskItem).Assembly.FullName ) );
102+ }
103+ UpdateLists ();
104+ }
105+
106+ private static void ActionRoutine (string title, string body)
107+ {
108+ if (Preferences.ActionNotification) {
109+ Do.Platform.Services.Notifications.Notify( new Do.Platform.Notification( title, body,
110+ "rtm.png@" + typeof(RTMTaskItem).Assembly.FullName ) );
111+ }
112+ UpdateLists ();
113+ }
114
115 public static RTMTaskItem NewTask (string listId, string taskData)
116 {
117@@ -367,6 +385,33 @@
118 priority,
119 rtmList.TaskSeriesCollection[0].TaskCollection[0].HasDueTime);
120 }
121+
122+ public static void NewList(string newListName)
123+ {
124+ try {
125+ rtm.ListsNew(timeline, newListName);
126+ } catch (RtmException e) {
127+ Console.Error.WriteLine (e.Message);
128+ return;
129+ }
130+
131+ ActionRoutine (Catalog.GetString("New List Created"),
132+ Catalog.GetString(String.Format ("A new task"
133+ + " list named \"{0}\" has been created.", newListName)));
134+ }
135+
136+ public static void DeleteList(string listId)
137+ {
138+ try {
139+ rtm.ListsDelete(timeline, listId);
140+ } catch (RtmException e) {
141+ Console.Error.WriteLine (e.Message);
142+ return;
143+ }
144+
145+ ActionRoutine (Catalog.GetString("List Deleted"),
146+ Catalog.GetString("The selected task list has been deleted."));
147+ }
148
149 public static void DeleteTask (string listId, string taskSeriesId, string taskId)
150 {
151@@ -532,6 +577,21 @@
152 taskId, listId);
153 }
154 }
155+
156+ public static void RenameList(string listId, string newListName)
157+ {
158+ try {
159+ rtm.ListsRename(timeline, listId, newListName);
160+ } catch (RtmException e) {
161+ Console.Error.WriteLine (e.Message);
162+ return;
163+ }
164+
165+ ActionRoutine (Catalog.GetString("Task List Renamed"),
166+ Catalog.GetString(String.Format ("The selected task"
167+ + " list has been renamed to \"{0}\".", newListName)),
168+ listId);
169+ }
170
171 public static void UncompleteTask (string listId, string taskSeriesId, string taskId)
172 {
173
174=== added file 'RememberTheMilk/src/RTMDeleteList.cs'
175--- RememberTheMilk/src/RTMDeleteList.cs 1970-01-01 00:00:00 +0000
176+++ RememberTheMilk/src/RTMDeleteList.cs 2009-03-20 16:35:27 +0000
177@@ -0,0 +1,67 @@
178+/* RTMDeleteList.cs
179+ *
180+ * GNOME Do is the legal property of its developers. Please refer to the
181+ * COPYRIGHT file distributed with this source distribution.
182+ *
183+ * This program is free software: you can redistribute it and/or modify
184+ * it under the terms of the GNU General Public License as published by
185+ * the Free Software Foundation, either version 3 of the License, or
186+ * (at your option) any later version.
187+ *
188+ * This program is distributed in the hope that it will be useful,
189+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
190+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
191+ * GNU General Public License for more details.
192+ *
193+ * You should have received a copy of the GNU General Public License
194+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
195+ */
196+
197+using System;
198+using System.Linq;
199+using System.Collections.Generic;
200+using Mono.Unix;
201+
202+using Do.Universe;
203+using Do.Platform;
204+
205+namespace RememberTheMilk
206+{
207+ public class RTMDeleteList : Act
208+ {
209+ public override string Name {
210+ get { return Catalog.GetString ("Delete List"); }
211+ }
212+
213+ public override string Description {
214+ get { return Catalog.GetString ("Delete the selected task list from Remember The Milk"); }
215+ }
216+
217+ public override string Icon {
218+ get { return "list-delete.png@" + GetType ().Assembly.FullName; }
219+ }
220+
221+ public override IEnumerable<Type> SupportedItemTypes {
222+ get {
223+ return new Type[] {
224+ typeof (RTMListItem),
225+ };
226+ }
227+ }
228+
229+ public override bool SupportsItem (Item item)
230+ {
231+ return true;
232+ }
233+
234+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
235+ {
236+ string listname = (items.First () as RTMListItem).Id;
237+
238+ Services.Application.RunOnThread (() => {
239+ RTM.DeleteList (listname);
240+ });
241+ yield break;
242+ }
243+ }
244+}
245
246=== added file 'RememberTheMilk/src/RTMNewList.cs'
247--- RememberTheMilk/src/RTMNewList.cs 1970-01-01 00:00:00 +0000
248+++ RememberTheMilk/src/RTMNewList.cs 2009-03-20 16:35:27 +0000
249@@ -0,0 +1,109 @@
250+/* RTMNewList.cs
251+ *
252+ * GNOME Do is the legal property of its developers. Please refer to the
253+ * COPYRIGHT file distributed with this source distribution.
254+ *
255+ * This program is free software: you can redistribute it and/or modify
256+ * it under the terms of the GNU General Public License as published by
257+ * the Free Software Foundation, either version 3 of the License, or
258+ * (at your option) any later version.
259+ *
260+ * This program is distributed in the hope that it will be useful,
261+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
262+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
263+ * GNU General Public License for more details.
264+ *
265+ * You should have received a copy of the GNU General Public License
266+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
267+ */
268+
269+using System;
270+using System.Linq;
271+using System.Collections.Generic;
272+using Mono.Unix;
273+
274+using Do.Universe;
275+using Do.Platform;
276+
277+namespace RememberTheMilk
278+{
279+ public class RTMNewList : Act
280+ {
281+ public override string Name {
282+ get { return Catalog.GetString ("New List"); }
283+ }
284+
285+ public override string Description {
286+ get { return Catalog.GetString ("Create a new task list."); }
287+ }
288+
289+ public override string Icon {
290+ get { return "list-add.png@" + GetType ().Assembly.FullName; }
291+ }
292+
293+ public bool IsValidListName(string newName) {
294+ string[] invalidNames = {"Inbox", "Sent", "All Tasks"};
295+ bool isValid = true;
296+
297+ foreach(string name in invalidNames) {
298+ if (newName == name)
299+ isValid = false;
300+ }
301+
302+ return isValid;
303+ }
304+
305+ public override IEnumerable<Type> SupportedItemTypes {
306+ get {
307+ return new Type[] {
308+ typeof (ITextItem),
309+ };
310+ }
311+ }
312+
313+ /*public override IEnumerable<Type> SupportedModifierItemTypes {
314+ get {
315+ return new Type[] {
316+ typeof (RTMListItem),
317+ };
318+ }
319+ }*/
320+
321+ public override bool ModifierItemsOptional {
322+ get { return true; }
323+ }
324+
325+ public override bool SupportsItem (Item item) {
326+ return true;
327+ }
328+
329+ public override bool SupportsModifierItemForItems (IEnumerable<Item> item, Item modItem)
330+ {
331+ return true;
332+ }
333+
334+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
335+ {
336+ string newListName = (items.First () as ITextItem).Text;
337+
338+ // Check if user is empty.
339+ if (string.IsNullOrEmpty(newListName)) {
340+ // Need new name.
341+ Services.Notifications.Notify("Remember The Milk",
342+ "No new list name provided.");
343+ yield break;
344+ }
345+
346+ if(!IsValidListName(newListName)) {
347+ Services.Notifications.Notify("Remember The Milk",
348+ "Invalid list name provided.");
349+ yield break;
350+ }
351+
352+ Services.Application.RunOnThread (() => {
353+ RTM.NewList (newListName);
354+ });
355+ yield break;
356+ }
357+ }
358+}
359
360=== added file 'RememberTheMilk/src/RTMRenameList.cs'
361--- RememberTheMilk/src/RTMRenameList.cs 1970-01-01 00:00:00 +0000
362+++ RememberTheMilk/src/RTMRenameList.cs 2009-03-20 15:13:34 +0000
363@@ -0,0 +1,110 @@
364+/* RTMListRename.cs
365+ *
366+ * GNOME Do is the legal property of its developers. Please refer to the
367+ * COPYRIGHT file distributed with this source distribution.
368+ *
369+ * This program is free software: you can redistribute it and/or modify
370+ * it under the terms of the GNU General Public License as published by
371+ * the Free Software Foundation, either version 3 of the License, or
372+ * (at your option) any later version.
373+ *
374+ * This program is distributed in the hope that it will be useful,
375+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
376+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
377+ * GNU General Public License for more details.
378+ *
379+ * You should have received a copy of the GNU General Public License
380+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
381+ */
382+
383+using System;
384+using System.Linq;
385+using System.Collections.Generic;
386+using Mono.Unix;
387+
388+using Do.Universe;
389+using Do.Platform;
390+
391+namespace RememberTheMilk
392+{
393+ public class RTMRenameList : Act
394+ {
395+ public override string Name {
396+ get { return Catalog.GetString ("Rename List"); }
397+ }
398+
399+ public override string Description {
400+ get { return Catalog.GetString ("Sets a new name for a task list."); }
401+ }
402+
403+ public override string Icon {
404+ get { return "list-rename.png@" + GetType ().Assembly.FullName; }
405+ }
406+
407+ public bool IsValidListName(string newName) {
408+ string[] invalidNames = {"Inbox", "Sent", "All Tasks"};
409+ bool isValid = true;
410+
411+ foreach(string name in invalidNames) {
412+ if (newName == name)
413+ isValid = false;
414+ }
415+
416+ return isValid;
417+ }
418+
419+ public override IEnumerable<Type> SupportedItemTypes {
420+ get {
421+ return new Type[] {
422+ typeof (RTMListItem),
423+ };
424+ }
425+ }
426+
427+ public override IEnumerable<Type> SupportedModifierItemTypes {
428+ get {
429+ return new Type[] {
430+ typeof (ITextItem),
431+ };
432+ }
433+ }
434+
435+ public override bool ModifierItemsOptional {
436+ get { return false; }
437+ }
438+
439+ public override bool SupportsItem (Item item) {
440+ return true;
441+ }
442+
443+ public override bool SupportsModifierItemForItems (IEnumerable<Item> item, Item modItem)
444+ {
445+ return true;
446+ }
447+
448+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
449+ {
450+ string newListName = ((modifierItems.FirstOrDefault() as ITextItem).Text);
451+
452+ // Check if user is empty.
453+ if (string.IsNullOrEmpty(newListName)) {
454+ // Need new name.
455+ Services.Notifications.Notify("Remember The Milk",
456+ "No new list name provided.");
457+ yield break;
458+ }
459+
460+ if(!IsValidListName(newListName)) {
461+ Services.Notifications.Notify("Remember The Milk",
462+ "Invalid list name provided.");
463+ yield break;
464+ }
465+
466+ Services.Application.RunOnThread (() => {
467+ RTM.RenameList ((items.First () as RTMListItem).Id,
468+ newListName);
469+ });
470+ yield break;
471+ }
472+ }
473+}
474
475=== modified file 'RememberTheMilk/src/RtmNet/Rtm.cs'
476--- RememberTheMilk/src/RtmNet/Rtm.cs 2009-03-16 23:26:24 +0000
477+++ RememberTheMilk/src/RtmNet/Rtm.cs 2009-03-20 16:35:27 +0000
478@@ -549,6 +549,65 @@
479 throw new RtmApiException(response.Error);
480 }
481 }
482+
483+ public Lists ListsNew(string timeline, string listName)
484+ {
485+ Hashtable parameters = new Hashtable();
486+ parameters.Add("method", "rtm.lists.add");
487+ parameters.Add("timeline", timeline);
488+ parameters.Add("name", listName);
489+ //parameters.Add("filter", listfilters); TODO.
490+
491+ RtmNet.Response response = GetResponse(parameters);
492+
493+ if( response.Status == ResponseStatus.OK )
494+ {
495+ return response.Lists;
496+ }
497+ else
498+ {
499+ throw new RtmApiException(response.Error);
500+ }
501+ }
502+
503+ public Lists ListsDelete(string timeline, string listId)
504+ {
505+ Hashtable parameters = new Hashtable();
506+ parameters.Add("method", "rtm.lists.delete");
507+ parameters.Add("timeline", timeline);
508+ parameters.Add("list_id", listId);
509+
510+ RtmNet.Response response = GetResponse(parameters);
511+
512+ if( response.Status == ResponseStatus.OK )
513+ {
514+ return response.Lists;
515+ }
516+ else
517+ {
518+ throw new RtmApiException(response.Error);
519+ }
520+ }
521+
522+ public Lists ListsRename(string timeline, string listId, string newName)
523+ {
524+ Hashtable parameters = new Hashtable();
525+ parameters.Add("method", "rtm.lists.setName");
526+ parameters.Add("timeline", timeline);
527+ parameters.Add("list_id", listId);
528+ parameters.Add("name", newName);
529+
530+ RtmNet.Response response = GetResponse(parameters);
531+
532+ if( response.Status == ResponseStatus.OK )
533+ {
534+ return response.Lists;
535+ }
536+ else
537+ {
538+ throw new RtmApiException(response.Error);
539+ }
540+ }
541 #endregion
542
543

Subscribers

People subscribed via source and target branches

to all changes: