[Commits] [SCM] claws branch, master, updated. 3.16.0-96-g3561faa

wwp at claws-mail.org wwp at claws-mail.org
Mon Mar 19 11:09:37 CET 2018


The branch, master has been updated
       via  3561faa0d119de9b0169f9065cd10d3ac5ed2cdf (commit)
      from  4729e80f93dc31db4b6f9bf4ecdee4095f15ea94 (commit)

Summary of changes:
 src/avatars.c                                      |   11 +++----
 src/common/hooks.c                                 |   14 +++++----
 src/common/hooks.h                                 |    6 ++--
 src/gtk/logwindow.h                                |    2 +-
 src/main.c                                         |   12 ++++----
 src/plugins/acpi_notifier/acpi_notifier.c          |    4 +--
 src/plugins/address_keeper/address_keeper.c        |    4 +--
 src/plugins/attachwarner/attachwarner.c            |    4 +--
 src/plugins/bogofilter/bogofilter.c                |   14 ++++-----
 src/plugins/bsfilter/bsfilter.c                    |   14 ++++-----
 src/plugins/clamd/clamav_plugin.c                  |    4 +--
 src/plugins/demo/demo.c                            |    4 +--
 src/plugins/fetchinfo/fetchinfo_plugin.c           |    4 +--
 src/plugins/gdata/gdata_plugin.c                   |   10 +++---
 src/plugins/libravatar/libravatar.c                |   16 +++++-----
 src/plugins/newmail/newmail.c                      |    4 +--
 .../notification/notification_foldercheck.c        |    4 +--
 src/plugins/notification/notification_plugin.c     |   32 ++++++++++----------
 src/plugins/perl/perl_plugin.c                     |    8 ++---
 src/plugins/pgpcore/autocompletion.c               |    6 ++--
 src/plugins/python/python_plugin.c                 |    4 +--
 src/plugins/spamassassin/spamassassin.c            |   17 +++++------
 src/procheader.c                                   |    8 ++---
 src/statusbar.c                                    |    8 ++---
 24 files changed, 108 insertions(+), 106 deletions(-)


- Log -----------------------------------------------------------------
commit 3561faa0d119de9b0169f9065cd10d3ac5ed2cdf
Author: wwp <wwp at free.fr>
Date:   Mon Mar 19 11:03:09 2018 +0100

    Fixed hook_id declarations to be gulong instead of guint.
    Made statusbar's hook_id static.
    Rework hook_id magic value, now 0 instead of -1, and use a define (HOOK_NONE)
    everywhere instead of 0. Any hook_id must be initialized to HOOK_NONE.
    Hook_id that get invalidated or reset get the same HOOK_NONE value.

diff --git a/src/avatars.c b/src/avatars.c
index e731194..372f30b 100644
--- a/src/avatars.c
+++ b/src/avatars.c
@@ -32,7 +32,7 @@
 #include "prefs_common.h"
 #include "avatars.h"
 
