+2007-05-28 Murray Cumming <murrayc@murrayc.com>
+
+ * src/modest-local-folder-info.h:
+ * src/modest-local-folder-info.c:
+ (modest_per_account_local_outbox_folder_info_get_maildir_path),
+ (modest_per_account_local_outbox_folder_info_get_maildir_path_to_ou
+ tbox_folder): Take a modest account name instead of a server TnyAccount,
+ so we can have per-modest-account rather than per-transport-account
+ outboxes.
+ We must make sure that we change or recreate the exisitng send queues
+ when the connection changes for connection-specific transport accounts.
+
+ * src/modest-tny-account-store.c:
+ (create_per_account_local_outbox_folders): Create outboxed per modest
+ account, not per transport account.
+
+ * src/modest-tny-account.h:
+ * src/modest-tny-account.c:
+ (modest_tny_account_get_special_folder): For outboxes, get the
+ parent modest account name. The account is ignored for other folders.
+ (modest_tny_account_new_for_per_account_local_outbox_folder): Take a
+ modest account name rather than a server TnyAccount.
+
2007-05-25 Murray Cumming <murrayc@murrayc.com>
* src/modest-tny-account.c:
#include <config.h>
#include <modest-cache-mgr.h>
+#include <stdio.h>
/* 'private'/'protected' functions */
static void modest_cache_mgr_class_init (ModestCacheMgrClass *klass);
GHashTable *cache;
g_return_val_if_fail (self, NULL);
+
+ if (!(type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM)) {
+ printf ("DEBUG: %s: incorrect type = %d\n", __FUNCTION__, type);
+ }
+
g_return_val_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM, NULL);
priv = MODEST_CACHE_MGR_GET_PRIVATE(self);
NULL);
}
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (TnyAccount *account)
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (const gchar* account_name)
{
/* This directory should contain an "outbox" child directory: */
return g_build_filename (g_get_home_dir(),
MODEST_DIR,
MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDERS_MAILDIR,
- tny_account_get_id (account),
+ account_name,
NULL);
}
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (TnyAccount *account)
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (const gchar* account_name)
{
gchar *path_to_account_folder =
- modest_per_account_local_outbox_folder_info_get_maildir_path(account);
+ modest_per_account_local_outbox_folder_info_get_maildir_path(account_name);
if (!path_to_account_folder)
return NULL;
* string, which must be freed by the caller.
*
*/
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (TnyAccount *account);
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (const gchar* account_name);
/**
* modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder
* string, which must be freed by the caller.
*
*/
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (TnyAccount *account);
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (const gchar* account_name);
G_END_DECLS
#endif /* __MODEST_LOCAL_FOLDER_INFO_H__ */
MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
/* printf("DEBUG: %s: priv->store_accounts_outboxes = %p\n", __FUNCTION__, priv->store_accounts_outboxes); */
-
- if (priv->store_accounts_outboxes) {
- return;
- }
-
- /* This transport accounts must be created before calling this function.
- * Otherwise, we have an infinite loop when there are no accounts. */
- if (!(priv->transport_accounts))
- return;
-#if 0
- /* Create the transport accounts, if necessary: */
- if (!(priv->transport_accounts)) {
- get_server_accounts (self, NULL /* TnyList */,
- TNY_ACCOUNT_TYPE_TRANSPORT);
- }
-#endif
GSList *accounts = NULL;
GSList *account_names = modest_account_mgr_account_names (priv->account_mgr,
TRUE /* including disabled accounts */);
- GSList *iter = account_names;
- for (iter = priv->transport_accounts; iter; iter = g_slist_next (iter)) {
+ GSList *iter = NULL;
+ for (iter = account_names; iter; iter = g_slist_next (iter)) {
- TnyAccount *transport_account = (TnyAccount*)iter->data;
+ const gchar* account_name = (const gchar*)iter->data;
/* Create a per-account local outbox folder (a _store_ account)
* for each _transport_ account: */
TnyAccount *tny_account_outbox =
modest_tny_account_new_for_per_account_local_outbox_folder (
- priv->account_mgr, transport_account, priv->session);
+ priv->account_mgr, account_name, priv->session);
accounts = g_slist_append (accounts, tny_account_outbox); /* cache it */
};
+ g_slist_free (account_names);
+
priv->store_accounts_outboxes = accounts;
}
g_free (prompt);
- printf("DEBUG: %s: returning %d\n", __FUNCTION__, retval);
+ /* printf("DEBUG: %s: returning %d\n", __FUNCTION__, retval); */
return retval;
}
/* Per-account outbox folders are each in their own on-disk directory: */
if (special_type == TNY_FOLDER_TYPE_OUTBOX) {
+ const gchar *modest_account_name =
+ modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+ g_assert (modest_account_name);
+
gchar *account_id = g_strdup_printf (
MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
- tny_account_get_id (account));
+ modest_account_name);
- local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
+ local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
account_id);
- g_free (account_id);
+ g_free (account_id);
} else {
/* Other local folders are all in one on-disk directory: */
local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
TnyAccount*
-modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, TnyAccount *account, TnySessionCamel *session)
+modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, const gchar* account_name, TnySessionCamel *session)
{
g_return_val_if_fail (account_mgr, NULL);
- g_return_val_if_fail (account, NULL);
- g_return_val_if_fail (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_TRANSPORT, NULL);
+ g_return_val_if_fail (account_name, NULL);
/* Notice that we create a ModestTnyOutboxAccount here,
* instead of just a TnyCamelStoreAccount,
/* Make sure that the paths exists on-disk so that TnyCamelStoreAccount can
* find it to create a TnyFolder for it: */
- gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account);
+ gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account_name);
modest_init_one_local_folder(folder_dir);
g_free (folder_dir);
folder_dir = NULL;
/* This path should contain just one directory - "outbox": */
gchar *maildir =
- modest_per_account_local_outbox_folder_info_get_maildir_path (account);
+ modest_per_account_local_outbox_folder_info_get_maildir_path (account_name);
CamelURL *url = camel_url_new ("maildir:", NULL);
camel_url_set_path (url, maildir);
gchar *account_id = g_strdup_printf (
MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s",
- tny_account_get_id (account));
+ account_name);
tny_account_set_id (TNY_ACCOUNT(tny_account), account_id);
g_free (account_id);
/**
* modest_tny_account_new_for_per_account_local_outbox_folder:
* @account_mgr: a valid account mgr instance
- * @account: a valid account instance
+ * @account_name: a modest account name.
* @session: a tny camel session
*
* get the per-account local outbox folder (pseudo) account.
* Returns: a new per-account local outbox folder TnyAccount or NULL in case of error.
*/
TnyAccount* modest_tny_account_new_for_per_account_local_outbox_folder (
- ModestAccountMgr *account_mgr, TnyAccount *account,
+ ModestAccountMgr *account_mgr, const gchar* account_name,
TnySessionCamel *session);
/**
* @self: a TnyAccount
* @special_type: the special folder to get
*
- * get the special (Inbox,Outbox,Sent,Draft etc.) folder for this account
+ * get the special (Inbox,Outbox,Sent,Draft etc.) folder for this server account's parent modest account.
* Note: currently, the implementation will always return a local folder for this.
* This can be changed later to return really account-specific special folders,
* such as (for example) server-side Sent/Junk mail for IMAP accounts