File sp-tasks-setup.diff of Package evolution

diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index c97f61c..16fa928 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -1413,6 +1413,12 @@ ensure_dates_are_in_default_zone (icalcomponent *icalcomp)
 		dt = icaltime_convert_to_zone (dt, zone);
 		icalcomponent_set_dtend (icalcomp, dt);
 	}
+	
+	dt = icalcomponent_get_due (icalcomp);
+	if (dt.is_utc) {
+		dt = icaltime_convert_to_zone (dt, zone);
+		icalcomponent_set_due (icalcomp, dt);
+	}
 }
 
 static void
diff --git a/plugins/sharepoint-account-setup/SharepointAccount.cs b/plugins/sharepoint-account-setup/SharepointAccount.cs
index 5009e98..61959ac 100644
--- a/plugins/sharepoint-account-setup/SharepointAccount.cs
+++ b/plugins/sharepoint-account-setup/SharepointAccount.cs
@@ -38,10 +38,10 @@ namespace Sharepoint
 					initialized = true;
 				}
 
+				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) 
@@ -49,7 +49,7 @@ namespace Sharepoint
 					Bus.Session.StartServiceByName (DaemonNamespace);
 				}
 
-				ConnectToICEcoreDaemon ();
+				sessionBus.NameOwnerChanged += OnDBusNameOwnerChanged;
 				try { deskIceDaemon.CheckAuthentication (String.Empty); }	
 				catch (NotAuthenticatedException) 
 				{ return; }
@@ -70,7 +70,7 @@ namespace Sharepoint
 		public void DeleteAccount ()
 		{
 			// we remove all share calendars. We currently support creating only one sharepoint account
-			SharepointSource spSource = new SharepointSource (CalSourceType.Event, null, null);
+			SharepointSource spSource = new SharepointSource (null, null);
 			spSource.DeleteSources ();
 			spSource.Sync ();
 		}
