[Commits] about.c 1.1 1.2 callbacks.c 1.4 1.5 claws-contacts.c 1.1 1.2 contactwindow.c 1.2 1.3 gtk-utils.c 1.3 1.4 mainwindow.c 1.2 1.3 plugin-loader.c 1.5 1.6 plugin-loader.h 1.3 1.4 plugin.h 1.4 1.5 printing.c 1.2 1.3 utils.c 1.3 1.4 utils.h 1.3 1.4

miras at claws-mail.org miras at claws-mail.org
Tue Oct 4 22:21:42 CEST 2011


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

Modified Files:
	about.c callbacks.c claws-contacts.c contactwindow.c 
	gtk-utils.c mainwindow.c plugin-loader.c plugin-loader.h 
	plugin.h printing.c utils.c utils.h 
Log Message:
2011-10-04 [mir]	0.6.0cvs20

	* dbus-client/client.c
	* plugins/example/example-plugin.c
	* plugins/ldap/ldap-plugin.c
	* plugins/xml/plugin-init.c
	* plugins/xml/xml-plugin.c
	* src/about.c
	* src/callbacks.c
	* src/claws-contacts.c
	* src/contactwindow.c
	* src/gtk-utils.c
	* src/mainwindow.c
	* src/plugin-loader.c
	* src/plugin-loader.h
	* src/plugin.h
	* src/printing.c
	* src/utils.c
	* src/utils.h
	* src/dbus/dbus-service.c
	* src/dbus/server-object.c
	* xmllib/parser.c
	* xmllib/parser.h
	    - Implemented forgotten functionality to reactivate closed
	    address books.
	    - Fix a ton of bugs.
	    - Extended plugin API so that it is possible to get a list
	      of closed address books as well as splitting attributes
	      in mandatory and optional.
	    - Provide plugins a way to have a fixed set of attributes.
	      Eg. LDAP has a finite set of attributes while XML supports
	      an infinite set of attributes. 

Index: contactwindow.c
===================================================================
RCS file: /home/claws-mail/contacts/src/contactwindow.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- contactwindow.c	20 Sep 2011 21:58:43 -0000	1.2
+++ contactwindow.c	4 Oct 2011 20:21:40 -0000	1.3
@@ -391,9 +391,7 @@
 						g_slist_remove(cw->contact->emails, remove);
 					contact_update(cw, cw->contact);
 					email_list_add(GTK_TREE_VIEW(cw->email_list), cw);
-					cur = NULL;
-					cur = g_slist_prepend(cur, remove);
-					gslist_free(&cur, g_free);
+					email_free(remove);
 				}
 			}
 		}
@@ -755,7 +753,7 @@
 
 	if (err) {
 		show_message(parent, GTK_UTIL_MESSAGE_WARNING, "%s", err->message);
-		g_error_free(err); 
+		g_clear_error(&err); 
 		return NULL; 
 	} 
 	gdk_pixbuf_loader_set_size(pl, PHOTO_WIDTH, PHOTO_HEIGHT); 

Index: utils.h
===================================================================
RCS file: /home/claws-mail/contacts/src/utils.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- utils.h	27 Sep 2011 17:13:04 -0000	1.3
+++ utils.h	4 Oct 2011 20:21:40 -0000	1.4
@@ -81,6 +81,7 @@
 gpointer attrib_def_copy(gpointer attrdef);
 GSList* gslist_deep_copy(GSList* list, COPYFUNC copy_func);
 void gslist_free(GSList** list, void (*elem_free) (gpointer data));
+void glist_free(GList** list, void (*elem_free) (gpointer data));
 GHashTable* hash_table_new(void);
 GHashTable * hash_table_copy(GHashTable* hash);
 void hash_table_dump(GHashTable* hash, FILE* f);
@@ -113,13 +114,15 @@
 AddressBook* address_book_copy(AddressBook* a, gboolean deep);
 void address_book_contacts_free(AddressBook* address_book);
 void address_book_free(AddressBook** address_book);
+gint address_book_compare(gconstpointer a, gconstpointer b);
 gboolean xor(const gchar* a, const gchar* b);
 gchar* base64_encode_data(const gchar* path);
 guint set_log_handler();
 gint utf8_collate(gchar* s1, gchar* s2);
 gboolean attribute_supported(Plugin* plugin, const gchar* attribute);
 void gslist_remove_member(GSList* haystack, AttrList* neddle);
