Add mailbox id storage in modest window.
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 2 Apr 2009 20:57:15 +0000 (20:57 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 2 Apr 2009 20:57:15 +0000 (20:57 +0000)
pmo-trunk-r8568

17 files changed:
src/dbus_api/modest-dbus-callbacks.c
src/gnome/modest-msg-view-window.c
src/hildon2/modest-folder-window.c
src/hildon2/modest-header-window.c
src/hildon2/modest-header-window.h
src/hildon2/modest-msg-edit-window.c
src/hildon2/modest-msg-view-window.c
src/maemo/modest-msg-edit-window.c
src/maemo/modest-msg-view-window.c
src/modest-ui-actions.c
src/modest-utils.c
src/modest-utils.h
src/widgets/modest-msg-edit-window.h
src/widgets/modest-msg-view-window.h
src/widgets/modest-window-priv.h
src/widgets/modest-window.c
src/widgets/modest-window.h

index 97edc98..df517c9 100644 (file)
@@ -498,6 +498,7 @@ find_msg_async_cb (TnyFolder *folder,
                 /* Drafts will be opened in the editor, and others will be opened in the viewer */
                 if (is_draft) {
                        gchar *modest_account_name = NULL;
+                       gchar *mailbox = NULL;
                        gchar *from_header;
 
                        /* we cannot edit without a valid account... */
@@ -510,14 +511,16 @@ find_msg_async_cb (TnyFolder *folder,
                        }
                
                        from_header = tny_header_dup_from (header);
-                       modest_account_name = modest_utils_get_account_name_from_recipient (from_header);
+                       modest_account_name = modest_utils_get_account_name_from_recipient (from_header, &mailbox);
                        g_free (from_header);
                        
                        if (modest_account_name == NULL) {
                                ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
                                modest_account_name = modest_account_mgr_get_default_account (mgr);
                        }
-                        msg_view = modest_msg_edit_window_new (msg, modest_account_name, TRUE);
+                        msg_view = modest_msg_edit_window_new (msg, modest_account_name, mailbox, TRUE);
+                       if (mailbox)
+                               g_free (mailbox);
                        g_free (modest_account_name);
                } else {
                         TnyHeader *header;
@@ -531,7 +534,8 @@ find_msg_async_cb (TnyFolder *folder,
                        }
 
                         header = tny_msg_get_header (msg);
-                        msg_view = modest_msg_view_window_new_for_search_result (msg, modest_account_name, msg_uid);
+                       /* TODO: fetch mailbox */
+                        msg_view = modest_msg_view_window_new_for_search_result (msg, modest_account_name, NULL, msg_uid);
                         if (! (tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN)) {
                                ModestMailOperation *mail_op;
                                
@@ -1181,6 +1185,8 @@ on_idle_open_account (gpointer user_data)
        if (MODEST_IS_ACCOUNTS_WINDOW (top)) {
                GtkWidget *folder_window;
 
+               /* TODO: should show the mailboxes window in multi mailboxes account */
+
                folder_window = (GtkWidget *) modest_folder_window_new (NULL);
                modest_folder_window_set_account (MODEST_FOLDER_WINDOW (folder_window),
                                                  acc_name);
index c6ecc38..e766ab0 100644 (file)
@@ -206,8 +206,9 @@ on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgViewWindow *self)
 
 ModestWindow *
 modest_msg_view_window_new_for_attachment (TnyMsg *msg, 
-                           const gchar *modest_account_name, 
-                           const gchar *msg_uid)
+                                          const gchar *modest_account_name, 
+                                          const gchar *mailbox, /* ignored */
+                                          const gchar *msg_uid)
 {
        GObject *obj;
        ModestMsgViewWindowPrivate *priv;
@@ -370,6 +371,7 @@ modest_msg_view_window_get_message_uid (ModestMsgViewWindow *self)
 ModestWindow*   
 modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
                                              const gchar *modest_account_name, 
+                                             const gchar *mailbox, /*ignored*/
                                              const gchar *msg_uid,
                                              GtkTreeModel *model, 
                                              GtkTreeRowReference *row_reference)
@@ -379,7 +381,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg,
           actions */
        g_message ("partially implemented %s", __FUNCTION__);
 
-       return modest_msg_view_window_new_for_attachment (msg, modest_account_name, msg_uid);
+       return modest_msg_view_window_new_for_attachment (msg, modest_account_name, NULL, msg_uid);
 }
 
 
index 4c3201c..4fca617 100644 (file)
@@ -459,7 +459,7 @@ modest_folder_window_set_mailbox (ModestFolderWindow *self,
        priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self);
 
        modest_folder_view_set_mailbox (MODEST_FOLDER_VIEW (priv->folder_view), mailbox);
-
+       modest_window_set_active_mailbox (MODEST_WINDOW (self), mailbox);
 }
 
 static void
@@ -516,7 +516,9 @@ on_folder_activated (ModestFolderView *folder_view,
        if (tny_folder_get_caps (folder) & TNY_FOLDER_CAPS_NOSELECT)
                return;
 
-       headerwin = modest_header_window_new (folder, modest_window_get_active_account (MODEST_WINDOW (self)));
+       headerwin = modest_header_window_new (folder, 
+                                             modest_window_get_active_account (MODEST_WINDOW (self)),
+                                             modest_window_get_active_mailbox (MODEST_WINDOW (self)));
 
        if (modest_window_mgr_register_window (modest_runtime_get_window_mgr (),
                                               MODEST_WINDOW (headerwin),
index 59bb75a..1b08bdc 100644 (file)
@@ -433,7 +433,7 @@ on_vertical_movement (HildonPannableArea *area,
 
 
 ModestWindow *
-modest_header_window_new (TnyFolder *folder, const gchar *account_name)
+modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gchar *mailbox)
 {
        ModestHeaderWindow *self = NULL;        
        ModestHeaderWindowPrivate *priv = NULL;
@@ -554,6 +554,7 @@ modest_header_window_new (TnyFolder *folder, const gchar *account_name)
 
 
        modest_window_set_active_account (MODEST_WINDOW (self), account_name);
+       modest_window_set_active_mailbox (MODEST_WINDOW (self), mailbox);
        mgr = modest_runtime_get_account_mgr ();
        settings = modest_account_mgr_load_account_settings (mgr, account_name);
        if (settings) {
index 9409b71..409d963 100644 (file)
@@ -73,7 +73,7 @@ GType modest_header_window_get_type (void) G_GNUC_CONST;
  *
  * Returns: a new ModestHeaderWindow, or NULL in case of error
  */
-ModestWindow* modest_header_window_new (TnyFolder *folder, const gchar *account_name);
+ModestWindow* modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gchar *mailbox);
 
 /**
  * modest_header_window_get_header_view:
index 396d7f6..7fad0c1 100644 (file)
@@ -244,6 +244,8 @@ struct _ModestMsgEditWindowPrivate {
 
        gchar       *references;
        gchar       *in_reply_to;
+
+       gchar       *original_mailbox;
        
        GtkWidget   *to_field;
        GtkWidget   *cc_field;
@@ -976,6 +978,8 @@ modest_msg_edit_window_finalize (GObject *obj)
        }
        if (priv->original_account_name)
                g_free (priv->original_account_name);
+       if (priv->original_mailbox)
+               g_free (priv->original_mailbox);
        g_free (priv->msg_uid);
        g_free (priv->last_search);
        g_free (priv->references);
@@ -1486,7 +1490,7 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
 
 
 ModestWindow*
-modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean preserve_is_rich)
+modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, const gchar *mailbox, gboolean preserve_is_rich)
 {
        GObject *obj;
        ModestWindowPrivate *parent_priv;
@@ -1524,8 +1528,10 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
        restore_settings (MODEST_MSG_EDIT_WINDOW(obj));
                
        modest_window_set_active_account (MODEST_WINDOW(obj), account_name);
+       modest_window_set_active_mailbox (MODEST_WINDOW(obj), mailbox);
 
        priv->original_account_name = (account_name) ? g_strdup (account_name) : NULL;
+       priv->original_mailbox = (mailbox) ? g_strdup (mailbox) : NULL;
 
        toolbar_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_TOOLBAR, TRUE);
        clipboard_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_CLIPBOARD, FALSE);
@@ -3244,6 +3250,8 @@ modest_msg_edit_window_is_modified (ModestMsgEditWindow *editor)
                return TRUE;
        if (gtk_text_buffer_get_modified (priv->text_buffer))
                return TRUE;
+
+       /* TODO: check the mailbox too here */
        account_name = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
        if (!priv->original_account_name || strcmp(account_name, priv->original_account_name)) {
                return TRUE;
index 45a981c..14f6212 100644 (file)
@@ -725,6 +725,7 @@ select_next_valid_row (GtkTreeModel *model,
 static void
 modest_msg_view_window_construct (ModestMsgViewWindow *self, 
                                  const gchar *modest_account_name,
+                                 const gchar *mailbox,
                                  const gchar *msg_uid)
 {
        GObject *obj = NULL;
@@ -808,6 +809,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
                                                          obj);
 
        modest_window_set_active_account (MODEST_WINDOW(obj), modest_account_name);
+       modest_window_set_active_mailbox (MODEST_WINDOW(obj), mailbox);
 
        g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_view_window_find_toolbar_close), obj);
        g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_view_window_find_toolbar_search), obj);
@@ -827,6 +829,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
 ModestWindow *
 modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
                                              const gchar *modest_account_name,
+                                             const gchar *mailbox,
                                              const gchar *msg_uid,
                                              GtkTreeModel *model, 
                                              GtkTreeRowReference *row_reference)
@@ -846,7 +849,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg,
        window = MODEST_MSG_VIEW_WINDOW (modest_window_mgr_get_msg_view_window (mgr));
        g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL);
 
-       modest_msg_view_window_construct (window, modest_account_name, msg_uid);
+       modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
 
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
 
@@ -925,6 +928,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg,
 ModestWindow *
 modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view, 
                                              const gchar *modest_account_name,
+                                            const gchar *mailbox,
                                              const gchar *msg_uid,
                                              GtkTreeRowReference *row_reference)
 {
@@ -939,7 +943,7 @@ modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view,
        window = MODEST_MSG_VIEW_WINDOW (modest_window_mgr_get_msg_view_window (mgr));
        g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL);
 
