[Commits] callbacks.c 1.8 1.9 contactwindow.c 1.5 1.6

miras at claws-mail.org miras at claws-mail.org
Tue Nov 22 01:10:55 CET 2011


Update of /home/claws-mail/contacts/src
In directory claws-mail:/tmp/cvs-serv15613/src

Modified Files:
	callbacks.c contactwindow.c 
Log Message:
2011-11-22 [mir]	0.6.0cvs25

	* plugins/ldap/ldap-plugin.c
	* plugins/xml/xml-plugin.c
	* src/callbacks.c
	* src/contactwindow.c
	    Fixing small bug in xml-plugin.
	    Fixing small bug in callbacks and contactwindow.
	    Preparing ldap-plugin for update support. 

Index: callbacks.c
===================================================================
RCS file: /home/claws-mail/contacts/src/callbacks.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- callbacks.c	20 Nov 2011 23:01:38 -0000	1.8
+++ callbacks.c	22 Nov 2011 00:10:53 -0000	1.9
@@ -364,19 +364,25 @@
 							 ContactColumn column,
 							 const gchar* value) {
 	Email* mail;
+	AttribDef* attr = g_new0(AttribDef, 1);
 	
+	attr->type = ATTRIB_TYPE_STRING;
+	attr->value.string = g_strdup(value);
 	switch (column) {
 		case CONTACT_DISPLAYNAME_COLUMN:
+			attr->attrib_name = g_strdup("cn");
 			g_hash_table_replace(contact->data,
-					g_strdup("cn"), g_strdup(value));
+					g_strdup("cn"), attr);
 			break;
     	case CONTACT_FIRSTNAME_COLUMN:
+    		attr->attrib_name = g_strdup("first-name");
 			g_hash_table_replace(contact->data,
-					g_strdup("first-name"), g_strdup(value));
+					g_strdup("first-name"), attr);
 			break;
 		case CONTACT_LASTNAME_COLUMN:
+			attr->attrib_name = g_strdup("last-name");
 			g_hash_table_replace(contact->data,
-					g_strdup("last-name"), g_strdup(value));
+					g_strdup("last-name"), attr);
 			break;
 		case CONTACT_EMAIL_COLUMN:
 			/* In default view only the first email will be used */
@@ -391,6 +397,7 @@
 			mail->email = g_strdup(value);
 			break;
 		default:
+			attrib_def_free(attr);
 			break;
 	}
 }
