From 07d534bd00afb989cfd472eb22f463d31be71b03 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 6 Jan 2012 08:42:40 +0000 Subject: added new plug-in signals to notify start and end of receiving. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3005 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 10 ++++++++++ plugin/test/test.c | 21 ++++++++++++++++++++- src/inc.c | 9 +++++++++ src/plugin-marshal.list | 1 + src/plugin.c | 22 ++++++++++++++++++++++ src/plugin.h | 7 ++++++- 6 files changed, 68 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index efe63fb6..5ad425d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2012-01-06 + + * src/inc.c + src/plugin.[ch] + src/plugin-marshal.list + plugin/test/test.c: added new plug-in signals: + "inc-mail-start": notify start of receiving + "inc-mail-finished": notify end of receiving and number of new + messages + 2012-01-06 * src/trayicon.c: extended the blinking period of tray icon to 10 diff --git a/plugin/test/test.c b/plugin/test/test.c index 7a2b4631..a7e63ebe 100644 --- a/plugin/test/test.c +++ b/plugin/test/test.c @@ -28,7 +28,7 @@ static SylPluginInfo info = { "Test Plugin", - "3.1.0", + "3.2.0", "Hiroyuki Yamamoto", "Test plug-in for Sylpheed plug-in system" }; @@ -56,6 +56,8 @@ static gboolean compose_send_cb(GObject *obj, gpointer compose, const gchar *msg_file, GSList *to_list); static void messageview_show_cb(GObject *obj, gpointer msgview, MsgInfo *msginfo, gboolean all_headers); +static void inc_start_cb(GObject *obj, PrefsAccount *ac); +static void inc_finished_cb(GObject *obj, gint new_messages); static void create_window(void); static void create_folderview_sub_widget(void); @@ -109,6 +111,10 @@ void plugin_load(void) G_CALLBACK(compose_send_cb), NULL); syl_plugin_signal_connect("messageview-show", G_CALLBACK(messageview_show_cb), NULL); + syl_plugin_signal_connect("inc-mail-start", + G_CALLBACK(inc_start_cb), NULL); + syl_plugin_signal_connect("inc-mail-finished", + G_CALLBACK(inc_finished_cb), NULL); syl_plugin_add_factory_item("", "/---", NULL, NULL); syl_plugin_add_factory_item("", "/Test Plug-in menu", @@ -247,6 +253,19 @@ static void messageview_show_cb(GObject *obj, gpointer msgview, msginfo && msginfo->subject ? msginfo->subject : ""); } +static void inc_start_cb(GObject *obj, PrefsAccount *ac) +{ + if (ac) + g_print("test: receive start: account: %s\n", ac->account_name); + else + g_print("test: receive start: all accounts\n"); +} + +static void inc_finished_cb(GObject *obj, gint new_messages) +{ + g_print("test: received %d new messages\n", new_messages); +} + static void button_clicked(GtkWidget *widget, gpointer data) { g_print("button_clicked\n"); diff --git a/src/inc.c b/src/inc.c index 661aa394..9f16004d 100644 --- a/src/inc.c +++ b/src/inc.c @@ -61,6 +61,7 @@ #include "filter.h" #include "folder.h" #include "procheader.h" +#include "plugin.h" static GList *inc_dialog_list = NULL; @@ -167,6 +168,8 @@ static void inc_finished(MainWindow *mainwin, gint new_messages) trayicon_set_notify(TRUE); } + syl_plugin_signal_emit("inc-mail-finished", new_messages); + inc_block_notify(FALSE); if (new_messages <= 0 && !prefs_common.scan_all_after_inc) return; @@ -213,6 +216,8 @@ void inc_mail(MainWindow *mainwin) summary_write_cache(mainwin->summaryview); main_window_lock(mainwin); + syl_plugin_signal_emit("inc-mail-start", cur_account); + if (prefs_common.use_extinc && prefs_common.extinc_cmd) { /* external incorporating program */ if (execute_command_line(prefs_common.extinc_cmd, FALSE) != 0) { @@ -406,6 +411,8 @@ gint inc_account_mail(MainWindow *mainwin, PrefsAccount *account) summary_write_cache(mainwin->summaryview); main_window_lock(mainwin); + syl_plugin_signal_emit("inc-mail-start", account); + new_msgs = inc_account_mail_real(mainwin, account); inc_finished(mainwin, new_msgs); @@ -431,6 +438,8 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean autocheck) summary_write_cache(mainwin->summaryview); main_window_lock(mainwin); + syl_plugin_signal_emit("inc-mail-start", NULL); + if (prefs_common.inc_local) { new_msgs = inc_spool(); if (new_msgs < 0) diff --git a/src/plugin-marshal.list b/src/plugin-marshal.list index 07b7f3de..7ae8571e 100644 --- a/src/plugin-marshal.list +++ b/src/plugin-marshal.list @@ -2,3 +2,4 @@ VOID:POINTER VOID:POINTER,POINTER,STRING,STRING,POINTER BOOLEAN:POINTER,INT,INT,STRING,POINTER VOID:POINTER,POINTER,BOOLEAN +VOID:INT diff --git a/src/plugin.c b/src/plugin.c index 666a4fb2..c3be1255 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -38,6 +38,8 @@ enum { TEXTVIEW_MENU_POPUP, COMPOSE_SEND, MESSAGEVIEW_SHOW, + INC_MAIL_START, + INC_MAIL_FINISHED, LAST_SIGNAL }; @@ -200,6 +202,26 @@ static void syl_plugin_class_init(SylPluginClass *klass) G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_BOOLEAN); + plugin_signals[INC_MAIL_START] = + g_signal_new("inc-mail-start", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SylPluginClass, inc_mail_start), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); + plugin_signals[INC_MAIL_FINISHED] = + g_signal_new("inc-mail-finished", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SylPluginClass, inc_mail_finished), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, + G_TYPE_INT); } void syl_plugin_signal_connect(const gchar *name, GCallback callback, diff --git a/src/plugin.h b/src/plugin.h index f966fd69..c9bd3830 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -45,7 +45,7 @@ typedef void (*SylPluginLoadFunc) (void); typedef void (*SylPluginUnloadFunc) (void); typedef void (*SylPluginCallbackFunc) (void); -#define SYL_PLUGIN_INTERFACE_VERSION 0x0108 +#define SYL_PLUGIN_INTERFACE_VERSION 0x0109 struct _SylPlugin { @@ -83,6 +83,11 @@ struct _SylPluginClass gpointer msgview, MsgInfo *msginfo, gboolean all_headers); + + void (* inc_mail_start) (GObject *obj, + PrefsAccount *account); + void (* inc_mail_finished) (GObject *obj, + gint new_messages); }; struct _SylPluginInfo -- cgit v1.2.3