2007-06-12 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Tue, 12 Jun 2007 11:25:18 +0000 (11:25 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 12 Jun 2007 11:25:18 +0000 (11:25 +0000)
* src/dbus_api/modest-dbus-api.h:
        * src/dbus_api/modest-dbus-callbacks.c:
        (on_idle_open_default_inbox), (on_open_default_inbox),
        (modest_dbus_req_handler):
        Added a new OpenDefaultInbox method.

        * libmodest-dbus-client/libmodest-dbus-client.h:
        * libmodest-dbus-client/libmodest-dbus-client.c:
        Added libmodest_dbus_client_open_default_inbox() to call the new
        dbus method. This should be useful to projects.maemo.org bug NB#57214,
        though it should maybe be used by a new osso-email-interface function.

        * tests/dbus_api/Makefile.am:
        * tests/dbus_api/test_open_default_inbox.c: Added a test for the new
        function.

pmo-trunk-r2179

ChangeLog2
libmodest-dbus-client/libmodest-dbus-client.c
libmodest-dbus-client/libmodest-dbus-client.h
src/dbus_api/modest-dbus-api.h
src/dbus_api/modest-dbus-callbacks.c
tests/dbus_api/Makefile.am
tests/dbus_api/test_open_default_inbox.c [new file with mode: 0644]

index 3620bb5..5010652 100644 (file)
@@ -1,5 +1,23 @@
 2007-06-12  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/dbus_api/modest-dbus-api.h:
+       * src/dbus_api/modest-dbus-callbacks.c:
+       (on_idle_open_default_inbox), (on_open_default_inbox),
+       (modest_dbus_req_handler):
+       Added a new OpenDefaultInbox method.
+       
+       * libmodest-dbus-client/libmodest-dbus-client.h:
+       * libmodest-dbus-client/libmodest-dbus-client.c:
+       Added libmodest_dbus_client_open_default_inbox() to call the new 
+       dbus method. This should be useful to projects.maemo.org bug NB#57214,
+       though it should maybe be used by a new osso-email-interface function.
+       
+       * tests/dbus_api/Makefile.am:
+       * tests/dbus_api/test_open_default_inbox.c: Added a test for the new 
+       function.
+
+2007-06-12  Murray Cumming  <murrayc@murrayc.com>
+
        * src/modest-account-mgr.c: (on_key_change): Append to the list, not to 
        NULL, so that the signals get all the keys. This should not actually 
        change any behaviour because we currently update everything when anything 
index 1d5c772..8c89c45 100644 (file)
@@ -201,6 +201,27 @@ libmodest_dbus_client_send_and_receive (osso_context_t *osso_context)
        return TRUE;
 }
 
+gboolean 
+libmodest_dbus_client_open_default_inbox (osso_context_t *osso_context)
+{
+       osso_rpc_t retval;
+       const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
+                  MODEST_DBUS_NAME, 
+                  MODEST_DBUS_METHOD_OPEN_DEFAULT_INBOX, &retval, 
+                  DBUS_TYPE_INVALID);
+               
+       if (ret != OSSO_OK) {
+               printf("debug: osso_rpc_run() failed.\n");
+               return FALSE;
+       } else {
+               printf("debug: osso_rpc_run() succeeded.\n");
+       }
+       
+       osso_rpc_free_val(&retval);
+       
+       return TRUE;
+}
+
 /**
  * libmodest_dbus_client_delete_message:
  * @osso_context: a valid #osso_context_t object.
index 6afc269..cb7609e 100644 (file)
@@ -55,6 +55,8 @@ libmodest_dbus_client_open_message (osso_context_t *osso_context,
 gboolean 
 libmodest_dbus_client_send_and_receive (osso_context_t *osso_context);
 
+gboolean 
+libmodest_dbus_client_open_default_inbox (osso_context_t *osso_context);
 
 typedef enum {
 
index cb6cb4d..2a02242 100644 (file)
@@ -89,6 +89,9 @@ enum ModestDbusDeleteMessageArguments
        MODEST_DEBUS_DELETE_MESSAGE_ARGS_COUNT
 };
 
+#define MODEST_DBUS_METHOD_OPEN_DEFAULT_INBOX "OpenDefaultInbox"
+
+
 
 
 #endif /* __MODEST_DBUS_API__ */