-       modest_msg_view_window_construct (window, modest_account_name, msg_uid);
+       modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
 
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
 
@@ -1019,6 +1023,7 @@ modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view,
 ModestWindow *
 modest_msg_view_window_new_for_search_result (TnyMsg *msg, 
                                              const gchar *modest_account_name,
+                                             const gchar *mailbox,
                                              const gchar *msg_uid)
 {
        ModestMsgViewWindow *window = NULL;
@@ -1028,7 +1033,7 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg,
        mgr = modest_runtime_get_window_mgr ();
        window = MODEST_MSG_VIEW_WINDOW (modest_window_mgr_get_msg_view_window (mgr));
        g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL);
-       modest_msg_view_window_construct (window, modest_account_name, msg_uid);
+       modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
 
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
 
@@ -1052,8 +1057,9 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg,
 
 ModestWindow *
 modest_msg_view_window_new_for_attachment (TnyMsg *msg, 
-                           const gchar *modest_account_name,
-                           const gchar *msg_uid)
+                                          const gchar *modest_account_name,
+                                          const gchar *mailbox,
+                                          const gchar *msg_uid)
 {
        GObject *obj = NULL;
        ModestMsgViewWindowPrivate *priv;       
@@ -1064,7 +1070,7 @@ modest_msg_view_window_new_for_attachment (TnyMsg *msg,
        obj = G_OBJECT (modest_window_mgr_get_msg_view_window (mgr));
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj);
        modest_msg_view_window_construct (MODEST_MSG_VIEW_WINDOW (obj), 
-               modest_account_name, msg_uid);
+                                         modest_account_name, mailbox, msg_uid);
 
        tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
        update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
