+
+void
+modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
+ const gchar *account_name,
+ gboolean leave_on_server)
+{
+ modest_account_mgr_set_bool (self,
+ account_name,
+ MODEST_ACCOUNT_LEAVE_ON_SERVER,
+ leave_on_server,
+ FALSE);
+}
+
+gboolean
+modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_bool (self,
+ account_name,
+ MODEST_ACCOUNT_LEAVE_ON_SERVER,
+ FALSE);
+}
+
+gint
+modest_account_mgr_get_last_updated (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_int (modest_runtime_get_account_mgr (),
+ account_name,
+ MODEST_ACCOUNT_LAST_UPDATED,
+ TRUE);
+}
+
+void
+modest_account_mgr_set_last_updated (ModestAccountMgr *self,
+ const gchar* account_name,
+ gint time)
+{
+ modest_account_mgr_set_int (self,
+ account_name,
+ MODEST_ACCOUNT_LAST_UPDATED,
+ time,
+ TRUE);
+
+ /* TODO: notify about changes */
+}
+
+gint
+modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_int (self,
+ account_name,
+ MODEST_ACCOUNT_LIMIT_RETRIEVE,
+ FALSE);
+}
+
+void
+modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
+ const gchar* account_name,
+ gint limit_retrieve)
+{
+ modest_account_mgr_set_int (self,
+ account_name,
+ MODEST_ACCOUNT_LIMIT_RETRIEVE,
+ limit_retrieve,
+ FALSE /* not server account */);
+}
+
+gint
+modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_int (self,
+ account_name,
+ MODEST_ACCOUNT_PORT,
+ TRUE);
+}
+
+void
+modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
+ const gchar *account_name,
+ gint port_num)
+{
+ modest_account_mgr_set_int (self,
+ account_name,
+ MODEST_ACCOUNT_PORT,
+ port_num, TRUE /* server account */);
+}
+
+gchar*
+modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
+ const gchar *account_name,
+ TnyAccountType account_type)
+{
+ return modest_account_mgr_get_string (self,
+ account_name,
+ (account_type == TNY_ACCOUNT_TYPE_STORE) ?
+ MODEST_ACCOUNT_STORE_ACCOUNT :
+ MODEST_ACCOUNT_TRANSPORT_ACCOUNT,
+ FALSE);
+}
+
+static const gchar *
+get_retrieve_type_name (ModestAccountRetrieveType retrieve_type)
+{
+ switch(retrieve_type) {
+ case MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
+ break;
+ case MODEST_ACCOUNT_RETRIEVE_MESSAGES:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES;
+ break;
+ case MODEST_ACCOUNT_RETRIEVE_MESSAGES_AND_ATTACHMENTS:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES_AND_ATTACHMENTS;
+ break;
+ default:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
+ };
+}
+
+static ModestAccountRetrieveType
+get_retrieve_type (const gchar *name)
+{
+ if (!name || name[0] == 0)
+ return MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY;
+ if (strcmp (name, MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES) == 0) {
+ return MODEST_ACCOUNT_RETRIEVE_MESSAGES;
+ } else if (strcmp (name, MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES_AND_ATTACHMENTS) == 0) {
+ return MODEST_ACCOUNT_RETRIEVE_MESSAGES_AND_ATTACHMENTS;
+ } else {
+ /* we fall back to headers only */
+ return MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY;
+ }
+}
+
+ModestAccountRetrieveType
+modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
+ const gchar *account_name)
+{
+ gchar *string;
+ ModestAccountRetrieveType result;
+
+ string = modest_account_mgr_get_string (self,
+ account_name,
+ MODEST_ACCOUNT_RETRIEVE,
+ FALSE /* not server account */);
+ result = get_retrieve_type (string);
+ g_free (string);
+
+ return result;
+}
+
+void
+modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
+ const gchar *account_name,
+ ModestAccountRetrieveType retrieve_type)
+{
+ modest_account_mgr_set_string (self,
+ account_name,
+ MODEST_ACCOUNT_RETRIEVE,
+ get_retrieve_type_name (retrieve_type),
+ FALSE /* not server account */);
+}
+
+
+void
+modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *fullname)
+{
+ modest_account_mgr_set_string (self,
+ account_name,
+ MODEST_ACCOUNT_FULLNAME,
+ fullname,
+ FALSE /* not server account */);
+}
+
+void
+modest_account_mgr_set_user_email (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *email)
+{
+ modest_account_mgr_set_string (self,
+ account_name,
+ MODEST_ACCOUNT_EMAIL,
+ email,
+ FALSE /* not server account */);
+}