+2007-06-19 Murray Cumming,,, <murrayc@murrayc-desktop>
+
+ * libmodest-dbus-client/libmodest-dbus-client.c:
+ (_dbus_iter_get_string_or_null): Initialize the string variable in
+ case this helps with Dirk's crash.
+
+2007-06-19 Murray Cumming <murrayc@murrayc.com>
+
+ * src/dbus_api/modest-dbus-api.h: Add the attachments enum for send_mail,
+ though it is not implemented yet (this function is maybe not even used),
+ to avoid breaking ABI in future.
+ * libmodest-dbus-client/libmodest-dbus-client.c:
+ (get_attachments_string): Moved some code into this generic function.
+ (libmodest_dbus_client_send_mail): Corrected the documentation. This really
+ sends email. It is maybe not used.
+ * src/dbus_api/modest-dbus-callbacks.c: (on_idle_send_mail),
+ (on_send_mail): Use attachments.
+
+ * src/widgets/modest-msg-edit-window.h: Improve the documentation.
+ * src/maemo/modest-msg-edit-window.c:
+ (modest_msg_edit_window_attach_file_noninteractive): Convert the URI to
+ a filename before using it, to fix projects.maemo.org bug NB#58233.
+
2007-06-19 Murray Cumming <murrayc@murrayc.com>
* src/modest-ui-actions.c: (modest_ui_actions_on_copy):
#include <dbus/dbus-glib-lowlevel.h>
#include <string.h>
+
+
+/** Get a comma-separated list of attachement URI strings,
+ * from a list of strings.
+ */
+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);
+ 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:
* @osso_context: a valid #osso_context_t object.
* @attachments: Additional list of attachments
*
* This function will try to do a remote procedure call (rpc)
- * into modest (or start it if necessary) and open a composer
- * window with the supplied parameters prefilled.
+ * into modest (or start it if necessary) and send a new
+ * email with the supplied parameters.
*
* 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,
DBUS_TYPE_STRING, bcc,
DBUS_TYPE_STRING, subject,
DBUS_TYPE_STRING, body,
+ DBUS_TYPE_STRING, attachments_str,
DBUS_TYPE_INVALID);
if (ret != OSSO_OK) {
osso_rpc_free_val(&retval);
+ g_free (attachments_str);
+
return TRUE;
}
return TRUE;
}
+/**
+ * libmodest_dbus_client_compose_mail:
+ * @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
+ *
+ * This function will try to do a remote procedure call (rpc)
+ * 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_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;
- gchar *attachments_str = NULL;
- gchar *tmp = NULL;
- GSList *next = NULL;
- attachments_str = g_strdup( (gchar *) attachments->data );
-
- for (next = g_slist_next(attachments); next != NULL; next = g_slist_next(next))
- {
- tmp = g_strconcat(attachments_str, ",", (gchar *) (next->data), NULL);
- g_free(attachments_str);
- attachments_str = tmp;
- if (attachments_str == NULL) {
- return OSSO_ERROR;
- }
- }
+ gchar *attachments_str = get_attachments_string(attachments);
const osso_return_t ret = osso_rpc_run_with_defaults(osso_context,
MODEST_DBUS_NAME,
}
osso_rpc_free_val(&retval);
+
+ g_free (attachments_str);
return TRUE;
}
static char *
_dbus_iter_get_string_or_null (DBusMessageIter *iter)
{
- const char *string;
- char *ret;
+ const char *string = NULL;
+ char *ret = NULL;
dbus_message_iter_get_basic (iter, &string);
- ret = NULL;
if (string && strlen (string)) {
ret = g_strdup (string);
}
* @flags: A list of flags where to search so the documentation
* of %ModestDBusSearchFlags for details.
* @hits: A pointer to a valid GList pointer that will contain the search
- * hits (must be freed by the caller).
+ * hits (ModestSearchHit). The list and the items must be freed by the caller
+ * with modest_search_hit_list_free().
*
* This method will search the folder specified by a valid url in @folder or all
* known accounts (local and remote) if %NULL for matches of the search term(s)
gchar *bcc;
gchar *subject;
gchar *body;
+ gchar *attachments;
} SendMailIdleData;
typedef struct
g_free (idle_data->bcc);
g_free (idle_data->subject);
g_free (idle_data->body);
+ g_free (idle_data->attachments);
g_free (idle_data);
return FALSE; /* Do not call this callback again. */
}
+/* TODO: Is this actually used by anything?
+ * I guess that everything uses *_compose_mail() instead. murrayc.
+ */
static gint on_send_mail(GArray * arguments, gpointer data, osso_rpc_t * retval)
{
if (arguments->len != MODEST_DEBUS_SEND_MAIL_ARGS_COUNT)
val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_BODY);
idle_data->body = g_strdup (val.value.s);
+ val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_SEND_MAIL_ARG_ATTACHMENTS);
+ idle_data->attachments = g_strdup (val.value.s);
+
/* printf(" debug: to=%s\n", idle_data->to); */
g_idle_add(on_idle_send_mail, (gpointer)idle_data);