[evolution-patches] Exchange: patch for bug #221030



Hi,

I am attaching a patch for bug #221030 (support for categories in
exchange).

Please review the patch.

Thanks,
Shakti

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.369
diff -u -p -r1.369 ChangeLog
--- ChangeLog	9 Aug 2005 08:15:40 -0000	1.369
+++ ChangeLog	9 Aug 2005 12:33:46 -0000
@@ -1,3 +1,10 @@
+2005-08-09  Shakti Sen <shprasad novell com>
+
+	* addressbook/e-book-backend-exchange.c (proppatch_categories)
+	(populate_categories): Added support for categories.
+
+	Fixes bug #221030.
+
 2005-08-08  Sarfraaz Ahmed <asarfraaz novell com>
 
 	* configure.in : Bumped the version to 2.3.7
Index: addressbook/e-book-backend-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/addressbook/e-book-backend-exchange.c,v
retrieving revision 1.32
diff -u -p -r1.32 e-book-backend-exchange.c
--- addressbook/e-book-backend-exchange.c	25 Jul 2005 11:03:16 -0000	1.32
+++ addressbook/e-book-backend-exchange.c	9 Aug 2005 12:33:46 -0000
@@ -95,10 +95,8 @@ static void proppatch_email(PropMapping 
 static void proppatch_date(PropMapping *prop_mapping, EContact *new_contact, EContact *cur_contact, E2kProperties *props);
 static void populate_address(EContactField field, EContact *new_contact, void *data);
 static void populate_date(EContactField field, EContact *new_contact, void *data);
-#ifdef ENABLE_CATEGORIES
-static void proppatch_categories(PropMapping *prop_mapping, EContact *new_contact, EContact *cur_contact, E2kProperties *props);
-static void populate_categories(EContactField field, EContact *new_contact, void *data);
-#endif
+static void proppatch_categories (PropMapping *prop_mapping, EContact *new_contact, EContact *cur_contact, E2kProperties *props);
+static void populate_categories (EContactField field, EContact *new_contact, void *data);
 static E2kRestriction *e_book_backend_exchange_build_restriction (const char *sexp,
 							       E2kRestriction *base_rn);
 
@@ -203,10 +201,7 @@ prop_mappings[] = {
 
 	HTTPMAIL_FIELD (NOTE, TEXT_DESCRIPTION, "note"),
 
-#ifdef ENABLE_CATEGORIES
-	/* this doesn't work at the moment */
 	EXCHANGE_FIELD (CATEGORIES, KEYWORDS, "categories", proppatch_categories, populate_categories)
-#endif
 };
 static int num_prop_mappings = sizeof(prop_mappings) / sizeof (prop_mappings[0]);
 
@@ -748,82 +743,40 @@ proppatch_email (PropMapping *prop_mappi
 		e2k_properties_remove (props, E2K_PR_MAPI_EMAIL_ADDRESS_LIST);
 }
 
-#ifdef ENABLE_CATEGORIES
 static void
 proppatch_categories (PropMapping *prop_mapping,
 		      EContact *new_contact, EContact *cur_contact,
 		      E2kProperties *props)
 {
-	gboolean changed;
-	char *new_categories, *cur_categories = NULL;
-	EList *categories;
-	EIterator *iter;
+	GList *new_categories_list = NULL;
+	GList *l = NULL;
 	GPtrArray *array = NULL;
 
-	new_categories = e_contact_get (new_contact, field);
-	if (cur_contact)
-		cur_categories = e_contact_get (cur_contact, field);
-
-	changed = value_changed (cur_categories, new_categories);
-	g_free (new_categories);
-	g_free (cur_categories);
-
-	if (!changed)
-		return;
-
-
-#ifdef DEBUG
-	printf ("CATEGORIES = %s\n", new_categories);
-#endif
+	new_categories_list = e_contact_get (new_contact, E_CONTACT_CATEGORY_LIST);
+	array = g_ptr_array_new ();
 
-	g_object_get ((new_contact->card),
-			"category_list", &categories,
-			NULL);
-
-	iter = e_list_get_iterator (categories);
-	while (e_iterator_is_valid (iter)) {
-		const char *category = e_iterator_get (iter);
-
-		if (!array)
-			array = g_ptr_array_new ();
-		g_ptr_array_add (array, g_strdup (category));
-		e_iterator_next (iter);
+	for (l = new_categories_list; l; l = g_list_next (l)) {
+		g_ptr_array_add (array, g_strdup (l->data));
 	}
-	g_object_unref (iter);
 
 	e2k_properties_set_string_array (props, prop_mapping->prop_name, array);
 }
 
 static void
-populate_categories(EContactField field, EContact *new_contact, void *data)
+populate_categories (EContactField field, EContact *new_contact, void *data)
 {
-	GSList *list = data;
-	GSList *l;
-	EList *categories;
-
-	categories = e_list_new ((EListCopyFunc) g_strdup, 
-				 (EListFreeFunc) g_free,
-				 NULL);
+	GList *list = NULL;
+	GPtrArray *lst = data;
+	gint i;
 
-	for (l = list; l; l = l->next) {
-		e_list_append (categories, l->data);
+	for (i = 0; i < lst->len; i++) {
+		list = g_list_append (list, (char *)lst->pdata[i]);
 	}
+	
 
-	g_object_set ((new_contact->card),
-			"category_list", categories,
-			NULL);
-
-#ifdef DEBUG 
-	{
-		char *category_text = e_contact_get (new_contact, E_CONTACT_CATEGORIES);
-		printf ("populated categories = %s\n", category_text);
-		g_free (category_text);
-	}
-#endif
+	e_contact_set (new_contact, E_CONTACT_CATEGORY_LIST, list);
 
-	g_object_unref (categories);
 }
-#endif
 
 static void
 proppatch_date (PropMapping *prop_mapping,


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