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>
44 #ifdef MODEST_HILDON_VERSION_0
45 #include <hildon-widgets/hildon-file-system-info.h>
47 #include <hildon/hildon-file-system-info.h>
51 modest_tny_account_get_special_folder (TnyAccount *account,
52 TnyFolderType special_type)
56 TnyFolder *special_folder = NULL;
59 g_return_val_if_fail (account, NULL);
60 g_return_val_if_fail (0 <= special_type && special_type < TNY_FOLDER_TYPE_NUM,
63 TnyAccount *local_account = NULL;
65 /* The accounts have already been instantiated by
66 * modest_tny_account_store_get_accounts(), which is the
67 * TnyAccountStore::get_accounts_func() implementation,
68 * so we just get them here.
71 /* Per-account outbox folders are each in their own on-disk directory: */
72 if (special_type == TNY_FOLDER_TYPE_OUTBOX) {
73 const gchar *modest_account_name =
74 modest_tny_account_get_parent_modest_account_name_for_server_account (account);
75 g_assert (modest_account_name);
77 gchar *account_id = g_strdup_printf (
78 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
81 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
85 /* Other local folders are all in one on-disk directory: */
86 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
87 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
91 g_printerr ("modest: cannot get local account\n");
95 folders = TNY_LIST (tny_simple_list_new ());
97 /* There is no need to do this _async, as these are local folders. */
98 /* TODO: However, this seems to fail sometimes when the network is busy,
99 * returning an empty list. murrayc. */
100 tny_folder_store_get_folders (TNY_FOLDER_STORE (local_account),
101 folders, NULL, NULL);
102 iter = tny_list_create_iterator (folders);
104 while (!tny_iterator_is_done (iter)) {
106 TNY_FOLDER (tny_iterator_get_current (iter));
107 if (modest_tny_folder_get_local_folder_type (folder) == special_type) {
108 special_folder = folder;
112 g_object_unref (G_OBJECT(folder));
113 tny_iterator_next (iter);
116 g_object_unref (G_OBJECT (folders));
117 g_object_unref (G_OBJECT (iter));
118 g_object_unref (G_OBJECT (local_account));
120 return special_folder;
125 /* These seem to be listed in
126 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
128 #define MODEST_ACCOUNT_OPTION_SSL "use_ssl"
129 #define MODEST_ACCOUNT_OPTION_SSL_NEVER "never"
130 #define MODEST_ACCOUNT_OPTION_SSL_ALWAYS "always"
131 #define MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE "when-possible"
133 /* These seem to be listed in
134 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-provider.c
136 #define MODEST_ACCOUNT_OPTION_USE_LSUB "use_lsub" /* Show only subscribed folders */
137 #define MODEST_ACCOUNT_OPTION_CHECK_ALL "check_all" /* Check for new messages in all folders */
140 /* Posssible values for tny_account_set_secure_auth_mech().
141 * These might be camel-specific.
142 * Really, tinymail should use an enum.
143 * camel_sasl_authtype() seems to list some possible values.
146 /* Note that evolution does not offer these for IMAP: */
147 #define MODEST_ACCOUNT_AUTH_PLAIN "PLAIN"
148 #define MODEST_ACCOUNT_AUTH_ANONYMOUS "ANONYMOUS"
150 /* Caeml's IMAP uses NULL instead for "Password".
151 * Also, not that Evolution offers "Password" for IMAP, but "Login" for SMTP.*/
152 #define MODEST_ACCOUNT_AUTH_PASSWORD "LOGIN"
153 #define MODEST_ACCOUNT_AUTH_CRAMMD5 "CRAM-MD5"
158 * modest_tny_account_new_from_server_account:
159 * @account_mgr: a valid account mgr instance
160 * @account_name: the server account name for which to create a corresponding tny account
161 * @type: the type of account to create (TNY_ACCOUNT_TYPE_STORE or TNY_ACCOUNT_TYPE_TRANSPORT)
163 * get a tnyaccount corresponding to the server_accounts (store or transport) for this account.
164 * NOTE: this function does not set the camel session or the get/forget password functions
166 * Returns: a new TnyAccount or NULL in case of error.
169 modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr,
170 ModestServerAccountData *account_data)
174 g_return_val_if_fail (account_mgr, NULL);
175 g_return_val_if_fail (account_data, NULL);
178 if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN) {
179 g_printerr ("modest: '%s' does not provide a protocol\n",
180 account_data->account_name);
184 TnyAccount *tny_account = NULL;
186 switch (account_data->proto) {
187 case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
188 case MODEST_PROTOCOL_TRANSPORT_SMTP:
189 tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
190 case MODEST_PROTOCOL_STORE_POP:
191 tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
192 case MODEST_PROTOCOL_STORE_IMAP:
193 tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
194 case MODEST_PROTOCOL_STORE_MAILDIR:
195 case MODEST_PROTOCOL_STORE_MBOX:
196 /* Note that this is not where we create the special local folders account.
197 * That happens in modest_tny_account_new_for_local_folders() instead.
199 tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
201 g_return_val_if_reached (NULL);
204 g_printerr ("modest: could not create tny account for '%s'\n",
205 account_data->account_name);
208 tny_account_set_id (tny_account, account_data->account_name);
211 const gchar* proto_name =
212 modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
213 tny_account_set_proto (tny_account, proto_name);
216 /* mbox and maildir accounts use a URI instead of the rest:
217 * Note that this is not where we create the special local folders account.
218 * We do that in modest_tny_account_new_for_local_folders() instead. */
219 if (account_data->uri) {
220 tny_account_set_url_string (TNY_ACCOUNT(tny_account), account_data->uri);
221 /* g_message ("DEBUG: %s: local account-url:\n %s", __FUNCTION__, account_data->uri); */
224 /* Set camel-specific options: */
226 /* Enable secure connection settings: */
227 /* printf("DEBUG: %s: security=%d\n", __FUNCTION__, account_data->security); */
228 const gchar* option_security = NULL;
229 switch (account_data->security) {
230 case MODEST_PROTOCOL_CONNECTION_NORMAL:
231 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_NEVER;
233 case MODEST_PROTOCOL_CONNECTION_SSL:
234 case MODEST_PROTOCOL_CONNECTION_TLS:
235 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_ALWAYS;;
237 case MODEST_PROTOCOL_CONNECTION_TLS_OP:
238 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE;
245 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
248 /* Secure authentication: */
249 /* printf("DEBUG: %s: secure-auth=%d\n", __FUNCTION__, account_data->secure_auth); */
250 const gchar* auth_mech_name = NULL;
251 switch (account_data->secure_auth) {
252 case MODEST_PROTOCOL_AUTH_NONE:
253 /* IMAP and POP need at least a password,
254 * which camel uses if we specify NULL.
255 * This setting should never happen anyway. */
256 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP ||
257 account_data->proto == MODEST_PROTOCOL_STORE_POP)
258 auth_mech_name = NULL;
259 else if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_SMTP)
260 auth_mech_name = MODEST_ACCOUNT_AUTH_ANONYMOUS;
262 auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN;
265 case MODEST_PROTOCOL_AUTH_PASSWORD:
266 /* Camel use a password for IMAP or POP if we specify NULL,
267 * For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
268 * (POP is know to report an error for Login too. Probably Password and Plain too.) */
269 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP)
270 auth_mech_name = NULL;
271 else if (account_data->proto == MODEST_PROTOCOL_STORE_POP)
272 auth_mech_name = NULL;
274 auth_mech_name = MODEST_ACCOUNT_AUTH_PASSWORD;
277 case MODEST_PROTOCOL_AUTH_CRAMMD5:
278 auth_mech_name = MODEST_ACCOUNT_AUTH_CRAMMD5;
282 g_warning ("%s: Unhandled secure authentication setting %d for "
283 "account=%s (%s)", __FUNCTION__, account_data->secure_auth,
284 account_data->account_name, account_data->hostname);
289 tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
291 if (modest_protocol_info_protocol_is_store(account_data->proto) &&
292 (account_data->proto == MODEST_PROTOCOL_STORE_IMAP) ) {
293 /* Other connection options, needed for IMAP. */
294 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
295 MODEST_ACCOUNT_OPTION_USE_LSUB);
296 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
297 MODEST_ACCOUNT_OPTION_CHECK_ALL);
300 if (account_data->username)
301 tny_account_set_user (tny_account, account_data->username);
302 if (account_data->hostname)
303 tny_account_set_hostname (tny_account, account_data->hostname);
306 if (account_data->port)
307 tny_account_set_port (tny_account, account_data->port);
310 /* FIXME: for debugging */
311 url = tny_account_get_url_string (TNY_ACCOUNT(tny_account));
312 /* g_message ("modest: %s:\n account-url: %s", __FUNCTION__, url); */
314 /***********************/
320 modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
321 const gchar *server_account_name)
323 ModestServerAccountData *account_data =
324 modest_account_mgr_get_server_account_data (account_mgr,
325 server_account_name);
329 TnyAccount *result = modest_tny_account_new_from_server_account (
330 account_mgr, account_data);
332 modest_account_mgr_free_server_account_data (account_mgr, account_data);
338 /* we need these dummy functions, or tinymail will complain */
340 get_pass_dummy (TnyAccount *account, const gchar *prompt, gboolean *cancel)
345 forget_pass_dummy (TnyAccount *account)
347 /* intentionally left blank */
351 modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar *account_name,
353 TnySessionCamel *session,
354 TnyGetPassFunc get_pass_func,
355 TnyForgetPassFunc forget_pass_func)
357 TnyAccount *tny_account = NULL;
358 ModestAccountData *account_data = NULL;
359 ModestServerAccountData *server_data = NULL;
361 g_return_val_if_fail (account_mgr, NULL);
362 g_return_val_if_fail (account_name, NULL);
364 account_data = modest_account_mgr_get_account_data (account_mgr, account_name);
366 g_printerr ("modest: %s: cannot get account data for account %s\n", __FUNCTION__, account_name);
370 if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
371 server_data = account_data->store_account;
372 else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
373 server_data = account_data->transport_account;
375 g_printerr ("modest: no %s account defined for '%s'\n",
376 type == TNY_ACCOUNT_TYPE_STORE ? "store" : "transport",
377 account_data->display_name);
378 modest_account_mgr_free_account_data (account_mgr, account_data);
382 tny_account = modest_tny_account_new_from_server_account (account_mgr, server_data);
384 g_printerr ("modest: failed to create tny account for %s (%s)\n",
385 account_data->account_name, server_data->account_name);
386 modest_account_mgr_free_account_data (account_mgr, account_data);
390 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
391 tny_account_set_forget_pass_func (tny_account,
392 forget_pass_func ? forget_pass_func : forget_pass_dummy);
393 tny_account_set_pass_func (tny_account,
394 get_pass_func ? get_pass_func: get_pass_dummy);
396 /* This name is what shows up in the folder view -- so for some POP/IMAP/... server
397 * account, we set its name to the account of which it is part. */
398 if (account_data->display_name)
399 tny_account_set_name (tny_account, account_data->display_name);
401 modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, account_name);
403 modest_account_mgr_free_account_data (account_mgr, account_data);
408 /* TODO: Notify the treemodel somehow that the display name
409 * is now available. We should probably request this from the cell_data_func
410 * so we can provide a treerowreference. */
412 on_modest_file_system_info(HildonFileSystemInfoHandle *handle,
413 HildonFileSystemInfo *info,
414 const GError *error, gpointer data)
416 TnyAccount *account = TNY_ACCOUNT (data);
419 printf (" DEBUG: %s: error=%s\n", __FUNCTION__, error->message);
422 const gchar *display_name = NULL;
423 if (!error && info) {
424 display_name = hildon_file_system_info_get_display_name(info);
428 /* printf ("DEBUG: %s: display name=%s\n", __FUNCTION__, display_name); */
429 tny_account_set_name (account, display_name);
435 modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySessionCamel *session, const gchar* location_filepath)
437 /* Make sure that the directories exist: */
438 modest_init_local_folders (location_filepath);
440 TnyStoreAccount *tny_account;
442 gchar *maildir, *url_string;
444 g_return_val_if_fail (account_mgr, NULL);
446 tny_account = tny_camel_store_account_new ();
448 g_printerr ("modest: cannot create account for local folders");
451 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
453 /* This path contains directories for each local folder.
454 * We have created them so that TnyCamelStoreAccount can find them
455 * and report a folder for each directory: */
456 maildir = modest_local_folder_info_get_maildir_path (location_filepath);
457 url = camel_url_new ("maildir:", NULL);
458 camel_url_set_path (url, maildir);
459 /* Needed by tinymail's DBC assertions */
460 camel_url_set_host (url, "localhost");
461 url_string = camel_url_to_string (url, 0);
463 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
464 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
466 /* TODO: Use a more generic way of identifying memory card paths,
467 * and of marking accounts as memory card accounts, maybe
468 * via a derived TnyCamelStoreAccount ? */
469 const gboolean is_mmc =
471 (strcmp (location_filepath, MODEST_MCC1_VOLUMEPATH) == 0);
473 /* The name of memory card locations will be updated asynchronously.
474 * This is just a default: */
475 const gchar *name = is_mmc ? _("Memory Card") :
476 MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME;
477 tny_account_set_name (TNY_ACCOUNT(tny_account), name);
479 /* Get the correct display name for memory cards, asynchronously: */
480 if (location_filepath) {
481 GError *error = NULL;
482 gchar *uri = g_filename_to_uri(location_filepath, NULL, &error);
484 g_warning ("%s: g_filename_to_uri(%s) failed: %s", __FUNCTION__,
485 location_filepath, error->message);
486 g_error_free (error);
489 /* TODO: gnome_vfs_volume_get_display_name() does not return
490 * the same string. But why not? Why does hildon needs its own
493 hildon_file_system_info_async_new(uri,
494 on_modest_file_system_info, tny_account /* user_data */);
502 const gchar* id = is_mmc ? MODEST_MMC_ACCOUNT_ID :
503 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID;
504 tny_account_set_id (TNY_ACCOUNT(tny_account), id);
506 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
507 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
509 modest_tny_account_set_parent_modest_account_name_for_server_account (
510 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
512 camel_url_free (url);
516 return TNY_ACCOUNT(tny_account);
521 modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, const gchar* account_name, TnySessionCamel *session)
523 g_return_val_if_fail (account_mgr, NULL);
524 g_return_val_if_fail (account_name, NULL);
526 /* Notice that we create a ModestTnyOutboxAccount here,
527 * instead of just a TnyCamelStoreAccount,
528 * so that we can later identify this as a special account for internal use only.
530 TnyStoreAccount *tny_account = TNY_STORE_ACCOUNT (modest_tny_outbox_account_new ());
532 g_printerr ("modest: cannot create account for per-account local outbox folder.");
536 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
538 /* Make sure that the paths exists on-disk so that TnyCamelStoreAccount can
539 * find it to create a TnyFolder for it: */
540 gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account_name);
541 modest_init_one_local_folder(folder_dir);
545 /* This path should contain just one directory - "outbox": */
547 modest_per_account_local_outbox_folder_info_get_maildir_path (account_name);
549 CamelURL *url = camel_url_new ("maildir:", NULL);
550 camel_url_set_path (url, maildir);
553 /* Needed by tinymail's DBC assertions */
554 camel_url_set_host (url, "localhost");
555 gchar *url_string = camel_url_to_string (url, 0);
556 camel_url_free (url);
558 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
559 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
562 /* This text should never been seen,
563 * because the per-account outbox accounts are not seen directly by the user.
564 * Their folders are merged and shown as one folder. */
565 tny_account_set_name (TNY_ACCOUNT(tny_account), "Per-Account Outbox");
567 gchar *account_id = g_strdup_printf (
568 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
570 tny_account_set_id (TNY_ACCOUNT(tny_account), account_id);
573 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
574 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
576 /* Make this think that it belongs to the modest local-folders parent account: */
577 modest_tny_account_set_parent_modest_account_name_for_server_account (
578 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
580 return TNY_ACCOUNT(tny_account);
585 typedef gint (*TnyStatsFunc) (TnyFolderStats *stats);
587 typedef struct _RecurseFoldersHelper {
588 TnyStatsFunc function;
591 } RecurseFoldersHelper;
594 recurse_folders (TnyFolderStore *store,
595 TnyFolderStoreQuery *query,
596 RecurseFoldersHelper *helper)
599 TnyList *folders = tny_simple_list_new ();
601 tny_folder_store_get_folders (store, folders, query, NULL);
602 iter = tny_list_create_iterator (folders);
604 helper->folders += tny_list_get_length (folders);
606 while (!tny_iterator_is_done (iter)) {
607 TnyFolderStats *stats;
610 folder = TNY_FOLDER (tny_iterator_get_current (iter));
611 stats = tny_folder_get_stats (folder);
613 /* initially, we sometimes get -1 from tinymail; ignore that */
614 if (helper->function && helper->function (stats) > 0)
615 helper->sum += helper->function (stats);
617 if (TNY_IS_FOLDER_STORE (folder)) {
618 recurse_folders (TNY_FOLDER_STORE (folder), query, helper);
621 g_object_unref (folder);
622 g_object_unref (stats);
623 tny_iterator_next (iter);
625 g_object_unref (G_OBJECT (iter));
626 g_object_unref (G_OBJECT (folders));
630 modest_tny_folder_store_get_folder_count (TnyFolderStore *self)
632 RecurseFoldersHelper *helper;
635 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
638 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
639 helper->function = NULL;
643 recurse_folders (self, NULL, helper);
645 retval = helper->folders;
653 modest_tny_folder_store_get_message_count (TnyFolderStore *self)
655 RecurseFoldersHelper *helper;
658 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
661 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
662 helper->function = (TnyStatsFunc) tny_folder_stats_get_all_count;
665 recurse_folders (self, NULL, helper);
667 retval = helper->sum;
675 modest_tny_folder_store_get_local_size (TnyFolderStore *self)
677 RecurseFoldersHelper *helper;
680 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
683 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
684 helper->function = (TnyStatsFunc) tny_folder_stats_get_local_size;
687 recurse_folders (self, NULL, helper);
689 retval = helper->sum;
696 const gchar* modest_tny_account_get_parent_modest_account_name_for_server_account (TnyAccount *self)
698 return (const gchar *)g_object_get_data (G_OBJECT (self), "modest_account");
701 void modest_tny_account_set_parent_modest_account_name_for_server_account (TnyAccount *self, const gchar* parent_modest_acount_name)
703 g_object_set_data_full (G_OBJECT(self), "modest_account",
704 (gpointer*) g_strdup (parent_modest_acount_name), g_free);