@@ -499,7 +506,7 @@
 	gchar* error = NULL;
 	
 	if (! plugin->readonly) {
-		plugin->delete_contact(abook, old, &error);
+/*		plugin->delete_contact(abook, old, &error);
 		if (!error) {
 			abook->contacts = g_list_remove(abook->contacts, old);
 			plugin->set_contact(abook, new, &error);
@@ -508,7 +515,10 @@
 			}
 			else {
 			}
-		}
+		}*/
+		abook->contacts = g_list_remove(abook->contacts, old);
+		if (! plugin->update_contact(abook, new, &error))
+			abook->contacts = g_list_prepend(abook->contacts, new);
 	}
 	else {
 		error = g_strdup(_("Plugin does not support updates"));
@@ -1676,7 +1686,7 @@
 			new_contact = contact_copy(old_contact);
 			if (new_contact) {			
 				contact_set_attr(new_contact, col, new_text);
-				gtk_list_store_set(GTK_LIST_STORE(model), &iter, col, new_text, -1);
+				/*gtk_list_store_set(GTK_LIST_STORE(model), &iter, col, new_text, -1);*/
 				error = contact_write_to_backend(
 						plugin, abook, old_contact, new_contact);
 			}
@@ -1692,6 +1702,7 @@
 		g_free(new_contact);
 	}
 	else {
+		gtk_list_store_set(GTK_LIST_STORE(model), &iter, col, new_text, -1);
 		gtk_list_store_set(GTK_LIST_STORE(model), &iter,
 				CONTACT_DATA_COLUMN, new_contact, -1);
 		if (old_contact) {
@@ -1774,12 +1785,27 @@
     MainWindow* win = (MainWindow *) data;
 	gchar* error = NULL;
 	GtkTreeView* view;
+	GtkTreeIter* iter = NULL;
+	GtkTreeSelection* row;
+	AddressBook* abook;
 	Plugin* plugin;
 
 	view = GTK_TREE_VIEW(win->abook_list);
-
+	abook = get_selected_address_book(view);
+	if (abook == NULL) {
+		iter = set_selection_combobox(win->window,
+						_("[New Contact] Choose address book"),
+						gtk_tree_view_get_model(view),
+						BOOK_NAME_COLUMN);
+		if (! iter)
+			return;
+		row = gtk_tree_view_get_selection(view);
+		gtk_tree_selection_select_iter(row, iter);
+		g_free(iter);
+	}
 	plugin = get_selected_plugin(view);
-	if (! plugin->readonly) {
+
+	if (plugin && ! plugin->readonly) {
 		contact_show(win, NULL, &error);
 	}
 	else
@@ -1805,14 +1831,6 @@
 
 	mail = cn = first = last = con_id = NULL;
 	view = GTK_TREE_VIEW(win->abook_list);
-	plugin = get_selected_plugin(view);
-
-	if (plugin && plugin->readonly) {
-		show_message(win->window, GTK_UTIL_MESSAGE_INFO,
-				_("Plugin does not support updates"));
-		return;
-	}
-	
 	abook = get_selected_address_book(view);
 	if (abook == NULL) {
 		iter = set_selection_combobox(win->window,
@@ -1827,6 +1845,14 @@
 		abook = get_selected_address_book(view);
 	}
 
+	plugin = get_selected_plugin(view);
+
+	if (! plugin || (plugin && plugin->readonly)) {
+		show_message(win->window, GTK_UTIL_MESSAGE_INFO,
+				_("Plugin does not support updates"));
+		return;
+	}
+	
 	view = GTK_TREE_VIEW(win->contact_list);
 	if (win->selected_contact) {
 		contact = (Contact *) win->selected_contact;

Index: contactwindow.c
===================================================================
RCS file: /home/claws-mail/contacts/src/contactwindow.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- contactwindow.c	20 Nov 2011 21:24:20 -0000	1.5
+++ contactwindow.c	22 Nov 2011 00:10:53 -0000	1.6
@@ -588,21 +588,28 @@
 	if (win->abook && win->plugin) {	
 		if (contact_is_new) {
 			new_contact = contact_copy(win->contact);
-			list_view_append_contact(
+/*			list_view_append_contact(
 					GTK_TREE_VIEW(win->main->contact_list), new_contact);
 			while (gtk_events_pending())
-  				gtk_main_iteration();
+  				gtk_main_iteration();*/
 			win->plugin->set_contact(win->abook, new_contact, &error);
-			if (! error)
+			if (! error) {
 				contact_is_new = FALSE;
+				list_view_append_contact(
+					GTK_TREE_VIEW(win->main->contact_list), new_contact);
+				while (gtk_events_pending())
+  					gtk_main_iteration();
+			}
 		}
 		else {
 			old_contact = win->contact;
 			new_contact = contact_copy(old_contact);
 			contact_set_attr(new_contact, atoi(path_string), col, new_text);
-			gtk_list_store_set(GTK_LIST_STORE(model), &iter, col, new_text, -1);
+/*			gtk_list_store_set(GTK_LIST_STORE(model), &iter, col, new_text, -1);*/
 			error = contact_write_to_backend(
 					win->plugin, win->abook, old_contact, new_contact);
+			if (! error)
+				gtk_list_store_set(GTK_LIST_STORE(model), &iter, col, new_text, -1);
 		}
 	}
 	else {



More information about the Commits mailing list