New virtual method modest_account_protocol_decode_part_to_stream, to
[modest] / libmodest-dbus-client / libmodest-dbus-client.c
index 19210d3..b483dc7 100644 (file)
@@ -44,81 +44,42 @@ static gchar* get_attachments_string (GSList *attachments)
 {
        if (!attachments)
                return NULL;
-               
+
        gchar *attachments_str = g_strdup("");
-       
+
        GSList *iter = attachments;
        while (iter)
        {
                if (iter->data) {
-                       gchar *tmp = g_strconcat(attachments_str, ",", (gchar *) (iter->data), NULL);
+                       gchar *escaped;
+                       gchar *tmp;
+                       escaped = g_uri_escape_string ((const gchar *) (iter->data), NULL, TRUE);
+                       tmp = g_strconcat(attachments_str, ",", escaped, NULL);
+                       g_free(escaped);
                        g_free(attachments_str);
                        attachments_str = tmp;
                }
-               
                iter = g_slist_next(iter);
        }
-       
        return attachments_str;
 }
 
-/* TODO: Is this actually used by anything?
- * I guess that everything uses *_compose_mail() instead. murrayc.
- */
 /**
- * libmodest_dbus_client_send_mail:
+ * libmodest_dbus_client_mail_to:
  * @osso_context: a valid #osso_context_t object.
- * @to: The Recipients (From: line)
- * @cc: Recipients for carbon copies
- * @bcc: Recipients for blind carbon copies
- * @subject: Subject line
- * @body: The actual body of the mail to send
- * @attachments: Additional list of attachments
+ * @mailto_uri: A mailto URI.
  * 
  * This function will try to do a remote procedure call (rpc)
- * into modest (or start it if necessary) and send a new 
- * email with the supplied parameters.
+ * into modest (or start it if necessary) and open a composer
+ * window with the supplied parameters prefilled.
  *
  * Return value: Whether or not the rpc call to modest
  * was successfull
  **/
