#
# Makefile.am
-# Time-stamp: <2007-01-24 09:06:54 (djcb)>
+# Time-stamp: <2007-01-27 18:11:31 (djcb)>
SUBDIRS=$(MODEST_PLATFORM) widgets
DIST_SUBDIRS = widgets gtk maemo
modest-cache-mgr.h\
modest-conf.c\
modest-conf.h \
- modest-debug.c\
- modest-debug.h\
modest-defs.h\
modest-error.h \
modest-formatter.c \
modest-formatter.h \
modest-icon-factory.c\
modest-icon-factory.h\
- modest-init.h\
- modest-init.c\
modest-local-folder-info.h \
modest-local-folder-info.c \
modest-mail-operation-queue.c \
modest-pair.h\
modest-protocol-info.c\
modest-protocol-info.h\
+ modest-runtime.c\
+ modest-runtime.h\
+ modest-singletons.c\
+ modest-singletons.h\
modest-text-utils.c\
modest-text-utils.h\
modest-tny-account-store.c\
modest-tny-account-store.h\
+ modest-tny-account.c\
+ modest-tny-account.h\
modest-tny-folder.c \
modest-tny-folder.h \
modest-tny-msg-actions.c\
*/
#include <glib/gi18n.h>
+#include <modest-runtime.h>
#include "modest-account-view-window.h"
#include "modest-account-assistant.h"
#include "modest-tny-platform-factory.h"
static void
on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
{
- TnyPlatformFactory *fact;
ModestAccountViewWindowPrivate *priv;
ModestAccountMgr *account_mgr;
const gchar *account_name;
priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
- fact = modest_tny_platform_factory_get_instance ();
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(fact));
+ account_mgr = modest_runtime_get_account_mgr();
account_name = modest_account_view_get_selected_account (priv->account_view);
if (account_name) {
{
GtkWidget *assistant;
ModestAccountViewWindowPrivate *priv;
- TnyPlatformFactory *fact;
- ModestAccountMgr *account_mgr;
priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
- fact = modest_tny_platform_factory_get_instance ();
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(fact));
-
- assistant = modest_account_assistant_new (account_mgr,
+ assistant = modest_account_assistant_new (modest_runtime_get_account_mgr(),
priv->widget_factory);
gtk_window_set_transient_for (GTK_WINDOW(assistant),
GTK_WINDOW(self));
#include <string.h>
#include <tny-account-store.h>
#include <tny-simple-list.h>
+#include <modest-conf.h>
+#include <modest-runtime.h>
#include "modest-account-mgr.h"
#include "modest-account-mgr-helpers.h"
static void
save_settings (ModestEditMsgWindow *self)
{
- ModestWindowPrivate *parent_priv;
- ModestConf *conf;
-
- parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
- conf = modest_tny_platform_factory_get_conf_instance
- (MODEST_TNY_PLATFORM_FACTORY(parent_priv->plat_factory));
-
- modest_widget_memory_save (conf, G_OBJECT(self), "modest-edit-msg-window");
+ modest_widget_memory_save (modest_runtime_get_conf (),
+ G_OBJECT(self), "modest-edit-msg-window");
}
static void
restore_settings (ModestEditMsgWindow *self)
{
- ModestWindowPrivate *parent_priv;
- ModestConf *conf;
-
- parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
- conf = modest_tny_platform_factory_get_conf_instance
- (MODEST_TNY_PLATFORM_FACTORY(parent_priv->plat_factory));
- modest_widget_memory_restore (conf, G_OBJECT(self), "modest-edit-msg-window");
+ modest_widget_memory_restore (modest_runtime_get_conf (),
+ G_OBJECT(self), "modest-edit-msg-window");
}
cc_button = gtk_button_new_with_label (_("Cc..."));
bcc_button = gtk_button_new_with_label (_("Bcc..."));
- priv->from_field = modest_widget_factory_get_combo_box (parent_priv->widget_factory,
+ priv->from_field = modest_widget_factory_get_combo_box (modest_runtime_get_widget_factory(),
MODEST_COMBO_BOX_TYPE_TRANSPORTS);
priv->to_field = gtk_entry_new_with_max_length (80);
priv->cc_field = gtk_entry_new_with_max_length (80);
gtk_widget_show_all (GTK_WIDGET(main_vbox));
gtk_container_add (GTK_CONTAINER(obj), main_vbox);
}
-
static void
ModestWindow *
-modest_edit_msg_window_new (ModestWidgetFactory *factory,
- TnyAccountStore *account_store,
- ModestEditType type)
+modest_edit_msg_window_new (ModestEditType type)
{
GObject *obj;
ModestEditMsgWindowPrivate *priv;
GtkActionGroup *action_group;
GError *error = NULL;
- g_return_val_if_fail (factory, NULL);
g_return_val_if_fail (type < MODEST_EDIT_TYPE_NUM, NULL);
obj = g_object_new(MODEST_TYPE_EDIT_MSG_WINDOW, NULL);
priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj);
parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
-
- parent_priv->widget_factory = g_object_ref (factory);
- parent_priv->account_store = g_object_ref (account_store);
-
- /* ****** */
+
parent_priv->ui_manager = gtk_ui_manager_new();
action_group = gtk_action_group_new ("ModestEditMsgWindowActions");
#include <glib/gi18n.h>
#include <gtk/gtktreeviewcolumn.h>
+#include <modest-runtime.h>
#include "modest-main-window.h"
#include "modest-window-priv.h"
header_view_new (ModestMainWindow *self)
{
ModestHeaderView *header_view;
- ModestWindowPrivate *parent_priv;
-
- parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
- header_view = modest_widget_factory_get_header_view (parent_priv->widget_factory);
- modest_header_view_set_style (header_view, MODEST_HEADER_VIEW_STYLE_DETAILS);
+ header_view = modest_widget_factory_get_header_view
+ (modest_runtime_get_widget_factory());
+ modest_header_view_set_style
+ (header_view, MODEST_HEADER_VIEW_STYLE_DETAILS);
+
return header_view;
}
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
- conf = modest_tny_platform_factory_get_conf_instance
- (MODEST_TNY_PLATFORM_FACTORY(parent_priv->plat_factory));
-
+ conf = modest_runtime_get_conf ();
+
modest_widget_memory_restore (conf, G_OBJECT(priv->folder_paned),
"modest-folder-paned");
modest_widget_memory_restore (conf, G_OBJECT(priv->msg_paned),
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
- conf = modest_tny_platform_factory_get_conf_instance
- (MODEST_TNY_PLATFORM_FACTORY(parent_priv->plat_factory));
+ conf = modest_runtime_get_conf ();
modest_widget_memory_save (conf,G_OBJECT(self), "modest-main-window");
modest_widget_memory_save (conf, G_OBJECT(priv->folder_paned),
ModestWindow *
-modest_main_window_new (ModestWidgetFactory *widget_factory,
- TnyAccountStore *account_store)
+modest_main_window_new (void)
{
GObject *obj;
ModestMainWindowPrivate *priv;
GtkWidget *main_vbox;
GtkWidget *status_hbox;
GtkWidget *header_win, *folder_win;
+ ModestWidgetFactory *widget_factory;
GtkActionGroup *action_group;
GError *error = NULL;
- g_return_val_if_fail (widget_factory, NULL);
-
+
obj = g_object_new(MODEST_TYPE_MAIN_WINDOW, NULL);
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj);
parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
-
- parent_priv->widget_factory = g_object_ref (widget_factory);
- parent_priv->account_store = g_object_ref (account_store);
-
+
/* ***************** */
parent_priv->ui_manager = gtk_ui_manager_new();
action_group = gtk_action_group_new ("ModestMainWindowActions");
+ widget_factory = modest_runtime_get_widget_factory ();
+
/* Add common actions */
gtk_action_group_add_actions (action_group,
modest_action_entries,
/* Load the UI definition */
gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-ui.xml", &error);
if (error != NULL) {
- g_warning ("Could not merge modest-ui.xml: %s", error->message);
+ g_printerr ("modest: could not merge modest-ui.xml: %s", error->message);
g_error_free (error);
error = NULL;
}
gtk_window_add_accel_group (GTK_WINDOW (obj),
gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
-
/* Toolbar / Menubar */
parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
parent_priv->menubar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar");
G_CALLBACK (on_folder_view_button_press_event),
obj);
-
/* paned */
priv->folder_paned = gtk_vpaned_new ();
priv->msg_paned = gtk_vpaned_new ();
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <modest-debug.h>
-
-/* http://primates.ximian.com/~federico/news-2006-04.html#memory-debugging-infrastructure*/
-ModestDebugFlags
-modest_debug_get_debug_flags ()
-{
- GDebugKey debug_keys[] = {
- { "abort-on-warning", MODEST_DEBUG_ABORT_ON_WARNING },
- { "log-actions", MODEST_DEBUG_LOG_ACTIONS },
- { "debug-objects", MODEST_DEBUG_DEBUG_OBJECTS },
- { "debug-signals", MODEST_DEBUG_DEBUG_SIGNALS }
- };
- const gchar *str;
- ModestDebugFlags debug_flags = -1;
-
- if (debug_flags != -1)
- return debug_flags;
-
- str = g_getenv (MODEST_DEBUG);
-
- if (str != NULL)
- debug_flags = g_parse_debug_string (str, debug_keys, G_N_ELEMENTS (debug_keys));
- else
- debug_flags = 0;
-
- return debug_flags;
-}
-
-
-void
-modest_debug_g_type_init (void)
-{
- GTypeDebugFlags gflags;
- ModestDebugFlags mflags;
-
- gflags = 0;
- mflags = modest_debug_get_debug_flags ();
-
- if (mflags & MODEST_DEBUG_DEBUG_OBJECTS)
- gflags |= G_TYPE_DEBUG_OBJECTS;
- if (mflags & MODEST_DEBUG_DEBUG_SIGNALS)
- gflags |= G_TYPE_DEBUG_SIGNALS;
-
- g_type_init_with_debug_flags (gflags);
-
-}
-
-void
-modest_debug_logging_init (void)
-{
- ModestDebugFlags mflags;
- mflags = modest_debug_get_debug_flags ();
-
- if (mflags & MODEST_DEBUG_ABORT_ON_WARNING)
- g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
- G_LOG_LEVEL_CRITICAL |
- G_LOG_LEVEL_WARNING);
-}
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MODEST_DEBUG_H__
-#define __MODEST_DEBUG_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define MODEST_DEBUG "MODEST_DEBUG"
-
-typedef enum {
- MODEST_DEBUG_ABORT_ON_WARNING = 1 << 0,
- MODEST_DEBUG_LOG_ACTIONS = 1 << 1, /* not in use atm */
- MODEST_DEBUG_DEBUG_OBJECTS = 1 << 2, /* for g_type_init */
- MODEST_DEBUG_DEBUG_SIGNALS = 1 << 3, /* for g_type_init */
-} ModestDebugFlags;
-
-
-/**
- * modest_debug_get_debug_flags
- *
- * get the debug flags for modest; they are read from the MODEST_DEBUG
- * environment variable; the flags specified as strings, separated by ':'.
- * Possible values are:
- * - "abort-on-warning": abort the program when a gtk/glib/.. warning occurs.
- * useful when running in debugger
- * - "log-actions": log user actions (not in use atm)
- * - "track-object": track the use of (g)objects in the program. this option influences
- * g_type_init_with_debug_flags
- * - "track-signals": track the use of (g)signals in the program. this option influences
- * g_type_init_with_debug_flags
- * - "disable-cache": disable caching of strings and pixbuf
- * if you would want to track signals and log actions, you could do something like:
- * MODEST_DEBUG="log-actions:track-signals" ./modest
- * NOTE that the flags will stay the same during the run of the program, even
- * if the environment variable changes.
- *
- * Returns: the bitwise OR of the debug flags
- */
-ModestDebugFlags modest_debug_get_debug_flags (void) G_GNUC_CONST;
-
-/**
- * modest_g_type_init
- *
- * do a g_type_init_with_debug_flags based on the modest debug flags
- */
-void modest_debug_g_type_init (void);
-
-/**
- * modest_g_type_init
- *
- * do set the logging based on the modest debug flags (ie. whether
- * we should abort when a warning occurs.
- */
-void modest_debug_logging_init (void);
-
-G_END_DECLS
-
-#endif /*__MODEST_DEBUG_H__*/
/* modest-icon-factory.c */
#include <modest-icon-factory.h>
-#include <modest-tny-platform-factory.h>
-
-static GHashTable*
-get_icon_cache (void)
-{
- TnyPlatformFactory *fakt;
- ModestCacheMgr *cache_mgr;
-
- fakt = modest_tny_platform_factory_get_instance ();
-
- cache_mgr = modest_tny_platform_factory_get_cache_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(fakt));
-
- return modest_cache_mgr_get_cache (cache_mgr,
- MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF);
-}
-
+#include <modest-runtime.h>
GdkPixbuf*
modest_icon_factory_get_icon (const gchar *name)
g_return_val_if_fail (name, NULL);
if (G_UNLIKELY(!icon_cache))
- icon_cache = get_icon_cache ();
+ icon_cache = modest_cache_mgr_get_cache (modest_runtime_get_cache_mgr(),
+ MODEST_CACHE_MGR_CACHE_TYPE_PIXBUF);
if (!icon_cache || !g_hash_table_lookup_extended (icon_cache, name, &orig_key,
(gpointer*)&pixbuf)) {
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <config.h>
-#include <modest-defs.h>
-#include <widgets/modest-header-view.h>
-#include <widgets/modest-folder-view.h>
-#include <modest-tny-platform-factory.h>
-#include <modest-widget-memory.h>
-#include <modest-widget-memory-priv.h>
-#include <modest-local-folder-info.h>
-#include <modest-init.h>
-#include <glib/gstdio.h>
-#include <modest-account-mgr.h>
-#include <modest-account-mgr-helpers.h>
-
-typedef struct {
- ModestHeaderViewColumn col;
- guint width;
-} FolderCols;
-
-static const FolderCols INBOX_COLUMNS_DETAILS[] = {
- {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
- {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
- {MODEST_HEADER_VIEW_COLUMN_FROM, 80},
- {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80},
- {MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE, 60},
- {MODEST_HEADER_VIEW_COLUMN_SIZE, 50}
-};
-static const FolderCols INBOX_COLUMNS_TWOLINES[] = {
- {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
- {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
- {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN, 200}
-};
-
-static const FolderCols OUTBOX_COLUMNS_DETAILS[] = {
- {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
- {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
- {MODEST_HEADER_VIEW_COLUMN_TO, 80},
- {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80},
- {MODEST_HEADER_VIEW_COLUMN_SENT_DATE, 80},
- {MODEST_HEADER_VIEW_COLUMN_SIZE, 50}
-};
-static const FolderCols OUTBOX_COLUMNS_TWOLINES[] = {
- {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
- {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
- {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,200},
-};
-
-static const TnyFolderType LOCAL_FOLDERS[] = {
- TNY_FOLDER_TYPE_OUTBOX,
- TNY_FOLDER_TYPE_DRAFTS,
- TNY_FOLDER_TYPE_SENT,
- TNY_FOLDER_TYPE_ARCHIVE
-};
-
-static ModestTnyPlatformFactory*
-get_platform_factory (void)
-{
- TnyPlatformFactory *fact =
- modest_tny_platform_factory_get_instance ();
-
- if (!fact) {
- g_printerr ("modest: cannot get platform factory instance\n");
- return NULL;
- }
-
- return MODEST_TNY_PLATFORM_FACTORY(fact);
-}
-
-
-static ModestConf*
-get_modest_conf (void)
-{
- ModestTnyPlatformFactory *fact =
- get_platform_factory ();
- ModestConf *conf =
- modest_tny_platform_factory_get_conf_instance (fact);
- if (!conf) {
- g_printerr ("modest: cannot get modest conf instance\n");
- return NULL;
- }
- return conf;
-}
-
-
-static ModestAccountMgr*
-get_account_mgr (void)
-{
- ModestTnyPlatformFactory *fact =
- get_platform_factory ();
- ModestAccountMgr *acc_mgr =
- modest_tny_platform_factory_get_account_mgr_instance (fact);
- if (!acc_mgr) {
- g_printerr ("modest: cannot get modest account mgr instance\n");
- return NULL;
- }
- return acc_mgr;
-}
-
-
-/* NOTE: the exact details of this format are important, as they
- * are also used in modest-widget-memory. FIXME: make a shared function
- * for this with widget-memory
- */
-static gboolean
-save_header_settings (ModestConf *conf, TnyFolderType type,
- ModestHeaderViewStyle style, const FolderCols* cols,
- guint col_num, gboolean overwrite)
-{
- int i;
- gchar *key;
- GString *str;
-
- g_return_val_if_fail (cols, FALSE);
-
- key = _modest_widget_memory_get_keyname_with_double_type ("header-view",
- type, style,
- MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
- /* if we're not in overwrite mode, only write stuff it
- * there was nothing before */
- if (!overwrite && modest_conf_key_exists(conf, key, NULL)) {
- g_free (key);
- return TRUE;
- }
-
- /* the format is necessarily the same as the one in modest-widget-memory */
- str = g_string_new (NULL);
- for (i = 0; i != col_num; ++i)
- g_string_append_printf (str, "%d:%d ",
- cols[i].col, cols[i].width);
-
- modest_conf_set_string (conf, key, str->str, NULL);
- g_free (key);
- g_string_free (str, TRUE);
-
- return TRUE;
-}
-
-/* we set the the defaults here for all folder types */
-gboolean
-modest_init_header_columns (gboolean overwrite)
-{
- ModestConf *conf;
- int folder_type;
-
- conf = get_modest_conf ();
- if (!conf) {
- g_printerr ("modest: cannot get modest conf\n");
- return FALSE;
- }
-
- for (folder_type = TNY_FOLDER_TYPE_UNKNOWN;
- folder_type <= TNY_FOLDER_TYPE_CALENDAR; ++folder_type) {
-
- switch (folder_type) {
- case TNY_FOLDER_TYPE_OUTBOX:
- case TNY_FOLDER_TYPE_SENT:
- case TNY_FOLDER_TYPE_DRAFTS:
- save_header_settings (conf, folder_type,
- MODEST_HEADER_VIEW_STYLE_DETAILS,
- OUTBOX_COLUMNS_DETAILS,
- G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS),
- overwrite);
- save_header_settings (conf, folder_type,
- MODEST_HEADER_VIEW_STYLE_TWOLINES,
- OUTBOX_COLUMNS_TWOLINES,
- G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES),
- overwrite);
- break;
-
- default:
- save_header_settings (conf, folder_type,
- MODEST_HEADER_VIEW_STYLE_DETAILS,
- INBOX_COLUMNS_DETAILS,
- G_N_ELEMENTS(INBOX_COLUMNS_DETAILS),
- overwrite);
- save_header_settings (conf, folder_type,
- MODEST_HEADER_VIEW_STYLE_TWOLINES,
- INBOX_COLUMNS_TWOLINES,
- G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES),
- overwrite);
- };
- }
- return TRUE;
-}
-
-gboolean
-modest_init_local_folders (void)
-{
- int i;
- gchar *maildir_path;
- static const gchar* maildirs[] = {
- "cur", "new", "tmp"
- };
-
- maildir_path = modest_local_folder_info_get_maildir_path ();
-
- for (i = 0; i != G_N_ELEMENTS(LOCAL_FOLDERS); ++i) {
- int j;
- for (j = 0; j != G_N_ELEMENTS(maildirs); ++j) {
- gchar *dir;
- dir = g_build_filename (maildir_path,
- modest_local_folder_info_get_type_name(LOCAL_FOLDERS[i]),
- maildirs[j],
- NULL);
- if (g_mkdir_with_parents (dir, 0755) < 0) {
- g_printerr ("modest: failed to create %s\n", dir);
- g_free (dir);
- g_free (maildir_path);
- return FALSE;
- }
- g_free(dir);
- }
- }
-
- g_free (maildir_path);
- return TRUE;
-}
-
-
-
-static void
-free_element (gpointer data, gpointer user_data)
-{
- g_free (data);
-}
-
-
-gboolean
-modest_init_default_account_maybe (void)
-{
- ModestAccountMgr *acc_mgr;
-
- GSList *all_accounts = NULL;
- gchar *default_account;
- gboolean retval = TRUE;
-
- acc_mgr = get_account_mgr ();
- if (!acc_mgr) {
- g_printerr ("modest: cannot get modest account mgr\n");
- return FALSE;
- }
-
- all_accounts = modest_account_mgr_account_names (acc_mgr, NULL);
- if (all_accounts) { /* if there are any accounts, there should be a default one */
- default_account =
- modest_account_mgr_get_default_account (acc_mgr);
- if (!default_account) {
- gchar *first_account;
- g_printerr ("modest: no default account defined\n");
- first_account = (gchar*)all_accounts->data;
- if ((retval = modest_account_mgr_set_default_account (acc_mgr, first_account)))
- g_printerr ("modest: set '%s' as the default account\n",
- first_account);
- else
- g_printerr ("modest: failed to set '%s' as the default account\n",
- first_account);
- g_free (default_account);
- }
- g_slist_foreach (all_accounts, free_element, NULL);
- g_slist_free (all_accounts);
- }
- return retval;
-}
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MODEST_INIT_H__
-#define __MODEST_INIT_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-/*
- * functions to initialize various parts of the modest system
- */
-G_BEGIN_DECLS
-
-/**
- * modest_init_header_columns:
- * @overwrite: write the setting, even if it already exists
- *
- * will set defaults for the columns to show for folder,
- * if there are no such settings yet (in ModestWidgetMemory)
- *
- * Returns: TRUE if succeeded, FALSE in case of error
- */
-gboolean modest_init_header_columns (gboolean overwrite);
-
-/**
- * modest_init_local_folders:
- *
- * create the Local Folders folder under cache, if they
- * do not exist yet.
- *
- * Returns: TRUE if the folder were already there, or
- * they were created, FALSE otherwise
- */
-gboolean modest_init_local_folders (void);
-
-
-/**
- * modest_init_default_account_maybe:
- *
- * if there are accounts defined, but there is no default account,
- * it will be defined.
- *
- * Returns: TRUE if there was a default account already,
- * or one has been created or there are no accounts yet,
- * returns FALSE in case of error
- */
-gboolean modest_init_default_account_maybe (void);
-
-
-G_END_DECLS
-
-#endif /*__MODEST_INIT_H__*/
#include <tny-list.h>
#include <tny-simple-list.h>
+#include <modest-runtime.h>
#include <modest-defs.h>
-#include <modest-init.h>
-#include <modest-conf.h>
-#include <modest-account-mgr.h>
#include <modest-ui.h>
-#include <modest-debug.h>
#include <modest-icon-factory.h>
#include <modest-tny-account-store.h>
#include <modest-tny-platform-factory.h>
#include <modest-mail-operation.h>
-#if MODEST_PLATFORM_ID==2 /* maemo */
-#include <libosso.h>
-#endif /* MODEST_PLATFORM==2 */
-
-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,
- TnyAccountStore *account_store);
+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,
const gchar* subject, const gchar *body);
main (int argc, char *argv[])
{
GOptionContext *context = NULL;
- TnyPlatformFactory *fact = NULL;
- TnyAccountStore *account_store = NULL;
GError *err = NULL;
int retval = MODEST_ERR_NONE;
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
- bindtextdomain (GETTEXT_PACKAGE, MODEST_LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
-
- modest_debug_g_type_init ();
- modest_debug_logging_init ();
-
- g_thread_init (NULL);
- modest_init_default_account_maybe ();
-
- gdk_threads_init (); /* hmmm... not really needed if we're not doing ui*/
+ 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);
-
- /* Get platform factory */
- fact = modest_tny_platform_factory_get_instance ();
-
- if (!modest_init_local_folders ()) {
- g_printerr ("modest: failed to initialize local folders, exiting\n");
- retval = MODEST_ERR_INIT;
- 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 (!getenv("DISPLAY"))
batch = TRUE;
g_printerr ("modest: failed to start graphical ui\n");
goto cleanup;
}
- modest_init_header_columns (factory_settings);
- retval = start_ui (mailto, cc, bcc, subject, body, account_store);
+ retval = start_ui (mailto, cc, bcc, subject, body);
} else
retval = send_mail (mailto, cc, bcc, subject, body);
cleanup:
- if (fact)
- g_object_unref (G_OBJECT(fact));
-
- /* this will clean up account_store as well */
-
+ if (!modest_runtime_uninit ())
+ g_printerr ("modest: modest_runtime_uninit failed\n");
return retval;
}
static int
start_ui (const gchar* mailto, const gchar *cc, const gchar *bcc,
- const gchar* subject, const gchar *body,
- TnyAccountStore *account_store)
+ const gchar* subject, const gchar *body)
{
- ModestUI *modest_ui;
ModestWindow *win = NULL;
- gint retval = 0;
+ ModestUI *modest_ui = NULL;
- 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;
- goto cleanup;
- }
-
- if (!hildon_init ()) { /* NOP if hildon is not defined */
- g_printerr ("modest: failed to initialize hildon, exiting\n");
- retval = MODEST_ERR_HILDON;
- goto cleanup;
- }
+ gint retval = 0;
+
+ modest_ui = modest_ui_new ();
if (mailto||cc||bcc||subject||body) {
+ g_warning ("FIXME: implement this");
/* ok = modest_ui_new_edit_window (modest_ui, */
/* mailto, /\* to *\/ */
/* cc, /\* cc *\/ */
win = modest_ui_main_window (modest_ui);
if (win) {
- TnyDevice *device;
-
gtk_widget_show_all (GTK_WIDGET (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);
-
- return retval;
-}
+ g_object_unref (G_OBJECT(modest_ui));
-
-static gboolean
-hildon_init ()
-{
-#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 acquire osso context\n");
- return FALSE;
- }
-#endif /* MODEST_PLATFORM_ID==2 */
- return TRUE;
+ return retval;
}
send_mail (const gchar* mailto, const gchar *cc, const gchar *bcc,
const gchar* subject, const gchar *body)
{
- ModestAccountMgr *acc_mgr = NULL;
- TnyPlatformFactory *fact = NULL;
- TnyAccountStore *acc_store = NULL;
ModestMailOperation *mail_operation = NULL;
-
TnyList *accounts = NULL;
TnyIterator *iter = NULL;
TnyTransportAccount *account = NULL;
int retval;
- fact = modest_tny_platform_factory_get_instance ();
- acc_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(fact));
- acc_store = tny_platform_factory_new_account_store (fact);
-
accounts = TNY_LIST(tny_simple_list_new ());
- tny_account_store_get_accounts (TNY_ACCOUNT_STORE(acc_store), accounts,
- TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
+ tny_account_store_get_accounts (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()),
+ accounts,
+ TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
iter = tny_list_create_iterator(accounts);
tny_iterator_first (iter);
}
account = TNY_TRANSPORT_ACCOUNT (tny_iterator_get_current(iter));
-
mail_operation = modest_mail_operation_new ();
modest_mail_operation_send_new_mail (mail_operation,
goto cleanup;
} else
retval = MODEST_ERR_NONE; /* hurray! */
-
cleanup:
if (iter)
g_object_unref (G_OBJECT (iter));
g_object_unref (G_OBJECT (accounts));
if (mail_operation)
g_object_unref (G_OBJECT (mail_operation));
-
return retval;
}
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gstdio.h>
+#include <modest-runtime.h>
+#include <modest-defs.h>
+#include <modest-singletons.h>
+#include <widgets/modest-header-view.h>
+#include <widgets/modest-folder-view.h>
+#include <modest-tny-platform-factory.h>
+#include <modest-widget-memory.h>
+#include <modest-widget-memory-priv.h>
+#include <modest-local-folder-info.h>
+#include <modest-account-mgr.h>
+#include <modest-account-mgr-helpers.h>
+
+#if MODEST_PLATFORM_ID==2 /* maemo/hildon */
+#include <libosso.h>
+static gboolean hildon_init (void);
+#endif /* MODEST_PLATFORM_ID==2 */
+
+static gboolean init_header_columns (ModestConf *conf, gboolean overwrite);
+static gboolean init_local_folders (void);
+static gboolean init_default_account_maybe (ModestAccountMgr *acc_mgr);
+static void init_i18n (void);
+static void debug_g_type_init (void);
+static void debug_logging_init (void);
+
+static ModestSingletons *_singletons = NULL;
+
+/*
+ * defaults for the column headers
+ */
+
+typedef struct {
+ ModestHeaderViewColumn col;
+ guint width;
+} FolderCols;
+
+static const FolderCols INBOX_COLUMNS_DETAILS[] = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
+ {MODEST_HEADER_VIEW_COLUMN_FROM, 80},
+ {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80},
+ {MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE, 60},
+ {MODEST_HEADER_VIEW_COLUMN_SIZE, 50}
+};
+static const FolderCols INBOX_COLUMNS_TWOLINES[] = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
+ {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN, 200}
+};
+
+static const FolderCols OUTBOX_COLUMNS_DETAILS[] = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
+ {MODEST_HEADER_VIEW_COLUMN_TO, 80},
+ {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80},
+ {MODEST_HEADER_VIEW_COLUMN_SENT_DATE, 80},
+ {MODEST_HEADER_VIEW_COLUMN_SIZE, 50}
+};
+static const FolderCols OUTBOX_COLUMNS_TWOLINES[] = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40},
+ {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,200},
+};
+
+static const TnyFolderType LOCAL_FOLDERS[] = {
+ TNY_FOLDER_TYPE_OUTBOX,
+ TNY_FOLDER_TYPE_DRAFTS,
+ TNY_FOLDER_TYPE_SENT,
+ TNY_FOLDER_TYPE_ARCHIVE
+};
+
+
+gboolean
+modest_runtime_init (void)
+{
+ ModestSingletons *my_singletons;
+
+ if (_singletons) {
+ g_printerr ("modest: modest_runtime_init can only be called once\n");
+ return FALSE;
+ }
+
+ init_i18n();
+ debug_g_type_init();
+ debug_logging_init();
+
+ g_thread_init(NULL);
+ gdk_threads_init ();
+
+ my_singletons = modest_singletons_new ();
+ if (!my_singletons) {
+ g_printerr ("modest: failed to initialize singletons\n");
+ return FALSE;
+ }
+
+#if MODEST_PLATFORM_ID==2
+ if (!hildon_init ()) {
+ modest_runtime_uninit ();
+ g_printerr ("modest: failed to initialize hildon\n");
+ return FALSE;
+ }
+#endif /* MODEST_PLATFORM_ID==2 */
+
+ if (!init_header_columns(modest_singletons_get_conf (my_singletons),
+ FALSE)) {
+ modest_runtime_uninit ();
+ g_printerr ("modest: failed to init header columns\n");
+ return FALSE;
+ }
+
+ if (!init_local_folders()) {
+ modest_runtime_uninit ();
+ g_printerr ("modest: failed to init local folders\n");
+ return FALSE;
+ }
+
+ if (!init_default_account_maybe(modest_singletons_get_account_mgr (my_singletons))) {
+ modest_runtime_uninit ();
+ g_printerr ("modest: failed to init default account\n");
+ return FALSE;
+ }
+
+ /* don't initialize _singletons before all the other init stuff
+ * is done; thus, using any of the singleton stuff before
+ * runtime is fully init'ed is avoided
+ */
+ _singletons = my_singletons;
+
+ return TRUE;
+}
+
+
+gboolean
+modest_runtime_uninit (void)
+{
+ if (!_singletons) {
+ g_printerr ("modest: modest_runtime is not initialized\n");
+ return FALSE;
+ }
+
+ g_object_unref (G_OBJECT(_singletons));
+ _singletons = NULL;
+
+ return TRUE;
+}
+
+
+ModestAccountMgr*
+modest_runtime_get_account_mgr (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_account_mgr (_singletons);
+}
+
+ModestTnyAccountStore*
+modest_runtime_get_account_store (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_account_store (_singletons);
+
+}
+
+ModestConf*
+modest_runtime_get_conf (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_conf (_singletons);
+}
+
+
+ModestCacheMgr*
+modest_runtime_get_cache_mgr (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_cache_mgr (_singletons);
+}
+
+
+ModestMailOperationQueue*
+modest_runtime_get_mail_operation_queue (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_mail_operation_queue (_singletons);
+}
+
+
+ModestWidgetFactory*
+modest_runtime_get_widget_factory (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_widget_factory (_singletons);
+}
+
+
+
+/* http://primates.ximian.com/~federico/news-2006-04.html#memory-debugging-infrastructure*/
+ModestRuntimeDebugFlags
+modest_runtime_get_debug_flags ()
+{
+ 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 }
+ };
+ const gchar *str;
+ static ModestRuntimeDebugFlags debug_flags = -1;
+
+ if (debug_flags != -1)
+ return debug_flags;
+
+ str = g_getenv (MODEST_DEBUG);
+
+ if (str != NULL)
+ debug_flags = g_parse_debug_string (str, debug_keys, G_N_ELEMENTS (debug_keys));
+ else
+ debug_flags = 0;
+
+ return debug_flags;
+}
+
+
+
+
+
+/* NOTE: the exact details of this format are important, as they
+ * are also used in modest-widget-memory. FIXME: make a shared function
+ * for this with widget-memory
+ */
+static gboolean
+save_header_settings (ModestConf *conf, TnyFolderType type,
+ ModestHeaderViewStyle style, const FolderCols* cols,
+ guint col_num, gboolean overwrite)
+{
+ int i;
+ gchar *key;
+ GString *str;
+
+ g_return_val_if_fail (cols, FALSE);
+
+ key = _modest_widget_memory_get_keyname_with_double_type ("header-view",
+ type, style,
+ MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
+ /* if we're not in overwrite mode, only write stuff it
+ * there was nothing before */
+ if (!overwrite && modest_conf_key_exists(conf, key, NULL)) {
+ g_free (key);
+ return TRUE;
+ }
+
+ /* the format is necessarily the same as the one in modest-widget-memory */
+ str = g_string_new (NULL);
+ for (i = 0; i != col_num; ++i)
+ g_string_append_printf (str, "%d:%d ",
+ cols[i].col, cols[i].width);
+
+ modest_conf_set_string (conf, key, str->str, NULL);
+ g_free (key);
+ g_string_free (str, TRUE);
+
+ return TRUE;
+}
+
+/**
+ * modest_init_header_columns:
+ * @overwrite: write the setting, even if it already exists
+ *
+ * will set defaults for the columns to show for folder,
+ * if there are no such settings yet (in ModestWidgetMemory)
+ *
+ * Returns: TRUE if succeeded, FALSE in case of error
+ */
+static gboolean
+init_header_columns (ModestConf *conf, gboolean overwrite)
+{
+ int folder_type;
+
+ for (folder_type = TNY_FOLDER_TYPE_UNKNOWN;
+ folder_type <= TNY_FOLDER_TYPE_CALENDAR; ++folder_type) {
+
+ switch (folder_type) {
+ case TNY_FOLDER_TYPE_OUTBOX:
+ case TNY_FOLDER_TYPE_SENT:
+ case TNY_FOLDER_TYPE_DRAFTS:
+ save_header_settings (conf, folder_type,
+ MODEST_HEADER_VIEW_STYLE_DETAILS,
+ OUTBOX_COLUMNS_DETAILS,
+ G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS),
+ overwrite);
+ save_header_settings (conf, folder_type,
+ MODEST_HEADER_VIEW_STYLE_TWOLINES,
+ OUTBOX_COLUMNS_TWOLINES,
+ G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES),
+ overwrite);
+ break;
+
+ default:
+ save_header_settings (conf, folder_type,
+ MODEST_HEADER_VIEW_STYLE_DETAILS,
+ INBOX_COLUMNS_DETAILS,
+ G_N_ELEMENTS(INBOX_COLUMNS_DETAILS),
+ overwrite);
+ save_header_settings (conf, folder_type,
+ MODEST_HEADER_VIEW_STYLE_TWOLINES,
+ INBOX_COLUMNS_TWOLINES,
+ G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES),
+ overwrite);
+ };
+ }
+ return TRUE;
+}
+
+/**
+ * init_local_folders:
+ *
+ * create the Local Folders folder under cache, if they
+ * do not exist yet.
+ *
+ * Returns: TRUE if the folder were already there, or
+ * they were created, FALSE otherwise
+ */
+static gboolean
+init_local_folders (void)
+{
+ int i;
+ gchar *maildir_path;
+ static const gchar* maildirs[] = {
+ "cur", "new", "tmp"
+ };
+
+ maildir_path = modest_local_folder_info_get_maildir_path ();
+
+ for (i = 0; i != G_N_ELEMENTS(LOCAL_FOLDERS); ++i) {
+ int j;
+ for (j = 0; j != G_N_ELEMENTS(maildirs); ++j) {
+ gchar *dir;
+ dir = g_build_filename (maildir_path,
+ modest_local_folder_info_get_type_name(LOCAL_FOLDERS[i]),
+ maildirs[j],
+ NULL);
+ if (g_mkdir_with_parents (dir, 0755) < 0) {
+ g_printerr ("modest: failed to create %s\n", dir);
+ g_free (dir);
+ g_free (maildir_path);
+ return FALSE;
+ }
+ g_free(dir);
+ }
+ }
+
+ g_free (maildir_path);
+ return TRUE;
+}
+
+
+
+static void
+free_element (gpointer data, gpointer user_data)
+{
+ g_free (data);
+}
+
+
+
+/**
+ * init_default_account_maybe:
+ *
+ * if there are accounts defined, but there is no default account,
+ * it will be defined.
+ *
+ * Returns: TRUE if there was a default account already,
+ * or one has been created or there are no accounts yet,
+ * returns FALSE in case of error
+ */
+static gboolean
+init_default_account_maybe (ModestAccountMgr *acc_mgr)
+{
+ GSList *all_accounts = NULL;
+ gchar *default_account;
+ gboolean retval = TRUE;
+
+ all_accounts = modest_account_mgr_account_names (acc_mgr, NULL);
+ if (all_accounts) { /* if there are any accounts, there should be a default one */
+ default_account =
+ modest_account_mgr_get_default_account (acc_mgr);
+ if (!default_account) {
+ gchar *first_account;
+ g_printerr ("modest: no default account defined\n");
+ first_account = (gchar*)all_accounts->data;
+ if ((retval = modest_account_mgr_set_default_account (acc_mgr, first_account)))
+ g_printerr ("modest: set '%s' as the default account\n",
+ first_account);
+ else
+ g_printerr ("modest: failed to set '%s' as the default account\n",
+ first_account);
+ g_free (default_account);
+ }
+ g_slist_foreach (all_accounts, free_element, NULL);
+ g_slist_free (all_accounts);
+ }
+ return retval;
+}
+
+
+
+static void
+debug_g_type_init (void)
+{
+ GTypeDebugFlags gflags;
+ ModestRuntimeDebugFlags mflags;
+
+ gflags = 0;
+ mflags = modest_runtime_get_debug_flags ();
+
+ if (mflags & MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS)
+ gflags |= G_TYPE_DEBUG_OBJECTS;
+ if (mflags & MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS)
+ gflags |= G_TYPE_DEBUG_SIGNALS;
+
+ g_type_init_with_debug_flags (gflags);
+
+}
+
+static void
+debug_logging_init (void)
+{
+ ModestRuntimeDebugFlags mflags;
+ mflags = modest_runtime_get_debug_flags ();
+
+ if (mflags & MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING)
+ g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
+ G_LOG_LEVEL_CRITICAL |
+ G_LOG_LEVEL_WARNING);
+}
+
+
+static void
+init_i18n (void)
+{
+ bindtextdomain (GETTEXT_PACKAGE, MODEST_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+}
+
+
+#if MODEST_PLATFORM_ID==2
+static gboolean
+hildon_init (void)
+{
+ osso_context_t *osso_context =
+ osso_initialize(PACKAGE, PACKAGE_VERSION,
+ TRUE, NULL);
+ if (!osso_context) {
+ g_printerr ("modest: failed to acquire osso context\n");
+ return FALSE;
+ }
+#endif /* MODEST_PLATFORM_ID==2 */
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MODEST_RUNTIME_H__
+#define __MODEST_RUNTIME_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <modest-conf.h>
+#include <modest-account-mgr.h>
+#include <modest-cache-mgr.h>
+#include <modest-mail-operation-queue.h>
+#include <modest-tny-account-store.h>
+#include <modest-widget-factory.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_DEBUG "MODEST_DEBUG"
+
+typedef enum {
+ MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING = 1 << 0,
+ 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 */
+} ModestRuntimeDebugFlags;
+
+/**
+ * modest_runtime_init:
+ *
+ * initialize the modest runtime system (which sets up the
+ * environment, instantiates singletons and so on)
+ * modest_runtime_init should only be called once, and
+ * when done with it, modest_runtime_uninit should be called
+ *
+ * TRUE if this succeeded, FALSE otherwise.
+ */
+gboolean modest_runtime_init (void);
+
+
+/**
+ * modest_runtime_uinit:
+ *
+ * uninitialize the modest runtime system; free all the
+ * resources and so on.
+ *
+ * TRUE if this succeeded, FALSE otherwise
+ */
+gboolean modest_runtime_uninit (void);
+
+
+/**
+ * modest_runtime_get_debug_flags
+ *
+ * get the debug flags for modest; they are read from the MODEST_DEBUG
+ * environment variable; the flags specified as strings, separated by ':'.
+ * Possible values are:
+ * - "abort-on-warning": abort the program when a gtk/glib/.. warning occurs.
+ * useful when running in debugger
+ * - "log-actions": log user actions (not in use atm)
+ * - "track-object": track the use of (g)objects in the program. this option influences
+ * g_type_init_with_debug_flags
+ * - "track-signals": track the use of (g)signals in the program. this option influences
+ * g_type_init_with_debug_flags
+ * - "disable-cache": disable caching of strings and pixbuf
+ * if you would want to track signals and log actions, you could do something like:
+ * MODEST_DEBUG="log-actions:track-signals" ./modest
+ * NOTE that the flags will stay the same during the run of the program, even
+ * if the environment variable changes.
+ *
+ * Returns: the bitwise OR of the debug flags
+ */
+ModestRuntimeDebugFlags modest_runtime_get_debug_flags (void) G_GNUC_CONST;
+
+/**
+ * modest_runtime_get_conf:
+ *
+ * get the ModestConf singleton instance
+ *
+ * Returns: the ModestConf singleton
+ **/
+ModestConf* modest_runtime_get_conf (void);
+
+
+/**
+ * modest_runtime_get_account_mgr:
+ *
+ * get the ModestAccountMgr singleton instance
+ *
+ * Returns: the ModestAccountMgr singleton
+ **/
+ModestAccountMgr* modest_runtime_get_account_mgr (void);
+
+/**
+ * modest_runtime_get_account_store:
+ *
+ * get the ModestTnyAccountStore singleton instance
+ *
+ * Returns: the ModestTnyAccountStore singleton
+ **/
+ModestTnyAccountStore* modest_runtime_get_account_store (void);
+
+
+/**
+ * modest_runtime_get_cache_mgr:
+ *
+ * get the ModestCacheMgr singleton instance
+ *
+ * Returns: the ModestCacheMgr singleton
+ **/
+ModestCacheMgr* modest_runtime_get_cache_mgr (void);
+
+
+/**
+ * modest_runtime_get_mail_operation_queue:
+ *
+ * get the ModestMailOperationQueue singleton instance
+ *
+ * Returns: the ModestMailOperationQueue singleton
+ **/
+ModestMailOperationQueue* modest_runtime_get_mail_operation_queue (void);
+
+
+/**
+ * modest_runtime_get_widget_factory
+ *
+ * get the ModestWidgetFactory singleton instance
+ *
+ * Returns: the ModestCacheMgr singleton
+ **/
+ModestWidgetFactory* modest_runtime_get_widget_factory (void);
+
+
+G_END_DECLS
+
+#endif /*__MODEST_RUNTIME_H__*/
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "modest-singletons.h"
+
+/* 'private'/'protected' functions */
+static void modest_singletons_class_init (ModestSingletonsClass *klass);
+static void modest_singletons_init (ModestSingletons *obj);
+static void modest_singletons_finalize (GObject *obj);
+
+typedef struct _ModestSingletonsPrivate ModestSingletonsPrivate;
+struct _ModestSingletonsPrivate {
+ ModestConf *conf;
+ ModestAccountMgr *account_mgr;
+ ModestTnyAccountStore *account_store;
+ ModestCacheMgr *cache_mgr;
+ ModestMailOperationQueue *mail_op_queue;
+ ModestWidgetFactory *widget_factory;
+};
+#define MODEST_SINGLETONS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+ MODEST_TYPE_SINGLETONS, \
+ ModestSingletonsPrivate))
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+GType
+modest_singletons_get_type (void)
+{
+ static GType my_type = 0;
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestSingletonsClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_singletons_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestSingletons),
+ 1, /* n_preallocs */
+ (GInstanceInitFunc) modest_singletons_init,
+ NULL
+ };
+ my_type = g_type_register_static (G_TYPE_OBJECT,
+ "ModestSingletons",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_singletons_class_init (ModestSingletonsClass *klass)
+{
+ GObjectClass *gobject_class;
+ gobject_class = (GObjectClass*) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = modest_singletons_finalize;
+
+ g_type_class_add_private (gobject_class, sizeof(ModestSingletonsPrivate));
+}
+
+static void
+modest_singletons_init (ModestSingletons *obj)
+{
+ ModestSingletonsPrivate *priv;
+ priv = MODEST_SINGLETONS_GET_PRIVATE(obj);
+
+ priv->conf = NULL;
+ priv->account_mgr = NULL;
+ priv->account_store = NULL;
+ priv->cache_mgr = NULL;
+ priv->mail_op_queue = NULL;
+ priv->widget_factory = NULL;
+
+ priv->conf = modest_conf_new ();
+ if (!priv->conf) {
+ g_printerr ("modest: cannot create modest conf instance\n");
+ return;
+ }
+
+ priv->account_mgr = modest_account_mgr_new (priv->conf);
+ if (!priv->account_mgr) {
+ g_printerr ("modest: cannot create modest account mgr instance\n");
+ return;
+ }
+
+ priv->account_store = modest_tny_account_store_new (priv->account_mgr);
+ if (!priv->account_store) {
+ g_printerr ("modest: cannot create modest tny account store instance\n");
+ return;
+ }
+
+ priv->cache_mgr = modest_cache_mgr_new ();
+ if (!priv->cache_mgr) {
+ g_printerr ("modest: cannot create modest cache mgr instance\n");
+ return;
+ }
+
+ priv->mail_op_queue = modest_mail_operation_queue_new ();
+ if (!priv->mail_op_queue) {
+ g_printerr ("modest: cannot create modest mail operation queue instance\n");
+ return;
+ }
+
+ /* don't initialize widget_factory here, but do it lazily, so we can
+ * instaniatie modest-singletons before gtk_init
+ */
+}
+
+static void
+modest_singletons_finalize (GObject *obj)
+{
+ ModestSingletonsPrivate *priv;
+ priv = MODEST_SINGLETONS_GET_PRIVATE(obj);
+
+ if (priv->conf) {
+ g_object_unref (G_OBJECT(priv->conf));
+ priv->conf = NULL;
+ }
+
+ if (priv->account_mgr) {
+ g_object_unref (G_OBJECT(priv->account_mgr));
+ priv->account_mgr = NULL;
+ }
+ if (priv->account_store) {
+ g_object_unref (G_OBJECT(priv->account_store));
+ priv->account_store = NULL;
+ }
+
+ if (priv->cache_mgr) {
+ g_object_unref (G_OBJECT(priv->cache_mgr));
+ priv->cache_mgr = NULL;
+ }
+
+ if (priv->widget_factory) {
+ g_object_unref (G_OBJECT(priv->widget_factory));
+ priv->widget_factory = NULL;
+ }
+
+ G_OBJECT_CLASS(parent_class)->finalize (obj);
+}
+
+ModestSingletons*
+modest_singletons_new (void)
+{
+ ModestSingletonsPrivate *priv;
+ ModestSingletons *self;
+
+ self = MODEST_SINGLETONS(g_object_new(MODEST_TYPE_SINGLETONS, NULL));
+ priv = MODEST_SINGLETONS_GET_PRIVATE(self);
+
+ /* widget_factory will still be NULL, as it is initialized lazily */
+ if (!(priv->conf && priv->account_mgr && priv->account_store &&
+ priv->cache_mgr && priv->mail_op_queue)) {
+ g_printerr ("modest: failed to create singletons instance\n");
+ g_object_unref (G_OBJECT(self));
+ self = NULL;
+ }
+
+ return self;
+}
+
+
+ModestConf*
+modest_singletons_get_conf (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+ return MODEST_SINGLETONS_GET_PRIVATE(self)->conf;
+}
+
+ModestAccountMgr*
+modest_singletons_get_account_mgr (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+ return MODEST_SINGLETONS_GET_PRIVATE(self)->account_mgr;
+}
+
+ModestTnyAccountStore*
+modest_singletons_get_account_store (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+ return MODEST_SINGLETONS_GET_PRIVATE(self)->account_store;
+}
+
+ModestCacheMgr*
+modest_singletons_get_cache_mgr (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+ return MODEST_SINGLETONS_GET_PRIVATE(self)->cache_mgr;
+}
+
+
+ModestMailOperationQueue*
+modest_singletons_get_mail_operation_queue (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+ return MODEST_SINGLETONS_GET_PRIVATE(self)->mail_op_queue;
+}
+
+
+ModestWidgetFactory*
+modest_singletons_get_widget_factory (ModestSingletons *self)
+{
+ ModestSingletonsPrivate *priv;
+
+ g_return_val_if_fail (self, NULL);
+
+ priv = MODEST_SINGLETONS_GET_PRIVATE(self);
+
+ if (G_UNLIKELY(!priv->widget_factory))
+ priv->widget_factory = modest_widget_factory_new (priv->account_store);
+ if (G_UNLIKELY(!priv->widget_factory)) {
+ g_printerr ("modest: cannot create modest widget factory instance\n");
+ return NULL;
+ }
+ return priv->widget_factory;
+}
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MODEST_SINGLETONS_H__
+#define __MODEST_SINGLETONS_H__
+
+#include <config.h>
+
+#include <glib-object.h>
+#include <modest-conf.h>
+#include <modest-account-mgr.h>
+#include <modest-tny-account-store.h>
+#include <modest-mail-operation-queue.h>
+#include <modest-cache-mgr.h>
+#include <modest-widget-factory.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_SINGLETONS (modest_singletons_get_type())
+#define MODEST_SINGLETONS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_SINGLETONS,ModestSingletons))
+#define MODEST_SINGLETONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_SINGLETONS,GObject))
+#define MODEST_IS_SINGLETONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_SINGLETONS))
+#define MODEST_IS_SINGLETONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_SINGLETONS))
+#define MODEST_SINGLETONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_SINGLETONS,ModestSingletonsClass))
+
+typedef struct _ModestSingletons ModestSingletons;
+typedef struct _ModestSingletonsClass ModestSingletonsClass;
+
+struct _ModestSingletons {
+ GObject parent;
+};
+
+struct _ModestSingletonsClass {
+ GObjectClass parent_class;
+};
+
+
+/**
+ * modest_singletons_get_type:
+ *
+ * get the GType for ModestSingletons
+ *
+ * Returns: the GType
+ */
+GType modest_singletons_get_type (void) G_GNUC_CONST;
+
+
+/**
+ * modest_singletons_new:
+ *
+ * create a new ModestSingletons instance;
+ * don't use this function directly, use the modest-runtime
+ * functions instead.
+ *
+ * Returns: a new ModestSingletons instance, or NULL in case
+ * of any error
+ */
+ModestSingletons* modest_singletons_new (void);
+
+
+/**
+ * modest_singletons_get_conf:
+ *
+ * get the ModestConf singleton instance
+ * don't use this function directly, use the modest-runtime
+ * functions instead.
+ *
+ * Returns: the ModestConf singleton
+ **/
+ModestConf* modest_singletons_get_conf (ModestSingletons *self);
+
+
+/**
+ * modest_singletons_get_account_mgr:
+ *
+ * get the ModestAccountMgr singleton instance
+ * don't use this function directly, use the modest-runtime
+ * functions instead.
+ *
+ * Returns: the ModestAccountMgr singleton
+ **/
+ModestAccountMgr* modest_singletons_get_account_mgr (ModestSingletons *self);
+
+
+/**
+ * modest_singletons_get_account_store:
+ *
+ * get the ModestTnyAccountStore singleton instance
+ * don't use this function directly, use the modest-runtime
+ * functions instead.
+ *
+ * Returns: the ModestTnyAccountStore singleton
+ **/
+ModestTnyAccountStore* modest_singletons_get_account_store (ModestSingletons *self);
+
+
+/**
+ * modest_singletons_get_cache_mgr:
+ *
+ * get the ModestCacheMgr singleton instance
+ * don't use this function directly, use the modest-runtime
+ * functions instead.
+ *
+ * Returns: the ModestCacheMgr singleton
+ **/
+ModestCacheMgr* modest_singletons_get_cache_mgr (ModestSingletons *self);
+
+
+/**
+ * modest_singletons_get_mail_operation_queue:
+ *
+ * get the ModestMailOperationQueue singleton instance
+ * don't use this function directly, use the modest-runtime
+ * functions instead.
+ *
+ * Returns: the ModestMailOperationQueue singleton
+ **/
+ModestMailOperationQueue* modest_singletons_get_mail_operation_queue (ModestSingletons *self);
+
+
+
+
+/**
+ * modest_singletons_get_widget_factory:
+ *
+ * get the ModestWidgetFactory singleton instance
+ * don't use this function directly, use the modest-runtime
+ * functions instead.
+ *
+ * Returns: the ModestWidgetFactory singleton
+ **/
+ModestWidgetFactory* modest_singletons_get_widget_factory (ModestSingletons *self);
+
+
+G_END_DECLS
+
+#endif /* __MODEST_SINGLETONS_H__ */
+
#include <glib/gi18n.h>
#include <regex.h>
#include <modest-tny-platform-factory.h>
-#include "modest-text-utils.h"
+#include <modest-text-utils.h>
+#include <modest-runtime.h>
#ifdef HAVE_CONFIG_H
static GHashTable*
get_display_date_cache (void)
{
- TnyPlatformFactory *fakt;
- ModestCacheMgr *cache_mgr;
-
- fakt = modest_tny_platform_factory_get_instance ();
-
- cache_mgr = modest_tny_platform_factory_get_cache_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(fakt));
-
- return modest_cache_mgr_get_cache (cache_mgr,
+ return modest_cache_mgr_get_cache (modest_runtime_get_cache_mgr (),
MODEST_CACHE_MGR_CACHE_TYPE_DATE_STRING);
}
GHashTable *password_hash;
TnyDevice *device;
- TnyPlatformFactory *platform_fact;
TnySessionCamel *tny_session_camel;
+ ModestAccountMgr *account_mgr;
TnyAccount *local_folders;
};
MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
priv->cache_dir = NULL;
-
- priv->platform_fact = NULL;
+ priv->account_mgr = NULL;
priv->tny_session_camel = NULL;
priv->device = NULL;
g_printerr ("modest: cannot create account for local folders");
return NULL;
}
-
- maildir = modest_local_folder_info_get_maildir_path ();
+ tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account),priv->tny_session_camel);
+
+ maildir = modest_local_folder_info_get_maildir_path ();
url = camel_url_new ("maildir:", NULL);
camel_url_set_path (url, maildir);
-
url_string = camel_url_to_string (url, 0);
- tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
- tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account),
- priv->tny_session_camel);
+ tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
tny_account_set_name (TNY_ACCOUNT(tny_account), MODEST_LOCAL_FOLDERS_ACCOUNT_NAME);
tny_account_set_id (TNY_ACCOUNT(tny_account), MODEST_LOCAL_FOLDERS_ACCOUNT_NAME);
static ModestTnyAccountStore*
get_account_store_for_account (TnyAccount *account)
{
- return MODEST_TNY_ACCOUNT_STORE(g_object_get_data (G_OBJECT(account), "account_store"));
+ return MODEST_TNY_ACCOUNT_STORE(g_object_get_data (G_OBJECT(account),
+ "account_store"));
}
get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
{
const gchar *key;
- ModestAccountMgr *account_mgr;
const TnyAccountStore *account_store;
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
key = tny_account_get_id (account);
account_store = TNY_ACCOUNT_STORE(get_account_store_for_account (account));
-
+
self = MODEST_TNY_ACCOUNT_STORE (account_store);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->platform_fact));
-
/* is it in the hash? if it's already there, it must be wrong... */
pwd_ptr = (gpointer)&pwd; /* pwd_ptr so the compiler does not complained about
* type-punned ptrs...*/
/* if the password is not already there, try ModestConf */
if (!already_asked) {
- pwd = modest_account_mgr_get_string (account_mgr,
+ pwd = modest_account_mgr_get_string (priv->account_mgr,
key, MODEST_ACCOUNT_PASSWORD,
TRUE, NULL);
g_hash_table_insert (priv->password_hash, g_strdup (key), g_strdup (pwd));
if (!*cancel) {
if (remember)
- modest_account_mgr_set_string (account_mgr,
+ modest_account_mgr_set_string (priv->account_mgr,
key, MODEST_ACCOUNT_PASSWORD,
pwd,
TRUE, NULL);
static void
-forget_password (TnyAccount *account) {
-
+forget_password (TnyAccount *account)
+{
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
const TnyAccountStore *account_store;
gchar *pwd;
const gchar *key;
- ModestAccountMgr *account_mgr;
account_store = TNY_ACCOUNT_STORE(get_account_store_for_account (account));
self = MODEST_TNY_ACCOUNT_STORE (account_store);
g_hash_table_insert (priv->password_hash, g_strdup (key), NULL);
}
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->platform_fact));
-
/* Remove from configuration system */
- modest_account_mgr_unset (account_mgr,
+ modest_account_mgr_unset (priv->account_mgr,
key, MODEST_ACCOUNT_PASSWORD,
TRUE, NULL);
}
g_hash_table_destroy (priv->password_hash);
priv->password_hash = NULL;
}
+
+ if (priv->account_mgr) {
+ g_object_unref (priv->account_mgr);
+ priv->account_mgr = NULL;
+ }
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GObject *obj;
ModestTnyAccountStorePrivate *priv;
- TnyPlatformFactory *pfact;
g_return_val_if_fail (account_mgr, NULL);
obj = G_OBJECT(g_object_new(MODEST_TYPE_TNY_ACCOUNT_STORE, NULL));
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
- pfact = TNY_PLATFORM_FACTORY (modest_tny_platform_factory_get_instance());
- if (!pfact) {
- g_printerr ("modest: cannot get platform factory instance\n");
- g_object_unref (obj);
- return NULL;
- } else
- priv->platform_fact = pfact;
-
+ priv->account_mgr = account_mgr;
+ g_object_ref (G_OBJECT(priv->account_mgr));
+
/* The session needs the platform factory */
priv->tny_session_camel = tny_session_camel_new (TNY_ACCOUNT_STORE(obj));
if (!priv->tny_session_camel) {
g_object_unref (obj);
return NULL;
}
+
tny_session_camel_set_ui_locker (priv->tny_session_camel, tny_gtk_lockable_new ());
- priv->local_folders = get_local_folders_account (MODEST_TNY_ACCOUNT_STORE(obj));
/* FIXME: unref this in the end? */
/* Connect signals */
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
GSList *accounts, *cursor;
- ModestAccountMgr *account_mgr;
g_return_if_fail (account_store);
g_return_if_fail (TNY_IS_LIST(list));
self = MODEST_TNY_ACCOUNT_STORE(account_store);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->platform_fact));
if (type == TNY_ACCOUNT_STORE_BOTH) {
modest_tny_account_store_get_accounts (account_store, list,
TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
}
- accounts = modest_account_mgr_account_names (account_mgr, NULL);
+ accounts = modest_account_mgr_account_names (priv->account_mgr, NULL);
for (cursor = accounts; cursor; cursor = cursor->next) {
TnyAccount *tny_account = NULL;
ModestAccountData *account_data =
- modest_account_mgr_get_account_data (account_mgr,
+ modest_account_mgr_get_account_data (priv->account_mgr,
(gchar*)cursor->data);
if (account_data && account_data->enabled) {
tny_account = get_tny_account_from_account (self, account_data, type);
tny_list_prepend (list, G_OBJECT(tny_account));
}
g_free (cursor->data);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ modest_account_mgr_free_account_data (priv->account_mgr, account_data);
}
g_slist_free (accounts);
/* also, add the local folder pseudo-account */
if (type != TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS) {
if (!priv->local_folders)
+ priv->local_folders = get_local_folders_account (self);
+ if (!priv->local_folders)
g_printerr ("modest: no local folders account\n");
else
tny_list_prepend (list, G_OBJECT(priv->local_folders));
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
if (!priv->device)
- priv->device = tny_platform_factory_new_device (priv->platform_fact);
+ priv->device = tny_platform_factory_new_device
+ (modest_tny_platform_factory_get_instance());
return g_object_ref (G_OBJECT(priv->device));
}
}
-
TnyAccount*
modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self)
{
return MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self)->local_folders;
}
-
-/* for now, ignore the account ===> the special folders are the same,
- * local folders for all accounts
- * this might change, ie, IMAP might have server-side sent-items
- */
-TnyFolder *
-modest_tny_account_store_get_special_folder (ModestTnyAccountStore*self, TnyAccount *account,
- TnyFolderType special_type)
-{
- g_return_val_if_fail (self, NULL);
- g_return_val_if_fail (account, NULL);
- g_return_val_if_fail (0 <= special_type && special_type < TNY_FOLDER_TYPE_NUM,
- NULL);
- //TnyAccount *local_account =
- // tny_account_store_get_local_folders_account (self);
-
- /* FIXME: implement this */
- return NULL;
-}
*/
TnySessionCamel* tny_account_store_get_session (TnyAccountStore *self);
-
-
/**
* tny_account_store_get_local_folders_account
* @self: a ModestTnyAccountStore instance
*/
TnyAccount* modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self);
-
-/**
- * tny_account_store_get_special_folder
- * @self: a ModestTnyAccountStore instance
- * @type: some tny folder type
- *
- * get the special (Inbox,Outbox,Sent,Draft etc.) folder for this account
- *
- * Returns: the tny folder corresponding to this special folder, or NULL
- */
-TnyFolder* modest_tny_account_store_get_special_folder (ModestTnyAccountStore *self,
- TnyAccount *account,
- TnyFolderType special_type);
-
G_END_DECLS
#endif /* __MODEST_TNY_ACCOUNT_STORE_H__ */
*/
gboolean modest_tny_folder_is_local_folder (const TnyFolder *folder);
+
/**
* modest_tny_folder_get_local_folder_type:
* @folder: a valid tnymail folder
/* modest-tny-platform-factory.c */
#include <config.h>
+#include <modest-runtime.h>
#include <tny-camel-header.h>
#include <tny-camel-mime-part.h>
#include <tny-camel-msg.h>
};
typedef struct _ModestTnyPlatformFactoryPrivate ModestTnyPlatformFactoryPrivate;
-struct _ModestTnyPlatformFactoryPrivate {
- ModestTnyAccountStore *account_store;
- ModestConf *conf;
- ModestAccountMgr *account_mgr;
- ModestMailOperationQueue *mail_op_queue;
- ModestCacheMgr *cache_mgr;
-};
+struct _ModestTnyPlatformFactoryPrivate {};
#define MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_TNY_PLATFORM_FACTORY, \
static GObjectClass *parent_class = NULL;
static ModestTnyPlatformFactory *singleton = NULL;
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
GType
modest_tny_platform_factory_get_type (void)
{
static void
modest_tny_platform_factory_init (ModestTnyPlatformFactory *obj)
{
- ModestTnyPlatformFactoryPrivate *priv;
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(obj);
-
- priv->account_mgr = NULL;
- priv->conf = NULL;
- priv->account_store = NULL;
- priv->mail_op_queue = NULL;
- priv->cache_mgr = NULL;
+ /* empty */
}
static GObject*
static void
modest_tny_platform_factory_finalize (GObject *obj)
{
- ModestTnyPlatformFactoryPrivate *priv;
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(obj);
-
- if (priv->account_mgr)
- g_object_unref (G_OBJECT(priv->account_mgr));
-
- if (priv->conf)
- g_object_unref (G_OBJECT(priv->conf));
-
- if (priv->account_store)
- g_object_unref (G_OBJECT(priv->account_store));
-
- if (priv->mail_op_queue)
- g_object_unref (G_OBJECT(priv->mail_op_queue));
-
- if (priv->cache_mgr)
- g_object_unref (G_OBJECT(priv->cache_mgr));
-
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
static TnyAccountStore *
modest_tny_platform_factory_new_account_store (TnyPlatformFactory *self)
{
- ModestTnyPlatformFactoryPrivate *priv;
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(self);
-
- if (!priv->account_store) {
- if (!priv->account_mgr)
- modest_tny_platform_factory_get_account_mgr_instance (MODEST_TNY_PLATFORM_FACTORY (self));
-
- priv->account_store = modest_tny_account_store_new (priv->account_mgr);
- }
-
- return TNY_ACCOUNT_STORE (priv->account_store);
+ return TNY_ACCOUNT_STORE(modest_tny_account_store_new
+ (modest_runtime_get_account_mgr()));
}
static TnyDevice *
{
return tny_camel_header_new ();
}
-
-
-ModestAccountMgr *
-modest_tny_platform_factory_get_account_mgr_instance (ModestTnyPlatformFactory *fact)
-{
- ModestTnyPlatformFactoryPrivate *priv;
-
- g_return_val_if_fail (fact, NULL);
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact);
-
- if (!priv->account_mgr) {
- if (!priv->conf)
- modest_tny_platform_factory_get_conf_instance (fact);
- priv->account_mgr = modest_account_mgr_new (priv->conf);
- }
-
- return priv->account_mgr;
-}
-
-ModestConf *
-modest_tny_platform_factory_get_conf_instance (ModestTnyPlatformFactory *fact)
-{
- ModestTnyPlatformFactoryPrivate *priv;
-
- g_return_val_if_fail (fact, NULL);
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact);
-
- if (!priv->conf)
- priv->conf = modest_conf_new ();
-
- return priv->conf;
-}
-
-ModestMailOperationQueue*
-modest_tny_platform_factory_get_mail_operation_queue_instance (ModestTnyPlatformFactory *fact)
-{
- ModestTnyPlatformFactoryPrivate *priv;
-
- g_return_val_if_fail (fact, NULL);
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact);
-
- if (!priv->mail_op_queue)
- priv->mail_op_queue = modest_mail_operation_queue_new ();
-
- return priv->mail_op_queue;
-}
-
-
-
-ModestCacheMgr*
-modest_tny_platform_factory_get_cache_mgr_instance (ModestTnyPlatformFactory *fact)
-{
- ModestTnyPlatformFactoryPrivate *priv;
-
- g_return_val_if_fail (fact, NULL);
-
- priv = MODEST_TNY_PLATFORM_FACTORY_GET_PRIVATE(fact);
-
- if (!priv->cache_mgr)
- priv->cache_mgr = modest_cache_mgr_new ();
-
- return priv->cache_mgr;
-}
#define __MODEST_TNY_PLATFORM_FACTORY_H__
#include <glib-object.h>
-
#include <tny-platform-factory.h>
-#include <modest-account-mgr.h>
-#include <modest-conf.h>
-#include <modest-mail-operation-queue.h>
-#include <modest-cache-mgr.h>
G_BEGIN_DECLS
GObjectClass parent_class;
};
-/* member functions */
+
+/**
+ * modest_tny_platform_factory_get_type:
+ *
+ * get the GType for #ModestTnyPlatformFactory
+ *
+ * Returns: the GType for #ModestTnyPlatformFactory
+ */
GType modest_tny_platform_factory_get_type (void) G_GNUC_CONST;
/**
**/
TnyPlatformFactory* modest_tny_platform_factory_get_instance (void);
-/**
- * modest_tny_platform_factory_get_account_mgr_instance:
- * @fact: the #TnyPlatformFactory that holds the #ModestAccountMgr instance
- *
- * Gets a new instance of a #ModestAccountMgr if it is the first call
- * to the function, or the current instantiated one otherwise. This
- * object is supposed to be a singleton
- *
- * Returns: an instance of a #ModestAccountMgr
- **/
-ModestAccountMgr* modest_tny_platform_factory_get_account_mgr_instance (ModestTnyPlatformFactory *fact);
-
-/**
- * modest_tny_platform_factory_get_conf_instance:
- * @fact: the #TnyPlatformFactory that holds the #ModestConf instance
- *
- * Gets a new instance of a #ModestConf if it is the first call to the
- * function, or the current instantiated one otherwise. This object is
- * supposed to be a singleton
- *
- * Returns: an instance of a #ModestConf
- **/
-ModestConf* modest_tny_platform_factory_get_conf_instance (ModestTnyPlatformFactory *fact);
-
-/**
- * modest_tny_platform_factory_get_mail_operation_queue_instance:
- * @fact: the #TnyPlatformFactory that holds the #ModestMailOperationQueue instance
- *
- * Gets a new instance of a #ModestMailOperationQueue if it is the
- * first call to the function, or the current instantiated one
- * otherwise. This object is supposed to be a singleton
- *
- * Returns: an instance of a #ModestMailOperationQueue
- **/
-ModestMailOperationQueue* modest_tny_platform_factory_get_mail_operation_queue_instance (ModestTnyPlatformFactory *fact);
-
-
-/**
- * modest_tny_platform_factory_get_cache_mgr_instance:
- * @fact: the #TnyPlatformFactory that holds the #ModestCacheMgr instance
- *
- * Gets a new instance of a #ModestCacheMgr if it is the
- * first call to the function, or the current instantiated one
- * otherwise. This object is supposed to be a singleton
- *
- * Returns: an instance of a #ModestCacheMgr.
- **/
-ModestCacheMgr* modest_tny_platform_factory_get_cache_mgr_instance (ModestTnyPlatformFactory *fact);
-
-
-
-
G_END_DECLS
#endif /* __MODEST_TNY_PLATFORM_FACTORY_H__ */
typedef struct _ModestUIPrivate ModestUIPrivate;
struct _ModestUIPrivate {
- ModestWidgetFactory *widget_factory;
- TnyAccountStore *account_store;
ModestWindow *main_window;
GtkUIManager *ui_manager;
};
#include <glib/gi18n.h>
#include <string.h>
+#include <modest-runtime.h>
#include "modest-ui-priv.h"
#include "modest-ui.h"
#include "modest-ui-actions.h"
priv = MODEST_UI_GET_PRIVATE(obj);
- priv->widget_factory = NULL;
priv->main_window = NULL;
- priv->account_store = NULL;
}
{
ModestUIPrivate *priv = MODEST_UI_GET_PRIVATE(obj);
- if (priv->widget_factory) {
- g_object_unref (G_OBJECT(priv->widget_factory));
- priv->widget_factory = NULL;
- }
-
if (priv->ui_manager) {
g_object_unref (G_OBJECT(priv->ui_manager));
priv->ui_manager = NULL;
}
+ priv->main_window = NULL;
+
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
ModestUI*
-modest_ui_new (TnyAccountStore *account_store)
+modest_ui_new (void)
{
GObject *obj;
ModestUIPrivate *priv;
- TnyPlatformFactory *fact;
- ModestAccountMgr *account_mgr;
obj = g_object_new(MODEST_TYPE_UI, NULL);
priv = MODEST_UI_GET_PRIVATE(obj);
-
- /* Get the platform-dependent instances */
- fact = modest_tny_platform_factory_get_instance ();
- priv->account_store = account_store;
-
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(fact));
- if (!account_mgr) {
- g_printerr ("modest: could not create ModestAccountMgr instance\n");
- g_object_unref (obj);
- return NULL;
- }
-
- priv->widget_factory = modest_widget_factory_new ();
- if (!priv->widget_factory) {
- g_printerr ("modest: could not initialize widget factory\n");
- return NULL;
- }
-
/* Register our own icons as stock icons in order to
use them with the UI manager */
register_stock_icons ();
priv = MODEST_UI_GET_PRIVATE(self);
if (!priv->main_window) {
-
- /* Create main window */
- priv->main_window = modest_main_window_new (priv->widget_factory,
- priv->account_store);
-
+ priv->main_window = modest_main_window_new ();
connect_signals (self);
}
priv = MODEST_UI_GET_PRIVATE(self);
/* Create window */
- edit_window = modest_edit_msg_window_new (priv->widget_factory,
- priv->account_store,
- edit_type);
+ edit_window = modest_edit_msg_window_new (edit_type);
/* Connect Edit Window signals */
/* connect_edit_window_signals (self); */
ModestHeaderView *header_view;
ModestMsgView *msg_view;
GtkWidget *toggle;
+ ModestWidgetFactory *widget_factory;
priv = MODEST_UI_GET_PRIVATE(self);
- folder_view = modest_widget_factory_get_folder_view (priv->widget_factory);
- header_view = modest_widget_factory_get_header_view (priv->widget_factory);
- msg_view = modest_widget_factory_get_msg_preview (priv->widget_factory);
- toggle = modest_widget_factory_get_online_toggle (priv->widget_factory);
- device = tny_account_store_get_device (priv->account_store);
+ widget_factory = modest_runtime_get_widget_factory ();
+
+ folder_view = modest_widget_factory_get_folder_view (widget_factory);
+ header_view = modest_widget_factory_get_header_view (widget_factory);
+ msg_view = modest_widget_factory_get_msg_preview (widget_factory);
+ toggle = modest_widget_factory_get_online_toggle (widget_factory);
+ device = tny_account_store_get_device
+ (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()));
/* folder view */
g_signal_connect (G_OBJECT(folder_view), "folder_selection_changed",
TnyIterator *iter;
GtkTreeModel *model;
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
+ widget_factory = modest_runtime_get_widget_factory ();
header_view = modest_widget_factory_get_header_view (widget_factory);
header_list = modest_header_view_get_selected_headers (header_view);
- g_object_unref (G_OBJECT(widget_factory));
if (header_list) {
iter = tny_list_create_iterator (header_list);
void
_modest_ui_actions_on_accounts (GtkWidget *widget,
- ModestMainWindow *main_window)
+ ModestMainWindow *main_window)
{
GtkWidget *account_win;
- ModestWidgetFactory *widget_factory;
-
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- account_win = modest_account_view_window_new (widget_factory);
- g_object_unref (G_OBJECT(widget_factory));
+ account_win = modest_account_view_window_new (modest_runtime_get_widget_factory());
gtk_window_set_transient_for (GTK_WINDOW (account_win),
GTK_WINDOW (main_window));
ModestMainWindow *main_window)
{
ModestWindow *msg_win;
- ModestWidgetFactory *widget_factory;
- TnyAccountStore *account_store;
-
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- account_store = modest_window_get_account_store (MODEST_WINDOW (main_window));
- msg_win = modest_edit_msg_window_new (widget_factory,
- account_store,
- MODEST_EDIT_TYPE_NEW);
- g_object_unref (G_OBJECT (widget_factory));
- g_object_unref (G_OBJECT (account_store));
-
+ msg_win = modest_edit_msg_window_new (MODEST_EDIT_TYPE_NEW);
gtk_widget_show_all (GTK_WIDGET (msg_win));
}
static void
reply_forward_func (gpointer data, gpointer user_data)
{
- ModestWidgetFactory *widget_factory;
- //TnyHeader *new_header;
TnyMsg *msg, *new_msg;
- TnyAccountStore *account_store;
GetMsgAsyncHelper *helper;
ReplyForwardHelper *rf_helper;
ModestWindow *msg_win;
g_warning ("Unable to create a message");
goto cleanup;
}
-
-/* /\* Set from *\/ */
-/* new_header = tny_msg_get_header (new_msg); */
-/* tny_header_set_from (new_header, rf_helper->from); */
-/* g_object_unref (G_OBJECT (new_header)); */
/* Show edit window */
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (helper->main_window));
- account_store = modest_window_get_account_store (MODEST_WINDOW (helper->main_window));
- msg_win = modest_edit_msg_window_new (widget_factory,
- account_store,
- MODEST_EDIT_TYPE_NEW);
- g_object_unref (G_OBJECT (widget_factory));
- g_object_unref (G_OBJECT (account_store));
-
+ msg_win = modest_edit_msg_window_new (MODEST_EDIT_TYPE_NEW);
modest_edit_msg_window_set_msg (MODEST_EDIT_MSG_WINDOW (msg_win),
new_msg);
gtk_widget_show_all (GTK_WIDGET (msg_win));
{
ModestHeaderView *header_view;
ModestAccountMgr *account_mgr;
- ModestWidgetFactory *widget_factory;
TnyList *header_list;
guint reply_forward_type;
ModestConf *conf;
ModestAccountData *default_account_data;
- TnyPlatformFactory *plat_factory;
TnyHeader *header;
TnyFolder *folder;
gchar *from, *key, *default_account_name;
GetMsgAsyncHelper *helper;
ReplyForwardHelper *rf_helper;
- /* Get ModestConf */
- plat_factory = modest_tny_platform_factory_get_instance ();
- conf = modest_tny_platform_factory_get_conf_instance
- (MODEST_TNY_PLATFORM_FACTORY(plat_factory));
-
+ conf = modest_runtime_get_conf ();
+
/* Get reply or forward type */
key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE,
(action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE);
g_free (key);
/* Get the list of headers */
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- header_view = modest_widget_factory_get_header_view (widget_factory);
- header_list = modest_header_view_get_selected_headers (header_view);
- g_object_unref (G_OBJECT(widget_factory));
-
+ header_view = modest_widget_factory_get_header_view (modest_runtime_get_widget_factory());
+ header_list = modest_header_view_get_selected_headers (header_view);
if (!header_list)
return;
same folder and that we reply all of them from the
same account. In fact the interface currently only
allows single selection */
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(plat_factory));
+ account_mgr = modest_runtime_get_account_mgr();
default_account_name = modest_account_mgr_get_default_account (account_mgr);
default_account_data =
modest_account_mgr_get_account_data (account_mgr,
ModestMainWindow *main_window)
{
ModestHeaderView *header_view;
- ModestWidgetFactory *widget_factory;
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- header_view = modest_widget_factory_get_header_view (widget_factory);
- g_object_unref (G_OBJECT(widget_factory));
+ header_view = modest_widget_factory_get_header_view
+ (modest_runtime_get_widget_factory());
modest_header_view_select_next (header_view);
}
_modest_ui_actions_toggle_view (GtkWidget *widget,
ModestMainWindow *main_window)
{
- ModestHeaderView *header_view;
- ModestWidgetFactory *widget_factory;
ModestConf *conf;
- TnyPlatformFactory *plat_factory;
+ ModestHeaderView *header_view;
- /* Get ModestConf */
- plat_factory = modest_tny_platform_factory_get_instance ();
- conf = modest_tny_platform_factory_get_conf_instance
- (MODEST_TNY_PLATFORM_FACTORY(plat_factory));
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- header_view = modest_widget_factory_get_header_view (widget_factory);
- g_object_unref (G_OBJECT(widget_factory));
+ header_view = modest_widget_factory_get_header_view
+ (modest_runtime_get_widget_factory());
+ conf = modest_runtime_get_conf ();
+
/* what is saved/restored is depending on the style; thus; we save with
* old style, then update the style, and restore for this new style*/
modest_widget_memory_save (conf, G_OBJECT(header_view), "header-view");
read_msg_func (gpointer data, gpointer user_data)
{
ModestMsgView *msg_view;
- ModestWidgetFactory *widget_factory;
TnyMsg *msg;
TnyHeader *header;
GetMsgAsyncHelper *helper;
g_object_unref (G_OBJECT (header));
/* Set message on msg view */
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (helper->main_window));
- msg_view = modest_widget_factory_get_msg_preview (widget_factory);
- g_object_unref (G_OBJECT(widget_factory));
+ msg_view = modest_widget_factory_get_msg_preview
+ (modest_runtime_get_widget_factory());
modest_msg_view_set_message (msg_view, msg);
}
if (*err && ((*err)->code == TNY_FOLDER_ERROR_GET_MSG)) {
ModestHeaderView *header_view;
- ModestWidgetFactory *widget_factory;
-
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (helper->main_window));
- header_view = modest_widget_factory_get_header_view (widget_factory);
- g_object_unref (G_OBJECT (widget_factory));
+ header_view = modest_widget_factory_get_header_view
+ (modest_runtime_get_widget_factory());
_modest_ui_actions_on_item_not_found (header_view,
MODEST_ITEM_TYPE_MESSAGE,
helper->main_window);
/* when there's no header, clear the msgview */
if (!header) {
ModestMsgView *msg_view;
- ModestWidgetFactory *widget_factory;
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- msg_view = modest_widget_factory_get_msg_preview (widget_factory);
+ msg_view = modest_widget_factory_get_msg_preview
+ (modest_runtime_get_widget_factory());
modest_msg_view_set_message (msg_view, NULL);
return;
}
ModestMainWindow *main_window)
{
GtkLabel *folder_info_label;
- TnyPlatformFactory *factory;
gchar *txt;
ModestConf *conf;
ModestHeaderView *header_view;
- ModestWidgetFactory *widget_factory;
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
folder_info_label =
- GTK_LABEL (modest_widget_factory_get_folder_info_label (widget_factory));
+ GTK_LABEL (modest_widget_factory_get_folder_info_label
+ (modest_runtime_get_widget_factory()));
if (!folder) {
gtk_label_set_label (GTK_LABEL(folder_info_label), "");
return;
}
-
- factory = modest_tny_platform_factory_get_instance ();
- header_view = modest_widget_factory_get_header_view (widget_factory);
- conf = modest_tny_platform_factory_get_conf_instance
- (MODEST_TNY_PLATFORM_FACTORY(factory));
- g_object_unref (G_OBJECT (widget_factory));
+
+ header_view = modest_widget_factory_get_header_view (modest_runtime_get_widget_factory());
+ conf = modest_runtime_get_conf ();
if (!selected) { /* the folder was unselected; save it's settings */
modest_widget_memory_save (conf, G_OBJECT (header_view),
/****************************************************************************/
void
-_modest_ui_actions_on_connection_changed (TnyDevice *device,
- gboolean online,
- ModestMainWindow *main_window)
+_modest_ui_actions_on_connection_changed (TnyDevice *device, gboolean online,
+ ModestMainWindow *main_window)
{
GtkWidget *online_toggle;
ModestHeaderView *header_view;
g_return_if_fail (main_window);
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
+ widget_factory = modest_runtime_get_widget_factory ();
header_view = modest_widget_factory_get_header_view (widget_factory);
online_toggle = modest_widget_factory_get_online_toggle (widget_factory);
statusbar_push (widget_factory, 0,
online ? _("Modest went online") : _("Modest went offline"));
- g_object_unref (G_OBJECT (widget_factory));
-
+
/* If Modest has became online and the header view has a
header selected then show it */
if (online) {
{
gboolean online;
TnyDevice *device;
- TnyPlatformFactory *factory;
- TnyAccountStore *account_store;
- /* Get device. Do not ask the platform factory for it, because
- it returns always a new one */
- factory = modest_tny_platform_factory_get_instance ();
- account_store = tny_platform_factory_new_account_store (factory);
- device = tny_account_store_get_device (account_store);
+ device = tny_account_store_get_device
+ (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()));
online = gtk_toggle_button_get_active (toggle);
ModestMainWindow *main_window)
{
GtkWidget *progress_bar;
- ModestWidgetFactory *widget_factory;
char* txt;
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- progress_bar = modest_widget_factory_get_progress_bar (widget_factory);
-
+ progress_bar = modest_widget_factory_get_progress_bar
+ (modest_runtime_get_widget_factory());
if (total != 0)
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress_bar),
(gdouble)num/(gdouble)total);
gtk_progress_bar_set_text (GTK_PROGRESS_BAR(progress_bar), txt);
g_free (txt);
- statusbar_push (widget_factory, 0, msg);
-
- /* Free */
- g_object_unref (G_OBJECT (widget_factory));
+ statusbar_push (modest_runtime_get_widget_factory(), 0, msg);
}
const gchar* link,
ModestMainWindow *main_window)
{
- ModestWidgetFactory *widget_factory;
-
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- statusbar_push (widget_factory, 0, link);
- g_object_unref (G_OBJECT (widget_factory));
+ statusbar_push (modest_runtime_get_widget_factory(), 0, link);
/* TODO: do something */
}
ModestMainWindow *main_window)
{
gchar *msg;
- ModestWidgetFactory *widget_factory;
msg = g_strdup_printf (_("Opening %s..."), link);
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- statusbar_push (widget_factory, 0, msg);
-
- g_object_unref (G_OBJECT (widget_factory));
-
+ statusbar_push (modest_runtime_get_widget_factory(), 0, msg);
g_free (msg);
/* TODO: do something */
ModestMainWindow *main_window)
{
gchar *msg;
- ModestWidgetFactory *widget_factory;
msg = g_strdup_printf (_("Opening attachment %d..."), index);
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- statusbar_push (widget_factory, 0, msg);
+ statusbar_push (modest_runtime_get_widget_factory(), 0, msg);
g_free (msg);
- g_object_unref (G_OBJECT (widget_factory));
/* TODO: do something */
}
{
TnyList *accounts;
TnyIterator *iter;
- TnyAccountStore *account_store;
-
+
accounts = TNY_LIST(tny_simple_list_new ());
- account_store = modest_window_get_account_store (MODEST_WINDOW (edit_window));
- tny_account_store_get_accounts (account_store, accounts,
+ tny_account_store_get_accounts (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()),
+ accounts,
TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
- g_object_unref (G_OBJECT (account_store));
iter = tny_list_create_iterator(accounts);
tny_iterator_first (iter);
{
TnyFolder *parent_folder;
ModestFolderView *folder_view;
- ModestWidgetFactory *widget_factory;
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- folder_view = modest_widget_factory_get_folder_view (widget_factory);
+ folder_view = modest_widget_factory_get_folder_view
+ (modest_runtime_get_widget_factory());
parent_folder = modest_folder_view_get_selected (folder_view);
-
+
if (parent_folder) {
gchar *folder_name;
}
g_object_unref (parent_folder);
}
- g_object_unref (G_OBJECT (widget_factory));
}
void
{
TnyFolder *folder;
ModestFolderView *folder_view;
- ModestWidgetFactory *widget_factory;
-
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- folder_view = modest_widget_factory_get_folder_view (widget_factory);
+
+ folder_view = modest_widget_factory_get_folder_view (modest_runtime_get_widget_factory());
folder = modest_folder_view_get_selected (folder_view);
if (folder) {
}
g_object_unref (folder);
}
- g_object_unref (G_OBJECT (widget_factory));
}
static void
{
TnyFolder *folder;
ModestFolderView *folder_view;
- ModestWidgetFactory *widget_factory;
ModestMailOperation *mail_op;
-
- widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window));
- folder_view = modest_widget_factory_get_folder_view (widget_factory);
+
+ folder_view = modest_widget_factory_get_folder_view (modest_runtime_get_widget_factory());
folder = modest_folder_view_get_selected (folder_view);
mail_op = modest_mail_operation_new ();
*
* Returns: a new ModestUI, or NULL in case of error
*/
-ModestUI* modest_ui_new (TnyAccountStore *account_store);
+ModestUI* modest_ui_new (void);
/**
#include <modest-account-mgr.h>
#include <modest-account-mgr-helpers.h>
+#include <modest-runtime.h>
#include "modest-mail-operation.h"
#include "widgets/modest-header-view-priv.h"
};
typedef struct _ModestWidgetFactoryPrivate ModestWidgetFactoryPrivate;
-struct _ModestWidgetFactoryPrivate {
-
- TnyPlatformFactory *fact;
- TnyAccountStore *account_store;
+struct _ModestWidgetFactoryPrivate {
+
+ ModestTnyAccountStore *account_store;
ModestHeaderView *header_view;
ModestFolderView *folder_view;
{
ModestWidgetFactoryPrivate *priv;
priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(obj);
-
- priv->fact = modest_tny_platform_factory_get_instance ();
- priv->account_store = tny_platform_factory_new_account_store (priv->fact);
+
+ priv->account_store = NULL;
priv->progress_bar = gtk_progress_bar_new ();
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(priv->progress_bar),
static void
modest_widget_factory_finalize (GObject *obj)
{
- ModestWidgetFactoryPrivate *priv;
- priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(obj);
-
+ /* no need to unref account_store; we don't own the reference */
+
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
/* folder view */
query = tny_folder_store_query_new ();
tny_folder_store_query_add_item (query, NULL, TNY_FOLDER_STORE_QUERY_OPTION_SUBSCRIBED);
- if (!(priv->folder_view =
- MODEST_FOLDER_VIEW(modest_folder_view_new (MODEST_TNY_ACCOUNT_STORE (priv->account_store),
- query)))) {
+
+ priv->folder_view = MODEST_FOLDER_VIEW(modest_folder_view_new (priv->account_store,query));
+ if (!priv->folder_view) {
g_printerr ("modest: cannot instantiate folder view\n");
return FALSE;
- }
+ }
g_object_unref (G_OBJECT (query));
-
+
/* header view */
- if (!(priv->header_view =
- MODEST_HEADER_VIEW(modest_header_view_new (NULL,MODEST_HEADER_VIEW_STYLE_DETAILS)))) {
+ priv->header_view =
+ MODEST_HEADER_VIEW(modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS));
+ if (!priv->header_view) {
g_printerr ("modest: cannot instantiate header view\n");
return FALSE;
}
/* msg preview */
- if (!(priv->msg_preview = MODEST_MSG_VIEW(modest_msg_view_new (NULL)))) {
+ priv->msg_preview = MODEST_MSG_VIEW(modest_msg_view_new (NULL));
+ if (!priv->msg_preview) {
g_printerr ("modest: cannot instantiate header view\n");
return FALSE;
}
-
-
/* online/offline combo */
priv->online_toggle = gtk_toggle_button_new ();
the current folder */
priv->folder_info_label = gtk_label_new (NULL);
-/* init_signals (self); */
-
return TRUE;
}
ModestWidgetFactory*
-modest_widget_factory_new (void)
+modest_widget_factory_new (ModestTnyAccountStore *account_store)
{
GObject *obj;
ModestWidgetFactoryPrivate *priv;
+ g_return_val_if_fail (account_store, NULL);
+
obj = g_object_new (MODEST_TYPE_WIDGET_FACTORY, NULL);
priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(obj);
+ priv->account_store = account_store;
+
if (!init_widgets (MODEST_WIDGET_FACTORY(obj))) {
g_printerr ("modest: widget factory failed to init widgets\n");
g_object_unref (obj);
ModestAccountView*
modest_widget_factory_get_account_view (ModestWidgetFactory *self)
{
- ModestWidgetFactoryPrivate *priv;
- ModestAccountMgr *account_mgr;
-
- g_return_val_if_fail (self, NULL);
- priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(self);
-
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->fact));
- return modest_account_view_new (account_mgr);
+ return modest_account_view_new (modest_runtime_get_account_mgr());
}
priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(self);
- account_mgr =
- modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->fact));
+ account_mgr = modest_runtime_get_account_mgr();
cursor = accounts = modest_account_mgr_account_names (account_mgr, NULL);
while (cursor) {
ModestAccountData *data;
struct _ModestWidgetFactory {
GObject parent;
- /* insert public members, if any */
};
struct _ModestWidgetFactoryClass {
GObjectClass parent_class;
- /* insert signal callback declarations, eg. */
- /* void (* my_event) (ModestWidgetFactory* obj); */
};
/**
* modest_widget_factory_new
- *
+ * @account_store: a valid ModestTnyAccountStore instance
+ *
* instantiates a ModestWidgetFactory
*
* Returns: a new ModestWidgetFactory, or NULL in case of error
*/
-ModestWidgetFactory* modest_widget_factory_new (void);
+ModestWidgetFactory* modest_widget_factory_new (ModestTnyAccountStore *account_store);
+
+
/**
* modest_widget_factory_get_folder_view
* @self: a ModestWidgetFactory instance
*
* Returns: a header tree view, or NULL in case of error
*/
-ModestMsgView* modest_widget_factory_get_msg_preview (ModestWidgetFactory *self);
+ModestMsgView* modest_widget_factory_get_msg_preview (ModestWidgetFactory *self);
/**
#define __MODEST_EDIT_MSG_WINDOW_H__
#include <tny-msg.h>
-#include "modest-window.h"
-#include "modest-widget-factory.h"
+#include <modest-window.h>
G_BEGIN_DECLS
/* void (* my_event) (ModestEditMsgWindow* obj); */
};
-
-typedef enum _ModestEditType {
+typedef enum {
MODEST_EDIT_TYPE_NEW,
MODEST_EDIT_TYPE_REPLY,
MODEST_EDIT_TYPE_FORWARD,
typedef struct _MsgData {
gchar *from, *to, *cc, *bcc, *subject, *body;
} MsgData;
-/* typedef enum _ModestEditType ModestEditType; */
-/* member functions */
+/**
+ * modest_edit_msg_window_get_type:
+ *
+ * get the GType for the #ModestEditMsgWindow class
+ *
+ * Returns: a GType for #ModestEditMsgWindow
+ */
GType modest_edit_msg_window_get_type (void) G_GNUC_CONST;
-ModestWindow* modest_edit_msg_window_new (ModestWidgetFactory *factory,
- TnyAccountStore *account_store,
- ModestEditType type);
+
+/**
+ * modest_edit_msg_window_new:
+ *
+ * instantiates a new #ModestEditMsgWindow widget
+ *
+ * Returns: a new #ModestEditMsgWindow, or NULL in case of error
+ */
+ModestWindow* modest_edit_msg_window_new (ModestEditType type);
+
/**
* modest_edit_msg_window_set_msg:
/**
* modest_edit_msg_window_get_msg_data:
- * @edit_window: a #ModestEditMsgWindow
+ * @self: a #ModestEditMsgWindow
*
* gets the message data already present in the edit message
* window. The message data must be freed with
*
* Returns: the message data
**/
-MsgData * modest_edit_msg_window_get_msg_data (ModestEditMsgWindow *edit_window);
+MsgData * modest_edit_msg_window_get_msg_data (ModestEditMsgWindow *self);
/**
* modest_edit_msg_window_free_msg_data:
- * @edit_window: a #ModestEditMsgWindow
+ * @self: a #ModestEditMsgWindow
* @data:
*
* frees the message data passed as argument
**/
-void modest_edit_msg_window_free_msg_data (ModestEditMsgWindow *edit_window,
+void modest_edit_msg_window_free_msg_data (ModestEditMsgWindow *self,
MsgData *data);
-
G_END_DECLS
#endif /* __MODEST_EDIT_MSG_WINDOW_H__ */
ModestWindowClass parent_class;
};
-/* member functions */
-GType modest_main_window_get_type (void) G_GNUC_CONST;
-
-
-ModestWindow* modest_main_window_new (ModestWidgetFactory *factory,
- TnyAccountStore *account_store);
-
/**
- * modest_main_window_get_widget_factory:
- * @edit_window: a #ModestMainWindow
- *
- * gets a new reference to the #ModestWidgetFactory associated with
- * the main window
+ * modest_main_window_get_type:
*
- * Returns: the widget factory
- **/
-ModestWidgetFactory * modest_main_window_get_widget_factory (ModestMainWindow *main_window);
+ * get the GType for the ModestMainWindow class
+ *
+ * Returns: a GType for ModestMainWindow
+ */
+GType modest_main_window_get_type (void) G_GNUC_CONST;
+
/**
- * modest_main_window_get_account_store:
- * @edit_window: a #ModestMainWindow
+ * modest_main_window_new
*
- * gets a new reference to the account store associated with the main
- * window
- *
- * Returns: the account store
- **/
-TnyAccountStore * modest_main_window_get_account_store (ModestMainWindow *main_window);
+ * instantiates a new ModestMainWindow widget
+ *
+ * Returns: a new ModestMainWindow, or NULL in case of error
+ */
+ModestWindow* modest_main_window_new (void);
G_END_DECLS
typedef struct _ModestWindowPrivate ModestWindowPrivate;
struct _ModestWindowPrivate {
-
- ModestWidgetFactory *widget_factory;
- TnyPlatformFactory *plat_factory;
-
- TnyAccountStore *account_store;
GtkUIManager *ui_manager;
-
GtkWidget *toolbar;
GtkWidget *menubar;
};
priv = MODEST_WINDOW_GET_PRIVATE(obj);
- priv->plat_factory = modest_tny_platform_factory_get_instance ();
priv->ui_manager = NULL;
- priv->account_store = NULL;
-
priv->toolbar = NULL;
priv->menubar = NULL;
}
g_object_unref (G_OBJECT(priv->ui_manager));
priv->ui_manager = NULL;
}
- if (priv->account_store) {
- g_object_unref (G_OBJECT(priv->account_store));
- priv->account_store = NULL;
- }
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
-
-TnyAccountStore *
-modest_window_get_account_store (ModestWindow *window)
-{
- ModestWindowPrivate *priv;
-
- g_return_val_if_fail (MODEST_IS_WINDOW (window), NULL);
-
- priv = MODEST_WINDOW_GET_PRIVATE (window);
-
- return g_object_ref (priv->account_store);
-}
-
-ModestWidgetFactory *
-modest_window_get_widget_factory (ModestWindow *window)
-{
- ModestWindowPrivate *priv;
-
- g_return_val_if_fail (MODEST_IS_WINDOW (window), NULL);
-
- priv = MODEST_WINDOW_GET_PRIVATE (window);
-
- return g_object_ref (priv->widget_factory);
-}
/* member functions */
GType modest_window_get_type (void) G_GNUC_CONST;
-/**
- * modest_window_get_account_store:
- * @window: a #ModestWindow
- *
- * gets a new reference to the account store associated with the main
- * window. The caller must free the returned instance
- *
- * Returns: the account store
- **/
-TnyAccountStore* modest_window_get_account_store (ModestWindow *window);
-
-/**
- * modest_window_get_widget_factory:
- * @window: a #ModestWindow
- *
- * gets a reference to the #ModestWidgetFactory associated with the
- * Modest Window. The caller must free the returned instance
- *
- * Returns: the widget factory
- **/
-ModestWidgetFactory* modest_window_get_widget_factory (ModestWindow *window);
-
-
G_END_DECLS
#endif /* __MODEST_WINDOW_H__ */