* all:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 9 Feb 2007 13:23:43 +0000 (13:23 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 9 Feb 2007 13:23:43 +0000 (13:23 +0000)
  - update for account stuff
  - merge cleanups with sergio

pmo-trunk-r810

src/modest-defs.h
src/modest-main.c
src/modest-runtime.c
src/modest-singletons.h
src/modest-ui-actions.c
src/modest-ui-actions.h

index 2f50285..05df54a 100644 (file)
 /* configuration key definitions for modest */
 #define MODEST_CONF_NAMESPACE          "/apps/modest"
 
 /* configuration key definitions for modest */
 #define MODEST_CONF_NAMESPACE          "/apps/modest"
 
+/* configuration key definitions for modest */
+#define MODEST_ACCOUNT_NAMESPACE         MODEST_CONF_NAMESPACE "/accounts"
+#define MODEST_CONF_DEFAULT_ACCOUNT      MODEST_CONF_NAMESPACE "/default_account"
+
+#define MODEST_CONF_REPLY_TYPE           MODEST_CONF_NAMESPACE "/reply_type"        /*  int  */
+#define MODEST_CONF_FORWARD_TYPE         MODEST_CONF_NAMESPACE "/forward_type"      /*  int  */
+
 /* place for widget settings */
 #define MODEST_CONF_WIDGET_NAMESPACE     MODEST_CONF_NAMESPACE "/widgets"
 
 /* place for widget settings */
 #define MODEST_CONF_WIDGET_NAMESPACE     MODEST_CONF_NAMESPACE "/widgets"
 
-/* configuration key definitions for modest */
-#define MODEST_ACCOUNT_NAMESPACE         MODEST_CONF_NAMESPACE "/" "accounts"
-#define MODEST_CONF_DEFAULT_ACCOUNT      MODEST_CONF_NAMESPACE "/" "default_account"
+
 
 #define MODEST_SERVER_ACCOUNT_NAMESPACE  MODEST_CONF_NAMESPACE "/" "server_accounts"
 
 #define MODEST_SERVER_ACCOUNT_NAMESPACE  MODEST_CONF_NAMESPACE "/" "server_accounts"
-#define MODEST_CONF_REPLY_TYPE           "reply_type"        /*  int  */
-#define MODEST_CONF_FORWARD_TYPE         "forward_type"      /*  int  */
 
 
 /* per-account data */
 
 
 /* per-account data */
index 9d658a1..328e37a 100644 (file)
@@ -169,8 +169,7 @@ start_ui (const gchar *account, const gchar* mailto, const gchar *cc, const gcha
                from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(), account);
                msg  = modest_tny_msg_new (mailto,from,cc,bcc,subject,body,NULL);
                
                from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(), account);
                msg  = modest_tny_msg_new (mailto,from,cc,bcc,subject,body,NULL);
                
-               win = modest_msg_edit_window_new (MODEST_EDIT_TYPE_NEW);
-               modest_msg_edit_window_set_msg  (MODEST_MSG_EDIT_WINDOW(win), msg);
+               win = modest_msg_edit_window_new (msg, account);
                
                g_object_unref (G_OBJECT(msg));
                g_free (from);
                
                g_object_unref (G_OBJECT(msg));
                g_free (from);
index 08eb861..a4fc46a 100644 (file)
@@ -234,6 +234,7 @@ modest_runtime_get_mail_operation_queue (void)
 }
 
 
 }
 
 
