[evolution-patches] [addressbook] bbdb plugin (syncing to an addressbook other than the one used for automatic contacts)



Hi,

Added provision for having the gaimbuddies synced to a separate
addressbook. Earlier it used the same addressbook as used for
Automatic Contacts.

Thanks
Devashish Sharma
Index: plugins/bbdb/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/bbdb/ChangeLog,v
retrieving revision 1.18
diff -u -p -r1.18 ChangeLog
--- plugins/bbdb/ChangeLog	28 Sep 2005 08:54:35 -0000	1.18
+++ plugins/bbdb/ChangeLog	15 Dec 2005 08:58:02 -0000
@@ -1,3 +1,11 @@
+2005-12-15  Devashish Sharma <sdevashish novell com>
+
+	* bbdb.c :
+	* gaimbuddies.c : 
+	Added provision for having the gaimbuddies synced to a separate
+	addressbook. Earlier it used the same addressbook as used for
+	Automatic Contacts.
+
 2005-09-13  Sushma Rai  <rsushma novell com>
 
 	* bbdb.c (bbdb_do_it): If the contact has only e-mail id and not name,
Index: plugins/bbdb/bbdb.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/bbdb/bbdb.c,v
retrieving revision 1.10
diff -u -p -r1.10 bbdb.c
--- plugins/bbdb/bbdb.c	28 Sep 2005 08:54:35 -0000	1.10
+++ plugins/bbdb/bbdb.c	15 Dec 2005 08:58:02 -0000
@@ -61,6 +61,7 @@ struct bbdb_stuff {
 	ESourceList *source_list;
 
 	GtkWidget *option_menu;
+	GtkWidget *gaim_option_menu;
 	GtkWidget *check;
 	GtkWidget *check_gaim;
 };
@@ -71,7 +72,7 @@ static void bbdb_do_it (EBook *book, con
 static void add_email_to_contact (EContact *contact, const char *email);
 static void enable_toggled_cb (GtkWidget *widget, gpointer data);
 static void source_changed_cb (GtkWidget *widget, ESource *source, gpointer data);
-static GtkWidget *create_addressbook_option_menu (struct bbdb_stuff *stuff);
+static GtkWidget *create_addressbook_option_menu (struct bbdb_stuff *stuff, int type);
 static void cleanup_cb (GObject *o, gpointer data);
 
 int
@@ -110,7 +111,7 @@ bbdb_handle_reply (EPlugin *ep, EMEventT
 	int         i;
 
 	/* Open the addressbook */
-	book = bbdb_open_addressbook ();
+	book = bbdb_open_addressbook (AUTOMATIC_CONTACTS_ADDRESSBOOK);
 	if (book == NULL)
 		return;
 
@@ -246,7 +247,7 @@ bbdb_do_it (EBook *book, const char *nam
 }
 
 EBook *
-bbdb_open_addressbook (void)
+bbdb_open_addressbook (int type)
 {
 	GConfClient *gconf;
 	char        *uri;
@@ -267,7 +268,10 @@ bbdb_open_addressbook (void)
 	}
 
 	/* Open the appropriate addresbook. */
-	uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
+	if (type == GAIM_ADDRESSBOOK)
+		uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, NULL);
+	else
+		uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
 	g_object_unref (G_OBJECT (gconf));
 	if (uri == NULL)
 		book = e_book_new_system_addressbook (&error);
@@ -341,6 +345,8 @@ enable_gaim_toggled_cb (GtkWidget *widge
 
 	/* Save the new setting to gconf */
 	gconf_client_set_bool (stuff->target->gconf, GCONF_KEY_ENABLE_GAIM, active, NULL);
+	
+	gtk_widget_set_sensitive (stuff->gaim_option_menu, active);
 }
 
 static void
@@ -357,8 +363,15 @@ source_changed_cb (GtkWidget *widget, ES
 	gconf_client_set_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK, e_source_get_uri (source), NULL);
 }
 
+static void
+gaim_source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
+{
+	struct bbdb_stuff *stuff = (struct bbdb_stuff *) data;
+	gconf_client_set_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, e_source_get_uri (source), NULL);
+}
+
 static GtkWidget *
