[evolution-patches] patch to add ldap address book Esource as part of GW account setup



Hi,
Attached is the patch to add an ldap address book ESource when a
groupwise account is created. It also modifies or deletes the
corresponding ESource whenever a gw account is modified or deleted
respectively. 

Thanks,
Siva

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1962
diff -u -r1.1962 ChangeLog
--- ChangeLog	14 Jan 2004 11:55:06 -0000	1.1962
+++ ChangeLog	14 Jan 2004 16:23:56 -0000
@@ -1,3 +1,10 @@
+2004-01-14 Sivaiah Nallagatla <snallagatla novell com>
+	* providers/groupwise/camel-groupwise-provider.c: added some conf entires for LDAP address setup
+	* providers/groupwise/camel-gw-listener.c: added add_ldap_addressbook_source,
+	modify_ldap_addressbook_source, remove_ldap_addressbook_source functions for setting up 
+	LDAP address book 
+	
+	
 2004-01-14  Rodrigo Moya <rodrigo ximian com>
 
 	* providers/groupwise/camel-gw-listener.c (add_esource): set the
Index: camel-groupwise-provider.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/groupwise/camel-groupwise-provider.c,v
retrieving revision 1.4
diff -u -r1.4 camel-groupwise-provider.c
--- camel-groupwise-provider.c	13 Jan 2004 17:44:23 -0000	1.4
+++ camel-groupwise-provider.c	14 Jan 2004 16:26:00 -0000
@@ -55,23 +55,24 @@
 	  N_("Check for new messages in all folders"), "1" },
 	{ CAMEL_PROVIDER_CONF_SECTION_END },
 
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
+	  N_("Apply filters to new messages in Inbox on this server"), "0" },
+
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "offline_sync", NULL,
+	  N_("Automatically synchronize remote mail locally"), "0" },
+
 	/* extra Groupwise  configuration settings */
-	/*CAMEL_PROVIDER_CONF_SECTION_START, "ldapserver", NULL,
+	{CAMEL_PROVIDER_CONF_SECTION_START, "ldapserver", NULL,
 	  N_("Address Book") },
 
 	{ CAMEL_PROVIDER_CONF_ENTRY, "ldap_server", NULL,
 	  N_("LDAP Server Name:") },
 
-	{ CAMEL_PROVIDER_CONF_CHECKSPIN, "ldap_download_limit", NULL,
-	  N_("LDAP Download limit: %s"), "y:1:500:10000" },
-
-	  { CAMEL_PROVIDER_CONF_SECTION_END }, */
-
-	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
-	  N_("Apply filters to new messages in Inbox on this server"), "0" },
+	{ CAMEL_PROVIDER_CONF_ENTRY, "search_base", NULL, 
+	  N_("Search base:") },
+	
+	 { CAMEL_PROVIDER_CONF_SECTION_END }, 
 
-	{ CAMEL_PROVIDER_CONF_CHECKBOX, "offline_sync", NULL,
-	  N_("Automatically synchronize remote mail locally"), "0" },
 
 	{ CAMEL_PROVIDER_CONF_END }
 };
@@ -132,11 +133,11 @@
 
 	if (!config_listener)	{
 
-		config_listener = groupwise_config_listener_new  (gconf_client_get_default ());	
+		config_listener = camel_gw_listener_new ();	
 		g_atexit ( free_groupwise_listener );
 	}
 	
-	g_object_unref (temp_session);
+	camel_object_unref (temp_session);
 
 }
 
Index: camel-gw-listener.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/groupwise/camel-gw-listener.c,v
retrieving revision 1.2
diff -u -r1.2 camel-gw-listener.c
--- camel-gw-listener.c	14 Jan 2004 11:55:24 -0000	1.2
+++ camel-gw-listener.c	14 Jan 2004 16:26:19 -0000
@@ -51,6 +51,8 @@
 #define GROUPWISE_URI_PREFIX   "groupwise://" 
 #define GROUPWISE_PREFIX_LENGTH 12
 
+#define LDAP_URI_PREFIX "ldap://";
+
 #define PARENT_TYPE G_TYPE_OBJECT
 
 static GObjectClass *parent_class = NULL;
@@ -331,6 +333,143 @@
 	g_free (relative_uri);
 
 }