+
 ModestTnySendQueue*
 modest_runtime_get_send_queue  (TnyTransportAccount *account)
 {
 ModestTnySendQueue*
 modest_runtime_get_send_queue  (TnyTransportAccount *account)
 {
index dcffb9f..84e647a 100644 (file)
@@ -147,6 +147,8 @@ ModestCacheMgr*           modest_singletons_get_cache_mgr     (ModestSingletons
  **/
 ModestMailOperationQueue* modest_singletons_get_mail_operation_queue (ModestSingletons *self);
 
  **/
 ModestMailOperationQueue* modest_singletons_get_mail_operation_queue (ModestSingletons *self);
 
+
+
 G_END_DECLS
 
 #endif /* __MODEST_SINGLETONS_H__ */
 G_END_DECLS
 
 #endif /* __MODEST_SINGLETONS_H__ */
index 2837c8e..0a4d048 100644 (file)
@@ -34,7 +34,9 @@
 #include <glib/gi18n.h>
 #include <string.h>
 #include <modest-runtime.h>
 #include <glib/gi18n.h>
 #include <string.h>
 #include <modest-runtime.h>
+#include <modest-tny-msg.h>
 #include "modest-ui-actions.h"
 #include "modest-ui-actions.h"
+
 #include "modest-tny-platform-factory.h"
 
 #include <widgets/modest-main-window.h>
 #include "modest-tny-platform-factory.h"
 
 #include <widgets/modest-main-window.h>
@@ -66,7 +68,7 @@ typedef enum _ReplyForwardAction {
 typedef struct _ReplyForwardHelper {
 guint reply_forward_type;
        ReplyForwardAction action;
 typedef struct _ReplyForwardHelper {
 guint reply_forward_type;
        ReplyForwardAction action;
-       gchar *from;
+       gchar *account;
 } ReplyForwardHelper;
 
 
 } ReplyForwardHelper;
 
 
@@ -184,10 +186,25 @@ void
 modest_ui_actions_on_new_msg (GtkWidget *widget, ModestWindow *win)
 {
        ModestWindow *msg_win;
 modest_ui_actions_on_new_msg (GtkWidget *widget, ModestWindow *win)
 {
        ModestWindow *msg_win;
-       msg_win = modest_msg_edit_window_new (MODEST_EDIT_TYPE_NEW);
+       TnyMsg *msg;
+       gchar *account;
+       gchar *from_str;
+
+       account = g_strdup(modest_window_get_active_account (win));
+       if (!account)
+               account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
+       
+       from_str = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
+                                                      account);
+       
+       msg = modest_tny_msg_new ("", from_str, "", "", "", "", NULL);
+       msg_win = modest_msg_edit_window_new (msg, account);
        if (win)
                gtk_window_set_transient_for (GTK_WINDOW (msg_win),
        if (win)
                gtk_window_set_transient_for (GTK_WINDOW (msg_win),
-                                             GTK_WINDOW (win));
+                                             GTK_WINDOW (win));        
+       g_free (account);
+       g_free (from_str);
+       g_object_unref (G_OBJECT(msg));
        
        gtk_widget_show_all (GTK_WIDGET (msg_win));
 }
        
        gtk_widget_show_all (GTK_WIDGET (msg_win));
 }
@@ -201,6 +218,8 @@ modest_ui_actions_on_open (GtkWidget *widget, ModestWindow *win)
 }
 
 
 }
 
 
+
+
 static void
 reply_forward_func (gpointer data, gpointer user_data)
 {
 static void
 reply_forward_func (gpointer data, gpointer user_data)
 {
@@ -209,29 +228,32 @@ reply_forward_func (gpointer data, gpointer user_data)
        ReplyForwardHelper *rf_helper;
        ModestWindow *msg_win;
        ModestEditType edit_type;
        ReplyForwardHelper *rf_helper;
        ModestWindow *msg_win;
        ModestEditType edit_type;
-
+       gchar *from;
+       
        msg = TNY_MSG (data);
        helper = (GetMsgAsyncHelper *) user_data;
        rf_helper = (ReplyForwardHelper *) helper->user_data;
 
        msg = TNY_MSG (data);
        helper = (GetMsgAsyncHelper *) user_data;
        rf_helper = (ReplyForwardHelper *) helper->user_data;
 
+       from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
+                                                  rf_helper->account);
        /* Create reply mail */
        switch (rf_helper->action) {
        case ACTION_REPLY:
                new_msg = 
                        modest_mail_operation_create_reply_mail (msg, 
        /* Create reply mail */
        switch (rf_helper->action) {
        case ACTION_REPLY:
                new_msg = 
                        modest_mail_operation_create_reply_mail (msg, 
-                                                                rf_helper->from, 
+                                                                from, 
                                                                 rf_helper->reply_forward_type,
                                                                 MODEST_MAIL_OPERATION_REPLY_MODE_SENDER);
                break;
        case ACTION_REPLY_TO_ALL:
                new_msg = 
                                                                 rf_helper->reply_forward_type,
                                                                 MODEST_MAIL_OPERATION_REPLY_MODE_SENDER);
                break;
        case ACTION_REPLY_TO_ALL:
                new_msg = 
-                       modest_mail_operation_create_reply_mail (msg, rf_helper->from, rf_helper->reply_forward_type,
+                       modest_mail_operation_create_reply_mail (msg, from, rf_helper->reply_forward_type,
                                                                 MODEST_MAIL_OPERATION_REPLY_MODE_ALL);
                edit_type = MODEST_EDIT_TYPE_REPLY;
                break;
        case ACTION_FORWARD:
                new_msg = 
                                                                 MODEST_MAIL_OPERATION_REPLY_MODE_ALL);
                edit_type = MODEST_EDIT_TYPE_REPLY;
                break;
        case ACTION_FORWARD:
                new_msg = 
-                       modest_mail_operation_create_forward_mail (msg, rf_helper->from, rf_helper->reply_forward_type);
+                       modest_mail_operation_create_forward_mail (msg, from, rf_helper->reply_forward_type);
                edit_type = MODEST_EDIT_TYPE_FORWARD;
                break;
        default:
                edit_type = MODEST_EDIT_TYPE_FORWARD;
                break;
        default:
@@ -244,16 +266,14 @@ reply_forward_func (gpointer data, gpointer user_data)
        }
                
        /* Show edit window */
        }
                
        /* Show edit window */
-       msg_win = modest_msg_edit_window_new (MODEST_EDIT_TYPE_NEW);
-       modest_msg_edit_window_set_msg (MODEST_MSG_EDIT_WINDOW (msg_win),
-                                       new_msg);
+       msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account);
        gtk_widget_show_all (GTK_WIDGET (msg_win));
        
        /* Clean */
        g_object_unref (G_OBJECT (new_msg));
 
  cleanup:
        gtk_widget_show_all (GTK_WIDGET (msg_win));
        
        /* Clean */
        g_object_unref (G_OBJECT (new_msg));
 
  cleanup:
-       g_free (rf_helper->from);
+       g_free (rf_helper->account);
        g_slice_free (ReplyForwardHelper, rf_helper);
 }
 
        g_slice_free (ReplyForwardHelper, rf_helper);
 }
 