@@ -2544,9 +2550,11 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window,
                        /* it's not found, so create a new window for it */
                        modest_window_mgr_register_header (mgr, header, attachment_uid); /* register the uid before building the window */
                        gchar *account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (window)));
+                       const gchar *mailbox = modest_window_get_active_mailbox (MODEST_WINDOW (window));
                        if (!account)
                                account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ());
-                       msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (mime_part), account, attachment_uid);
+                       msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (mime_part), account, 
+                                                                            mailbox, attachment_uid);
                        modest_window_set_zoom (MODEST_WINDOW (msg_win),
                                                modest_window_get_zoom (MODEST_WINDOW (window)));
                        modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (window));
index e485047..5fad32b 100644 (file)
@@ -1477,7 +1477,10 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
 
 
 ModestWindow*
-modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean preserve_is_rich)
+modest_msg_edit_window_new (TnyMsg *msg, 
+                           const gchar *account_name, 
+                           const gchar *mailbox, /* ignored */
+                           gboolean preserve_is_rich)
 {
        GObject *obj;
        ModestWindowPrivate *parent_priv;
index facfbc4..883491d 100644 (file)
@@ -934,6 +934,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
 ModestWindow *
 modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
                                              const gchar *modest_account_name,
+                                             const gchar *mailbox, /*ignored */
                                              const gchar *msg_uid,
                                              GtkTreeModel *model, 
                                              GtkTreeRowReference *row_reference)
