Re: [evolution-patches] Exchange: patch for bug #257802



Hi,

I have incorporated all the changes and sending the modified patch.

Please review it.

Thanks,
Shakti


On Wed, 2005-08-10 at 12:10 +0530, Sarfraaz Ahmed wrote:
> A few comments below.
> 
> On Fri, 2005-08-05 at 20:54 +0530, shakti wrote:
> > Hi,
> > 
> 
> 
> > Index: addressbook/e-book-backend-exchange.c
> > ===================================================================
> 
> > +static void
> > +free_attr_list (GList *attr_list)
> 
> This doesnt seem necessary. You can remove this, after incorporating the
> changes below.
> 
> > +{
> > +        GList *l;
> > +
> > +        for (l = attr_list; l; l = g_list_next (l)) {
> > +                EVCardAttribute *attr = l->data;
> > +                e_vcard_attribute_free (attr);
> > +        }
> > +
> > +        g_list_free (attr_list);
> > +}
> > +
> > +static void
> > +proppatch_im (PropMapping *prop_mapping, 
> > +                  EContact *new_contact, EContact *cur_contact,
> > +                  E2kProperties *props)
> > +{
> > +       GList *new_list;
> > +
> > +       new_list = e_contact_get (new_contact, prop_mapping->field);
> > +       for (; new_list; new_list = g_list_next (new_list)) {
> 
> You could probably use a while loop instead.
> 
> > +               if (prop_mapping->field == E_CONTACT_IM_MSN) {
> > +                       e2k_properties_set_string (props, 
> > +
> > E2K_PR_OUTLOOK_CONTACT_IM_ADDR,
> > +                                                  g_strdup
> > (new_list->data));
> > +               }
> > +       }
> > +}
> > +
> > +static void
> > +populate_im (EContactField field, EContact *new_contact, void *data)
> > +{
> > +       GList *aim_list = NULL;
> > +       GList *icq_list = NULL;
> > +       GList *yahoo_list = NULL;
> > +       GList *msn_list = NULL;
> > +       GList *jabber_list = NULL;
> > +       GList *groupwise_list = NULL;
> > +       GList **im_attr_list = NULL;
> > +       EVCardAttribute *attr;
> > +
> 
> How about this logic here ...
> 
> GList *im_attr_list = NULL;
> 	if (field == E_CONTACT_IM_MSN) { 
> 		create the attribute and append it to the GList.
> 	}
> 
> e_contact_set_attributes (new_contact, field, im_attr_list);
> 
> This has much less code and also looks neat.
> 
> > +       if (field == E_CONTACT_IM_ICQ)
> > +               im_attr_list = &icq_list;
> > +       else if (field == E_CONTACT_IM_AIM)
> > +               im_attr_list = &aim_list;
> > +       else if (field == E_CONTACT_IM_MSN)
> > +               im_attr_list = &msn_list;
> > +       else if (field == E_CONTACT_IM_YAHOO)
> > +               im_attr_list = &yahoo_list;
> > +       else if (field == E_CONTACT_IM_JABBER)
> > +               im_attr_list = &jabber_list;
> > +       else
> > +               im_attr_list = &groupwise_list;
> > +
> > +       attr = e_vcard_attribute_new ("", e_contact_vcard_attribute
> > (field));
> > +       e_vcard_attribute_add_param_with_value (attr,
> > e_vcard_attribute_param_new (EVC_TYPE), "WORK");
> > +
> > +       if (field == E_CONTACT_IM_MSN)
> > +               e_vcard_attribute_add_value (attr, (const char
> > *)data);
> > +
> > +       *im_attr_list = g_list_append (*im_attr_list, attr);
> > +
> > +       e_contact_set_attributes (new_contact, field, *im_attr_list);
> > +
> > +       free_attr_list (aim_list);
> > +       free_attr_list (jabber_list);
> > +       free_attr_list (icq_list);
> > +       free_attr_list (yahoo_list);
> > +       free_attr_list (msn_list);
> > +       free_attr_list (groupwise_list);
> >  }
> >  
> >  static void
> > 
> > _______________________________________________
> > evolution-patches mailing list
> > evolution-patches lists ximian com
> > http://lists.ximian.com/mailman/listinfo/evolution-patches
> > 
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
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	11 Aug 2005 14:12:55 -0000
@@ -1,3 +1,11 @@
+2005-08-11  Shakti Sen <shprasad novell com>
+
+	* addressbook/e-book-backend-exchange.c:
+	Added new functions proppatch_im(), populate_im().
+	In brief, contact editor (exchange) supports IM field.
+
+	Fixes bug #257802.
+
 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	11 Aug 2005 14:12:55 -0000