-create_addressbook_option_menu (struct bbdb_stuff *stuff)
+create_addressbook_option_menu (struct bbdb_stuff *stuff, int type)
 {
 	GtkWidget   *menu;
 	ESourceList *source_list;
@@ -370,7 +383,10 @@ create_addressbook_option_menu (struct b
 	source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/addressbook/sources");
 	menu = e_source_option_menu_new (source_list);
 
-	selected_source_uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
+	if (type == GAIM_ADDRESSBOOK)
+		selected_source_uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, NULL);
+	else
+		selected_source_uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
 	if (selected_source_uri != NULL) {
 		selected_source = e_source_new_with_absolute_uri ("", selected_source_uri);
 		e_source_option_menu_select (E_SOURCE_OPTION_MENU (menu), selected_source);
@@ -397,6 +413,7 @@ bbdb_page_factory (EPlugin *ep, EConfigH
 	GtkWidget *inner_vbox;
 	GtkWidget *check;
 	GtkWidget *option;
+	GtkWidget *gaim_option;
 	GtkWidget *check_gaim;
 	GtkWidget *button;
 
@@ -436,7 +453,7 @@ bbdb_page_factory (EPlugin *ep, EConfigH
 	stuff->check = check;
 	
 	/* Source selection open menu */
-	option = create_addressbook_option_menu (stuff);
+	option = create_addressbook_option_menu (stuff, AUTOMATIC_CONTACTS_ADDRESSBOOK);
 	g_signal_connect (option, "source_selected", G_CALLBACK (source_changed_cb), stuff);
 	gtk_widget_set_sensitive (option, gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE, NULL));
 	gtk_box_pack_start (GTK_BOX (inner_vbox), option, FALSE, FALSE, 0);
@@ -458,6 +475,14 @@ bbdb_page_factory (EPlugin *ep, EConfigH
 	gtk_box_pack_start (GTK_BOX (hbox), padding_label, FALSE, FALSE, 0);
 	inner_vbox = gtk_vbox_new (FALSE, 6);
 	gtk_box_pack_start (GTK_BOX (hbox), inner_vbox, FALSE, FALSE, 0);
+
+	/* Gaim Source Selection Option Menu */
+	
+	gaim_option = create_addressbook_option_menu (stuff, GAIM_ADDRESSBOOK);
+	g_signal_connect (gaim_option, "source_selected", G_CALLBACK (gaim_source_changed_cb), stuff);
+	gtk_widget_set_sensitive (gaim_option, gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE_GAIM, NULL));
+	gtk_box_pack_start (GTK_BOX (inner_vbox), gaim_option, FALSE, FALSE, 0);
+	stuff->gaim_option_menu = gaim_option;
 	
 	/* Enable Gaim Checkbox */
 	check_gaim = gtk_check_button_new_with_mnemonic (_("Periodically synchronize contact information and images from my _instant messenger"));
Index: plugins/bbdb/bbdb.h
===================================================================
RCS file: /cvs/gnome/evolution/plugins/bbdb/bbdb.h,v
retrieving revision 1.1
diff -u -p -r1.1 bbdb.h
--- plugins/bbdb/bbdb.h	26 Oct 2004 03:02:04 -0000	1.1
+++ plugins/bbdb/bbdb.h	15 Dec 2005 08:58:02 -0000
@@ -5,13 +5,18 @@
 #define GCONF_KEY_ENABLE "/apps/evolution/autocontacts/enable_autocontacts"
 #define GCONF_KEY_ENABLE_GAIM "/apps/evolution/autocontacts/auto_sync_gaim"
 #define GCONF_KEY_WHICH_ADDRESSBOOK "/apps/evolution/autocontacts/addressbook_source"
+#define GCONF_KEY_WHICH_ADDRESSBOOK_GAIM "/apps/evolution/autocontacts/gaim_addressbook_source"
 #define GCONF_KEY_GAIM_LAST_SYNC "/apps/evolution/autocontacts/gaim_last_sync_time"
 
+#define GAIM_ADDRESSBOOK 1
+#define AUTOMATIC_CONTACTS_ADDRESSBOOK 0
+
+
 /* How often to poll the buddy list for changes (every two minutes) */
 #define BBDB_BLIST_CHECK_INTERVAL (2 * 60 * 1000) 
 
 /* bbdb.c */
-EBook *bbdb_open_addressbook (void);
+EBook *bbdb_open_addressbook (int type);
 gboolean bbdb_check_gaim_enabled (void);
 
 /* gaimbuddies.c */
Index: plugins/bbdb/gaimbuddies.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/bbdb/gaimbuddies.c,v
retrieving revision 1.5
diff -u -p -r1.5 gaimbuddies.c
--- plugins/bbdb/gaimbuddies.c	17 Jun 2005 15:20:30 -0000	1.5
+++ plugins/bbdb/gaimbuddies.c	15 Dec 2005 08:58:03 -0000
@@ -61,7 +61,7 @@ typedef struct {
 } GaimBuddy;
 
 /* Defined in bbdb.c */
-EBook *bbdb_open_addressbook (void);
+EBook *bbdb_open_addressbook (int type);
 
 /* Forward declarations for this file. */
 void bbdb_sync_buddy_list (void);
@@ -125,7 +125,7 @@ bbdb_sync_buddy_list (void)
 		return;
 
 	/* Open the addressbook */
-	book = bbdb_open_addressbook ();
+	book = bbdb_open_addressbook (GAIM_ADDRESSBOOK);
 	if (book == NULL) {
 		free_buddy_list (blist);
 		return;
@@ -141,7 +141,7 @@ bbdb_sync_buddy_list (void)
 		EContact *c;
 
 		if (b->alias == NULL || strlen (b->alias) == 0)
-			continue;
+			b->alias = b->account_name;
 
 		/* Look for an exact match full name == buddy alias */
 		query = e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_IS, b->alias);


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