- GOptionContext *context = NULL;
-
- GError *err = NULL;
- int retval = MODEST_ERR_NONE;
-
- static gboolean batch = FALSE;
- static gchar *mailto, *subject, *bcc, *cc, *body, *account;
-
- static GOptionEntry options[] = {
- { "mailto", 'm', 0, G_OPTION_ARG_STRING, &mailto,
- N_("New email to <addresses> (comma-separated)"), NULL},
- { "subject", 's', 0, G_OPTION_ARG_STRING, &subject,
- N_("Subject for a new mail"), NULL},
- { "body", 'b', 0, G_OPTION_ARG_STRING, &body,
- N_("Body for a new email"), NULL},
- { "cc", 'c', 0, G_OPTION_ARG_STRING, &cc,
- N_("Cc: addresses for a new mail (comma-separated)"), NULL},
- { "bcc", 'x', 0, G_OPTION_ARG_STRING, &bcc,
- N_("Bcc: addresses for a new mail (comma-separated)"), NULL},
- { "account", 'a', 0, G_OPTION_ARG_STRING, &account,
- N_("Account to use (if specified, default account is used)"), NULL},
- { "batch", 'y', 0, G_OPTION_ARG_NONE, &batch,
- N_("Run in batch mode (don't show UI)"), NULL},
- { NULL, 0, 0, 0, NULL, NULL, NULL }
- };
-
- if (!modest_runtime_init ()) {
- g_printerr ("modest: cannot init runtime\n");
- return MODEST_ERR_INIT;
- }
-
- context = g_option_context_new (NULL);
- g_option_context_add_main_entries (context, options, NULL);
-
- if (!g_option_context_parse (context, &argc, &argv, &err)) {
- g_printerr ("modest: error in command line parameter(s): '%s', exiting\n",
- err ? err->message : "");
- g_error_free (err);
- retval = MODEST_ERR_OPTIONS;
- goto cleanup;
- }
- g_option_context_free (context);
-
- if (!batch) {
- if (!modest_runtime_init_ui (argc, argv)) {
- g_printerr ("modest: cannot start UI\n");
- retval = MODEST_ERR_UI;
- goto cleanup;
- } else
- retval = start_ui (mailto, cc, bcc, subject, body);
- } else
- retval = send_mail (mailto, cc, bcc, subject, body);
-
-cleanup:
- if (!modest_runtime_uninit ())
- g_printerr ("modest: modest_runtime_uninit failed\n");