-
+gint gslist_get_index(GSList* list, gconstpointer data, GCompareFunc comp);
+gint gslist_compare_gchar(gconstpointer a, gconstpointer b);
 GPtrArray* g_value_email_new();
 void dbus_contact_print(DBusContact* contact, FILE* f);
 

Index: plugin-loader.h
===================================================================
RCS file: /home/claws-mail/contacts/src/plugin-loader.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- plugin-loader.h	20 Sep 2011 21:58:43 -0000	1.3
+++ plugin-loader.h	4 Oct 2011 20:21:40 -0000	1.4
@@ -61,6 +61,7 @@
 	GSList* (*attrib_list) (void);
 	void (*attribs_set) (GHashTable* attributes);
 	GSList* (*addrbook_all_get) (void);
+	GList* (*closed_books_get) (void);
 	gboolean (*abook_open) (AddressBook* abook, gchar** error);
 	gboolean (*abook_close) (AddressBook* abook, gchar** error);
 	gboolean (*abook_delete) (AddressBook* abook, gchar** error);

Index: plugin.h
===================================================================
RCS file: /home/claws-mail/contacts/src/plugin.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- plugin.h	27 Sep 2011 17:13:04 -0000	1.4
+++ plugin.h	4 Oct 2011 20:21:40 -0000	1.5
@@ -152,6 +152,8 @@
 
 /* Return a list of address book names */
 GSList* plugin_addrbook_all_get(void);
+/* Return a list of closed address books */
+GList* plugin_closed_books_get(void);
 
 /* Commit all changes */
 gboolean plugin_commit_all(gchar** error);

Index: gtk-utils.c
===================================================================
RCS file: /home/claws-mail/contacts/src/gtk-utils.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gtk-utils.c	27 Sep 2011 17:13:04 -0000	1.3
+++ gtk-utils.c	4 Oct 2011 20:21:40 -0000	1.4
@@ -177,19 +177,16 @@
 
 GHashTable* get_attrib_list(GtkWidget* parent, 
 							AttribContainer* attrib_lists,
-							/*Plugin* plugin,*/
 							const gchar* info_text, gboolean can_delete,
 							gchar** error, AddAttribCallback callback) {
 	GtkWidget *header, *dialog, *window, *vbox1, *attrib_box,
 			  *frame1, *frame2, *hbtnbox, *add_attrib_btn;
-	/*gint i;*/
 	GHashTable*	hash_table = NULL;
 	CallbackData* callback_data;
 	ButtonCB* button_cb;
 	GSList* cur;
 	
-	if (! attrib_lists /*|| 
-			(! attrib_lists->existing_attribs && ! attrib_lists->inactive_attribs)*/)
+	if (! attrib_lists)
 		return NULL;
 
 	callback_data = g_new0(CallbackData, 1);
@@ -215,7 +212,6 @@
 			GTK_SCROLLED_WINDOW(window), attrib_box);
 	
 	for (cur = attrib_lists->existing_attribs; cur; cur = g_slist_next(cur)) {
-	/*for(i = 0; attrib_lists->existing_attribs[i]; i++) {*/
 		AttribDef* attr = (AttribDef *) cur->data;
 		GtkWidget* check_btn = gtk_check_button_new_with_label(attr->attrib_name);
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_btn), TRUE);
@@ -224,21 +220,16 @@
 		gtk_container_add(GTK_CONTAINER(frame), check_btn);
 		gtk_box_pack_start(GTK_BOX(attrib_box), frame, FALSE, TRUE, 0);
 	}
-	/*gslist_free(&list, attrib_def_free);*/
 	
 	for (cur = attrib_lists->inactive_attribs; cur; cur = g_slist_next(cur)) {
-	/*if (attrib_lists->inactive_attribs && *attrib_lists->inactive_attribs) {*/
 		AttribDef* attr = (AttribDef *) cur->data;
-		/*for(i = 0; attrib_lists->inactive_attribs[i]; i++) {*/
 		GtkWidget* check_btn = gtk_check_button_new_with_label(attr->attrib_name);
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_btn), FALSE);
 		gtk_widget_set_sensitive(check_btn, can_delete);
 		GtkWidget* frame = gtk_frame_new(NULL);
 		gtk_container_add(GTK_CONTAINER(frame), check_btn);
 		gtk_box_pack_start(GTK_BOX(attrib_box), frame, FALSE, TRUE, 0);
