Re: [evolution-patches] [addressbook] Patch for Bug #269482
- From: Devashish <sdevashish novell com>
- To: patches <evolution-patches gnome org>
- Subject: Re: [evolution-patches] [addressbook] Patch for Bug #269482
- Date: Thu, 15 Dec 2005 16:47:19 +0530
Hi,
Attaching the modified patch.
It now allows to merge the conflicting contacts.
If a duplicate contact is detected the options are:
Add the contact
Don't add
Add the contact and delete the older contact
Merge the two contacts
Thanks
Devashish Sharma
On Wed, 2005-09-14 at 18:20 +0530, Devashish wrote:
> Hi
>
> The attached patch partially solves 269482 and related bugs.
> Now the duplicate contact can be deleted, merging of cards still to be
> implemented.
>
> Thanks
>
> devashish
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches gnome org
> http://mail.gnome.org/mailman/listinfo/evolution-patches
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.2016
diff -u -p -r1.2016 ChangeLog
--- addressbook/ChangeLog 10 Dec 2005 09:52:22 -0000 1.2016
+++ addressbook/ChangeLog 13 Dec 2005 06:03:47 -0000
@@ -1,3 +1,13 @@
+2005-12-12 Devashish Sharma <sdevashish novell com>
+
+ * gui/merging/eab-contact-merging.c : Added merge and replace
+ features to duplicate detected dialog. Earlier if a duplicate contact
+ was detected there were only two options either to add it or not to
+ add it. Now, the older contact can be deleted or the two contacts can
+ be merged.
+ * gui/merging/eab-contact-duplicate-detected.glade : Added the merge
+ and replace buttons to the dialog.
+
2005-12-10 Sushma Rai <rsushma novell com>
* gui/contact-editor/e-contact-editor.c (fill_in_address_textview):
Index: addressbook/gui/merging/eab-contact-duplicate-detected.glade
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/merging/eab-contact-duplicate-detected.glade,v
retrieving revision 1.5
diff -u -p -r1.5 eab-contact-duplicate-detected.glade
--- addressbook/gui/merging/eab-contact-duplicate-detected.glade 17 Aug 2005 08:47:40 -0000 1.5
+++ addressbook/gui/merging/eab-contact-duplicate-detected.glade 13 Dec 2005 05:48:17 -0000
@@ -55,6 +55,32 @@
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
</widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button5">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">_Replace</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">2</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button6">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">_Merge</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">3</property>
+ </widget>
</child>
</widget>
<packing>
Index: addressbook/gui/merging/eab-contact-merging.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/merging/eab-contact-merging.c,v
retrieving revision 1.6
diff -u -p -r1.6 eab-contact-merging.c
--- addressbook/gui/merging/eab-contact-merging.c 17 Aug 2005 09:35:22 -0000 1.6
+++ addressbook/gui/merging/eab-contact-merging.c 13 Dec 2005 05:46:03 -0000
@@ -28,6 +28,7 @@ typedef struct {
EContactMergingOpType op;
EBook *book;
EContact *contact;
+ EContact *match;
GList *avoid;
EBookIdCallback id_cb;
EBookCallback cb;
@@ -79,6 +80,8 @@ free_lookup (EContactMergingLookup *look
{
g_object_unref (lookup->book);
g_object_unref (lookup->contact);
+ if(lookup->match)
+ g_object_unref (lookup->match);
g_list_free (lookup->avoid);
g_free (lookup);
@@ -132,6 +135,83 @@ cancelit (EContactMergingLookup *lookup)
}
static void
+replaceit (EContactMergingLookup *lookup)
+{
+ e_book_async_remove_contact (lookup->book, lookup->match, NULL, lookup);
+ if (lookup->op == E_CONTACT_MERGING_ADD)
+ e_book_async_add_contact (lookup->book, lookup->contact, final_id_cb, lookup);
+ else if (lookup->op == E_CONTACT_MERGING_COMMIT)
+ e_book_async_commit_contact (lookup->book, lookup->contact, final_cb, lookup);
+
+}
+
+static void
+free_attr_list (GList *attr_list)
+{
+ 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
+mergeit(EContactMergingLookup *lookup)
+{
+ GList *old_list = e_contact_get_attributes(lookup->match, E_CONTACT_EMAIL);
+ GList *new_list = e_contact_get_attributes(lookup->contact, E_CONTACT_EMAIL);
+ EContactAddress *home_address, *work_address, *other_address;
+ EContactField contact_field;
+ const char *old_field_value, *new_field_value;
+
+ new_list = g_list_concat(old_list, new_list);
+ e_contact_set_attributes(lookup->match, E_CONTACT_EMAIL, new_list);
+
+ home_address = e_contact_get(lookup->match, E_CONTACT_ADDRESS_HOME);
+ if(!home_address) {
+ printf("home address NULL\n");
+ home_address = e_contact_get(lookup->contact, E_CONTACT_ADDRESS_HOME);
+ if(home_address)
+ e_contact_set(lookup->match, E_CONTACT_ADDRESS_HOME, home_address);
+ }
+ if(home_address)
+ e_contact_address_free(home_address);
+ work_address = e_contact_get(lookup->match, E_CONTACT_ADDRESS_WORK);
+ if(!work_address) {
+ printf("work address NULL\n");
+ work_address = e_contact_get(lookup->contact, E_CONTACT_ADDRESS_WORK);
+ if(work_address)
+ e_contact_set(lookup->match, E_CONTACT_ADDRESS_WORK, work_address);
+ }
+ if(work_address)
+ e_contact_address_free(work_address);
+ other_address = e_contact_get(lookup->match, E_CONTACT_ADDRESS_OTHER);
+ if(!other_address) {
+ printf("other address NULL\n");
+ other_address = e_contact_get(lookup->contact, E_CONTACT_ADDRESS_OTHER);
+ if(other_address)
+ e_contact_set(lookup->match, E_CONTACT_ADDRESS_OTHER, other_address);
+ }
+ if(other_address)
+ e_contact_address_free(other_address);
+
+ for(contact_field = E_CONTACT_FIRST_PHONE_ID; contact_field <= E_CONTACT_LAST_PHONE_ID; contact_field++) {
+ old_field_value = e_contact_get_const(lookup->match, contact_field);
+ new_field_value = e_contact_get_const(lookup->contact, contact_field);
+ if(old_field_value == NULL && new_field_value != NULL)
+ e_contact_set(lookup->match, contact_field, new_field_value);
+
+ }
+
+ lookup->contact = lookup->match;
+ e_book_async_remove_contact (lookup->book, lookup->match, NULL, lookup);
+ e_book_async_add_contact (lookup->book, lookup->contact, final_id_cb, lookup);
+
+ free_attr_list(new_list);
+}
+
+static void
response (GtkWidget *dialog, int response, EContactMergingLookup *lookup)
{
gtk_widget_destroy (dialog);
@@ -143,6 +223,13 @@ response (GtkWidget *dialog, int respons
case 1:
cancelit (lookup);
break;
+ case 2:
+ replaceit (lookup);
+ break;
+
+ case 3:
+ mergeit (lookup);
+ break;
case GTK_RESPONSE_DELETE_EVENT:
cancelit (lookup);
break;
@@ -161,6 +248,7 @@ match_query_callback (EContact *contact,
GtkWidget *widget;
+ lookup->match = g_object_ref (match);
if (lookup->op == E_CONTACT_MERGING_ADD)
ui = glade_xml_new (EVOLUTION_GLADEDIR "/eab-contact-duplicate-detected.glade", NULL, NULL);
else if (lookup->op == E_CONTACT_MERGING_COMMIT)
@@ -188,6 +276,10 @@ match_query_callback (EContact *contact,
G_CALLBACK (response), lookup);
gtk_widget_show_all (widget);
+
+ if(eab_contact_compare_name (lookup->match, lookup->contact) != EAB_CONTACT_MATCH_EXACT) {
+ gtk_widget_hide (glade_xml_get_widget(ui, "button6"));
+ }
}
}
@@ -204,6 +296,7 @@ eab_merging_book_add_contact (EBook
lookup->op = E_CONTACT_MERGING_ADD;
lookup->book = g_object_ref (book);
lookup->contact = g_object_ref (contact);
+ lookup->match = NULL;
lookup->id_cb = cb;
lookup->closure = closure;
lookup->avoid = NULL;
@@ -226,6 +319,7 @@ eab_merging_book_commit_contact (EBook
lookup->op = E_CONTACT_MERGING_COMMIT;
lookup->book = g_object_ref (book);
lookup->contact = g_object_ref (contact);
+ lookup->match = NULL;
lookup->cb = cb;
lookup->closure = closure;
lookup->avoid = g_list_append (NULL, contact);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]