evolution r35435 - branches/gnome-2-22/plugins/groupwise-account-setup



Author: abharath
Date: Tue Apr 29 07:06:31 2008
New Revision: 35435
URL: http://svn.gnome.org/viewvc/evolution?rev=35435&view=rev

Log:
Committing on behalf of Chenthill Palanisamy  <pchenthill novell com>

2008-04-29  Chenthill Palanisamy  <pchenthill novell com>

        ** Fixes #358644 (bnc) 
           Retracted groupwise appointments should disappear as
           soon as they are retracted.


Modified:
   branches/gnome-2-22/plugins/groupwise-account-setup/ChangeLog
   branches/gnome-2-22/plugins/groupwise-account-setup/camel-gw-listener.c
   branches/gnome-2-22/plugins/groupwise-account-setup/groupwise-account-setup.c
   branches/gnome-2-22/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml

Modified: branches/gnome-2-22/plugins/groupwise-account-setup/camel-gw-listener.c
==============================================================================
--- branches/gnome-2-22/plugins/groupwise-account-setup/camel-gw-listener.c	(original)
+++ branches/gnome-2-22/plugins/groupwise-account-setup/camel-gw-listener.c	Tue Apr 29 07:06:31 2008
@@ -49,6 +49,8 @@
 	char *uid;
 	char *name;
 	char *source_url;
+	gboolean auto_check;
+	guint auto_check_time;
 };
 
 typedef struct _GwAccountInfo GwAccountInfo;
@@ -168,7 +170,7 @@
 #define SELECTED_NOTES   "/apps/evolution/calendar/memos/selected_memos"
 
 static void
-add_esource (const char *conf_key, const char *group_name,  const char *source_name, CamelURL *url, const char* parent_id_name, gboolean can_create)
+add_esource (const char *conf_key, GwAccountInfo *info,  const char *source_name, CamelURL *url, const char* parent_id_name, gboolean can_create)
 {
 	ESourceList *source_list;
 	ESourceGroup *group;
@@ -181,11 +183,14 @@
 	const char * use_ssl;
 	const char *poa_address;
 	const char *offline_sync;
+	const char *group_name;
 
 	poa_address = url->host;
 	if (!poa_address || strlen (poa_address) ==0)
 		return;
 
+	group_name = info->name;
+
 	soap_port = camel_url_get_param (url, "soap_port");
 
  	if (!soap_port || strlen (soap_port) == 0)
@@ -206,6 +211,7 @@
 	if (!can_create)
 		e_source_group_set_property (group, "create_source", "no");
 
+
 	relative_uri = g_strdup_printf ("%s %s/", url->user, poa_address);
 	source = e_source_new (source_name, relative_uri);
 	e_source_set_property (source, "auth", "1");
@@ -213,6 +219,15 @@
 	e_source_set_property (source, "port", camel_url_get_param (url, "soap_port"));
 	e_source_set_property (source, "auth-domain", "Groupwise");
 	e_source_set_property (source, "use_ssl", use_ssl);
+
+	if (info->auto_check) {
+		char *str = g_strdup_printf ("%d", info->auto_check_time);
+
+		e_source_set_property (source, "refresh", str);
+		g_free (str);
+	} else 
+		e_source_set_property (source, "refresh", NULL);
+
 	e_source_set_property (source, "offline_sync", offline_sync ? "1" : "0" );
 	e_source_set_property (source, "delete", "no");
 	if (parent_id_name) {
@@ -324,7 +339,7 @@
 /* looks up for e-source with having same info as old_account_info and changes its values passed in new values */
 
 static void
-modify_esource (const char* conf_key, GwAccountInfo *old_account_info, const char* new_group_name, CamelURL *new_url)
+modify_esource (const char* conf_key, GwAccountInfo *old_account_info, EAccount *a, CamelURL *new_url)
 {
 	ESourceList *list;
         GSList *groups;
@@ -334,7 +349,8 @@
       	GConfClient* client;
 	const char *poa_address;
 	const char *new_poa_address;
-
+	const char* new_group_name = a->name;
+	
 	url = camel_url_new (old_account_info->source_url, NULL);
 	poa_address = url->host;
 	if (!poa_address || strlen (poa_address) ==0)
@@ -372,6 +388,15 @@
 					e_source_set_property (source, "port", camel_url_get_param (new_url,"soap_port"));
 					e_source_set_property (source, "use_ssl",  camel_url_get_param (url, "use_ssl"));
 					e_source_set_property (source, "offline_sync",  camel_url_get_param (url, "offline_sync") ? "1" : "0");
+				
+					if (a->source->auto_check) {
+						char *str = g_strdup_printf ("%d", a->source->auto_check_time);
+					
+						e_source_set_property (source, "refresh", str);
+						g_free (str);
+					} else 
+						e_source_set_property (source, "refresh", NULL);
+
 					e_source_list_sync (list, NULL);
 					found_group = TRUE;
 					g_free (new_relative_uri);
@@ -397,10 +422,10 @@
 	CamelURL *url;
 
 	url = camel_url_new (info->source_url, NULL);
-	add_esource ("/apps/evolution/calendar/sources", info->name, _("Calendar"), url, NULL, FALSE);
-	add_esource ("/apps/evolution/tasks/sources", info->name, _("Tasks"), url, NULL, FALSE);
-	add_esource ("/apps/evolution/memos/sources", info->name, _("Notes"), url, NULL, TRUE);
-
+	add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, NULL, FALSE);
+	add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, NULL, FALSE);
+	add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, NULL, TRUE);
+ 
 	camel_url_free (url);
 
 