-		/*}*/
 	}
-	/*gslist_free(&list, attrib_def_free);*/
 	
 	gtk_box_pack_start(GTK_BOX(vbox1), frame2, TRUE, TRUE, 0);
 
@@ -279,21 +270,15 @@
 			}
 			break;
 		default:
-/*			for(i = 0; attrib_lists->existing_attribs[i]; i++) {
-				AttribDef* attr = g_new0(AttribDef, 1);
-				attr->attrib_name = g_strdup(attrib_lists->existing_attribs[i]);
-				attr->type = ATTRIB_TYPE_STRING;*/
 			for (cur = attrib_lists->existing_attribs; cur; cur = g_slist_next(cur)) {
 				AttribDef* attr = (AttribDef *) cur->data;
 				g_hash_table_replace(callback_data->hash_table,
 					g_strdup(attr->attrib_name), attrib_def_copy(attr));
 			}
-			/*gslist_free(&list, attrib_def_free);*/
 			hash_table = hash_table_copy(callback_data->hash_table);
 			break;
 	}
 	gtk_widget_destroy(dialog);
-	/*gslist_free(&button_cb->remaining_attribs, attrib_def_free);*/
 	g_free(button_cb);
 	callback_data_free(callback_data);
 
@@ -312,16 +297,11 @@
 	ButtonCB* button_cb = (ButtonCB *) data;
 	gchar* reply = NULL;
 	GSList *cur, *choices = NULL;
-	/*gint i;*/
 	
 	if (button_cb->remaining_attribs) {
-		/* supported attributes by plugin is not infinite */
 		for (cur = button_cb->remaining_attribs; cur; cur = g_slist_next(cur)) {
 			AttribDef* attr = (AttribDef *) cur->data;
 			choices = g_slist_prepend(choices, g_strdup(attr->attrib_name));
-		/*if (*button_cb->remaining_attribs) {
-			for (i = 0; i < g_strv_length(button_cb->remaining_attribs); i++)
-				choices = g_slist_prepend(choices, button_cb->remaining_attribs[i]);*/
 			if (show_choice_list(button_cb->parent, "Choice new attribute",
 				choices, &reply)) {
 			}

Index: plugin-loader.c
===================================================================
RCS file: /home/claws-mail/contacts/src/plugin-loader.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- plugin-loader.c	27 Sep 2011 17:13:04 -0000	1.5
+++ plugin-loader.c	4 Oct 2011 20:21:40 -0000	1.6
@@ -638,7 +638,8 @@
 			 plugin_abook_open, plugin_abook_close, plugin_abook_delete,
 			 plugin_addrbook_all_get, plugin_abook_set_config, plugin_type,
 			 plugin_url, plugin_attribs_set, plugin_commit_all,
-			 plugin_remaining_attribs, plugin_inactive_attribs;
+			 plugin_remaining_attribs, plugin_inactive_attribs,
+			 plugin_closed_books_get;
 
 	plugin = g_new0(Plugin, 1);
 	if (plugin == NULL) {
@@ -671,6 +672,7 @@
 		!g_module_symbol(plugin->module, "plugin_abook_set_config", &plugin_abook_set_config) ||
 		!g_module_symbol(plugin->module, "plugin_commit_all", &plugin_commit_all) ||
 		!g_module_symbol(plugin->module, "plugin_init", &plugin_init) ||
+		!g_module_symbol(plugin->module, "plugin_closed_books_get", &plugin_closed_books_get) ||
 		!g_module_symbol(plugin->module, "plugin_remaining_attribs", &plugin_remaining_attribs) ||
 		!g_module_symbol(plugin->module, "plugin_inactive_attribs", &plugin_inactive_attribs)) {
 		*error = g_strdup(g_module_error());
@@ -751,6 +753,7 @@
 	plugin->abooks_commit_all = plugin_commit_all;
 	plugin->remaining_attribs = plugin_remaining_attribs;
 	plugin->inactive_attribs = plugin_inactive_attribs;
+	plugin->closed_books_get = plugin_closed_books_get;
 	
 	compute_hash(plugin);
 
@@ -803,18 +806,25 @@
 	if (plugin->error) {
 		unloaded_plugins = g_slist_remove(unloaded_plugins, plugin);
 		plugin_free(plugin);
-		return;
-	}
-	if (g_module_symbol(plugin->module, "plugin_done", (gpointer) &plugin_done)) {
-		can_unload = plugin_done();
-	}
-
-	if (can_unload) {
-		plugins = g_slist_remove(plugins, plugin);
-		plugin_free(plugin);
 	}
 	else {
-		//plugin->unloaded_hidden = TRUE;
+		if (g_module_symbol(plugin->module, "plugin_done", (gpointer) &plugin_done)) {
+			can_unload = plugin_done();
+		}
+	
+		if (can_unload) {
+			plugins = g_slist_remove(plugins, plugin);
+			plugin_free(plugin);
+		}
+		else {
+			g_warning("Unloading '%s' failed!", plugin_get_name(plugin));
+			if (plugin->error)
+				g_warning("Error message: %s", plugin->error);
+			/* FIXME. Should we forcefully unload a plugin which have
+			 * failed to be unloaded?*/
+			/*plugins = g_slist_remove(plugins, plugin);
+			plugin_free(plugin);*/
+		}
 	}
 }
 

Index: mainwindow.c
===================================================================
RCS file: /home/claws-mail/contacts/src/mainwindow.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mainwindow.c	8 Sep 2011 07:09:28 -0000	1.2
+++ mainwindow.c	4 Oct 2011 20:21:40 -0000	1.3
@@ -618,7 +618,7 @@
         err = NULL;
     }
     if (err)
-        g_error_free(err);
+        g_clear_error(&err);
 
     return list;
 }

