* Implement account change and add signals and data.
[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         
401         g_signal_emit (self,
402                 tny_account_store_iface_signals [TNY_ACCOUNT_STORE_IFACE_ACCOUNTS_RELOADED], 0);
403                 
404 }
405
406
407 static void
408 modest_tny_account_store_finalize (GObject *obj)
409 {
410         ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(obj);
411         ModestTnyAccountStorePrivate *priv =
412                 MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
413
414         g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modest_acc_mgr), 
415                 G_CALLBACK(manager_new_account), NULL);
416         g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modest_acc_mgr), 
417                 G_CALLBACK(manager_remove_account), NULL);
418         g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modest_acc_mgr), 
419                 G_CALLBACK(manager_change_account), NULL);
420                 
421         if (priv->modest_acc_mgr) {
422                 g_object_unref (G_OBJECT(priv->modest_acc_mgr));
423                 priv->modest_acc_mgr = NULL;
424         }
425
426         if (priv->tny_session_camel) {
427                 g_object_unref (G_OBJECT(priv->tny_session_camel));
428                 priv->tny_session_camel = NULL;
429         }
430
431         if (priv->device) {
432                 g_object_unref (G_OBJECT(priv->device));
433                 priv->device = NULL;
434         }
435
436         g_mutex_lock (priv->store_lock);
437         priv->store_accounts     = free_gobject_list (priv->store_accounts);
438         g_mutex_unlock (priv->store_lock);
439         
440         g_mutex_lock (priv->transport_lock);
441         priv->transport_accounts = free_gobject_list (priv->store_accounts);
442         g_mutex_unlock (priv->transport_lock);
443
444
445         g_mutex_free (priv->store_lock);
446         g_mutex_free (priv->transport_lock);
447         
448         g_free (priv->cache_dir);
449         priv->cache_dir = NULL;
450
451 }
452
453
454 GObject*
455 modest_tny_account_store_new (ModestAccountMgr *modest_acc_mgr)
456 {
457         GObject *obj;
458         ModestTnyAccountStorePrivate *priv;
459
460         g_return_val_if_fail (modest_acc_mgr, NULL);
461
462         obj  = G_OBJECT(g_object_new(MODEST_TYPE_TNY_ACCOUNT_STORE, NULL));
463
464         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
465         
466         g_object_ref(G_OBJECT(modest_acc_mgr));
467         priv->modest_acc_mgr = modest_acc_mgr;
468         
469         priv->store_lock = g_mutex_new ();
470         priv->transport_lock = g_mutex_new ();
471         
472         priv->device = (TnyDeviceIface*)tny_device_new();
473         if (!priv->device) {
474                 g_warning ("Cannot create Device instance");
475                 g_object_unref (obj);
476                 return NULL;
477         }
478         priv->tny_session_camel = tny_session_camel_new
479                 (TNY_ACCOUNT_STORE_IFACE(obj));
480         if (!priv->tny_session_camel) {
481                 g_warning ("Cannot create TnySessionCamel instance");
482                 g_object_unref (obj);
483                 return NULL;
484         }
485         
486         g_signal_connect (G_OBJECT (modest_acc_mgr), "account-add", 
487                 G_CALLBACK(manager_new_account), obj);
488         g_signal_connect (G_OBJECT (modest_acc_mgr), "account-remove", 
489                 G_CALLBACK(manager_remove_account), obj);
490         g_signal_connect (G_OBJECT (modest_acc_mgr), "account-change", 
491                 G_CALLBACK(manager_change_account), obj);
492
493         return obj;
494 }
495
496
497 static gboolean
498 add_account  (TnyAccountStoreIface *self, TnyAccountIface *account)
499 {
500         TnyAccountIface       *account_iface;
501         ModestTnyAccountStore *account_store;
502         ModestTnyAccountStorePrivate *priv;
503
504         const gchar *account_name;
505         const gchar *hostname, *username, *proto;
506
507         g_return_val_if_fail (self, FALSE);
508         g_return_val_if_fail (account, FALSE);
509
510         account_iface  = TNY_ACCOUNT_IFACE(account);
511         account_store  = MODEST_TNY_ACCOUNT_STORE(self);
512         priv           = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
513
514         account_name   = tny_account_iface_get_id(account_iface);
515         if (!account_name) {
516                 g_warning ("failed to retrieve account name");
517                 return FALSE;
518         }
519
520         hostname =  tny_account_iface_get_hostname(account_iface);
521         username =  tny_account_iface_get_user(account_iface);
522         proto    =  tny_account_iface_get_proto(account_iface);
523
524         return modest_account_mgr_add_server_account (priv->modest_acc_mgr,
525                                                       account_name,
526                                                       hostname, username, NULL,
527                                                       proto);
528 }
529
530
531 static void
532 modest_tny_account_store_add_store_account  (TnyAccountStoreIface *self,
533                                              TnyStoreAccountIface *account)
534 {
535         if (!add_account (self, TNY_ACCOUNT_IFACE(account)))
536                 g_warning ("failed to add store account");
537 }
538
539
540 static void
541 modest_tny_account_store_add_transport_account  (TnyAccountStoreIface *self,
542                                                  TnyTransportAccountIface *account)
543 {
544         if (!add_account (self, TNY_ACCOUNT_IFACE(account)))
545                 g_warning ("failed to add transport account");
546 }
547
548
549 static const GList*
550 modest_tny_account_store_get_store_accounts  (TnyAccountStoreIface *iface)
551 {
552         ModestTnyAccountStore        *self;
553         ModestTnyAccountStorePrivate *priv;
554         GSList                       *accounts;
555
556         g_return_val_if_fail (iface, NULL);
557
558         self = MODEST_TNY_ACCOUNT_STORE(iface);
559         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
560
561         if (!priv->store_accounts) {
562                 accounts =
563                         modest_account_mgr_server_account_names (priv->modest_acc_mgr,
564                                                                  NULL,
565                                                                  MODEST_PROTO_TYPE_STORE,
566                                                                  NULL, FALSE);
567
568                 g_mutex_lock (priv->store_lock);
569                 priv->store_accounts = tny_accounts_from_server_accounts (self, accounts, TRUE);
570                 g_mutex_unlock (priv->store_lock);
571                 g_slist_free (accounts);
572         }       
573
574         return priv->store_accounts;
575 }
576
577
578 static const GList*
579 modest_tny_account_store_get_transport_accounts (TnyAccountStoreIface *iface)
580 {
581         ModestTnyAccountStore        *self;
582         ModestTnyAccountStorePrivate *priv;
583         GSList                       *accounts;
584
585         g_return_val_if_fail (iface, NULL);
586
587         self = MODEST_TNY_ACCOUNT_STORE(iface);
588         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
589
590         
591         if (!priv->transport_accounts) {
592                 accounts =
593                         modest_account_mgr_server_account_names (priv->modest_acc_mgr,
594                                                                  NULL,
595                                                                  MODEST_PROTO_TYPE_TRANSPORT,
596                                                                  NULL, FALSE);
597                 g_mutex_lock (priv->transport_lock);
598                 priv->transport_accounts = tny_accounts_from_server_accounts (self, accounts, FALSE);
599                 g_mutex_unlock (priv->transport_lock);
600                 g_slist_free (accounts);
601         }
602
603
604         return priv->transport_accounts;
605 }
606
607
608 ModestAccountMgr
609 *modest_tny_account_store_get_accout_mgr(ModestTnyAccountStore *self)
610 {
611         ModestTnyAccountStorePrivate *priv;
612         g_return_val_if_fail (self, NULL);
613
614         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
615
616         return priv->modest_acc_mgr;
617 }
618
619
620 TnySessionCamel*
621 tny_account_store_get_session (TnyAccountStore *self)
622 {
623         ModestTnyAccountStorePrivate *priv;
624         g_return_val_if_fail (self, NULL);
625
626         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
627
628         return priv->tny_session_camel;
629 }
630
631
632 /**
633  * modest_tny_account_store_get_cache_dir:
634  * @self: self a TnyAccountStoreIface instance
635  *
636  * returns the pathname of the cache directory
637  *
638  * Returns: a string with the value of the pathname
639  * to the cache directory or NULL if the environment variable $HOME is
640  * not set. string should _not_ be freed by caller
641  */
642 static const gchar*
643 modest_tny_account_store_get_cache_dir (TnyAccountStoreIface *self)
644 {
645         ModestTnyAccountStorePrivate *priv;
646         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
647
648         if (!priv->cache_dir) {
649                 if (g_getenv("HOME") != NULL)
650                         priv->cache_dir = g_strconcat(g_getenv("HOME"),
651                                                       "/.modest/cache/", NULL);
652         }
653         return priv->cache_dir;
654 }
655
656
657 static const TnyDeviceIface*
658 modest_tny_account_store_get_device (TnyAccountStoreIface *self)
659 {
660         ModestTnyAccountStorePrivate *priv;
661
662         priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
663
664         return priv->device;
665 }
666
667
668 static void
669 modest_tny_account_store_iface_init (gpointer g_iface, gpointer iface_data)
670 {
671         TnyAccountStoreIfaceClass *klass;
672
673         g_return_if_fail (g_iface);
674
675         klass = (TnyAccountStoreIfaceClass *)g_iface;
676
677         klass->add_store_account_func      =
678                 modest_tny_account_store_add_store_account;
679         klass->get_store_accounts_func     =
680                 modest_tny_account_store_get_store_accounts;
681         klass->add_transport_account_func  =
682                 modest_tny_account_store_add_transport_account;
683         klass->get_transport_accounts_func =
684                 modest_tny_account_store_get_transport_accounts;
685         klass->get_cache_dir_func =
686                 modest_tny_account_store_get_cache_dir;
687         klass->get_device_func =
688                 modest_tny_account_store_get_device;
689 }