From cf9b3231c7afdd953f9d3f1fb9552a12be82c73c11c174b891f0e0e79737e6b5 Mon Sep 17 00:00:00 2001
From: OBS User unknown <null@suse.de>
Date: Fri, 21 Nov 2008 14:16:34 +0000
Subject: [PATCH] OBS-URL:
 https://build.opensuse.org/package/show/openSUSE:Factory/evolution?expand=0&rev=53

---
 evolution.changes   |   6 ++
 evolution.spec      |   8 +-
 sp-tasks-setup.diff | 236 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+), 1 deletion(-)
 create mode 100644 sp-tasks-setup.diff

diff --git a/evolution.changes b/evolution.changes
index 7e056e5..3289d09 100644
--- a/evolution.changes
+++ b/evolution.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Fri Nov 21 12:55:16 CET 2008 - pchenthill@suse.de
+
+- sp-tasks-setup.diff: Adds support for sharepoint tasks.
+  FATE id: 304465
+
 -------------------------------------------------------------------
 Thu Nov 20 10:40:30 CET 2008 - abharath@suse.de
 
diff --git a/evolution.spec b/evolution.spec
index 909ea5d..d66371d 100644
--- a/evolution.spec
+++ b/evolution.spec
@@ -60,7 +60,7 @@ Group:          Productivity/Networking/Email/Clients
 # This should be updated upon major version changes; it should match BASE_VERSION as defined in configure.in.
 %define evolution_base_version 2.24
 Version:        2.24.1.1
-Release:        2
+Release:        3
 Summary:        The Integrated GNOME Mail, Calendar, and Address Book Suite
 Source0:        %{name}-%{version}.tar.bz2
 Source1:        summerdance-about2.png
@@ -116,6 +116,8 @@ Patch33:        bnc-446390-corrupted-vfolders.patch
 Patch34:        bnc-446286-message-tracking-status.patch
 # PATCH-FIX-UPSTREAM bnc-210959-evo-accept-ics.patch bnc210959 pchenthill@novell.com -- Patch yet to be pushed upstream.
 Patch35:        bnc-210959-evo-accept-ics.patch
+# PATCH-FIX-UPSTREAM sp-tasks-setup.diff pchenthill@suse.de -- Patch needs to upstreamed. 
+Patch36:        sp-tasks-setup.diff
 # PATCH-FIX-UPSTREAM evo-core-mapi-changes.diff msuman@suse.de -- This patch contains changes in the core code base for the MAPI provider.
 Patch100:       evo-core-mapi-changes.diff
 Url:            http://gnome.org/projects/evolution/
@@ -373,6 +375,7 @@ Authors:
 %patch33
 %patch34
 %patch35
+%patch36 -p1
 %patch100 -p1
 
 %build
@@ -487,6 +490,9 @@ fi
 %{_libdir}/evolution/*/conduits
 
 %changelog
+* Fri Nov 21 2008 pchenthill@suse.de
+- sp-tasks-setup.diff: Adds support for sharepoint tasks.
+  FATE id: 304465
 * Thu Nov 20 2008 abharath@suse.de
 - Patches added
   + bgo#556224 - bgo-556224-search-events-offline.patch - Search
diff --git a/sp-tasks-setup.diff b/sp-tasks-setup.diff
new file mode 100644
index 0000000..5dc6a5b
--- /dev/null
+++ b/sp-tasks-setup.diff
@@ -0,0 +1,236 @@
+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);
+ 			}
+ 		}
+ 	}