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.
30 #include <sys/utsname.h>
33 #include <glib-object.h>
34 #include <glib/gstdio.h>
35 #include <modest-runtime.h>
36 #include <modest-runtime-priv.h>
37 #include <modest-init.h>
38 #include <modest-defs.h>
39 #include "modest-address-book.h"
40 #include <modest-singletons.h>
41 #include <widgets/modest-header-view.h>
42 #include <widgets/modest-folder-view.h>
43 #include <modest-tny-platform-factory.h>
44 #include <modest-platform.h>
45 #include <modest-widget-memory.h>
46 #include <modest-widget-memory-priv.h>
47 #include <modest-local-folder-info.h>
48 #include <modest-account-mgr.h>
49 #include <modest-account-mgr-helpers.h>
50 #include <modest-icon-names.h>
51 #include "widgets/modest-global-settings-dialog.h"
52 #include "modest-tny-msg.h"
53 #include <libgnomevfs/gnome-vfs.h>
55 #include "modest-text-utils.h"
57 #ifdef MODEST_TOOLKIT_HILDON2
58 #include "modest-hildon-includes.h"
61 static gboolean init_header_columns (ModestConf *conf, gboolean overwrite);
62 static gboolean init_default_account_maybe (ModestAccountMgr *acc_mgr);
63 static void init_i18n (void);
64 static void init_stock_icons (void);
65 static void init_debug_g_type (void);
66 static void init_debug_logging (void);
67 static void init_default_settings (ModestConf *conf);
68 static void init_device_name (ModestConf *conf);
69 static gboolean init_ui (gint argc, gchar** argv);
72 static gboolean _is_initialized = FALSE;
75 * defaults for the column headers
78 ModestHeaderViewColumn col;
84 static const guint MODEST_MAIN_PANED_POS_PERCENTAGE = 30;
85 static const guint MODEST_MSG_PANED_POS_PERCENTAGE = 50;
87 static const FolderCols INBOX_COLUMNS_DETAILS[] = {
88 {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40, 0},
89 {MODEST_HEADER_VIEW_COLUMN_FROM, 80, 0},
90 {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80, 0},
91 {MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE, 60, 0},
92 {MODEST_HEADER_VIEW_COLUMN_SIZE, 50, 0}
95 static const FolderCols INBOX_COLUMNS_TWOLINES[] = {
96 {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN, 180, 0},
99 static const FolderCols OUTBOX_COLUMNS_DETAILS[] = {
100 {MODEST_HEADER_VIEW_COLUMN_ATTACH, 40, 0},
101 {MODEST_HEADER_VIEW_COLUMN_TO, 80, 0},
102 {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80, 0},
103 {MODEST_HEADER_VIEW_COLUMN_SENT_DATE, 80, 0},
104 {MODEST_HEADER_VIEW_COLUMN_SIZE, 50, 0}
107 static const FolderCols OUTBOX_COLUMNS_TWOLINES[] = {
108 {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,180, 0}
109 // {MODEST_HEADER_VIEW_COLUMN_STATUS, 240, 0}
112 static const FolderCols SENT_COLUMNS_TWOLINES[] = {
113 {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,180, 0},
116 #ifndef MODEST_TOOLKIT_GTK
117 static const TnyFolderType LOCAL_FOLDERS[] = {
118 /* TNY_FOLDER_TYPE_OUTBOX, */
119 TNY_FOLDER_TYPE_DRAFTS,
123 static const TnyFolderType LOCAL_FOLDERS[] = {
124 /* TNY_FOLDER_TYPE_OUTBOX, */
125 TNY_FOLDER_TYPE_DRAFTS,
126 TNY_FOLDER_TYPE_SENT,
127 TNY_FOLDER_TYPE_TRASH,
128 TNY_FOLDER_TYPE_ARCHIVE
130 #endif /* MODEST_TOOLKIT_GTK */
133 new_cold_ids_gslist_from_array( const FolderCols* cols, guint col_num)
135 GList *result = NULL;
138 for (i = 0; i < col_num; ++i) {
139 result = g_list_append (result, GINT_TO_POINTER (cols[i].col));
146 modest_init_get_default_header_view_column_ids (TnyFolderType folder_type, ModestHeaderViewStyle style)
148 GList *result = NULL;
150 switch (folder_type) {
151 case TNY_FOLDER_TYPE_SENT:
152 case TNY_FOLDER_TYPE_DRAFTS:
153 if (style == MODEST_HEADER_VIEW_STYLE_DETAILS)
154 result = new_cold_ids_gslist_from_array (OUTBOX_COLUMNS_DETAILS,
155 G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS));
156 else if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES)
157 result = new_cold_ids_gslist_from_array (SENT_COLUMNS_TWOLINES,
158 G_N_ELEMENTS(SENT_COLUMNS_TWOLINES));
160 case TNY_FOLDER_TYPE_OUTBOX:
161 if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES)
162 result = new_cold_ids_gslist_from_array (OUTBOX_COLUMNS_TWOLINES,
163 G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES));
167 if (style == MODEST_HEADER_VIEW_STYLE_DETAILS)
168 result = new_cold_ids_gslist_from_array (INBOX_COLUMNS_DETAILS,
169 G_N_ELEMENTS(INBOX_COLUMNS_DETAILS));
170 else if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES)
171 result = new_cold_ids_gslist_from_array (INBOX_COLUMNS_TWOLINES,
172 G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES));
176 g_warning("DEBUG: %s: No default columns IDs found for "
177 "folder_type=%d, style=%d\n", __FUNCTION__, folder_type, style);
185 force_ke_recv_load (void)
187 #ifdef MODEST_PLATFORM_MAEMO
188 if (strcmp ("cerm_device_memory_full",
189 _KR("cerm_device_memory_full")) == 0) {
190 g_debug ("%s: cannot get translation for cerm_device_memory_full",
200 modest_init (int argc, char *argv[])
204 if (_is_initialized) {
205 g_printerr ("modest: %s may only be invoked once\n", __FUNCTION__);
211 if (!force_ke_recv_load()) {
212 g_printerr ("modest: %s: ke-recv is missing "
213 "or memory is very low\n", __FUNCTION__);
214 /* don't return FALSE here, because it might be that ke-recv is
215 missing. TODO: find a way to verify that
220 init_debug_logging();
222 /* initialize the prng, we need it when creating random files */
223 srandom((int)getpid());
225 if (!gnome_vfs_initialized()) {
226 if (!gnome_vfs_init ()) {
227 g_printerr ("modest: failed to init gnome-vfs\n");
232 if (!modest_runtime_init()) {
233 modest_init_uninit ();
234 g_printerr ("modest: failed to initialize the modest runtime\n");
238 modest_plugin_factory_load_all (modest_runtime_get_plugin_factory ());
240 /* do an initial guess for the device name */
241 init_device_name (modest_runtime_get_conf());
243 if (!modest_platform_init(argc, argv)) {
244 modest_init_uninit ();
245 g_printerr ("modest: failed to run platform-specific initialization\n");
249 /* Initialize addressbook */
250 modest_address_book_init ();
252 reset = modest_runtime_get_debug_flags () & MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS;
253 if (!init_header_columns(modest_runtime_get_conf(), TRUE)) {
254 modest_init_uninit ();
255 g_printerr ("modest: failed to init header columns\n");
259 init_default_settings (modest_runtime_get_conf ());
261 if (!modest_init_local_folders(NULL)) {
262 modest_init_uninit ();
263 g_printerr ("modest: failed to init local folders\n");
267 if (!init_default_account_maybe (modest_runtime_get_account_mgr ())) {
268 modest_init_uninit ();
269 g_printerr ("modest: failed to init default account\n");
273 if (!init_ui (argc, argv)) {
274 modest_init_uninit ();
275 g_printerr ("modest: failed to init ui\n");
279 return _is_initialized = TRUE;
284 init_ui (gint argc, gchar** argv)
286 /* Set application name */
287 g_set_application_name (modest_platform_get_app_name());
288 /* g_debug (modest_platform_get_app_name()); */
290 /* Init stock icons */
293 /* Init notification system */
294 #ifdef MODEST_HAVE_HILDON_NOTIFY
295 notify_init ("Basics");
302 modest_init_uninit (void)
304 if (!_is_initialized)
307 if (!modest_runtime_uninit())
308 g_printerr ("modest: failed to uninit runtime\n");
310 if (!modest_platform_uninit())
311 g_printerr ("modest: failed to uninit platform\n");
313 if (gnome_vfs_initialized()) /* apparently, this returns TRUE, even after a shutdown */
314 gnome_vfs_shutdown ();
316 _is_initialized = FALSE;
323 /* NOTE: the exact details of this format are important, as they
324 * are also used in modest-widget-memory. FIXME: make a shared function
325 * for this with widget-memory
328 save_header_settings (ModestConf *conf, TnyFolderType type,
329 ModestHeaderViewStyle style, const FolderCols* cols,
330 guint col_num, gboolean overwrite)
338 g_return_val_if_fail (cols, FALSE);
340 key = _modest_widget_memory_get_keyname_with_double_type ("header-view",
342 MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
343 sort_key = _modest_widget_memory_get_keyname_with_double_type ("header-view",
345 MODEST_WIDGET_MEMORY_PARAM_COLUMN_SORT);
346 /* if we're not in overwrite mode, only write stuff it
347 * there was nothing before */
348 if (!overwrite && modest_conf_key_exists(conf, key, NULL)) {
354 /* the format is necessarily the same as the one in modest-widget-memory */
355 str = g_string_new (NULL);
356 for (i = 0; i != col_num; ++i)
357 g_string_append_printf (str, "%d:%d:%d ",
358 cols[i].col, cols[i].width, cols[i].sort);
360 modest_conf_set_string (conf, key, str->str, NULL);
362 g_string_free (str, TRUE);
366 if (cols[0].col == MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT)
367 sort_col_id = TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN;
369 sort_col_id = TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN;
370 sort_value = g_strdup_printf("%d:%d:%d", sort_col_id, GTK_SORT_DESCENDING, 0);
371 modest_conf_set_string (conf, sort_key, sort_value, NULL);
380 * modest_init_header_columns:
381 * @overwrite: write the setting, even if it already exists
383 * will set defaults for the columns to show for folder,
384 * if there are no such settings yet (in ModestWidgetMemory)
386 * Returns: TRUE if succeeded, FALSE in case of error
389 init_header_columns (ModestConf *conf, gboolean overwrite)
394 for (folder_type = TNY_FOLDER_TYPE_UNKNOWN;
395 folder_type < TNY_FOLDER_TYPE_NUM; ++folder_type) {
397 switch (folder_type) {
398 case TNY_FOLDER_TYPE_SENT:
399 case TNY_FOLDER_TYPE_DRAFTS:
400 save_header_settings (conf, folder_type,
401 MODEST_HEADER_VIEW_STYLE_DETAILS,
402 OUTBOX_COLUMNS_DETAILS,
403 G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS),
405 save_header_settings (conf, folder_type,
406 MODEST_HEADER_VIEW_STYLE_TWOLINES,
407 SENT_COLUMNS_TWOLINES,
408 G_N_ELEMENTS(SENT_COLUMNS_TWOLINES),
411 case TNY_FOLDER_TYPE_OUTBOX:
412 save_header_settings (conf, folder_type,
413 MODEST_HEADER_VIEW_STYLE_TWOLINES,
414 OUTBOX_COLUMNS_TWOLINES,
415 G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES),
420 save_header_settings (conf, folder_type,
421 MODEST_HEADER_VIEW_STYLE_DETAILS,
422 INBOX_COLUMNS_DETAILS,
423 G_N_ELEMENTS(INBOX_COLUMNS_DETAILS),
425 save_header_settings (conf, folder_type,
426 MODEST_HEADER_VIEW_STYLE_TWOLINES,
427 INBOX_COLUMNS_TWOLINES,
428 G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES),
433 key = _modest_widget_memory_get_keyname (MODEST_CONF_MAIN_PANED_KEY,
434 MODEST_WIDGET_MEMORY_PARAM_POS);
435 /* if we're not in overwrite mode, only write stuff it
436 * there was nothing before */
437 if (overwrite || !modest_conf_key_exists(conf, key, NULL))
438 modest_conf_set_float (conf, key, MODEST_MAIN_PANED_POS_PERCENTAGE, NULL);
442 key = _modest_widget_memory_get_keyname (MODEST_CONF_MSG_PANED_KEY,
443 MODEST_WIDGET_MEMORY_PARAM_POS);
444 /* if we're not in overwrite mode, only write stuff it
445 * there was nothing before */
446 if (overwrite || !modest_conf_key_exists(conf, key, NULL))
447 modest_conf_set_float (conf, key, MODEST_MSG_PANED_POS_PERCENTAGE, NULL);
453 gboolean modest_init_one_local_folder (gchar *maildir_path)
455 static const gchar* maildirs[] = {
460 for (j = 0; j != G_N_ELEMENTS(maildirs); ++j) {
461 gchar *dir = g_build_filename (maildir_path,
464 if (g_mkdir_with_parents (dir, 0755) < 0) {
465 g_printerr ("modest: %s: failed to create %s\n", __FUNCTION__, dir);
477 * modest_init_local_folders:
479 * create the Local Folders folder under cache, if they
482 * Returns: TRUE if the folder were already there, or
483 * they were created, FALSE otherwise
486 modest_init_local_folders (const gchar* location_filepath)
488 gboolean retval = TRUE;
490 gchar *maildir_path = modest_local_folder_info_get_maildir_path (location_filepath);
492 if (location_filepath) {
493 /* For instance, for memory card, just create the top-level .modest folder
494 * and one "archive" folder (so that messages can be put somewhere):
497 gchar *dir = g_build_filename (maildir_path,
498 modest_local_folder_info_get_type_name(TNY_FOLDER_TYPE_ARCHIVE),
500 const gboolean created = modest_init_one_local_folder (dir);
508 /* Create each of the standard on-disk folders.
509 * Per-account outbox folders will be created when first needed. */
511 for (i = 0; i != G_N_ELEMENTS(LOCAL_FOLDERS); ++i) {
512 gchar *dir = g_build_filename (maildir_path,
513 modest_local_folder_info_get_type_name(LOCAL_FOLDERS[i]),
515 const gboolean created = modest_init_one_local_folder (dir);
524 g_free (maildir_path);
529 * init_default_account_maybe:
531 * if there are accounts defined, but there is no default account,
532 * it will be defined.
534 * Returns: TRUE if there was a default account already,
535 * or one has been created or there are no accounts yet,
536 * returns FALSE in case of error
539 init_default_account_maybe (ModestAccountMgr *acc_mgr)
541 gchar *default_account;
542 gboolean retval = TRUE;
544 default_account = modest_account_mgr_get_default_account (acc_mgr);
545 if (!default_account)
546 retval = modest_account_mgr_set_first_account_as_default (acc_mgr);
547 g_free (default_account);
555 init_debug_g_type (void)
557 GTypeDebugFlags gflags;
558 ModestRuntimeDebugFlags mflags;
561 mflags = modest_runtime_get_debug_flags ();
563 if (mflags & MODEST_RUNTIME_DEBUG_OBJECTS)
564 gflags |= G_TYPE_DEBUG_OBJECTS;
565 if (mflags & MODEST_RUNTIME_DEBUG_SIGNALS)
566 gflags |= G_TYPE_DEBUG_SIGNALS;
568 g_type_init_with_debug_flags (gflags);
573 null_log(const gchar* dom,
583 init_debug_logging (void)
585 ModestRuntimeDebugFlags mflags;
586 mflags = modest_runtime_get_debug_flags ();
589 if (! (mflags & MODEST_RUNTIME_DEBUG_CODE)) {
590 g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, null_log, NULL);
594 if (mflags & MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING)
595 g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
596 G_LOG_LEVEL_CRITICAL |
597 G_LOG_LEVEL_WARNING);
603 const gchar *lc_messages = setlocale (LC_MESSAGES, NULL);
606 setenv ("LANGUAGE", "en_GB", 1);
607 setenv ("LC_MESSAGES", "en_GB", 1);
608 #ifdef MODEST_PLATFORM_GNOME
610 gchar *new_lc_messages;
611 new_lc_messages = g_strconcat (lc_messages, ":en_GB", NULL);
612 setenv ("LANGUAGE", new_lc_messages, 1);
613 setenv ("LC_MESSAGES", new_lc_messages, 1);
614 g_free (new_lc_messages);
618 bindtextdomain (GETTEXT_PACKAGE, MODEST_LOCALE_DIR);
619 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
620 textdomain (GETTEXT_PACKAGE);
625 * This function registers our custom toolbar icons, so they can be
626 * themed. The idea of this function was taken from the gtk-demo
629 init_stock_icons (void)
631 static gboolean registered = FALSE;
634 GtkIconTheme *current_theme;
636 GtkIconFactory *factory;
639 static GtkStockItem items[] = {
640 #ifdef MODEST_TOOLKIT_HILDON2
641 { MODEST_STOCK_SORT, "sort mail", 0, 0, NULL },
642 { MODEST_STOCK_REFRESH, "refresh mail", 0, 0, NULL },
643 #endif /*MODEST_TOOLKIT_GTK*/
644 { MODEST_STOCK_MAIL_SEND, "send mail", 0, 0, NULL },
645 { MODEST_STOCK_NEW_MAIL, "new mail", 0, 0, NULL },
646 { MODEST_STOCK_REPLY, "reply", 0, 0, NULL },
647 { MODEST_STOCK_REPLY_ALL, "reply all", 0, 0, NULL },
648 { MODEST_STOCK_FORWARD, "forward", 0, 0, NULL },
649 { MODEST_STOCK_DELETE, "delete", 0, 0, NULL },
652 static gchar *items_names [] = {
653 #ifdef MODEST_TOOLKIT_HILDON2
654 MODEST_TOOLBAR_ICON_SORT,
655 MODEST_TOOLBAR_ICON_REFRESH,
656 #endif /*MODEST_TOOLKIT_GTK*/
657 MODEST_TOOLBAR_ICON_MAIL_SEND,
658 MODEST_TOOLBAR_ICON_NEW_MAIL,
659 MODEST_TOOLBAR_ICON_REPLY,
660 MODEST_TOOLBAR_ICON_REPLY_ALL,
661 MODEST_TOOLBAR_ICON_FORWARD,
662 MODEST_TOOLBAR_ICON_DELETE,
667 /* Register our stock items */
668 gtk_stock_add (items, G_N_ELEMENTS (items));
670 /* Add our custom icon factory to the list of defaults */
671 factory = gtk_icon_factory_new ();
672 gtk_icon_factory_add_default (factory);
674 current_theme = gtk_icon_theme_get_default ();
676 /* Register icons to accompany stock items */
677 for (i = 0; i < G_N_ELEMENTS (items); i++) {
679 #ifndef MODEST_PLATFORM_GTK
680 pixbuf = gtk_icon_theme_load_icon (current_theme,
682 #ifdef MODEST_TOOLKIT_HILDON2
683 MODEST_ICON_SIZE_BIG,
685 MODEST_ICON_SIZE_SMALL,
687 GTK_ICON_LOOKUP_NO_SVG,
690 pixbuf = gdk_pixbuf_new_from_file (items_names[i], NULL);
693 if (pixbuf != NULL) {
694 GtkIconSet *icon_set;
696 #ifndef MODEST_TOOLKIT_HILDON2
697 GdkPixbuf *transparent;
698 transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
699 icon_set = gtk_icon_set_new_from_pixbuf (transparent);
700 g_object_unref (transparent);
702 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
704 gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
705 gtk_icon_set_unref (icon_set);
706 g_object_unref (pixbuf);
709 g_warning ("%s: failed to load %s icon", __FUNCTION__, items_names[i]);
711 /* Drop our reference to the factory, GTK will hold a reference. */
712 g_object_unref (factory);
718 init_default_settings (ModestConf *conf)
720 /* Show toolbar keys */
721 if (!modest_conf_key_exists (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR, NULL))
722 modest_conf_set_bool (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR, TRUE, NULL);
724 if (!modest_conf_key_exists (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL))
725 modest_conf_set_bool (conf, MODEST_CONF_MAIN_WINDOW_SHOW_TOOLBAR_FULLSCREEN, TRUE, NULL);
727 if (!modest_conf_key_exists (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR, NULL))
728 modest_conf_set_bool (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR, TRUE, NULL);
730 if (!modest_conf_key_exists (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL))
731 modest_conf_set_bool (conf, MODEST_CONF_MSG_VIEW_WINDOW_SHOW_TOOLBAR_FULLSCREEN, TRUE, NULL);
733 if (!modest_conf_key_exists (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, NULL))
734 modest_conf_set_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, TRUE, NULL);
736 if (!modest_conf_key_exists (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL))
737 modest_conf_set_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, TRUE, NULL);
740 if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_CC, NULL))
741 modest_conf_set_bool (conf, MODEST_CONF_SHOW_CC, FALSE, NULL);
743 if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_BCC, NULL))
744 modest_conf_set_bool (conf, MODEST_CONF_SHOW_BCC, FALSE, NULL);
746 /* File chooser keys */
747 if (!modest_conf_key_exists (conf, MODEST_CONF_LATEST_ATTACH_FILE_PATH, NULL))
748 modest_conf_set_string (conf, MODEST_CONF_LATEST_ATTACH_FILE_PATH, "", NULL);
749 if (!modest_conf_key_exists (conf, MODEST_CONF_LATEST_INSERT_IMAGE_PATH, NULL))
750 modest_conf_set_string (conf, MODEST_CONF_LATEST_INSERT_IMAGE_PATH, "", NULL);
751 if (!modest_conf_key_exists (conf, MODEST_CONF_LATEST_SAVE_ATTACHMENT_PATH, NULL))
752 modest_conf_set_string (conf, MODEST_CONF_LATEST_SAVE_ATTACHMENT_PATH, "", NULL);
754 /* Global settings */
755 if (!modest_conf_key_exists (conf, MODEST_CONF_AUTO_UPDATE, NULL))
756 modest_conf_set_bool (conf, MODEST_CONF_AUTO_UPDATE, TRUE, NULL);
758 if (!modest_conf_key_exists (conf, MODEST_CONF_NOTIFICATIONS, NULL))
759 modest_conf_set_bool (conf, MODEST_CONF_NOTIFICATIONS, TRUE, NULL);
761 if (!modest_conf_key_exists (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, NULL))
762 modest_conf_set_bool (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, TRUE, NULL);
764 if (!modest_conf_key_exists (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, NULL))
765 modest_conf_set_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, MODEST_CONNECTED_VIA_WLAN_OR_WIMAX, NULL);
767 if (!modest_conf_key_exists (conf, MODEST_CONF_UPDATE_INTERVAL, NULL))
768 modest_conf_set_int (conf, MODEST_CONF_UPDATE_INTERVAL, MODEST_UPDATE_INTERVAL_30_MIN, NULL);
770 if (!modest_conf_key_exists (conf, MODEST_CONF_MSG_SIZE_LIMIT, NULL))
771 modest_conf_set_int (conf, MODEST_CONF_MSG_SIZE_LIMIT, 100, NULL);
773 if (!modest_conf_key_exists (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, NULL))
774 modest_conf_set_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, FALSE, NULL);
776 if (!modest_conf_key_exists (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, NULL))
777 modest_conf_set_bool (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, TRUE, NULL);
779 if (!modest_conf_key_exists (conf, MODEST_CONF_REPLY_TYPE, NULL))
780 modest_conf_set_int (conf, MODEST_CONF_REPLY_TYPE, MODEST_TNY_MSG_REPLY_TYPE_QUOTE, NULL);
782 if (!modest_conf_key_exists (conf, MODEST_CONF_FETCH_HTML_EXTERNAL_IMAGES, NULL))
783 modest_conf_set_bool (conf, MODEST_CONF_FETCH_HTML_EXTERNAL_IMAGES, FALSE, NULL);
787 /* set the device name -- note this is an initial guess from /etc/hostname
788 * on maemo-device it will most probably be replaced with the Bluetooth device
789 * name later during starting (see maemo/modest-maemo-utils.[ch])
792 init_device_name (ModestConf *conf)
796 if (uname (&name) == 0) {
797 modest_conf_set_string (modest_runtime_get_conf(),
798 MODEST_CONF_DEVICE_NAME, name.nodename,
801 modest_conf_set_string (modest_runtime_get_conf(),
802 MODEST_CONF_DEVICE_NAME,
803 MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME,