2007-04-24 Murray Cumming <murrayc@murrayc.com>
[modest] / libmodest-dbus-client / libmodest-dbus-client.c
index 98522e1..55e03c3 100644 (file)
 #include "libmodest-dbus-client.h"
 #include <dbus_api/modest-dbus-api.h> /* For the API strings. */
 
-
 gboolean
-libmodest_dbus_client_call_helloworld(osso_context_t *osso_context)
+libmodest_dbus_client_send_mail (osso_context_t *osso_context, const gchar *to, const gchar *cc, 
+       const gchar *bcc, const gchar* subject, const gchar* body, GSList *attachments)
 {
        osso_rpc_t retval;
        const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
                   MODEST_DBUS_NAME, 
-                  MODEST_DBUS_EXAMPLE_MESSAGE, &retval, 
+                  MODEST_DBUS_METHOD_SEND_MAIL, &retval, 
+                  DBUS_TYPE_STRING, to, 
+                  DBUS_TYPE_STRING, cc, 
+                  DBUS_TYPE_STRING, bcc, 
+                  DBUS_TYPE_STRING, subject, 
+                  DBUS_TYPE_STRING, body, 
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
@@ -51,20 +56,15 @@ libmodest_dbus_client_call_helloworld(osso_context_t *osso_context)
        
        return TRUE;
 }
-
-gboolean
-libmodfest_dbus_client_send_mail (osso_context_t *osso_context, const gchar *to, const gchar *cc, 
-       const gchar *bcc, const gchar* subject, const gchar* body, GSList *attachments)
+       
+gboolean 
+libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto_uri)
 {
        osso_rpc_t retval;
        const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
                   MODEST_DBUS_NAME, 
-                  MODEST_DBUS_METHOD_SEND_MAIL, &retval, 
-                  DBUS_TYPE_STRING, to, 
-                  DBUS_TYPE_STRING, cc, 
-                  DBUS_TYPE_STRING, bcc, 
-                  DBUS_TYPE_STRING, subject, 
-                  DBUS_TYPE_STRING, body, 
+                  MODEST_DBUS_METHOD_MAIL_TO, &retval, 
+                  DBUS_TYPE_STRING, mailto_uri, 
                   DBUS_TYPE_INVALID);
                
        if (ret != OSSO_OK) {
@@ -78,17 +78,27 @@ libmodfest_dbus_client_send_mail (osso_context_t *osso_context, const gchar *to,
        
        return TRUE;
 }
-       
-gboolean 
-libmodfest_dbus_client_mailto (osso_context_t *osso_context, const gchar *mailto_uri)
-{
-       return FALSE;
-}
 
 gboolean 
-libmodfest_dbus_client_open_message (osso_context_t *osso_context, const gchar *mail_uri)
+libmodest_dbus_client_open_message (osso_context_t *osso_context, const gchar *mail_uri)
 {
-       return FALSE;
+       osso_rpc_t retval;
+       const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
+                  MODEST_DBUS_NAME, 
+                  MODEST_DBUS_METHOD_OPEN_MESSAGE, &retval, 
+                  DBUS_TYPE_STRING, mail_uri, 
+                  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;
 }