-static guint avatar_render_hook_id = -1;
+static gulong avatar_render_hook_id = HOOK_NONE;
 
 AvatarRender *avatars_avatarrender_new(MsgInfo *msginfo)
 {
@@ -93,21 +93,20 @@ gboolean avatars_internal_rendering_hook(gpointer source, gpointer data)
 
 void avatars_init(void)
 {
-	if (avatar_render_hook_id != (guint) -1) {
+	if (avatar_render_hook_id != HOOK_NONE) {
 		g_warning("Internal avatars rendering already initialized");
 		return;
 	}
 	avatar_render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST, avatars_internal_rendering_hook, NULL);
-	if (avatar_render_hook_id == (guint) -1) {
+	if (avatar_render_hook_id == HOOK_NONE) {
 		g_warning("Failed to register avatars internal rendering hook");
 	}
 }
 
 void avatars_done(void)
 {
-	if (avatar_render_hook_id != (guint) -1) {
+	if (avatar_render_hook_id != HOOK_NONE) {
 		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST, avatar_render_hook_id);
-		avatar_render_hook_id = -1;
+		avatar_render_hook_id = HOOK_NONE;
 	}
 }
-
diff --git a/src/common/hooks.c b/src/common/hooks.c
index b66e54e..230fb71 100644
--- a/src/common/hooks.c
+++ b/src/common/hooks.c
@@ -46,21 +46,21 @@ static GHookList *hooks_get_hooklist(const gchar *hooklist_name)
 	return hooklist;
 }
 
-guint hooks_register_hook(const gchar *hooklist_name,
+gulong hooks_register_hook(const gchar *hooklist_name,
 			  SylpheedHookFunction hook_func,
 			  gpointer userdata)
 {
 	GHookList *hooklist;
 	GHook *hook;
 
-	cm_return_val_if_fail(hooklist_name != NULL, (guint)-1);
-	cm_return_val_if_fail(hook_func != NULL, (guint)-1);
+	cm_return_val_if_fail(hooklist_name != NULL, HOOK_NONE);
+	cm_return_val_if_fail(hook_func != NULL, HOOK_NONE);
 	
 	hooklist = hooks_get_hooklist(hooklist_name);
-	cm_return_val_if_fail(hooklist != NULL, (guint)-1);
+	cm_return_val_if_fail(hooklist != NULL, HOOK_NONE);
 
 	hook = g_hook_alloc(hooklist);
-	cm_return_val_if_fail(hook != NULL, (guint)-1);
+	cm_return_val_if_fail(hook != NULL, HOOK_NONE);
 
 	hook->func = hook_func;
 	hook->data = userdata;
@@ -68,12 +68,14 @@ guint hooks_register_hook(const gchar *hooklist_name,
 	g_hook_append(hooklist, hook);
 
 	debug_print("registered new hook for '%s' as id %lu\n", hooklist_name, hook->hook_id);
+	if (hook->hook_id == HOOK_NONE)
+		g_error("unexpected hook ID 0");
 
 	return hook->hook_id;
 }
 
 void hooks_unregister_hook(const gchar *hooklist_name,
-			   guint hook_id)
+			   gulong hook_id)
 {
 	GHookList *hooklist;
 	GHook *hook;
diff --git a/src/common/hooks.h b/src/common/hooks.h
index 84de822..bbb4d3e 100644
--- a/src/common/hooks.h
+++ b/src/common/hooks.h
@@ -22,14 +22,16 @@
 
 #include <glib.h>
 
+#define HOOK_NONE 0
+
 typedef gboolean (*SylpheedHookFunction)	(gpointer source,
 						 gpointer userdata);
 
-guint hooks_register_hook	(const gchar		*hooklist_name,
+gulong hooks_register_hook	(const gchar		*hooklist_name,
 				 SylpheedHookFunction	 hook_func,
 				 gpointer		 userdata);
 void hooks_unregister_hook	(const gchar		*hooklist_name,
-				 guint			 hook_id);
+				 gulong			 hook_id);
 gboolean hooks_invoke		(const gchar		*hooklist_name,
 				 gpointer		 source);
 
diff --git a/src/gtk/logwindow.h b/src/gtk/logwindow.h
index 318b745..75a7def 100644
--- a/src/gtk/logwindow.h
+++ b/src/gtk/logwindow.h
@@ -44,7 +44,7 @@ struct _LogWindow
 
 	gboolean clip;
 	guint	 clip_length;
-	guint 	 hook_id;
+	gulong 	 hook_id;
 	GtkTextBuffer *buffer;
 	GtkTextTag *error_tag;
 	GtkTextMark *end_mark;
diff --git a/src/main.c b/src/main.c
index cb86e59..a0b8f82 100644
--- a/src/main.c
+++ b/src/main.c
@@ -864,17 +864,17 @@ static void main_dump_features_list(gboolean show_debug_only)
 }
 
 #ifdef HAVE_DBUS_GLIB
-static guint dbus_item_hook_id = -1;
-static guint dbus_folder_hook_id = -1;
+static gulong dbus_item_hook_id = HOOK_NONE;
+static gulong dbus_folder_hook_id = HOOK_NONE;
 
 static void uninstall_dbus_status_handler(void)
 {
 	if(awn_proxy)
 		g_object_unref(awn_proxy);
 	awn_proxy = NULL;
-	if (dbus_item_hook_id != (guint) -1)
+	if (dbus_item_hook_id != HOOK_NONE)
 		hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, dbus_item_hook_id);
-	if (dbus_folder_hook_id != (guint) -1)
+	if (dbus_folder_hook_id != HOOK_NONE)
 		hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, dbus_folder_hook_id);
 }
 
@@ -948,14 +948,14 @@ static void install_dbus_status_handler(void)
 			"/com/google/code/Awn",
 			"com.google.code.Awn");
 	dbus_item_hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, dbus_status_update_item_hook, NULL);