@@ -541,9 +566,9 @@
 
 	camel_url_set_param (url, "color", color);
 
-	add_esource ("/apps/evolution/calendar/sources", info->name, _("Calendar"), url, parent_name, FALSE);
-	add_esource ("/apps/evolution/tasks/sources", info->name, _("Tasks"), url, parent_name, FALSE);
-	add_esource ("/apps/evolution/memos/sources", info->name, _("Notes"), url, parent_name, TRUE);
+	add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, parent_name, FALSE);
+	add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, parent_name, FALSE);
+	add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, parent_name, TRUE);
 
 	g_free (color);
 	camel_url_free (url);
@@ -793,6 +818,8 @@
 	info->uid = g_strdup (account->uid);
 	info->name = g_strdup (account->name);
 	info->source_url = g_strdup (account->source->url);
+	info->auto_check = account->source->auto_check;
+	info->auto_check_time = account->source->auto_check_time;
 	if (account->parent_uid) {
 		parent = (EAccount *)e_account_list_find (account_listener, E_ACCOUNT_FIND_UID, account->parent_uid);
 
@@ -900,9 +927,9 @@
 			account_added (account_listener, account);
 		} else if (strcmp (existing_account_info->name, account->name)) {
 
-			modify_esource ("/apps/evolution/calendar/sources", existing_account_info, account->name, new_url);
-			modify_esource ("/apps/evolution/tasks/sources", existing_account_info, account->name,  new_url);
-			modify_esource ("/apps/evolution/memos/sources", existing_account_info, account->name,  new_url);
+			modify_esource ("/apps/evolution/calendar/sources", existing_account_info, account, new_url);
+			modify_esource ("/apps/evolution/tasks/sources", existing_account_info, account,  new_url);
+			modify_esource ("/apps/evolution/memos/sources", existing_account_info, account,  new_url);
 			modify_addressbook_sources (account, existing_account_info);
 
 		}

Modified: branches/gnome-2-22/plugins/groupwise-account-setup/groupwise-account-setup.c
==============================================================================
--- branches/gnome-2-22/plugins/groupwise-account-setup/groupwise-account-setup.c	(original)
+++ branches/gnome-2-22/plugins/groupwise-account-setup/groupwise-account-setup.c	Tue Apr 29 07:06:31 2008
@@ -28,11 +28,99 @@
 #include "camel-gw-listener.h"
 #include <gtk/gtk.h>
 #include "mail/em-config.h"