index 875eb09..ee4419a 100644 (file)
@@ -766,6 +766,34 @@ static gint on_send_receive(GArray * arguments, gpointer data, osso_rpc_t * retv
         * because that would be asynchronous. */
        return OSSO_OK;
 }
+
+static gboolean
+on_idle_open_default_inbox(gpointer user_data)
+{
+       ModestWindow *win = 
+               modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
+
+       /* Get the folder view */
+       GtkWidget *folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+                                                          MODEST_WIDGET_TYPE_FOLDER_VIEW);
+       modest_folder_view_select_first_inbox_or_local (
+               MODEST_FOLDER_VIEW (folder_view));
+       
+       return FALSE; /* Do not call this callback again. */
+}
+
+static gint on_open_default_inbox(GArray * arguments, gpointer data, osso_rpc_t * retval)
+{
+    /* Use g_idle to context-switch into the application's thread: */
+
+    /* This method has no arguments. */
+       
+       g_idle_add(on_idle_open_default_inbox, 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,
@@ -788,6 +816,8 @@ gint modest_dbus_req_handler(const gchar * interface, const gchar * method,
                return on_compose_mail (arguments, data, retval);
        } else if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_DELETE_MESSAGE) == 0) {
                return on_delete_message (arguments,data, retval);
+       } else if (g_ascii_strcasecmp(method, MODEST_DBUS_METHOD_OPEN_DEFAULT_INBOX) == 0) {
+               return on_open_default_inbox (arguments, data, retval);
        }
        else { 
                /* We need to return INVALID here so
@@ -1022,6 +1052,7 @@ modest_dbus_req_filter (DBusConnection *con,
                DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
 }
 
+
 void
 modest_osso_cb_hw_state_handler(osso_hw_state_t *state, gpointer data)
 {
index c92fa4d..27805a7 100644 (file)
@@ -21,7 +21,8 @@ noinst_PROGRAMS = test_send_mail      \
                  test_open_message   \
                  test_search         \
                  test_delete_message \
-                 test_compose_mail
+                 test_compose_mail \
+                 test_open_default_inbox
 
 test_send_mail_SOURCES = test_send_mail.c
 test_send_mail_LDADD = $(objects)
@@ -32,15 +33,14 @@ test_mail_to_LDADD = $(objects)
 test_open_message_SOURCES = test_open_message.c
 test_open_message_LDADD = $(objects)
 
-
 test_compose_mail_SOURCES = test_compose_mail.c
 test_compose_mail_LDADD = $(objects)
 
 test_search_SOURCES = test_search.c
 test_search_LDADD = $(objects)
 
-
 test_delete_message_SOURCES = test_delete_message.c
 test_delete_message_LDADD = $(objects)
 
-
+test_open_default_inbox_SOURCES = test_open_default_inbox.c
+test_open_default_inbox_LDADD = $(objects)
diff --git a/tests/dbus_api/test_open_default_inbox.c b/tests/dbus_api/test_open_default_inbox.c
new file mode 100644 (file)
index 0000000..4b320ae
--- /dev/null
@@ -0,0 +1,38 @@
+#include <libmodest-dbus-client/libmodest-dbus-client.h>
+#include <stdio.h>
+
+int
+main (int argc, char *argv[])
+{
+       osso_context_t *osso_context;
+       const char *url;
+       gboolean ret; 
+
+       osso_context = osso_initialize ("test_open_default_inbox",
+                                       "0.0.1",
+                                       TRUE,
+                                       NULL);
+              
+       if (osso_context == NULL) {
+               g_printerr ("osso_initialize() failed.\n");
+           return -1;
+       }
+       
+       if (argc == 2) {
+               url = argv[1];
+       } else {
+               url = "local://???FIXME???";
+       }
+
+       g_print ("Trying to open the default inbox:\n", url);
+       ret = libmodest_dbus_client_open_default_inbox (osso_context);
+
+       if (!ret) {
+               g_printerr ("libmodest_dbus_client_open_default_inbox() failed.\n");
+       } else {
+               g_print ("libmodest_dbus_client_open_default_inbox() succeeded.\n");
+       }
+               
+    return ret ? 0 : -1;
+
+}