From 68b391b5c17420988118f2152d90832472bbfc0b Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 8 Jun 2011 02:20:00 +0000 Subject: added a new plug-in API: 'compose-send'. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2886 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 7 +++++++ PLUGIN.txt | 2 +- plugin/test/test.c | 16 ++++++++++++++++ src/compose.c | 24 ++++++++++++++++++++++++ src/plugin-marshal.list | 1 + src/plugin.c | 15 +++++++++++++++ src/plugin.h | 9 ++++++++- 7 files changed, 72 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce821393..847513f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-06-08 + + * src/compose.c + src/plugin.[ch] + src/plugin-marshal.list + plugin/test/test.c: added a new plug-in API: "compose-send". + 2011-06-06 * src/compose.c: compose_generate_msgid(): don't use mailbox part diff --git a/PLUGIN.txt b/PLUGIN.txt index 990e23b8..12bdef82 100644 --- a/PLUGIN.txt +++ b/PLUGIN.txt @@ -276,7 +276,7 @@ following process: 'Click this button' is displayed. When it is clicked, a message is displayed - Capture the following events and show messages: application initialization and exiting, folder view context menu popup, creating and destroying compose - window + window, sending messages - Capture the text view context menu popup event and add a menu item Attachment Tool Plug-in diff --git a/plugin/test/test.c b/plugin/test/test.c index 858f2f35..99fbecd4 100644 --- a/plugin/test/test.c +++ b/plugin/test/test.c @@ -51,6 +51,9 @@ static void menu_selected_cb(void); static void compose_created_cb(GObject *obj, gpointer compose); static void compose_destroy_cb(GObject *obj, gpointer compose); +static gboolean compose_send_cb(GObject *obj, gpointer compose, + gint compose_mode, gint send_mode, + const gchar *msg_file, GSList *to_list); static void create_window(void); static void create_folderview_sub_widget(void); @@ -100,6 +103,8 @@ void plugin_load(void) G_CALLBACK(compose_created_cb), NULL); syl_plugin_signal_connect("compose-destroy", G_CALLBACK(compose_destroy_cb), NULL); + syl_plugin_signal_connect("compose-send", + G_CALLBACK(compose_send_cb), NULL); syl_plugin_add_factory_item("", "/---", NULL, NULL); syl_plugin_add_factory_item("", "/Test Plug-in menu", @@ -219,6 +224,17 @@ static void compose_destroy_cb(GObject *obj, gpointer compose) g_print("test: %p: compose will be destroyed (%p)\n", obj, compose); } +static gboolean compose_send_cb(GObject *obj, gpointer compose, + gint compose_mode, gint send_mode, + const gchar *msg_file, GSList *to_list) +{ + g_print("test: %p: composed message will be sent (%p)\n", obj, compose); + g_print("test: compose_mode: %d, send_mode: %d, file: %s\n", + compose_mode, send_mode, msg_file); + + return TRUE; /* return FALSE to cancel sending */ +} + static void button_clicked(GtkWidget *widget, gpointer data) { g_print("button_clicked\n"); diff --git a/src/compose.c b/src/compose.c index 79e2fd91..32858e15 100644 --- a/src/compose.c +++ b/src/compose.c @@ -3444,6 +3444,7 @@ static gint compose_send(Compose *compose) { gchar tmp[MAXPATHLEN + 1]; gint ok = 0; + gboolean ack = TRUE; if (compose->lock_count > 0) return 1; @@ -3488,6 +3489,14 @@ static gint compose_send(Compose *compose) if (!compose->to_list && !compose->newsgroup_list) { g_warning(_("can't get recipient list.")); + g_unlink(tmp); + compose_unlock(compose); + return 1; + } + + syl_plugin_signal_emit("compose-send", compose, compose->mode, 0, + tmp, compose->to_list, &ack); + if (ack == FALSE) { g_unlink(tmp); compose_unlock(compose); return -1; @@ -7204,6 +7213,7 @@ static void compose_send_later_cb(gpointer data, guint action, Compose *compose = (Compose *)data; FolderItem *queue; gchar tmp[MAXPATHLEN + 1]; + gboolean ack = TRUE; if (compose_check_entries(compose) == FALSE) return; @@ -7236,8 +7246,22 @@ static void compose_send_later_cb(gpointer data, guint action, } } + if (!compose->to_list && !compose->newsgroup_list) { + g_warning("can't get recipient list."); + g_unlink(tmp); + return; + } + + syl_plugin_signal_emit("compose-send", compose, compose->mode, 1, + tmp, compose->to_list, &ack); + if (ack == FALSE) { + g_unlink(tmp); + return; + } + if (compose_queue(compose, tmp) < 0) { alertpanel_error(_("Can't queue the message.")); + g_unlink(tmp); return; } diff --git a/src/plugin-marshal.list b/src/plugin-marshal.list index 3eb1e2b6..2f6032ae 100644 --- a/src/plugin-marshal.list +++ b/src/plugin-marshal.list @@ -1,2 +1,3 @@ VOID:POINTER VOID:POINTER,POINTER,STRING,STRING,POINTER +BOOLEAN:POINTER,INT,INT,STRING,POINTER diff --git a/src/plugin.c b/src/plugin.c index 8b5ea643..9e152cd1 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -36,6 +36,7 @@ enum { COMPOSE_CREATED, COMPOSE_DESTROY, TEXTVIEW_MENU_POPUP, + COMPOSE_SEND, LAST_SIGNAL }; @@ -172,6 +173,20 @@ static void syl_plugin_class_init(SylPluginClass *klass) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); + plugin_signals[COMPOSE_SEND] = + g_signal_new("compose-send", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(SylPluginClass, compose_send), + NULL, NULL, + syl_plugin_marshal_BOOLEAN__POINTER_INT_INT_STRING_POINTER, + G_TYPE_BOOLEAN, + 5, + G_TYPE_POINTER, + G_TYPE_INT, + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_POINTER); } void syl_plugin_signal_connect(const gchar *name, GCallback callback, diff --git a/src/plugin.h b/src/plugin.h index 26b03242..65497882 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 0x0107 +#define SYL_PLUGIN_INTERFACE_VERSION 0x0108 struct _SylPlugin { @@ -71,6 +71,13 @@ struct _SylPluginClass const gchar *uri, const gchar *selected_text, MsgInfo *msginfo); + + gboolean (* compose_send) (GObject *obj, + gpointer compose, + gint compose_mode, + gint send_mode, + const gchar *msg_file, + GSList *to_list); }; struct _SylPluginInfo -- cgit v1.2.3