-	if (dbus_item_hook_id == (guint) -1) {
+	if (dbus_item_hook_id == HOOK_NONE) {
 		g_warning("Failed to register folder item update hook");
 		uninstall_dbus_status_handler();
 		return;
 	}
 
 	dbus_folder_hook_id = hooks_register_hook (FOLDER_UPDATE_HOOKLIST, dbus_status_update_folder_hook, NULL);
-	if (dbus_folder_hook_id == (guint) -1) {
+	if (dbus_folder_hook_id == HOOK_NONE) {
 		g_warning("Failed to register folder update hook");
 		uninstall_dbus_status_handler();
 		return;
diff --git a/src/plugins/acpi_notifier/acpi_notifier.c b/src/plugins/acpi_notifier/acpi_notifier.c
index c25a3df..1f96ea2 100644
--- a/src/plugins/acpi_notifier/acpi_notifier.c
+++ b/src/plugins/acpi_notifier/acpi_notifier.c
@@ -96,8 +96,8 @@ PredefinedAcpis known_implementations[] = {
 	{NULL, NULL, NULL, NULL, FALSE, NULL}
 };
 
-static guint folder_hook_id;
-static guint alertpanel_hook_id;
+static gulong folder_hook_id = HOOK_NONE;
+static gulong alertpanel_hook_id = HOOK_NONE;
 
 struct AcpiNotifierPage
 {
diff --git a/src/plugins/address_keeper/address_keeper.c b/src/plugins/address_keeper/address_keeper.c
index c85b6fb..a5aab85 100644
--- a/src/plugins/address_keeper/address_keeper.c
+++ b/src/plugins/address_keeper/address_keeper.c
@@ -33,7 +33,7 @@
 #include "prefs_common.h"
 
 /** Identifier for the hook. */
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 /**
  * Extracts name from an address.
@@ -248,7 +248,7 @@ gint plugin_init(gchar **error)
 	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
 				      addrk_before_send_hook, NULL);
 	
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register check before send hook"));
 		return -1;
 	}
diff --git a/src/plugins/attachwarner/attachwarner.c b/src/plugins/attachwarner/attachwarner.c
index 3f782f5..9132604 100644
--- a/src/plugins/attachwarner/attachwarner.c
+++ b/src/plugins/attachwarner/attachwarner.c
@@ -31,7 +31,7 @@
 #include "prefs_common.h"
 
 /** Identifier for the hook. */
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 static AttachWarnerMention *aw_matcherlist_string_match(MatcherList *matchers, gchar *str, gchar *sig_separator)
 {
@@ -248,7 +248,7 @@ gint plugin_init(gchar **error)
 	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
 				      attwarn_before_send_hook, NULL);
 	
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register check before send hook"));
 		return -1;
 	}
diff --git a/src/plugins/bogofilter/bogofilter.c b/src/plugins/bogofilter/bogofilter.c
index 85c5ddb..a0823e9 100644
--- a/src/plugins/bogofilter/bogofilter.c
+++ b/src/plugins/bogofilter/bogofilter.c
@@ -80,7 +80,7 @@
 
 #define PLUGIN_NAME (_("Bogofilter"))
 
-static guint hook_id = -1;
+static gulong hook_id = HOOK_NONE;
 static MessageCallback message_callback;
 
 static BogofilterConfig config;
@@ -901,7 +901,7 @@ gint plugin_init(gchar **error)
 {
 	gchar *rcpath;
 
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 
 	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
 				VERSION_NUMERIC, PLUGIN_NAME, error))
@@ -959,7 +959,7 @@ FolderItem *bogofilter_get_spam_folder(MsgInfo *msginfo)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		bogofilter_unregister_hook();
 	}
 #ifdef USE_PTHREAD
@@ -1021,9 +1021,9 @@ struct PluginFeature *plugin_provides(void)
 
 void bogofilter_register_hook(void)
 {
-	if (hook_id == (guint) -1)
+	if (hook_id == HOOK_NONE)
 		hook_id = hooks_register_hook(MAIL_LISTFILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -1031,8 +1031,8 @@ void bogofilter_register_hook(void)
 
 void bogofilter_unregister_hook(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		hooks_unregister_hook(MAIL_LISTFILTERING_HOOKLIST, hook_id);
 	}
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 }
diff --git a/src/plugins/bsfilter/bsfilter.c b/src/plugins/bsfilter/bsfilter.c
index 9390983..58e0126 100644
--- a/src/plugins/bsfilter/bsfilter.c
+++ b/src/plugins/bsfilter/bsfilter.c
@@ -81,7 +81,7 @@
 
 #define PLUGIN_NAME (_("Bsfilter"))
 
-static guint hook_id = -1;
+static gulong hook_id = HOOK_NONE;
 static MessageCallback message_callback;
 
 static BsfilterConfig config;
@@ -530,7 +530,7 @@ void bsfilter_set_message_callback(MessageCallback callback)
 gint plugin_init(gchar **error)
 {
 	gchar *rcpath;
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 
 	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
 				VERSION_NUMERIC, PLUGIN_NAME, error))
@@ -592,7 +592,7 @@ FolderItem *bsfilter_get_spam_folder(MsgInfo *msginfo)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		bsfilter_unregister_hook();
 	}
 #ifdef USE_PTHREAD