Index: utils.c
===================================================================
RCS file: /home/claws-mail/contacts/src/utils.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- utils.c	27 Sep 2011 17:13:04 -0000	1.3
+++ utils.c	4 Oct 2011 20:21:40 -0000	1.4
@@ -242,6 +242,22 @@
 	*list = NULL;
 }
 
+void glist_free(GList** list, void (*elem_free) (gpointer data)) {
+	GList* cur;
+	
+	if (!list || !*list)
+		return;
+
+	if (elem_free) {
+		for (cur = *list; cur; cur = g_list_next(cur)) {
+			elem_free(cur->data);
+			cur->data = NULL;
+		}
+	}
+	g_list_free(*list);
+	*list = NULL;
+}
+
 void hash_table_free(GHashTable** hash_table) {
 	if (*hash_table == NULL)
 		return;
@@ -399,15 +415,23 @@
 	cl_books = config->closed_books;
 	
 	if (cf_books && cf_books->group) {
-		list = gslist_to_array(cf_books->books, &num);
+		if (cf_books->books)
+			list = gslist_to_array(cf_books->books, &num);
+		else {
+			list = g_new0(gchar *, 1);
+		}
 		g_key_file_set_string_list(config->key_file, cf_books->group,
 				"books", (const gchar* const *) list, num);
 		g_strfreev(list);
 	}
 	if (cl_books && cl_books->group) {
-		list = gslist_to_array(cl_books->books, &num);
+		if (cl_books->books)
+			list = gslist_to_array(cl_books->books, &num);
+		else {
+			list = g_new0(gchar *, 1);
+		}
 		g_key_file_set_string_list(config->key_file, cl_books->group,
-				"closed books", (const gchar* const *) list, num);
+				"books", (const gchar* const *) list, num);
 		g_strfreev(list);
 	}
 }
@@ -459,6 +483,7 @@
 	for (num = 0; num < len; num++) {
 		cf_books->books = g_slist_prepend(cf_books->books, g_strdup(str[num]));
 	}
+	g_clear_error(&err);
 	g_strfreev(str);
 	
 	cl_books->group = g_strdup("closed address books");
@@ -467,9 +492,8 @@
 	for (num = 0; num < len; num++) {
 		cl_books->books = g_slist_prepend(cl_books->books, g_strdup(str[num]));
 	}
+	g_clear_error(&err);
 	g_strfreev(str);
-
-	g_error_free(err);
 }
 
 static void config_close(ConfigFile* config, gchar** error) {
@@ -483,7 +507,7 @@
 		if (err) {
 			if (error)
 				*error = g_strdup(err->message);
-			g_error_free(err);
+			g_clear_error(&err);
 		}
 		else {
 			gchar* old = g_strconcat(config->path, ".bak", NULL);
@@ -517,7 +541,7 @@
 			g_free(error);
 			if (error)
 				*error = g_strdup(err->message);
-			g_error_free(err);
+			g_clear_error(&err);
 			return;
 		}
 	}
