#include "modest-mail-operation.h"
-#ifdef MODEST_ENABLE_HILDON /* Hildon includes */
+#if MODEST_PLATFORM_ID==2
#include <libosso.h>
-#endif /* MODEST_ENABLE_HILDON */
+#endif /* MODEST_PLATFORM==2 */
/* return values */
#define MODEST_ERR_NONE 0
static gboolean hildon_init (); /* NOP if HILDON is not defined */
static int start_ui (const gchar* mailto, const gchar *cc,
- const gchar *bcc, const gchar* subject, const gchar *body);
+ const gchar *bcc, const gchar* subject, const gchar *body,
+ TnyAccountStore *account_store);
static int send_mail (const gchar* mailto, const gchar *cc, const gchar *bcc,
const gchar* subject, const gchar *body);
int
main (int argc, char *argv[])
{
- GOptionContext *context = NULL;
- TnyPlatformFactory *fact = NULL;
- ModestConf *modest_conf = NULL;
+ GOptionContext *context = NULL;
+ TnyPlatformFactory *fact = NULL;
+ TnyAccountStore *account_store = NULL;
+ ModestConf *modest_conf = NULL;
GError *err = NULL;
int retval = MODEST_ERR_NONE;
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
- bindtextdomain (GETTEXT_PACKAGE, MODESTLOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, MODEST_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- g_type_init ();
+ g_type_init ();
+ g_thread_init (NULL);
+ gdk_threads_init ();
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
goto cleanup;
}
g_option_context_free (context);
-
+
+ /* Get platform factory */
fact = modest_tny_platform_factory_get_instance ();
+
+ /* Check modest conf */
modest_conf = modest_tny_platform_factory_get_modest_conf_instance (fact);
if (!modest_conf) {
g_printerr ("modest: failed to initialize config system, exiting\n");
goto cleanup;
}
+ /* Get the account store */
+ account_store = tny_platform_factory_new_account_store (fact);
+ if (!account_store) {
+ g_printerr ("modest: could not initialize a ModestTnyAccountStore instance\n");
+ retval = MODEST_ERR_RUN;
+ goto cleanup;
+ }
+
if (debug)
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING);
if (!batch) {
gtk_init (&argc, &argv);
- retval = start_ui (mailto, cc, bcc, subject, body);
+ retval = start_ui (mailto, cc, bcc, subject, body, account_store);
} else
retval = send_mail (mailto, cc, bcc, subject, body);
static int
start_ui (const gchar* mailto, const gchar *cc, const gchar *bcc,
- const gchar* subject, const gchar *body)
+ const gchar* subject, const gchar *body,
+ TnyAccountStore *account_store)
{
ModestUI *modest_ui;
GtkWidget *win;
#endif
- modest_ui = MODEST_UI(modest_ui_new ());
+ modest_ui = MODEST_UI(modest_ui_new (account_store));
if (!modest_ui) {
g_printerr ("modest: failed to initialize ui, exiting\n");
retval = MODEST_ERR_UI;
/* subject, /\* subject *\/ */
/* body, /\* body *\/ */
/* NULL); /\* attachments *\/ */
- } else
-#ifndef OLD_UI_STUFF
- win = modest_ui_main_window (modest_ui);
- gtk_widget_show (win);
-#else
- modest_ui_show_main_window (modest_ui);
-#endif
- gtk_main();
+ } else
+ win = modest_ui_main_window (modest_ui);
+
+ if (win) {
+ TnyDevice *device;
+
+ gtk_widget_show (win);
+ /* Go online */
+ device = tny_account_store_get_device (account_store);
+ tny_device_force_online (device);
+ g_object_unref (G_OBJECT (device));
+
+ gtk_main();
+ }
cleanup:
if (modest_ui)
g_object_unref (modest_ui);
static gboolean
hildon_init ()
{
-#ifdef MODEST_ENABLE_HILDON
-
+#if MODEST_PLATFORM_ID==2
+
osso_context_t *osso_context =
osso_initialize(PACKAGE, PACKAGE_VERSION,
TRUE, NULL);
if (!osso_context) {
- g_printerr ("modest: failed to aquire osso context, exiting\n");
-
+ g_printerr ("modest: failed to acquire osso context\n");
return FALSE;
-
}
-#endif /* MODEST_ENABLE_HILDON */
+
+#endif /* MODEST_PLATFORM_ID==2 */
return TRUE;
}