tasque r208 - in trunk: . src/Backends/Hiveminder src/Backends/Hiveminder/service
- From: jjohnny svn gnome org
- To: svn-commits-list gnome org
- Subject: tasque r208 - in trunk: . src/Backends/Hiveminder src/Backends/Hiveminder/service
- Date: Thu, 15 Jan 2009 15:12:47 +0000 (UTC)
Author: jjohnny
Date: Thu Jan 15 15:12:47 2009
New Revision: 208
URL: http://svn.gnome.org/viewvc/tasque?rev=208&view=rev
Log:
Hiveminder : Basic code for upating tasks on server
Modified:
trunk/ChangeLog
trunk/src/Backends/Hiveminder/HmBackend.cs
trunk/src/Backends/Hiveminder/HmTask.cs
trunk/src/Backends/Hiveminder/service/Hiveminder.cs
trunk/src/Backends/Hiveminder/service/Task.cs
Modified: trunk/src/Backends/Hiveminder/HmBackend.cs
==============================================================================
--- trunk/src/Backends/Hiveminder/HmBackend.cs (original)
+++ trunk/src/Backends/Hiveminder/HmBackend.cs Thu Jan 15 15:12:47 2009
@@ -79,8 +79,9 @@
newTaskId = 0;
taskIters = new Dictionary<string, Gtk.TreeIter> ();
taskStore = new Gtk.TreeStore (typeof (ITask));
+
taskLock = new object ();
-
+
sortedTasksModel = new Gtk.TreeModelSort (taskStore);
sortedTasksModel.SetSortFunc (0, new Gtk.TreeIterCompareFunc (CompareTasksSortFunc));
sortedTasksModel.SetSortColumnId (0, Gtk.SortType.Ascending);
@@ -95,6 +96,14 @@
runningRefreshThread = false;
refreshThread = new Thread(RefreshThreadLoop);
}
+
+ void HandleRowChanged(object o, Gtk.RowChangedArgs args)
+ {
+ Logger.Debug ("Handle Row Changed : Task Modified.");
+ HmTask task = (HmTask) taskStore.GetValue (args.Iter, 0);
+ Logger.Debug (task.Name);
+
+ }
#region Public Properties
public string Name
@@ -145,7 +154,7 @@
task.Summary = taskName;
createdTask = this.hm.CreateTask (task);
- HmTask hmTask = new HmTask (createdTask);
+ HmTask hmTask = new HmTask (createdTask, this);
//Add the newly created task into our store.
lock (taskLock) {
@@ -159,6 +168,7 @@
public void DeleteTask(ITask task)
{
+
}
public void Refresh()
@@ -211,7 +221,7 @@
Logger.Debug ("Fetching tasks");
- HmTask[] tasks = HmTask.GetTasks (this.hm.DownloadTasks());
+ HmTask[] tasks = HmTask.GetTasks (this.hm.DownloadTasks(), this);
foreach (HmTask task in tasks) {
task.Dump();
@@ -362,11 +372,13 @@
});
}
}
-
+
public void UpdateTask (HmTask task)
{
-
+ Logger.Debug ("Updating task : " + task.Id);
+ this.hm.UpdateTask (task.RemoteTask);
}
+
#endregion // Private Methods
#region Event Handlers
Modified: trunk/src/Backends/Hiveminder/HmTask.cs
==============================================================================
--- trunk/src/Backends/Hiveminder/HmTask.cs (original)
+++ trunk/src/Backends/Hiveminder/HmTask.cs Thu Jan 15 15:12:47 2009
@@ -38,6 +38,7 @@
{
Task task;
+ private HmBackend backend;
private List <INote> notes;
#region Properties
@@ -50,7 +51,10 @@
public override string Name
{
get { return this.task.Summary; }
- set { this.task.Summary = value; }
+ set {
+ this.task.Summary = value;
+ this.backend.UpdateTask (this);
+ }
}
public override DateTime DueDate
@@ -61,7 +65,9 @@
}
return DateTime.MinValue;
}
- set {this.task.Due = value.ToString();}
+ set {this.task.Due = value.ToString();
+ Logger.Debug ("");
+ }
}
public override DateTime CompletionDate
@@ -142,6 +148,11 @@
}
}
+ public Hiveminder.Task RemoteTask
+ {
+ get { return this.task; }
+ }
+
/// <value>
/// The ID of the timer used to complete a task after being marked
/// inactive.
@@ -159,28 +170,30 @@
#endregion Properties
- public static HmTask[] GetTasks (XmlNodeList list)
+ public static HmTask[] GetTasks (XmlNodeList list, HmBackend backend)
{
uint i = 0;
XmlSerializer serializer = new XmlSerializer(typeof(Task));
HmTask[] tasks = new HmTask[list.Count];
foreach (XmlNode node in list )
- tasks[i++] = new HmTask ((Task)serializer.Deserialize(new StringReader(node.OuterXml)));
+ tasks[i++] = new HmTask ((Task)serializer.
+ Deserialize(new StringReader(node.OuterXml)),
+ backend);
return tasks;
}
#region Constructors
- public HmTask () : this (new Task())
+ public HmTask () : this (new Task(), null)
{
}
- public HmTask (Hiveminder.Task task)
+ public HmTask (Hiveminder.Task task, HmBackend hmBackend)
{
this.task = task;
-
+ this.backend = hmBackend;
//Add Description as note.
this.notes = null;
if (!string.IsNullOrEmpty (this.task.Description)) {
Modified: trunk/src/Backends/Hiveminder/service/Hiveminder.cs
==============================================================================
--- trunk/src/Backends/Hiveminder/service/Hiveminder.cs (original)
+++ trunk/src/Backends/Hiveminder/service/Hiveminder.cs Thu Jan 15 15:12:47 2009
@@ -42,7 +42,8 @@
{
string cookieValue;
cookieValue = this.Login(username, password);
- this.COOKIE_HIVEMINDER_SID = new Cookie ("JIFTY_SID_HIVEMINDER", cookieValue, "/", "hiveminder.com");
+ this.COOKIE_HIVEMINDER_SID = new Cookie ("JIFTY_SID_HIVEMINDER", cookieValue,
+ "/", "hiveminder.com");
}
public string CookieValue
@@ -126,7 +127,7 @@
req.Method = method;
//Data for POST
- if (method.Equals ("POST") && data.Length > 0) {
+ if ((method.Equals ("POST") || method.Equals ("PUT")) && data.Length > 0) {
// We can handle only XML responses.
req.Accept = "text/xml";
req.ContentType = "application/x-www-form-urlencoded";
@@ -243,5 +244,32 @@
createdTask = (Task) serializer.Deserialize(new StringReader(node.OuterXml));
return createdTask;
}
+
+ /// <summary>
+ /// Update Task on the server.
+ /// </summary>
+ public Task UpdateTask (Task task)
+ {
+ string responseString;
+ Task updatedTask;
+
+ XmlSerializer serializer = new XmlSerializer(typeof(Task));
+
+ // Can use /=/model/Task/id/<fields> with PUT.
+ responseString = this.Command ("/=/action/BTDT.Action.UpdateTask/", "POST",
+ task.ToUrlEncodedString);
+
+ XmlDocument xmlDoc = new XmlDocument();
+ xmlDoc.LoadXml (responseString);
+
+ // Updated Task is contained inside 'data' root node
+ XmlNode node = xmlDoc.SelectSingleNode ("//data");
+
+ // Task's root node is 'value'.
+ node = RenameNode (node, string.Empty, "value");
+
+ updatedTask = (Task) serializer.Deserialize(new StringReader(node.OuterXml));
+ return updatedTask;
+ }
}
}
\ No newline at end of file
Modified: trunk/src/Backends/Hiveminder/service/Task.cs
==============================================================================
--- trunk/src/Backends/Hiveminder/service/Task.cs (original)
+++ trunk/src/Backends/Hiveminder/service/Task.cs Thu Jan 15 15:12:47 2009
@@ -34,7 +34,8 @@
[Serializable]
public class Task
{
-
+ private string description;
+
#region PublicProperties
[XmlElement("id", Form=XmlSchemaForm.Unqualified)]
@@ -84,18 +85,24 @@
Console.WriteLine ("complete : " + this.IsComplete);
Console.WriteLine ("Description : " + this.Description);
}
-
+
+ #endregion
+
public string ToUrlEncodedString
{
get {
- //TODO : Add all the required properties here.
string url = "summary=" + this.Summary + "&" +
"description=" + this.Description + "&" +
- "priority=" + this.Priority ;
+ "priority=" + this.Priority + "&" +
+ "complete=" + (this.IsComplete ? "1" : "0") + "&" +
+ "id=" + this.Id + "&" +
+ "due" + this.Due + "&" +
+ "started" + this.Started + "&" +
+ "created" + this.Created + "&" +
+ "group_id" + this.GroupId + "&";
return url;
}
}
- #endregion
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]