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
=== added file 'GTG/GTG.mdp'
--- GTG/GTG.mdp 1970-01-01 00:00:00 +0000
+++ GTG/GTG.mdp 2010-10-13 08:39:47 +0000
@@ -0,0 +1,39 @@
1<Project name="GTG" fileversion="2.0" newfilesearch="OnLoadAutoInsert" DefaultNamespace="GTG" language="C#" targetFramework="3.5" ctype="DotNetProject">
2 <Deployment.LinuxDeployData />
3 <Configurations active="Debug">
4 <Configuration name="Debug" ctype="DotNetProjectConfiguration">
5 <Output directory="bin/Debug" assembly="GTG" />
6 <Build debugmode="True" target="Library" />
7 <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
8 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
9 </Configuration>
10 <Configuration name="Release" ctype="DotNetProjectConfiguration">
11 <Output directory="bin/Release" assembly="GTG" />
12 <Build debugmode="False" target="Library" />
13 <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
14 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
15 </Configuration>
16 </Configurations>
17 <Contents>
18 <File subtype="Directory" buildaction="Compile" name="src" />
19 <File subtype="Directory" buildaction="Compile" name="Resources" />
20 <File subtype="Code" buildaction="Compile" name="src/CompleteAction.cs" />
21 <File subtype="Code" buildaction="Compile" name="src/CreateAction.cs" />
22 <File subtype="Code" buildaction="Compile" name="src/DeleteTask.cs" />
23 <File subtype="Code" buildaction="Compile" name="src/GTGDBus.cs" />
24 <File subtype="Code" buildaction="Compile" name="src/GTGTask.cs" />
25 <File subtype="Code" buildaction="Compile" name="src/GTGTaskItemSource.cs" />
26 <File subtype="Code" buildaction="Compile" name="src/OpenAction.cs" />
27 <File subtype="Code" buildaction="Nothing" name="Resources/GTG.addin.xml" />
28 </Contents>
29 <References>
30 <ProjectReference type="Gac" localcopy="True" refto="Do.Universe, Version=0.9.0.0, Culture=neutral" />
31 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
32 <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
33 <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.9.0.0, Culture=neutral" />
34 <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
35 <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins.Gui, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
36 <ProjectReference type="Gac" localcopy="True" refto="NDesk.DBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6716e4f9b2ed099" />
37 <ProjectReference type="Gac" localcopy="True" refto="NDesk.DBus.GLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6716e4f9b2ed099" />
38 </References>
39</Project>
0\ No newline at end of file40\ No newline at end of file
141
=== modified file 'GTG/Makefile.am'
--- GTG/Makefile.am 2010-03-27 12:22:00 +0000
+++ GTG/Makefile.am 2010-10-13 08:39:47 +0000
@@ -3,7 +3,10 @@
3ASSEMBLY=GTG3ASSEMBLY=GTG
44
5FILES = \5FILES = \
6 src/GTGAction.cs \6 src/CompleteAction.cs \
7 src/CreateAction.cs \
8 src/DeleteTask.cs \
9 src/OpenAction.cs \
7 src/GTGTask.cs \10 src/GTGTask.cs \
8 src/GTGTaskItemSource.cs \11 src/GTGTaskItemSource.cs \
9 src/GTGDBus.cs12 src/GTGDBus.cs
1013
=== modified file 'GTG/Resources/GTG.addin.xml'
--- GTG/Resources/GTG.addin.xml 2010-05-01 10:59:54 +0000
+++ GTG/Resources/GTG.addin.xml 2010-10-13 08:39:47 +0000
@@ -13,7 +13,7 @@
13 <Import assembly="GTG.dll"/>13 <Import assembly="GTG.dll"/>
14 </Runtime>14 </Runtime>
1515
16 <Localizer type="Gettext" catalog="gnome-do-plugins" location="@expanded_datadir@/locale" />16 <Localizer type="Gettext" catalog="gnome-do-plugins" location="/usr/local/share/locale" />
17 17
18 <Dependencies>18 <Dependencies>
19 <Addin id="Universe" version="1.0" />19 <Addin id="Universe" version="1.0" />
@@ -29,4 +29,4 @@
29 <Action type="GTG.CompleteTask" />29 <Action type="GTG.CompleteTask" />
30 <Action type="GTG.DeleteTask" />30 <Action type="GTG.DeleteTask" />
31 </Extension>31 </Extension>
32</Addin>
33\ No newline at end of file32\ No newline at end of file
33</Addin>
3434
=== added file 'GTG/Resources/GTG.addin.xml.in'
--- GTG/Resources/GTG.addin.xml.in 1970-01-01 00:00:00 +0000
+++ GTG/Resources/GTG.addin.xml.in 2010-10-13 08:39:47 +0000
@@ -0,0 +1,32 @@
1<Addin
2 id="GTG"
3 namespace="Do"
4 version="1.1"
5 name="Getting Things Gnome"
6 description="Create a new and edit, complete or delete an existing GTG task."
7 author="Tomaž Muraus"
8 category="Community"
9 defaultEnabled="false"
10 url="http://do.davebsd.com/wiki/GTG_Plugin"
11>
12 <Runtime>
13 <Import assembly="GTG.dll"/>
14 </Runtime>
15
16 <Localizer type="Gettext" catalog="gnome-do-plugins" location="@expanded_datadir@/locale" />
17
18 <Dependencies>
19 <Addin id="Universe" version="1.0" />
20 </Dependencies>
21
22 <!-- Sources -->
23 <Extension path="/Do/ItemSource">
24 <ItemSource type="GTG.GTGTaskItemSource" />
25 </Extension>
26 <Extension path="/Do/Action">
27 <Action type="GTG.CreateTask" />
28 <Action type="GTG.OpenTask" />
29 <Action type="GTG.CompleteTask" />
30 <Action type="GTG.DeleteTask" />
31 </Extension>
32</Addin>
0\ No newline at end of file33\ No newline at end of file
134
=== modified file 'GTG/src/CreateAction.cs'
--- GTG/src/CreateAction.cs 2010-05-01 10:59:54 +0000
+++ GTG/src/CreateAction.cs 2010-10-13 08:39:47 +0000
@@ -53,7 +53,7 @@
53 53
54 public override string Description54 public override string Description
55 {55 {
56 get { return AddinManager.CurrentLocalizer.GetString ("Creata a new task in Getting Things Gnome!"); }56 get { return AddinManager.CurrentLocalizer.GetString ("Create a new task in Getting Things Gnome!"); }
57 }57 }
58 58
59 public override string Icon59 public override string Icon
@@ -153,9 +153,11 @@
153 }153 }
154 154
155 task.Title = itemText;155 task.Title = itemText;
156 gtg.CreateTask(task);156 var tid = gtg.CreateTask(task);
157 if(tid.ContainsKey("id")){
158 gtg.OpenTaskEditor(tid["id"].ToString());
159 }
157 gtgItemSource.UpdateItems();160 gtgItemSource.UpdateItems();
158
159 return null;161 return null;
160 }162 }
161 163
162164
=== removed file 'GTG/src/GTGAction.cs'
--- GTG/src/GTGAction.cs 2010-05-01 10:59:54 +0000
+++ GTG/src/GTGAction.cs 1970-01-01 00:00:00 +0000
@@ -1,186 +0,0 @@
1// GTGAction.cs
2//
3// GNOME Do is the legal property of its developers, whose names are too
4// numerous to list here. Please refer to the COPYRIGHT file distributed with
5// this source distribution.
6//
7// This program is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20using System;
21using System.Linq;
22using System.Collections;
23using System.Collections.Generic;
24using System.Text.RegularExpressions;
25
26using Do.Universe;
27using Do.Platform;
28
29using Mono.Addins;
30
31using GTG.DBus;
32
33namespace GTG
34{
35 public class CreateTask : Act
36 {
37 static Regex regExpDate = new Regex(@"(?<type>(starts?|ends?|due)):\s?
38 ((?<date_full>(?<day>0[1-9]|[12][0-9]|3[01])[- /.](?<month>0[1-9]|1[012])[- /.](?<year>20\d\d))
39 |(?<date_days>\+(?<days>\d+)\s?days?)
40 |(?<date_tommorow>tom{1,2}or{1,2}ow)
41 |(?<date_today>today))",
42 RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase | RegexOptions.Compiled);
43 static Regex regExpTags = new Regex(@"@(?<tag>[A-Za-z0-9_]+)");
44
45 public CreateTask()
46 {
47 }
48
49 public override string Name
50 {
51 get { return AddinManager.CurrentLocalizer.GetString ("Create a GTG task"); }
52 }
53
54 public override string Description
55 {
56 get { return AddinManager.CurrentLocalizer.GetString ("Creata a new task in Getting Things Gnome!"); }
57 }
58
59 public override string Icon
60 {
61 get { return "gtg"; }
62 }
63
64 public override IEnumerable<Type> SupportedItemTypes
65 {
66 get
67 {
68 yield return typeof(ITextItem);
69 yield return typeof(GTGTask);
70 }
71 }
72
73 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
74 {
75 if (items.First() is ITextItem)
76 {
77 TextItemPerform(items.First() as ITextItem);
78 }
79 else
80 {
81 TaskItemPerform(items.First() as GTGTask);
82 }
83
84 return null;
85 }
86
87 protected Item[] TaskItemPerform(GTGTask task)
88 {
89 GTGDBus gtg = new GTGDBus();
90
91 gtg.OpenTaskEditor(task.TaskId);
92
93 return null;
94 }
95
96 protected Item[] TextItemPerform (ITextItem item)
97 {
98 GTGTaskItemSource gtgItemSource = new GTGTaskItemSource();
99 string itemText = item.Text;
100
101 if (itemText.Length == 0)
102 {
103 return null;
104 }
105
106 GTGDBus gtg = new GTGDBus();
107 GTGTask task = new GTGTask();
108
109 MatchCollection matchesDate = regExpDate.Matches(itemText);
110 MatchCollection matchesTags = regExpTags.Matches(itemText);
111
112 if (matchesDate.Count > 0)
113 {
114 DateTime dateStart = DateTime.MinValue;
115 DateTime dateDue = DateTime.MinValue;
116 itemText = regExpDate.Replace(itemText, "");
117
118 // Task start and/or due date is located in the text
119 foreach (Match match in matchesDate)
120 {
121 string type = match.Groups["type"].Value;
122
123 if (type.IndexOf("start") != -1)
124 {
125 // Start date
126 dateStart = getDateFromMatch(match);
127 }
128 else
129 {
130 // Due/end data
131 dateDue = getDateFromMatch(match);
132 }
133 }
134
135 if (dateStart != DateTime.MinValue)
136 {
137 task.StartDate = dateStart;
138 }
139
140 if (dateDue != DateTime.MinValue)
141 {
142 task.DueDate = dateDue;
143 }
144 }
145
146 if (matchesTags.Count > 0)
147 {
148 itemText = regExpTags.Replace(itemText, "");
149 foreach (Match match in matchesTags)
150 {
151 task.Tags.Add("@" + match.Groups["tag"].Value);
152 }
153 }
154
155 task.Title = itemText;
156 gtg.CreateTask(task);
157 gtgItemSource.UpdateItems();
158
159 return null;
160 }
161
162 protected DateTime getDateFromMatch(Match match)
163 {
164 DateTime date;
165
166 if (match.Groups["date_full"].Success)
167 {
168 date = new DateTime(int.Parse(match.Groups["year"].Value), int.Parse(match.Groups["month"].Value), int.Parse(match.Groups["day"].Value));
169 }
170 else if (match.Groups["date_days"].Success)
171 {
172 date = DateTime.Today.AddDays(int.Parse(match.Groups["days"].Value));
173 }
174 else if (match.Groups["date_tommorow"].Success)
175 {
176 date = DateTime.Today.AddDays(1);
177 }
178 else
179 {
180 date = DateTime.Today;
181 }
182
183 return date;
184 }
185 }
186}
187\ No newline at end of file0\ No newline at end of file
1881
=== modified file 'GTG/src/GTGDBus.cs'
--- GTG/src/GTGDBus.cs 2010-05-01 10:59:54 +0000
+++ GTG/src/GTGDBus.cs 2010-10-13 08:39:47 +0000
@@ -20,7 +20,7 @@
20using System;20using System;
21using System.Collections;21using System.Collections;
22using System.Collections.Generic;22using System.Collections.Generic;
2323using System.Linq;
24using NDesk.DBus;24using NDesk.DBus;
2525
26using Do.Platform;26using Do.Platform;
@@ -33,13 +33,17 @@
33 {33 {
34 // There is a bug in ndesk-dbus package which comes with Ubuntu (9.10)34 // There is a bug in ndesk-dbus package which comes with Ubuntu (9.10)
35 // Package from https://edge.launchpad.net/~docky-core/+archive/ppa PPA works fine35 // Package from https://edge.launchpad.net/~docky-core/+archive/ppa PPA works fine
36 //This call cause System.Exception: Read non-zero byte at position 4 while expecting padding
36 IDictionary<string, object>[] get_tasks();37 IDictionary<string, object>[] get_tasks();
37 IDictionary<string, object> get_task(string taskId);38 IDictionary<string, object> get_task(string taskId);
38 39 string[] get_task_ids(string ids);
39 string open_task_editor(string taskId);40
40 string new_task(string status, string title, string dueDate, string startDate, string doneDate, string[] tags, string text, string subTasks);41 void open_task_editor(string taskId);
41 string modify_task(string taskId, Hashtable taskData);42 IDictionary<string, object> new_task(string status, string title, string dueDate, string startDate, string doneDate, string[] tags, string text, string subTasks);
42 string delete_task(string taskId);43 void modify_task(string taskId, IDictionary<string, object> taskData);
44 void delete_task(string taskId);
45 void show_task_browser();
46
43 }47 }
44 48
45 public class GTGDBus49 public class GTGDBus
@@ -50,7 +54,7 @@
50 54
51 public GTGDBus()55 public GTGDBus()
52 {56 {
53 GTG = FindInstance();57 //GTG = FindInstance();
54 try58 try
55 {59 {
56 GTG = FindInstance();60 GTG = FindInstance();
@@ -73,61 +77,87 @@
73 77
74 public IDictionary<string, object>[] GetActiveTasks()78 public IDictionary<string, object>[] GetActiveTasks()
75 {79 {
76 return GTG.get_tasks();80 var tids = GTG.get_task_ids("Active");
81 return tids.Select(tid => GetTask(tid)).ToArray();
82
77 }83 }
78 84
79 public IDictionary<string, object> GetTask(string taskId)85 public IDictionary<string, object> GetTask(string taskId)
80 {86 {
87 Log.Debug("Get GTG task "+taskId);
81 return GTG.get_task(taskId);88 return GTG.get_task(taskId);
82 }89 }
83 90
84 public string CreateTask(GTGTask task)91 public IDictionary<string, object> CreateTask(GTGTask task)
85 {92 {
86 try93 try
87 {94 {
88 return GTG.new_task(task.StatusString, task.Title, task.DueDateString, task.StartDateString,95 Log.Debug("Creating GTG task "+task.Title);
96 //We want add tags also to the body of task as classic
97 task.Text = String.Join(", ",task.TagsArray) + task.Text +"\n";
98 var returnedTask = GTG.new_task(task.StatusString, task.Title, task.DueDateString, task.StartDateString,
89 task.DoneDateString, task.TagsArray, task.Text, task.SubTasksString);99 task.DoneDateString, task.TagsArray, task.Text, task.SubTasksString);
90 }100 Log.Debug("GTG task created with id "+returnedTask["id"]);
91 catch (Exception)101 return returnedTask;
92 {102 }
93 return "";103 catch (Exception)
94 }104 {
95 }105 return null;
96 106 }
97 public string OpenTaskEditor(string taskId)107 }
98 {108
99 try109 public void OpenTaskEditor(string taskId)
100 {110 {
101 return GTG.open_task_editor(taskId);111 try
102 }112 {
103 catch (Exception)113 Log.Debug("Opening GTG task editor "+taskId);
104 {114 GTG.open_task_editor(taskId);
105 return "";115 }
106 }116 catch (Exception)
107 }117 {
108 118
109 public string CompleteTask(GTGTask task)119 }
110 {120 }
111 try121
112 {122 public void CompleteTask(GTGTask task)
113 return GTG.modify_task(task.TaskId, task.GetTaskData());123 {
114 }124 try
115 catch (Exception)125 {
116 {126 Log.Debug("Modifying GTG task "+task.Title);
117 return "";127 GTG.modify_task(task.TaskId, task.GetTaskData());
118 }128 }
119 }129 catch (Exception)
120 130 {
121 public string DeleteTask(string taskId)131
122 {132 }
123 try133 }
124 {134
125 return GTG.delete_task(taskId);135 public void DeleteTask(string taskId)
126 }136 {
127 catch (Exception)137 try
128 {138 {
129 return "";139 Log.Debug("Delete GTG task "+taskId);
130 }140 GTG.delete_task(taskId);
131 }141 }
142 catch (Exception)
143 {
144
145 }
146 }
147
148 public void ShowTaskBrowser()
149 {
150 try
151 {
152 Log.Debug("Showing GTG task browser");
153 GTG.show_task_browser();
154 }
155 catch (Exception)
156 {
157
158 }
159 }
160
161
132 }162 }
133}163}
134\ No newline at end of file164\ No newline at end of file
135165
=== modified file 'GTG/src/GTGTask.cs'
--- GTG/src/GTGTask.cs 2010-05-01 10:59:54 +0000
+++ GTG/src/GTGTask.cs 2010-10-13 08:39:47 +0000
@@ -169,9 +169,10 @@
169 get { return ""; }169 get { return ""; }
170 }170 }
171 171
172 public Hashtable GetTaskData()172 public IDictionary<string, object> GetTaskData()
173 {173 {
174 Hashtable taskData = new Hashtable();174 //Hashtable taskData = new Hashtable();
175 var taskData = new Dictionary<string, object>();
175 176
176 taskData.Add("status", this.StatusString);177 taskData.Add("status", this.StatusString);
177 taskData.Add("title", this.Title);178 taskData.Add("title", this.Title);
178179
=== modified file 'GTG/src/GTGTaskItemSource.cs'
--- GTG/src/GTGTaskItemSource.cs 2010-05-01 10:59:54 +0000
+++ GTG/src/GTGTaskItemSource.cs 2010-10-13 08:39:47 +0000
@@ -66,7 +66,8 @@
66 public override void UpdateItems()66 public override void UpdateItems()
67 {67 {
68 items.Clear(); 68 items.Clear();
6969
70
70 foreach (IDictionary<string, object> item in gtg.GetActiveTasks())71 foreach (IDictionary<string, object> item in gtg.GetActiveTasks())
71 {72 {
72 items.Add(new GTGTask((string)item["id"], (string)item["title"]));73 items.Add(new GTGTask((string)item["id"], (string)item["title"]));
7374
=== modified file 'configure.ac'
--- configure.ac 2010-03-08 02:43:56 +0000
+++ configure.ac 2010-10-13 08:39:47 +0000
@@ -313,6 +313,8 @@
313GoogleMaps/Resources/GoogleMaps.addin.xml313GoogleMaps/Resources/GoogleMaps.addin.xml
314GoogleSearch/Makefile314GoogleSearch/Makefile
315GoogleSearch/Resources/GoogleSearch.addin.xml315GoogleSearch/Resources/GoogleSearch.addin.xml
316GTG/Makefile
317GTG/Resources/GTG.addin.xml
316ImageShack/Makefile318ImageShack/Makefile
317ImageShack/Resources/ImageShack.addin.xml319ImageShack/Resources/ImageShack.addin.xml
318JIRA/Makefile320JIRA/Makefile

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: