static ModestErrorCode start_ui (const gchar *account,
const gchar* mailto, const gchar *cc,
- const gchar *bcc, const gchar* subject, const gchar *body);
+ const gchar *bcc, const gchar* subject, const gchar *body, GtkWidget **ui);
static ModestErrorCode send_mail (const gchar* account,
const gchar* mailto, const gchar *cc, const gchar *bcc,
const gchar* subject, const gchar *body);
+
+static void
+on_show (GtkWidget *widget, gpointer user_data)
+{
+ if (modest_conf_get_bool (modest_runtime_get_conf(),
+ MODEST_CONF_CONNECT_AT_STARTUP, NULL))
+ modest_platform_connect_and_wait(NULL);
+}
+
int
main (int argc, char *argv[])
{
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
+ /* Enable threads before anything else, to prevent memory corruption */
+ if (!g_thread_supported())
+ g_thread_init(NULL);
+ gdk_threads_init ();
+
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
}
g_option_context_free (context);
- if (!modest_init_init_core ()) {
+ if (!modest_init_init_core (argc, argv)) {
g_printerr ("modest: cannot init modest core\n");
return MODEST_ERR_INIT;
-
}
account_or_default = check_account (account);
retval = MODEST_ERR_UI;
goto cleanup;
} else {
- if (modest_conf_get_bool (modest_runtime_get_conf(),
- MODEST_CONF_CONNECT_AT_STARTUP, NULL))
- modest_platform_connect_and_wait(NULL);
-
+ GtkWidget *ui = NULL;
retval = start_ui (account_or_default,
- mailto, cc, bcc, subject, body);
+ mailto, cc, bcc, subject, body, &ui);
+ if (G_IS_OBJECT(ui))
+ g_signal_connect (G_OBJECT (ui), "show", G_CALLBACK(on_show), NULL);
}
} else {
if (!account_or_default) {
static ModestErrorCode
start_ui (const gchar *account_name, const gchar* mailto, const gchar *cc, const gchar *bcc,
- const gchar* subject, const gchar *body)
+ const gchar* subject, const gchar *body, GtkWidget **ui)
{
ModestWindow *win = NULL;
} else {
ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
modest_window_mgr_register_window (mgr, win);
+ *ui = (GtkWidget*) win;
+ g_object_unref (win);
}
gtk_widget_show_all (GTK_WIDGET (win));
from_string = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
account_name);
- mail_operation = modest_mail_operation_new ();
+ mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_SEND, NULL);
+
modest_mail_operation_send_new_mail (mail_operation, account,
+ NULL,
from_string, mailto,
- cc, bcc, subject, body, NULL,
- NULL, 0);
+ cc, bcc, subject, body, NULL /* html_body */,
+ NULL /* attachments */, 0 /* priority */);
if (modest_mail_operation_get_status (mail_operation) ==
MODEST_MAIL_OPERATION_STATUS_FAILED) {
retval = MODEST_ERR_SEND;