#include <modest-tny-platform-factory.h>
#include <modest-mail-operation.h>
-
static int start_ui (const gchar* mailto, const gchar *cc, const gchar *bcc,
const gchar* subject, const gchar *body);
static int send_mail (const gchar* mailto, const gchar *cc, const gchar *bcc,
int
main (int argc, char *argv[])
{
- GOptionContext *context = NULL;
+ GOptionContext *context = NULL;
GError *err = NULL;
int retval = MODEST_ERR_NONE;
- static gboolean batch=FALSE, factory_settings=FALSE;
+ static gboolean batch = FALSE;
static gchar *mailto, *subject, *bcc, *cc, *body, *account;
static GOptionEntry options[] = {
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},
- { "factory-settings", 0, 0, G_OPTION_ARG_NONE, &factory_settings,
- N_("return to factory settings"), NULL},
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
}
g_option_context_free (context);
- if (!getenv("DISPLAY"))
- batch = TRUE;
-
if (!batch) {
- if (!gtk_init_check(&argc, &argv)) {
- g_printerr ("modest: failed to start graphical ui\n");
+ if (!modest_runtime_init_ui (argc, argv)) {
+ g_printerr ("modest: cannot start UI\n");
+ retval = MODEST_ERR_UI;
goto cleanup;
- }
- retval = start_ui (mailto, cc, bcc, subject, body);
-
+ } else
+ retval = start_ui (mailto, cc, bcc, subject, body);
} else
retval = send_mail (mailto, cc, bcc, subject, body);
ModestUI *modest_ui = NULL;
gint retval = 0;
-
modest_ui = modest_ui_new ();
if (mailto||cc||bcc||subject||body) {
modest_runtime_init (void)
{
ModestSingletons *my_singletons;
+ gboolean reset;
if (_singletons) {
g_printerr ("modest: modest_runtime_init can only be called once\n");
return FALSE;
}
#endif /* MODEST_PLATFORM_ID==2 */
-
- if (!init_header_columns(modest_singletons_get_conf (my_singletons),
- FALSE)) {
+
+ /* based on the debug settings, we decide whether to overwrite old settings */
+ reset = modest_runtime_get_debug_flags () & MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS;
+ if (!init_header_columns(modest_singletons_get_conf (my_singletons), reset)) {
modest_runtime_uninit ();
g_printerr ("modest: failed to init header columns\n");
return FALSE;
gboolean
+modest_runtime_init_ui (gint argc, gchar** argv)
+{
+ if (!gtk_init_check(&argc, &argv)) {
+ g_printerr ("modest: failed to initialize graphical ui\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+gboolean
modest_runtime_uninit (void)
{
if (!_singletons) {
ModestRuntimeDebugFlags
modest_runtime_get_debug_flags ()
{
- GDebugKey debug_keys[] = {
+ static const GDebugKey debug_keys[] = {
{ "abort-on-warning", MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING },
{ "log-actions", MODEST_RUNTIME_DEBUG_LOG_ACTIONS },
{ "debug-objects", MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS },
- { "debug-signals", MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS }
+ { "debug-signals", MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS },
+ { "factory-settings", MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS }
};
const gchar *str;
static ModestRuntimeDebugFlags debug_flags = -1;
gflags |= G_TYPE_DEBUG_OBJECTS;
if (mflags & MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS)
gflags |= G_TYPE_DEBUG_SIGNALS;
-
- g_type_init_with_debug_flags (gflags);
+ g_type_init_with_debug_flags (gflags);
}
static void
MODEST_RUNTIME_DEBUG_LOG_ACTIONS = 1 << 1, /* not in use atm */
MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS = 1 << 2, /* for g_type_init */
MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS = 1 << 3, /* for g_type_init */
+ MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS = 1 << 4, /* reset to factory defaults */
} ModestRuntimeDebugFlags;
/**
/**
+ * modest_runtime_init_ui:
+ * @argc: the #argc argument to the main function
+ * @argv: the #argv argument to the main function
+ *
+ * initialize the modest UI; this replaces the call to
+ * gtk_init
+ *
+ * TRUE if this succeeded, FALSE otherwise.
+ */
+gboolean modest_runtime_init_ui (gint argc, gchar** argv);
+
+/**
* modest_runtime_uinit:
*
* uninitialize the modest runtime system; free all the