/* 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... */
}
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;
}
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;
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);
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;
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)
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);
}
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
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),
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;
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) {
*
* 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:
gchar *references;
gchar *in_reply_to;
+
+ gchar *original_mailbox;
GtkWidget *to_field;
GtkWidget *cc_field;
}
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);
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;
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);
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;
static void
modest_msg_view_window_construct (ModestMsgViewWindow *self,
const gchar *modest_account_name,
+ const gchar *mailbox,
const gchar *msg_uid)
{
GObject *obj = NULL;
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);
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)
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);
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)
{
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);
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;
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);
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;
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));
/* 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));
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;
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)
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;
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;
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));
gboolean set_as_modified)
{
gchar *account_name = NULL;
+ const gchar *mailbox;
TnyMsg *msg = NULL;
TnyAccount *account = NULL;
TnyFolder *folder = NULL;
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);
/* 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));
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;
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);
}
}
- 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);
}
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)) {
}
/* 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);
}
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;
* 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,
* 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
*/
ModestWindow* modest_msg_edit_window_new (TnyMsg *msg,
const gchar *account_name,
+ const gchar *mailbox,
gboolean preserve_is_rich);
* 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.
* 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.
*
*/
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);
* 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.
*
*/
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);
ModestWindow *
modest_msg_view_window_new_for_search_result (TnyMsg *msg,
const gchar *modest_account_name,
+ const gchar *mailbox,
const gchar *msg_uid);
/**
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), \
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),
}
g_free (priv->active_account);
+ g_free (priv->active_mailbox);
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
}
}
+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)
{
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)