@@ -759,6 +783,7 @@
 	}
 	g_list_free(address_book->contacts);
 	address_book->contacts = NULL;
+	address_book->dirty = TRUE;
 }
 
 void address_book_free(AddressBook** address_book) {
@@ -772,7 +797,7 @@
 	g_free(a->username);
 	g_free(a->password);
 	address_book_contacts_free(a);
-	a = NULL;
+	*address_book = NULL;
 }
 
 AddressBook* address_book_new() {
@@ -1191,4 +1216,57 @@
 			}
 		}
 	}
+}
+
+gint address_book_compare(gconstpointer a, gconstpointer b) {
+	const AddressBook* s1 = (const AddressBook *) a;
+	const AddressBook* s2 = (const AddressBook *) b;
+	gint found;
+	
+	if (!s1 && !s2)
+		return 0;
+		
+	if (!s1 && s2)
+		return 1;
+		
+	if (s1 && !s2)
+		return -1;
+	
+	found = g_utf8_collate(s1->abook_name, s2->abook_name);
+	if (found)
+		return found;
+		
+	return g_utf8_collate(s1->URL, s2->URL);
+}
+
+gint gslist_compare_gchar(gconstpointer a, gconstpointer b) {
+	const gchar* s1 = (const gchar *) a;
+	const gchar* s2 = (const gchar *) b;
+	
+	if (!s1 && !s2)
+		return 0;
+		
+	if (!s1 && s2)
+		return 1;
+		
+	if (s1 && !s2)
+		return -1;
+	
+	return g_utf8_collate(s1, s2);
+}
+
+gint gslist_get_index(GSList* list, gconstpointer data, GCompareFunc comp) {
+	gint index = -1, i = 0;
+	GSList* cur;
+	
+	if (comp) {
+		for (cur = list; cur && index < 0; cur = g_slist_next(cur), i++) {
+			if (comp(cur->data, data) == 0)
+				index = i;
+		}	 
+	}
+	else
+		index = g_slist_index(list, data);
+
+	return index;
 }
\ No newline at end of file

Index: printing.c
===================================================================
RCS file: /home/claws-mail/contacts/src/printing.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- printing.c	20 Sep 2011 21:58:44 -0000	1.2
+++ printing.c	4 Oct 2011 20:21:40 -0000	1.3
@@ -271,7 +271,7 @@
 	if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
 		show_message(info->win->window, GTK_UTIL_MESSAGE_WARNING,
 			_("Error printing file:\n%s"), error->message);
-   		g_error_free (error);
+   		g_clear_error(&error);
 	}
 	else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
 		if (settings != NULL)

Index: about.c
===================================================================
RCS file: /home/claws-mail/contacts/src/about.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- about.c	7 Sep 2011 17:35:29 -0000	1.1
+++ about.c	4 Oct 2011 20:21:40 -0000	1.2
@@ -59,9 +59,9 @@
         error_dialog = gtk_message_dialog_new(
                 NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
                 GTK_BUTTONS_OK, "Failed to show url %s", error->message);
-        gtk_dialog_run (GTK_DIALOG (error_dialog));
-        g_error_free (error);
-        gtk_widget_destroy (error_dialog);
+        gtk_dialog_run(GTK_DIALOG (error_dialog));
+        g_clear_error(&error);
+        gtk_widget_destroy(error_dialog);
     }
 }
 
@@ -87,7 +87,7 @@
                 NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
                 "Failed to show url %s", error->message); 
         gtk_dialog_run(GTK_DIALOG (error_dialog));
-        g_error_free(error);
+        g_clear_error(&error);
         gtk_widget_destroy (error_dialog);
     }
 }

Index: claws-contacts.c
===================================================================
RCS file: /home/claws-mail/contacts/src/claws-contacts.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- claws-contacts.c	7 Sep 2011 17:35:29 -0000	1.1
+++ claws-contacts.c	4 Oct 2011 20:21:40 -0000	1.2
@@ -77,7 +77,7 @@
     g_option_context_set_help_enabled(context, TRUE);
     if (! g_option_context_parse(context, &argc, &argv, &error)) {
         g_print(_("Parsing options failed: %s\n"), error->message);
-        g_error_free(error);
+        g_clear_error(&error);
         res = TRUE;
     }
     g_option_context_free(context);