@@ -1032,6 +1033,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg,
 ModestWindow *
 modest_msg_view_window_new_for_search_result (TnyMsg *msg, 
                                              const gchar *modest_account_name,
+                                             const gchar *mailbox, /*ignored*/
                                              const gchar *msg_uid)
 {
        ModestMsgViewWindow *window = NULL;
@@ -1065,8 +1067,9 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg,
 
 ModestWindow *
 modest_msg_view_window_new_for_attachment (TnyMsg *msg, 
-                           const gchar *modest_account_name,
-                           const gchar *msg_uid)
+                                          const gchar *modest_account_name,
+                                          const gchar *mailbox, /* ignored */
+                                          const gchar *msg_uid)
 {
        GObject *obj = NULL;
        ModestMsgViewWindowPrivate *priv;       
@@ -2657,7 +2660,8 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window,
                        gchar *account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (window)));
                        if (!account)
                                account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ());
-                       msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (mime_part), account, attachment_uid);
+                       msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (mime_part), account, 
+                                                                            NULL, attachment_uid);
                        modest_window_set_zoom (MODEST_WINDOW (msg_win), 
                                                modest_window_get_zoom (MODEST_WINDOW (window)));
                        modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (window));
index 490dd92..3d12d02 100644 (file)
@@ -787,6 +787,7 @@ modest_ui_actions_compose_msg(ModestWindow *win,
                              gboolean set_as_modified)
 {
        gchar *account_name = NULL;
+       const gchar *mailbox;
        TnyMsg *msg = NULL;
        TnyAccount *account = NULL;
        TnyFolder *folder = NULL;
@@ -811,6 +812,8 @@ modest_ui_actions_compose_msg(ModestWindow *win,
                g_printerr ("modest: no account found\n");
                goto cleanup;
        }
+
+       mailbox = modest_window_get_active_mailbox (win);
        account = modest_tny_account_store_get_server_account (store, account_name, TNY_ACCOUNT_TYPE_STORE);
        if (!account) {
                g_printerr ("modest: failed to get tnyaccount for '%s'\n", account_name);
@@ -844,7 +847,7 @@ modest_ui_actions_compose_msg(ModestWindow *win,
        /* This is destroyed by TODO. */
        total_size = 0;
        allowed_size = MODEST_MAX_ATTACHMENT_SIZE;
-       msg_win = modest_msg_edit_window_new (msg, account_name, FALSE);
+       msg_win = modest_msg_edit_window_new (msg, account_name, mailbox, FALSE);
 
        if (!modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win, win)) {
                gtk_widget_destroy (GTK_WIDGET (msg_win));
@@ -1006,6 +1009,7 @@ get_header_view_from_window (ModestWindow *window)
 static gchar *
 get_info_from_header (TnyHeader *header, gboolean *is_draft, gboolean *can_open)
 {
+       /* TODO: should also retrieve the mailbox from header */
        TnyFolder *folder;
        gchar *account = NULL;
        TnyFolderType folder_type = TNY_FOLDER_TYPE_UNKNOWN;
@@ -1110,6 +1114,7 @@ open_msg_cb (ModestMailOperation *mail_op,
        if (open_in_editor) {
                ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
                gchar *from_header = NULL, *acc_name;
+               gchar *mailbox = NULL;
 
                from_header = tny_header_dup_from (header);
 
@@ -1123,22 +1128,26 @@ open_msg_cb (ModestMailOperation *mail_op,
                        }
                }
 
-               acc_name = modest_utils_get_account_name_from_recipient (from_header);
+               acc_name = modest_utils_get_account_name_from_recipient (from_header, &mailbox);
                g_free (from_header);
                if (acc_name) {
                        g_free (account);
                        account = acc_name;
                }
 
-               win = modest_msg_edit_window_new (msg, account, TRUE);
+               win = modest_msg_edit_window_new (msg, account, mailbox, TRUE);
+               if (mailbox)
+                       g_free (mailbox);
        } else {
                gchar *uid = modest_tny_folder_get_header_unique_id (header);
 
                if (helper->rowref && helper->model) {
-                       win = modest_msg_view_window_new_with_header_model (msg, account, (const gchar*) uid,
+                       /* TODO: use mailbox */
+                       win = modest_msg_view_window_new_with_header_model (msg, account, NULL, (const gchar*) uid,
                                                                            helper->model, helper->rowref);
                } else {
-                       win = modest_msg_view_window_new_for_attachment (msg, account, (const gchar*) uid);
+                       /* TODO: use mailbox */
+                       win = modest_msg_view_window_new_for_attachment (msg, account, NULL, (const gchar*) uid);
                }
                g_free (uid);
        }
@@ -1434,8 +1443,9 @@ open_msg_performer(gboolean canceled,
                header_view = get_header_view_from_window (MODEST_WINDOW (parent_window));
                uid = modest_tny_folder_get_header_unique_id (helper->header);
                if (header_view) {
-                       window = modest_msg_view_window_new_from_header_view
-                               (MODEST_HEADER_VIEW (header_view), account_name, uid, helper->rowref);
+                       /* TODO: use mailbox */
+                       window = modest_msg_view_window_new_from_header_view 
+                               (MODEST_HEADER_VIEW (header_view), account_name, NULL, uid, helper->rowref);
                        if (window != NULL) {
                                if (!modest_window_mgr_register_window (modest_runtime_get_window_mgr (),
                                                                        window, NULL)) {
@@ -1757,7 +1767,8 @@ reply_forward_cb (ModestMailOperation *mail_op,
        }
 
        /* Create and register the windows */
-       msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name, FALSE);
+       /* TODO: fetch mailbox */
+       msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name, NULL, FALSE);
        mgr = modest_runtime_get_window_mgr ();
        modest_window_mgr_register_window (mgr, msg_win, (ModestWindow *) rf_helper->parent_window);
 
index 33b5a04..a36dc59 100644 (file)
@@ -720,8 +720,9 @@ modest_images_cache_get_id (const gchar *account, const gchar *uri)
 }
 
 gchar *
-modest_utils_get_account_name_from_recipient (const gchar *from_header)
+modest_utils_get_account_name_from_recipient (const gchar *from_header, gchar **mailbox)
 {
+       /* TODO: fetch mailbox too */
        gchar *account_name = NULL;
        ModestAccountMgr *mgr = NULL;
        GSList *accounts = NULL, *node = NULL;
index 76a2027..8f88a35 100644 (file)
@@ -183,7 +183,7 @@ gchar *modest_images_cache_get_id (const gchar *account, const gchar *uri);
  * Returns: a newly allocated string containing the account name or
  * %NULL in case of error
  */
-gchar *modest_utils_get_account_name_from_recipient (const gchar *from);
+gchar *modest_utils_get_account_name_from_recipient (const gchar *from, gchar **mailbox);
 
 void modest_utils_on_entry_invalid_character (ModestValidatingEntry *self, 
                                              const gchar* character,
index 4012ac9..a364da0 100644 (file)
@@ -130,6 +130,7 @@ GType        modest_msg_edit_window_get_type    (void) G_GNUC_CONST;
  * modest_msg_edit_window_new:
  * @msg: a #TnyMsg instance
  * @account_name: the account this message applies to
+ * @mailbox: the mailbox (if any)
  * @preserve_is_rich: if @msg is not rich, open the message as plain text
  * 
  * instantiates a new #ModestMsgEditWindow widget
@@ -138,6 +139,7 @@ GType        modest_msg_edit_window_get_type    (void) G_GNUC_CONST;
  */
 ModestWindow*   modest_msg_edit_window_new         (TnyMsg *msg, 
                                                    const gchar *account_name, 
+                                                   const gchar *mailbox,
                                                    gboolean preserve_is_rich);
 
 
index b0c8a43..a141383 100644 (file)
@@ -91,6 +91,7 @@ GType        modest_msg_view_window_get_type    (void) G_GNUC_CONST;
  * modest_msg_view_window_new_for_attachment:
  * @msg: an #TnyMsg instance
  * @modest_account_name: the account name 
+ * @mailbox: the mailbox (if any)
  * 
  * instantiates a new #ModestMsgViewWindow widget to view a message that is an
  * attachment in another message.
@@ -100,13 +101,15 @@ GType        modest_msg_view_window_get_type    (void) G_GNUC_CONST;
  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
  */
 ModestWindow*   modest_msg_view_window_new_for_attachment         (TnyMsg *msg, 
-                                                   const gchar *modest_account_name,
-                                                   const gchar *msg_uid);
+                                                                  const gchar *modest_account_name,
+                                                                  const gchar *mailbox,
+                                                                  const gchar *msg_uid);
 
 /**
  * modest_msg_view_window_new_with_header_model:
  * @msg: an #TnyMsg instance
  * @modest_account_name: the account name 
+ * @mailbox: the mailbox (if any)
  * @model: a #GtkTreeModel, with the format used by #ModestHeaderView
  * @row_reference: a #GtkTreeRowReference, pointing to the position of @msg in @model.
  * 
@@ -119,6 +122,7 @@ ModestWindow*   modest_msg_view_window_new_for_attachment         (TnyMsg *msg,
  */
 ModestWindow*   modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
                                                              const gchar *modest_account_name, 
+                                                             const gchar *mailbox,
                                                              const gchar *msg_uid,
                                                              GtkTreeModel *model, 
                                                              GtkTreeRowReference *row_reference);
@@ -127,6 +131,7 @@ ModestWindow*   modest_msg_view_window_new_with_header_model (TnyMsg *msg,
  * modest_msg_view_window_new_from_header_view:
  * @header_view: an #ModestHeaderView instance
  * @modest_account_name: the account name 
+ * @mailbox: the mailbox (if any)
  * @msg_uid: the initial uid reserved by this window
  * @row_reference: a #GtkTreeRowReference, pointing to the selected position @model.
  * 
@@ -139,6 +144,7 @@ ModestWindow*   modest_msg_view_window_new_with_header_model (TnyMsg *msg,
  */
 ModestWindow*   modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view, 
                                                             const gchar *modest_account_name, 
+                                                            const gchar *mailbox,
                                                             const gchar *msg_uid,
                                                             GtkTreeRowReference *row_reference);
 
@@ -158,6 +164,7 @@ ModestWindow*   modest_msg_view_window_new_from_header_view (ModestHeaderView *h
 ModestWindow *
 modest_msg_view_window_new_for_search_result (TnyMsg *msg, 
                                              const gchar *modest_account_name,
+                                             const gchar *mailbox,
                                              const gchar *msg_uid);
                                              
 /**
index 89304ca..84799d2 100644 (file)
@@ -46,6 +46,7 @@ struct _ModestWindowPrivate {
        DimmedState             *dimming_state;
        gboolean                ui_dimming_enabled;
        gchar                   *active_account;
+       gchar                   *active_mailbox;
 };
 
 #define MODEST_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
index 99b0015..e28a2ae 100644 (file)
@@ -141,6 +141,7 @@ modest_window_init (ModestWindow *obj)
        priv->dimming_state = NULL;
        priv->ui_dimming_enabled = TRUE;
        priv->active_account = NULL;
+       priv->active_mailbox = NULL;
 
        /* Connect signals */
        g_signal_connect (G_OBJECT (obj), 
@@ -161,6 +162,7 @@ modest_window_finalize (GObject *obj)
        }
 
        g_free (priv->active_account);
+       g_free (priv->active_mailbox);
        
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
@@ -228,6 +230,31 @@ modest_window_set_active_account (ModestWindow *self, const gchar *active_accoun
        }
 }
 
+const gchar*
+modest_window_get_active_mailbox (ModestWindow *self)
+{
+       g_return_val_if_fail (self, NULL);
+       return MODEST_WINDOW_GET_PRIVATE(self)->active_mailbox;
+}
+
+void
+modest_window_set_active_mailbox (ModestWindow *self, const gchar *active_mailbox)
+{
+       ModestWindowPrivate *priv;
+
+       g_return_if_fail (self);        
+       priv = MODEST_WINDOW_GET_PRIVATE(self);
+
+       if (active_mailbox == priv->active_mailbox)
+               return;
+       else {
+               g_free (priv->active_mailbox);
+               priv->active_mailbox = NULL;
+               if (active_mailbox)
+                       priv->active_mailbox = g_strdup (active_mailbox);
+       }
+}
+
 void
 modest_window_check_dimming_rules (ModestWindow *self)
 {
index 0c8b874..3084d2b 100644 (file)
@@ -151,6 +151,28 @@ const gchar* modest_window_get_active_account (ModestWindow *self);
 void modest_window_set_active_account (ModestWindow *self, const gchar *active_account);
 
 /**
+ * modest_window_get_active_mailbox:
+ * @self: a modest window instance
+ * 
+ * get the name of the active mailbox
+ * 
+ * Returns: the active mailbox as a constant string
+ */    
+const gchar* modest_window_get_active_mailbox (ModestWindow *self);
+
+
+
+/**
+ * modest_window_set_active_account:
+ * @self: a modest window instance
+ * @active_mailbox: a new active mailbox name for this window
+ * 
+ * set the active mailbox for this window.
+ * 
+ */    
+void modest_window_set_active_mailbox (ModestWindow *self, const gchar *active_mailbox);
+
+/**
  * modest_window_set_zoom:
  * @window: a #ModestWindow instance
  * @zoom: the zoom level (1.0 is no zoom)