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 <modest-tny-platform-factory.h>
31 #include <modest-tny-account.h>
32 #include <modest-tny-account-store.h>
33 #include <modest-runtime.h>
34 #include <tny-simple-list.h>
35 #include <modest-tny-folder.h>
36 #include <modest-tny-outbox-account.h>
37 #include <modest-account-mgr-helpers.h>
38 #include <modest-init.h>
39 #include <tny-camel-transport-account.h>
40 #include <tny-camel-imap-store-account.h>
41 #include <tny-camel-pop-store-account.h>
42 #include <tny-folder-stats.h>
43 #include <hildon-widgets/hildon-file-system-info.h>
48 modest_tny_account_get_special_folder (TnyAccount *account,
49 TnyFolderType special_type)
53 TnyFolder *special_folder = NULL;
56 g_return_val_if_fail (account, NULL);
57 g_return_val_if_fail (0 <= special_type && special_type < TNY_FOLDER_TYPE_NUM,
60 TnyAccount *local_account = NULL;
62 /* The accounts have already been instantiated by
63 * modest_tny_account_store_get_accounts(), which is the
64 * TnyAccountStore::get_accounts_func() implementation,
65 * so we just get them here.
68 /* Per-account outbox folders are each in their own on-disk directory: */
69 if (special_type == TNY_FOLDER_TYPE_OUTBOX) {
70 const gchar *modest_account_name =
71 modest_tny_account_get_parent_modest_account_name_for_server_account (account);
72 g_assert (modest_account_name);
74 gchar *account_id = g_strdup_printf (
75 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
78 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
82 /* Other local folders are all in one on-disk directory: */
83 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
84 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
88 g_printerr ("modest: cannot get local account\n");
92 folders = TNY_LIST (tny_simple_list_new ());
94 /* There is no need to do this _async, as these are local folders. */
95 /* TODO: However, this seems to fail sometimes when the network is busy,
96 * returning an empty list. murrayc. */
97 tny_folder_store_get_folders (TNY_FOLDER_STORE (local_account),
99 iter = tny_list_create_iterator (folders);
101 while (!tny_iterator_is_done (iter)) {
103 TNY_FOLDER (tny_iterator_get_current (iter));
104 if (modest_tny_folder_get_local_folder_type (folder) == special_type) {
105 special_folder = folder;
109 g_object_unref (G_OBJECT(folder));
110 tny_iterator_next (iter);
113 g_object_unref (G_OBJECT (folders));
114 g_object_unref (G_OBJECT (iter));
115 g_object_unref (G_OBJECT (local_account));
117 return special_folder;
122 /* These seem to be listed in
123 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
125 #define MODEST_ACCOUNT_OPTION_SSL "use_ssl"
126 #define MODEST_ACCOUNT_OPTION_SSL_NEVER "never"
127 #define MODEST_ACCOUNT_OPTION_SSL_ALWAYS "always"
128 #define MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE "when-possible"
130 /* These seem to be listed in
131 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-provider.c
133 #define MODEST_ACCOUNT_OPTION_USE_LSUB "use_lsub" /* Show only subscribed folders */
134 #define MODEST_ACCOUNT_OPTION_CHECK_ALL "check_all" /* Check for new messages in all folders */
137 /* Posssible values for tny_account_set_secure_auth_mech().
138 * These might be camel-specific.
139 * Really, tinymail should use an enum.
140 * camel_sasl_authtype() seems to list some possible values.
143 /* Note that evolution does not offer these for IMAP: */
144 #define MODEST_ACCOUNT_AUTH_PLAIN "PLAIN"
145 #define MODEST_ACCOUNT_AUTH_ANONYMOUS "ANONYMOUS"
147 /* Caeml's IMAP uses NULL instead for "Password".
148 * Also, not that Evolution offers "Password" for IMAP, but "Login" for SMTP.*/
149 #define MODEST_ACCOUNT_AUTH_PASSWORD "LOGIN"
150 #define MODEST_ACCOUNT_AUTH_CRAMMD5 "CRAM-MD5"
155 * modest_tny_account_new_from_server_account:
156 * @account_mgr: a valid account mgr instance
157 * @account_name: the server account name for which to create a corresponding tny account
158 * @type: the type of account to create (TNY_ACCOUNT_TYPE_STORE or TNY_ACCOUNT_TYPE_TRANSPORT)
160 * get a tnyaccount corresponding to the server_accounts (store or transport) for this account.
161 * NOTE: this function does not set the camel session or the get/forget password functions
163 * Returns: a new TnyAccount or NULL in case of error.
166 modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr,
167 ModestServerAccountData *account_data)
171 g_return_val_if_fail (account_mgr, NULL);
172 g_return_val_if_fail (account_data, NULL);
175 if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN) {
176 g_printerr ("modest: '%s' does not provide a protocol\n",
177 account_data->account_name);
181 TnyAccount *tny_account = NULL;
183 switch (account_data->proto) {
184 case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
185 case MODEST_PROTOCOL_TRANSPORT_SMTP:
186 tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
187 case MODEST_PROTOCOL_STORE_POP:
188 tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
189 case MODEST_PROTOCOL_STORE_IMAP:
190 tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
191 case MODEST_PROTOCOL_STORE_MAILDIR:
192 case MODEST_PROTOCOL_STORE_MBOX:
193 /* Note that this is not where we create the special local folders account.
194 * That happens in modest_tny_account_new_for_local_folders() instead.
196 tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
198 g_return_val_if_reached (NULL);
201 g_printerr ("modest: could not create tny account for '%s'\n",
202 account_data->account_name);
205 tny_account_set_id (tny_account, account_data->account_name);
208 const gchar* proto_name =
209 modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
210 tny_account_set_proto (tny_account, proto_name);
213 /* mbox and maildir accounts use a URI instead of the rest:
214 * Note that this is not where we create the special local folders account.
215 * We do that in modest_tny_account_new_for_local_folders() instead. */
216 if (account_data->uri) {
217 tny_account_set_url_string (TNY_ACCOUNT(tny_account), account_data->uri);
218 /* g_message ("DEBUG: %s: local account-url:\n %s", __FUNCTION__, account_data->uri); */
221 /* Set camel-specific options: */
223 /* Enable secure connection settings: */
224 /* printf("DEBUG: %s: security=%d\n", __FUNCTION__, account_data->security); */
225 const gchar* option_security = NULL;
226 switch (account_data->security) {
227 case MODEST_PROTOCOL_CONNECTION_NORMAL:
228 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_NEVER;
230 case MODEST_PROTOCOL_CONNECTION_SSL:
231 case MODEST_PROTOCOL_CONNECTION_TLS:
232 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_ALWAYS;;
234 case MODEST_PROTOCOL_CONNECTION_TLS_OP:
235 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE;
242 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
245 /* Secure authentication: */
246 /* printf("DEBUG: %s: secure-auth=%d\n", __FUNCTION__, account_data->secure_auth); */
247 const gchar* auth_mech_name = NULL;
248 switch (account_data->secure_auth) {
249 case MODEST_PROTOCOL_AUTH_NONE:
250 /* IMAP and POP need at least a password,
251 * which camel uses if we specify NULL.
252 * This setting should never happen anyway. */
253 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP ||
254 account_data->proto == MODEST_PROTOCOL_STORE_POP)
255 auth_mech_name = NULL;
256 else if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_SMTP)
257 auth_mech_name = MODEST_ACCOUNT_AUTH_ANONYMOUS;
259 auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN;
262 case MODEST_PROTOCOL_AUTH_PASSWORD:
263 /* Camel use a password for IMAP or POP if we specify NULL,
264 * For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
265 * (POP is know to report an error for Login too. Probably Password and Plain too.) */
266 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP)
267 auth_mech_name = NULL;
268 else if (account_data->proto == MODEST_PROTOCOL_STORE_POP)
269 auth_mech_name = NULL;
271 auth_mech_name = MODEST_ACCOUNT_AUTH_PASSWORD;
274 case MODEST_PROTOCOL_AUTH_CRAMMD5:
275 auth_mech_name = MODEST_ACCOUNT_AUTH_CRAMMD5;
279 g_warning ("%s: Unhandled secure authentication setting %d for "
280 "account=%s (%s)", __FUNCTION__, account_data->secure_auth,
281 account_data->account_name, account_data->hostname);
286 tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
288 if (modest_protocol_info_protocol_is_store(account_data->proto) &&
289 (account_data->proto == MODEST_PROTOCOL_STORE_IMAP) ) {
290 /* Other connection options, needed for IMAP. */
291 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
292 MODEST_ACCOUNT_OPTION_USE_LSUB);
293 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
294 MODEST_ACCOUNT_OPTION_CHECK_ALL);
297 if (account_data->username)
298 tny_account_set_user (tny_account, account_data->username);
299 if (account_data->hostname)
300 tny_account_set_hostname (tny_account, account_data->hostname);
303 if (account_data->port)
304 tny_account_set_port (tny_account, account_data->port);
307 /* FIXME: for debugging */
308 url = tny_account_get_url_string (TNY_ACCOUNT(tny_account));
309 /* g_message ("modest: %s:\n account-url: %s", __FUNCTION__, url); */
311 /***********************/
317 modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
318 const gchar *server_account_name)
320 ModestServerAccountData *account_data =
321 modest_account_mgr_get_server_account_data (account_mgr,
322 server_account_name);
326 TnyAccount *result = modest_tny_account_new_from_server_account (
327 account_mgr, account_data);
329 modest_account_mgr_free_server_account_data (account_mgr, account_data);
335 /* we need these dummy functions, or tinymail will complain */
337 get_pass_dummy (TnyAccount *account, const gchar *prompt, gboolean *cancel)
342 forget_pass_dummy (TnyAccount *account)
344 /* intentionally left blank */
348 modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar *account_name,
350 TnySessionCamel *session,
351 TnyGetPassFunc get_pass_func,
352 TnyForgetPassFunc forget_pass_func)
354 TnyAccount *tny_account = NULL;
355 ModestAccountData *account_data = NULL;
356 ModestServerAccountData *server_data = NULL;
358 g_return_val_if_fail (account_mgr, NULL);
359 g_return_val_if_fail (account_name, NULL);
361 account_data = modest_account_mgr_get_account_data (account_mgr, account_name);
363 g_printerr ("modest: %s: cannot get account data for account %s\n", __FUNCTION__, account_name);
367 if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
368 server_data = account_data->store_account;
369 else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
370 server_data = account_data->transport_account;
372 g_printerr ("modest: no %s account defined for '%s'\n",
373 type == TNY_ACCOUNT_TYPE_STORE ? "store" : "transport",
374 account_data->display_name);
375 modest_account_mgr_free_account_data (account_mgr, account_data);
379 tny_account = modest_tny_account_new_from_server_account (account_mgr, server_data);
381 g_printerr ("modest: failed to create tny account for %s (%s)\n",
382 account_data->account_name, server_data->account_name);
383 modest_account_mgr_free_account_data (account_mgr, account_data);
387 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
388 tny_account_set_forget_pass_func (tny_account,
389 forget_pass_func ? forget_pass_func : forget_pass_dummy);
390 tny_account_set_pass_func (tny_account,
391 get_pass_func ? get_pass_func: get_pass_dummy);
393 /* This name is what shows up in the folder view -- so for some POP/IMAP/... server
394 * account, we set its name to the account of which it is part. */
395 if (account_data->display_name)
396 tny_account_set_name (tny_account, account_data->display_name);
398 modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, account_name);
400 modest_account_mgr_free_account_data (account_mgr, account_data);
405 /* TODO: Notify the treemodel somehow that the display name
406 * is now available. We should probably request this from the cell_data_func
407 * so we can provide a treerowreference. */
409 on_modest_file_system_info(HildonFileSystemInfoHandle *handle,
410 HildonFileSystemInfo *info,
411 const GError *error, gpointer data)
413 TnyAccount *account = TNY_ACCOUNT (data);
416 printf (" DEBUG: %s: error=%s\n", __FUNCTION__, error->message);
419 const gchar *display_name = NULL;
420 if (!error && info) {
421 display_name = hildon_file_system_info_get_display_name(info);
425 /* printf ("DEBUG: %s: display name=%s\n", __FUNCTION__, display_name); */
426 tny_account_set_name (account, display_name);
432 modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySessionCamel *session, const gchar* location_filepath)
434 /* Make sure that the directories exist: */
435 modest_init_local_folders (location_filepath);
437 TnyStoreAccount *tny_account;
439 gchar *maildir, *url_string;
441 g_return_val_if_fail (account_mgr, NULL);
443 tny_account = tny_camel_store_account_new ();
445 g_printerr ("modest: cannot create account for local folders");
448 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
450 /* This path contains directories for each local folder.
451 * We have created them so that TnyCamelStoreAccount can find them
452 * and report a folder for each directory: */
453 maildir = modest_local_folder_info_get_maildir_path (location_filepath);
454 url = camel_url_new ("maildir:", NULL);
455 camel_url_set_path (url, maildir);
456 /* Needed by tinymail's DBC assertions */
457 camel_url_set_host (url, "localhost");
458 url_string = camel_url_to_string (url, 0);
460 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
461 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
463 /* TODO: Use a more generic way of identifying memory card paths,
464 * and of marking accounts as memory card accounts, maybe
465 * via a derived TnyCamelStoreAccount ? */
466 const gboolean is_mmc =
468 (strcmp (location_filepath, MODEST_MCC1_VOLUMEPATH) == 0);
470 /* The name of memory card locations will be updated asynchronously.
471 * This is just a default: */
472 const gchar *name = is_mmc ? _("Memory Card") :
473 MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME;
474 tny_account_set_name (TNY_ACCOUNT(tny_account), name);
476 /* Get the correct display name for memory cards, asynchronously: */
477 if (location_filepath) {
478 GError *error = NULL;
479 gchar *uri = g_filename_to_uri(location_filepath, NULL, &error);
481 g_warning ("%s: g_filename_to_uri(%s) failed: %s", __FUNCTION__,
482 location_filepath, error->message);
483 g_error_free (error);
486 /* TODO: gnome_vfs_volume_get_display_name() does not return
487 * the same string. But why not? Why does hildon needs its own
490 hildon_file_system_info_async_new(uri,
491 on_modest_file_system_info, tny_account /* user_data */);
499 const gchar* id = is_mmc ? MODEST_MMC_ACCOUNT_ID :
500 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID;
501 tny_account_set_id (TNY_ACCOUNT(tny_account), id);
503 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
504 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
506 modest_tny_account_set_parent_modest_account_name_for_server_account (
507 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
509 camel_url_free (url);
513 return TNY_ACCOUNT(tny_account);
518 modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, const gchar* account_name, TnySessionCamel *session)
520 g_return_val_if_fail (account_mgr, NULL);
521 g_return_val_if_fail (account_name, NULL);
523 /* Notice that we create a ModestTnyOutboxAccount here,
524 * instead of just a TnyCamelStoreAccount,
525 * so that we can later identify this as a special account for internal use only.
527 TnyStoreAccount *tny_account = TNY_STORE_ACCOUNT (modest_tny_outbox_account_new ());
529 g_printerr ("modest: cannot create account for per-account local outbox folder.");
533 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
535 /* Make sure that the paths exists on-disk so that TnyCamelStoreAccount can
536 * find it to create a TnyFolder for it: */
537 gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account_name);
538 modest_init_one_local_folder(folder_dir);
542 /* This path should contain just one directory - "outbox": */
544 modest_per_account_local_outbox_folder_info_get_maildir_path (account_name);
546 CamelURL *url = camel_url_new ("maildir:", NULL);
547 camel_url_set_path (url, maildir);
550 /* Needed by tinymail's DBC assertions */
551 camel_url_set_host (url, "localhost");
552 gchar *url_string = camel_url_to_string (url, 0);
553 camel_url_free (url);
555 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
556 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
559 /* This text should never been seen,
560 * because the per-account outbox accounts are not seen directly by the user.
561 * Their folders are merged and shown as one folder. */
562 tny_account_set_name (TNY_ACCOUNT(tny_account), "Per-Account Outbox");
564 gchar *account_id = g_strdup_printf (
565 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
567 tny_account_set_id (TNY_ACCOUNT(tny_account), account_id);
570 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
571 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
573 /* Make this think that it belongs to the modest local-folders parent account: */
574 modest_tny_account_set_parent_modest_account_name_for_server_account (
575 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
577 return TNY_ACCOUNT(tny_account);
582 typedef gint (*TnyStatsFunc) (TnyFolderStats *stats);
584 typedef struct _RecurseFoldersHelper {
585 TnyStatsFunc function;
588 } RecurseFoldersHelper;
591 recurse_folders (TnyFolderStore *store,
592 TnyFolderStoreQuery *query,
593 RecurseFoldersHelper *helper)
596 TnyList *folders = tny_simple_list_new ();
598 tny_folder_store_get_folders (store, folders, query, NULL);
599 iter = tny_list_create_iterator (folders);
601 helper->folders += tny_list_get_length (folders);
603 while (!tny_iterator_is_done (iter)) {
604 TnyFolderStats *stats;
607 folder = TNY_FOLDER (tny_iterator_get_current (iter));
608 stats = tny_folder_get_stats (folder);
610 /* initially, we sometimes get -1 from tinymail; ignore that */
611 if (helper->function && helper->function (stats) > 0)
612 helper->sum += helper->function (stats);
614 if (TNY_IS_FOLDER_STORE (folder)) {
615 recurse_folders (TNY_FOLDER_STORE (folder), query, helper);
618 g_object_unref (folder);
619 g_object_unref (stats);
620 tny_iterator_next (iter);
622 g_object_unref (G_OBJECT (iter));
623 g_object_unref (G_OBJECT (folders));
627 modest_tny_folder_store_get_folder_count (TnyFolderStore *self)
629 RecurseFoldersHelper *helper;
632 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
635 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
636 helper->function = NULL;
640 recurse_folders (self, NULL, helper);
642 retval = helper->folders;
650 modest_tny_folder_store_get_message_count (TnyFolderStore *self)
652 RecurseFoldersHelper *helper;
655 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
658 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
659 helper->function = (TnyStatsFunc) tny_folder_stats_get_all_count;
662 recurse_folders (self, NULL, helper);
664 retval = helper->sum;
672 modest_tny_folder_store_get_local_size (TnyFolderStore *self)
674 RecurseFoldersHelper *helper;
677 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
680 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
681 helper->function = (TnyStatsFunc) tny_folder_stats_get_local_size;
684 recurse_folders (self, NULL, helper);
686 retval = helper->sum;
693 const gchar* modest_tny_account_get_parent_modest_account_name_for_server_account (TnyAccount *self)
695 return (const gchar *)g_object_get_data (G_OBJECT (self), "modest_account");
698 void modest_tny_account_set_parent_modest_account_name_for_server_account (TnyAccount *self, const gchar* parent_modest_acount_name)
700 g_object_set_data_full (G_OBJECT(self), "modest_account",
701 (gpointer*) g_strdup (parent_modest_acount_name), g_free);