Do

Merge lp:~ilja-smoli/do/gtg into lp:~tomaz-muraus/do/gtg

Proposed by Ilja Smoli
Status: Merged
Merged at revision: 684
Proposed branch: lp:~ilja-smoli/do/gtg
Merge into: lp:~tomaz-muraus/do/gtg
Diff against target: 560 lines (+171/-247)
10 files modified
GTG/GTG.mdp (+39/-0)
GTG/Makefile.am (+4/-1)
GTG/Resources/GTG.addin.xml (+2/-2)
GTG/Resources/GTG.addin.xml.in (+32/-0)
GTG/src/CreateAction.cs (+5/-3)
GTG/src/GTGAction.cs (+0/-186)
GTG/src/GTGDBus.cs (+82/-52)
GTG/src/GTGTask.cs (+3/-2)
GTG/src/GTGTaskItemSource.cs (+2/-1)
configure.ac (+2/-0)
To merge this branch: bzr merge lp:~ilja-smoli/do/gtg

This proposal supersedes a proposal from 2010-10-03.

Description of the change

-- Fixed plugin crash gnome-do
-- Adjusted a bit GTG Dbus contract
-- Tags are added to the body of task
Now active tasks are working

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=== added file 'GTG/GTG.mdp'
2--- GTG/GTG.mdp 1970-01-01 00:00:00 +0000
3+++ GTG/GTG.mdp 2010-10-13 08:39:47 +0000
4@@ -0,0 +1,39 @@
5+<Project name="GTG" fileversion="2.0" newfilesearch="OnLoadAutoInsert" DefaultNamespace="GTG" language="C#" targetFramework="3.5" ctype="DotNetProject">
6+ <Deployment.LinuxDeployData />
7+ <Configurations active="Debug">
8+ <Configuration name="Debug" ctype="DotNetProjectConfiguration">
9+ <Output directory="bin/Debug" assembly="GTG" />
10+ <Build debugmode="True" target="Library" />
11+ <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
12+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
13+ </Configuration>
14+ <Configuration name="Release" ctype="DotNetProjectConfiguration">
15+ <Output directory="bin/Release" assembly="GTG" />
16+ <Build debugmode="False" target="Library" />
17+ <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
18+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
19+ </Configuration>
20+ </Configurations>
21+ <Contents>
22+ <File subtype="Directory" buildaction="Compile" name="src" />
23+ <File subtype="Directory" buildaction="Compile" name="Resources" />
24+ <File subtype="Code" buildaction="Compile" name="src/CompleteAction.cs" />
25+ <File subtype="Code" buildaction="Compile" name="src/CreateAction.cs" />
26+ <File subtype="Code" buildaction="Compile" name="src/DeleteTask.cs" />
27+ <File subtype="Code" buildaction="Compile" name="src/GTGDBus.cs" />
28+ <File subtype="Code" buildaction="Compile" name="src/GTGTask.cs" />
29+ <File subtype="Code" buildaction="Compile" name="src/GTGTaskItemSource.cs" />
30+ <File subtype="Code" buildaction="Compile" name="src/OpenAction.cs" />
31+ <File subtype="Code" buildaction="Nothing" name="Resources/GTG.addin.xml" />
32+ </Contents>
33+ <References>
34+ <ProjectReference type="Gac" localcopy="True" refto="Do.Universe, Version=0.9.0.0, Culture=neutral" />
35+ <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
36+ <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
37+ <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.9.0.0, Culture=neutral" />
38+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
39+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
40+ <ProjectReference type="Gac" localcopy="True" refto="NDesk.DBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6716e4f9b2ed099" />
41+ <ProjectReference type="Gac" localcopy="True" refto="NDesk.DBus.GLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6716e4f9b2ed099" />
42+ </References>
43+</Project>
44\ No newline at end of file
45
46=== modified file 'GTG/Makefile.am'
47--- GTG/Makefile.am 2010-03-27 12:22:00 +0000
48+++ GTG/Makefile.am 2010-10-13 08:39:47 +0000
49@@ -3,7 +3,10 @@
50 ASSEMBLY=GTG
51
52 FILES = \
53- src/GTGAction.cs \
54+ src/CompleteAction.cs \
55+ src/CreateAction.cs \
56+ src/DeleteTask.cs \
57+ src/OpenAction.cs \
58 src/GTGTask.cs \
59 src/GTGTaskItemSource.cs \
60 src/GTGDBus.cs
61
62=== modified file 'GTG/Resources/GTG.addin.xml'
63--- GTG/Resources/GTG.addin.xml 2010-05-01 10:59:54 +0000
64+++ GTG/Resources/GTG.addin.xml 2010-10-13 08:39:47 +0000
65@@ -13,7 +13,7 @@
66 <Import assembly="GTG.dll"/>
67 </Runtime>
68
69- <Localizer type="Gettext" catalog="gnome-do-plugins" location="@expanded_datadir@/locale" />
70+ <Localizer type="Gettext" catalog="gnome-do-plugins" location="/usr/local/share/locale" />
71
72 <Dependencies>
73 <Addin id="Universe" version="1.0" />
74@@ -29,4 +29,4 @@
75 <Action type="GTG.CompleteTask" />
76 <Action type="GTG.DeleteTask" />
77 </Extension>
78-</Addin>
79\ No newline at end of file
80+</Addin>
81
82=== added file 'GTG/Resources/GTG.addin.xml.in'
83--- GTG/Resources/GTG.addin.xml.in 1970-01-01 00:00:00 +0000
84+++ GTG/Resources/GTG.addin.xml.in 2010-10-13 08:39:47 +0000
85@@ -0,0 +1,32 @@
86+<Addin
87+ id="GTG"
88+ namespace="Do"
89+ version="1.1"
90+ name="Getting Things Gnome"
91+ description="Create a new and edit, complete or delete an existing GTG task."
92+ author="Tomaž Muraus"
93+ category="Community"
94+ defaultEnabled="false"
95+ url="http://do.davebsd.com/wiki/GTG_Plugin"
96+>
97+ <Runtime>
98+ <Import assembly="GTG.dll"/>
99+ </Runtime>
100+
101+ <Localizer type="Gettext" catalog="gnome-do-plugins" location="@expanded_datadir@/locale" />
102+
103+ <Dependencies>
104+ <Addin id="Universe" version="1.0" />
105+ </Dependencies>
106+
107+ <!-- Sources -->
108+ <Extension path="/Do/ItemSource">
109+ <ItemSource type="GTG.GTGTaskItemSource" />
110+ </Extension>
111+ <Extension path="/Do/Action">
112+ <Action type="GTG.CreateTask" />
113+ <Action type="GTG.OpenTask" />
114+ <Action type="GTG.CompleteTask" />
115+ <Action type="GTG.DeleteTask" />
116+ </Extension>
117+</Addin>
118\ No newline at end of file
119
120=== modified file 'GTG/src/CreateAction.cs'
121--- GTG/src/CreateAction.cs 2010-05-01 10:59:54 +0000
122+++ GTG/src/CreateAction.cs 2010-10-13 08:39:47 +0000
123@@ -53,7 +53,7 @@
124
125 public override string Description
126 {
127- get { return AddinManager.CurrentLocalizer.GetString ("Creata a new task in Getting Things Gnome!"); }
128+ get { return AddinManager.CurrentLocalizer.GetString ("Create a new task in Getting Things Gnome!"); }
129 }
130
131 public override string Icon
132@@ -153,9 +153,11 @@
133 }
134
135 task.Title = itemText;
136- gtg.CreateTask(task);
137+ var tid = gtg.CreateTask(task);
138+ if(tid.ContainsKey("id")){
139+ gtg.OpenTaskEditor(tid["id"].ToString());
140+ }
141 gtgItemSource.UpdateItems();
142-
143 return null;
144 }
145
146
147=== removed file 'GTG/src/GTGAction.cs'
148--- GTG/src/GTGAction.cs 2010-05-01 10:59:54 +0000
149+++ GTG/src/GTGAction.cs 1970-01-01 00:00:00 +0000
150@@ -1,186 +0,0 @@
151-// GTGAction.cs
152-//
153-// GNOME Do is the legal property of its developers, whose names are too
154-// numerous to list here. Please refer to the COPYRIGHT file distributed with
155-// this source distribution.
156-//
157-// This program is free software: you can redistribute it and/or modify
158-// it under the terms of the GNU General Public License as published by
159-// the Free Software Foundation, either version 3 of the License, or
160-// (at your option) any later version.
161-//
162-// This program is distributed in the hope that it will be useful,
163-// but WITHOUT ANY WARRANTY; without even the implied warranty of
164-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
165-// GNU General Public License for more details.
166-//
167-// You should have received a copy of the GNU General Public License
168-// along with this program. If not, see <http://www.gnu.org/licenses/>.
169-
170-using System;
171-using System.Linq;
172-using System.Collections;
173-using System.Collections.Generic;
174-using System.Text.RegularExpressions;
175-
176-using Do.Universe;
177-using Do.Platform;
178-
179-using Mono.Addins;
180-
181-using GTG.DBus;
182-
183-namespace GTG
184-{
185- public class CreateTask : Act
186- {
187- static Regex regExpDate = new Regex(@"(?<type>(starts?|ends?|due)):\s?
188- ((?<date_full>(?<day>0[1-9]|[12][0-9]|3[01])[- /.](?<month>0[1-9]|1[012])[- /.](?<year>20\d\d))
189- |(?<date_days>\+(?<days>\d+)\s?days?)
190- |(?<date_tommorow>tom{1,2}or{1,2}ow)
191- |(?<date_today>today))",
192- RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase | RegexOptions.Compiled);
193- static Regex regExpTags = new Regex(@"@(?<tag>[A-Za-z0-9_]+)");
194-
195- public CreateTask()
196- {
197- }
198-
199- public override string Name
200- {
201- get { return AddinManager.CurrentLocalizer.GetString ("Create a GTG task"); }
202- }
203-
204- public override string Description
205- {
206- get { return AddinManager.CurrentLocalizer.GetString ("Creata a new task in Getting Things Gnome!"); }
207- }
208-
209- public override string Icon
210- {
211- get { return "gtg"; }
212- }
213-
214- public override IEnumerable<Type> SupportedItemTypes
215- {
216- get
217- {
218- yield return typeof(ITextItem);
219- yield return typeof(GTGTask);
220- }
221- }
222-
223- public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
224- {
225- if (items.First() is ITextItem)
226- {
227- TextItemPerform(items.First() as ITextItem);
228- }
229- else
230- {
231- TaskItemPerform(items.First() as GTGTask);
232- }
233-
234- return null;
235- }
236-
237- protected Item[] TaskItemPerform(GTGTask task)
238- {
239- GTGDBus gtg = new GTGDBus();
240-
241- gtg.OpenTaskEditor(task.TaskId);
242-
243- return null;
244- }
245-
246- protected Item[] TextItemPerform (ITextItem item)
247- {
248- GTGTaskItemSource gtgItemSource = new GTGTaskItemSource();
249- string itemText = item.Text;
250-
251- if (itemText.Length == 0)
252- {
253- return null;
254- }
255-
256- GTGDBus gtg = new GTGDBus();
257- GTGTask task = new GTGTask();
258-
259- MatchCollection matchesDate = regExpDate.Matches(itemText);
260- MatchCollection matchesTags = regExpTags.Matches(itemText);
261-
262- if (matchesDate.Count > 0)
263- {
264- DateTime dateStart = DateTime.MinValue;
265- DateTime dateDue = DateTime.MinValue;
266- itemText = regExpDate.Replace(itemText, "");
267-
268- // Task start and/or due date is located in the text
269- foreach (Match match in matchesDate)
270- {
271- string type = match.Groups["type"].Value;
272-
273- if (type.IndexOf("start") != -1)
274- {
275- // Start date
276- dateStart = getDateFromMatch(match);
277- }
278- else
279- {
280- // Due/end data
281- dateDue = getDateFromMatch(match);
282- }
283- }
284-
285- if (dateStart != DateTime.MinValue)
286- {
287- task.StartDate = dateStart;
288- }
289-
290- if (dateDue != DateTime.MinValue)
291- {
292- task.DueDate = dateDue;
293- }
294- }
295-
296- if (matchesTags.Count > 0)
297- {
298- itemText = regExpTags.Replace(itemText, "");
299- foreach (Match match in matchesTags)
300- {
301- task.Tags.Add("@" + match.Groups["tag"].Value);
302- }
303- }
304-
305- task.Title = itemText;
306- gtg.CreateTask(task);
307- gtgItemSource.UpdateItems();
308-
309- return null;
310- }
311-
312- protected DateTime getDateFromMatch(Match match)
313- {
314- DateTime date;
315-
316- if (match.Groups["date_full"].Success)
317- {
318- date = new DateTime(int.Parse(match.Groups["year"].Value), int.Parse(match.Groups["month"].Value), int.Parse(match.Groups["day"].Value));
319- }
320- else if (match.Groups["date_days"].Success)
321- {
322- date = DateTime.Today.AddDays(int.Parse(match.Groups["days"].Value));
323- }
324- else if (match.Groups["date_tommorow"].Success)
325- {
326- date = DateTime.Today.AddDays(1);
327- }
328- else
329- {
330- date = DateTime.Today;
331- }
332-
333- return date;
334- }
335- }
336-}
337\ No newline at end of file
338
339=== modified file 'GTG/src/GTGDBus.cs'
340--- GTG/src/GTGDBus.cs 2010-05-01 10:59:54 +0000
341+++ GTG/src/GTGDBus.cs 2010-10-13 08:39:47 +0000
342@@ -20,7 +20,7 @@
343 using System;
344 using System.Collections;
345 using System.Collections.Generic;
346-
347+using System.Linq;
348 using NDesk.DBus;
349
350 using Do.Platform;
351@@ -33,13 +33,17 @@
352 {
353 // There is a bug in ndesk-dbus package which comes with Ubuntu (9.10)
354 // Package from https://edge.launchpad.net/~docky-core/+archive/ppa PPA works fine
355+ //This call cause System.Exception: Read non-zero byte at position 4 while expecting padding
356 IDictionary<string, object>[] get_tasks();
357 IDictionary<string, object> get_task(string taskId);
358-
359- string open_task_editor(string taskId);
360- string new_task(string status, string title, string dueDate, string startDate, string doneDate, string[] tags, string text, string subTasks);
361- string modify_task(string taskId, Hashtable taskData);
362- string delete_task(string taskId);
363+ string[] get_task_ids(string ids);
364+
365+ void open_task_editor(string taskId);
366+ IDictionary<string, object> new_task(string status, string title, string dueDate, string startDate, string doneDate, string[] tags, string text, string subTasks);
367+ void modify_task(string taskId, IDictionary<string, object> taskData);
368+ void delete_task(string taskId);
369+ void show_task_browser();
370+
371 }
372
373 public class GTGDBus
374@@ -50,7 +54,7 @@
375
376 public GTGDBus()
377 {
378- GTG = FindInstance();
379+ //GTG = FindInstance();
380 try
381 {
382 GTG = FindInstance();
383@@ -73,61 +77,87 @@
384
385 public IDictionary<string, object>[] GetActiveTasks()
386 {
387- return GTG.get_tasks();
388+ var tids = GTG.get_task_ids("Active");
389+ return tids.Select(tid => GetTask(tid)).ToArray();
390+
391 }
392
393 public IDictionary<string, object> GetTask(string taskId)
394 {
395+ Log.Debug("Get GTG task "+taskId);
396 return GTG.get_task(taskId);
397 }
398
399- public string CreateTask(GTGTask task)
400+ public IDictionary<string, object> CreateTask(GTGTask task)
401 {
402 try
403 {
404- return GTG.new_task(task.StatusString, task.Title, task.DueDateString, task.StartDateString,
405+ Log.Debug("Creating GTG task "+task.Title);
406+ //We want add tags also to the body of task as classic
407+ task.Text = String.Join(", ",task.TagsArray) + task.Text +"\n";
408+ var returnedTask = GTG.new_task(task.StatusString, task.Title, task.DueDateString, task.StartDateString,
409 task.DoneDateString, task.TagsArray, task.Text, task.SubTasksString);
410- }
411- catch (Exception)
412- {
413- return "";
414- }
415- }
416-
417- public string OpenTaskEditor(string taskId)
418- {
419- try
420- {
421- return GTG.open_task_editor(taskId);
422- }
423- catch (Exception)
424- {
425- return "";
426- }
427- }
428-
429- public string CompleteTask(GTGTask task)
430- {
431- try
432- {
433- return GTG.modify_task(task.TaskId, task.GetTaskData());
434- }
435- catch (Exception)
436- {
437- return "";
438- }
439- }
440-
441- public string DeleteTask(string taskId)
442- {
443- try
444- {
445- return GTG.delete_task(taskId);
446- }
447- catch (Exception)
448- {
449- return "";
450- }
451- }
452+ Log.Debug("GTG task created with id "+returnedTask["id"]);
453+ return returnedTask;
454+ }
455+ catch (Exception)
456+ {
457+ return null;
458+ }
459+ }
460+
461+ public void OpenTaskEditor(string taskId)
462+ {
463+ try
464+ {
465+ Log.Debug("Opening GTG task editor "+taskId);
466+ GTG.open_task_editor(taskId);
467+ }
468+ catch (Exception)
469+ {
470+
471+ }
472+ }
473+
474+ public void CompleteTask(GTGTask task)
475+ {
476+ try
477+ {
478+ Log.Debug("Modifying GTG task "+task.Title);
479+ GTG.modify_task(task.TaskId, task.GetTaskData());
480+ }
481+ catch (Exception)
482+ {
483+
484+ }
485+ }
486+
487+ public void DeleteTask(string taskId)
488+ {
489+ try
490+ {
491+ Log.Debug("Delete GTG task "+taskId);
492+ GTG.delete_task(taskId);
493+ }
494+ catch (Exception)
495+ {
496+
497+ }
498+ }
499+
500+ public void ShowTaskBrowser()
501+ {
502+ try
503+ {
504+ Log.Debug("Showing GTG task browser");
505+ GTG.show_task_browser();
506+ }
507+ catch (Exception)
508+ {
509+
510+ }
511+ }
512+
513+
514 }
515 }
516\ No newline at end of file
517
518=== modified file 'GTG/src/GTGTask.cs'
519--- GTG/src/GTGTask.cs 2010-05-01 10:59:54 +0000
520+++ GTG/src/GTGTask.cs 2010-10-13 08:39:47 +0000
521@@ -169,9 +169,10 @@
522 get { return ""; }
523 }
524
525- public Hashtable GetTaskData()
526+ public IDictionary<string, object> GetTaskData()
527 {
528- Hashtable taskData = new Hashtable();
529+ //Hashtable taskData = new Hashtable();
530+ var taskData = new Dictionary<string, object>();
531
532 taskData.Add("status", this.StatusString);
533 taskData.Add("title", this.Title);
534
535=== modified file 'GTG/src/GTGTaskItemSource.cs'
536--- GTG/src/GTGTaskItemSource.cs 2010-05-01 10:59:54 +0000
537+++ GTG/src/GTGTaskItemSource.cs 2010-10-13 08:39:47 +0000
538@@ -66,7 +66,8 @@
539 public override void UpdateItems()
540 {
541 items.Clear();
542-
543+
544+
545 foreach (IDictionary<string, object> item in gtg.GetActiveTasks())
546 {
547 items.Add(new GTGTask((string)item["id"], (string)item["title"]));
548
549=== modified file 'configure.ac'
550--- configure.ac 2010-03-08 02:43:56 +0000
551+++ configure.ac 2010-10-13 08:39:47 +0000
552@@ -313,6 +313,8 @@
553 GoogleMaps/Resources/GoogleMaps.addin.xml
554 GoogleSearch/Makefile
555 GoogleSearch/Resources/GoogleSearch.addin.xml
556+GTG/Makefile
557+GTG/Resources/GTG.addin.xml
558 ImageShack/Makefile
559 ImageShack/Resources/ImageShack.addin.xml
560 JIRA/Makefile

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: