* Fixes: NB#55446
[modest] / src / dbus_api / modest-dbus-callbacks.c
index a8fbc5e..a8e1b22 100644 (file)
@@ -32,6 +32,7 @@
 #include "modest-account-mgr.h"
 #include "modest-account-mgr-helpers.h"
 #include "modest-tny-account.h"
+#include "modest-ui-actions.h"
 #include "widgets/modest-msg-edit-window.h"
 #include "modest-tny-msg.h"
 #include <libgnomevfs/gnome-vfs-utils.h>
@@ -61,10 +62,9 @@ on_idle_send_mail(gpointer user_data)
        
        TnyTransportAccount *transport_account = NULL;
        if (account_mgr) {
-               transport_account = TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_tny_account_by_account
+               transport_account = TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_transport_account_for_open_connection
                                      (modest_runtime_get_account_store(),
-                                      account_name,
-                                      TNY_ACCOUNT_TYPE_TRANSPORT));
+                                      account_name));
        }
        
        if (!transport_account) {
@@ -79,7 +79,7 @@ on_idle_send_mail(gpointer user_data)
                if (!from) {
                        g_printerr ("modest: no from address for account '%s'\n", account_name);
                } else {
-                       ModestMailOperation *mail_operation = modest_mail_operation_new ();
+                       ModestMailOperation *mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_SEND, NULL);
                        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
                        
                        modest_mail_operation_send_new_mail (mail_operation,
@@ -270,9 +270,8 @@ on_idle_mail_to(gpointer user_data)
        
        TnyAccount *account = NULL;
        if (account_mgr) {
-               account = modest_tny_account_store_get_tny_account_by_account (
-                       modest_runtime_get_account_store(), account_name,
-                       TNY_ACCOUNT_TYPE_TRANSPORT);
+               account = modest_tny_account_store_get_transport_account_for_open_connection (
+                       modest_runtime_get_account_store(), account_name);
        }
        
        if (!account) {
@@ -406,6 +405,30 @@ static gint on_open_message(GArray * arguments, gpointer data, osso_rpc_t * retv
         * because that would be asynchronous. */
        return OSSO_OK;
 }
+
+static gboolean
+on_idle_send_receive(gpointer user_data)
+{
+       ModestWindow* main_window = modest_window_mgr_get_main_window(
+               modest_runtime_get_window_mgr ());
+       do_send_receive(main_window);
+       
+       return FALSE; /* Do not call this callback again. */
+}
+
+static gint on_send_receive(GArray * arguments, gpointer data, osso_rpc_t * retval)
+{      
+    /* Use g_idle to context-switch into the application's thread: */
+
+    /* This method has no arguments. */
+       
+       /* printf("  debug: to=%s\n", idle_data->to); */
+       g_idle_add(on_idle_send_receive, NULL);
+       
+       /* Note that we cannot report failures during send/receive, 
+        * because that would be asynchronous. */
+       return OSSO_OK;
+}
                       
 /* Callback for normal D-BUS messages */
 gint modest_dbus_req_handler(const gchar * interface, const gchar * method,
@@ -422,7 +445,28 @@ gint modest_dbus_req_handler(const gchar * interface, const gchar * method,
                return on_mail_to (arguments, data, retval);
        } else if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_OPEN_MESSAGE) == 0) {
                return on_open_message (arguments, data, retval);
+       } else if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_SEND_RECEIVE) == 0) {
+               return on_send_receive (arguments, data, retval);
        }
        else
                return OSSO_ERROR;
 }
+
+void
+modest_osso_cb_hw_state_handler(osso_hw_state_t *state, gpointer data)
+{
+    printf("%s()\n", __PRETTY_FUNCTION__);
+
+    if(state->system_inactivity_ind)
+    {
+    }
+    else if(state->save_unsaved_data_ind)
+    {
+    }
+    else
+    {
+    
+    }
+
+    printf("debug: %s(): return\n", __PRETTY_FUNCTION__);
+}