File sharepoint-tasks.diff of Package evolution-mono-providers

diff --git a/calendar/backends/sharepoint/BackGroundWorker.cs b/calendar/backends/sharepoint/BackGroundWorker.cs
index b84e228..d0d2055 100644
--- a/calendar/backends/sharepoint/BackGroundWorker.cs
+++ b/calendar/backends/sharepoint/BackGroundWorker.cs
@@ -32,8 +32,12 @@ namespace SharePoint
 			get {return running;}
 		}
 
-		private void GetCalendarEvents ()
+		private void GetCalendarItems ()
 		{
+
+			if (spBackend.authenticated == false)
+				return;
+			
 			string timestamp = spBackend.cache.ServerUtcTime;
 
 			Novell.IceDesktop.IDaemon deskIceDaemon = DaemonConnection.deskIceDaemon;
@@ -74,6 +78,7 @@ namespace SharePoint
 					
 	
 					spBackend.cache.PutComponent (comp);
+					Console.WriteLine (comp.GetAsString ());
 					
 					if (cacheComp == null)
 						spBackend.backend.NotifyObjectCreated (comp.GetAsString ());
@@ -133,8 +138,7 @@ namespace SharePoint
 			Thread.Sleep (32);
 			do
 			{
-				if (spBackend.backend.Kind == IcalcomponentKind.VeventComponent)
-						GetCalendarEvents ();
+				GetCalendarItems ();
 				
 				if (shutdown == false)
 				{
diff --git a/calendar/backends/sharepoint/DaemonConnection.cs b/calendar/backends/sharepoint/DaemonConnection.cs
index 6001365..93e5c85 100644
--- a/calendar/backends/sharepoint/DaemonConnection.cs
+++ b/calendar/backends/sharepoint/DaemonConnection.cs
@@ -1,6 +1,7 @@
 using System;
 using NDesk.DBus;
 using Novell.IceDesktop;
+using EDS.Backends;
 
 namespace SharePoint
 {
@@ -10,106 +11,84 @@ namespace SharePoint
 		static ObjectPath DaemonPath = new ObjectPath (Novell.IceDesktop.ServiceName.DaemonPath);
 		static string DaemonNamespace = Novell.IceDesktop.ServiceName.DaemonNamespace;
 		static readonly string conLocker = "lockr";
-		static bool initiated = false;
+		static bool busInitiated = false;
 		static readonly string busLocker = "lockr";
-		SharePointBackend spBackend;
-
+		
 		public static Novell.IceDesktop.IDaemon deskIceDaemon = null;
 		
-		public DaemonConnection (SharePointBackend backend)
+		public DaemonConnection ()
 		{
-			spBackend = backend;
 		}
 
-		public void ConnectToDaemon ()
+		public static void ConnectToDaemon ()
 		{
 			lock (conLocker)
-			{
-					
-				if (deskIceDaemon != null)
+			{				
+				if (deskIceDaemon != null && deskIceDaemon.Ping ())
 					return;
-				
+
 				InitDBus ();
+
+				ConnectToICEcoreDaemon ();
+				
 				sessionBus =
 				Bus.Session.GetObject<org.freedesktop.DBus.IBus> (
 						"org.freedesktop.DBus",
 						new ObjectPath ("/org/freedesktop/DBus"));
-				//sessionBus.NameOwnerChanged += OnDBusNameOwnerChanged;
 			
 				// Force the daemon to start up if it's not already running
 				if (Bus.Session.NameHasOwner (DaemonNamespace) == false) {
 					Bus.Session.StartServiceByName (DaemonNamespace);
 				}
 				
-				ConnectToICEcoreDaemon ();
-				
+				sessionBus.NameOwnerChanged += OnDBusNameOwnerChanged;
 			}
 		}
 
-		void OnAuthenticated (string server, string username)
+		/// <summary>
+		/// Connect with the ICEcore Daemon and register event handlers.
+		/// </summary>
+		static void ConnectToICEcoreDaemon ()
 		{
-			this.spBackend.readOnly = false;
+			deskIceDaemon =
+				Bus.Session.GetObject<IDaemon> (DaemonNamespace, DaemonPath);
 		}
 
-		void OnDisconnected (string server, string username)
-		{
-			this.spBackend.readOnly = true;
-
-			AccountInfo aInfo = deskIceDaemon.GetDefaultAccountInfo ();
-			this.spBackend.hostUrl = aInfo.hostUrl;
-		}
-		
-		void OnDBusNameOwnerChanged (string serviceName,
+		static void OnDBusNameOwnerChanged (string serviceName,
 													string oldOwner,
 													string newOwner)
 		{
 
 			try {
-			Console.WriteLine ("O/p {0} {1}", serviceName, DaemonNamespace);
-			
-			if (serviceName == null)
-				return;
-			if (serviceName.CompareTo (DaemonNamespace) != 0)
-				return;
-			Console.WriteLine ("Navigator detected Daemon Going up/down");
-			
-			if (oldOwner != null && oldOwner.Length > 0) {
-				// The daemon just went away
-				// TODO: What should the Navigator do if the ICEcore Daemon suddenly exits?
-				Console.WriteLine ("TODO: What should the Navigator do if the ICEcore Daemon suddenly exits?");
-			} else {
-				// Connect to the new instance of the daemon
-				ConnectToICEcoreDaemon ();
-			}
+				Console.WriteLine ("O/p {0} {1}", serviceName, DaemonNamespace);
+				
+				if (serviceName == null)
+					return;
+				if (serviceName.CompareTo (DaemonNamespace) != 0)
+					return;
+				
+				if (oldOwner != null && oldOwner.Length > 0) {
+					// The daemon just went away
+					// TODO: What should the Navigator do if the ICEcore Daemon suddenly exits?
+					Console.WriteLine ("TODO: What should the Navigator do if the ICEcore Daemon suddenly exits?");
+				} else {
+					// Connect to the new instance of the daemon
+					ConnectToICEcoreDaemon ();
+				}
 			} catch {}
+
 		}
 
 		static void InitDBus ()
 		{	
 			lock (busLocker)
 			{
-				if (initiated == false)
+				if (busInitiated == false)
 				{
 					BusG.Init ();
-					Console.WriteLine ("Bus inited ");
 				}
-				initiated = true;
+				busInitiated = true;
 			}
 		}
-		
-		/// <summary>
-		/// Connect with the ICEcore Daemon and register event handlers.
-		/// </summary>
-		void ConnectToICEcoreDaemon ()
-		{
-			Console.WriteLine ("Connecting the navigator to the ICEcore Daemon");
-			// Check DBus to see if the Daemon is currently running
-			deskIceDaemon =
-				Bus.Session.GetObject<IDaemon> (DaemonNamespace, DaemonPath);
-			// Set up the daemon event handlers
-			deskIceDaemon.Authenticated += OnAuthenticated;
-			deskIceDaemon.Disconnected += OnDisconnected;
-		}
-
 	}
-}
\ No newline at end of file
+}
diff --git a/calendar/backends/sharepoint/Makefile.am b/calendar/backends/sharepoint/Makefile.am
index 1636b55..b439a60 100644
--- a/calendar/backends/sharepoint/Makefile.am
+++ b/calendar/backends/sharepoint/Makefile.am
@@ -6,7 +6,8 @@ ASSEMBLY = $(ASSEMBLY_NAME).dll
 
 @BACKEND_RULE@
 
-CSFILES =  DaemonConnection.cs BackGroundWorker.cs Sharepoint.cs SharepointCal.cs SharepointAbstractBackend.cs
+CSFILES =  DaemonConnection.cs BackGroundWorker.cs Sharepoint.cs SharepointCal.cs SharepointAbstractBackend.cs SharepointTask.cs
+
 EXTRA_DIST = sharepoint-backend-config.backend.xml $(CSFILES)
 
 ASSEMBLIES = \
diff --git a/calendar/backends/sharepoint/Sharepoint.cs b/calendar/backends/sharepoint/Sharepoint.cs
index 8adab37..259c8a2 100644
--- a/calendar/backends/sharepoint/Sharepoint.cs
+++ b/calendar/backends/sharepoint/Sharepoint.cs
@@ -18,6 +18,7 @@ namespace SharePoint {
 		static readonly string baseUri = "sharepoint://";
 		
 		#endregion
+
 		
 		#region Public members
 		
@@ -30,6 +31,7 @@ namespace SharePoint {
 		public string workspaceid;
 		public string folderid;
 		public bool readOnly;
+		public bool authenticated;
 		// This is just used for common backend operations
 		public SharePointAbstractBackend absBackend; 
 		
@@ -47,11 +49,32 @@ namespace SharePoint {
 			hostUrl = null;
 			absBackend = null;
 			readOnly = true;
+			authenticated = false;
 			Console.WriteLine ("constructor called");
 		}
 		#endregion
 
 		
+		#region Private methods
+		BackendStatus CheckForRemoteOp
+		{
+			get
+			{
+				if (mode == CalMode.Local)
+					return BackendStatus.RepositoryOffline;
+				
+				if (authenticated == false)
+					return BackendStatus.AuthenticationRequired;
+	
+				if (readOnly)
+					return BackendStatus.PermissionDenied;
+
+				return BackendStatus.Success;
+			}
+		}
+		#endregion
+
+		
 		#region Authentication
 		
 		public BackendStatus BackendOpen (IntPtr raw, bool if_exists, string username, string password)
@@ -60,64 +83,95 @@ namespace SharePoint {
 				if (loaded == true)
 					return BackendStatus.Success;
 
-				Console.WriteLine ("Opening calendar");
-				backend = new CalBackend (raw);
-				Evolution.Source source = backend.Source;
-				string user = source.GetSourceProperty ("username");
-				workspaceid = source.GetSourceProperty ("workspaceid");
-				folderid = source.GetSourceProperty ("Id");
 
-	
 				if (mode == CalMode.Remote)
 				{
 					try
 					{
-						DaemonConnection con = new DaemonConnection (this);
-						con.ConnectToDaemon ();
+						DaemonConnection.ConnectToDaemon ();
+						DaemonConnection.deskIceDaemon.Authenticated += OnAuthenticated;
+						DaemonConnection.deskIceDaemon.Disconnected += OnDisconnected;
 						
 						try 
 						{
 							DaemonConnection.deskIceDaemon.CheckAuthentication (String.Empty);
+							authenticated = true;
 							readOnly = false;
 
 							AccountInfo aInfo =  DaemonConnection.deskIceDaemon.GetDefaultAccountInfo ();
 							hostUrl = aInfo.hostUrl;
+						} catch (Exception ex) 
+						{
+							NotAuthenticatedException nax = new NotAuthenticatedException ();
+
+							if (ex.Message.Contains (nax.Message))
+								readOnly = true;
+							else
+							{
+								Console.WriteLine ("Open calendar " + ex.Message);
+								Console.WriteLine (ex.StackTrace);
+								return BackendStatus.OtherError;
+							}
 						}
-						catch (NotAuthenticatedException) {readOnly = true;}
-			
 					}
+				
 					catch (Exception ex)
 					{
-						Console.WriteLine (ex.Message);
+						Console.WriteLine ("open calendar" + ex.Message);
 						Console.WriteLine (ex.StackTrace);
 						return BackendStatus.OtherError;
 					}
 				}
 
+				if (backend == null)
+					backend = new CalBackend (raw);
+			
+				Evolution.Source source = backend.Source;
+				string user = source.GetSourceProperty ("username");
+				workspaceid = source.GetSourceProperty ("workspaceid");
+				folderid = source.GetSourceProperty ("Id");
+
 				string cacheUri = backend.Uri + source.Name;
-				cache = new CalBackendCache (cacheUri, CalSourceType.Event);
+				if (backend.Kind == IcalcomponentKind.VeventComponent)
+					cache = new CalBackendCache (cacheUri, CalSourceType.Event);
+				else
+					cache = new CalBackendCache (cacheUri, CalSourceType.Todo);
+			
 				if (cache == null)
 					return BackendStatus.OtherError;
 
 				if (backend.Kind == IcalcomponentKind.VeventComponent) {
 						absBackend = new SharePoint.SharePointCalBackend (this);
-				}
+				} else if (backend.Kind == IcalcomponentKind.VtodoComponent)
+						absBackend = new SharePoint.SharePointTaskBackend (this);
 				
 				loaded = true;
 			
-
 			return BackendStatus.Success;
 		}
-		#endregion
 
-		
-		#region Backend properties
-		
-		public BackendStatus BackendRemove ()
+		void OnDisconnected (string server, string username)
 		{
-			return BackendStatus.PermissionDenied;
+			readOnly = true;
+			authenticated = false;
+			backend.NotifyReadonly (readOnly);
+		}
+
+		void OnAuthenticated (string server, string username)
+		{
+			authenticated = true;
+			readOnly = false;
+			backend.NotifyReadonly (readOnly);
+			
+			AccountInfo aInfo = DaemonConnection.deskIceDaemon.GetDefaultAccountInfo ();
+			hostUrl = aInfo.hostUrl;
 		}
 		
+		#endregion
+
+		
+		#region Backend properties
+
 		public BackendStatus BackendIsReadonly (out bool ret)
 		{
 			ret = readOnly;
@@ -133,6 +187,11 @@ namespace SharePoint {
 		public void BackendSetMode (CalMode calMode)
 		{
 			mode = calMode;
+
+			if (mode == CalMode.Remote)
+				readOnly = false;
+			else
+				readOnly = true;
 		}
 
 		public bool BackendIsLoaded ()
@@ -159,35 +218,47 @@ namespace SharePoint {
 		
 		public BackendStatus BackendCreateObject (ref string calobj, out string uid)
 		{
-			string id = null;
+			uid = null;
+			BackendStatus status;
 
-			BackendStatus status = absBackend.BackendCreateObject (ref calobj, out id);
-			uid = id;
+			status = CheckForRemoteOp;
+
+			if (status != BackendStatus.Success)
+				return status;
+	
+			status = absBackend.BackendCreateObject (ref calobj, out uid);
 			
 			return status;
 		}
 
 		public BackendStatus BackendModifyObject (string calobj, CalObjModType mod, out string oldObject, out string newObject)
 		{
-			string old = null;
-			string obj = null;
+			oldObject = null;
+			newObject = null;
+			BackendStatus status;
 
-			BackendStatus status = absBackend.BackendModifyObject (calobj, mod, out old, out obj);
-			
-			oldObject = old;
-			newObject = obj;
+			status = CheckForRemoteOp;
+
+			if (status != BackendStatus.Success)
+				return status;
+
+			status = absBackend.BackendModifyObject (calobj, mod, out oldObject, out newObject);
 			
 			return status;
 		}
 
 		public BackendStatus BackendRemoveObject (string uid, string rid, CalObjModType mod, out string oldObject, out string calobj)
 		{
-			string old = null;
-			string obj = null;
-			
-			BackendStatus status = absBackend.BackendRemoveObject (uid, rid, mod, out old, out obj);
-			oldObject = old;
-			calobj = obj;
+			oldObject = null;
+			calobj = null;
+			BackendStatus status;
+
+			status = CheckForRemoteOp;
+
+			if (status != BackendStatus.Success)
+				return status;
+				
+			status = absBackend.BackendRemoveObject (uid, rid, mod, out oldObject, out calobj);
 			
 			return status;
 		}
@@ -242,6 +313,13 @@ namespace SharePoint {
 				Console.WriteLine (ex.StackTrace);
 			}
 		}
+
+		
+		public BackendStatus BackendRemove ()
+		{
+			return BackendStatus.PermissionDenied;
+		}
+		
 		#endregion
 
 		
diff --git a/calendar/backends/sharepoint/SharepointCal.cs b/calendar/backends/sharepoint/SharepointCal.cs
index 322492c..529cfc4 100644
--- a/calendar/backends/sharepoint/SharepointCal.cs
+++ b/calendar/backends/sharepoint/SharepointCal.cs
@@ -52,12 +52,6 @@ namespace SharePoint
 		{
 			uid = null;
 			
-			if (spBackend.readOnly)
-				return BackendStatus.PermissionDenied;
-
-			if (spBackend.mode == CalMode.Local)
-				return BackendStatus.RepositoryOffline;
-
 			string[] comps = new string [1];
 			comps [0] = calobj;
 
@@ -88,17 +82,12 @@ namespace SharePoint
 			
 			oldObject = null;
 			newObject = null;
-			
-			if (spBackend.readOnly)
-				return BackendStatus.PermissionDenied;
-
-			if (spBackend.mode == CalMode.Local)
-				return BackendStatus.RepositoryOffline;
 
 			CalComponent comp = new CalComponent (calobj);
 			
 			if (comp.HasRRules || comp.IsInstance)
 				return BackendStatus.UnsupportedMethod;
+			
 			CalComponent cacheComp = spBackend.cache.GetComponent (comp.Uid, comp.RecurId);
 
 			string cacheStr = cacheComp.GetAsString ();
@@ -108,6 +97,7 @@ namespace SharePoint
 			{
 				status = DaemonConnection.deskIceDaemon.ModifyCalendarItem (spBackend.workspaceid, 
 			                                                                        spBackend.folderid, calobj, cacheStr);
+				spBackend.cache.PutComponent (comp);
 			}
 			catch (Exception ex)
 			{
@@ -130,13 +120,6 @@ namespace SharePoint
 		{
 			oldObject = null;
 			calobj = null;
-			
-			if (spBackend.readOnly)
-				return BackendStatus.PermissionDenied;
-
-			if (spBackend.mode == CalMode.Local)
-				return BackendStatus.RepositoryOffline;
-
 
 			if (String.IsNullOrEmpty (rid) == false)
 				return BackendStatus.UnsupportedMethod;
diff --git a/calendar/backends/sharepoint/SharepointTask.cs b/calendar/backends/sharepoint/SharepointTask.cs
new file mode 100644
index 0000000..aa0bfeb
--- /dev/null
+++ b/calendar/backends/sharepoint/SharepointTask.cs
@@ -0,0 +1,158 @@
+using System;
+using Evolution;
+using Novell.IceDesktop;
+using System.Collections.Generic;
+
+namespace SharePoint 
+{
+	public class SharePointTaskBackend : SharePointAbstractBackend
+	{
+		BackendGroundWorker bgw;
+			
+		public SharePointTaskBackend (SharePointBackend backend) : base (backend)
+		{
+			bgw = new BackendGroundWorker (spBackend);
+		}
+
+		public override void BackendStartQuery (IntPtr query, string sexp)
+		{
+			
+			if (bgw.Running == false)
+						bgw.Start (60);
+
+			string [] comps = BackendGetObjectList (sexp);
+			Console.WriteLine ("Gettting tasks " + bgw.Running);
+			
+			GLib.List objects = new GLib.List (null);
+			foreach (string comp in comps)
+			{
+				objects.Append (comp);
+			}
+			
+			spBackend.backend.NotifyObjectsAdded (query, objects);
+		}
+
+		public override string[] BackendGetObjectList (string sexp)
+		{
+			CalBackendSExp backendSexp = new CalBackendSExp (sexp);
+			List<string> compList = new List<string> ();
+			
+			CalComponent[] comps = spBackend.cache.Components;
+	
+			foreach (CalComponent comp in comps)
+			{
+				if (backendSexp.MatchObject (comp, spBackend.backend))
+				    compList.Add (comp.GetAsString ());
+			}
+
+			return compList.ToArray ();
+			
+		}
+
+		public override BackendStatus BackendCreateObject (ref string calobj, out string uid)
+		{
+			uid = null;
+			
+			string[] comps = new string [1];
+			comps [0] = calobj;
+
+			CalComponentStatus[] status = null;
+			
+			status = DaemonConnection.deskIceDaemon.CreateCalendarItems (spBackend.workspaceid, spBackend.folderid, comps);
+
+			if (status [0].errorCode == 0)
+			{
+				calobj = status [0].compStr;
+				
+				CalComponent comp = new CalComponent (calobj);
+				spBackend.cache.PutComponent (comp);
+
+				return BackendStatus.Success;
+			} 
+			else
+			{
+				calobj = null;
+				uid = null;
+
+				return BackendStatus.OtherError;
+			}			
+		}
+
+		public override BackendStatus BackendModifyObject (string calobj, CalObjModType mod, out string oldObject, out string newObject)
+		{
+			
+			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;
+
+			try 
+			{
+				status = DaemonConnection.deskIceDaemon.ModifyCalendarItem (spBackend.workspaceid, 
+			                                                                        spBackend.folderid, calobj, cacheStr);
+			}
+			catch (Exception ex)
+			{
+				Console.WriteLine ("error Deleting " + ex.Message);
+				return BackendStatus.OtherError;
+			}
+			
+			if (status.errorCode == 0)
+			{
+				oldObject = cacheStr;
+				newObject = status.compStr;
+
+				return BackendStatus.Success;
+			}
+
+			return BackendStatus.OtherError;
+		}
+
+		public override BackendStatus BackendRemoveObject (string uid, string rid, CalObjModType mod, out string oldObject, out string calobj)
+		{
+			oldObject = null;
+			calobj = null;
+
+			if (String.IsNullOrEmpty (rid) == false)
+				return BackendStatus.UnsupportedMethod;
+
+			CalComponent comp = spBackend.cache.GetComponent (uid, rid);
+
+			string[] ids = new string [1];
+			string id = null;
+			if (comp.IsInstance)
+				id = comp.GetXProp ("X-SP-INSTANCE-UID");
+			else
+				id = comp.Uid;
+			
+			ids [0] = id;
+			uint [] errorCodes = null;
+
+			try 
+			{
+				errorCodes = DaemonConnection.deskIceDaemon.DeleteCalendarItems (spBackend.workspaceid, 
+			                                                                         spBackend.folderid, ids);
+			}
+			catch (Exception ex)
+			{
+				Console.WriteLine (ex.Message);
+				return BackendStatus.OtherError;
+			}
+			
+			if (errorCodes [0] == 0)
+			{
+				spBackend.cache.RemoveComponent (uid, rid);
+				oldObject = comp.GetAsString ();
+				return BackendStatus.Success;
+			} else
+				return BackendStatus.OtherError;
+		}
+	}
+}
\ No newline at end of file
diff --git a/calendar/backends/sharepoint/sharepoint-backend-config.backend.xml b/calendar/backends/sharepoint/sharepoint-backend-config.backend.xml
index 9d2be5f..ac4e397 100644
--- a/calendar/backends/sharepoint/sharepoint-backend-config.backend.xml
+++ b/calendar/backends/sharepoint/sharepoint-backend-config.backend.xml
@@ -3,5 +3,7 @@
 
 <backend type="event" location="@BACKENDDIR@/SharePoint.dll" namespace="SharePoint" classname="SharePointBackend" protocol="sharepoint">
 </backend>
+<backend type="todo" location="@BACKENDDIR@/SharePoint.dll" namespace="SharePoint" classname="SharePointBackend" protocol="sharepoint">
+</backend>
 
 </backend-list>
diff --git a/calendar/backends/sharepoint/sharepoint.mdp b/calendar/backends/sharepoint/sharepoint.mdp
new file mode 100644
index 0000000..340f55d
--- /dev/null
+++ b/calendar/backends/sharepoint/sharepoint.mdp
@@ -0,0 +1,30 @@
+<Project name="sharepoint" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+  <Configurations active="Debug">
+    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+      <Output directory="bin/Debug" assembly="sharepoint" />
+      <Build debugmode="True" target="Exe" />
+      <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+    <Configuration name="Release" ctype="DotNetProjectConfiguration">
+      <Output directory="bin/Release" assembly="sharepoint" />
+      <Build debugmode="False" target="Exe" />
+      <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+  </Configurations>
+  <Contents>
+    <File name="BackGroundWorker.cs" subtype="Code" buildaction="Compile" />
+    <File name="DaemonConnection.cs" subtype="Code" buildaction="Compile" />
+    <File name="Sharepoint.cs" subtype="Code" buildaction="Compile" />
+    <File name="SharepointAbstractBackend.cs" subtype="Code" buildaction="Compile" />
+    <File name="SharepointCal.cs" subtype="Code" buildaction="Compile" />
+    <File name="SharepointTask.cs" subtype="Code" buildaction="Compile" />
+  </Contents>
+  <References>
+    <ProjectReference type="Gac" localcopy="True" refto="evolution-sharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=c46a23b774189844" />
+    <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <ProjectReference type="Assembly" localcopy="True" refto="../../factory/interface/Backend.dll" />
+    <ProjectReference type="Assembly" localcopy="True" refto="../../../../../../../../usr/lib/dice/Novell.IceDesktop.dll" />
+  </References>
+</Project>
\ No newline at end of file
diff --git a/calendar/backends/sharepoint/sharepoint.mds b/calendar/backends/sharepoint/sharepoint.mds
new file mode 100644
index 0000000..e6e7724
--- /dev/null
+++ b/calendar/backends/sharepoint/sharepoint.mds
@@ -0,0 +1,16 @@
+<Combine name="sharepoint" fileversion="2.0">
+  <Configurations active="Debug">
+    <Configuration name="Debug" ctype="CombineConfiguration">
+      <Entry build="True" name="sharepoint" configuration="Debug" />
+    </Configuration>
+    <Configuration name="Release" ctype="CombineConfiguration">
+      <Entry build="True" name="sharepoint" configuration="Release" />
+    </Configuration>
+  </Configurations>
+  <StartMode startupentry="sharepoint" single="True">
+    <Execute type="None" entry="sharepoint" />
+  </StartMode>
+  <Entries>
+    <Entry filename="sharepoint.mdp" />
+  </Entries>
+</Combine>
\ No newline at end of file
diff --git a/calendar/backends/sharepoint/sharepoint.userprefs b/calendar/backends/sharepoint/sharepoint.userprefs
new file mode 100644
index 0000000..7dd203a
--- /dev/null
+++ b/calendar/backends/sharepoint/sharepoint.userprefs
@@ -0,0 +1,27 @@
+<Properties>
+  <MonoDevelop.Ide.Workbench ActiveDocument="SharepointCal.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" />
+    </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>
+        </State>
+      </Pad>
+      <Pad Id="ClassPad">
+        <State expanded="True" />
+      </Pad>
+    </Pads>
+  </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService>
+    <BreakpointStore />
+  </MonoDevelop.Ide.DebuggingService>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" ctype="Workspace" />
+</Properties>
\ No newline at end of file
diff --git a/calendar/backends/sharepoint/sharepoint.usertasks b/calendar/backends/sharepoint/sharepoint.usertasks
new file mode 100644
index 0000000..d887d0e
--- /dev/null
+++ b/calendar/backends/sharepoint/sharepoint.usertasks
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ArrayOfUserTask xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
\ No newline at end of file
diff --git a/calendar/factory/e-cal-backend-mono-factory.c b/calendar/factory/e-cal-backend-mono-factory.c
index 417be04..0451b41 100644
--- a/calendar/factory/e-cal-backend-mono-factory.c
+++ b/calendar/factory/e-cal-backend-mono-factory.c
@@ -294,7 +294,7 @@ eds_module_initialize (GTypeModule *module)
 			c_protocols = g_slist_prepend (c_protocols, info->protocol);
 		else if (strcmp (info->type, "journal") == 0)
 			j_protocols = g_slist_prepend (j_protocols, info->protocol);
-		else if (strcmp (info->type, "tasks") == 0)
+		else if (strcmp (info->type, "todo") == 0)
 			t_protocols = g_slist_prepend (t_protocols, info->protocol);
 		else
 			g_assert_not_reached ();
diff --git a/calendar/factory/e-cal-backend-mono.c b/calendar/factory/e-cal-backend-mono.c
index 4e249ab..e2d3786 100644
--- a/calendar/factory/e-cal-backend-mono.c
+++ b/calendar/factory/e-cal-backend-mono.c
@@ -193,7 +193,6 @@ e_cal_backend_mono_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
 	r = mono_loader_method_invoke (method, priv->this, args);
 	
 	result = *(int *) mono_object_unbox (r);
-	g_print ("Uri of backend  after is %s  %p \n", e_cal_backend_get_uri (backend), backend);	
 		
 	return result;
 }
diff --git a/calendar/factory/interface/Logger.cs b/calendar/factory/interface/Logger.cs
new file mode 100644
index 0000000..d534c64
--- /dev/null
+++ b/calendar/factory/interface/Logger.cs
@@ -0,0 +1,169 @@
+//***********************************************************************
+// *  $RCSfile$ - Logger.cs
+// *
+// *  Copyright (C) 2007 Novell, Inc.
+// *
+// *  This program is free software; you can redistribute it and/or
+// *  modify it under the terms of the GNU General Public
+// *  License as published by the Free Software Foundation; either
+// *  version 2 of the License, or (at your option) any later version.
+// *
+// *  This program is distributed in the hope that it will be useful,
+// *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+// *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// *  General Public License for more details.
+// *
+// *  You should have received a copy of the GNU General Public
+// *  License along with this program; if not, write to the Free
+// *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// *
+// **********************************************************************
+
+using System;
+using System.IO;
+
+namespace EDS.Backends 
+{
+	public enum LogLevel { Debug, Info, Warn, Error, Fatal };
+	
+	public interface ILogger
+	{
+		void Log (LogLevel lvl, string message, params object[] args);
+	}
+	
+	class NullLogger : ILogger
+	{
+		public void Log (LogLevel lvl, string msg, params object[] args)
+		{
+		}
+	}
+
+	class ConsoleLogger : ILogger
+	{
+		public void Log (LogLevel lvl, string msg, params object[] args)
+		{
+			msg = string.Format ("[{0}]: {1}", Enum.GetName (typeof (LogLevel), lvl), msg);
+			Console.WriteLine (msg, args);
+		}
+	}
+
+	class FileLogger : ILogger
+	{
+		StreamWriter log;
+		ConsoleLogger console;
+
+		public FileLogger ()
+		{
+			try
+			{
+				string logPath =
+					String.Format (
+	                    "{0}{1}{2}",
+	                    Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData),
+	                    Path.DirectorySeparatorChar.ToString (),
+	                    "evolution-data-server-mono");
+
+				if (Directory.Exists (logPath) == false) Directory.CreateDirectory (logPath);
+				Console.WriteLine (logPath);
+				
+				log = File.CreateText (Path.Combine (logPath, "evolution-data-server-mono.log"));
+				log.Flush ();
+			} 
+			catch (IOException flex)
+			{
+				// FIXME: Use temp file
+				Console.WriteLine ("failed creating log file");
+				Console.WriteLine (flex.Message);
+			}
+
+			console = new ConsoleLogger ();
+		}
+
+		~FileLogger ()
+		{
+			if (log != null)
+				log.Flush ();
+		}
+
+		public void Log (LogLevel lvl, string msg, params object[] args)
+		{
+			console.Log (lvl, msg, args);
+
+			if (log != null) {
+				msg = string.Format ("{0} [{1}]: {2}", 
+						     DateTime.Now.ToString(), 
+						     Enum.GetName (typeof (LogLevel), lvl), 
+						     msg);
+				log.WriteLine (msg, args);
+				log.Flush();
+			}
+		}
+	}
+
+	// <summary>
+	// This class provides a generic logging facility. By default all
+	// information is written to standard out and a log file, but other 
+	// loggers are pluggable.
+	// </summary>
+	public static class Logger
+	{
+		private static LogLevel logLevel = LogLevel.Debug;
+
+		static ILogger logDev = new FileLogger ();
+
+		static bool muted = false;
+
+		public static LogLevel LogLevel
+		{
+			get { return logLevel; }
+			set { logLevel = value; }
+		}
+
+		public static ILogger LogDevice
+		{
+			get { return logDev; }
+			set { logDev = value; }
+		}
+
+		public static void Debug (string msg, params object[] args)
+		{
+			Log (LogLevel.Debug, msg, args);
+		}
+
+		public static void Info (string msg, params object[] args)
+		{
+			Log (LogLevel.Info, msg, args);
+		}
+
+		public static void Warn (string msg, params object[] args)
+		{
+			Log (LogLevel.Warn, msg, args);
+		}
+
+		public static void Error (string msg, params object[] args)
+		{
+			Log (LogLevel.Error, msg, args);
+		}
+
+		public static void Fatal (string msg, params object[] args)
+		{
+			Log (LogLevel.Fatal, msg, args);
+		}
+
+		public static void Log (LogLevel lvl, string msg, params object[] args)
+		{
+			if (!muted && lvl >= logLevel)
+				logDev.Log (lvl, msg, args);
+		}
+
+		public static void Mute ()
+		{
+			muted = true;
+		}
+
+		public static void Unmute ()
+		{
+			muted = false;
+		}
+	}
+}
diff --git a/calendar/factory/interface/Makefile.am b/calendar/factory/interface/Makefile.am
index f18c373..269d7d7 100644
--- a/calendar/factory/interface/Makefile.am
+++ b/calendar/factory/interface/Makefile.am
@@ -6,7 +6,7 @@ ASSEMBLY = $(ASSEMBLY_NAME).dll
 
 CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
 
-CSFILES =  IBackend.cs 
+CSFILES =  IBackend.cs Logger.cs
 
 ASSEMBLIES = \
     	  -r:System \
diff --git a/configure.in b/configure.in
index 8096fb7..27ef914 100644
--- a/configure.in
+++ b/configure.in
@@ -48,7 +48,7 @@ dnl *************************
 dnl CFLAGS and LIBS and stuff
 dnl *************************
 
-GNOME_COMPILE_WARNINGS(maximum)
+GNOME_COMPILE_WARNINGS(yes)
 CFLAGS="$CFLAGS $WARN_CFLAGS"
 case $CFLAGS in
 *-Wall*)
diff --git a/loader/mono-loader.c b/loader/mono-loader.c
index 2d7f75a..1785ef3 100644
--- a/loader/mono-loader.c
+++ b/loader/mono-loader.c
@@ -45,10 +45,10 @@ load_xml (const char *filename, GSList **m_backends)
 	}
 
 	root = xmlDocGetRootElement (doc);
-	minfo = g_new0 (MonoBackendInfo, 1);
 
 	for (root= root->children; root; root = root->next) {
 		if (strcmp ((char *) root->name, "backend") == 0) {
+			minfo = g_new0 (MonoBackendInfo, 1);
 
 			minfo->protocol = get_xml_prop (root, "protocol");
 			minfo->type = get_xml_prop (root, "type");
openSUSE Build Service is sponsored by