@@ -89,7 +89,7 @@ namespace Sharepoint
 		{
 			Console.WriteLine ("Getting folders ");
 			AccountInfo accountInfo = deskIceDaemon.GetDefaultAccountInfo ();
-			SharepointSource spSource = new SharepointSource (CalSourceType.Event, accountInfo.username,
+			SharepointSource spSource = new SharepointSource (accountInfo.username,
 			                                                  accountInfo.hostUrl);
 			
 			if (spSource.AccountExists) {
@@ -100,20 +100,17 @@ namespace Sharepoint
 			FileInfo [] workspaces = deskIceDaemon.EnumerateWorkspaces ();
 			foreach (FileInfo workspace in workspaces) 
 			{
-				FileInfo[] folders = null;
+				Folder[] folders = null;
 
-				if (spSource.srcType == CalSourceType.Event)
-					 folders = deskIceDaemon.GetCalendarFolders (string.Empty, workspace.Id);
-				// else get task folders
+				folders = deskIceDaemon.GetCalendarFolders (string.Empty, workspace.Id);
 					
-
 				if (folders.Length == 0)
 					continue;
 
 				spSource.CreateSources (workspace, folders);
 			}
+
 			spSource.Sync ();
-			Console.WriteLine ("******* Got folders ");
 			backgroundThread = null;
 			RemoveHandlers ();
 		}
diff --git a/plugins/sharepoint-account-setup/SharepointSource.cs b/plugins/sharepoint-account-setup/SharepointSource.cs
index c61fcf0..e9dad79 100644
--- a/plugins/sharepoint-account-setup/SharepointSource.cs
+++ b/plugins/sharepoint-account-setup/SharepointSource.cs
@@ -16,33 +16,36 @@ namespace Sharepoint
 	
 	public class SharepointSource
 	{
-		public CalSourceType srcType;
 		readonly string calPath = "/apps/evolution/calendar/sources";
 		readonly string taskPath = "/apps/evolution/tasks/sources";
 		static Client client;
-		SourceList srcList;
+		SourceList CalsrcList;
+		SourceList TasksrcList;
 		readonly string baseUri = "sharepoint://";
 		string username;
 		string hostUrl;
 		
-		public SharepointSource(CalSourceType type, string userName, string hosturl)
+		public SharepointSource(string userName, string hosturl)
 		{
-			srcType = type;
 			client = new Client ();
 			username = userName;
 			hostUrl = hosturl;
 			
-			if (type == CalSourceType.Event)
-				srcList = new SourceList (calPath);
-			else
-				srcList = new SourceList (taskPath);
+			CalsrcList = new SourceList (calPath);
+			TasksrcList = new SourceList (taskPath);
 		}
 
 		public bool AccountExists
 		{
 			get
 			{
-				foreach (SourceGroup group in srcList.Groups)
+				foreach (SourceGroup group in CalsrcList.Groups)
+				{
+					if (group.BaseUri == baseUri)
+						return true;
+				}
+
+				foreach (SourceGroup group in TasksrcList.Groups)
 				{
 					if (group.BaseUri == baseUri)
 						return true;
@@ -52,45 +55,85 @@ namespace Sharepoint
 			}
 		}
 
-		public void CreateSources (FileInfo workspace, FileInfo [] folders)
+		public void CreateSources (FileInfo workspace, Folder [] folders)
 		{
-			SourceGroup group = new SourceGroup (workspace.DisplayName, baseUri);
+			SourceGroup calGroup = new SourceGroup (workspace.DisplayName, baseUri);
+			SourceGroup taskGroup = new SourceGroup (workspace.DisplayName, baseUri);
+			bool addCalGroup = false;
+			bool addTaskGroup = false;
 
-			foreach (FileInfo folder in folders)
+			foreach (Folder folder in folders)
 			{
-				Console.WriteLine (workspace.DisplayName + " folder " + folder.DisplayName);
-				string relativeUri = hostUrl + ":" + folder.Id;
-				Source source= new Source (folder.DisplayName, relativeUri);
+				Console.WriteLine (workspace.DisplayName + " folder " + folder.Title + " " + folder.Type);
+				string relativeUri = hostUrl + ":" + folder.ID;
+				Source source= new Source (folder.Title, relativeUri);
 				source.SetProperty ("username", username);
 				source.SetProperty ("workspaceid", workspace.Id);
-				source.SetProperty ("Id", folder.Id);
+				source.SetProperty ("Id", folder.ID);
 				source.SetProperty ("Auth","True");
-				group.AddSource (source, -1);
+				source.SetProperty ("delete","no");
+				if (folder.Type == FolderType.Task) 
+				{
+					taskGroup.AddSource (source, -1);
+					addTaskGroup = true;
+				} else if (folder.Type == FolderType.Calendar)
+				{
+					calGroup.AddSource (source, -1);
+					addCalGroup = true;
+				}
+			}
+		
+			
+			if (addCalGroup)
+			{
+				calGroup.SetProperty ("username", username);
+				CalsrcList.AddGroup (calGroup, -1);
+			}
+			
+			if (addTaskGroup)
+			{
+				taskGroup.SetProperty ("username", username);
+				TasksrcList.AddGroup (taskGroup, -1);
 			}
-			group.SetProperty ("username", username);
-			srcList.AddGroup (group, -1);
 		}
 
 		public void Sync ()
 		{
-			srcList.Sync ();
+			CalsrcList.Sync ();
+			TasksrcList.Sync ();
 		}
 
 		public void DeleteSources ()
 		{
-			List<SourceGroup> groupsToRemove = new List<SourceGroup> ();
-			foreach (SourceGroup group in srcList.Groups)
+			List<SourceGroup> calGroupsToRemove = new List<SourceGroup> ();
+			foreach (SourceGroup group in CalsrcList.Groups)
+			{
+				if (group.BaseUri.StartsWith (baseUri))
+				{
+					/// Currently we remove all sharepoint calendars
+					calGroupsToRemove.Add (group);
+				}
+			}
+
+			foreach (SourceGroup group in calGroupsToRemove)
+			{
+				CalsrcList.RemoveGroup (group);
+			}
+
+			List<SourceGroup> TaskGroupsToRemove = new List<SourceGroup> ();
+
+			foreach (SourceGroup group in TasksrcList.Groups)
 			{
 				if (group.BaseUri.StartsWith (baseUri))
 				{
 					/// Currently we remove all sharepoint calendars
-					groupsToRemove.Add (group);
+					TaskGroupsToRemove.Add (group);
 				}
 			}
 
-			foreach (SourceGroup group in groupsToRemove)
+			foreach (SourceGroup group in TaskGroupsToRemove)
 			{
-				srcList.RemoveGroup (group);
+				TasksrcList.RemoveGroup (group);
 			}
 		}
 	}
openSUSE Build Service is sponsored by