{ 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);
goto cleanup;
}
g_option_context_free (context);
+
+ if (!modest_runtime_init ()) {
+ g_printerr ("modest: cannot init runtime\n");
+ return MODEST_ERR_INIT;
+ }
+
account_or_default = check_account (account);
g_free (account);
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);
}
gboolean
modest_runtime_uninit (void)
{
- if (!_singletons) {
- g_printerr ("modest: modest_runtime is not initialized\n");
- return FALSE;
+ if (_singletons) {
+ g_object_unref (G_OBJECT(_singletons));
+ _singletons = NULL;
}
+ if (G_IS_OBJECT(_singletons))
+ g_warning ("BUG: _singletons is still alive\n");
- g_object_unref (G_OBJECT(_singletons));
- _singletons = NULL;
-
return TRUE;
}
g_free (priv->cache_dir);
priv->cache_dir = NULL;
-
- if (priv->device) {
- g_object_unref (G_OBJECT(priv->device));
- priv->device = NULL;
- }
if (priv->password_hash) {
g_hash_table_destroy (priv->password_hash);
camel_object_unref (CAMEL_OBJECT(priv->session));
priv->session = NULL;
}
-
+
+ /* the device should be unref'ed *AFTER* the session */
+ if (priv->device) {
+ g_object_unref (G_OBJECT(priv->device));
+ priv->device = NULL;
+ }
G_OBJECT_CLASS(parent_class)->finalize (obj);
}