2007-08-17 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Fri, 17 Aug 2007 16:15:39 +0000 (16:15 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Fri, 17 Aug 2007 16:15:39 +0000 (16:15 +0000)
* src/dbus_api/modest-dbus-callbacks.c:
        (on_dbus_method_get_folders): Avoid trying to get the account name
        when there are no accounts, to avoid critical g_warnings, fixing
        projects.maemo.org bug NB#65574.

pmo-trunk-r3013

ChangeLog2
src/dbus_api/modest-dbus-callbacks.c
src/modest-ui-actions.c

index cbb6b31..e57cb4c 100644 (file)
@@ -1,5 +1,21 @@
 2007-08-17  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/dbus_api/modest-dbus-callbacks.c:
+       (on_dbus_method_get_folders): Avoid trying to get the account name 
+       when there are no accounts, to avoid critical g_warnings, fixing 
+       projects.maemo.org bug NB#65574.
+
+2007-08-17  Murray Cumming  <murrayc@murrayc.com>
+
+       * src/modest-ui-actions.c: (modest_ui_actions_on_new_msg): 
+       Use modest_account_mgr_get_signature() instead of accessing gconf 
+       directly, to slightly simplify the code.
+       * src/dbus_api/modest-dbus-callbacks.c: (on_idle_compose_mail):
+       Append the signature also when opening via other applications, 
+       fixing projects.maemo.org bug NB#65828.
+
+2007-08-17  Murray Cumming  <murrayc@murrayc.com>
+
        * src/modest-tny-send-queue.c: (modest_tny_send_queue_get_msg_id):
        Check for NULLs to prevent a crash when opening an email that is 
        an attachment in another email, fixing projects.maemo.org bug 
index d88583b..cfd92a8 100644 (file)
@@ -379,12 +379,36 @@ on_idle_compose_mail(gpointer user_data)
                if (!from) {
                        g_printerr ("modest: no from address for account '%s'\n", account_name);
                } else {
-       
+                       /* Get the signature. 
+                        * TODO: This, like much of this function is copy/pasted from 
+                        * modest_ui_actions_on_new_msg(): */
+                       gboolean use_signature = FALSE;
+                       gchar *signature = modest_account_mgr_get_signature (modest_runtime_get_account_mgr (), account_name, &use_signature);
+               
+                       gchar* blank_and_signature = NULL;
+                       if (use_signature) {
+                               blank_and_signature = g_strconcat ("\n", signature, NULL);
+                       } else {
+                               blank_and_signature = g_strdup ("");
+                       }
+                       g_free (signature);
+                       
+                       /* Add it to the body. */
+                       gchar *body_with_sig = NULL;
+                       if (!(idle_data->body))
+                               body_with_sig = g_strdup (blank_and_signature);
+                       else {
+                               body_with_sig = g_strconcat (idle_data->body, blank_and_signature, NULL);
+                       }
+                               
                        /* Create the message: */
                        TnyMsg *msg  = modest_tny_msg_new (idle_data->to, from, 
-                               idle_data->cc, idle_data->bcc, idle_data->subject, idle_data->body, 
+                               idle_data->cc, idle_data->bcc, idle_data->subject, body_with_sig, 
                                NULL); /* NULL because m_t_m_n doesn't use it */
                                
+                       g_free (body_with_sig);
+                       g_free (blank_and_signature);
+                               
                        if (!msg) {
                                g_printerr ("modest: failed to create message\n");
                        } else
@@ -1395,26 +1419,29 @@ on_dbus_method_get_folders (DBusConnection *con, DBusMessage *message)
                g_printerr ("modest: no account found\n");
        }
        
-       TnyAccount *account = NULL;
-       if (account_mgr) {
-               account = modest_tny_account_store_get_server_account (
-                       modest_runtime_get_account_store(), account_name, 
-                       TNY_ACCOUNT_TYPE_STORE);
-       }
+       GList *folder_names = NULL;
        
-       if (!account) {
-               g_printerr ("modest: failed to get tny account folder'%s'\n", account_name);
-       } 
+       TnyAccount *account = NULL;
+       if (account_name) {
+               if (account_mgr) {
+                       account = modest_tny_account_store_get_server_account (
+                               modest_runtime_get_account_store(), account_name, 
+                               TNY_ACCOUNT_TYPE_STORE);
+               }
+               
+               if (!account) {
+                       g_printerr ("modest: failed to get tny account folder'%s'\n", account_name);
+               } 
+               
+               printf("DEBUG: %s: Getting folders for account name=%s\n", __FUNCTION__, account_name);
+               g_free (account_name);
+               account_name = NULL;
                
-       printf("DEBUG: %s: Getting folders for account name=%s\n", __FUNCTION__, account_name);
-       g_free (account_name);
-       account_name = NULL;
+               add_folders_to_list (TNY_FOLDER_STORE (account), &folder_names);
        
-       GList *folder_names = NULL;
-       add_folders_to_list (TNY_FOLDER_STORE (account), &folder_names);
-
-       g_object_unref (account);
-       account = NULL;
+               g_object_unref (account);
+               account = NULL;
+       }
        
        /* Also add the folders from the local folders account,
         * because they are (currently) used with all accounts:
@@ -1464,13 +1491,11 @@ modest_dbus_req_filter (DBusConnection *con,
        if (dbus_message_is_method_call (message,
                                         MODEST_DBUS_IFACE,
                                         MODEST_DBUS_METHOD_SEARCH)) {
-               printf ("  DEBUG1: %s\n", __FUNCTION__);
                on_dbus_method_search (con, message);
                handled = TRUE;                         
        } else if (dbus_message_is_method_call (message,
                                         MODEST_DBUS_IFACE,
                                         MODEST_DBUS_METHOD_GET_FOLDERS)) {
-               printf ("  DEBUG2: %s\n", __FUNCTION__);
                on_dbus_method_get_folders (con, message);
                handled = TRUE;                         
        }
index f7d2a47..f35b31a 100644 (file)
@@ -717,16 +717,17 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
                goto cleanup;
        }
 
-       if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr (), account_name,
-                                        MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) {
-               signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), account_name,
-                                                          MODEST_ACCOUNT_SIGNATURE, FALSE);
+       gboolean use_signature = FALSE;
+       signature = modest_account_mgr_get_signature (modest_runtime_get_account_mgr (), account_name, &use_signature);
+
+       if (use_signature) {
                blank_and_signature = g_strconcat ("\n", signature, NULL);
-               g_free (signature);
        } else {
                blank_and_signature = g_strdup ("");
        }
 
+       g_free (signature);
+
        msg = modest_tny_msg_new ("", from_str, "", "", "", blank_and_signature, NULL);
        if (!msg) {
                g_printerr ("modest: failed to create new msg\n");
@@ -741,7 +742,7 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
        
 
        /* Create and register edit window */
-       /* This is destroyed by TOOD. */
+       /* This is destroyed by TODO. */
        msg_win = modest_msg_edit_window_new (msg, account_name, FALSE);
        mgr = modest_runtime_get_window_mgr ();
        modest_window_mgr_register_window (mgr, msg_win);