@@ -654,9 +654,9 @@ struct PluginFeature *plugin_provides(void)
 
 void bsfilter_register_hook(void)
 {
-	if (hook_id == (guint) -1)
+	if (hook_id == HOOK_NONE)
 		hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -664,8 +664,8 @@ void bsfilter_register_hook(void)
 
 void bsfilter_unregister_hook(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
 	}
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 }
diff --git a/src/plugins/clamd/clamav_plugin.c b/src/plugins/clamd/clamav_plugin.c
index 8a2736c..7bb3b39 100644
--- a/src/plugins/clamd/clamav_plugin.c
+++ b/src/plugins/clamd/clamav_plugin.c
@@ -46,7 +46,7 @@
 
 #define PLUGIN_NAME (_("Clam AntiVirus"))
 
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 static MessageCallback message_callback;
 
 static ClamAvConfig config;
@@ -276,7 +276,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register mail filtering hook"));
 		return -1;
 	}
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index d5f484c..3df83cd 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -39,7 +39,7 @@ gboolean my_log_hook(gpointer source, gpointer data)
 	return FALSE;
 }
 
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 gint plugin_init(gchar **error)
 {
@@ -48,7 +48,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, my_log_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register log text hook"));
 		return -1;
 	}
diff --git a/src/plugins/fetchinfo/fetchinfo_plugin.c b/src/plugins/fetchinfo/fetchinfo_plugin.c
index bf350dd..032c53c 100644
--- a/src/plugins/fetchinfo/fetchinfo_plugin.c
+++ b/src/plugins/fetchinfo/fetchinfo_plugin.c
@@ -44,7 +44,7 @@
 #include "procheader.h"
 #include "plugin.h"
 
-static guint mail_receive_hook_id;
+static gulong mail_receive_hook_id = HOOK_NONE;
 
 static FetchinfoConfig config;
 
@@ -162,7 +162,7 @@ gint plugin_init(gchar **error)
 		return -1;
 
 	mail_receive_hook_id = hooks_register_hook(MAIL_RECEIVE_HOOKLIST, mail_receive_hook, NULL);
