* Removed the modest send/receive custom icon
[modest] / src / modest-runtime.c
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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.
16  *
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.
28  */
29
30 #include <config.h>
31 #include <glib.h>
32 #include <glib-object.h>
33 #include <glib/gstdio.h>
34 #include <modest-runtime.h>
35 #include <modest-defs.h>
36 #include <modest-singletons.h>
37 #include <widgets/modest-header-view.h>
38 #include <widgets/modest-folder-view.h>
39 #include <modest-tny-platform-factory.h>
40 #include <modest-widget-memory.h>
41 #include <modest-widget-memory-priv.h>
42 #include <modest-local-folder-info.h>
43 #include <modest-account-mgr.h>
44 #include <modest-account-mgr-helpers.h>
45 #include <modest-icon-names.h>
46
47 #if MODEST_PLATFORM_ID==2 /* maemo/hildon */
48 #include <libosso.h>
49 static gboolean init_hildon (void);
50 #endif /* MODEST_PLATFORM_ID==2 */
51
52 static gboolean init_header_columns (ModestConf *conf, gboolean overwrite);
53 static gboolean init_local_folders  (void);
54 static gboolean init_default_account_maybe  (ModestAccountMgr *acc_mgr);
55 static void     init_i18n (void);
56 static void     init_stock_icons (void);
57 static void     init_debug_g_type (void);
58 static void     init_debug_logging (void);
59 static void     init_test_accounts (ModestAccountMgr *acc_mgr);
60
61
62 static ModestSingletons *_singletons = NULL;
63
64
65 /*
66  * defaults for the column headers
67  */
68 typedef struct {
69         ModestHeaderViewColumn col;
70         guint                  width;
71 } FolderCols;
72
73 static const FolderCols INBOX_COLUMNS_DETAILS[] = {
74         {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
75         {MODEST_HEADER_VIEW_COLUMN_ATTACH,  40},
76         {MODEST_HEADER_VIEW_COLUMN_FROM,    80},
77         {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80},
78         {MODEST_HEADER_VIEW_COLUMN_RECEIVED_DATE, 60},
79         {MODEST_HEADER_VIEW_COLUMN_SIZE, 50}
80 };
81 static const FolderCols INBOX_COLUMNS_TWOLINES[] = {
82         {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
83         {MODEST_HEADER_VIEW_COLUMN_ATTACH,  40},
84         {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN, 200}
85 };
86
87 static const FolderCols OUTBOX_COLUMNS_DETAILS[] = {
88          {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
89          {MODEST_HEADER_VIEW_COLUMN_ATTACH,  40},
90          {MODEST_HEADER_VIEW_COLUMN_TO,    80},
91          {MODEST_HEADER_VIEW_COLUMN_SUBJECT, 80},
92          {MODEST_HEADER_VIEW_COLUMN_SENT_DATE, 80},
93          {MODEST_HEADER_VIEW_COLUMN_SIZE, 50}
94 };
95 static const FolderCols OUTBOX_COLUMNS_TWOLINES[] = {
96          {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40},
97          {MODEST_HEADER_VIEW_COLUMN_ATTACH,  40},
98          {MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT,200},
99 };
100          
101 static const TnyFolderType LOCAL_FOLDERS[] = {
102         TNY_FOLDER_TYPE_OUTBOX,
103         TNY_FOLDER_TYPE_DRAFTS,
104         TNY_FOLDER_TYPE_SENT,
105         TNY_FOLDER_TYPE_TRASH,
106         TNY_FOLDER_TYPE_ARCHIVE 
107 };
108
109
110 gboolean
111 modest_runtime_init (void)
112 {
113         ModestSingletons *my_singletons;
114         gboolean reset;
115         
116         if (_singletons) {
117                 g_printerr ("modest: modest_runtime_init can only be called once\n");
118                 return FALSE;
119         }
120         
121         init_i18n();
122         init_debug_g_type();
123         init_debug_logging();
124
125         g_thread_init(NULL);
126         gdk_threads_init ();
127
128         my_singletons = modest_singletons_new ();
129         if (!my_singletons) {
130                 g_printerr ("modest: failed to initialize singletons\n");
131                 return FALSE;
132         }
133
134 #if MODEST_PLATFORM_ID==2 
135         if (!init_hildon ()) {
136                 modest_runtime_uninit ();
137                 g_printerr ("modest: failed to initialize hildon\n");
138                 return FALSE;
139         }
140 #endif /* MODEST_PLATFORM_ID==2 */
141
142         /* based on the debug settings, we decide whether to overwrite old settings */
143         reset = modest_runtime_get_debug_flags () & MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS;
144         if (!init_header_columns(modest_singletons_get_conf (my_singletons), reset)) {
145                 modest_runtime_uninit ();
146                 g_printerr ("modest: failed to init header columns\n");
147                 return FALSE;
148         }
149         
150         if (!init_local_folders()) {
151                 modest_runtime_uninit ();
152                 g_printerr ("modest: failed to init local folders\n");
153                 return FALSE;
154         }
155         
156         if (!init_default_account_maybe(modest_singletons_get_account_mgr (my_singletons))) {
157                 modest_runtime_uninit ();
158                 g_printerr ("modest: failed to init default account\n");
159                 return FALSE;
160         }
161
162         /* create the test accounts if the debug flag for that is set */
163         if (modest_runtime_get_debug_flags () & MODEST_RUNTIME_DEBUG_TINY_TEST_ACCOUNTS)
164                 init_test_accounts (modest_singletons_get_account_mgr (my_singletons)); 
165         
166         /* don't initialize _singletons before all the other init stuff
167          * is done; thus, using any of the singleton stuff before
168          * runtime is fully init'ed  is avoided
169          */
170         _singletons = my_singletons;
171         
172         return TRUE;
173 }
174
175
176 gboolean
177 modest_runtime_init_ui (gint argc, gchar** argv)
178 {
179         if (!gtk_init_check(&argc, &argv)) {
180                 g_printerr ("modest: failed to initialize graphical ui\n");
181                 return FALSE;
182         }
183
184         init_stock_icons ();
185         return TRUE;
186 }
187
188
189 gboolean
190 modest_runtime_uninit (void)
191 {
192         if (_singletons) {
193                 g_object_unref (G_OBJECT(_singletons));
194                 _singletons = NULL;
195         }
196         modest_runtime_verify_object_death (_singletons, "_singletons");
197         
198         return TRUE;
199 }
200
201
202 ModestAccountMgr*
203 modest_runtime_get_account_mgr   (void)
204 {
205         g_return_val_if_fail (_singletons, NULL);
206         return modest_singletons_get_account_mgr (_singletons);
207 }
208
209 ModestTnyAccountStore*
210 modest_runtime_get_account_store   (void)
211 {
212         g_return_val_if_fail (_singletons, NULL);
213         return modest_singletons_get_account_store (_singletons);
214
215 }
216
217 ModestConf*
218 modest_runtime_get_conf (void)
219 {
220         g_return_val_if_fail (_singletons, NULL);
221         return modest_singletons_get_conf (_singletons);
222 }
223
224
225 ModestCacheMgr*
226 modest_runtime_get_cache_mgr (void)
227 {
228         g_return_val_if_fail (_singletons, NULL);
229         return modest_singletons_get_cache_mgr (_singletons);
230 }
231
232
233 ModestMailOperationQueue*
234 modest_runtime_get_mail_operation_queue (void)
235 {
236         g_return_val_if_fail (_singletons, NULL);
237         return modest_singletons_get_mail_operation_queue (_singletons);
238 }
239
240
241
242 TnyDevice*
243 modest_runtime_get_device (void)
244 {
245         g_return_val_if_fail (_singletons, NULL);
246         return modest_singletons_get_device (_singletons);
247 }
248
249
250 TnyPlatformFactory*
251 modest_runtime_get_platform_factory  (void)
252 {
253         g_return_val_if_fail (_singletons, NULL);
254         return modest_singletons_get_platform_factory (_singletons);
255 }
256
257
258
259
260 ModestTnySendQueue*
261 modest_runtime_get_send_queue  (TnyTransportAccount *account)
262 {
263         ModestCacheMgr *cache_mgr;
264         GHashTable     *send_queue_cache;
265         gpointer       orig_key, send_queue;
266         
267         g_return_val_if_fail (_singletons, NULL);
268         g_return_val_if_fail (TNY_IS_TRANSPORT_ACCOUNT(account), NULL);
269
270         cache_mgr = modest_singletons_get_cache_mgr (_singletons);
271         send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
272                                                        MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE);
273
274         if (!g_hash_table_lookup_extended (send_queue_cache, account, &orig_key, &send_queue)) {
275                 send_queue = (gpointer)modest_tny_send_queue_new (TNY_CAMEL_TRANSPORT_ACCOUNT(account));
276                 g_hash_table_insert (send_queue_cache, account, send_queue);
277         }
278
279         return MODEST_TNY_SEND_QUEUE(send_queue);
280 }
281
282
283
284
285 /* http://primates.ximian.com/~federico/news-2006-04.html#memory-debugging-infrastructure*/
286 ModestRuntimeDebugFlags
287 modest_runtime_get_debug_flags ()
288 {
289         static const GDebugKey debug_keys[] = {
290                 { "abort-on-warning",   MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING },
291                 { "log-actions",        MODEST_RUNTIME_DEBUG_LOG_ACTIONS },
292                 { "debug-objects",      MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS },
293                 { "debug-signals",      MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS },
294                 { "factory-settings",   MODEST_RUNTIME_DEBUG_FACTORY_SETTINGS},
295                 { "tiny-test-accounts", MODEST_RUNTIME_DEBUG_TINY_TEST_ACCOUNTS}
296         };
297         const gchar *str;
298         static ModestRuntimeDebugFlags debug_flags = -1;
299
300         if (debug_flags != -1)
301                 return debug_flags;
302         
303         str = g_getenv (MODEST_DEBUG);
304         
305         if (str != NULL)
306                 debug_flags = g_parse_debug_string (str, debug_keys, G_N_ELEMENTS (debug_keys));
307         else
308                 debug_flags = 0;
309         
310         return debug_flags;
311 }
312
313
314
315
316
317 /* NOTE: the exact details of this format are important, as they
318  * are also used in modest-widget-memory. FIXME: make a shared function
319  * for this with widget-memory
320  */
321 static gboolean
322 save_header_settings (ModestConf *conf, TnyFolderType type,
323                       ModestHeaderViewStyle style,  const FolderCols* cols,
324                       guint col_num, gboolean overwrite)
325 {
326         int i;
327         gchar *key;
328         GString *str;
329
330         g_return_val_if_fail (cols, FALSE);
331
332         key = _modest_widget_memory_get_keyname_with_double_type ("header-view",
333                                                                   type, style,
334                                                                   MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
335         /* if we're not in overwrite mode, only write stuff it
336          * there was nothing before */
337         if (!overwrite &&  modest_conf_key_exists(conf, key, NULL)) {
338                 g_free (key);
339                 return TRUE;
340         }
341
342         /* the format is necessarily the same as the one in modest-widget-memory */
343         str = g_string_new (NULL);
344         for (i = 0; i != col_num; ++i) 
345                 g_string_append_printf (str, "%d:%d ",
346                                         cols[i].col, cols[i].width); 
347
348         modest_conf_set_string (conf, key, str->str, NULL);
349         g_free (key);
350         g_string_free (str, TRUE);
351         
352         return TRUE;
353 }
354
355 /**
356  * modest_init_header_columns:
357  * @overwrite: write the setting, even if it already exists
358  * 
359  * will set defaults for the columns to show for folder,
360  * if there are no such settings yet (in ModestWidgetMemory)
361  * 
362  * Returns: TRUE if succeeded, FALSE in case of error
363  */
364 static gboolean
365 init_header_columns (ModestConf *conf, gboolean overwrite)
366 {
367         int folder_type;
368         
369         for (folder_type = TNY_FOLDER_TYPE_UNKNOWN;
370              folder_type <= TNY_FOLDER_TYPE_CALENDAR; ++folder_type) {          
371                 
372                 switch (folder_type) {
373                 case TNY_FOLDER_TYPE_OUTBOX:
374                 case TNY_FOLDER_TYPE_SENT:
375                 case TNY_FOLDER_TYPE_DRAFTS:
376                 save_header_settings (conf, folder_type,
377                                       MODEST_HEADER_VIEW_STYLE_DETAILS,
378                                       OUTBOX_COLUMNS_DETAILS,
379                                       G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS),
380                                       overwrite);
381                 save_header_settings (conf, folder_type,
382                                       MODEST_HEADER_VIEW_STYLE_TWOLINES,
383                                       OUTBOX_COLUMNS_TWOLINES,
384                                       G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES),
385                                       overwrite);
386                 break;
387
388                 default:
389                 save_header_settings (conf, folder_type,
390                                       MODEST_HEADER_VIEW_STYLE_DETAILS,
391                                       INBOX_COLUMNS_DETAILS,
392                                       G_N_ELEMENTS(INBOX_COLUMNS_DETAILS),
393                                       overwrite);
394                 save_header_settings (conf, folder_type,
395                                       MODEST_HEADER_VIEW_STYLE_TWOLINES,
396                                       INBOX_COLUMNS_TWOLINES,
397                                       G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES),
398                                       overwrite);
399                 };
400         }
401         return TRUE;
402 }
403
404 /**
405  * init_local_folders:
406  * 
407  * create the Local Folders folder under cache, if they
408  * do not exist yet.
409  * 
410  * Returns: TRUE if the folder were already there, or
411  * they were created, FALSE otherwise
412  */
413 static gboolean
414 init_local_folders  (void)
415 {
416         int i;
417         gchar *maildir_path;
418         static const gchar* maildirs[] = {
419                 "cur", "new", "tmp"
420         };
421         
422         maildir_path = modest_local_folder_info_get_maildir_path ();
423
424         for (i = 0; i != G_N_ELEMENTS(LOCAL_FOLDERS); ++i) {
425                 int j;
426                 for (j = 0; j != G_N_ELEMENTS(maildirs); ++j) {
427                         gchar *dir;
428                         dir = g_build_filename (maildir_path,
429                                                 modest_local_folder_info_get_type_name(LOCAL_FOLDERS[i]),
430                                                 maildirs[j],
431                                                 NULL);
432                         if (g_mkdir_with_parents (dir, 0755) < 0) {
433                                 g_printerr ("modest: failed to create %s\n", dir);
434                                 g_free (dir);
435                                 g_free (maildir_path);
436                                 return FALSE;
437                         }
438                         g_free(dir);
439                 }
440         }
441         
442         g_free (maildir_path);
443         return TRUE;
444 }
445
446
447
448 static void
449 free_element (gpointer data, gpointer user_data)
450 {
451         g_free (data);
452 }
453
454
455
456 /**
457  * init_default_account_maybe:
458  *
459  * if there are accounts defined, but there is no default account,
460  * it will be defined.
461  * 
462  * Returns: TRUE if there was a default account already,
463  *  or one has been created or there are no accounts yet,
464  *  returns FALSE in case of error
465  */
466 static gboolean
467 init_default_account_maybe  (ModestAccountMgr *acc_mgr)
468 {
469         GSList *all_accounts = NULL;
470         gchar *default_account;
471         gboolean retval = TRUE;
472         
473         all_accounts = modest_account_mgr_account_names (acc_mgr);
474         if (all_accounts) { /* if there are any accounts, there should be a default one */
475                 default_account = 
476                         modest_account_mgr_get_default_account (acc_mgr);
477                 if (!default_account) {
478                         gchar *first_account;
479                         g_printerr ("modest: no default account defined\n");
480                         first_account = (gchar*)all_accounts->data;
481                         if ((retval = modest_account_mgr_set_default_account (acc_mgr, first_account)))
482                                 g_printerr ("modest: set '%s' as the default account\n",
483                                             first_account);
484                         else
485                                 g_printerr ("modest: failed to set '%s' as the default account\n",
486                                             first_account);
487                         g_free (default_account);
488                 }
489                 g_slist_foreach (all_accounts, free_element, NULL);
490                 g_slist_free    (all_accounts);
491         }
492         return retval;
493 }
494
495
496
497 static void
498 init_debug_g_type (void)
499 {
500         GTypeDebugFlags gflags;
501         ModestRuntimeDebugFlags mflags;
502         
503         gflags = 0;
504         mflags = modest_runtime_get_debug_flags ();
505
506         if (mflags & MODEST_RUNTIME_DEBUG_DEBUG_OBJECTS)
507                 gflags |= G_TYPE_DEBUG_OBJECTS;
508         if (mflags & MODEST_RUNTIME_DEBUG_DEBUG_SIGNALS)
509                 gflags |= G_TYPE_DEBUG_SIGNALS;
510
511         g_type_init_with_debug_flags (gflags);
512 }
513
514 static void
515 init_debug_logging (void)
516 {
517         ModestRuntimeDebugFlags mflags;
518         mflags = modest_runtime_get_debug_flags ();
519         
520         if (mflags & MODEST_RUNTIME_DEBUG_ABORT_ON_WARNING)
521                 g_log_set_always_fatal (G_LOG_LEVEL_ERROR |
522                                         G_LOG_LEVEL_CRITICAL |
523                                         G_LOG_LEVEL_WARNING);
524 }
525
526
527 static void
528 init_i18n (void)
529 {
530         bindtextdomain (GETTEXT_PACKAGE, MODEST_LOCALEDIR);
531         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
532         textdomain (GETTEXT_PACKAGE);
533
534 }
535
536
537 #if MODEST_PLATFORM_ID==2 
538 static gboolean
539 init_hildon (void)
540 {
541         osso_context_t *osso_context =
542                 osso_initialize(PACKAGE, PACKAGE_VERSION,
543                                 TRUE, NULL);    
544         if (!osso_context) {
545                 g_printerr ("modest: failed to acquire osso context\n");
546                 return FALSE;
547         }
548 }
549 #endif /* MODEST_PLATFORM_ID==2 */
550
551
552 /* 
553  *  This function registers our custom toolbar icons, so they can be
554  *  themed. The idea of this function was taken from the gtk-demo
555  */
556 static void
557 init_stock_icons (void)
558 {
559         static gboolean registered = FALSE;
560   
561         if (!registered) {
562                 GdkPixbuf *pixbuf;
563                 GtkIconFactory *factory;
564                 gint i;
565
566                 static GtkStockItem items[] = {
567                         { MODEST_STOCK_MAIL_SEND, "send mail", 0, 0, NULL },
568                         { MODEST_STOCK_NEW_MAIL, "new mail", 0, 0, NULL },
569 /*                      { MODEST_STOCK_SEND_RECEIVE, "send receive", 0, 0, NULL },  */
570                         { MODEST_STOCK_REPLY, "reply", 0, 0, NULL },
571                         { MODEST_STOCK_REPLY_ALL, "reply all", 0, 0, NULL },
572                         { MODEST_STOCK_FORWARD, "forward", 0, 0, NULL },
573                         { MODEST_STOCK_DELETE, "delete", 0, 0, NULL }, 
574 /*                      { MODEST_STOCK_NEXT, "next", 0, 0, NULL }, */
575 /*                      { MODEST_STOCK_PREV, "prev", 0, 0, NULL }, */
576 /*                      { MODEST_STOCK_STOP, "stop", 0, 0, NULL } */
577                 };
578       
579                 static gchar *items_names [] = {
580                         MODEST_TOOLBAR_ICON_MAIL_SEND,
581                         MODEST_TOOLBAR_ICON_NEW_MAIL,
582 /*                      MODEST_TOOLBAR_ICON_SEND_RECEIVE,  */
583                         MODEST_TOOLBAR_ICON_REPLY,      
584                         MODEST_TOOLBAR_ICON_REPLY_ALL,
585                         MODEST_TOOLBAR_ICON_FORWARD,
586                         MODEST_TOOLBAR_ICON_DELETE, 
587 /*                      MODEST_TOOLBAR_ICON_NEXT, */
588 /*                      MODEST_TOOLBAR_ICON_PREV, */
589 /*                      MODEST_TOOLBAR_ICON_STOP */
590                 };
591
592                 registered = TRUE;
593
594                 /* Register our stock items */
595                 gtk_stock_add (items, G_N_ELEMENTS (items));
596       
597                 /* Add our custom icon factory to the list of defaults */
598                 factory = gtk_icon_factory_new ();
599                 gtk_icon_factory_add_default (factory);
600
601                 /* Register icons to accompany stock items */
602                 for (i = 0; i < G_N_ELEMENTS (items); i++) {
603                         pixbuf = NULL;
604                         pixbuf = gdk_pixbuf_new_from_file (items_names[i], NULL);
605
606                         if (pixbuf != NULL) {
607                                 GtkIconSet *icon_set;
608                                 GdkPixbuf *transparent;
609
610                                 transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
611
612                                 icon_set = gtk_icon_set_new_from_pixbuf (transparent);
613                                 gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
614                                 gtk_icon_set_unref (icon_set);
615                                 g_object_unref (pixbuf);
616                                 g_object_unref (transparent);
617                         }
618                         else
619                                 g_warning ("failed to load %s icon", items_names[i]);
620                 }
621                 /* Drop our reference to the factory, GTK will hold a reference. */
622                 g_object_unref (factory);
623         }
624 }
625
626
627 static void
628 init_test_accounts (ModestAccountMgr *acc_mgr)
629 {
630         const gchar *imap_test = "TnyImapTest";
631         const gchar *pop_test  = "TnyPopTest";
632         const gchar *smtp_test = "TnySmtpTest";
633
634         if (!modest_account_mgr_account_exists (acc_mgr, imap_test, FALSE)) 
635                 modest_account_mgr_add_server_account (acc_mgr,
636                                                        imap_test,
637                                                        "imap2.tinymail.org",
638                                                        "tnytest", "tnytest",
639                                                        MODEST_PROTOCOL_STORE_IMAP,
640                                                        MODEST_PROTOCOL_SECURITY_NONE,
641                                                        MODEST_PROTOCOL_AUTH_NONE);
642         if (!modest_account_mgr_account_exists (acc_mgr, pop_test, FALSE)) 
643                 modest_account_mgr_add_server_account (acc_mgr,
644                                                        pop_test,
645                                                        "imap2.tinymail.org",
646                                                        "tnytest", "tnytest",
647                                                        MODEST_PROTOCOL_STORE_POP,
648                                                        MODEST_PROTOCOL_SECURITY_NONE,
649                                                        MODEST_PROTOCOL_AUTH_NONE);
650         if (!modest_account_mgr_account_exists (acc_mgr, smtp_test, FALSE)) 
651                 modest_account_mgr_add_server_account (acc_mgr,
652                                                        smtp_test,
653                                                        "127.0.0.1",
654                                                        NULL,NULL,
655                                                        MODEST_PROTOCOL_TRANSPORT_SMTP,
656                                                        MODEST_PROTOCOL_SECURITY_NONE,
657                                                        MODEST_PROTOCOL_AUTH_NONE);
658         
659         modest_account_mgr_add_account (acc_mgr, imap_test, imap_test, smtp_test);
660         modest_account_mgr_add_account (acc_mgr,  pop_test, pop_test,  smtp_test);
661 }