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-tny-local-folders-account.h>
34 #include <modest-runtime.h>
35 #include <tny-simple-list.h>
36 #include <modest-tny-folder.h>
37 #include <modest-tny-outbox-account.h>
38 #include <modest-account-mgr-helpers.h>
39 #include <modest-init.h>
40 #include <tny-camel-transport-account.h>
41 #include <tny-camel-imap-store-account.h>
42 #include <tny-camel-pop-store-account.h>
43 #include <tny-folder-stats.h>
45 #ifdef MODEST_HILDON_VERSION_0
46 #include <hildon-widgets/hildon-file-system-info.h>
48 #include <hildon/hildon-file-system-info.h>
52 modest_tny_account_get_special_folder (TnyAccount *account,
53 TnyFolderType special_type)
57 TnyFolder *special_folder = NULL;
60 g_return_val_if_fail (account, NULL);
61 g_return_val_if_fail (0 <= special_type && special_type < TNY_FOLDER_TYPE_NUM,
64 TnyAccount *local_account = NULL;
66 /* The accounts have already been instantiated by
67 * modest_tny_account_store_get_accounts(), which is the
68 * TnyAccountStore::get_accounts_func() implementation,
69 * so we just get them here.
72 /* Per-account outbox folders are each in their own on-disk directory: */
73 if (special_type == TNY_FOLDER_TYPE_OUTBOX) {
74 const gchar *modest_account_name =
75 modest_tny_account_get_parent_modest_account_name_for_server_account (account);
76 g_assert (modest_account_name);
78 gchar *account_id = g_strdup_printf (
79 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
82 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
86 /* Other local folders are all in one on-disk directory: */
87 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
88 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
92 g_printerr ("modest: cannot get local account\n");
96 folders = TNY_LIST (tny_simple_list_new ());
98 /* There is no need to do this _async, as these are local folders. */
99 /* TODO: However, this seems to fail sometimes when the network is busy,
100 * returning an empty list. murrayc. */
101 tny_folder_store_get_folders (TNY_FOLDER_STORE (local_account),
102 folders, NULL, NULL);
103 iter = tny_list_create_iterator (folders);
105 while (!tny_iterator_is_done (iter)) {
107 TNY_FOLDER (tny_iterator_get_current (iter));
108 if (modest_tny_folder_get_local_folder_type (folder) == special_type) {
109 special_folder = folder;
113 g_object_unref (G_OBJECT(folder));
114 tny_iterator_next (iter);
117 g_object_unref (G_OBJECT (folders));
118 g_object_unref (G_OBJECT (iter));
119 g_object_unref (G_OBJECT (local_account));
121 return special_folder;
126 /* These seem to be listed in
127 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
129 #define MODEST_ACCOUNT_OPTION_SSL "use_ssl"
130 #define MODEST_ACCOUNT_OPTION_SSL_NEVER "never"
131 #define MODEST_ACCOUNT_OPTION_SSL_ALWAYS "always"
132 #define MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE "when-possible"
134 /* These seem to be listed in
135 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-provider.c
137 #define MODEST_ACCOUNT_OPTION_USE_LSUB "use_lsub" /* Show only subscribed folders */
138 #define MODEST_ACCOUNT_OPTION_CHECK_ALL "check_all" /* Check for new messages in all folders */
141 /* Posssible values for tny_account_set_secure_auth_mech().
142 * These might be camel-specific.
143 * Really, tinymail should use an enum.
144 * camel_sasl_authtype() seems to list some possible values.
147 /* Note that evolution does not offer these for IMAP: */
148 #define MODEST_ACCOUNT_AUTH_PLAIN "PLAIN"
149 #define MODEST_ACCOUNT_AUTH_ANONYMOUS "ANONYMOUS"
151 /* Caeml's IMAP uses NULL instead for "Password".
152 * Also, not that Evolution offers "Password" for IMAP, but "Login" for SMTP.*/
153 #define MODEST_ACCOUNT_AUTH_PASSWORD "LOGIN"
154 #define MODEST_ACCOUNT_AUTH_CRAMMD5 "CRAM-MD5"
159 * modest_tny_account_new_from_server_account:
160 * @account_mgr: a valid account mgr instance
161 * @account_name: the server account name for which to create a corresponding tny account
162 * @type: the type of account to create (TNY_ACCOUNT_TYPE_STORE or TNY_ACCOUNT_TYPE_TRANSPORT)
164 * get a tnyaccount corresponding to the server_accounts (store or transport) for this account.
165 * NOTE: this function does not set the camel session or the get/forget password functions
167 * Returns: a new TnyAccount or NULL in case of error.
170 modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr,
171 ModestServerAccountData *account_data)
175 g_return_val_if_fail (account_mgr, NULL);
176 g_return_val_if_fail (account_data, NULL);
179 if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN) {
180 g_printerr ("modest: '%s' does not provide a protocol\n",
181 account_data->account_name);
185 TnyAccount *tny_account = NULL;
187 switch (account_data->proto) {
188 case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
189 case MODEST_PROTOCOL_TRANSPORT_SMTP:
190 tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
191 case MODEST_PROTOCOL_STORE_POP:
192 tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
193 case MODEST_PROTOCOL_STORE_IMAP:
194 tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
195 case MODEST_PROTOCOL_STORE_MAILDIR:
196 case MODEST_PROTOCOL_STORE_MBOX:
197 /* Note that this is not where we create the special local folders account.
198 * That happens in modest_tny_account_new_for_local_folders() instead.
200 tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
202 g_return_val_if_reached (NULL);
205 g_printerr ("modest: could not create tny account for '%s'\n",
206 account_data->account_name);
209 tny_account_set_id (tny_account, account_data->account_name);
212 const gchar* proto_name =
213 modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
214 tny_account_set_proto (tny_account, proto_name);
217 /* mbox and maildir accounts use a URI instead of the rest:
218 * Note that this is not where we create the special local folders account.
219 * We do that in modest_tny_account_new_for_local_folders() instead. */
220 if (account_data->uri) {
221 tny_account_set_url_string (TNY_ACCOUNT(tny_account), account_data->uri);
222 /* g_message ("DEBUG: %s: local account-url:\n %s", __FUNCTION__, account_data->uri); */
225 /* Set camel-specific options: */
227 /* Enable secure connection settings: */
228 /* printf("DEBUG: %s: security=%d\n", __FUNCTION__, account_data->security); */
229 const gchar* option_security = NULL;
230 switch (account_data->security) {
231 case MODEST_PROTOCOL_CONNECTION_NORMAL:
232 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_NEVER;
234 case MODEST_PROTOCOL_CONNECTION_SSL:
235 case MODEST_PROTOCOL_CONNECTION_TLS:
236 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_ALWAYS;;
238 case MODEST_PROTOCOL_CONNECTION_TLS_OP:
239 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE;
246 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
249 /* Secure authentication: */
250 /* printf("DEBUG: %s: secure-auth=%d\n", __FUNCTION__, account_data->secure_auth); */
251 const gchar* auth_mech_name = NULL;
252 switch (account_data->secure_auth) {
253 case MODEST_PROTOCOL_AUTH_NONE:
254 /* IMAP and POP need at least a password,
255 * which camel uses if we specify NULL.
256 * This setting should never happen anyway. */
257 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP ||
258 account_data->proto == MODEST_PROTOCOL_STORE_POP)
259 auth_mech_name = NULL;
260 else if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_SMTP)
261 auth_mech_name = MODEST_ACCOUNT_AUTH_ANONYMOUS;
263 auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN;
266 case MODEST_PROTOCOL_AUTH_PASSWORD:
267 /* Camel use a password for IMAP or POP if we specify NULL,
268 * For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
269 * (POP is know to report an error for Login too. Probably Password and Plain too.) */
270 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP)
271 auth_mech_name = NULL;
272 else if (account_data->proto == MODEST_PROTOCOL_STORE_POP)
273 auth_mech_name = NULL;
275 auth_mech_name = MODEST_ACCOUNT_AUTH_PASSWORD;
278 case MODEST_PROTOCOL_AUTH_CRAMMD5:
279 auth_mech_name = MODEST_ACCOUNT_AUTH_CRAMMD5;
283 g_warning ("%s: Unhandled secure authentication setting %d for "
284 "account=%s (%s)", __FUNCTION__, account_data->secure_auth,
285 account_data->account_name, account_data->hostname);
290 tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
292 if (modest_protocol_info_protocol_is_store(account_data->proto) &&
293 (account_data->proto == MODEST_PROTOCOL_STORE_IMAP) ) {
294 /* Other connection options, needed for IMAP. */
295 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
296 MODEST_ACCOUNT_OPTION_USE_LSUB);
297 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
298 MODEST_ACCOUNT_OPTION_CHECK_ALL);
301 if (account_data->username)
302 tny_account_set_user (tny_account, account_data->username);
303 if (account_data->hostname)
304 tny_account_set_hostname (tny_account, account_data->hostname);
307 if (account_data->port)
308 tny_account_set_port (tny_account, account_data->port);
311 /* FIXME: for debugging */
312 url = tny_account_get_url_string (TNY_ACCOUNT(tny_account));
313 /* g_message ("modest: %s:\n account-url: %s", __FUNCTION__, url); */
315 /***********************/
321 modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
322 const gchar *server_account_name)
324 ModestServerAccountData *account_data =
325 modest_account_mgr_get_server_account_data (account_mgr,
326 server_account_name);
330 TnyAccount *result = modest_tny_account_new_from_server_account (
331 account_mgr, account_data);
333 modest_account_mgr_free_server_account_data (account_mgr, account_data);
339 /* we need these dummy functions, or tinymail will complain */
341 get_pass_dummy (TnyAccount *account, const gchar *prompt, gboolean *cancel)
346 forget_pass_dummy (TnyAccount *account)
348 /* intentionally left blank */
352 modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar *account_name,
354 TnySessionCamel *session,
355 TnyGetPassFunc get_pass_func,
356 TnyForgetPassFunc forget_pass_func)
358 TnyAccount *tny_account = NULL;
359 ModestAccountData *account_data = NULL;
360 ModestServerAccountData *server_data = NULL;
362 g_return_val_if_fail (account_mgr, NULL);
363 g_return_val_if_fail (account_name, NULL);
365 account_data = modest_account_mgr_get_account_data (account_mgr, account_name);
367 g_printerr ("modest: %s: cannot get account data for account %s\n", __FUNCTION__, account_name);
371 if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
372 server_data = account_data->store_account;
373 else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
374 server_data = account_data->transport_account;
376 g_printerr ("modest: no %s account defined for '%s'\n",
377 type == TNY_ACCOUNT_TYPE_STORE ? "store" : "transport",
378 account_data->display_name);
379 modest_account_mgr_free_account_data (account_mgr, account_data);
383 tny_account = modest_tny_account_new_from_server_account (account_mgr, server_data);
385 g_printerr ("modest: failed to create tny account for %s (%s)\n",
386 account_data->account_name, server_data->account_name);
387 modest_account_mgr_free_account_data (account_mgr, account_data);
391 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
392 tny_account_set_forget_pass_func (tny_account,
393 forget_pass_func ? forget_pass_func : forget_pass_dummy);
394 tny_account_set_pass_func (tny_account,
395 get_pass_func ? get_pass_func: get_pass_dummy);
397 /* This name is what shows up in the folder view -- so for some POP/IMAP/... server
398 * account, we set its name to the account of which it is part. */
399 if (account_data->display_name)
400 tny_account_set_name (tny_account, account_data->display_name);
402 modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, account_name);
404 modest_account_mgr_free_account_data (account_mgr, account_data);
409 /* TODO: Notify the treemodel somehow that the display name
410 * is now available. We should probably request this from the cell_data_func
411 * so we can provide a treerowreference. */
413 on_modest_file_system_info(HildonFileSystemInfoHandle *handle,
414 HildonFileSystemInfo *info,
415 const GError *error, gpointer data)
417 TnyAccount *account = TNY_ACCOUNT (data);
420 printf (" DEBUG: %s: error=%s\n", __FUNCTION__, error->message);
423 const gchar *display_name = NULL;
424 if (!error && info) {
425 display_name = hildon_file_system_info_get_display_name(info);
429 /* printf ("DEBUG: %s: display name=%s\n", __FUNCTION__, display_name); */
430 tny_account_set_name (account, display_name);
436 modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySessionCamel *session, const gchar* location_filepath)
438 /* Make sure that the directories exist: */
439 modest_init_local_folders (location_filepath);
441 TnyStoreAccount *tny_account;
443 gchar *maildir, *url_string;
445 g_return_val_if_fail (account_mgr, NULL);
447 if (!location_filepath) {
448 /* A NULL filepath means that this is the special local-folders maildir
450 tny_account = TNY_STORE_ACCOUNT (modest_tny_local_folders_account_new ());
453 /* Else, for instance, a per-account outbox maildir account: */
454 tny_account = TNY_STORE_ACCOUNT (tny_camel_store_account_new ());
458 g_printerr ("modest: %s: cannot create account for local folders. filepath=%s",
459 __FUNCTION__, location_filepath);
462 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
464 /* This path contains directories for each local folder.
465 * We have created them so that TnyCamelStoreAccount can find them
466 * and report a folder for each directory: */
467 maildir = modest_local_folder_info_get_maildir_path (location_filepath);
468 url = camel_url_new ("maildir:", NULL);
469 camel_url_set_path (url, maildir);
470 /* Needed by tinymail's DBC assertions */
471 camel_url_set_host (url, "localhost");
472 url_string = camel_url_to_string (url, 0);
474 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
475 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
477 /* TODO: Use a more generic way of identifying memory card paths,
478 * and of marking accounts as memory card accounts, maybe
479 * via a derived TnyCamelStoreAccount ? */
480 const gboolean is_mmc =
482 (strcmp (location_filepath, MODEST_MCC1_VOLUMEPATH) == 0);
484 /* The name of memory card locations will be updated asynchronously.
485 * This is just a default: */
486 const gchar *name = is_mmc ? _("Memory Card") :
487 MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME;
488 tny_account_set_name (TNY_ACCOUNT(tny_account), name);
490 /* Get the correct display name for memory cards, asynchronously: */
491 if (location_filepath) {
492 GError *error = NULL;
493 gchar *uri = g_filename_to_uri(location_filepath, NULL, &error);
495 g_warning ("%s: g_filename_to_uri(%s) failed: %s", __FUNCTION__,
496 location_filepath, error->message);
497 g_error_free (error);
500 /* TODO: gnome_vfs_volume_get_display_name() does not return
501 * the same string. But why not? Why does hildon needs its own
504 hildon_file_system_info_async_new(uri,
505 on_modest_file_system_info, tny_account /* user_data */);
513 const gchar* id = is_mmc ? MODEST_MMC_ACCOUNT_ID :
514 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID;
515 tny_account_set_id (TNY_ACCOUNT(tny_account), id);
517 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
518 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
520 modest_tny_account_set_parent_modest_account_name_for_server_account (
521 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
523 camel_url_free (url);
527 return TNY_ACCOUNT(tny_account);
532 modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, const gchar* account_name, TnySessionCamel *session)
534 g_return_val_if_fail (account_mgr, NULL);
535 g_return_val_if_fail (account_name, NULL);
537 /* Notice that we create a ModestTnyOutboxAccount here,
538 * instead of just a TnyCamelStoreAccount,
539 * so that we can later identify this as a special account for internal use only.
541 TnyStoreAccount *tny_account = TNY_STORE_ACCOUNT (modest_tny_outbox_account_new ());
543 g_printerr ("modest: cannot create account for per-account local outbox folder.");
547 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
549 /* Make sure that the paths exists on-disk so that TnyCamelStoreAccount can
550 * find it to create a TnyFolder for it: */
551 gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account_name);
552 modest_init_one_local_folder(folder_dir);
556 /* This path should contain just one directory - "outbox": */
558 modest_per_account_local_outbox_folder_info_get_maildir_path (account_name);
560 CamelURL *url = camel_url_new ("maildir:", NULL);
561 camel_url_set_path (url, maildir);
564 /* Needed by tinymail's DBC assertions */
565 camel_url_set_host (url, "localhost");
566 gchar *url_string = camel_url_to_string (url, 0);
567 camel_url_free (url);
569 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
570 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
573 /* This text should never been seen,
574 * because the per-account outbox accounts are not seen directly by the user.
575 * Their folders are merged and shown as one folder. */
576 tny_account_set_name (TNY_ACCOUNT(tny_account), "Per-Account Outbox");
578 gchar *account_id = g_strdup_printf (
579 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
581 tny_account_set_id (TNY_ACCOUNT(tny_account), account_id);
584 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
585 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
587 /* Make this think that it belongs to the modest local-folders parent account: */
588 modest_tny_account_set_parent_modest_account_name_for_server_account (
589 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
591 return TNY_ACCOUNT(tny_account);
596 typedef gint (*TnyStatsFunc) (TnyFolderStats *stats);
598 typedef struct _RecurseFoldersHelper {
599 TnyStatsFunc function;
602 } RecurseFoldersHelper;
605 recurse_folders (TnyFolderStore *store,
606 TnyFolderStoreQuery *query,
607 RecurseFoldersHelper *helper)
610 TnyList *folders = tny_simple_list_new ();
612 tny_folder_store_get_folders (store, folders, query, NULL);
613 iter = tny_list_create_iterator (folders);
615 helper->folders += tny_list_get_length (folders);
617 while (!tny_iterator_is_done (iter)) {
618 TnyFolderStats *stats;
621 folder = TNY_FOLDER (tny_iterator_get_current (iter));
622 stats = tny_folder_get_stats (folder);
624 /* initially, we sometimes get -1 from tinymail; ignore that */
625 if (helper->function && helper->function (stats) > 0)
626 helper->sum += helper->function (stats);
628 if (TNY_IS_FOLDER_STORE (folder)) {
629 recurse_folders (TNY_FOLDER_STORE (folder), query, helper);
632 g_object_unref (folder);
633 g_object_unref (stats);
634 tny_iterator_next (iter);
636 g_object_unref (G_OBJECT (iter));
637 g_object_unref (G_OBJECT (folders));
641 modest_tny_folder_store_get_folder_count (TnyFolderStore *self)
643 RecurseFoldersHelper *helper;
646 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
649 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
650 helper->function = NULL;
654 recurse_folders (self, NULL, helper);
656 retval = helper->folders;
664 modest_tny_folder_store_get_message_count (TnyFolderStore *self)
666 RecurseFoldersHelper *helper;
669 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
672 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
673 helper->function = (TnyStatsFunc) tny_folder_stats_get_all_count;
676 recurse_folders (self, NULL, helper);
678 retval = helper->sum;
686 modest_tny_folder_store_get_local_size (TnyFolderStore *self)
688 RecurseFoldersHelper *helper;
691 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
694 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
695 helper->function = (TnyStatsFunc) tny_folder_stats_get_local_size;
698 recurse_folders (self, NULL, helper);
700 retval = helper->sum;
707 const gchar* modest_tny_account_get_parent_modest_account_name_for_server_account (TnyAccount *self)
709 return (const gchar *)g_object_get_data (G_OBJECT (self), "modest_account");
712 void modest_tny_account_set_parent_modest_account_name_for_server_account (TnyAccount *self, const gchar* parent_modest_acount_name)
714 g_object_set_data_full (G_OBJECT(self), "modest_account",
715 (gpointer*) g_strdup (parent_modest_acount_name), g_free);