#
# Makefile.am
-# Time-stamp: <2007-01-15 10:49:27 (djcb)>
+# Time-stamp: <2007-01-16 23:49:28 (djcb)>
SUBDIRS=$(MODEST_PLATFORM) widgets
DIST_SUBDIRS = widgets gtk maemo
modest-formatter.h \
modest-icon-factory.c\
modest-icon-factory.h\
+ modest-init.h\
+ modest-init.c\
modest-mail-operation-queue.c \
modest-mail-operation-queue.h \
modest-mail-operation.c \
modest-widget-factory.c \
modest-widget-factory.h \
modest-widget-memory.c\
- modest-widget-memory.h
+ modest-widget-memory.h \
+ modest-widget-memory-priv.h
modest_LDADD = \
$(MODEST_GSTUFF_LIBS) \
--- /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 <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-init.h>
+
+typedef struct {
+ ModestHeaderViewColumn col;
+ guint width;
+} FolderCols;
+
+
+#if MODEST_PLATFORM_ID==1 /*gtk*/
+static const FolderCols INBOX_COLUMNS[] = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 20},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 20},
+ {MODEST_HEADER_VIEW_COLUMN_FROM, 50},
+ {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 50},
+ {MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE, 50},
+ {MODEST_HEADER_VIEW_COLUMN_SIZE, 30},
+};
+
+static const FolderCols OUTBOX_COLUMNS[] = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 20},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 20},
+ {MODEST_HEADER_VIEW_COLUMN_TO, 50},
+ {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 50},
+ {MODEST_HEADER_VIEW_COLUMN_SENT_DATE, 50},
+ {MODEST_HEADER_VIEW_COLUMN_SIZE, 30},
+};
+#elif MODEST_PLATFORM==2 /*maemo*/
+static const FolderCols INBOX_COLUMNS = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 20},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 20},
+ {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN,150},
+};
+static const FolderCols OUTBOX_COLUMNS = {
+ {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 20},
+ {MODEST_HEADER_VIEW_COLUMN_ATTACH, 20},
+ {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,150},
+};
+#endif /*MODEST_PLATFORM*/
+
+
+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;
+}
+
+
+/* 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, 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_type ("header-view",
+ type,
+ 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, OUTBOX_COLUMNS,
+ G_N_ELEMENTS(OUTBOX_COLUMNS),
+ overwrite);
+ break;
+ default:
+ save_header_settings (conf, folder_type, INBOX_COLUMNS,
+ G_N_ELEMENTS(INBOX_COLUMNS),
+ overwrite);
+ };
+ }
+ return TRUE;
+}
+
+gboolean
+modest_init_local_folders (void)
+{
+ return TRUE;
+}
--- /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);
+
+G_END_DECLS
+
+#endif /*__MODEST_INIT_H__*/
GError *err = NULL;
int retval = MODEST_ERR_NONE;
- static gboolean batch=FALSE;
+ static gboolean batch=FALSE, factory_settings=FALSE;
static gchar *mailto, *subject, *bcc, *cc, *body, *account;
static GOptionEntry options[] = {
N_("Account to use (if specified, default account is used)"), NULL},
{ "batch", 'y', 0, G_OPTION_ARG_NONE, &batch,
N_("Run in batch mode (don't show UI)"), NULL},
+ { "factory-settings", 0, 0, G_OPTION_ARG_NONE, &factory_settings,
+ N_("return to factory settings"), NULL},
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
retval = MODEST_ERR_CONF;
goto cleanup;
}
-
+
/* Get the account store */
account_store = tny_platform_factory_new_account_store (fact);
if (!account_store) {
retval = MODEST_ERR_RUN;
goto cleanup;
}
+
if (!getenv("DISPLAY"))
batch = TRUE;
if (!batch) {
gdk_threads_init ();
gtk_init (&argc, &argv);
+ modest_init_header_columns (factory_settings);
+
retval = start_ui (mailto, cc, bcc, subject, body, account_store);
} else
retval = send_mail (mailto, cc, bcc, subject, body);
--- /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_WIDGET_MEMORY_PRIV_H__
+#define __MODEST_WIDGET_MEMORY_PRIV_H__
+
+G_BEGIN_DECLS
+
+
+#define MODEST_WIDGET_MEMORY_PARAM_X "x"
+#define MODEST_WIDGET_MEMORY_PARAM_Y "y"
+#define MODEST_WIDGET_MEMORY_PARAM_HEIGHT "height"
+#define MODEST_WIDGET_MEMORY_PARAM_WIDTH "width"
+#define MODEST_WIDGET_MEMORY_PARAM_POS "pos"
+#define MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH "column-width"
+
+/* private functions, only for use in modest-widget-memory and modest-init */
+gchar* _modest_widget_memory_get_keyname (const gchar *name, const gchar *param);
+gchar* _modest_widget_memory_get_keyname_with_type (const gchar *name, guint type,
+ const gchar *param);
+
+G_END_DECLS
+
+#endif /*__MODEST_WIDGET_MEMORY_PRIV_H__*/
+
+
+
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "modest-widget-memory.h"
+#include <modest-widget-memory.h>
+#include <modest-widget-memory-priv.h>
#include <modest-tny-platform-factory.h>
#include <modest-tny-folder.h>
#include <widgets/modest-header-view.h>
#include <widgets/modest-msg-view.h>
#include <widgets/modest-folder-view.h>
-
#include <string.h>
-#define PARAM_X "x"
-#define PARAM_Y "y"
-#define PARAM_HEIGHT "height"
-#define PARAM_WIDTH "width"
-#define PARAM_POS "pos"
-#define PARAM_COLUMN_WIDTH "column-width"
-
-static gchar*
-get_keyname (ModestConf *conf, const gchar *name, const gchar *param)
+gchar*
+_modest_widget_memory_get_keyname (const gchar *name, const gchar *param)
{
gchar *esc_name, *keyname;
+
+ g_return_val_if_fail (name, NULL);
+ g_return_val_if_fail (param, NULL);
+
esc_name = modest_conf_key_escape (name);
keyname = g_strdup_printf ("%s/%s/%s",
}
-static gchar*
-get_keyname_with_type (ModestConf *conf, const gchar *name, guint type, const gchar *param)
+gchar*
+_modest_widget_memory_get_keyname_with_type (const gchar *name, guint type,
+ const gchar *param)
{
gchar *esc_name, *keyname;
+
+ g_return_val_if_fail (name, NULL);
+ g_return_val_if_fail (param, NULL);
+
esc_name = modest_conf_key_escape (name);
keyname = g_strdup_printf ("%s/%s/%s_%d",
{
gchar *key;
- key = get_keyname (conf, name, PARAM_HEIGHT);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_HEIGHT);
modest_conf_set_int (conf, key, GTK_WIDGET(widget)->allocation.height, NULL);
g_free (key);
- key = get_keyname (conf, name, PARAM_WIDTH);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_WIDTH);
modest_conf_set_int (conf, key, GTK_WIDGET(widget)->allocation.width, NULL);
g_free (key);
GtkRequisition req;
gchar *key;
- key = get_keyname (conf, name, PARAM_HEIGHT);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_HEIGHT);
if (modest_conf_key_exists (conf, key, NULL))
req.height = modest_conf_get_int (conf, key, NULL);
g_free (key);
- key = get_keyname (conf, name, PARAM_WIDTH);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_WIDTH);
if (modest_conf_key_exists (conf, key, NULL))
req.width = modest_conf_get_int (conf, key, NULL);
g_free (key);
gtk_window_get_size (win, &width, &height);
- key = get_keyname (conf, name, PARAM_HEIGHT);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_HEIGHT);
modest_conf_set_int (conf, key, height, NULL);
g_free (key);
- key = get_keyname (conf, name, PARAM_WIDTH);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_WIDTH);
modest_conf_set_int (conf, key, width, NULL);
g_free (key);
gchar *key;
int height = 0, width = 0;
- key = get_keyname (conf, name, PARAM_HEIGHT);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_HEIGHT);
if (modest_conf_key_exists (conf, key, NULL))
height = modest_conf_get_int (conf, key, NULL);
g_free (key);
- key = get_keyname (conf, name, PARAM_WIDTH);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_WIDTH);
if (modest_conf_key_exists (conf, key, NULL))
width = modest_conf_get_int (conf, key, NULL);
pos = gtk_paned_get_position (paned);
- key = get_keyname (conf, name, PARAM_POS);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS);
modest_conf_set_int (conf, key, pos, NULL);
g_free (key);
gchar *key;
int pos;
- key = get_keyname (conf, name, PARAM_POS);
+ key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS);
if (modest_conf_key_exists (conf, key, NULL)) {
pos = modest_conf_get_int (conf, key, NULL);
return TRUE; /* no folder: no settings */
type = modest_tny_folder_guess_folder_type (folder);
- key = get_keyname_with_type (conf, name, type, PARAM_COLUMN_WIDTH);
+ key = _modest_widget_memory_get_keyname_with_type (name, type,
+ MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
cursor = cols = modest_header_view_get_columns (header_view);
str = g_string_new (NULL);
-
+
+ /* NOTE: the exact details of this format are important, as they
+ * are also used in modest-init.
+ */
while (cursor) {
int col_id, width;
type = modest_tny_folder_guess_folder_type (folder);
- key = get_keyname_with_type (conf, name, type, PARAM_COLUMN_WIDTH);
+ key = _modest_widget_memory_get_keyname_with_type (name, type,
+ MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
if (modest_conf_key_exists (conf, key, NULL)) {
gchar *data, *cursor;
*/
gboolean modest_widget_memory_restore (ModestConf *conf, GObject *widget, const gchar *name);
-
G_END_DECLS
#endif /*__MODEST_WIDGET_MEMORY_H__*/