aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mailing-list-actions
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mailing-list-actions')
-rw-r--r--plugins/mailing-list-actions/Makefile.am5
-rw-r--r--plugins/mailing-list-actions/mailing-list-actions.c262
-rw-r--r--plugins/mailing-list-actions/org-gnome-mailing-list-actions.eplug.xml92
-rw-r--r--plugins/mailing-list-actions/org-gnome-mailing-list-actions.xml25
4 files changed, 263 insertions, 121 deletions
diff --git a/plugins/mailing-list-actions/Makefile.am b/plugins/mailing-list-actions/Makefile.am
index 80dc122e40..7f205a19b1 100644
--- a/plugins/mailing-list-actions/Makefile.am
+++ b/plugins/mailing-list-actions/Makefile.am
@@ -6,7 +6,7 @@ AM_CPPFLAGS = \
@EVO_PLUGIN_RULE@
-plugin_DATA = org-gnome-mailing-list-actions.eplug org-gnome-mailing-list-actions.xml
+plugin_DATA = org-gnome-mailing-list-actions.eplug
plugin_LTLIBRARIES = liborg-gnome-mailing-list-actions.la
liborg_gnome_mailing_list_actions_la_SOURCES = mailing-list-actions.c
@@ -27,7 +27,6 @@ CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
org-gnome-mailing-list-actions.eplug.xml \
- org-gnome-mailing-list-actions.error.xml \
- org-gnome-mailing-list-actions.xml
+ org-gnome-mailing-list-actions.error.xml
-include $(top_srcdir)/git.mk
diff --git a/plugins/mailing-list-actions/mailing-list-actions.c b/plugins/mailing-list-actions/mailing-list-actions.c
index f3ca8d1651..428bb187a7 100644
--- a/plugins/mailing-list-actions/mailing-list-actions.c
+++ b/plugins/mailing-list-actions/mailing-list-actions.c
@@ -35,16 +35,28 @@
#include "camel/camel-exception.h"
#include "camel/camel-folder.h"
#include "composer/e-msg-composer.h"
+#include "mail/e-mail-browser.h"
+#include "mail/e-mail-reader.h"
#include "mail/em-composer-utils.h"
#include "mail/em-format-hook.h"
-#include "mail/em-format.h"
-#include "mail/em-menu.h"
#include "mail/em-config.h"
+#include "mail/em-utils.h"
#include "mail/mail-ops.h"
#include "mail/mail-mt.h"
#include "mail/mail-config.h"
#include "e-util/e-util.h"
#include "e-util/e-error.h"
+#include "shell/e-shell-view.h"
+#include "shell/e-shell-window.h"
+#include "shell/e-shell-window-actions.h"
+
+/* EError Message IDs */
+#define MESSAGE_PREFIX "org.gnome.mailing-list-actions:"
+#define MESSAGE_NO_ACTION MESSAGE_PREFIX "no-action"
+#define MESSAGE_NO_HEADER MESSAGE_PREFIX "no-header"
+#define MESSAGE_ASK_SEND_MESSAGE MESSAGE_PREFIX "ask-send-message"
+#define MESSAGE_MALFORMED_HEADER MESSAGE_PREFIX "malformed-header"
+#define MESSAGE_POSTING_NOT_ALLOWED MESSAGE_PREFIX "posting-not-allowed"
typedef enum {
EMLA_ACTION_HELP,
@@ -70,38 +82,22 @@ const EmlaActionHeader emla_action_headers[] = {
{ EMLA_ACTION_ARCHIVE, FALSE, "List-Archive" },
};
-const gint emla_n_action_headers = sizeof(emla_action_headers) / sizeof(EmlaActionHeader);
-
-void emla_list_action (EPlugin *item, EMMenuTargetSelect* sel, EmlaAction action);
-void emla_list_help (EPlugin *item, EMMenuTargetSelect* sel);
-void emla_list_unsubscribe (EPlugin *item, EMMenuTargetSelect* sel);
-void emla_list_subscribe (EPlugin *item, EMMenuTargetSelect* sel);
-void emla_list_post (EPlugin *item, EMMenuTargetSelect* sel);
-void emla_list_owner (EPlugin *item, EMMenuTargetSelect* sel);
-void emla_list_archive (EPlugin *item, EMMenuTargetSelect* sel);
-
-void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data);
+gboolean mail_browser_init (GtkUIManager *ui_manager,
+ EMailBrowser *browser);
+gboolean mail_shell_view_init (GtkUIManager *ui_manager,
+ EShellView *shell_view);
typedef struct {
+ EMailReader *reader;
EmlaAction action;
gchar * uri;
} emla_action_data;
-void emla_list_action (EPlugin *item, EMMenuTargetSelect* sel, EmlaAction action)
-{
- emla_action_data *data;
-
- g_return_if_fail (sel->uids->len == 1);
-
- data = (emla_action_data *) malloc (sizeof (emla_action_data));
- data->action = action;
- data->uri = strdup (sel->uri);
-
- mail_get_message (sel->folder, (const gchar *) g_ptr_array_index (sel->uids, 0),
- emla_list_action_do, data, mail_msg_unordered_push);
-}
-
-void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data)
+static void
+emla_list_action_do (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *msg,
+ gpointer data)
{
emla_action_data *action_data = (emla_action_data *) data;
EmlaAction action = action_data->action;
@@ -111,11 +107,14 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
EMsgComposer *composer;
gint send_message_response;
EAccount *account;
+ GtkWindow *parent;
if (msg == NULL)
return;
- for (t = 0; t < emla_n_action_headers; t++) {
+ parent = e_mail_reader_get_window (action_data->reader);
+
+ for (t = 0; t < G_N_ELEMENTS (emla_action_headers); t++) {
if (emla_action_headers[t].action == action &&
(header = camel_medium_get_header (CAMEL_MEDIUM (msg), emla_action_headers[t].header)) != NULL)
break;
@@ -123,7 +122,7 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
if (!header) {
/* there was no header matching the action */
- e_error_run (NULL, "org.gnome.mailing-list-actions:no-header", NULL);
+ e_error_run (parent, MESSAGE_NO_HEADER, NULL);
goto exit;
}
@@ -132,7 +131,7 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
if (action == EMLA_ACTION_POST) {
while (*headerpos == ' ') headerpos++;
if (g_ascii_strcasecmp (headerpos, "NO") == 0) {
- e_error_run (NULL, "org.gnome.mailing-list-actions:posting-not-allowed", NULL);
+ e_error_run (parent, MESSAGE_POSTING_NOT_ALLOWED, NULL);
goto exit;
}
}
@@ -142,7 +141,9 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
/* skip whitespace */
while (*headerpos == ' ') headerpos++;
if (*headerpos != '<' || (end = strchr (headerpos++, '>')) == NULL) {
- e_error_run (NULL, "org.gnome.mailing-list-actions:malformed-header", emla_action_headers[t].header, header, NULL);
+ e_error_run (
+ parent, MESSAGE_MALFORMED_HEADER,
+ emla_action_headers[t].header, header, NULL);
goto exit;
}
@@ -153,7 +154,9 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
if (emla_action_headers[t].interactive)
send_message_response = GTK_RESPONSE_NO;
else
- send_message_response = e_error_run (NULL, "org.gnome.mailing-list-actions:ask-send-message", url, NULL);
+ send_message_response = e_error_run (
+ parent, MESSAGE_ASK_SEND_MESSAGE,
+ url, NULL);
if (send_message_response == GTK_RESPONSE_YES) {
/* directly send message */
@@ -162,7 +165,7 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
e_composer_header_table_set_account (
e_msg_composer_get_header_table (composer),
account);
- em_utils_composer_send_cb (composer, NULL);
+ e_msg_composer_send (composer);
} else if (send_message_response == GTK_RESPONSE_NO) {
/* show composer */
em_utils_compose_new_message_with_mailto (url, action_data->uri);
@@ -170,8 +173,7 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
goto exit;
} else {
- /* FIXME Pass a parent window. */
- e_show_uri (NULL, url);
+ e_show_uri (parent, url);
goto exit;
}
g_free (url);
@@ -186,40 +188,196 @@ void emla_list_action_do (CamelFolder *folder, const gchar *uid, CamelMimeMessag
}
/* if we got here, there's no valid action */
- e_error_run (NULL, "org.gnome.mailing-list-actions:no-action", header, NULL);
+ e_error_run (parent, MESSAGE_NO_ACTION, header, NULL);
exit:
- free (action_data->uri);
- free (action_data);
- g_free(url);
+ g_object_unref (action_data->reader);
+ g_free (action_data->uri);
+ g_free (action_data);
+ g_free (url);
+}
+
+static void
+emla_list_action (EMailReader *reader,
+ EmlaAction action)
+{
+ MessageList *message_list;
+ CamelFolder *folder;
+ GPtrArray *uids;
+ emla_action_data *data;
+ const gchar *folder_uri;
+
+ message_list = e_mail_reader_get_message_list (reader);
+
+ folder = message_list->folder;
+ folder_uri = message_list->folder_uri;
+ uids = message_list_get_selected (message_list);
+ g_return_if_fail (uids->len == 1);
+
+ data = g_malloc (sizeof (emla_action_data));
+ data->reader = g_object_ref (reader);
+ data->action = action;
+ data->uri = g_strdup (folder_uri);
+
+ mail_get_message (
+ folder, uids->pdata[0],
+ emla_list_action_do, data,
+ mail_msg_unordered_push);
+
+ em_utils_uids_free (uids);
+}
+
+static void
+action_mailing_list_archive_cb (GtkAction *action,
+ EMailReader *reader)
+{
+ emla_list_action (reader, EMLA_ACTION_ARCHIVE);
+}
+
+static void
+action_mailing_list_help_cb (GtkAction *action,
+ EMailReader *reader)
+{
+ emla_list_action (reader, EMLA_ACTION_HELP);
+}
+
+static void
+action_mailing_list_owner_cb (GtkAction *action,
+ EMailReader *reader)
+{
+ emla_list_action (reader, EMLA_ACTION_OWNER);
}
-void emla_list_help (EPlugin *item, EMMenuTargetSelect* sel)
+static void
+action_mailing_list_post_cb (GtkAction *action,
+ EMailReader *reader)
{
- emla_list_action (item, sel, EMLA_ACTION_HELP);
+ emla_list_action (reader, EMLA_ACTION_POST);
}
-void emla_list_unsubscribe (EPlugin *item, EMMenuTargetSelect* sel)
+static void
+action_mailing_list_subscribe_cb (GtkAction *action,
+ EMailReader *reader)
{
- emla_list_action (item, sel, EMLA_ACTION_UNSUBSCRIBE);
+ emla_list_action (reader, EMLA_ACTION_SUBSCRIBE);
}
-void emla_list_subscribe (EPlugin *item, EMMenuTargetSelect* sel)
+static void
+action_mailing_list_unsubscribe_cb (GtkAction *action,
+ EMailReader *reader)
{
- emla_list_action (item, sel, EMLA_ACTION_SUBSCRIBE);
+ emla_list_action (reader, EMLA_ACTION_UNSUBSCRIBE);
}
-void emla_list_post (EPlugin *item, EMMenuTargetSelect* sel)
+static GtkActionEntry mailing_list_entries[] = {
+
+ { "mailing-list-archive",
+ NULL,
+ N_("Get List _Archive"),
+ NULL,
+ N_("Get an archive of the list this message belongs to"),
+ G_CALLBACK (action_mailing_list_archive_cb) },
+
+ { "mailing-list-help",
+ NULL,
+ N_("Get List _Usage Information"),
+ NULL,
+ N_("Get information about the usage of the list this message belongs to"),
+ G_CALLBACK (action_mailing_list_help_cb) },
+
+ { "mailing-list-owner",
+ NULL,
+ N_("Contact List _Owner"),
+ NULL,
+ N_("Contact the owner of the mailing list this message belongs to"),
+ G_CALLBACK (action_mailing_list_owner_cb) },
+
+ { "mailing-list-post",
+ NULL,
+ N_("_Post Message to List"),
+ NULL,
+ N_("Post a message to the mailing list this message belongs to"),
+ G_CALLBACK (action_mailing_list_post_cb) },
+
+ { "mailing-list-subscribe",
+ NULL,
+ N_("_Subscribe to List"),
+ NULL,
+ N_("Subscribe to the mailing list this message belongs to"),
+ G_CALLBACK (action_mailing_list_subscribe_cb) },
+
+ { "mailing-list-unsubscribe",
+ NULL,
+ N_("_Unsubscribe from List"),
+ NULL,
+ N_("Unsubscribe from the mailing list this message belongs to"),
+ G_CALLBACK (action_mailing_list_unsubscribe_cb) },
+
+ /*** Menus ***/
+
+ { "mailing-list-menu",
+ NULL,
+ N_("Mailing _List"),
+ NULL,
+ NULL,
+ NULL }
+};
+
+static void
+update_actions_cb (EMailReader *reader,
+ GtkActionGroup *action_group)
+{
+ gboolean sensitive;
+ guint32 state;
+
+ state = e_mail_reader_check_state (reader);
+ sensitive = (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST);
+ gtk_action_group_set_sensitive (action_group, sensitive);
+}
+
+static void
+setup_actions (EMailReader *reader,
+ GtkUIManager *ui_manager)
{
- emla_list_action (item, sel, EMLA_ACTION_POST);
+ GtkActionGroup *action_group;
+ const gchar *domain = GETTEXT_PACKAGE;
+
+ action_group = gtk_action_group_new ("mailing-list");
+ gtk_action_group_set_translation_domain (action_group, domain);
+ gtk_action_group_add_actions (
+ action_group, mailing_list_entries,
+ G_N_ELEMENTS (mailing_list_entries), reader);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ g_object_unref (action_group);
+
+ /* GtkUIManager now owns the action group reference.
+ * The signal we're connecting to will only be emitted
+ * during the GtkUIManager's lifetime, so the action
+ * group will not disappear on us. */
+
+ g_signal_connect (
+ reader, "update-actions",
+ G_CALLBACK (update_actions_cb), action_group);
}
-void emla_list_owner (EPlugin *item, EMMenuTargetSelect* sel)
+gboolean
+mail_browser_init (GtkUIManager *ui_manager,
+ EMailBrowser *browser)
{
- emla_list_action (item, sel, EMLA_ACTION_OWNER);
+ setup_actions (E_MAIL_READER (browser), ui_manager);
+
+ return TRUE;
}
-void emla_list_archive (EPlugin *item, EMMenuTargetSelect* sel)
+gboolean
+mail_shell_view_init (GtkUIManager *ui_manager,
+ EShellView *shell_view)
{
- emla_list_action (item, sel, EMLA_ACTION_ARCHIVE);
+ EShellContent *shell_content;
+
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ setup_actions (E_MAIL_READER (shell_content), ui_manager);
+
+ return TRUE;
}
diff --git a/plugins/mailing-list-actions/org-gnome-mailing-list-actions.eplug.xml b/plugins/mailing-list-actions/org-gnome-mailing-list-actions.eplug.xml
index 7b0861c70e..464ade9053 100644
--- a/plugins/mailing-list-actions/org-gnome-mailing-list-actions.eplug.xml
+++ b/plugins/mailing-list-actions/org-gnome-mailing-list-actions.eplug.xml
@@ -1,44 +1,54 @@
<?xml version="1.0"?>
<e-plugin-list>
- <e-plugin
- type="shlib"
- id="org.gnome.plugin.mailing-list.actions"
- domain="@GETTEXT_PACKAGE@"
- location="@PLUGINDIR@/liborg-gnome-mailing-list-actions@SOEXT@"
- _name="Mailing List Actions">
- <author name="Meilof Veeningen" email="meilof@wanadoo.nl"/>
- <_description>Perform common mailing list actions (subscribe, unsubscribe, etc.).</_description>
- <hook class="org.gnome.evolution.mail.bonobomenu:1.0">
- <menu id="org.gnome.evolution.mail.browser" target="select">
- <ui file="@PLUGINDIR@/org-gnome-mailing-list-actions.xml"/>
- <item type="item" verb="ListHelp" path="/commands/ListHelp" enable="mailing_list" activate="emla_list_help"/>
- <item type="item" verb="ListSubscribe" path="/commands/ListSubscribe" enable="mailing_list" activate="emla_list_subscribe"/>
- <item type="item" verb="ListUnsubscribe" path="/commands/ListUnsubscribe" enable="mailing_list" activate="emla_list_unsubscribe"/>
- <item type="item" verb="ListPost" path="/commands/ListPost" enable="mailing_list" activate="emla_list_post"/>
- <item type="item" verb="ListOwner" path="/commands/ListOwner" enable="mailing_list" activate="emla_list_owner"/>
- <item type="item" verb="ListArchive" path="/commands/ListArchive" enable="mailing_list" activate="emla_list_archive"/>
- </menu>
- <menu id="org.gnome.evolution.mail.messagebrowser" target="select">
- <ui file="@PLUGINDIR@/org-gnome-mailing-list-actions.xml"/>
- <item type="item" verb="ListHelp" path="/commands/ListHelp" enable="mailing_list" activate="emla_list_help"/>
- <item type="item" verb="ListSubscribe" path="/commands/ListSubscribe" enable="mailing_list" activate="emla_list_subscribe"/>
- <item type="item" verb="ListUnsubscribe" path="/commands/ListUnsubscribe" enable="mailing_list" activate="emla_list_unsubscribe"/>
- <item type="item" verb="ListPost" path="/commands/ListPost" enable="mailing_list" activate="emla_list_post"/>
- <item type="item" verb="ListOwner" path="/commands/ListOwner" enable="mailing_list" activate="emla_list_owner"/>
- <item type="item" verb="ListArchive" path="/commands/ListArchive" enable="mailing_list" activate="emla_list_archive"/>
- </menu>
- </hook>
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu id="org.gnome.mail.folderview.popup.select" target="select">
- <item type="bar" path="96.list" visible="mailing_list" activate=""/>
- <item type="submenu" path="96.list.00" visible="mailing_list" activate="" _label="Mailing _List"/>
- <item type="item" verb="ListHelp" path="96.list.00/00.help" _label="Get list _usage information" visible="mailing_list" activate="emla_list_help"/>
- <item type="item" verb="ListSubscribe" path="96.list.00/10.subscribe" _label="_Subscribe to list" visible="mailing_list" activate="emla_list_subscribe"/>
- <item type="item" verb="ListUnsubscribe" path="96.list.00/20.unsubscribe" _label="_Un-subscribe to list" visible="mailing_list" activate="emla_list_unsubscribe"/>
- <item type="item" verb="ListPost" path="96.list.00/30.post" _label="_Post message to list" visible="mailing_list" activate="emla_list_post"/>
- <item type="item" verb="ListOwner" path="96.list.00/40.owner" _label="Contact list _owner" visible="mailing_list" activate="emla_list_owner"/>
- <item type="item" verb="ListArchive" path="96.list.00/50.archive" _label="Get list _archive" visible="mailing_list" activate="emla_list_archive"/>
- </menu>
- </hook>
- </e-plugin>
+ <e-plugin
+ type="shlib"
+ id="org.gnome.plugin.mailing-list.actions"
+ domain="@GETTEXT_PACKAGE@"
+ location="@PLUGINDIR@/liborg-gnome-mailing-list-actions@SOEXT@"
+ _name="Mailing List Actions">
+ <author name="Meilof Veeningen" email="meilof@wanadoo.nl"/>
+ <_description>Perform common mailing list actions (subscribe, unsubscribe, etc.).</_description>
+
+ <hook class="org.gnome.evolution.ui:1.0">
+ <ui-manager id="org.gnome.evolution.mail"
+ callback="mail_shell_view_init">
+ <menubar name='main-menu'>
+ <placeholder name='custom-menus'>
+ <menu action='mail-message-menu'>
+ <placeholder name='mail-message-custom-menus'>
+ <menu action='mailing-list-menu'>
+ <menuitem action='mailing-list-help'/>
+ <menuitem action='mailing-list-subscribe'/>
+ <menuitem action='mailing-list-unsubscribe'/>
+ <menuitem action='mailing-list-post'/>
+ <menuitem action='mailing-list-owner'/>
+ <menuitem action='mailing-list-archive'/>
+ </menu>
+ </placeholder>
+ </menu>
+ </placeholder>
+ </menubar>
+ </ui-manager>
+ <ui-manager id="org.gnome.evolution.mail.browser"
+ callback="mail_browser_init">
+ <menubar name='main-menu'>
+ <placeholder name='custom-menus'>
+ <menu action='mail-message-menu'>
+ <placeholder name='mail-message-custom-menus'>
+ <menu action='mailing-list-menu'>
+ <menuitem action='mailing-list-help'/>
+ <menuitem action='mailing-list-subscribe'/>
+ <menuitem action='mailing-list-unsubscribe'/>
+ <menuitem action='mailing-list-post'/>
+ <menuitem action='mailing-list-owner'/>
+ <menuitem action='mailing-list-archive'/>
+ </menu>
+ </placeholder>
+ </menu>
+ </placeholder>
+ </menubar>
+ </ui-manager>
+ </hook>
+
+ </e-plugin>
</e-plugin-list>
diff --git a/plugins/mailing-list-actions/org-gnome-mailing-list-actions.xml b/plugins/mailing-list-actions/org-gnome-mailing-list-actions.xml
deleted file mode 100644
index 980f15bdd7..0000000000
--- a/plugins/mailing-list-actions/org-gnome-mailing-list-actions.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<Root>
- <commands>
- <cmd name="ListHelp" _tip="Get information about the usage of the list this message belongs to"/>
- <cmd name="ListSubscribe" _tip="Subscribe to the mailing list this message belongs to"/>
- <cmd name="ListUnsubscribe" _tip="Unsubscribe to the mailing list this message belongs to"/>
- <cmd name="ListPost" _tip="Post a message to the mailing list this message belongs to"/>
- <cmd name="ListOwner" _tip="Contact the owner of the mailing list this message belongs to"/>
- <cmd name="ListArchive" _tip="Get an archive of the list this message belongs to"/>
- </commands>
-
- <menu>
- <placeholder name="MessagePlaceholder">
- <submenu name="Message">
- <submenu name="List" _label="Mailing _List">
- <menuitem verb="ListHelp" _label="Get List _Usage Information"/>
- <menuitem verb="ListSubscribe" _label="_Subscribe to List"/>
- <menuitem verb="ListUnsubscribe" _label="_Unsubscribe from List"/>
- <menuitem verb="ListPost" _label="_Post Message to List"/>
- <menuitem verb="ListOwner" _label="Contact List _Owner"/>
- <menuitem verb="ListArchive" _label="Get List _Archive"/>
- </submenu>
- </submenu>
- </placeholder>
- </menu>
-</Root>