* Add common "AW:" to list of ignored subject prefixes.
[modest] / src / modest-tny-account-store.c
1 /* modest-tny-account-store.c */
2
3 /* insert (c)/licensing information) */
4
5 #include <string.h>
6
7 #include <tny-account-iface.h>
8 #include <tny-account-store-iface.h>
9 #include <tny-store-account-iface.h>
10 #include <tny-transport-account-iface.h>
11 #include <tny-device-iface.h>
12 #include <tny-device.h>
13 #include <tny-account-store.h>
14
15 #include <tny-store-account.h>
16 #include <tny-transport-account.h>
17
18 #include "modest-account-mgr.h"
19 #include "modest-tny-account-store.h"
20
21 /* 'private'/'protected' functions */
22 static void modest_tny_account_store_class_init   (ModestTnyAccountStoreClass *klass);
23 static void modest_tny_account_store_init         (ModestTnyAccountStore *obj);
24 static void modest_tny_account_store_finalize     (GObject *obj);
25
26 /* implementations for tny-account-store-iface */
27 static void    modest_tny_account_store_iface_init              (gpointer g_iface, gpointer iface_data);
28
29 static void    modest_tny_account_store_add_store_account       (TnyAccountStoreIface *self,
30                                                                TnyStoreAccountIface *account);
31 static void    modest_tny_account_store_add_transport_account   (TnyAccountStoreIface *self,
32                                                                        TnyTransportAccountIface *account);
33 static const GList*  modest_tny_account_store_get_store_accounts      (TnyAccountStoreIface *iface);
34 static const GList*  modest_tny_account_store_get_transport_accounts  (TnyAccountStoreIface *iface);
35
36 /* list my signals */
37 enum {
38         PASSWORD_REQUESTED_SIGNAL,
39         LAST_SIGNAL
40 };
41
42 static const gchar *transport_protocols[] = { "smtp", NULL };
43
44 typedef struct _ModestTnyAccountStorePrivate ModestTnyAccountStorePrivate;
45 struct _ModestTnyAccountStorePrivate {
46
47         GMutex *store_lock;
48         GMutex *transport_lock;
49         GList *store_accounts;
50         GList *transport_accounts;
51         gchar *cache_dir;
52
53         TnySessionCamel *tny_session_camel;
54         TnyDeviceIface  *device;
55
56         ModestAccountMgr *modest_acc_mgr;
57 };
58 #define MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
59                                                       MODEST_TYPE_TNY_ACCOUNT_STORE, \
60                                                       ModestTnyAccountStorePrivate))
61 /* globals */
62 static GObjectClass *parent_class = NULL;
63
64 static guint signals[LAST_SIGNAL] = {0};
65
66 GType
67 modest_tny_account_store_get_type (void)
68 {
69         static GType my_type = 0;
70         if (!my_type) {
71                 static const GTypeInfo my_info = {
72                         sizeof(ModestTnyAccountStoreClass),
73                         NULL,           /* base init */
74                         NULL,           /* base finalize */
75                         (GClassInitFunc) modest_tny_account_store_class_init,
76                         NULL,           /* class finalize */
77                         NULL,           /* class data */
78                         sizeof(ModestTnyAccountStore),
79                         1,              /* n_preallocs */
80                         (GInstanceInitFunc) modest_tny_account_store_init,
81                 };
82
83                 static const GInterfaceInfo iface_info = {
84                         (GInterfaceInitFunc) modest_tny_account_store_iface_init,
85                         NULL,         /* interface_finalize */
86                         NULL          /* interface_data */
87                 };
88                 /* hack hack */
89                 my_type = g_type_register_static (TNY_TYPE_ACCOUNT_STORE,
90                                                   "ModestTnyAccountStore", &my_info, 0);
91
92                 g_type_add_interface_static (my_type, TNY_TYPE_ACCOUNT_STORE_IFACE,
93                                              &iface_info);
94         }
95         return my_type;
96 }
97
98 static void
99 modest_tny_account_store_class_init (ModestTnyAccountStoreClass *klass)
100 {
101         GObjectClass *gobject_class;
102         gobject_class = (GObjectClass*) klass;
103
104         parent_class            = g_type_class_peek_parent (klass);
105         gobject_class->finalize = modest_tny_account_store_finalize;
106
107         g_type_class_add_private (gobject_class,
108                                   sizeof(ModestTnyAccountStorePrivate));
109
110         signals[PASSWORD_REQUESTED_SIGNAL] =
111                 g_signal_new ("password_requested",
112                               G_TYPE_FROM_CLASS (gobject_class),
113                               G_SIGNAL_RUN_FIRST,
114                               G_STRUCT_OFFSET(ModestTnyAccountStoreClass, password_requested),
115                               NULL, NULL,
116                               g_cclosure_marshal_VOID__POINTER,
117                               G_TYPE_NONE, 1, G_TYPE_POINTER);
118 }
119
120 static void
121 modest_tny_account_store_init (ModestTnyAccountStore *obj)
122 {
123         ModestTnyAccountStorePrivate *priv =
124                 MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
125
126         priv->modest_acc_mgr         = NULL;
127         priv->device                 = NULL;
128
129         priv->store_lock             = NULL;
130         priv->transport_lock         = NULL;
131         priv->store_accounts         = NULL;
132         priv->transport_accounts     = NULL;
133         priv->cache_dir              = NULL;
134
135         priv->tny_session_camel      = NULL;
136 }
137
138
139 static void
140 free_gobject (GObject *obj, gpointer user_data)
141 {
142         if (obj)
143                 g_object_unref (obj);
144 }
145
146
147 static GList*
148 free_gobject_list (GList *list)
149 {
150         if (list) {
151                 g_list_foreach (list, (GFunc)free_gobject, NULL);
152                 g_list_free (list);
153         }
154         return NULL;
155 }
156
157 static gchar*
158 get_password (TnyAccountIface *account, const gchar *prompt, gboolean *cancel)
159 {
160         const gchar *key;
161         const TnyAccountStoreIface *account_store;
162         ModestTnyAccountStore *self;
163         ModestTnyAccountStorePrivate *priv;
164         gchar *val;
165
166         g_return_val_if_fail (account, NULL);
167
168         key = tny_account_iface_get_id (account);
169         account_store = tny_account_iface_get_account_store(account);
170
171         self = MODEST_TNY_ACCOUNT_STORE (account_store);
172         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
173
174         val = modest_account_mgr_get_server_account_string (priv->modest_acc_mgr, key,
175                                                                                                 MODEST_ACCOUNT_PASSWORD, NULL);
176         if (!val) {
177                 /* FIXME:
178                  * append the prompt to the emitted signal,
179                  * so the password dialog shows the prompt supplied by the caller of this function.
180                  */
181                 g_signal_emit (G_OBJECT(self), signals[PASSWORD_REQUESTED_SIGNAL], 0, key);
182         }
183
184         return val;
185 }
186
187
188 static void
189 forget_password (TnyAccountIface *account)
190 {
191         g_warning (__FUNCTION__);
192 }
193
194
195 static TnyAccountIface*
196 tny_account_from_key (ModestTnyAccountStore *self, const gchar *key,
197                       gboolean is_store)
198 {
199         TnyAccountIface *tny_account;
200         ModestTnyAccountStorePrivate *priv;
201         gchar *val;
202
203         g_return_val_if_fail (self, NULL);
204         g_return_val_if_fail (key, NULL);
205
206         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
207
208         /* is it a store or a transport? */
209         if (is_store)
210                 tny_account = TNY_ACCOUNT_IFACE(tny_store_account_new ());
211         else
212                 tny_account = TNY_ACCOUNT_IFACE(tny_transport_account_new ());
213
214         if (!tny_account) {
215                 g_warning ("failed to create new tny %s account",
216                            is_store ? "store" : "transport");
217                 return NULL;
218         }
219
220         tny_account_iface_set_account_store (TNY_ACCOUNT_IFACE(tny_account),
221                                              TNY_ACCOUNT_STORE_IFACE(self));
222         /* id */
223         tny_account_iface_set_id (tny_account, key);
224         tny_account_iface_set_name (tny_account, key);
225         
226         /* proto */
227         val = modest_account_mgr_get_server_account_string (priv->modest_acc_mgr, key,
228                                                             MODEST_ACCOUNT_PROTO, NULL);
229         if (val) {
230                 tny_account_iface_set_proto (tny_account, val);
231                 g_free (val);
232         } else {
233                 g_warning ("protocol not defined for %s", key);
234                 g_object_unref (G_OBJECT(tny_account));
235                 return NULL;
236         }
237
238         /* hostname */
239         val = modest_account_mgr_get_server_account_string (priv->modest_acc_mgr, key,
240                                                             MODEST_ACCOUNT_HOSTNAME,
241                                                             NULL);
242         if (val) {
243                 tny_account_iface_set_hostname (tny_account, val);
244                 g_free (val);
245         }
246
247
248         /* username */
249         val = modest_account_mgr_get_server_account_string (priv->modest_acc_mgr, key,
250                                                             MODEST_ACCOUNT_USERNAME,
251                                                             NULL);
252         if (val) {
253                 tny_account_iface_set_user (tny_account, val);
254                 g_free (val);
255         }
256
257         tny_account_iface_set_pass_func (tny_account, get_password);
258         tny_account_iface_set_forget_pass_func (tny_account, forget_password);
259
260         return tny_account;
261 }
262
263
264 static GList*
265 tny_accounts_from_server_accounts (ModestTnyAccountStore *self, GSList *accounts,
266                                    gboolean is_store)
267 {
268         GSList *cursor = accounts;
269         GList *tny_accounts = NULL;
270
271         g_return_val_if_fail (self, NULL);
272
273         while (cursor) {
274                 TnyAccountIface *tny_account;
275                 tny_account = tny_account_from_key (self, (gchar*)cursor->data,
276                                                     is_store);
277                 if (!tny_account) {
278                         g_warning ("could not create tnyaccount for %s",
279                                    (gchar*)cursor->data);
280                 } else {
281                         tny_accounts =
282                                 g_list_append (tny_accounts, tny_account);
283                 }
284                 cursor = cursor->next;
285         }
286
287         return tny_accounts;
288 }
289
290
291 static void 
292 manager_new_account (ModestAccountMgr *modest_acc_mgr, gchar *name, gpointer data)
293 {
294         ModestTnyAccountStore *self = data;
295         ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
296         TnyAccountIface *new_account;
297         gchar *proto;
298         gint i = 0;
299         gboolean is_store = TRUE;
300         
301         g_print ("new account signal %s\n", name);
302         
303         
304         proto = modest_account_mgr_get_server_account_string (priv->modest_acc_mgr, name,
305                                                             MODEST_ACCOUNT_PROTO, NULL);
306         if (!proto) {
307                 g_printerr ("Cannot add account: unknown type.");
308                 return;
309         }
310         
311         while (transport_protocols [i]) {
312                 if (!strcmp (transport_protocols [i], proto)) {
313                         is_store = FALSE;
314                         break;
315                 }
316                 i++;
317         }
318         
319         /* fill account lists */
320         if (!priv->store_accounts)
321                 modest_tny_account_store_get_store_accounts (TNY_ACCOUNT_STORE_IFACE(self));
322         if (!priv->transport_accounts)
323                 modest_tny_account_store_get_transport_accounts (TNY_ACCOUNT_STORE_IFACE(self));
324
325         
326         if (is_store) {
327                         new_account = tny_account_from_key (self, name, is_store);
328                         g_mutex_lock (priv->store_lock);
329                         priv->store_accounts = g_list_append (priv->store_accounts, new_account);
330                         g_mutex_unlock (priv->store_lock);
331         } else {
332                         new_account = tny_account_from_key (self, name, is_store);
333                         g_mutex_lock (priv->transport_lock);
334                         priv->transport_accounts = g_list_append (priv->transport_accounts, new_account);
335                         g_mutex_unlock (priv->transport_lock);
336         }
337         g_signal_emit (self, 
338                 tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNT_INSERTED], 0, new_account);
339 }
340
341
342 static void 
343 manager_remove_account (ModestAccountMgr *modest_acc_mgr, gchar *name, gpointer data)
344 {
345         g_print ("remove account signal %s\n", name);
346 }
347
348
349 static void 
350 manager_change_account (ModestAccountMgr *modest_acc_mgr, gchar *accountname, 
351         gchar *key, gchar* value, gpointer data)
352 {
353         ModestTnyAccountStore *self = data;
354         ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
355         GList *iter;
356         TnyAccountIface *account = NULL;
357         
358         g_print ("account change signal: account: %s key: %s value: %s\n", accountname, key, value);
359         
360         /* fill account lists */
361         if (!priv->store_accounts)
362                 modest_tny_account_store_get_store_accounts (TNY_ACCOUNT_STORE_IFACE(self));
363         if (!priv->transport_accounts)
364                 modest_tny_account_store_get_transport_accounts (TNY_ACCOUNT_STORE_IFACE(self));
365         
366         for (iter = priv->store_accounts; iter; iter = iter->next) {
367                 TnyAccountIface *acc = iter->data;
368                 if (!strcmp (tny_account_iface_get_name (acc), accountname)) {
369                         account = acc;
370                         break;
371                 }
372         }
373         
374         if (!account)
375                 for (iter = priv->transport_accounts; iter; iter = iter->next) {
376                         TnyAccountIface *acc = iter->data;
377                         if (!strcmp (tny_account_iface_get_name (acc), accountname)) {
378                                 account = acc;
379                                 break;
380                         }
381                 }
382         
383         if (!account) {
384                 g_printerr ("Couldn't find account - returning without applying changes.");
385                 return;
386         }
387         
388         g_mutex_lock (priv->store_lock);
389         g_mutex_lock (priv->transport_lock);
390         
391         if (!strcmp (key, MODEST_ACCOUNT_HOSTNAME))
392                 tny_account_iface_set_hostname (account, value);
393         if (!strcmp (key, MODEST_ACCOUNT_USERNAME))
394                 tny_account_iface_set_user (account, value);
395                 
396         g_mutex_unlock (priv->transport_lock);
397         g_mutex_unlock (priv->store_lock);
398                 
399         /* TODO: handle protocol and password changes */
400         g_signal_emit (self,
401                 tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0);
402 }
403
404
405 static void
406 modest_tny_account_store_finalize (GObject *obj)
407 {
408         ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(obj);
409         ModestTnyAccountStorePrivate *priv =
410                 MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
411
412         g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modest_acc_mgr), 
413                 G_CALLBACK(manager_new_account), NULL);
414         g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modest_acc_mgr), 
415                 G_CALLBACK(manager_remove_account), NULL);
416         g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modest_acc_mgr), 
417                 G_CALLBACK(manager_change_account), NULL);
418                 
419         if (priv->modest_acc_mgr) {
420                 g_object_unref (G_OBJECT(priv->modest_acc_mgr));
421                 priv->modest_acc_mgr = NULL;
422         }
423
424         if (priv->tny_session_camel) {
425                 g_object_unref (G_OBJECT(priv->tny_session_camel));
426                 priv->tny_session_camel = NULL;
427         }
428
429         if (priv->device) {
430                 g_object_unref (G_OBJECT(priv->device));
431                 priv->device = NULL;
432         }
433
434         g_mutex_lock (priv->store_lock);
435         priv->store_accounts     = free_gobject_list (priv->store_accounts);
436         g_mutex_unlock (priv->store_lock);
437         
438         g_mutex_lock (priv->transport_lock);
439         priv->transport_accounts = free_gobject_list (priv->store_accounts);
440         g_mutex_unlock (priv->transport_lock);
441
442
443         g_mutex_free (priv->store_lock);
444         g_mutex_free (priv->transport_lock);
445         
446         g_free (priv->cache_dir);
447         priv->cache_dir = NULL;
448
449 }
450
451
452 GObject*
453 modest_tny_account_store_new (ModestAccountMgr *modest_acc_mgr)
454 {
455         GObject *obj;
456         ModestTnyAccountStorePrivate *priv;
457
458         g_return_val_if_fail (modest_acc_mgr, NULL);
459
460         obj  = G_OBJECT(g_object_new(MODEST_TYPE_TNY_ACCOUNT_STORE, NULL));
461
462         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
463         
464         g_object_ref(G_OBJECT(modest_acc_mgr));
465         priv->modest_acc_mgr = modest_acc_mgr;
466         
467         priv->store_lock = g_mutex_new ();
468         priv->transport_lock = g_mutex_new ();
469         
470         priv->device = (TnyDeviceIface*)tny_device_new();
471         if (!priv->device) {
472                 g_warning ("Cannot create Device instance");
473                 g_object_unref (obj);
474                 return NULL;
475         }
476         priv->tny_session_camel = tny_session_camel_new
477                 (TNY_ACCOUNT_STORE_IFACE(obj));
478         if (!priv->tny_session_camel) {
479                 g_warning ("Cannot create TnySessionCamel instance");
480                 g_object_unref (obj);
481                 return NULL;
482         }
483         
484         g_signal_connect (G_OBJECT (modest_acc_mgr), "account-add", 
485                 G_CALLBACK(manager_new_account), obj);
486         g_signal_connect (G_OBJECT (modest_acc_mgr), "account-remove", 
487                 G_CALLBACK(manager_remove_account), obj);
488         g_signal_connect (G_OBJECT (modest_acc_mgr), "account-change", 
489                 G_CALLBACK(manager_change_account), obj);
490
491         return obj;
492 }
493
494
495 static gboolean
496 add_account  (TnyAccountStoreIface *self, TnyAccountIface *account)
497 {
498         TnyAccountIface       *account_iface;
499         ModestTnyAccountStore *account_store;
500         ModestTnyAccountStorePrivate *priv;
501
502         const gchar *account_name;
503         const gchar *hostname, *username, *proto;
504
505         g_return_val_if_fail (self, FALSE);
506         g_return_val_if_fail (account, FALSE);
507
508         account_iface  = TNY_ACCOUNT_IFACE(account);
509         account_store  = MODEST_TNY_ACCOUNT_STORE(self);
510         priv           = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
511
512         account_name   = tny_account_iface_get_id(account_iface);
513         if (!account_name) {
514                 g_warning ("failed to retrieve account name");
515                 return FALSE;
516         }
517
518         hostname =  tny_account_iface_get_hostname(account_iface);
519         username =  tny_account_iface_get_user(account_iface);
520         proto    =  tny_account_iface_get_proto(account_iface);
521
522         return modest_account_mgr_add_server_account (priv->modest_acc_mgr,
523                                                       account_name,
524                                                       hostname, username, NULL,
525                                                       proto);
526 }
527
528
529 static void
530 modest_tny_account_store_add_store_account  (TnyAccountStoreIface *self,
531                                              TnyStoreAccountIface *account)
532 {
533         if (!add_account (self, TNY_ACCOUNT_IFACE(account)))
534                 g_warning ("failed to add store account");
535 }
536
537
538 static void
539 modest_tny_account_store_add_transport_account  (TnyAccountStoreIface *self,
540                                                  TnyTransportAccountIface *account)
541 {
542         if (!add_account (self, TNY_ACCOUNT_IFACE(account)))
543                 g_warning ("failed to add transport account");
544 }
545
546
547 static const GList*
548 modest_tny_account_store_get_store_accounts  (TnyAccountStoreIface *iface)
549 {
550         ModestTnyAccountStore        *self;
551         ModestTnyAccountStorePrivate *priv;
552         GSList                       *accounts;
553
554         g_return_val_if_fail (iface, NULL);
555
556         self = MODEST_TNY_ACCOUNT_STORE(iface);
557         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
558
559         if (!priv->store_accounts) {
560                 accounts =
561                         modest_account_mgr_server_account_names (priv->modest_acc_mgr,
562                                                                  NULL,
563                                                                  MODEST_PROTO_TYPE_STORE,
564                                                                  NULL, FALSE);
565
566                 g_mutex_lock (priv->store_lock);
567                 priv->store_accounts = tny_accounts_from_server_accounts (self, accounts, TRUE);
568                 g_mutex_unlock (priv->store_lock);
569                 g_slist_free (accounts);
570         }       
571
572         return priv->store_accounts;
573 }
574
575
576 static const GList*
577 modest_tny_account_store_get_transport_accounts (TnyAccountStoreIface *iface)
578 {
579         ModestTnyAccountStore        *self;
580         ModestTnyAccountStorePrivate *priv;
581         GSList                       *accounts;
582
583         g_return_val_if_fail (iface, NULL);
584
585         self = MODEST_TNY_ACCOUNT_STORE(iface);
586         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
587
588         
589         if (!priv->transport_accounts) {
590                 accounts =
591                         modest_account_mgr_server_account_names (priv->modest_acc_mgr,
592                                                                  NULL,
593                                                                  MODEST_PROTO_TYPE_TRANSPORT,
594                                                                  NULL, FALSE);
595                 g_mutex_lock (priv->transport_lock);
596                 priv->transport_accounts = tny_accounts_from_server_accounts (self, accounts, FALSE);
597                 g_mutex_unlock (priv->transport_lock);
598                 g_slist_free (accounts);
599         }
600
601
602         return priv->transport_accounts;
603 }
604
605
606 ModestAccountMgr
607 *modest_tny_account_store_get_accout_mgr(ModestTnyAccountStore *self)
608 {
609         ModestTnyAccountStorePrivate *priv;
610         g_return_val_if_fail (self, NULL);
611
612         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
613
614         return priv->modest_acc_mgr;
615 }
616
617
618 TnySessionCamel*
619 tny_account_store_get_session (TnyAccountStore *self)
620 {
621         ModestTnyAccountStorePrivate *priv;
622         g_return_val_if_fail (self, NULL);
623
624         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
625
626         return priv->tny_session_camel;
627 }
628
629
630 /**
631  * modest_tny_account_store_get_cache_dir:
632  * @self: self a TnyAccountStoreIface instance
633  *
634  * returns the pathname of the cache directory
635  *
636  * Returns: a string with the value of the pathname
637  * to the cache directory or NULL if the environment variable $HOME is
638  * not set. string should _not_ be freed by caller
639  */
640 static const gchar*
641 modest_tny_account_store_get_cache_dir (TnyAccountStoreIface *self)
642 {
643         ModestTnyAccountStorePrivate *priv;
644         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
645
646         if (!priv->cache_dir) {
647                 if (g_getenv("HOME") != NULL)
648                         priv->cache_dir = g_strconcat(g_getenv("HOME"),
649                                                       "/.modest/cache/", NULL);
650         }
651         return priv->cache_dir;
652 }
653
654
655 static const TnyDeviceIface*
656 modest_tny_account_store_get_device (TnyAccountStoreIface *self)
657 {
658         ModestTnyAccountStorePrivate *priv;
659
660         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
661
662         return priv->device;
663 }
664
665
666 static void
667 modest_tny_account_store_iface_init (gpointer g_iface, gpointer iface_data)
668 {
669         TnyAccountStoreIfaceClass *klass;
670
671         g_return_if_fail (g_iface);
672
673         klass = (TnyAccountStoreIfaceClass *)g_iface;
674
675         klass->add_store_account_func      =
676                 modest_tny_account_store_add_store_account;
677         klass->get_store_accounts_func     =
678                 modest_tny_account_store_get_store_accounts;
679         klass->add_transport_account_func  =
680                 modest_tny_account_store_add_transport_account;
681         klass->get_transport_accounts_func =
682                 modest_tny_account_store_get_transport_accounts;
683         klass->get_cache_dir_func =
684                 modest_tny_account_store_get_cache_dir;
685         klass->get_device_func =
686                 modest_tny_account_store_get_device;
687 }