aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-backend.c17
-rw-r--r--mail/em-event.c22
-rw-r--r--mail/em-event.h10
-rw-r--r--plugins/mail-notification/mail-notification.c36
4 files changed, 44 insertions, 41 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 0ae8706a32..b22dbcf2ca 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -356,7 +356,7 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
static void
mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
CamelStore *store,
- const gchar *folder_fullname,
+ const gchar *folder_name,
gint new_messages,
const gchar *msg_uid,
const gchar *msg_sender,
@@ -367,13 +367,11 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
EMEvent *event = em_event_peek ();
EMEventTargetFolder *target;
EMFolderTreeModel *model;
- EAccount *account;
- const gchar *uid;
gchar *folder_uri;
gint folder_type;
CamelFolderInfoFlags flags = 0;
- folder_uri = e_mail_folder_uri_build (store, folder_fullname);
+ folder_uri = e_mail_folder_uri_build (store, folder_name);
if (mail_folder_cache_get_folder_from_uri (
folder_cache, folder_uri, &folder))
@@ -381,19 +379,18 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
folder_cache, folder, &flags))
g_return_if_reached ();
- uid = camel_service_get_uid (CAMEL_SERVICE (store));
- account = e_get_account_by_uid (uid);
+ g_free (folder_uri);
target = em_event_target_new_folder (
- event, account, folder_uri, new_messages,
+ event, store, folder_name, new_messages,
msg_uid, msg_sender, msg_subject);
folder_type = (flags & CAMEL_FOLDER_TYPE_MASK);
target->is_inbox = (folder_type == CAMEL_FOLDER_TYPE_INBOX);
model = em_folder_tree_model_get_default ();
- target->name = em_folder_tree_model_get_folder_name (
- model, store, folder_fullname);
+ target->display_name = em_folder_tree_model_get_folder_name (
+ model, store, folder_name);
if (target->new > 0)
e_shell_event (shell, "mail-icon", (gpointer) "mail-unread");
@@ -411,8 +408,6 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
e_event_emit (
(EEvent *) event, "folder.changed",
(EEventTarget *) target);
-
- g_free (folder_uri);
}
static void
diff --git a/mail/em-event.c b/mail/em-event.c
index 074b9abfa9..3fb3176aab 100644
--- a/mail/em-event.c
+++ b/mail/em-event.c
@@ -40,10 +40,10 @@ eme_target_free (EEvent *ep, EEventTarget *t)
switch (t->type) {
case EM_EVENT_TARGET_FOLDER: {
EMEventTargetFolder *s = (EMEventTargetFolder *) t;
- if (s->account != NULL)
- g_object_unref (s->account);
- g_free (s->name);
- g_free (s->uri);
+ if (s->store != NULL)
+ g_object_unref (s->store);
+ g_free (s->folder_name);
+ g_free (s->display_name);
g_free (s->msg_uid);
g_free (s->msg_sender);
g_free (s->msg_subject);
@@ -108,8 +108,8 @@ em_event_peek (void)
EMEventTargetFolder *
em_event_target_new_folder (EMEvent *eme,
- EAccount *account,
- const gchar *uri,
+ CamelStore *store,
+ const gchar *folder_name,
guint new,
const gchar *msg_uid,
const gchar *msg_sender,
@@ -118,14 +118,14 @@ em_event_target_new_folder (EMEvent *eme,
EMEventTargetFolder *t;
guint32 flags = new ? EM_EVENT_FOLDER_NEWMAIL : 0;
+ g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+ g_return_val_if_fail (folder_name != NULL, NULL);
+
t = e_event_target_new (
&eme->popup, EM_EVENT_TARGET_FOLDER, sizeof (*t));
- if (E_IS_ACCOUNT (account))
- t->account = g_object_ref (account);
- else
- t->account = NULL;
- t->uri = g_strdup (uri);
+ t->store = g_object_ref (store);
+ t->folder_name = g_strdup (folder_name);
t->target.mask = ~flags;
t->new = new;
t->msg_uid = g_strdup (msg_uid);
diff --git a/mail/em-event.h b/mail/em-event.h
index f1cd25c59c..3fc5ac0fc3 100644
--- a/mail/em-event.h
+++ b/mail/em-event.h
@@ -72,11 +72,11 @@ typedef struct _EMEventTargetFolder EMEventTargetFolder;
struct _EMEventTargetFolder {
EEventTarget target;
- EAccount *account;
- gchar *uri;
+ CamelStore *store;
+ gchar *folder_name;
guint new;
gboolean is_inbox;
- gchar *name;
+ gchar *display_name;
/* valid (non-NULL) when only one new message reported */
gchar *msg_uid;
@@ -135,8 +135,8 @@ GType em_event_get_type (void);
EMEvent * em_event_peek (void);
EMEventTargetFolder *
em_event_target_new_folder (EMEvent *emp,
- EAccount *account,
- const gchar *uri,
+ CamelStore *store,
+ const gchar *folder_name,
guint32 count_new_msgs,
const gchar *msg_uid,
const gchar *msg_sender,
diff --git a/plugins/mail-notification/mail-notification.c b/plugins/mail-notification/mail-notification.c
index 0e628e0ee4..7c6c39adb2 100644
--- a/plugins/mail-notification/mail-notification.c
+++ b/plugins/mail-notification/mail-notification.c
@@ -39,6 +39,7 @@
#include <e-util/e-config.h>
#include <e-util/e-account-utils.h>
#include <e-util/gconf-bridge.h>
+#include <mail/e-mail-folder-utils.h>
#include <mail/em-utils.h>
#include <mail/em-event.h>
#include <mail/em-folder-tree.h>
@@ -115,7 +116,7 @@ static gboolean init_gdbus (void);
static void
send_dbus_message (const gchar *name,
- const gchar *data,
+ const gchar *display_name,
guint new_count,
const gchar *msg_uid,
const gchar *msg_sender,
@@ -126,9 +127,9 @@ send_dbus_message (const gchar *name,
GError *error = NULL;
g_return_if_fail (name != NULL);
- g_return_if_fail (data != NULL);
+ g_return_if_fail (display_name != NULL);
g_return_if_fail (g_utf8_validate (name, -1, NULL));
- g_return_if_fail (g_utf8_validate (data, -1, NULL));
+ g_return_if_fail (g_utf8_validate (display_name, -1, NULL));
g_return_if_fail (msg_uid == NULL || g_utf8_validate (msg_uid, -1, NULL));
g_return_if_fail (msg_sender == NULL || g_utf8_validate (msg_sender, -1, NULL));
g_return_if_fail (msg_subject == NULL || g_utf8_validate (msg_subject, -1, NULL));
@@ -140,15 +141,11 @@ send_dbus_message (const gchar *name,
builder = g_variant_builder_new (G_VARIANT_TYPE_TUPLE);
/* Appends the data as an argument to the message */
- g_variant_builder_add (builder, "(s)", data);
+ g_variant_builder_add (builder, "(s)", display_name);
if (new_count) {
- gchar *display_name = em_utils_folder_name_from_uri (data);
-
g_variant_builder_add (builder, "(s)", display_name);
g_variant_builder_add (builder, "(u)", new_count);
-
- g_free (display_name);
}
#define add_named_param(name, value) \
@@ -238,8 +235,8 @@ new_notify_dbus (EMEventTargetFolder *t)
{
if (connection != NULL)
send_dbus_message (
- "Newmail", t->uri, t->new, t->msg_uid,
- t->msg_sender, t->msg_subject);
+ "Newmail", t->display_name, t->new,
+ t->msg_uid, t->msg_sender, t->msg_subject);
}
static void
@@ -378,13 +375,18 @@ new_notify_status (EMEventTargetFolder *t)
gchar *msg;
if (!status_count) {
+ EAccount *account;
gchar *folder_name;
+ const gchar *uid;
- if (t->account != NULL)
+ uid = camel_service_get_uid (CAMEL_SERVICE (t->store));
+ account = e_get_account_by_uid (uid);
+
+ if (account != NULL)
folder_name = g_strdup_printf (
- "%s/%s", t->account->name, t->name);
+ "%s/%s", account->name, t->folder_name);
else
- folder_name = g_strdup (t->name);
+ folder_name = g_strdup (t->folder_name);
status_count = t->new;
@@ -454,6 +456,12 @@ new_notify_status (EMEventTargetFolder *t)
/* Check if actions are supported */
if (can_support_actions ()) {
+ gchar *folder_uri;
+
+ /* NotifyAction takes ownership. */
+ folder_uri = e_mail_folder_uri_build (
+ t->store, t->folder_name);
+
notify_notification_set_urgency (
notify, NOTIFY_URGENCY_NORMAL);
notify_notification_set_timeout (
@@ -462,7 +470,7 @@ new_notify_status (EMEventTargetFolder *t)
notify, "default", "Default",
(NotifyActionCallback)
notify_default_action_cb,
- g_strdup (t->uri),
+ folder_uri,
(GFreeFunc) g_free);
g_timeout_add (
500, notification_callback, notify);