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>
47 modest_tny_account_get_special_folder (TnyAccount *account,
48 TnyFolderType special_type)
52 TnyFolder *special_folder = NULL;
55 g_return_val_if_fail (account, NULL);
56 g_return_val_if_fail (0 <= special_type && special_type < TNY_FOLDER_TYPE_NUM,
59 TnyAccount *local_account = NULL;
61 /* The accounts have already been instantiated by
62 * modest_tny_account_store_get_accounts(), which is the
63 * TnyAccountStore::get_accounts_func() implementation,
64 * so we just get them here.
67 /* Per-account outbox folders are each in their own on-disk directory: */
68 if (special_type == TNY_FOLDER_TYPE_OUTBOX) {
69 const gchar *modest_account_name =
70 modest_tny_account_get_parent_modest_account_name_for_server_account (account);
71 g_assert (modest_account_name);
73 gchar *account_id = g_strdup_printf (
74 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
77 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
81 /* Other local folders are all in one on-disk directory: */
82 local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
83 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
87 g_printerr ("modest: cannot get local account\n");
91 folders = TNY_LIST (tny_simple_list_new ());
93 /* There is no need to do this _async, as these are local folders. */
94 /* TODO: However, this seems to fail sometimes when the network is busy,
95 * returning an empty list. murrayc. */
96 tny_folder_store_get_folders (TNY_FOLDER_STORE (local_account),
98 iter = tny_list_create_iterator (folders);
100 while (!tny_iterator_is_done (iter)) {
102 TNY_FOLDER (tny_iterator_get_current (iter));
103 if (modest_tny_folder_get_local_folder_type (folder) == special_type) {
104 special_folder = folder;
108 g_object_unref (G_OBJECT(folder));
109 tny_iterator_next (iter);
112 g_object_unref (G_OBJECT (folders));
113 g_object_unref (G_OBJECT (iter));
114 g_object_unref (G_OBJECT (local_account));
116 return special_folder;
121 /* These seem to be listed in
122 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
124 #define MODEST_ACCOUNT_OPTION_SSL "use_ssl"
125 #define MODEST_ACCOUNT_OPTION_SSL_NEVER "never"
126 #define MODEST_ACCOUNT_OPTION_SSL_ALWAYS "always"
127 #define MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE "when-possible"
129 /* These seem to be listed in
130 * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-provider.c
132 #define MODEST_ACCOUNT_OPTION_USE_LSUB "use_lsub" /* Show only subscribed folders */
133 #define MODEST_ACCOUNT_OPTION_CHECK_ALL "check_all" /* Check for new messages in all folders */
136 /* Posssible values for tny_account_set_secure_auth_mech().
137 * These might be camel-specific.
138 * Really, tinymail should use an enum.
139 * camel_sasl_authtype() seems to list some possible values.
142 /* Note that evolution does not offer these for IMAP: */
143 #define MODEST_ACCOUNT_AUTH_PLAIN "PLAIN"
144 #define MODEST_ACCOUNT_AUTH_ANONYMOUS "ANONYMOUS"
146 /* Caeml's IMAP uses NULL instead for "Password".
147 * Also, not that Evolution offers "Password" for IMAP, but "Login" for SMTP.*/
148 #define MODEST_ACCOUNT_AUTH_PASSWORD "LOGIN"
149 #define MODEST_ACCOUNT_AUTH_CRAMMD5 "CRAM-MD5"
154 * modest_tny_account_new_from_server_account:
155 * @account_mgr: a valid account mgr instance
156 * @account_name: the server account name for which to create a corresponding tny account
157 * @type: the type of account to create (TNY_ACCOUNT_TYPE_STORE or TNY_ACCOUNT_TYPE_TRANSPORT)
159 * get a tnyaccount corresponding to the server_accounts (store or transport) for this account.
160 * NOTE: this function does not set the camel session or the get/forget password functions
162 * Returns: a new TnyAccount or NULL in case of error.
165 modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr,
166 ModestServerAccountData *account_data)
170 g_return_val_if_fail (account_mgr, NULL);
171 g_return_val_if_fail (account_data, NULL);
174 if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN) {
175 g_printerr ("modest: '%s' does not provide a protocol\n",
176 account_data->account_name);
180 TnyAccount *tny_account = NULL;
182 switch (account_data->proto) {
183 case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
184 case MODEST_PROTOCOL_TRANSPORT_SMTP:
185 tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
186 case MODEST_PROTOCOL_STORE_POP:
187 tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
188 case MODEST_PROTOCOL_STORE_IMAP:
189 tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
190 case MODEST_PROTOCOL_STORE_MAILDIR:
191 case MODEST_PROTOCOL_STORE_MBOX:
192 /* Note that this is not where we create the special local folders account.
193 * That happens in modest_tny_account_new_for_local_folders() instead.
195 tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
197 g_return_val_if_reached (NULL);
200 g_printerr ("modest: could not create tny account for '%s'\n",
201 account_data->account_name);
204 tny_account_set_id (tny_account, account_data->account_name);
207 const gchar* proto_name =
208 modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
209 tny_account_set_proto (tny_account, proto_name);
212 /* mbox and maildir accounts use a URI instead of the rest:
213 * Note that this is not where we create the special local folders account.
214 * We do that in modest_tny_account_new_for_local_folders() instead. */
215 if (account_data->uri) {
216 tny_account_set_url_string (TNY_ACCOUNT(tny_account), account_data->uri);
217 /* g_message ("DEBUG: %s: local account-url:\n %s", __FUNCTION__, account_data->uri); */
220 /* Set camel-specific options: */
222 /* Enable secure connection settings: */
223 /* printf("DEBUG: %s: security=%d\n", __FUNCTION__, account_data->security); */
224 const gchar* option_security = NULL;
225 switch (account_data->security) {
226 case MODEST_PROTOCOL_CONNECTION_NORMAL:
227 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_NEVER;
229 case MODEST_PROTOCOL_CONNECTION_SSL:
230 case MODEST_PROTOCOL_CONNECTION_TLS:
231 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_ALWAYS;;
233 case MODEST_PROTOCOL_CONNECTION_TLS_OP:
234 option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE;
241 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
244 /* Secure authentication: */
245 /* printf("DEBUG: %s: secure-auth=%d\n", __FUNCTION__, account_data->secure_auth); */
246 const gchar* auth_mech_name = NULL;
247 switch (account_data->secure_auth) {
248 case MODEST_PROTOCOL_AUTH_NONE:
249 /* IMAP and POP need at least a password,
250 * which camel uses if we specify NULL.
251 * This setting should never happen anyway. */
252 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP ||
253 account_data->proto == MODEST_PROTOCOL_STORE_POP)
254 auth_mech_name = NULL;
255 else if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_SMTP)
256 auth_mech_name = MODEST_ACCOUNT_AUTH_ANONYMOUS;
258 auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN;
261 case MODEST_PROTOCOL_AUTH_PASSWORD:
262 /* Camel use a password for IMAP or POP if we specify NULL,
263 * For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
264 * (POP is know to report an error for Login too. Probably Password and Plain too.) */
265 if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP)
266 auth_mech_name = NULL;
267 else if (account_data->proto == MODEST_PROTOCOL_STORE_POP)
268 auth_mech_name = NULL;
270 auth_mech_name = MODEST_ACCOUNT_AUTH_PASSWORD;
273 case MODEST_PROTOCOL_AUTH_CRAMMD5:
274 auth_mech_name = MODEST_ACCOUNT_AUTH_CRAMMD5;
278 g_warning ("%s: Unhandled secure authentication setting %d for "
279 "account=%s (%s)", __FUNCTION__, account_data->secure_auth,
280 account_data->account_name, account_data->hostname);
285 tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
287 if (modest_protocol_info_protocol_is_store(account_data->proto) &&
288 (account_data->proto == MODEST_PROTOCOL_STORE_IMAP) ) {
289 /* Other connection options, needed for IMAP. */
290 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
291 MODEST_ACCOUNT_OPTION_USE_LSUB);
292 tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
293 MODEST_ACCOUNT_OPTION_CHECK_ALL);
296 if (account_data->username)
297 tny_account_set_user (tny_account, account_data->username);
298 if (account_data->hostname)
299 tny_account_set_hostname (tny_account, account_data->hostname);
302 if (account_data->port)
303 tny_account_set_port (tny_account, account_data->port);
306 /* FIXME: for debugging */
307 url = tny_account_get_url_string (TNY_ACCOUNT(tny_account));
308 /* g_message ("modest: %s:\n account-url: %s", __FUNCTION__, url); */
310 /***********************/
316 modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr,
317 const gchar *server_account_name)
319 ModestServerAccountData *account_data =
320 modest_account_mgr_get_server_account_data (account_mgr,
321 server_account_name);
325 TnyAccount *result = modest_tny_account_new_from_server_account (
326 account_mgr, account_data);
328 modest_account_mgr_free_server_account_data (account_mgr, account_data);
334 /* we need these dummy functions, or tinymail will complain */
336 get_pass_dummy (TnyAccount *account, const gchar *prompt, gboolean *cancel)
341 forget_pass_dummy (TnyAccount *account)
343 /* intentionally left blank */
347 modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, const gchar *account_name,
349 TnySessionCamel *session,
350 TnyGetPassFunc get_pass_func,
351 TnyForgetPassFunc forget_pass_func)
353 TnyAccount *tny_account = NULL;
354 ModestAccountData *account_data = NULL;
355 ModestServerAccountData *server_data = NULL;
357 g_return_val_if_fail (account_mgr, NULL);
358 g_return_val_if_fail (account_name, NULL);
360 account_data = modest_account_mgr_get_account_data (account_mgr, account_name);
362 g_printerr ("modest: %s: cannot get account data for account %s\n", __FUNCTION__, account_name);
366 if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
367 server_data = account_data->store_account;
368 else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
369 server_data = account_data->transport_account;
371 g_printerr ("modest: no %s account defined for '%s'\n",
372 type == TNY_ACCOUNT_TYPE_STORE ? "store" : "transport",
373 account_data->display_name);
374 modest_account_mgr_free_account_data (account_mgr, account_data);
378 tny_account = modest_tny_account_new_from_server_account (account_mgr, server_data);
380 g_printerr ("modest: failed to create tny account for %s (%s)\n",
381 account_data->account_name, server_data->account_name);
382 modest_account_mgr_free_account_data (account_mgr, account_data);
386 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
387 tny_account_set_forget_pass_func (tny_account,
388 forget_pass_func ? forget_pass_func : forget_pass_dummy);
389 tny_account_set_pass_func (tny_account,
390 get_pass_func ? get_pass_func: get_pass_dummy);
392 /* This name is what shows up in the folder view -- so for some POP/IMAP/... server
393 * account, we set its name to the account of which it is part. */
394 if (account_data->display_name)
395 tny_account_set_name (tny_account, account_data->display_name);
397 modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, account_name);
399 modest_account_mgr_free_account_data (account_mgr, account_data);
406 on_modest_file_system_info(HildonFileSystemInfoHandle *handle,
407 HildonFileSystemInfo *info,
408 const GError *error, gpointer data)
411 printf("DEBUG: %s: display name=%s\n", __FUNCTION__,
412 hildon_file_system_info_get_display_name(info));
415 printf("DEBUG: %s: info is NULL.\n", __FUNCTION__);
419 printf (" DEBUG: error=%s\n", error->message);
426 modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySessionCamel *session, const gchar* location_filepath)
428 /* Make sure that the directories exist: */
429 modest_init_local_folders (location_filepath);
431 TnyStoreAccount *tny_account;
433 gchar *maildir, *url_string;
435 g_return_val_if_fail (account_mgr, NULL);
437 tny_account = tny_camel_store_account_new ();
439 g_printerr ("modest: cannot create account for local folders");
442 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
444 /* This path contains directories for each local folder.
445 * We have created them so that TnyCamelStoreAccount can find them
446 * and report a folder for each directory: */
447 maildir = modest_local_folder_info_get_maildir_path (location_filepath);
448 url = camel_url_new ("maildir:", NULL);
449 camel_url_set_path (url, maildir);
450 /* Needed by tinymail's DBC assertions */
451 camel_url_set_host (url, "localhost");
452 url_string = camel_url_to_string (url, 0);
454 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
455 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
457 /* TODO: Use a more generic way of identifying memory card paths,
458 * and of marking accounts as memory card accounts, maybe
459 * via a derived TnyCamelStoreAccount ? */
460 const gboolean is_mmc =
462 (strcmp (location_filepath, MODEST_MCC1_VOLUMEPATH) == 0);
464 /* TODO: Use hildon_file_system_info_async_new() to get the display name? */
466 const gchar *uri = "file:///media/mmc1";
467 /* HildonFileSystemInfoHandle *async_handle = */
468 hildon_file_system_info_async_new(uri,
469 on_modest_file_system_info, NULL /* user_data */);
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 const gchar* id = is_mmc ? MODEST_MMC_ACCOUNT_ID :
477 MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID;
478 tny_account_set_id (TNY_ACCOUNT(tny_account), id);
480 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
481 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
483 modest_tny_account_set_parent_modest_account_name_for_server_account (
484 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
486 camel_url_free (url);
490 return TNY_ACCOUNT(tny_account);
495 modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, const gchar* account_name, TnySessionCamel *session)
497 g_return_val_if_fail (account_mgr, NULL);
498 g_return_val_if_fail (account_name, NULL);
500 /* Notice that we create a ModestTnyOutboxAccount here,
501 * instead of just a TnyCamelStoreAccount,
502 * so that we can later identify this as a special account for internal use only.
504 TnyStoreAccount *tny_account = TNY_STORE_ACCOUNT (modest_tny_outbox_account_new ());
506 g_printerr ("modest: cannot create account for per-account local outbox folder.");
510 tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
512 /* Make sure that the paths exists on-disk so that TnyCamelStoreAccount can
513 * find it to create a TnyFolder for it: */
514 gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account_name);
515 modest_init_one_local_folder(folder_dir);
519 /* This path should contain just one directory - "outbox": */
521 modest_per_account_local_outbox_folder_info_get_maildir_path (account_name);
523 CamelURL *url = camel_url_new ("maildir:", NULL);
524 camel_url_set_path (url, maildir);
527 /* Needed by tinymail's DBC assertions */
528 camel_url_set_host (url, "localhost");
529 gchar *url_string = camel_url_to_string (url, 0);
530 camel_url_free (url);
532 tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
533 printf("DEBUG: %s:\n url=%s\n", __FUNCTION__, url_string);
536 /* This text should never been seen,
537 * because the per-account outbox accounts are not seen directly by the user.
538 * Their folders are merged and shown as one folder. */
539 tny_account_set_name (TNY_ACCOUNT(tny_account), "Per-Account Outbox");
541 gchar *account_id = g_strdup_printf (
542 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
544 tny_account_set_id (TNY_ACCOUNT(tny_account), account_id);
547 tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy);
548 tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy);
550 /* Make this think that it belongs to the modest local-folders parent account: */
551 modest_tny_account_set_parent_modest_account_name_for_server_account (
552 TNY_ACCOUNT (tny_account), MODEST_ACTUAL_LOCAL_FOLDERS_ACCOUNT_ID);
554 return TNY_ACCOUNT(tny_account);
559 typedef gint (*TnyStatsFunc) (TnyFolderStats *stats);
561 typedef struct _RecurseFoldersHelper {
562 TnyStatsFunc function;
565 } RecurseFoldersHelper;
568 recurse_folders (TnyFolderStore *store,
569 TnyFolderStoreQuery *query,
570 RecurseFoldersHelper *helper)
573 TnyList *folders = tny_simple_list_new ();
575 tny_folder_store_get_folders (store, folders, query, NULL);
576 iter = tny_list_create_iterator (folders);
578 helper->folders += tny_list_get_length (folders);
580 while (!tny_iterator_is_done (iter)) {
581 TnyFolderStats *stats;
584 folder = TNY_FOLDER (tny_iterator_get_current (iter));
585 stats = tny_folder_get_stats (folder);
587 /* initially, we sometimes get -1 from tinymail; ignore that */
588 if (helper->function && helper->function (stats) > 0)
589 helper->sum += helper->function (stats);
591 if (TNY_IS_FOLDER_STORE (folder)) {
592 recurse_folders (TNY_FOLDER_STORE (folder), query, helper);
595 g_object_unref (folder);
596 g_object_unref (stats);
597 tny_iterator_next (iter);
599 g_object_unref (G_OBJECT (iter));
600 g_object_unref (G_OBJECT (folders));
604 modest_tny_folder_store_get_folder_count (TnyFolderStore *self)
606 RecurseFoldersHelper *helper;
609 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
612 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
613 helper->function = NULL;
617 recurse_folders (self, NULL, helper);
619 retval = helper->folders;
627 modest_tny_folder_store_get_message_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 = (TnyStatsFunc) tny_folder_stats_get_all_count;
639 recurse_folders (self, NULL, helper);
641 retval = helper->sum;
649 modest_tny_folder_store_get_local_size (TnyFolderStore *self)
651 RecurseFoldersHelper *helper;
654 g_return_val_if_fail (TNY_IS_FOLDER_STORE (self), -1);
657 helper = g_malloc0 (sizeof (RecurseFoldersHelper));
658 helper->function = (TnyStatsFunc) tny_folder_stats_get_local_size;
661 recurse_folders (self, NULL, helper);
663 retval = helper->sum;
670 const gchar* modest_tny_account_get_parent_modest_account_name_for_server_account (TnyAccount *self)
672 return (const gchar *)g_object_get_data (G_OBJECT (self), "modest_account");
675 void modest_tny_account_set_parent_modest_account_name_for_server_account (TnyAccount *self, const gchar* parent_modest_acount_name)
677 g_object_set_data_full (G_OBJECT(self), "modest_account",
678 (gpointer*) g_strdup (parent_modest_acount_name), g_free);