Index: callbacks.c
===================================================================
RCS file: /home/claws-mail/contacts/src/callbacks.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- callbacks.c	27 Sep 2011 17:13:04 -0000	1.4
+++ callbacks.c	4 Oct 2011 20:21:40 -0000	1.5
@@ -39,6 +39,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
+#include <stdlib.h>
 #include "mainwindow.h"
 #include "callbacks.h"
 #include "utils.h"
@@ -113,8 +114,7 @@
 			g_key_file_load_from_file(
 				config->key_file, configrc, G_KEY_FILE_KEEP_COMMENTS, &err);
 			if (err) {
-				g_error_free(err);
-				err = NULL;
+				g_clear_error(&err);
 				return;
 			}
 		}
@@ -158,11 +158,11 @@
 	
 	if (win) {
     	debug_print("Closing application\n");
-		gtk_widget_destroy(win->window);
+		//gtk_widget_destroy(win->window);
 		gtk_widget_destroy(win->progress_dialog);
 		g_free(win->default_book);
+		g_free(win);
 		gtk_main_quit();
-		win = NULL;
 	}
 	if (mainloop) {
 		//debug_print("main_loop [%p]\n", mainloop);
@@ -402,8 +402,7 @@
 		g_key_file_load_from_file(
 			config->key_file, configrc, G_KEY_FILE_KEEP_COMMENTS, &err);
 		if (err) {
-			g_error_free(err);
-			err = NULL;
+			g_clear_error(&err);
 		}
 	}
 
