-
- modest_conf = MODEST_CONF(modest_conf_new());
- if (!modest_conf) {
- g_printerr ("modest: failed to initialize config system, exiting\n");
- retval = MODEST_ERR_CONF;
- goto cleanup;
+
+ if (!modest_init_init_core ()) {
+ g_printerr ("modest: cannot init modest core\n");
+ return MODEST_ERR_INIT;
+
+ }
+
+ account_or_default = check_account (account);
+ g_free (account);
+
+ if (!batch) {
+ if (!modest_init_init_ui (argc, argv)) {
+ g_printerr ("modest: cannot init modest ui\n");
+ 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);
+
+ retval = start_ui (account_or_default,
+ mailto, cc, bcc, subject, body);
+ }
+ } else {
+ if (!account_or_default) {
+ g_printerr ("modest: no account has been defined yet\n");
+ retval = MODEST_ERR_CONF;
+ goto cleanup;
+ }
+ retval = send_mail (account_or_default,
+ mailto, cc, bcc, subject, body);