@@ -264,14 +284,10 @@ static void
 reply_forward (GtkWidget *widget, ReplyForwardAction action,
               ModestMainWindow *main_window)
 {
 reply_forward (GtkWidget *widget, ReplyForwardAction action,
               ModestMainWindow *main_window)
 {
-       ModestAccountMgr *account_mgr;
        TnyList *header_list;
        guint reply_forward_type;
        TnyList *header_list;
        guint reply_forward_type;
-       ModestConf *conf;       
-       ModestAccountData *default_account_data;
        TnyHeader *header;
        TnyFolder *folder;
        TnyHeader *header;
        TnyFolder *folder;
-       gchar *from, *key, *default_account_name;
        GetMsgAsyncHelper *helper;
        ReplyForwardHelper *rf_helper;
 
        GetMsgAsyncHelper *helper;
        ReplyForwardHelper *rf_helper;
 
@@ -281,34 +297,21 @@ reply_forward (GtkWidget *widget, ReplyForwardAction action,
        header_list = modest_header_view_get_selected_headers (main_window->header_view);       
        if (!header_list)
                return;
        header_list = modest_header_view_get_selected_headers (main_window->header_view);       
        if (!header_list)
                return;
-
-       conf = modest_runtime_get_conf ();
        
        
-       /* Get reply or forward type */
-       key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE, 
-                              (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE);
-       reply_forward_type = modest_conf_get_int (conf, key, NULL);
-       g_free (key);
-
+       reply_forward_type = modest_conf_get_int (modest_runtime_get_conf (),
+                                                 (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE,
+                                                 NULL);
        /* We assume that we can only select messages of the
           same folder and that we reply all of them from the
           same account. In fact the interface currently only
           allows single selection */
        /* We assume that we can only select messages of the
           same folder and that we reply all of them from the
           same account. In fact the interface currently only
           allows single selection */
-       account_mgr = modest_runtime_get_account_mgr();
-       default_account_name = modest_account_mgr_get_default_account (account_mgr);
-       default_account_data = 
-               modest_account_mgr_get_account_data (account_mgr,
-                                                    (const gchar*) default_account_name);
-       from = g_strdup (default_account_data->email);
-       modest_account_mgr_free_account_data (account_mgr, default_account_data);
-       g_free (default_account_name);
-       
+               
        /* Fill helpers */
        rf_helper = g_slice_new0 (ReplyForwardHelper);
        rf_helper->reply_forward_type = reply_forward_type;
        rf_helper->action = action;
        /* Fill helpers */
        rf_helper = g_slice_new0 (ReplyForwardHelper);
        rf_helper->reply_forward_type = reply_forward_type;
        rf_helper->action = action;
-       rf_helper->from = from;
-       
+       rf_helper->account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());;
+
        helper = g_slice_new0 (GetMsgAsyncHelper);
        helper->main_window = main_window;
        helper->func = reply_forward_func;
        helper = g_slice_new0 (GetMsgAsyncHelper);
        helper->main_window = main_window;
        helper->func = reply_forward_func;
@@ -372,6 +375,24 @@ modest_ui_actions_on_prev (GtkWidget *widget,
 
 
 void
 
 
 void
+modest_ui_actions_on_send_receive (GtkWidget *widget,  ModestWindow *win)
+{
+       TnyDevice *device;
+       TnyAccountStore *account_store;
+       
+       /* Get device. Do not ask the platform factory for it, because
+          it returns always a new one */
+       account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ());
+       device = tny_account_store_get_device (account_store);
+       
+       tny_device_force_online (device);
+       
+       /* FIXME: refresh the folders */
+}
+
+
+
+void
 modest_ui_actions_toggle_view (GtkWidget *widget, ModestMainWindow *main_window)
 {
        ModestConf *conf;
 modest_ui_actions_toggle_view (GtkWidget *widget, ModestMainWindow *main_window)
 {
        ModestConf *conf;
@@ -522,7 +543,8 @@ modest_ui_actions_on_header_activated (ModestHeaderView *folder_view, TnyHeader
        ModestWindow *win;
        TnyFolder *folder = NULL;
        TnyMsg    *msg    = NULL;
        ModestWindow *win;
        TnyFolder *folder = NULL;
        TnyMsg    *msg    = NULL;
-
+       gchar *account    = NULL;
+       
        g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
        
        if (!header)
        g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
        
        if (!header)
@@ -541,13 +563,19 @@ modest_ui_actions_on_header_activated (ModestHeaderView *folder_view, TnyHeader
                goto cleanup;
        }
 
                goto cleanup;
        }
 
-       win = modest_msg_view_window_new (msg);
+       account =  g_strdup(modest_window_get_active_account(MODEST_WINDOW(main_window)));
+       if (!account)
+               account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
+       
+       win = modest_msg_view_window_new (msg, account);
        gtk_window_set_transient_for (GTK_WINDOW (win),
                                      GTK_WINDOW (main_window));
 
        gtk_widget_show_all (GTK_WIDGET(win));
        
 cleanup:
        gtk_window_set_transient_for (GTK_WINDOW (win),
                                      GTK_WINDOW (main_window));
 
        gtk_widget_show_all (GTK_WIDGET(win));
        
 cleanup:
+       g_free (account);
+       
        if (folder)
                g_object_unref (G_OBJECT (folder));
        if (msg)
        if (folder)
                g_object_unref (G_OBJECT (folder));
        if (msg)
@@ -785,9 +813,11 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
           use the send queue provided by tinymail and some
           classifier */
        account_mgr = modest_runtime_get_account_mgr();
           use the send queue provided by tinymail and some
           classifier */
        account_mgr = modest_runtime_get_account_mgr();
-       account_name = modest_account_mgr_get_default_account (account_mgr);
+       account_name = g_strdup(modest_window_get_active_account (MODEST_WINDOW(edit_window)));
+       if (!account_name) 
+               account_name = modest_account_mgr_get_default_account (account_mgr);
        if (!account_name) {
        if (!account_name) {
-               g_printerr ("modest: no default account found\n");
+               g_printerr ("modest: no account found\n");
                modest_msg_edit_window_free_msg_data (edit_window, data);
                return;
        }
                modest_msg_edit_window_free_msg_data (edit_window, data);
                return;
        }
index 5bb2802..be7fd3e 100644 (file)
@@ -98,6 +98,8 @@ void     modest_ui_actions_on_msg_attachment_clicked   (ModestMsgView *msgview,
 void     modest_ui_actions_on_send                     (GtkWidget *widget,
                                                        ModestMsgEditWindow *edit_window);
 
 void     modest_ui_actions_on_send                     (GtkWidget *widget,
                                                        ModestMsgEditWindow *edit_window);
 
+void    modest_ui_actions_on_send_receive              (GtkWidget *widget, ModestWindow *win);
+
 void     modest_ui_actions_on_new_folder               (GtkWidget *widget,
                                                         ModestMainWindow *main_window);
 
 void     modest_ui_actions_on_new_folder               (GtkWidget *widget,
                                                         ModestMainWindow *main_window);