@@ -588,16 +587,26 @@
 }
 
 gint delete_event(GtkWidget* widget, GdkEvent* event, gpointer data) {
-	shutdown_application(data);
+	MainWindow* win = (MainWindow *) data;
+	shutdown_application(win);
+	//g_free(win);
     return TRUE;
 }
 
 void menu_quit_cb(GtkMenuItem *menuitem, gpointer data) {
 	shutdown_application(data);
+	while (gtk_events_pending())
+  		gtk_main_iteration ();
+  	gtk_main_quit();
+  	exit(EXIT_SUCCESS);
 }
 
 void toolbar_quit_cb(GtkToolButton *toolbutton, gpointer data) {
 	shutdown_application(data);
+	while (gtk_events_pending())
+  		gtk_main_iteration ();
+  	gtk_main_quit();
+  	exit(EXIT_SUCCESS);
 }
 
 void file_plugin_cb(GtkMenuItem *menuitem, gpointer data) {
@@ -712,6 +721,9 @@
 	AddressBook *book = NULL, *tmp;
 	gchar* plugin_name = NULL;
 	gchar* error = NULL;
+	gboolean use_closed = FALSE;
+	GList* cur;
+	GSList* names = NULL;
 
     debug_print("Creating address book window\n");
 	
@@ -724,22 +736,60 @@
 	if (response) {
 		plugin = plugin_get_plugin(plugin_name);
 		if (plugin) {
-			book = address_book_new();
-			if (address_book_edit(win->window, plugin, &book)) {
-				/* Empty name ensures the chosen name is used as name */
-				tmp = address_book_new();
-				tmp->URL = g_strdup(book->URL);
-				plugin->abook_set_config(tmp, book, &error);
-				if (! error) {		
-					if (plugin->abook_open(book, &error)) 
-						update_abook_list(win);
+			GList* closed = plugin->closed_books_get();
+			if (closed) {
+				use_closed = show_question(win->window,
+					"Choose from list of previously closed books?");
+			}
+			if (use_closed) {
+				for (cur = closed; cur; cur = g_list_next(cur)) {
+					AddressBook* abook = (AddressBook *) cur->data;
+					names = g_slist_append(names, g_strdup(abook->abook_name));
+				}
+				if (names) {
+					g_free(plugin_name);
+					plugin_name = NULL;
+					if (show_choice_list(win->window, "Choose address book",
+							names, &plugin_name)) {
+						gint index = gslist_get_index(
+							names, plugin_name, gslist_compare_gchar);
+						book = address_book_copy(g_list_nth_data(closed, index), TRUE);
+					}
+					gslist_free(&names, g_free);
+				}
+			}
+			else {
+				book = address_book_new();
+				if (address_book_edit(win->window, plugin, &book)) {
+					/* Empty name ensures the chosen name is used as name */
+					tmp = address_book_new();
+					tmp->URL = g_strdup(book->URL);
+					plugin->abook_set_config(tmp, book, &error);
+					if (error) {
+						show_message(win->window, GTK_UTIL_MESSAGE_WARNING, "%s", error);
+						g_free(error);
+						address_book_free(&book);
+					}
 				}
+				else
+					address_book_free(&book);
+			}
+			if (book) {		
+				if (plugin->abook_open(book, &error)) 
+					update_abook_list(win);
 				if (error) {
 					show_message(win->window, GTK_UTIL_MESSAGE_WARNING, "%s", error);
 					g_free(error);
 					address_book_free(&book);
 				}
 			}
+			if (closed) {
+				for (cur = closed; cur; cur = g_list_next(cur)) {
+					AddressBook* a = (AddressBook *) cur->data;
+					address_book_free(&a);
+				}
+				glist_free(&closed, NULL);
+			}
 		}
 	}
 	g_free(plugin_name);
@@ -771,7 +821,7 @@
 	if (abook && plugin) {
 		if (show_question(win->window, _("Close '%s' ?"), abook->abook_name)) {
 			plugin->abook_close(abook, &error);
-			address_book_free(&abook);
+			/*address_book_free(&abook);*/
 			update_abook_list(win);
 		}
 	}
@@ -1503,10 +1553,8 @@
 	MainWindow* win = (MainWindow *) data;
 	Plugin* plugin;
 	gchar* plugin_name;
-	GSList *plugins;/*, *cur;
-	GSList* attribs = NULL;*/
+	GSList *plugins;
 	AttribContainer* attr_container;
-	/*gint i;*/
 	gchar* error = NULL;
 	GHashTable* new_attribs = NULL;
 
@@ -1518,49 +1566,13 @@
 	if (response) {
 		plugin = plugin_get_plugin(plugin_name);
 
-/*
-		if (plugin->readonly) {
-			show_message(win->window, GTK_UTIL_MESSAGE_INFO,
-					_("Plugin does not support updates"));
-			return;
-		}
-*/
-	
 		if (plugin) {
-/*			attribs = plugin->attrib_list();
-			gchar** attr = g_new0(gchar *, g_slist_length(attribs) + 1);
-			for (cur = attribs, i = 0; cur; i++, cur = g_slist_next(cur)) {
-				AttribDef* attrdef = (AttribDef *) cur->data;
-				attr[i] = g_strdup(attrdef->attrib_name);
-			}
-			gslist_free(&attribs, attrib_def_free);
-			attribs = plugin->inactive_attribs();
-			gchar** inactive_attr = g_new0(gchar *, g_slist_length(attribs) + 1);
-			for (cur = attribs, i = 0; cur; i++, cur = g_slist_next(cur)) {
-				AttribDef* attrdef = (AttribDef *) cur->data;
-				inactive_attr[i] = g_strdup(attrdef->attrib_name);
-			}
-			gslist_free(&attribs, attrib_def_free);
-			attribs = plugin->remaining_attribs();
-			gchar** remaining_attr = NULL;
-			if (attribs) {
-				remaining_attr = g_new0(gchar *, g_slist_length(attribs) + 1);
-				for (cur = attribs, i = 0; cur; i++, cur = g_slist_next(cur)) {
-					AttribDef* attrdef = (AttribDef *) cur->data;
-					remaining_attr[i] = g_strdup(attrdef->attrib_name);
-				}
-				gslist_free(&attribs, attrib_def_free);
-			}*/
 			attr_container = g_new0(AttribContainer, 1);
 			attr_container->existing_attribs = plugin->attrib_list();
 			attr_container->inactive_attribs = plugin->inactive_attribs();
 			attr_container->remaining_attribs = plugin->remaining_attribs();
 			new_attribs = get_attrib_list(win->window, attr_container,
 					"Supported Attributes",	TRUE, &error, add_attrib_btn_cb);
-/*			g_strfreev(attr);
-			g_strfreev(inactive_attr);
-			g_strfreev(remaining_attr);
-			g_free(attr_container);*/
 			gslist_free(&attr_container->existing_attribs, attrib_def_free);
 			gslist_free(&attr_container->inactive_attribs, attrib_def_free);
 			gslist_free(&attr_container->remaining_attribs, attrib_def_free);



More information about the Commits mailing list