GHashTable *password_hash;
TnyDevice *device;
- TnyPlatformFactory *platform_fact;
TnySessionCamel *tny_session_camel;
+ ModestAccountMgr *account_mgr;
TnyAccount *local_folders;
};
MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
priv->cache_dir = NULL;
-
- priv->platform_fact = NULL;
+ priv->account_mgr = NULL;
priv->tny_session_camel = NULL;
priv->device = NULL;
g_printerr ("modest: cannot create account for local folders");
return NULL;
}
-
- maildir = modest_local_folder_info_get_maildir_path ();
+ tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account),priv->tny_session_camel);
+
+ maildir = modest_local_folder_info_get_maildir_path ();
url = camel_url_new ("maildir:", NULL);
camel_url_set_path (url, maildir);
-
url_string = camel_url_to_string (url, 0);
- tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
- tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account),
- priv->tny_session_camel);
+ tny_account_set_url_string (TNY_ACCOUNT(tny_account), url_string);
tny_account_set_name (TNY_ACCOUNT(tny_account), MODEST_LOCAL_FOLDERS_ACCOUNT_NAME);
tny_account_set_id (TNY_ACCOUNT(tny_account), MODEST_LOCAL_FOLDERS_ACCOUNT_NAME);
static ModestTnyAccountStore*
get_account_store_for_account (TnyAccount *account)
{
- return MODEST_TNY_ACCOUNT_STORE(g_object_get_data (G_OBJECT(account), "account_store"));
+ return MODEST_TNY_ACCOUNT_STORE(g_object_get_data (G_OBJECT(account),
+ "account_store"));
}
get_password (TnyAccount *account, const gchar *prompt, gboolean *cancel)
{
const gchar *key;
- ModestAccountMgr *account_mgr;
const TnyAccountStore *account_store;
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
key = tny_account_get_id (account);
account_store = TNY_ACCOUNT_STORE(get_account_store_for_account (account));
-
+
self = MODEST_TNY_ACCOUNT_STORE (account_store);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->platform_fact));
-
/* is it in the hash? if it's already there, it must be wrong... */
pwd_ptr = (gpointer)&pwd; /* pwd_ptr so the compiler does not complained about
* type-punned ptrs...*/
/* if the password is not already there, try ModestConf */
if (!already_asked) {
- pwd = modest_account_mgr_get_string (account_mgr,
+ pwd = modest_account_mgr_get_string (priv->account_mgr,
key, MODEST_ACCOUNT_PASSWORD,
TRUE, NULL);
g_hash_table_insert (priv->password_hash, g_strdup (key), g_strdup (pwd));
if (!*cancel) {
if (remember)
- modest_account_mgr_set_string (account_mgr,
+ modest_account_mgr_set_string (priv->account_mgr,
key, MODEST_ACCOUNT_PASSWORD,
pwd,
TRUE, NULL);
static void
-forget_password (TnyAccount *account) {
-
+forget_password (TnyAccount *account)
+{
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
const TnyAccountStore *account_store;
gchar *pwd;
const gchar *key;
- ModestAccountMgr *account_mgr;
account_store = TNY_ACCOUNT_STORE(get_account_store_for_account (account));
self = MODEST_TNY_ACCOUNT_STORE (account_store);
g_hash_table_insert (priv->password_hash, g_strdup (key), NULL);
}
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->platform_fact));
-
/* Remove from configuration system */
- modest_account_mgr_unset (account_mgr,
+ modest_account_mgr_unset (priv->account_mgr,
key, MODEST_ACCOUNT_PASSWORD,
TRUE, NULL);
}
g_hash_table_destroy (priv->password_hash);
priv->password_hash = NULL;
}
+
+ if (priv->account_mgr) {
+ g_object_unref (priv->account_mgr);
+ priv->account_mgr = NULL;
+ }
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GObject *obj;
ModestTnyAccountStorePrivate *priv;
- TnyPlatformFactory *pfact;
g_return_val_if_fail (account_mgr, NULL);
obj = G_OBJECT(g_object_new(MODEST_TYPE_TNY_ACCOUNT_STORE, NULL));
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
- pfact = TNY_PLATFORM_FACTORY (modest_tny_platform_factory_get_instance());
- if (!pfact) {
- g_printerr ("modest: cannot get platform factory instance\n");
- g_object_unref (obj);
- return NULL;
- } else
- priv->platform_fact = pfact;
-
+ priv->account_mgr = account_mgr;
+ g_object_ref (G_OBJECT(priv->account_mgr));
+
/* The session needs the platform factory */
priv->tny_session_camel = tny_session_camel_new (TNY_ACCOUNT_STORE(obj));
if (!priv->tny_session_camel) {
g_object_unref (obj);
return NULL;
}
+
tny_session_camel_set_ui_locker (priv->tny_session_camel, tny_gtk_lockable_new ());
- priv->local_folders = get_local_folders_account (MODEST_TNY_ACCOUNT_STORE(obj));
/* FIXME: unref this in the end? */
/* Connect signals */
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
GSList *accounts, *cursor;
- ModestAccountMgr *account_mgr;
g_return_if_fail (account_store);
g_return_if_fail (TNY_IS_LIST(list));
self = MODEST_TNY_ACCOUNT_STORE(account_store);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- account_mgr = modest_tny_platform_factory_get_account_mgr_instance
- (MODEST_TNY_PLATFORM_FACTORY(priv->platform_fact));
if (type == TNY_ACCOUNT_STORE_BOTH) {
modest_tny_account_store_get_accounts (account_store, list,
TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
}
- accounts = modest_account_mgr_account_names (account_mgr, NULL);
+ accounts = modest_account_mgr_account_names (priv->account_mgr, NULL);
for (cursor = accounts; cursor; cursor = cursor->next) {
TnyAccount *tny_account = NULL;
ModestAccountData *account_data =
- modest_account_mgr_get_account_data (account_mgr,
+ modest_account_mgr_get_account_data (priv->account_mgr,
(gchar*)cursor->data);
if (account_data && account_data->enabled) {
tny_account = get_tny_account_from_account (self, account_data, type);
tny_list_prepend (list, G_OBJECT(tny_account));
}
g_free (cursor->data);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ modest_account_mgr_free_account_data (priv->account_mgr, account_data);
}
g_slist_free (accounts);
/* also, add the local folder pseudo-account */
if (type != TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS) {
if (!priv->local_folders)
+ priv->local_folders = get_local_folders_account (self);
+ if (!priv->local_folders)
g_printerr ("modest: no local folders account\n");
else
tny_list_prepend (list, G_OBJECT(priv->local_folders));
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
if (!priv->device)
- priv->device = tny_platform_factory_new_device (priv->platform_fact);
+ priv->device = tny_platform_factory_new_device
+ (modest_tny_platform_factory_get_instance());
return g_object_ref (G_OBJECT(priv->device));
}
}
-
TnyAccount*
modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self)
{
return MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self)->local_folders;
}
-
-/* for now, ignore the account ===> the special folders are the same,
- * local folders for all accounts
- * this might change, ie, IMAP might have server-side sent-items
- */
-TnyFolder *
-modest_tny_account_store_get_special_folder (ModestTnyAccountStore*self, TnyAccount *account,
- TnyFolderType special_type)
-{
- g_return_val_if_fail (self, NULL);
- g_return_val_if_fail (account, NULL);
- g_return_val_if_fail (0 <= special_type && special_type < TNY_FOLDER_TYPE_NUM,
- NULL);
- //TnyAccount *local_account =
- // tny_account_store_get_local_folders_account (self);
-
- /* FIXME: implement this */
- return NULL;
-}