- /* Get previous notifications ids */
- notifications_list = modest_conf_get_list (modest_runtime_get_conf (),
- MODEST_CONF_NOTIFICATION_IDS,
- MODEST_CONF_VALUE_INT, NULL);
-
- iter = tny_list_create_iterator (header_list);
- while (!tny_iterator_is_done (iter)) {
- gchar *url = NULL, *display_address = NULL;
- TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
- TnyFolder *folder = tny_header_get_folder (header);
- gboolean first_notification = TRUE;
- gint notif_id;
- gchar *str;
-
- display_address = tny_header_dup_from (header);
- /* string is changed in-place */
- modest_text_utils_get_display_address (display_address);
-
- str = tny_header_dup_subject (header);
- notification = hildon_notification_new (display_address,
- str,
- "qgn_list_messagin",
- MODEST_NOTIFICATION_CATEGORY);
- g_free (str);
- /* Create the message URL */
- str = tny_header_dup_uid (header);
- url = g_strdup_printf ("%s/%s", tny_folder_get_url_string (folder),
- str);
- g_free (str);
-
- hildon_notification_add_dbus_action(notification,
- "default",
- "Cancel",
- MODEST_DBUS_SERVICE,
- MODEST_DBUS_OBJECT,
- MODEST_DBUS_IFACE,
- MODEST_DBUS_METHOD_OPEN_MESSAGE,
- G_TYPE_STRING, url,
- -1);
-
- /* Play sound if the user wants. Show the LED
- pattern. Show and play just one */
- if (G_UNLIKELY (first_notification)) {
- TnyAccount *account;
-
- first_notification = FALSE;
-
- /* Set the led pattern and make the notification persistent */
- notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
- "dialog-type", 4);
- notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
- "led-pattern",
- MODEST_NEW_MAIL_LIGHTING_PATTERN);
- notify_notification_set_hint_byte (NOTIFY_NOTIFICATION (notification),
- "persistent", TRUE);
-
- /* Set the account of the headers */
- account = tny_folder_get_account (folder);
- if (account) {
- const gchar *acc_name;
- acc_name =
- modest_tny_account_get_parent_modest_account_name_for_server_account (account);
- notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
- "email-account",
- acc_name);
- g_object_unref (account);
- }
- }
+ data = (ModestMsgNotificationData *) URI_list->data;
+
+ /* String is changed in-place. There is no need to
+ actually dup the data->from string but we just do
+ it in order not to modify the original contents */
+ from = g_strdup (data->from);
+ modest_text_utils_get_display_address (from);
+
+ /* Create notification */
+ notification = hildon_notification_new (from,
+ data->subject,
+ "qgn_list_messagin",
+ MODEST_NOTIFICATION_CATEGORY);
+ g_free (from);
+
+ /* Add DBus action */
+ hildon_notification_add_dbus_action(notification,
+ "default",
+ "Cancel",
+ MODEST_DBUS_SERVICE,
+ MODEST_DBUS_OBJECT,
+ MODEST_DBUS_IFACE,
+ MODEST_DBUS_METHOD_OPEN_MESSAGE,
+ G_TYPE_STRING, data->uri,
+ -1);
+
+ /* Set the led pattern */
+ if (data->time)
+ notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
+ "time", data->time);
+
+ notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
+ "dialog-type", 4);
+ notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
+ "led-pattern",
+ MODEST_NEW_MAIL_LIGHTING_PATTERN);
+
+ /* Make the notification persistent */
+ notify_notification_set_hint_byte (NOTIFY_NOTIFICATION (notification),
+ "persistent", TRUE);
+
+ /* Set the number of new notifications */
+ notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
+ "amount", g_list_length (URI_list));
+
+ /* Set the account of the headers */
+ acc_store = (TnyAccountStore *) modest_runtime_get_account_store ();
+ account = tny_account_store_find_account (acc_store, data->uri);
+ if (account) {
+ const gchar *acc_name;
+ acc_name =
+ modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+ notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
+ "email-account",
+ acc_name);
+ g_object_unref (account);
+ }