-gboolean
-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)
-{
-       gchar *attachments_str = get_attachments_string(attachments);
-       
-       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, 
-                  DBUS_TYPE_STRING, attachments_str,
-                  DBUS_TYPE_INVALID);
-               
-       if (ret != OSSO_OK) {
-               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
-               return FALSE;
-       } else {
-               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
-       }
-       
-       osso_rpc_free_val(&retval);
-       
-       g_free (attachments_str);
-       
-       return TRUE;
-}
-       
 gboolean 
 libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto_uri)
 {
-       osso_rpc_t retval;
+       osso_rpc_t retval = { 0 };
        const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
                   MODEST_DBUS_NAME, 
                   MODEST_DBUS_METHOD_MAIL_TO, &retval, 
@@ -144,8 +105,8 @@ libmodest_dbus_client_mail_to (osso_context_t *osso_context, const gchar *mailto
  * @cc: Recipients for carbon copies
  * @bcc: Recipients for blind carbon copies
  * @subject: Subject line
- * @body: The actual body of the mail to send
- * @attachments: Additional list of attachments
+ * @body: The actual body of the mail to compose.
+ * @attachments: Additional list of attachments. A list of URI strings.
  * 
  * This function will try to do a remote procedure call (rpc)
  * into modest (or start it if necessary) and open a composer
@@ -158,11 +119,11 @@ gboolean
 libmodest_dbus_client_compose_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;
-       
+       osso_rpc_t retval = { 0 };
+
        gchar *attachments_str = get_attachments_string(attachments);
 
-       const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
+       const osso_return_t ret = osso_rpc_run_with_defaults(osso_context,
                   MODEST_DBUS_NAME, 
                   MODEST_DBUS_METHOD_COMPOSE_MAIL, &retval, 
                   DBUS_TYPE_STRING, to, 
@@ -172,18 +133,19 @@ libmodest_dbus_client_compose_mail (osso_context_t *osso_context, const gchar *t
                   DBUS_TYPE_STRING, body,
                   DBUS_TYPE_STRING, attachments_str,
                   DBUS_TYPE_INVALID);
-               
+
+       g_free (attachments_str);
+
        if (ret != OSSO_OK) {
                printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
                return FALSE;
        } else {
                printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
        }
-       
+
        osso_rpc_free_val(&retval);
 
-       g_free (attachments_str);
-       
+
        return TRUE;
 }
 
@@ -202,7 +164,7 @@ libmodest_dbus_client_compose_mail (osso_context_t *osso_context, const gchar *t
 gboolean 
 libmodest_dbus_client_open_message (osso_context_t *osso_context, const gchar *mail_uri)
 {
-       osso_rpc_t retval;
+       osso_rpc_t retval = { 0 };
        const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
                   MODEST_DBUS_NAME, 
                   MODEST_DBUS_METHOD_OPEN_MESSAGE, &retval, 
@@ -224,7 +186,7 @@ libmodest_dbus_client_open_message (osso_context_t *osso_context, const gchar *m
 gboolean 
 libmodest_dbus_client_send_and_receive (osso_context_t *osso_context)
 {
-       osso_rpc_t retval;
+       osso_rpc_t retval = { 0 };
        const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
                   MODEST_DBUS_NAME, 
                   MODEST_DBUS_METHOD_SEND_RECEIVE, &retval, 
@@ -245,7 +207,7 @@ libmodest_dbus_client_send_and_receive (osso_context_t *osso_context)
 gboolean 
 libmodest_dbus_client_open_default_inbox (osso_context_t *osso_context)
 {
-       osso_rpc_t retval;
+       osso_rpc_t retval = { 0 };
        const osso_return_t ret = osso_rpc_run_with_defaults(osso_context, 
                   MODEST_DBUS_NAME, 
                   MODEST_DBUS_METHOD_OPEN_DEFAULT_INBOX, &retval, 
@@ -263,6 +225,30 @@ libmodest_dbus_client_open_default_inbox (osso_context_t *osso_context)
        return TRUE;
 }
 
+gboolean
+libmodest_dbus_client_open_account (osso_context_t *osso_context,
+                                   const gchar *account_id)
+{
+       osso_rpc_t retval = { 0 };
+       const osso_return_t ret =
+               osso_rpc_run_with_defaults(osso_context,
+                                          MODEST_DBUS_NAME,
+                                          MODEST_DBUS_METHOD_OPEN_ACCOUNT, &retval,
+                                          DBUS_TYPE_STRING, account_id,
+                                          DBUS_TYPE_INVALID);
+
+       if (ret != OSSO_OK) {
+               printf("debug: %s: osso_rpc_run() failed.\n", __FUNCTION__);
+               return FALSE;
+       } else {
+               printf("debug: %s: osso_rpc_run() succeeded.\n", __FUNCTION__);
+       }
+
+       osso_rpc_free_val(&retval);
+
+       return TRUE;
+}
+
 /**
  * libmodest_dbus_client_delete_message:
  * @osso_context: a valid #osso_context_t object.
@@ -278,7 +264,7 @@ gboolean
 libmodest_dbus_client_delete_message (osso_context_t   *osso_ctx,
                                      const char       *msg_uri)
 {
-       osso_rpc_t    retval;
+       osso_rpc_t    retval = { 0 };
        osso_return_t ret;
        
        ret = osso_rpc_run_with_defaults (osso_ctx, 
@@ -655,8 +641,8 @@ libmodest_dbus_client_search (osso_context_t          *osso_ctx,
                folder = "";
        }
 
-       sd_v = start_date;
-       ed_v = end_date;
+       sd_v = (dbus_int64_t) start_date;
+       ed_v = (dbus_int64_t) end_date;
        flags_v = (dbus_int32_t) flags;
        size_v = (dbus_uint32_t) min_size;