[Commits] example-plugin.c 1.4 1.5

miras at claws-mail.org miras at claws-mail.org
Mon Nov 14 23:06:45 CET 2011


Update of /home/claws-mail/contacts/plugins/example
In directory claws-mail:/tmp/cvs-serv18563/plugins/example

Modified Files:
	example-plugin.c 
Log Message:
Lots of bug fixes and read-only support for LDAP. No searching implemented though

Index: example-plugin.c
===================================================================
RCS file: /home/claws-mail/contacts/plugins/example/example-plugin.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- example-plugin.c	4 Oct 2011 20:21:40 -0000	1.4
+++ example-plugin.c	14 Nov 2011 22:06:43 -0000	1.5
@@ -42,6 +42,8 @@
 
 #define NAME "Example plugin"
 
+/* Reference to self */
+static Plugin* self = NULL;
 /* See plugin.h */
 static PluginFeature* feature = NULL;
 /* Description */
@@ -63,6 +65,16 @@
 static GSList* remaining_attribs = NULL;
 
 /**
+ * Remove newly open book from closed_books
+ * @param book AddressBook to remove
+ */
+static void closed_books_remove(AddressBook* book) {
+	GList* found = g_list_find_custom(closed_books, book, address_book_compare);
+	if (found)
+		closed_books = g_list_remove_link(closed_books, found);
+}
+
+/**
  * Free list of abooks.
  * @param error Pointer to memory where error is supposed to be saved
  */
@@ -235,17 +247,20 @@
  * @return TRUE if success FALSE otherwise
  */
 gboolean plugin_abook_open(AddressBook* abook, gchar** error) {
+	closed_books_remove(abook);
 	if (abook->dirty) {
 		/* Open Address book */
 		if (*error) {
 			show_message(NULL, GTK_UTIL_MESSAGE_WARNING, "%s", *error);
 			g_free(*error);
 			*error = NULL;
+			closed_books = g_list_prepend(closed_books, abook);
 			return FALSE;
 		}
 		abook->dirty = FALSE;
 	}
 	abooks = g_list_prepend(abooks, abook);
+	abook->open = TRUE;
 
 	return TRUE;	
 }
@@ -259,11 +274,15 @@
 gboolean plugin_abook_delete(AddressBook* abook, gchar** error) {
 	if (! abook)
 		return FALSE;
-		
-	plugin_abook_close(abook, error);
+	
+	if (abook->open)	
+		self->abook_close(abook, error);
+	/* Remove from closed books since deleting */
+	closed_books = g_list_remove(closed_books, abook);
 	if (abook->URL) {
 		/* Delete address book */
 	}
+	
 	return TRUE;	
 }
 
@@ -278,6 +297,9 @@
 	abooks = g_list_remove(abooks, abook);
 	address_book_contacts_free(abook);
 	debug_print("List contains %d elements after\n", g_list_length(abooks));
+	closed_books = g_list_prepend(closed_books, abook);
+	abook->open = FALSE;
+	
 	return TRUE;
 }
 
@@ -361,7 +383,8 @@
  * @param Pointer to memory where error is supposed to be saved
  * @return FALSE if success TRUE otherwise
  */
-gboolean plugin_init(gchar** error) {
+gboolean plugin_init(gpointer self_ref, gchar** error) {
+	self = (Plugin *) self_ref;
 	if (*error != NULL) {
 		g_free(*error);
 		*error = NULL;
@@ -376,6 +399,8 @@
 gboolean plugin_done(void) {
 	g_free(feature);
 	
+	self = NULL;
+
 	return TRUE;
 }
 
@@ -425,8 +450,8 @@
  * Get functional type of plugin. Returned memory is owned by the plugin.
  * @return type
  */
-const gchar* plugin_type(void) {
-	return "DEMO";
+PluginType plugin_type(void) {
+	return PLUGIN_TYPE_SIMPLE;
 }
 
 /**
@@ -436,3 +461,29 @@
 const gchar* plugin_license(void) {
 	return "GPL3+";
 }
+
+/**
+ * Does the plugin needs credentials for address books
+ * @return bool
+ */
+gboolean plugin_need_credentials(void) {
+	return FALSE;
+}
+
+/**
+ * Get list of additional config
+ * @return NULL if no additional config is required, a list of
+ * ExtraConfig otherwise
+ */
+GSList* plugin_extra_config(void) {
+	return NULL;
+}
+
+/**
+ * Get file filter for this plugin
+ * @return filter or NULL. If returning NULL means data storage is
+ * URL based URI based otherwise
+ */
+const gchar* plugin_file_filter(void) {
+	return "demo";
+}
\ No newline at end of file



More information about the Commits mailing list