File dice-api-changes.diff of Package evolution-mono-providers
commit e697ce39f12129cde77aa9e0bcbc28ab2bf13051
Author: chenthill <chen@rocky.blr.novell.com>
Date: Tue Dec 2 12:07:05 2008 +0530
Fixes bugs 449886(All day events displayed twice), 449885 (task with description does not work). Added support for modifying tasks.
Modified the dice API's as evolution-sharp dependency from dice
has been removed.
diff --git a/calendar/backends/sharepoint/BackGroundWorker.cs b/calendar/backends/sharepoint/BackGroundWorker.cs
index d0d2055..230782c 100644
--- a/calendar/backends/sharepoint/BackGroundWorker.cs
+++ b/calendar/backends/sharepoint/BackGroundWorker.cs
@@ -17,6 +17,55 @@ namespace SharePoint
private Thread backgroundThread;
private static readonly string locker = "lckr";
+
+ private CalComponent [] GetEventChanges (ref string timestamp, ref string [] ids)
+ {
+ CalComponentChanges changes = null;
+ Novell.IceDesktop.IDaemon deskIceDaemon = DaemonConnection.deskIceDaemon;
+
+
+ changes = deskIceDaemon.GetCalendarItemChanges (String.Empty, spBackend.workspaceid,
+ spBackend.folderid, timestamp);
+
+ CalComponent [] comps = new CalComponent [changes.entries.Length];
+ for (int i = 0; i < changes.entries.Length; i++)
+ {
+ ComponentEntry cEntry = new ComponentEntry (changes.entries [i]);
+ CalComponent comp = cEntry.EventEntryToComp ();
+
+ comps [i] = comp;
+ }
+
+ ids = changes.ids;
+ timestamp = changes.timestamp;
+
+ return comps;
+ }
+
+ private CalComponent [] GetTaskChanges (ref string timestamp, ref string [] ids)
+ {
+ TaskComponentChanges changes = null;
+ Novell.IceDesktop.IDaemon deskIceDaemon = DaemonConnection.deskIceDaemon;
+
+
+ changes = deskIceDaemon.GetTaskItemChanges (String.Empty, spBackend.workspaceid,
+ spBackend.folderid, timestamp);
+
+ CalComponent [] comps = new CalComponent [changes.entries.Length];
+ for (int i = 0; i < changes.entries.Length; i++)
+ {
+ ComponentEntry cEntry = new ComponentEntry (changes.entries [i]);
+ CalComponent comp = cEntry.TaskEntryToComp ();
+
+ comps [i] = comp;
+ }
+
+ ids = changes.ids;
+ timestamp = changes.timestamp;
+
+ return comps;
+ }
+
public BackendGroundWorker (SharePointBackend backend)
{
spBackend = backend;
@@ -40,35 +89,37 @@ namespace SharePoint
string timestamp = spBackend.cache.ServerUtcTime;
- Novell.IceDesktop.IDaemon deskIceDaemon = DaemonConnection.deskIceDaemon;
Console.WriteLine ("Getting calendar entries " + spBackend.backend.Source.Name + " " + spBackend.folderid);
if (timestamp == null)
timestamp = String.Empty;
-
- CalComponentChanges changes = null;
try
{
- changes = deskIceDaemon.GetCalendarItemChanges (String.Empty, spBackend.workspaceid,
- spBackend.folderid, timestamp);
+
} catch (Exception ex)
{
Console.WriteLine ("Get calendar changes exception " + ex.Message);
Console.WriteLine (ex.StackTrace);
return;
}
+
+ CalComponent[] changedComps = null;
+ string [] ids = null;
+ if (spBackend.backend.Kind == IcalcomponentKind.VeventComponent)
+ {
+ changedComps = GetEventChanges (ref timestamp, ref ids);
+ }
+ else
+ {
+ changedComps = GetTaskChanges (ref timestamp, ref ids);
+ }
- Console.WriteLine ("The number of events are " + changes.comps.Length);
- if (changes.comps.Length != 0)
+ Console.WriteLine ("The number of events are " + changedComps.Length);
+ if (changedComps.Length != 0)
{
- foreach (string compStr in changes.comps)
+ foreach (CalComponent comp in changedComps)
{
- if (String.IsNullOrEmpty (compStr))
- continue;
-
- CalComponent comp = new CalComponent (compStr);
-
CalComponent cacheComp = spBackend.cache.GetComponent (comp.Uid, comp.RecurId);
if (cacheComp != null)
{
@@ -76,9 +127,7 @@ namespace SharePoint
continue;
}
-
spBackend.cache.PutComponent (comp);
- Console.WriteLine (comp.GetAsString ());
if (cacheComp == null)
spBackend.backend.NotifyObjectCreated (comp.GetAsString ());
@@ -87,7 +136,6 @@ namespace SharePoint
}
}
- string[] ids = changes.ids;
Console.WriteLine ("number of changed ids " + ids.Length);
if (ids.Length != 0)
@@ -126,7 +174,7 @@ namespace SharePoint
}
}
- spBackend.cache.PutServerUtcTime (changes.timestamp);
+ spBackend.cache.PutServerUtcTime (timestamp);
}
diff --git a/calendar/backends/sharepoint/ComponentEntry.cs b/calendar/backends/sharepoint/ComponentEntry.cs
new file mode 100644
index 0000000..150fe2e
--- /dev/null
+++ b/calendar/backends/sharepoint/ComponentEntry.cs
@@ -0,0 +1,549 @@
+// ComponentEntry.cs created with MonoDevelop
+// User: chen at 2:20 PM 12/1/2008
+//
+// To change standard headers go to Edit->Preferences->Coding->Standard Headers
+//
+
+using System;
+using Novell.IceDesktop;
+using Evolution;
+
+namespace SharePoint
+{
+
+
+ public class ComponentEntry
+ {
+ EventEntry eentry;
+ TaskEntry tentry;
+ CalComponent comp;
+ Icaltimezone utcZone;
+
+ private Evolution.FrequencyType GetEvolutionFreq (Novell.IceDesktop.FrequencyType freq)
+ {
+ int frequency = (int) freq;
+
+ Evolution.FrequencyType evoFreq = (Evolution.FrequencyType) frequency;
+
+ return evoFreq;
+ }
+
+ private Novell.IceDesktop.FrequencyType GetDiceFreq (Evolution.FrequencyType freq)
+ {
+ int frequency = (int) freq;
+
+ Novell.IceDesktop.FrequencyType diceFreq = (Novell.IceDesktop.FrequencyType) frequency;
+
+ return diceFreq;
+ }
+
+ private CalRecurrence CalRecurrenceFromItem (EventEntry entry)
+ {
+ CalRecurrence rrule = new CalRecurrence ();
+
+ Console.WriteLine ("Recur Data");
+ Console.WriteLine (entry.Recur.UntilDate);
+ Console.WriteLine (entry.Recur.Count);
+ Console.WriteLine (entry.Recur.Freq);
+ Console.WriteLine (entry.Recur.Interval);
+ if (String.IsNullOrEmpty (entry.Recur.UntilDate) == false)
+ {
+ DateTime until = DateTime.Parse (entry.Recur.UntilDate);
+
+ rrule.Until = until;
+ }
+
+ if (entry.Recur.Count != -1)
+ rrule.count = entry.Recur.Count;
+
+ rrule.freq = GetEvolutionFreq (entry.Recur.Freq);
+ Console.WriteLine ("Evolution freq" + rrule.freq);
+ rrule.interval = entry.Recur.Interval;
+
+ if (rrule.freq == Evolution.FrequencyType.WEEKLY)
+ {
+ rrule.byDay [0] = entry.Recur.ByValue;
+ rrule.byDay [1] = 0x7f7f;
+ }
+
+ return rrule;
+ }
+
+
+ private void SetCalRecurrenceToEntry (CalRecurrence recur, ref EventEntry entry)
+ {
+ int weekStart = (int) recur.week_start_day;
+ entry.Recur.WeekStartDay = (Novell.IceDesktop.WeekDayType) weekStart;
+ entry.Recur.Freq = GetDiceFreq (recur.freq);
+ entry.Recur.Interval = recur.interval;
+
+ if (recur.count != 0)
+ entry.Recur.Count = recur.count;
+ else if (recur.Until != DateTime.MinValue)
+ {
+ entry.Recur.UntilDate = recur.Until.ToString ();
+ }
+
+ if (recur.freq == Evolution.FrequencyType.WEEKLY)
+ entry.Recur.ByValue = recur.byDay [0];
+ }
+
+ public ComponentEntry(EventEntry entry)
+ {
+ this.comp = new CalComponent (CalComponentVType.Event);
+ eentry = entry;
+ utcZone = Icaltimezone.UtcTimezone;
+ }
+
+ public ComponentEntry (TaskEntry entry)
+ {
+ this.comp = new CalComponent (CalComponentVType.Todo);
+ tentry = entry;
+ utcZone = Icaltimezone.UtcTimezone;
+ }
+
+ public ComponentEntry (CalComponent com)
+ {
+ comp = com;
+
+ if (comp.VType == CalComponentVType.Event)
+ eentry = new EventEntry ();
+ else
+ tentry = new TaskEntry ();
+ }
+
+ public CalComponent EventEntryToComp ()
+ {
+
+ if (eentry.EventType == 4)
+ {
+ comp.Uid = Convert.ToString (eentry.MasterSeriesId);
+
+ DateTime rid = DateTime.Parse (eentry.RecurrenceId);
+ comp.Rid = rid;
+ comp.SetXProp ("X-SP-INSTANCE-UID", eentry.ID);
+ } else
+ comp.Uid = eentry.ID;
+
+ comp.Summary = eentry.Title;
+
+ DateTime mod = DateTime.Parse (eentry.LastModifiedDate);
+ comp.LastModified = mod;
+
+ DateTime created = DateTime.Parse (eentry.CreationDate);
+ comp.Created = created;
+
+ if (String.IsNullOrEmpty (eentry.Description) == false)
+ {
+ string [] description = new string [1];
+ description [0] = eentry.Description;
+ comp.Descriptions = description;
+ }
+
+ comp.Location = eentry.Location;
+
+ Console.WriteLine ("All day" + eentry.AllDayEvent);
+
+ CalComponentDateTime dt = new CalComponentDateTime ();
+ Icaltimetype icalt = new Icaltimetype ();
+ DateTime eventDate = DateTime.Parse (eentry.StartDate);
+ icalt.SetDateTime = eventDate;
+ icalt.Zone = utcZone;
+ icalt.IsDate = eentry.AllDayEvent;
+ dt.IcalTime = icalt;
+ dt.Tzid = "UTC";
+ comp.DtStart = dt;
+
+ /// end date
+ dt = new CalComponentDateTime ();
+ icalt = new Icaltimetype ();
+ icalt.SetDateTime = DateTime.Parse (eentry.EndDate);
+ icalt.Zone = utcZone;
+ icalt.IsDate = eentry.AllDayEvent;
+ dt.IcalTime = icalt;
+ dt.Tzid = "UTC";
+ comp.DtEnd = dt;
+
+ if (eentry.EventType == 1)
+ {
+ CalRecurrence [] rrules = new CalRecurrence [1];
+ rrules [0] = CalRecurrenceFromItem (eentry);
+
+ comp.RRules = rrules;
+ }
+ comp.Commit ();
+
+ return comp;
+ }
+
+ private CalPriority GetCalPriority (Priority priority)
+ {
+ if (priority == Priority.High)
+ return CalPriority.High;
+ else if (priority == Priority.Medium)
+ return CalPriority.Normal;
+ else if (priority == Priority.Low)
+ return CalPriority.Low;
+ else
+ return CalPriority.Undefined;
+ }
+
+ private CalStatus GetCalStatus (TaskStatus status)
+ {
+ if (status == TaskStatus.Cancelled)
+ return CalStatus.Cancelled;
+ else if (status == TaskStatus.Completed)
+ return CalStatus.Completed;
+ else if (status == TaskStatus.InProcess)
+ return CalStatus.InProcess;
+ else if (status == TaskStatus.NeedsAction)
+ return CalStatus.NeedsAction;
+ else if (status == TaskStatus.NotStarted)
+ return CalStatus.None;
+ else
+ return CalStatus.None;
+ }
+
+ private Priority GetEntryPriority (CalPriority priority)
+ {
+ if (priority == CalPriority.High)
+ return Priority.High;
+ else if (priority == CalPriority.Low)
+ return Priority.Low;
+ else if (priority == CalPriority.Normal)
+ return Priority.Medium;
+ else
+ return Priority.Medium;
+ }
+
+ private TaskStatus GetEntryStatus (CalStatus status)
+ {
+ if (status == CalStatus.Cancelled)
+ return TaskStatus.Cancelled;
+ else if (status == CalStatus.Completed)
+ return TaskStatus.Completed;
+ else if (status == CalStatus.InProcess)
+ return TaskStatus.InProcess;
+ else if (status == CalStatus.NeedsAction)
+ return TaskStatus.NeedsAction;
+ else
+ return TaskStatus.NotStarted;
+ }
+
+ public CalComponent TaskEntryToComp ()
+ {
+ comp.Uid = tentry.ID;
+ comp.Summary = tentry.Title;
+
+ Console.WriteLine (tentry.LastModifiedDate);
+ DateTime mod = DateTime.Parse (tentry.LastModifiedDate);
+ comp.LastModified = mod;
+
+ Console.WriteLine (tentry.CreationDate);
+ DateTime created = DateTime.Parse (tentry.CreationDate);
+ comp.Created = created;
+
+ if (String.IsNullOrEmpty (tentry.Description) == false)
+ {
+ string [] description = new string [1];
+ description [0] = tentry.Description;
+ comp.Descriptions = description;
+ }
+
+ if (String.IsNullOrEmpty (tentry.StartDate) == false)
+ {
+ Console.WriteLine (tentry.StartDate);
+ DateTime start = DateTime.Parse (tentry.StartDate);
+
+ CalComponentDateTime dt = new CalComponentDateTime ();
+ Icaltimetype icalt = new Icaltimetype ();
+ icalt.SetDateTime = start;
+ icalt.Zone = utcZone;
+ icalt.IsDate = 1;
+ dt.IcalTime = icalt;
+ dt.Tzid = "UTC";
+ comp.DtStart = dt;
+ }
+
+ if (String.IsNullOrEmpty (tentry.DueDate) == false)
+ {
+ DateTime due = DateTime.Parse (tentry.DueDate);
+
+ CalComponentDateTime dt = new CalComponentDateTime ();
+ Icaltimetype icalt = new Icaltimetype ();
+ icalt.SetDateTime = due;
+ icalt.Zone = utcZone;
+ icalt.IsDate = 1;
+ dt.IcalTime = icalt;
+ dt.Tzid = "UTC";
+ comp.DueDate = dt;
+ }
+
+ comp.Priority = GetCalPriority (tentry.Prior);
+ comp.Status = GetCalStatus (tentry.Status);
+
+// comp.Percent = Convert.ToInt32 (tentry.PercentComplete);
+ comp.Commit ();
+
+ return comp;
+ }
+
+ public EventEntry CompToEventEntry (bool deleteInstance)
+ {
+ eentry.ID = comp.Uid;
+ eentry.EventType = 0;
+
+ if (comp.IsInstance)
+ {
+ eentry.MasterSeriesId = Convert.ToInt32 (comp.Uid);
+ eentry.RecurrenceId = comp.Rid.ToString ();
+ eentry.EventType = 4;
+ }
+
+ if (deleteInstance == true)
+ {
+ eentry.EventType = 3;
+ return eentry;
+ }
+
+ CalComponentDateTime dt = comp.DtStart;
+ Icaltimezone zone = null;
+ zone = Icaltimezone.GetBuiltinTimezoneFromTzid (dt.Tzid);
+
+ Icaltimetype icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+ eentry.StartDate = icalTime.AsDateTimeUtc.ToString ();
+
+ dt = comp.DtEnd;
+ icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+ eentry.EndDate = icalTime.AsDateTimeUtc.ToString ();
+
+ if (String.IsNullOrEmpty (comp.Summary) == false)
+ eentry.Title = comp.Summary;
+
+ string [] texts = comp.Descriptions;
+ if (texts.Length > 0)
+ {
+ eentry.Description = texts [0];
+ }
+
+ if (String.IsNullOrEmpty (comp.Location) == false)
+ eentry.Location = comp.Location;
+
+ if (comp.IsAllDay)
+ eentry.AllDayEvent = 1;
+ else
+ eentry.AllDayEvent = 0;
+
+
+ if (comp.HasRRules)
+ {
+ CalRecurrence[] rRules = comp.RRules;
+ CalRecurrence rRule = rRules [0];
+
+ SetCalRecurrenceToEntry (rRule, ref eentry);
+ eentry.EventType = 1;
+ }
+
+ return eentry;
+ }
+
+ public TaskEntry CompToTaskEntry ()
+ {
+ tentry.ID = comp.Uid;
+
+ CalComponentDateTime dt = comp.DtStart;
+ Icaltimezone zone = null;
+ zone = Icaltimezone.GetBuiltinTimezoneFromTzid (dt.Tzid);
+
+ Icaltimetype icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+ if (dt.IcalTime.Year != 0)
+ {
+ tentry.StartDate = icalTime.AsDateTimeUtc.ToString ();
+ }
+
+ dt = comp.DueDate;
+ icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+
+ if (dt.IcalTime.Year != 0)
+ {
+ tentry.DueDate = icalTime.AsDateTimeUtc.ToString ();
+ }
+
+ if (String.IsNullOrEmpty (comp.Summary) == false)
+ tentry.Title = comp.Summary;
+
+ string [] texts = comp.Descriptions;
+ if (texts.Length > 0)
+ {
+ tentry.Description = texts [0];
+ }
+
+ if (comp.Percent != -1)
+ tentry.PercentComplete = Convert.ToString (comp.Percent);
+
+ if (comp.Priority != CalPriority.Undefined)
+ {
+ tentry.Prior = GetEntryPriority (comp.Priority);
+ }
+
+ if (comp.Status != CalStatus.Undefined)
+ {
+ tentry.Status = GetEntryStatus (comp.Status);
+ }
+
+ return tentry;
+ }
+
+ public EventEntry GetEventEntryForChanges (CalComponent oldComp)
+ {
+ CalCompChanges changes = new CalCompChanges (oldComp, comp);
+
+ eentry.EventType = 0;
+
+ if (comp.IsInstance)
+ {
+ eentry.ID = comp.GetXProp ("X-SP-INSTANCE-UID");
+ eentry.MasterSeriesId = Convert.ToInt32 (comp.Uid);
+ eentry.EventType = 4;
+ } else
+ eentry.ID = comp.Uid;
+
+ if (changes.Summary)
+ {
+ if (String.IsNullOrEmpty (comp.Summary) == false)
+ eentry.Title = comp.Summary;
+ else
+ eentry.Title = "0";
+ }
+
+ if (changes.Description)
+ {
+ string [] texts = comp.Descriptions;
+ if (texts.Length > 0)
+ {
+ if (String.IsNullOrEmpty (texts [0]) == false)
+ eentry.Description = texts [0];
+ else
+ eentry.Description = "0";
+ } else
+ eentry.Description = "0";
+ }
+
+ if (changes.StartDate)
+ {
+ CalComponentDateTime dt = comp.DtStart;
+ Icaltimezone zone = null;
+ zone = Icaltimezone.GetBuiltinTimezoneFromTzid (dt.Tzid);
+
+ Icaltimetype icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+ eentry.StartDate = icalTime.AsDateTimeUtc.ToString ();
+
+ }
+
+ if (changes.EndDate)
+ {
+ CalComponentDateTime dt = comp.DtEnd;
+ Icaltimezone zone = null;
+ zone = Icaltimezone.GetBuiltinTimezoneFromTzid (dt.Tzid);
+
+ Icaltimetype icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+ eentry.EndDate = icalTime.AsDateTimeUtc.ToString ();
+ }
+
+ if (changes.AllDay)
+ {
+ if (comp.IsAllDay)
+ eentry.AllDayEvent = 1;
+ else
+ eentry.AllDayEvent = 0;
+ }
+
+ if (changes.Location)
+ {
+ if (String.IsNullOrEmpty (comp.Location) == false)
+ eentry.Location = comp.Location;
+ else
+ eentry.Location = "0";
+ }
+
+ if (changes.RRules)
+ {
+ CalRecurrence[] rRules = comp.RRules;
+ CalRecurrence rRule = rRules [0];
+
+ SetCalRecurrenceToEntry (rRule, ref eentry);
+ eentry.EventType = 1;
+ }
+
+ return eentry;
+ }
+
+ public TaskEntry GetTaskEntryForChanges (CalComponent oldComp)
+ {
+ CalCompChanges changes = new CalCompChanges (oldComp, comp);
+
+ tentry.ID = comp.Uid;
+
+ if (changes.Summary)
+ {
+ if (String.IsNullOrEmpty (comp.Summary) == false)
+ tentry.Title = comp.Summary;
+ else
+ tentry.Title = "0";
+ }
+
+ if (changes.Description)
+ {
+ string [] texts = comp.Descriptions;
+ if (texts.Length > 0)
+ {
+ if (String.IsNullOrEmpty (texts [0]) == false)
+ tentry.Description = texts [0];
+ else
+ tentry.Description = "0";
+ } else
+ tentry.Description = "0";
+ }
+
+ if (changes.StartDate)
+ {
+ CalComponentDateTime dt = comp.DtStart;
+ Icaltimezone zone = null;
+ zone = Icaltimezone.GetBuiltinTimezoneFromTzid (dt.Tzid);
+
+ Icaltimetype icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+ tentry.StartDate = icalTime.AsDateTimeUtc.ToString ();
+
+ }
+
+ if (changes.DueDate)
+ {
+ CalComponentDateTime dt = comp.DueDate;
+ Icaltimezone zone = null;
+ zone = Icaltimezone.GetBuiltinTimezoneFromTzid (dt.Tzid);
+
+ Icaltimetype icalTime = dt.IcalTime;
+ icalTime.Zone = zone;
+ tentry.DueDate = icalTime.AsDateTimeUtc.ToString ();
+ }
+
+ if (changes.Priority)
+ tentry.Prior = GetEntryPriority (comp.Priority);
+
+ if (changes.Status)
+ tentry.Status = GetEntryStatus (comp.Status);
+
+ if (changes.PercentComplete)
+ tentry.PercentComplete = Convert.ToString (comp.Percent);
+
+ return tentry;
+ }
+ }
+}
diff --git a/calendar/backends/sharepoint/Makefile.am b/calendar/backends/sharepoint/Makefile.am
index b439a60..17dfc35 100644
--- a/calendar/backends/sharepoint/Makefile.am
+++ b/calendar/backends/sharepoint/Makefile.am
@@ -6,7 +6,7 @@ ASSEMBLY = $(ASSEMBLY_NAME).dll
@BACKEND_RULE@
-CSFILES = DaemonConnection.cs BackGroundWorker.cs Sharepoint.cs SharepointCal.cs SharepointAbstractBackend.cs SharepointTask.cs
+CSFILES = DaemonConnection.cs BackGroundWorker.cs ComponentEntry.cs Sharepoint.cs SharepointCal.cs SharepointAbstractBackend.cs SharepointTask.cs
EXTRA_DIST = sharepoint-backend-config.backend.xml $(CSFILES)
diff --git a/calendar/backends/sharepoint/Sharepoint.cs b/calendar/backends/sharepoint/Sharepoint.cs
index cb7c580..b562655 100644
--- a/calendar/backends/sharepoint/Sharepoint.cs
+++ b/calendar/backends/sharepoint/Sharepoint.cs
@@ -123,10 +123,12 @@ namespace SharePoint {
}
}
+ backend = new CalBackend (raw);
if (backend == null)
- backend = new CalBackend (raw);
-
+ return BackendStatus.OtherError;
+
GC.KeepAlive (backend);
+
Evolution.Source source = backend.Source;
string user = source.GetSourceProperty ("username");
workspaceid = source.GetSourceProperty ("workspaceid");
@@ -363,7 +365,8 @@ namespace SharePoint {
{
if (defaultZone == null)
return IntPtr.Zero;
-
+
+ Console.WriteLine ("Default zone is " + defaultZone.Tzid);
return defaultZone.Handle;
}
diff --git a/calendar/backends/sharepoint/SharepointCal.cs b/calendar/backends/sharepoint/SharepointCal.cs
index 529cfc4..8f0d842 100644
--- a/calendar/backends/sharepoint/SharepointCal.cs
+++ b/calendar/backends/sharepoint/SharepointCal.cs
@@ -40,6 +40,7 @@ namespace SharePoint
foreach (CalComponent comp in comps)
{
+ Console.WriteLine (comp.GetAsString ());
if (backendSexp.MatchObject (comp, spBackend.backend))
compList.Add (comp.GetAsString ());
}
@@ -51,19 +52,24 @@ namespace SharePoint
public override BackendStatus BackendCreateObject (ref string calobj, out string uid)
{
uid = null;
+
+ EventEntry[] entries = new EventEntry [1];
+ CalComponent comp = new CalComponent (calobj);
- string[] comps = new string [1];
- comps [0] = calobj;
-
CalComponentStatus[] status = null;
- status = DaemonConnection.deskIceDaemon.CreateCalendarItems (spBackend.workspaceid, spBackend.folderid, comps);
+ ComponentEntry cEntry = new ComponentEntry (comp);
+ EventEntry entry = cEntry.CompToEventEntry (false);
+ entries [0] = entry;
+
+ status = DaemonConnection.deskIceDaemon.CreateCalendarItems (spBackend.workspaceid, spBackend.folderid, entries);
if (status [0].errorCode == 0)
{
- calobj = status [0].compStr;
+ cEntry = new ComponentEntry (status [0].entry);
+ comp = cEntry.EventEntryToComp ();
+ calobj = comp.GetAsString ();
- CalComponent comp = new CalComponent (calobj);
spBackend.cache.PutComponent (comp);
return BackendStatus.Success;
@@ -89,14 +95,17 @@ namespace SharePoint
return BackendStatus.UnsupportedMethod;
CalComponent cacheComp = spBackend.cache.GetComponent (comp.Uid, comp.RecurId);
+ ComponentEntry cEntry = new ComponentEntry (comp);
- string cacheStr = cacheComp.GetAsString ();
+ EventEntry entry = cEntry.GetEventEntryForChanges (cacheComp);
CalComponentStatus status;
try
{
status = DaemonConnection.deskIceDaemon.ModifyCalendarItem (spBackend.workspaceid,
- spBackend.folderid, calobj, cacheStr);
+ spBackend.folderid, entry);
+
+ comp.LastModified = DateTime.Parse (status.entry.LastModifiedDate);
spBackend.cache.PutComponent (comp);
}
catch (Exception ex)
@@ -107,8 +116,8 @@ namespace SharePoint
if (status.errorCode == 0)
{
- oldObject = cacheStr;
- newObject = status.compStr;
+ oldObject = cacheComp.GetAsString ();
+ newObject = comp.GetAsString ();
return BackendStatus.Success;
}
diff --git a/calendar/backends/sharepoint/SharepointTask.cs b/calendar/backends/sharepoint/SharepointTask.cs
index aa0bfeb..2e74c31 100644
--- a/calendar/backends/sharepoint/SharepointTask.cs
+++ b/calendar/backends/sharepoint/SharepointTask.cs
@@ -52,19 +52,23 @@ namespace SharePoint
public override BackendStatus BackendCreateObject (ref string calobj, out string uid)
{
uid = null;
+
+ TaskEntry[] entries = new TaskEntry [1];
+ CalComponent comp = new CalComponent (calobj);
- string[] comps = new string [1];
- comps [0] = calobj;
-
- CalComponentStatus[] status = null;
+ TaskComponentStatus[] status = null;
+ ComponentEntry cEntry = new ComponentEntry (comp);
+ TaskEntry entry = cEntry.CompToTaskEntry ();
+ entries [0] = entry;
- status = DaemonConnection.deskIceDaemon.CreateCalendarItems (spBackend.workspaceid, spBackend.folderid, comps);
+ status = DaemonConnection.deskIceDaemon.CreateTaskItems (spBackend.workspaceid, spBackend.folderid, entries);
if (status [0].errorCode == 0)
{
- calobj = status [0].compStr;
+ cEntry = new ComponentEntry (status [0].entry);
+ comp = cEntry.TaskEntryToComp ();
+ calobj = comp.GetAsString ();
- CalComponent comp = new CalComponent (calobj);
spBackend.cache.PutComponent (comp);
return BackendStatus.Success;
@@ -84,19 +88,21 @@ namespace SharePoint
oldObject = null;
newObject = null;
- return BackendStatus.UnsupportedMethod;
-
CalComponent comp = new CalComponent (calobj);
-
CalComponent cacheComp = spBackend.cache.GetComponent (comp.Uid, comp.RecurId);
- string cacheStr = cacheComp.GetAsString ();
- CalComponentStatus status;
+ ComponentEntry cEntry = new ComponentEntry (comp);
+
+ TaskEntry entry = cEntry.GetTaskEntryForChanges (cacheComp);
+ TaskComponentStatus status;
try
{
- status = DaemonConnection.deskIceDaemon.ModifyCalendarItem (spBackend.workspaceid,
- spBackend.folderid, calobj, cacheStr);
+ status = DaemonConnection.deskIceDaemon.ModifyTaskItem (spBackend.workspaceid,
+ spBackend.folderid, entry);
+
+ comp.LastModified = DateTime.Parse (status.entry.LastModifiedDate);
+ spBackend.cache.PutComponent (comp);
}
catch (Exception ex)
{
@@ -106,8 +112,8 @@ namespace SharePoint
if (status.errorCode == 0)
{
- oldObject = cacheStr;
- newObject = status.compStr;
+ oldObject = cacheComp.GetAsString ();
+ newObject = comp.GetAsString ();
return BackendStatus.Success;
}
diff --git a/calendar/backends/sharepoint/sharepoint.mdp b/calendar/backends/sharepoint/sharepoint.mdp
index 340f55d..ceb40a8 100644
--- a/calendar/backends/sharepoint/sharepoint.mdp
+++ b/calendar/backends/sharepoint/sharepoint.mdp
@@ -20,6 +20,7 @@
<File name="SharepointAbstractBackend.cs" subtype="Code" buildaction="Compile" />
<File name="SharepointCal.cs" subtype="Code" buildaction="Compile" />
<File name="SharepointTask.cs" subtype="Code" buildaction="Compile" />
+ <File name="ComponentEntry.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="evolution-sharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=c46a23b774189844" />
diff --git a/calendar/backends/sharepoint/sharepoint.userprefs b/calendar/backends/sharepoint/sharepoint.userprefs
index 7dd203a..fc3b2c8 100644
--- a/calendar/backends/sharepoint/sharepoint.userprefs
+++ b/calendar/backends/sharepoint/sharepoint.userprefs
@@ -1,17 +1,20 @@
<Properties>
- <MonoDevelop.Ide.Workbench ActiveDocument="SharepointCal.cs" ctype="Workbench">
+ <MonoDevelop.Ide.Workbench ActiveDocument="ComponentEntry.cs" ctype="Workbench">
<Files>
<File FileName="Welcome" />
- <File FileName="SharepointTask.cs" Line="87" Column="43" />
- <File FileName="BackGroundWorker.cs" Line="35" Column="32" />
- <File FileName="SharepointCal.cs" Line="101" Column="41" />
+ <File FileName="SharepointTask.cs" Line="104" Column="72" />
+ <File FileName="SharepointCal.cs" Line="43" Column="45" />
+ <File FileName="Sharepoint.cs" Line="369" Column="62" />
+ <File FileName="DaemonConnection.cs" Line="6" Column="21" />
+ <File FileName="ComponentEntry.cs" Line="145" Column="55" />
+ <File FileName="BackGroundWorker.cs" Line="131" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State expanded="True">
<Node name="sharepoint" expanded="True">
<Node name="References" expanded="True" />
- <Node name="SharepointCal.cs" selected="True" />
+ <Node name="ComponentEntry.cs" selected="True" />
</Node>
</State>
</Pad>