1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <glib-object.h>
33 #include <glib/gstdio.h>
34 #include <modest-runtime.h>
35 #include <modest-runtime-priv.h>
36 #include <modest-init.h>
37 #include <modest-defs.h>
38 #include <modest-singletons.h>
39 #include <widgets/modest-header-view.h>
40 #include <widgets/modest-folder-view.h>
41 #include <modest-tny-platform-factory.h>
42 #include <modest-platform.h>
43 #include <modest-widget-memory.h>
44 #include <modest-widget-memory-priv.h>
45 #include <modest-local-folder-info.h>
46 #include <modest-account-mgr.h>
47 #include <modest-account-mgr-helpers.h>
48 #include <modest-icon-names.h>
49 #include "widgets/modest-global-settings-dialog.h"
50 #include "modest-tny-msg.h"
51 #ifdef MODEST_PLATFORM_MAEMO
52 #include "modest-hildon-includes.h"
56 static gboolean init_header_columns (ModestConf *conf, gboolean overwrite);
57 static gboolean init_default_account_maybe (ModestAccountMgr *acc_mgr);
58 static void init_i18n (void);
59 static void init_stock_icons (void);
60 static void init_debug_g_type (void);
61 static void init_debug_logging (void);
62 static void init_default_settings (ModestConf *conf);
63 static void init_device_name (ModestConf *conf);
64 static gboolean init_ui (gint argc, gchar** argv);
67 static gboolean _is_initialized = FALSE;
70 * defaults for the column headers
73 ModestHeaderViewColumn col;
79 static const guint MODEST_MAIN_PANED_POS_PERCENTAGE = 30;
81 static const FolderCols INBOX_COLUMNS_DETAILS[] = {
82 {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40, 0},
83 {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40, 0},
84 {MODEST_HEADER_VIEW_COLUMN_FROM, 80, 0},
85 {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80, 0},
86 {MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE, 60, 0},
87 {MODEST_HEADER_VIEW_COLUMN_SIZE, 50, 0}
90 static const FolderCols INBOX_COLUMNS_TWOLINES[] = {
91 {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN, 180, 0},
94 static const FolderCols OUTBOX_COLUMNS_DETAILS[] = {
95 {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40, 0},
96 {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40, 0},
97 {MODEST_HEADER_VIEW_COLUMN_TO, 80, 0},
98 {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80, 0},
99 {MODEST_HEADER_VIEW_COLUMN_SENT_DATE, 80, 0},
100 {MODEST_HEADER_VIEW_COLUMN_SIZE, 50, 0}
103 static const FolderCols OUTBOX_COLUMNS_TWOLINES[] = {
104 {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,180, 0}
105 // {MODEST_HEADER_VIEW_COLUMN_STATUS, 240, 0}
108 static const FolderCols SENT_COLUMNS_TWOLINES[] = {
109 {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,180, 0},
112 #ifdef MODEST_PLATFORM_MAEMO
113 static const TnyFolderType LOCAL_FOLDERS[] = {
114 /* TNY_FOLDER_TYPE_OUTBOX, */
115 TNY_FOLDER_TYPE_DRAFTS,
119 static const TnyFolderType LOCAL_FOLDERS[] = {
120 /* TNY_FOLDER_TYPE_OUTBOX, */
121 TNY_FOLDER_TYPE_DRAFTS,
122 TNY_FOLDER_TYPE_SENT,
123 TNY_FOLDER_TYPE_TRASH,
124 TNY_FOLDER_TYPE_ARCHIVE
126 #endif /* MODEST_PLATFORM_MAEMO */
129 new_cold_ids_gslist_from_array( const FolderCols* cols, guint col_num)
131 GList *result = NULL;
134 for (i = 0; i < col_num; ++i) {
135 result = g_list_append (result, GINT_TO_POINTER (cols[i].col));
142 modest_init_get_default_header_view_column_ids (TnyFolderType folder_type, ModestHeaderViewStyle style)
144 GList *result = NULL;
146 switch (folder_type) {
147 case TNY_FOLDER_TYPE_SENT:
148 case TNY_FOLDER_TYPE_DRAFTS:
149 if (style == MODEST_HEADER_VIEW_STYLE_DETAILS)
150 result = new_cold_ids_gslist_from_array (OUTBOX_COLUMNS_DETAILS,
151 G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS));
152 else if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES)
153 result = new_cold_ids_gslist_from_array (SENT_COLUMNS_TWOLINES,
154 G_N_ELEMENTS(SENT_COLUMNS_TWOLINES));
156 case TNY_FOLDER_TYPE_OUTBOX:
157 if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES)
158 result = new_cold_ids_gslist_from_array (OUTBOX_COLUMNS_TWOLINES,
159 G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES));
163 if (style == MODEST_HEADER_VIEW_STYLE_DETAILS)
164 result = new_cold_ids_gslist_from_array (INBOX_COLUMNS_DETAILS,
165 G_N_ELEMENTS(INBOX_COLUMNS_DETAILS));
166 else if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES)
167 result = new_cold_ids_gslist_from_array (INBOX_COLUMNS_TWOLINES,
168 G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES));
172 g_warning("DEBUG: %s: No default columns IDs found for "
173 "folder_type=%d, style=%d\n", __FUNCTION__, folder_type, style);
181 modest_init (int argc, char *argv[])
185 if (_is_initialized) {
186 g_printerr ("modest: modest_init_init_core may only be invoked once\n");
192 init_debug_logging();
194 /* initialize the prng, we need it when creating random files */
195 srandom((int)getpid());
197 if (!gnome_vfs_initialized()) {
198 if (!gnome_vfs_init ()) {
199 g_printerr ("modest: failed to init gnome-vfs\n");
204 if (!modest_runtime_init()) {
205 modest_init_uninit ();
206 g_printerr ("modest: failed to initialize the modest runtime\n");
210 /* do an initial guess for the device name */
211 init_device_name (modest_runtime_get_conf());
213 if (!modest_platform_init(argc, argv)) {
214 modest_init_uninit ();
215 g_printerr ("modest: failed to run platform-specific initialization\n");
219 reset = modest_runtime_get_debug_flags () & MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS;
220 if (!init_header_columns(modest_runtime_get_conf(), reset)) {
221 modest_init_uninit ();
222 g_printerr ("modest: failed to init header columns\n");
226 init_default_settings (modest_runtime_get_conf ());
228 if (!modest_init_local_folders(NULL)) {
229 modest_init_uninit ();
230 g_printerr ("modest: failed to init local folders\n");
234 if (!init_default_account_maybe (modest_runtime_get_account_mgr ())) {
235 modest_init_uninit ();
236 g_printerr ("modest: failed to init default account\n");
240 if (!init_ui (argc, argv)) {
241 modest_init_uninit ();
242 g_printerr ("modest: failed to init ui\n");
246 return _is_initialized = TRUE;
251 init_ui (gint argc, gchar** argv)
253 /* Set application name */
254 g_set_application_name (modest_platform_get_app_name());
255 /* g_message (modest_platform_get_app_name()); */
257 /* Init stock icons */
260 /* Init notification system */
261 #ifdef MODEST_HAVE_HILDON_NOTIFY
262 notify_init ("Basics");
269 modest_init_uninit (void)
271 if (!_is_initialized)
274 if (gnome_vfs_initialized()) /* apparently, this returns TRUE, even after a shutdown */
275 gnome_vfs_shutdown ();
277 if (!modest_runtime_uninit())
278 g_printerr ("modest: failed to uninit runtime\n");
280 _is_initialized = FALSE;
287 /* NOTE: the exact details of this format are important, as they
288 * are also used in modest-widget-memory. FIXME: make a shared function
289 * for this with widget-memory
292 save_header_settings (ModestConf *conf, TnyFolderType type,
293 ModestHeaderViewStyle style, const FolderCols* cols,
294 guint col_num, gboolean overwrite)
302 g_return_val_if_fail (cols, FALSE);
304 key = _modest_widget_memory_get_keyname_with_double_type ("header-view",
306 MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
307 sort_key = _modest_widget_memory_get_keyname_with_double_type ("header-view",
309 MODEST_WIDGET_MEMORY_PARAM_COLUMN_SORT);
310 /* if we're not in overwrite mode, only write stuff it
311 * there was nothing before */
312 if (!overwrite && modest_conf_key_exists(conf, key, NULL)) {
318 /* the format is necessarily the same as the one in modest-widget-memory */
319 str = g_string_new (NULL);
320 for (i = 0; i != col_num; ++i)
321 g_string_append_printf (str, "%d:%d:%d ",
322 cols[i].col, cols[i].width, cols[i].sort);
324 modest_conf_set_string (conf, key, str->str, NULL);
326 g_string_free (str, TRUE);
330 if (cols[0].col == MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT)
331 sort_col_id = TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN;
333 sort_col_id = TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN;
334 sort_value = g_strdup_printf("%d:%d:%d", sort_col_id, GTK_SORT_DESCENDING, 0);
335 modest_conf_set_string (conf, sort_key, sort_value, NULL);
344 * modest_init_header_columns:
345 * @overwrite: write the setting, even if it already exists
347 * will set defaults for the columns to show for folder,
348 * if there are no such settings yet (in ModestWidgetMemory)
350 * Returns: TRUE if succeeded, FALSE in case of error
353 init_header_columns (ModestConf *conf, gboolean overwrite)
358 for (folder_type = TNY_FOLDER_TYPE_UNKNOWN;
359 folder_type <= TNY_FOLDER_TYPE_CALENDAR; ++folder_type) {
361 switch (folder_type) {
362 case TNY_FOLDER_TYPE_SENT:
363 case TNY_FOLDER_TYPE_DRAFTS:
364 save_header_settings (conf, folder_type,
365 MODEST_HEADER_VIEW_STYLE_DETAILS,
366 OUTBOX_COLUMNS_DETAILS,
367 G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS),
369 save_header_settings (conf, folder_type,
370 MODEST_HEADER_VIEW_STYLE_TWOLINES,
371 SENT_COLUMNS_TWOLINES,
372 G_N_ELEMENTS(SENT_COLUMNS_TWOLINES),
375 case TNY_FOLDER_TYPE_OUTBOX:
376 save_header_settings (conf, folder_type,
377 MODEST_HEADER_VIEW_STYLE_TWOLINES,
378 OUTBOX_COLUMNS_TWOLINES,
379 G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES),
384 save_header_settings (conf, folder_type,
385 MODEST_HEADER_VIEW_STYLE_DETAILS,
386 INBOX_COLUMNS_DETAILS,
387 G_N_ELEMENTS(INBOX_COLUMNS_DETAILS),
389 save_header_settings (conf, folder_type,
390 MODEST_HEADER_VIEW_STYLE_TWOLINES,
391 INBOX_COLUMNS_TWOLINES,
392 G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES),
397 key = _modest_widget_memory_get_keyname (MODEST_CONF_MAIN_PANED_KEY,
398 MODEST_WIDGET_MEMORY_PARAM_POS);
399 /* if we're not in overwrite mode, only write stuff it
400 * there was nothing before */
401 if (overwrite || !modest_conf_key_exists(conf, key, NULL))
402 modest_conf_set_int (conf, key, MODEST_MAIN_PANED_POS_PERCENTAGE, NULL);
408 gboolean modest_init_one_local_folder (gchar *maildir_path)
410 static const gchar* maildirs[] = {
415 for (j = 0; j != G_N_ELEMENTS(maildirs); ++j) {
416 gchar *dir = g_build_filename (maildir_path,
419 if (g_mkdir_with_parents (dir, 0755) < 0) {
420 g_printerr ("modest: %s: failed to create %s\n", __FUNCTION__, dir);
432 * modest_init_local_folders:
434 * create the Local Folders folder under cache, if they
437 * Returns: TRUE if the folder were already there, or
438 * they were created, FALSE otherwise
441 modest_init_local_folders (const gchar* location_filepath)
443 gboolean retval = TRUE;
445 gchar *maildir_path = modest_local_folder_info_get_maildir_path (location_filepath);
447 if (location_filepath) {
448 /* For instance, for memory card, just create the top-level .modest folder
449 * and one "archive" folder (so that messages can be put somewhere):
452 gchar *dir = g_build_filename (maildir_path,
453 modest_local_folder_info_get_type_name(TNY_FOLDER_TYPE_ARCHIVE),
455 const gboolean created = modest_init_one_local_folder (dir);
463 /* Do this if we only create the top-level dir: */
464 if (g_mkdir_with_parents (maildir_path, 0755) < 0) {
465 g_printerr ("modest: %s: failed to create %s\n", __FUNCTION__, location_filepath);
471 /* Create each of the standard on-disk folders.
472 * Per-account outbox folders will be created when first needed. */
474 for (i = 0; i != G_N_ELEMENTS(LOCAL_FOLDERS); ++i) {
475 gchar *dir = g_build_filename (maildir_path,
476 modest_local_folder_info_get_type_name(LOCAL_FOLDERS[i]),
478 const gboolean created = modest_init_one_local_folder (dir);
487 g_free (maildir_path);
492 * init_default_account_maybe:
494 * if there are accounts defined, but there is no default account,
495 * it will be defined.
497 * Returns: TRUE if there was a default account already,
498 * or one has been created or there are no accounts yet,
499 * returns FALSE in case of error
502 init_default_account_maybe (ModestAccountMgr *acc_mgr)
504 gchar *default_account;
505 gboolean retval = TRUE;
507 default_account = modest_account_mgr_get_default_account (acc_mgr);
508 if (!default_account)
509 retval = modest_account_mgr_set_first_account_as_default (acc_mgr);
510 g_free (default_account);
518 init_debug_g_type (void)
520 GTypeDebugFlags gflags;
521 ModestRuntimeDebugFlags mflags;
524 mflags = modest_runtime_get_debug_flags ();
526 if (mflags & MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS)
527 gflags |= G_TYPE_DEBUG_OBJECTS;
528 if (mflags & MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS)
529 gflags |= G_TYPE_DEBUG_SIGNALS;
531 g_type_init_with_debug_flags (gflags);
535 init_debug_logging (void)
537 ModestRuntimeDebugFlags mflags;
538 mflags = modest_runtime_get_debug_flags ();
540 if (mflags & MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING)
541 g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
542 G_LOG_LEVEL_CRITICAL |
543 G_LOG_LEVEL_WARNING);
550 const gchar* gettext_package;
551 /* Setup gettext, to use our .po files: */
552 /* GETTEXT_PACKAGE and MODEST_LOCALE_DIR are defined in config.h */
553 /* #ifdef MODEST_HILDON_VERSION_0 */
554 /* gettext_package = GETTEXT_PACKAGE; */
555 /* bindtextdomain (gettext_package, MODEST_LOCALE_DIR); */
557 /* gettext_package = "osso-email"; /\* HACK to use the localizations *\/ */
558 /* bindtextdomain (gettext_package, "/usr/share/locale"); */
559 /* #endif /\*MODEST_HILDON_VERSION_0*\/ */
561 gettext_package = GETTEXT_PACKAGE;
563 bind_textdomain_codeset (gettext_package, "UTF-8");
564 textdomain (gettext_package);
566 setlocale (LC_ALL, "");
571 * This function registers our custom toolbar icons, so they can be
572 * themed. The idea of this function was taken from the gtk-demo
575 init_stock_icons (void)
577 static gboolean registered = FALSE;
580 GtkIconTheme *current_theme;
582 GtkIconFactory *factory;
585 static GtkStockItem items[] = {
586 #ifdef MODEST_PLATFORM_MAEMO
587 { MODEST_STOCK_SPLIT_VIEW, "split view", 0, 0, NULL },
588 { MODEST_STOCK_SORT, "sort mail", 0, 0, NULL },
589 { MODEST_STOCK_REFRESH, "refresh mail", 0, 0, NULL },
590 #endif /*MODEST_PLATFORM_MAEMO*/
591 { MODEST_STOCK_MAIL_SEND, "send mail", 0, 0, NULL },
592 { MODEST_STOCK_NEW_MAIL, "new mail", 0, 0, NULL },
593 /* { MODEST_STOCK_SEND_RECEIVE, "send receive", 0, 0, NULL }, */
594 { MODEST_STOCK_REPLY, "reply", 0, 0, NULL },
595 /* { MODEST_STOCK_REPLY_ALL, "reply all", 0, 0, NULL }, */
596 /* { MODEST_STOCK_FORWARD, "forward", 0, 0, NULL }, */
597 { MODEST_STOCK_DELETE, "delete", 0, 0, NULL },
598 /* { MODEST_STOCK_NEXT, "next", 0, 0, NULL }, */
599 /* { MODEST_STOCK_PREV, "prev", 0, 0, NULL }, */
600 /* { MODEST_STOCK_STOP, "stop", 0, 0, NULL } */
603 static gchar *items_names [] = {
604 #ifdef MODEST_PLATFORM_MAEMO
605 MODEST_TOOLBAR_ICON_SPLIT_VIEW,
606 MODEST_TOOLBAR_ICON_SORT,
607 MODEST_TOOLBAR_ICON_REFRESH,
608 #endif /*MODEST_PLATFORM_MAEMO*/
609 MODEST_TOOLBAR_ICON_MAIL_SEND,
610 MODEST_TOOLBAR_ICON_NEW_MAIL,
611 /* MODEST_TOOLBAR_ICON_SEND_RECEIVE, */
612 MODEST_TOOLBAR_ICON_REPLY,
613 /* MODEST_TOOLBAR_ICON_REPLY_ALL, */
614 /* MODEST_TOOLBAR_ICON_FORWARD, */
615 MODEST_TOOLBAR_ICON_DELETE,
616 /* MODEST_TOOLBAR_ICON_NEXT, */
617 /* MODEST_TOOLBAR_ICON_PREV, */
618 /* MODEST_TOOLBAR_ICON_STOP */
619 MODEST_TOOLBAR_ICON_FORMAT_BULLETS,
624 /* Register our stock items */
625 gtk_stock_add (items, G_N_ELEMENTS (items));
627 /* Add our custom icon factory to the list of defaults */
628 factory = gtk_icon_factory_new ();
629 gtk_icon_factory_add_default (factory);
631 current_theme = gtk_icon_theme_get_default ();
633 /* Register icons to accompany stock items */
634 for (i = 0; i < G_N_ELEMENTS (items); i++) {
636 #ifdef MODEST_PLATFORM_MAEMO /* MODES_PLATFORM_ID: 1 ==> gnome, 2==> maemo */
637 pixbuf = gtk_icon_theme_load_icon (current_theme,
640 GTK_ICON_LOOKUP_NO_SVG,
643 pixbuf = gdk_pixbuf_new_from_file (items_names[i], NULL);
646 if (pixbuf != NULL) {
647 GtkIconSet *icon_set;
648 GdkPixbuf *transparent;
650 transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
651 icon_set = gtk_icon_set_new_from_pixbuf (transparent);
652 gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
653 gtk_icon_set_unref (icon_set);
654 g_object_unref (pixbuf);
655 g_object_unref (transparent);
658 g_warning ("Modest: %s: failed to load %s icon", __FUNCTION__, items_names[i]);
660 /* Drop our reference to the factory, GTK will hold a reference. */
661 g_object_unref (factory);
667 init_default_settings (ModestConf *conf)
669 /* Show toolbar keys */
670 if (!modest_conf_key_exists (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR, NULL))
671 modest_conf_set_bool (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR, TRUE, NULL);
673 if (!modest_conf_key_exists (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL))
674 modest_conf_set_bool (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR_FULLSCREEN, TRUE, NULL);
676 if (!modest_conf_key_exists (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR, NULL))
677 modest_conf_set_bool (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR, TRUE, NULL);
679 if (!modest_conf_key_exists (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL))
680 modest_conf_set_bool (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR_FULLSCREEN, TRUE, NULL);
682 if (!modest_conf_key_exists (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, NULL))
683 modest_conf_set_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, TRUE, NULL);
685 if (!modest_conf_key_exists (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL))
686 modest_conf_set_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, TRUE, NULL);
689 if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_CC, NULL))
690 modest_conf_set_bool (conf, MODEST_CONF_SHOW_CC, TRUE, NULL);
692 if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_BCC, NULL))
693 modest_conf_set_bool (conf, MODEST_CONF_SHOW_BCC, FALSE, NULL);
695 /* Global settings */
696 if (!modest_conf_key_exists (conf, MODEST_CONF_AUTO_UPDATE, NULL))
697 modest_conf_set_bool (conf, MODEST_CONF_AUTO_UPDATE, TRUE, NULL);
699 if (!modest_conf_key_exists (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, NULL))
700 modest_conf_set_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, MODEST_CONNECTED_VIA_WLAN, NULL);
702 if (!modest_conf_key_exists (conf, MODEST_CONF_UPDATE_INTERVAL, NULL))
703 modest_conf_set_int (conf, MODEST_CONF_UPDATE_INTERVAL, MODEST_UPDATE_INTERVAL_15_MIN, NULL);
705 if (!modest_conf_key_exists (conf, MODEST_CONF_MSG_SIZE_LIMIT, NULL))
706 modest_conf_set_int (conf, MODEST_CONF_MSG_SIZE_LIMIT, 1000, NULL);
708 if (!modest_conf_key_exists (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, NULL))
709 modest_conf_set_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, FALSE, NULL);
711 if (!modest_conf_key_exists (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, NULL))
712 modest_conf_set_bool (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, TRUE, NULL);
714 if (!modest_conf_key_exists (conf, MODEST_CONF_REPLY_TYPE, NULL))
715 modest_conf_set_int (conf, MODEST_CONF_REPLY_TYPE, MODEST_TNY_MSG_REPLY_TYPE_QUOTE, NULL);
719 /* set the device name -- note this is an initial guess from /etc/hostname
720 * on maemo-device it will most probably be replaced with the Bluetooth device
721 * name later during starting (see maemo/modest-maemo-utils.[ch])
724 init_device_name (ModestConf *conf)
726 unsigned int len = 255; /* max len */
727 gchar *devname = NULL;
729 if (!g_file_get_contents("/etc/hostname", &devname, &len, NULL) || len < 2 || len > 254) {
730 g_printerr ("modest: failed to read hostname\n");
731 modest_conf_set_string (conf, MODEST_CONF_DEVICE_NAME,
732 MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME,
735 /* remove the \n at the end */
736 if (devname[len-1] == '\n')
737 devname[len-1] = '\0';
742 if (!modest_conf_set_string (conf, MODEST_CONF_DEVICE_NAME,devname, &err)) {
743 g_printerr ("modest: error setting device name '%s': %s",
744 devname, err ? err->message: "?");