-	if (mail_receive_hook_id == (guint) -1) {
+	if (mail_receive_hook_id == HOOK_NONE) {
 		/* i18n: Possible error message during plugin load */
 		*error = g_strdup(_("Failed to register mail receive hook"));
 		return -1;
diff --git a/src/plugins/gdata/gdata_plugin.c b/src/plugins/gdata/gdata_plugin.c
index 387522d..e623d96 100644
--- a/src/plugins/gdata/gdata_plugin.c
+++ b/src/plugins/gdata/gdata_plugin.c
@@ -42,9 +42,9 @@
 #include "cm_gdata_contacts.h"
 #include "cm_gdata_prefs.h"
 
-static guint hook_address_completion;
-static guint hook_offline_switch;
-static guint timer_query_contacts = 0;
+static gulong hook_address_completion= 0;
+static gulong hook_offline_switch = 0;
+static gulong timer_query_contacts = 0;
 
 static gboolean my_address_completion_build_list_hook(gpointer source, gpointer data)
 {
@@ -104,13 +104,13 @@ gint plugin_init(gchar **error)
 
   hook_address_completion = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST,
       my_address_completion_build_list_hook, NULL);
-  if(hook_address_completion == (guint) -1) {
+  if(hook_address_completion == 0) {
     *error = g_strdup(_("Failed to register address completion hook in the GData plugin"));
     return -1;
   }
 
   hook_offline_switch = hooks_register_hook(OFFLINE_SWITCH_HOOKLIST, my_offline_switch_hook, NULL);
-  if(hook_offline_switch == (guint) -1) {
+  if(hook_offline_switch == 0) {
     hooks_unregister_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, hook_address_completion);
     *error = g_strdup(_("Failed to register offline switch hook in the GData plugin"));
     return -1;
diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c
index b8da96c..f07c6a2 100644
--- a/src/plugins/libravatar/libravatar.c
+++ b/src/plugins/libravatar/libravatar.c
@@ -49,8 +49,8 @@ static const char *def_mode[] = {
 	"retro"
 };
 
-static guint update_hook_id;
-static guint render_hook_id;
+static gulong update_hook_id = HOOK_NONE;
+static gulong render_hook_id = HOOK_NONE;
 static gchar *cache_dir = NULL; /* dir-separator terminated */
 
 static gboolean libravatar_header_update_hook(gpointer source, gpointer data)
@@ -313,15 +313,15 @@ static void missing_cache_done()
 
 static void unregister_hooks()
 {
-	if (render_hook_id != (guint) -1) {
+	if (render_hook_id != HOOK_NONE) {
 		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
 				      render_hook_id);
-		render_hook_id = -1;
+		render_hook_id = HOOK_NONE;
 	}
-	if (update_hook_id != (guint) -1) {
+	if (update_hook_id != HOOK_NONE) {
 		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
 				      update_hook_id);
-		update_hook_id = -1;
+		update_hook_id = HOOK_NONE;
 	}
 }
 
@@ -341,7 +341,7 @@ gint plugin_init(gchar **error)
 	update_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
 					     libravatar_header_update_hook,
 					     NULL);
-	if (update_hook_id == (guint) -1) {
+	if (update_hook_id == HOOK_NONE) {
 		*error = g_strdup(_("Failed to register avatar header update hook"));
 		return -1;
 	}
@@ -349,7 +349,7 @@ gint plugin_init(gchar **error)
 	render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
 					     libravatar_image_render_hook,
 					     NULL);
-	if (render_hook_id == (guint) -1) {
+	if (render_hook_id == HOOK_NONE) {
 		unregister_hooks();
 		*error = g_strdup(_("Failed to register avatar image render hook"));
 		return -1;
diff --git a/src/plugins/newmail/newmail.c b/src/plugins/newmail/newmail.c
index 1d77954..46bc1bc 100644
--- a/src/plugins/newmail/newmail.c
+++ b/src/plugins/newmail/newmail.c
@@ -36,7 +36,7 @@
 #define DEFAULT_DIR	"Mail"
 #define BUFSIZE		2048
 
-static guint hook_id;
+static gulong hook_id = HOOK_NONE;
 
 static FILE *NewLog   = NULL;
 static char *LogName  = NULL;
@@ -107,7 +107,7 @@ gint plugin_init (gchar **error)
 		return -1;
 
 	hook_id = hooks_register_hook (MAIL_POSTFILTERING_HOOKLIST, newmail_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		*error = g_strdup (_("Failed to register newmail hook"));
 		return (-1);
 	}
diff --git a/src/plugins/notification/notification_foldercheck.c b/src/plugins/notification/notification_foldercheck.c
index 80d6898..43e22c9 100644
--- a/src/plugins/notification/notification_foldercheck.c
+++ b/src/plugins/notification/notification_foldercheck.c
@@ -81,7 +81,7 @@ static GdkPixbuf *foldernoselectopen_pixbuf;
 static GArray *specific_folder_array;
 static guint   specific_folder_array_size;
 
-static guint hook_folder_update;
+static gulong hook_folder_update;
 
 
 /* defines */
@@ -139,7 +139,7 @@ guint notification_register_folder_specific_list(gchar *node_name)
     /* "The hook is registered" is bound to "the array is allocated" */
     hook_folder_update = hooks_register_hook(FOLDER_UPDATE_HOOKLIST,
 					     my_folder_update_hook, NULL);
-    if(hook_folder_update == (guint) -1) {
+    if(hook_folder_update == 0) {
       debug_print("Warning: Failed to register hook to folder update "
 		  "hooklist. "
 		  "Strange things can occur when deleting folders.\n");
diff --git a/src/plugins/notification/notification_plugin.c b/src/plugins/notification/notification_plugin.c
index 1cc8c9f..2798e3a 100644
--- a/src/plugins/notification/notification_plugin.c
+++ b/src/plugins/notification/notification_plugin.c
@@ -64,14 +64,14 @@ static gboolean my_update_theme_hook(gpointer, gpointer);
 static gboolean trayicon_startup_idle(gpointer);
 #endif
 
-static guint hook_f_item;
-static guint hook_f;
-static guint hook_m_info;
-static guint hook_offline;
-static guint hook_mw_close;
-static guint hook_got_iconified;
-static guint hook_account;
-static guint hook_theme_changed;
+static gulong hook_f_item;
+static gulong hook_f;
+static gulong hook_m_info;
+static gulong hook_offline;
+static gulong hook_mw_close;
+static gulong hook_got_iconified;
+static gulong hook_account;
+static gulong hook_theme_changed;
 
 #ifdef NOTIFICATION_BANNER
 static GSList* banner_collected_msgs;
@@ -224,7 +224,7 @@ gint plugin_init(gchar **error)
 
   hook_f_item = hooks_register_hook(FOLDER_ITEM_UPDATE_HOOKLIST,
 				    my_folder_item_update_hook, NULL);
-  if(hook_f_item == (guint) -1) {
+  if(hook_f_item == 0) {
     *error = g_strdup(_("Failed to register folder item update hook in the "
 			"Notification plugin"));
     return -1;
@@ -232,7 +232,7 @@ gint plugin_init(gchar **error)
 
   hook_f = hooks_register_hook(FOLDER_UPDATE_HOOKLIST,
 			       my_folder_update_hook, NULL);
-  if(hook_f == (guint) -1) {
+  if(hook_f == 0) {
     *error = g_strdup(_("Failed to register folder update hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -242,7 +242,7 @@ gint plugin_init(gchar **error)
 
   hook_m_info = hooks_register_hook(MSGINFO_UPDATE_HOOKLIST,
 				    my_msginfo_update_hook, NULL);
-  if(hook_m_info == (guint) -1) {
+  if(hook_m_info == 0) {
     *error = g_strdup(_("Failed to register msginfo update hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -252,7 +252,7 @@ gint plugin_init(gchar **error)
 
   hook_offline = hooks_register_hook(OFFLINE_SWITCH_HOOKLIST,
 				     my_offline_switch_hook, NULL);
-  if(hook_offline == (guint) -1) {
+  if(hook_offline == 0) {
     *error = g_strdup(_("Failed to register offline switch hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -263,7 +263,7 @@ gint plugin_init(gchar **error)
 
   hook_mw_close = hooks_register_hook(MAIN_WINDOW_CLOSE,
 				      my_main_window_close_hook, NULL);
-  if(hook_mw_close == (guint) -1) {
+  if(hook_mw_close == 0) {
     *error = g_strdup(_("Failed to register main window close hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -276,7 +276,7 @@ gint plugin_init(gchar **error)
   hook_got_iconified = hooks_register_hook(MAIN_WINDOW_GOT_ICONIFIED,
 					   my_main_window_got_iconified_hook,
 					   NULL);
-  if(hook_got_iconified == (guint) -1) {
+  if(hook_got_iconified == 0) {
     *error = g_strdup(_("Failed to register got iconified hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -289,7 +289,7 @@ gint plugin_init(gchar **error)
 
   hook_account = hooks_register_hook(ACCOUNT_LIST_CHANGED_HOOKLIST,
 				     my_account_list_changed_hook, NULL);
-  if (hook_account == (guint) -1) {
+  if (hook_account == 0) {
     *error = g_strdup(_("Failed to register account list changed hook in the "
 			"Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
@@ -302,7 +302,7 @@ gint plugin_init(gchar **error)
   }
 
   hook_theme_changed = hooks_register_hook(THEME_CHANGED_HOOKLIST, my_update_theme_hook, NULL);
-  if(hook_theme_changed == (guint) -1) {
+  if(hook_theme_changed == 0) {
     *error = g_strdup(_("Failed to register theme change hook in the "
       "Notification plugin"));
     hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
diff --git a/src/plugins/perl/perl_plugin.c b/src/plugins/perl/perl_plugin.c
index 1854eb0..3d68b8a 100644
--- a/src/plugins/perl/perl_plugin.c
+++ b/src/plugins/perl/perl_plugin.c
@@ -90,8 +90,8 @@ EXTERN_C void xs_init(pTHX);
 EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
 
 /* plugin stuff */
-static guint             filtering_hook_id;
-static guint             manual_filtering_hook_id;
+static guint             filtering_hook_id = HOOK_NONE;
+static guint             manual_filtering_hook_id = HOOK_NONE;
 static MailFilteringData *mail_filtering_data  = NULL;
 static MsgInfo           *msginfo              = NULL;
 static gboolean          stop_filtering        = FALSE;
@@ -2290,14 +2290,14 @@ gint plugin_init(gchar **error)
   filtering_hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST,
             my_filtering_hook,
             GUINT_TO_POINTER(AUTO_FILTER));
-  if(filtering_hook_id == (guint) -1) {
+  if(filtering_hook_id == HOOK_NONE) {
     *error = g_strdup("Failed to register mail filtering hook");
     return -1;
   }
   manual_filtering_hook_id = hooks_register_hook(MAIL_MANUAL_FILTERING_HOOKLIST,
              my_filtering_hook,
              GUINT_TO_POINTER(MANU_FILTER));
-  if(manual_filtering_hook_id == (guint) -1) {
+  if(manual_filtering_hook_id == HOOK_NONE) {
     hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, filtering_hook_id);
     *error = g_strdup("Failed to register manual mail filtering hook");
     return -1;
diff --git a/src/plugins/pgpcore/autocompletion.c b/src/plugins/pgpcore/autocompletion.c
index a4f15a6..c3d853f 100644
--- a/src/plugins/pgpcore/autocompletion.c
+++ b/src/plugins/pgpcore/autocompletion.c
@@ -39,7 +39,7 @@
 #include "hooks.h"
 #include "utils.h"
 
-static guint autocompletion_hook_id = 0;
+static gulong autocompletion_hook_id = HOOK_NONE;
 
 static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
 {
@@ -116,7 +116,7 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
 
 gboolean autocompletion_done(void)
 {
-	if (autocompletion_hook_id > 0)
+	if (autocompletion_hook_id != HOOK_NONE)
 	{
 		hooks_unregister_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, autocompletion_hook_id);
 
@@ -128,7 +128,7 @@ gboolean autocompletion_done(void)
 
 gint autocompletion_init(gchar ** error)
 {
-	if ((autocompletion_hook_id = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, pgp_autocompletion_hook, NULL)) == -1)
+	if ((autocompletion_hook_id = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, pgp_autocompletion_hook, NULL)) == HOOK_NONE)
 	{
 		*error = g_strdup(_("Failed to register PGP address autocompletion hook"));
 		return -1;
diff --git a/src/plugins/python/python_plugin.c b/src/plugins/python/python_plugin.c
index 1634a76..dc8b1d6 100644
--- a/src/plugins/python/python_plugin.c
+++ b/src/plugins/python/python_plugin.c
@@ -56,7 +56,7 @@ static GSList *python_compose_scripts_names = NULL;
 
 static GtkWidget *python_console = NULL;
 
-static guint hook_compose_create;
+static gulong hook_compose_create = 0;
 
 static gboolean python_console_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
@@ -653,7 +653,7 @@ gint plugin_init(gchar **error)
 
   /* load hooks */
   hook_compose_create = hooks_register_hook(COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL);
-  if(hook_compose_create == (guint) -1) {
+  if(hook_compose_create == 0) {
     *error = g_strdup(_("Failed to register \"compose create hook\" in the Python plugin"));
     return -1;
   }
diff --git a/src/plugins/spamassassin/spamassassin.c b/src/plugins/spamassassin/spamassassin.c
index 84aa9a6..5df6de1 100644
--- a/src/plugins/spamassassin/spamassassin.c
+++ b/src/plugins/spamassassin/spamassassin.c
@@ -81,7 +81,7 @@ enum {
     TIMEOUT_RUNNING = 1 << 1,
 };
 
-static guint hook_id = -1;
+static gulong hook_id = HOOK_NONE;
 static int flags = SPAMC_RAW_MODE | SPAMC_SAFE_FALLBACK | SPAMC_CHECK_ONLY;
 static MessageCallback message_callback;
 
@@ -513,7 +513,7 @@ gboolean spamassassin_check_username(void)
 	if (config.username == NULL || config.username[0] == '\0') {
 		config.username = (gchar*)g_get_user_name();
 		if (config.username == NULL) {
-			if (hook_id != (guint) -1) {
+			if (hook_id != HOOK_NONE) {
 				spamassassin_unregister_hook();
 			}
 			procmsg_unregister_spam_learner(spamassassin_learn);
@@ -533,7 +533,7 @@ gint plugin_init(gchar **error)
 {
 	gchar *rcpath;
 
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 
 	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
 				VERSION_NUMERIC, PLUGIN_NAME, error))
@@ -571,7 +571,7 @@ gint plugin_init(gchar **error)
 
 gboolean plugin_done(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		spamassassin_unregister_hook();
 	}
 	g_free(config.hostname);
@@ -629,9 +629,9 @@ struct PluginFeature *plugin_provides(void)
 
 void spamassassin_register_hook(void)
 {
-	if (hook_id == (guint) -1)
+	if (hook_id == HOOK_NONE)
 		hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
-	if (hook_id == (guint) -1) {
+	if (hook_id == HOOK_NONE) {
 		g_warning("Failed to register mail filtering hook");
 		config.process_emails = FALSE;
 	}
@@ -639,10 +639,10 @@ void spamassassin_register_hook(void)
 
 void spamassassin_unregister_hook(void)
 {
-	if (hook_id != (guint) -1) {
+	if (hook_id != HOOK_NONE) {
 		hooks_unregister_hook(MAIL_FILTERING_HOOKLIST, hook_id);
 	}
-	hook_id = -1;
+	hook_id = HOOK_NONE;
 }
 
 FolderItem *spamassassin_get_spam_folder(MsgInfo *msginfo)
@@ -670,4 +670,3 @@ FolderItem *spamassassin_get_spam_folder(MsgInfo *msginfo)
 	debug_print("SA spam dir: %s\n", folder_item_get_path(item));
 	return item;
 }
-
diff --git a/src/procheader.c b/src/procheader.c
index d261642..174e283 100644
--- a/src/procheader.c
+++ b/src/procheader.c
@@ -588,7 +588,7 @@ static gboolean avatar_from_some_face(gpointer source, gpointer userdata)
 	return FALSE;
 }
 
-static guint avatar_hook_id = 0;
+static gulong avatar_hook_id = HOOK_NONE;
 
 static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 			     gboolean full, gboolean decrypted)
@@ -644,11 +644,11 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 	
 	msginfo->inreplyto = NULL;
 
-	if (avatar_hook_id == 0 && (prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
+	if (avatar_hook_id == HOOK_NONE && (prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
 		avatar_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST, avatar_from_some_face, NULL);
-	} else if (avatar_hook_id != 0 && !(prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
+	} else if (avatar_hook_id != HOOK_NONE && !(prefs_common.enable_avatars & AVATARS_ENABLE_CAPTURE)) {
 		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST, avatar_hook_id);
-		avatar_hook_id = 0;
+		avatar_hook_id = HOOK_NONE;
 	}
 
 	while ((hnum = get_one_field(&buf, data, hentry)) != -1) {
diff --git a/src/statusbar.c b/src/statusbar.c
index 12fdb1d..3d59c45 100644
--- a/src/statusbar.c
+++ b/src/statusbar.c
@@ -37,7 +37,7 @@
 #define BUFFSIZE 1024
 
 static GList *statusbar_list = NULL;
-guint statusbar_puts_all_hook_id = -1;
+static gulong statusbar_puts_all_hook_id = HOOK_NONE;
 
 GtkWidget *statusbar_create(void)
 {
@@ -149,12 +149,12 @@ static gboolean statusbar_puts_all_hook (gpointer source, gpointer data)
 
 void statusbar_verbosity_set(gboolean verbose)
 {
-	if (verbose && (statusbar_puts_all_hook_id == (guint) -1)) {
+	if (verbose && (statusbar_puts_all_hook_id == HOOK_NONE)) {
 		statusbar_puts_all_hook_id =
 			hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, statusbar_puts_all_hook, NULL);
-	} else if (!verbose && (statusbar_puts_all_hook_id != (guint) -1)) {
+	} else if (!verbose && (statusbar_puts_all_hook_id != HOOK_NONE)) {
 		hooks_unregister_hook(LOG_APPEND_TEXT_HOOKLIST, statusbar_puts_all_hook_id);
-		statusbar_puts_all_hook_id = -1;
+		statusbar_puts_all_hook_id = HOOK_NONE;
 		statusbar_pop_all();
 	}
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list