+static void 
+add_ldap_addressbook_source (EAccount *account)
+{
+	CamelURL *url;
+	const char *ldap_server_name;
+	const char *search_scope;
+	ESourceList *list;
+        ESourceGroup *group;
+        ESource *source;
+        GSList *groups;
+       	gboolean found_group;
+	char * relative_uri;
+
+	url = camel_url_new (account->source->url, NULL);
+
+	if (url == NULL) {
+		return;
+	}
+	
+	ldap_server_name = camel_url_get_param (url, "ldap_server");
+	search_scope = camel_url_get_param (url, "search_base");
+
+	if (ldap_server_name == NULL) {
+	
+		return;
+	}
+
+	list = e_source_list_new_for_gconf (gconf_client_get_default (), "/apps/evolution/addressbook/sources" );
+	groups = e_source_list_peek_groups (list); 
+
+	relative_uri = g_strdup_printf ("%s:%s/%s%s%s", ldap_server_name, "389",
+                                      search_scope, "??", "sub");
+		
+	found_group = FALSE;
+
+	for ( ; groups != NULL &&  !found_group; groups = g_slist_next (groups)) {
+
+		group = E_SOURCE_GROUP (groups->data);
+		if ( strcmp ( e_source_group_peek_base_uri (group), LDAP_URI_PREFIX) == 0) {
+			source = e_source_new (account->name, relative_uri);
+			e_source_set_property ( source, "limit", "100");
+			e_source_set_property ( source, "ssl", "never");
+			e_source_set_property (source, "auth", "none");
+			e_source_group_add_source (group, source, -1);
+			e_source_list_sync (list, NULL);
+			found_group = TRUE;
+		}
+	}
+
+	g_free (relative_uri);
+	g_object_unref (list);
+	camel_url_free (url);
+	
+}
+
+static void 
+modify_ldap_addressbook_source ( EAccount *account)
+{
+	CamelURL *url;
+	const char *ldap_server_name;
+	const char *search_scope;
+	ESourceList *list;
+        ESourceGroup *group;
+        ESource *source;
+        GSList *groups;
+       	gboolean found_group;
+	char * relative_uri;
+
+	url = camel_url_new (account->source->url, NULL);
+
+	if (url == NULL) {
+		return;
+	}
+	
+	ldap_server_name = camel_url_get_param (url, "ldap_server");
+
+	if (ldap_server_name == NULL) {
+		return;
+	}
+		
+	search_scope = camel_url_get_param (url, "search_base");
+
+	list = e_source_list_new_for_gconf (gconf_client_get_default (), "/apps/evolution/addressbook/sources" );
+	groups = e_source_list_peek_groups (list); 
+
+	relative_uri = g_strdup_printf ("%s:%s/%s%s%s", ldap_server_name, "389",
+                                      search_scope, "??", "sub");
+		
+	found_group = FALSE;
+
+	for ( ; groups != NULL &&  !found_group; groups = g_slist_next (groups)) {
+
+		group = E_SOURCE_GROUP (groups->data);
+		if ( strcmp ( e_source_group_peek_base_uri (group), LDAP_URI_PREFIX) == 0) {
+			source = e_source_group_peek_source_by_name (group, account->name);
+			e_source_set_relative_uri (source, relative_uri);
+			e_source_list_sync (list, NULL);
+			found_group = TRUE;
+		}
+	}
+
+	g_free (relative_uri);
+	g_object_unref (list);
+	camel_url_free (url);
+
+}
+static void 
+remove_ldap_addressbook_source ( EAccount *account )
+{
+	ESourceList *list;
+       ESourceGroup *group;
+       ESource *source;
+       GSList *groups;
+       gboolean found_group;
+
+	list = e_source_list_new_for_gconf (gconf_client_get_default (), "/apps/evolution/addressbook/sources" );
+	groups = e_source_list_peek_groups (list); 
+
+		found_group = FALSE;
+
+	for ( ; groups != NULL &&  !found_group; groups = g_slist_next (groups)) {
+
+		group = E_SOURCE_GROUP (groups->data);
+		if ( strcmp ( e_source_group_peek_base_uri (group), LDAP_URI_PREFIX) == 0) {
+
+			source = e_source_group_peek_source_by_name (group, account->name);
+			e_source_group_remove_source (group, source);
+			e_source_list_sync (list, NULL);
+			found_group = TRUE;
+						
+		}
+	}
+	g_object_unref (list);
+	
+
+}
+
 
 static void 
 account_added (EAccountList *account_listener, EAccount *account)
@@ -347,7 +486,7 @@
 	info->source_url = g_strdup (account->source->url);
 	
 	add_calendar_tasks_sources (info);
-	
+	add_ldap_addressbook_source (account);
 }
 
 
@@ -388,6 +527,7 @@
 			existing_account_info->name = g_strdup (account->name);
 			existing_account_info->source_url = g_strdup (account->source->url);
 			camel_url_free (url);
+			modify_ldap_addressbook_source (account);
 		}
 		
 	}
@@ -409,6 +549,7 @@
 	}
 
 	remove_calendar_tasks_sources (info);
+	remove_ldap_addressbook_source (account);
 
 }
 


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