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



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
> 



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