@@ -103,6 +103,8 @@ static E2kRestriction *e_book_backend_ex
 							       E2kRestriction *base_rn);
 
 static const char *contact_name (EContact *contact);
+static void proppatch_im (PropMapping *prop_mapping, EContact *new_contact, EContact *cur_contact, E2kProperties *props);
+static void populate_im (EContactField field, EContact *new_contact, void *data);
 
 static GPtrArray *field_names_array;
 static const char **field_names;
@@ -133,6 +135,7 @@ http_status_to_pas (E2kHTTPStatus status
 #define CAL_FIELD(x,z) { E_CONTACT_##x, E2K_PR_CALENDAR_##x, z, FLAG_UNLIKEABLE, NULL }
 #define HTTPMAIL_FIELD(x,y,z) { E_CONTACT_##x, E2K_PR_HTTPMAIL_##y, z, FLAG_UNLIKEABLE | FLAG_PUT, NULL }
 #define EXCHANGE_FIELD(x,y,z,w,v) { E_CONTACT_##x, E2K_PR_EXCHANGE_##y, z, FLAG_COMPOSITE, w, v }
+#define IM_FIELD(x,z) { E_CONTACT_##x, E2K_PR_OUTLOOK_CONTACT_IM_ADDR, z, FLAG_COMPOSITE, proppatch_im, populate_im }
 
 struct PropMapping {
 	EContactField field;
@@ -200,6 +203,12 @@ prop_mappings[] = {
 	DATE_FIELD (BIRTH_DATE, "birth_date"),
 	DATE_FIELD (ANNIVERSARY, "anniversary"),
 	CAL_FIELD (FREEBUSY_URL, "fburl"),
+	IM_FIELD (IM_ICQ, "icq"),
+	IM_FIELD (IM_AIM, "aim"),
+	IM_FIELD (IM_MSN, "msn"),
+	IM_FIELD (IM_YAHOO, "yahoo"),
+	IM_FIELD (IM_JABBER, "jabber"),
+	IM_FIELD (IM_GROUPWISE, "nov"),
 
 	HTTPMAIL_FIELD (NOTE, TEXT_DESCRIPTION, "note"),
 
@@ -995,6 +1004,42 @@ proppatch_address (PropMapping *prop_map
 	e_contact_address_free (new_address);
 	if (cur_address)
 		e_contact_address_free (cur_address);
+}
+
+static void
+proppatch_im (PropMapping *prop_mapping, 
+	      EContact *new_contact, EContact *cur_contact,
+	      E2kProperties *props)
+{
+	GList *new_list;
+
+	new_list = e_contact_get (new_contact, prop_mapping->field);
+	while (new_list) {
+		if (prop_mapping->field == E_CONTACT_IM_MSN) {
+			e2k_properties_set_string (props, 
+						   E2K_PR_OUTLOOK_CONTACT_IM_ADDR,
+						   g_strdup (new_list->data));
+		}
+		new_list = g_list_next (new_list);
+	}
+}
+
+static void
+populate_im (EContactField field, EContact *new_contact, void *data)
+{
+	GList *im_attr_list = NULL;
+	EVCardAttribute *attr;
+
+	if (field == E_CONTACT_IM_MSN) {
+		attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (field));
+		e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_TYPE), "WORK");
+
+		e_vcard_attribute_add_value (attr, (const char *)data);
+
+		im_attr_list = g_list_append (im_attr_list, attr);
+	}
+
+	e_contact_set_attributes (new_contact, field, im_attr_list);
 }
 
 static void


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