+ if (!account) {
+ g_printerr ("modest: failed to get tny account folder'\n", account_name);
+ } else {
+ gchar * from = modest_account_mgr_get_from_string (account_mgr,
+ account_name);
+ if (!from) {
+ g_printerr ("modest: no from address for account '%s'\n", account_name);
+ } else {
+ TnyMsg *msg = modest_tny_msg_new (uri /* mailto */, from,
+ NULL /* cc */, NULL /* bcc */,
+ NULL /* subject */, NULL /* body */, NULL /* attachments */);
+ if (!msg) {
+ g_printerr ("modest: failed to create message\n");
+ } else
+ {
+ TnyFolder *folder = modest_tny_account_get_special_folder (account,
+ TNY_FOLDER_TYPE_DRAFTS);
+ if (!folder) {
+ g_printerr ("modest: failed to find Drafts folder\n");
+ } else {
+
+ tny_folder_add_msg (folder, msg, NULL); /* TODO: check err */
+
+ ModestWindow *win = modest_msg_edit_window_new (msg, account_name);
+ gtk_widget_show_all (GTK_WIDGET (win));
+
+ g_object_unref (G_OBJECT(folder));
+ }
+
+ g_object_unref (G_OBJECT(msg));
+ }
+ g_object_unref (G_OBJECT(account));
+
+ }
+ }
+
+ g_free (account_name);
+
+ g_free(uri);
+ return FALSE; /* Do not call this callback again. */
+}
+
+static gint on_mail_to(GArray * arguments, gpointer data, osso_rpc_t * retval)
+{
+ if (arguments->len != MODEST_DEBUS_MAIL_TO_ARGS_COUNT)
+ return OSSO_ERROR;
+
+ /* Use g_idle to context-switch into the application's thread: */
+
+ /* Get the arguments: */
+ osso_rpc_t val = g_array_index(arguments, osso_rpc_t, MODEST_DEBUS_MAIL_TO_ARG_URI);
+ gchar *uri = g_strdup (val.value.s);
+
+ /* printf(" debug: to=%s\n", idle_data->to); */
+ g_idle_add(on_idle_mail_to, (gpointer)uri);
+
+ /* Note that we cannot report failures during sending,
+ * because that would be asynchronous. */
+ return OSSO_OK;
+}
+
+
+static gboolean
+on_idle_open_message(gpointer user_data)
+{
+ gchar *uri = (gchar*)user_data;
+
+ g_message ("not implemented yet %s", __FUNCTION__);