+#include <gconf/gconf-client.h>
+#include "shell/es-event.h"
+#include <string.h>
+
+#define GROUPWISE_BASE_URI "groupwise://"
 
 static CamelGwListener *config_listener = NULL;
 
 int e_plugin_lib_enable (EPluginLib *ep, int enable);
 GtkWidget* org_gnome_gw_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data);
+void ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target);
+
+static gboolean
+is_groupwise_account (EAccount *account)
+{
+	if (account->source->url != NULL) {
+		return g_str_has_prefix (account->source->url, GROUPWISE_BASE_URI);
+	} else {
+		return FALSE;
+	}
+}
+
+static void
+set_esource_props (const char *path, EAccount *a, GConfClient *client, const char *name)
+{
+	ESourceList *list;
+        GSList *groups;
+	char *old_relative_uri;
+	const char *poa_address;
+	CamelURL *url = camel_url_new (a->source->url, NULL);
+	
+	old_relative_uri =  g_strdup_printf ("%s %s/", url->user, poa_address);
+        list = e_source_list_new_for_gconf (client, path);
+	groups = e_source_list_peek_groups (list);
+	poa_address = url->host;
+
+	if (!poa_address || !*poa_address)
+		return;
+
+	for ( ; groups != NULL; groups = g_slist_next (groups)) {
+		ESourceGroup *group = E_SOURCE_GROUP (groups->data);
+
+		if (strcmp (e_source_group_peek_name (group), name) == 0 &&
+		    strcmp (e_source_group_peek_base_uri (group), GROUPWISE_BASE_URI) == 0) {
+			GSList *sources = e_source_group_peek_sources (group);
+
+			for ( ; sources != NULL; sources = g_slist_next (sources)) {
+				ESource *source = E_SOURCE (sources->data);
+
+				if (a->source->auto_check) {
+					char *str = g_strdup_printf ("%d",a->source->auto_check_time);
+				
+					e_source_set_property (source, "refresh", str);
+					g_free (str);
+				} else
+					e_source_set_property (source, "refresh", NULL);
+				break;
+			}
+		}
+	}
+	e_source_list_sync (list, NULL);
+
+	g_object_unref (list);
+	g_free (old_relative_uri);
+	camel_url_free (url);
+
+}
+
+void
+ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target)
+{
+        GConfClient* client;
+	EAccountList *al;
+	EIterator *it;
+
+	client = gconf_client_get_default();
+	al = e_account_list_new (client);
+
+	for (it = e_list_get_iterator((EList *)al);
+			e_iterator_is_valid(it);
+			e_iterator_next(it)) {
+		EAccount *a;
+
+		a = (EAccount *) e_iterator_get(it);
+		if (!a->enabled || !is_groupwise_account (a))
+			continue;
+		set_esource_props ("/apps/evolution/calendar/sources", a, client, a->name);
+		set_esource_props ("/apps/evolution/tasks/sources", a, client, a->name);
+		set_esource_props ("/apps/evolution/memos/sources", a, client, a->name);
+	}
+	g_object_unref (al);
+	g_object_unref (client);
+}
 
 static void
 free_groupwise_listener ( void )

Modified: branches/gnome-2-22/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml
==============================================================================
--- branches/gnome-2-22/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml	(original)
+++ branches/gnome-2-22/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml	Tue Apr 29 07:06:31 2008
@@ -20,7 +20,15 @@
       <group target="account" id="org.gnome.evolution.mail.config.accountWizard">
 	<item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
       </group>
-    </hook>	
-    
+    </hook>
+
+    <hook class="org.gnome.evolution.shell.events:1.0">
+     <event
+	id="upgrade.done"
+	handle="ensure_mandatory_esource_properties"
+	target="upgrade"
+      />
+    </hook>    
+
   </e-plugin>
 </e-plugin-list>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]