#include "modest-account-mgr.h"
/* 'private'/'protected' functions */
-static void modest_account_mgr_class_init (ModestAccountMgrClass *klass);
-static void modest_account_mgr_init (ModestAccountMgr *obj);
-static void modest_account_mgr_finalize (GObject *obj);
+static void modest_account_mgr_class_init (ModestAccountMgrClass * klass);
+static void modest_account_mgr_init (ModestAccountMgr * obj);
+static void modest_account_mgr_finalize (GObject * obj);
-static gchar* get_account_keyname (const gchar *accname, const gchar *name);
-static gchar* get_server_account_keyname (const gchar *accname, const gchar *name);
-static gchar* get_identity_keyname (const gchar *accname, const gchar *name);
+static gchar *get_account_keyname (const gchar * accname, const gchar * name);
+static gchar *get_server_account_keyname (const gchar * accname,
+ const gchar * name);
/* list my signals */
enum {
struct _ModestAccountMgrPrivate {
ModestConf *modest_conf;
};
+
#define MODEST_ACCOUNT_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_ACCOUNT_MGR, \
ModestAccountMgrPrivate))
modest_account_mgr_get_type (void)
{
static GType my_type = 0;
+
if (!my_type) {
static const GTypeInfo my_info = {
- sizeof(ModestAccountMgrClass),
- NULL, /* base init */
- NULL, /* base finalize */
+ sizeof (ModestAccountMgrClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
(GClassInitFunc) modest_account_mgr_class_init,
- NULL, /* class finalize */
- NULL, /* class data */
- sizeof(ModestAccountMgr),
- 1, /* n_preallocs */
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (ModestAccountMgr),
+ 1, /* n_preallocs */
(GInstanceInitFunc) modest_account_mgr_init,
};
my_type = g_type_register_static (G_TYPE_OBJECT,
- "ModestAccountMgr",
- &my_info, 0);
+ "ModestAccountMgr",
+ &my_info, 0);
}
return my_type;
}
static void
-modest_account_mgr_class_init (ModestAccountMgrClass *klass)
+modest_account_mgr_class_init (ModestAccountMgrClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
- parent_class = g_type_class_peek_parent (klass);
+ gobject_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = modest_account_mgr_finalize;
- g_type_class_add_private (gobject_class, sizeof(ModestAccountMgrPrivate));
+ g_type_class_add_private (gobject_class,
+ sizeof (ModestAccountMgrPrivate));
/* signal definitions go here, e.g.: */
/* signals[MY_SIGNAL_1] = */
static void
-modest_account_mgr_init (ModestAccountMgr *obj)
+modest_account_mgr_init (ModestAccountMgr * obj)
{
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(obj);
- priv->modest_conf = NULL;
+ ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (obj);
+
+ priv->modest_conf = NULL;
}
static void
-modest_account_mgr_finalize (GObject *obj)
+modest_account_mgr_finalize (GObject * obj)
{
- ModestAccountMgr *self = MODEST_ACCOUNT_MGR(obj);
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ ModestAccountMgr *self = MODEST_ACCOUNT_MGR (obj);
+ ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
- g_object_unref (G_OBJECT(priv->modest_conf));
+ g_object_unref (G_OBJECT (priv->modest_conf));
priv->modest_conf = NULL;
}
-GObject*
-modest_account_mgr_new (ModestConf *conf)
+GObject *
+modest_account_mgr_new (ModestConf * conf)
{
GObject *obj;
ModestAccountMgrPrivate *priv;
g_return_val_if_fail (conf, NULL);
- obj = G_OBJECT(g_object_new(MODEST_TYPE_ACCOUNT_MGR, NULL));
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(obj);
+ obj = G_OBJECT (g_object_new (MODEST_TYPE_ACCOUNT_MGR, NULL));
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (obj);
/*
* increase the ref count on the modest_conf. Normally, the
* ModestConf should outlive the ModestAccountMgr though
*/
- g_object_ref(G_OBJECT(priv->modest_conf = conf));
+ g_object_ref (G_OBJECT (priv->modest_conf = conf));
return obj;
}
-
gboolean
-modest_account_mgr_add_account (ModestAccountMgr *self, const gchar* name,
- const gchar *store_account,
- const gchar *transport_account,
- GError **err)
+modest_account_mgr_add_account (ModestAccountMgr * self, const gchar * name,
+ const gchar * store_account,
+ const gchar * transport_account,
+ GError ** err)
{
ModestAccountMgrPrivate *priv;
gchar *key;
* we create the account by adding an account 'dir', with the name <name>,
* and in that the 'display_name' string key
*/
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
key = get_account_keyname (name, MODEST_ACCOUNT_DISPLAY_NAME);
modest_conf_set_string (priv->modest_conf, key, name, err);
g_free (key);
if (store_account) {
- key = get_account_keyname (name, MODEST_ACCOUNT_STORE_ACCOUNT);
- modest_conf_set_string (priv->modest_conf, key, store_account, err);
+ key = get_account_keyname (name,
+ MODEST_ACCOUNT_STORE_ACCOUNT);
+ modest_conf_set_string (priv->modest_conf, key, store_account,
+ err);
g_free (key);
}
if (transport_account) {
- key = get_account_keyname (name, MODEST_ACCOUNT_TRANSPORT_ACCOUNT);
- modest_conf_set_string (priv->modest_conf, key, transport_account, err);
+ key = get_account_keyname (name,
+ MODEST_ACCOUNT_TRANSPORT_ACCOUNT);
+ modest_conf_set_string (priv->modest_conf, key,
+ transport_account, err);
g_free (key);
}
- return TRUE; /* TODO: error handling */
+ return TRUE; /* TODO: error handling */
}
gboolean
-modest_account_mgr_remove_account (ModestAccountMgr *self, const gchar* name,
- GError **err)
+modest_account_mgr_remove_account (ModestAccountMgr * self,
+ const gchar * name, GError ** err)
{
ModestAccountMgrPrivate *priv;
gchar *key;
return FALSE;
}
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
key = get_account_keyname (name, NULL);
retval = modest_conf_remove_key (priv->modest_conf, key, NULL);
}
-static const gchar*
-null_means_empty(const gchar* str)
+static const gchar *
+null_means_empty (const gchar * str)
{
return str ? str : "";
}
gboolean
-modest_account_mgr_add_server_account (ModestAccountMgr *self,
- const gchar *name,
- const gchar *hostname,
- const gchar *username,
- const gchar *password,
- const gchar *proto)
+modest_account_mgr_add_server_account (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * hostname,
+ const gchar * username,
+ const gchar * password,
+ const gchar * proto)
{
ModestAccountMgrPrivate *priv;
gchar *acckey, *key;
/* TODO: check already exists */
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
acckey = g_strconcat (MODEST_SERVER_ACCOUNT_NAMESPACE, "/",
name, NULL);
- if (modest_conf_key_exists(priv->modest_conf, acckey, NULL)) {
+ if (modest_conf_key_exists (priv->modest_conf, acckey, NULL)) {
g_warning ("server account %s already exists", name);
//g_free (acckey);
//return FALSE;
/* hostname */
key = g_strconcat (acckey, "/", MODEST_ACCOUNT_HOSTNAME, NULL);
modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(hostname), NULL);
+ null_means_empty (hostname), NULL);
g_free (key);
/* username */
key = g_strconcat (acckey, "/", MODEST_ACCOUNT_USERNAME, NULL);
modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(username), NULL);
+ null_means_empty (username), NULL);
g_free (key);
/* password */
- if (password)
- {
- key = g_strconcat (acckey, "/", MODEST_ACCOUNT_PASSWORD, NULL);
- modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(password), NULL);
- g_free (key);
- }
+ if (password) {
+ key = g_strconcat (acckey, "/", MODEST_ACCOUNT_PASSWORD,
+ NULL);
+ modest_conf_set_string (priv->modest_conf, key,
+ null_means_empty (password), NULL);
+ g_free (key);
+ }
/* proto */
key = g_strconcat (acckey, "/", MODEST_ACCOUNT_PROTO, NULL);
modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(proto),
- NULL);
+ null_means_empty (proto), NULL);
g_free (key);
g_free (acckey);
-
- return TRUE; /* FIXME: better error checking */
-}
-
-gboolean
-modest_account_mgr_remove_server_account (ModestAccountMgr *self,
- const gchar *name,
- GError **err)
-{
- ModestAccountMgrPrivate *priv;
- gchar *acckey, *key;
- gboolean retval;
-
- g_return_val_if_fail (self, FALSE);
- g_return_val_if_fail (name, FALSE);
-
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
-
- acckey = g_strconcat (MODEST_SERVER_ACCOUNT_NAMESPACE, "/",
- name, NULL);
-
- if (!modest_conf_key_exists(priv->modest_conf, acckey, NULL)) {
- g_warning ("server account %s does not exist exist", name);
- g_free (acckey);
- return FALSE;
- }
-
- retval = modest_conf_remove_key (priv->modest_conf, acckey, NULL);
- g_free (acckey);
- return retval;
+ return TRUE; /* FIXME: better error checking */
}
gboolean
-modest_account_mgr_remove_identity (ModestAccountMgr *self,
- const gchar *name,
- GError **err)
+modest_account_mgr_remove_server_account (ModestAccountMgr * self,
+ const gchar * name, GError ** err)
{
ModestAccountMgrPrivate *priv;
gchar *acckey, *key;
g_return_val_if_fail (self, FALSE);
g_return_val_if_fail (name, FALSE);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
- acckey = g_strconcat (MODEST_IDENTITY_NAMESPACE, "/",
+ acckey = g_strconcat (MODEST_SERVER_ACCOUNT_NAMESPACE, "/",
name, NULL);
- if (!modest_conf_key_exists(priv->modest_conf, acckey, NULL)) {
+ if (!modest_conf_key_exists (priv->modest_conf, acckey, NULL)) {
g_warning ("server account %s does not exist exist", name);
g_free (acckey);
return FALSE;
}
-
-gboolean
-modest_account_mgr_add_identity (ModestAccountMgr *self,
- const gchar *name,
- const gchar *email,
- const gchar *replyto,
- const gchar *signature,
- const gboolean use_signature,
- const gchar *id_via,
- const gboolean use_id_via)
-{
- ModestAccountMgrPrivate *priv;
- gchar *id_key, *key;
-
- g_return_val_if_fail (self, FALSE);
- g_return_val_if_fail (name, FALSE);
-
- /* TODO: check already exists */
-
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
- id_key = g_strconcat (MODEST_IDENTITY_NAMESPACE, "/",
- name, NULL);
-
- if (modest_conf_key_exists(priv->modest_conf, id_key, NULL)) {
- g_warning ("identity %s already exists", name);
- //g_free (id_key);
- //return FALSE;
- }
-
- /* email */
- key = g_strconcat (id_key, "/", MODEST_ACCOUNT_EMAIL, NULL);
- modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(email), NULL);
- g_free (key);
-
- /* replyto */
- key = g_strconcat (id_key, "/", MODEST_ACCOUNT_REPLYTO, NULL);
- modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(replyto), NULL);
- g_free (key);
-
- /* signature */
- key = g_strconcat (id_key, "/", MODEST_ACCOUNT_SIGNATURE, NULL);
- modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(signature), NULL);
- g_free (key);
-
- /* use_signature */
- key = g_strconcat (id_key, "/", MODEST_ACCOUNT_USE_SIGNATURE, NULL);
- modest_conf_set_bool (priv->modest_conf, key,
- use_signature, NULL);
- g_free (key);
-
- /* signature */
- key = g_strconcat (id_key, "/", MODEST_ACCOUNT_ID_VIA, NULL);
- modest_conf_set_string (priv->modest_conf, key,
- null_means_empty(id_via), NULL);
- g_free (key);
-
- /* use_signature */
- key = g_strconcat (id_key, "/", MODEST_ACCOUNT_USE_ID_VIA, NULL);
- modest_conf_set_bool (priv->modest_conf, key,
- use_id_via, NULL);
- g_free (key);
- g_free (id_key);
-
- return TRUE; /* FIXME: better error checking */
-}
-
/* strip the first /n/ character from each element */
/* caller must make sure all elements are strings with
* length >= n, and also that data can be freed.
*/
-static GSList*
-strip_prefix_from_elements (GSList *lst, guint n)
+static GSList *
+strip_prefix_from_elements (GSList * lst, guint n)
{
GSList *cursor = lst;
+
while (cursor) {
- gchar *str = (gchar*)cursor->data;
+ gchar *str = (gchar *) cursor->data;
+
cursor->data = g_strdup (str + n);
g_free (str);
cursor = cursor->next;
}
-
-GSList*
-modest_account_mgr_server_account_names (ModestAccountMgr *self,
- const gchar* account_name,
- ModestProtoType type,
- const gchar* proto,
- gboolean only_enabled)
+GSList *
+modest_account_mgr_server_account_names (ModestAccountMgr * self,
+ const gchar * account_name,
+ ModestProtoType type,
+ const gchar * proto,
+ gboolean only_enabled)
{
GSList *accounts;
GSList *cursor;
g_return_val_if_fail (self, NULL);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
accounts = modest_conf_list_subkeys (priv->modest_conf,
MODEST_SERVER_ACCOUNT_NAMESPACE,
NULL);
/* no restrictions, return everything */
if (type == MODEST_PROTO_TYPE_ANY && !proto)
- return strip_prefix_from_elements (accounts,prefix_len);
+ return strip_prefix_from_elements (accounts, prefix_len);
/* otherwise, filter out the none-matching ones */
cursor = accounts;
while (cursor) {
gchar *keyspace, *proto_key, *acc_proto;
- keyspace = (gchar*) cursor->data;
- proto_key = g_strconcat (keyspace, "/", MODEST_ACCOUNT_PROTO, NULL);
- acc_proto = modest_conf_get_string (priv->modest_conf, proto_key,
- NULL);
+ keyspace = (gchar *) cursor->data;
+ proto_key =
+ g_strconcat (keyspace, "/", MODEST_ACCOUNT_PROTO,
+ NULL);
+ acc_proto =
+ modest_conf_get_string (priv->modest_conf, proto_key,
+ NULL);
g_free (proto_key);
- if ((!acc_proto) || /* proto not defined? */
- (type != MODEST_PROTO_TYPE_ANY && /* proto type ... */
- modest_proto_type (acc_proto) != type) || /* ... matches? */
- (proto && strcmp(proto,acc_proto) != 0)) { /* proto matches? */
+ if ((!acc_proto) || /* proto not defined? */
+ (type != MODEST_PROTO_TYPE_ANY && /* proto type ... */
+ modest_proto_type (acc_proto) != type) || /* ... matches? */
+ (proto && strcmp (proto, acc_proto) != 0)) { /* proto matches? */
/* no match: remove from the list */
GSList *nxt = cursor->next;
+
g_free (acc_proto);
accounts = g_slist_delete_link (accounts, cursor);
cursor = nxt;
}
-
-GSList*
-modest_account_mgr_account_names (ModestAccountMgr *self, GError **err)
+GSList *
+modest_account_mgr_account_names (ModestAccountMgr * self, GError ** err)
{
GSList *accounts, *cursor;
ModestAccountMgrPrivate *priv;
- const size_t prefix_len =
- strlen (MODEST_ACCOUNT_NAMESPACE "/");
+ const size_t prefix_len = strlen (MODEST_ACCOUNT_NAMESPACE "/");
g_return_val_if_fail (self, NULL);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
accounts = modest_conf_list_subkeys (priv->modest_conf,
- MODEST_ACCOUNT_NAMESPACE,
- err);
+ MODEST_ACCOUNT_NAMESPACE, err);
return strip_prefix_from_elements (accounts, prefix_len);
}
-
-static gchar*
-get_account_string (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean server_account,
- GError **err)
+static gchar *
+get_account_string (ModestAccountMgr * self, const gchar * name,
+ const gchar * key, gboolean server_account, GError ** err)
{
ModestAccountMgrPrivate *priv;
gchar *keyname;
- gchar * retval;
+ gchar *retval;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (name, NULL);
else
keyname = get_account_keyname (name, key);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
- retval = modest_conf_get_string (priv->modest_conf,keyname,err);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ retval = modest_conf_get_string (priv->modest_conf, keyname, err);
g_free (keyname);
return retval;
}
-gchar*
-modest_account_mgr_get_server_account_string (ModestAccountMgr *self, const gchar *name,
- const gchar *key, GError **err)
+gchar *
+modest_account_mgr_get_server_account_string (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * key,
+ GError ** err)
{
return get_account_string (self, name, key, TRUE, err);
}
-gchar*
-modest_account_mgr_get_account_string (ModestAccountMgr *self, const gchar *name,
- const gchar *key, GError **err)
-{
- return get_account_string (self, name, key, FALSE, err);
-}
-gchar*
-modest_account_mgr_get_identity_string (ModestAccountMgr *self, const gchar *name,
- const gchar *key, GError **err)
+gchar *
+modest_account_mgr_get_account_string (ModestAccountMgr * self,
+ const gchar * name, const gchar * key,
+ GError ** err)
{
- ModestAccountMgrPrivate *priv;
-
- gchar *keyname;
- gchar * retval;
-
- g_return_val_if_fail (self, NULL);
- g_return_val_if_fail (name, NULL);
- g_return_val_if_fail (key, NULL);
-
- keyname = get_identity_keyname (name, key);
-
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
- retval = modest_conf_get_string (priv->modest_conf,keyname,err);
- g_free (keyname);
-
- return retval;
+ return get_account_string (self, name, key, FALSE, err);
}
static gint
-get_account_int (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean server_account,
- GError **err)
+get_account_int (ModestAccountMgr * self, const gchar * name,
+ const gchar * key, gboolean server_account, GError ** err)
{
ModestAccountMgrPrivate *priv;
else
keyname = get_account_keyname (name, key);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
- retval = modest_conf_get_int (priv->modest_conf,keyname,err);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ retval = modest_conf_get_int (priv->modest_conf, keyname, err);
g_free (keyname);
return retval;
gint
-modest_account_mgr_get_server_account_int (ModestAccountMgr *self, const gchar *name,
- const gchar *key, GError **err)
+modest_account_mgr_get_server_account_int (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * key, GError ** err)
{
return get_account_int (self, name, key, TRUE, err);
}
+
gint
-modest_account_mgr_get_account_int (ModestAccountMgr *self, const gchar *name,
- const gchar *key, GError **err)
+modest_account_mgr_get_account_int (ModestAccountMgr * self,
+ const gchar * name, const gchar * key,
+ GError ** err)
{
return get_account_int (self, name, key, FALSE, err);
}
-
static gboolean
-get_account_bool (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean server_account,
- GError **err)
+get_account_bool (ModestAccountMgr * self, const gchar * name,
+ const gchar * key, gboolean server_account, GError ** err)
{
ModestAccountMgrPrivate *priv;
else
keyname = get_account_keyname (name, key);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
- retval = modest_conf_get_int (priv->modest_conf,keyname,err);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ retval = modest_conf_get_int (priv->modest_conf, keyname, err);
g_free (keyname);
return retval;
}
-
gint
-modest_account_mgr_get_server_account_bool (ModestAccountMgr *self, const gchar *name,
- const gchar *key, GError **err)
+modest_account_mgr_get_server_account_bool (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * key, GError ** err)
{
return get_account_bool (self, name, key, TRUE, err);
}
+
gint
-modest_account_mgr_get_account_bool (ModestAccountMgr *self, const gchar *name,
- const gchar *key, GError **err)
+modest_account_mgr_get_account_bool (ModestAccountMgr * self,
+ const gchar * name, const gchar * key,
+ GError ** err)
{
return get_account_bool (self, name, key, FALSE, err);
}
-
-
-
static gboolean
-set_account_string (ModestAccountMgr *self, const gchar *name,
- const gchar *key, const gchar* val, gboolean server_account,
- GError **err)
+set_account_string (ModestAccountMgr * self, const gchar * name,
+ const gchar * key, const gchar * val,
+ gboolean server_account, GError ** err)
{
ModestAccountMgrPrivate *priv;
else
keyname = get_account_keyname (name, key);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
- retval = modest_conf_set_string (priv->modest_conf,keyname,val,err);
+ retval = modest_conf_set_string (priv->modest_conf, keyname, val,
+ err);
g_free (keyname);
return retval;
}
-
-
-
gboolean
-modest_account_mgr_set_server_account_string (ModestAccountMgr *self, const gchar *name,
- const gchar *key, const gchar* val,
- GError **err)
+modest_account_mgr_set_server_account_string (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * key,
+ const gchar * val,
+ GError ** err)
{
return set_account_string (self, name, key, val, TRUE, err);
}
-
gboolean
-modest_account_mgr_set_account_string (ModestAccountMgr *self, const gchar *name,
- const gchar *key, const gchar* val,
- GError **err)
+modest_account_mgr_set_account_string (ModestAccountMgr * self,
+ const gchar * name, const gchar * key,
+ const gchar * val, GError ** err)
{
return set_account_string (self, name, key, val, FALSE, err);
}
static gboolean
-set_account_int (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean server_account, int val,
- GError **err)
+set_account_int (ModestAccountMgr * self, const gchar * name,
+ const gchar * key, gboolean server_account, int val,
+ GError ** err)
{
ModestAccountMgrPrivate *priv;
else
keyname = get_account_keyname (name, key);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
- retval = modest_conf_set_int (priv->modest_conf,keyname,val,err);
+ retval = modest_conf_set_int (priv->modest_conf, keyname, val, err);
g_free (keyname);
return retval;
}
-
gboolean
-modest_account_mgr_set_server_account_int (ModestAccountMgr *self, const gchar *name,
- const gchar *key, int val,
- GError **err)
+modest_account_mgr_set_server_account_int (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * key, int val,
+ GError ** err)
{
return set_account_int (self, name, key, val, TRUE, err);
}
gboolean
-modest_account_mgr_set_account_int (ModestAccountMgr *self, const gchar *name,
- const gchar *key, int val,
- GError **err)
+modest_account_mgr_set_account_int (ModestAccountMgr * self,
+ const gchar * name, const gchar * key,
+ int val, GError ** err)
{
return set_account_int (self, name, key, val, FALSE, err);
}
-
-
static gboolean
-set_account_bool (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean server_account, gboolean val,
- GError **err)
+set_account_bool (ModestAccountMgr * self, const gchar * name,
+ const gchar * key, gboolean server_account, gboolean val,
+ GError ** err)
{
ModestAccountMgrPrivate *priv;
else
keyname = get_account_keyname (name, key);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
- retval = modest_conf_set_bool (priv->modest_conf,keyname,val,err);
+ retval = modest_conf_set_bool (priv->modest_conf, keyname, val, err);
g_free (keyname);
return retval;
gboolean
-modest_account_mgr_set_server_account_bool (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean val,
- GError **err)
+modest_account_mgr_set_server_account_bool (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * key, gboolean val,
+ GError ** err)
{
return set_account_bool (self, name, key, val, TRUE, err);
}
-
gboolean
-modest_account_mgr_set_account_bool (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean val,
- GError **err)
+modest_account_mgr_set_account_bool (ModestAccountMgr * self,
+ const gchar * name, const gchar * key,
+ gboolean val, GError ** err)
{
return set_account_bool (self, name, key, val, FALSE, err);
}
-
-
-
gboolean
-account_exists (ModestAccountMgr *self, const gchar *name, gboolean server_account,
- GError **err)
+account_exists (ModestAccountMgr * self, const gchar * name,
+ gboolean server_account, GError ** err)
{
ModestAccountMgrPrivate *priv;
else
keyname = get_server_account_keyname (name, NULL);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE(self);
- retval = modest_conf_key_exists (priv->modest_conf,keyname,err);
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ retval = modest_conf_key_exists (priv->modest_conf, keyname, err);
g_free (keyname);
return retval;
gboolean
-modest_account_mgr_server_account_exists (ModestAccountMgr *self, const gchar *name,
- GError **err)
+modest_account_mgr_server_account_exists (ModestAccountMgr * self,
+ const gchar * name, GError ** err)
{
return account_exists (self, name, TRUE, err);
}
gboolean
-modest_account_mgr_account_exists (ModestAccountMgr *self, const gchar *name,
- GError **err)
+modest_account_mgr_account_exists (ModestAccountMgr * self,
+ const gchar * name, GError ** err)
{
return account_exists (self, name, FALSE, err);
}
-gboolean
-modest_account_mgr_identity_exists (ModestAccountMgr *self, const gchar *name,
- GError **err)
-{
- return account_exists (self, name, TRUE, err);
-}
-
-
-
-/* must be freed by caller */
-static gchar*
-get_account_keyname (const gchar *accname, const gchar *name)
-{
- if (name)
- return g_strconcat
- (MODEST_ACCOUNT_NAMESPACE, "/",
- accname, "/", name, NULL);
- else
- return g_strconcat
- (MODEST_ACCOUNT_NAMESPACE, "/",
- accname, NULL);
-}
-
/* must be freed by caller */
-static gchar*
-get_server_account_keyname (const gchar *accname, const gchar *name)
+static gchar *
+get_account_keyname (const gchar * accname, const gchar * name)
{
if (name)
return g_strconcat
- (MODEST_SERVER_ACCOUNT_NAMESPACE, "/",
+ (MODEST_ACCOUNT_NAMESPACE, "/",
accname, "/", name, NULL);
else
return g_strconcat
- (MODEST_SERVER_ACCOUNT_NAMESPACE, "/",
- accname, NULL);
+ (MODEST_ACCOUNT_NAMESPACE, "/", accname, NULL);
}
+
/* must be freed by caller */
-static gchar*
-get_identity_keyname (const gchar *accname, const gchar *name)
+static gchar *
+get_server_account_keyname (const gchar * accname, const gchar * name)
{
if (name)
return g_strconcat
- (MODEST_IDENTITY_NAMESPACE "/",
+ (MODEST_SERVER_ACCOUNT_NAMESPACE, "/",
accname, "/", name, NULL);
else
return g_strconcat
- (MODEST_IDENTITY_NAMESPACE, "/",
- accname, NULL);
+ (MODEST_SERVER_ACCOUNT_NAMESPACE, "/", accname, NULL);
}
--- /dev/null
+/* modest-identity-mgr.c */
+
+/* insert (c)/licensing information) */
+
+#include <string.h>
+#include "modest-identity-mgr.h"
+
+/* 'private'/'protected' functions */
+static void modest_identity_mgr_class_init (ModestIdentityMgrClass * klass);
+static void modest_identity_mgr_init (ModestIdentityMgr * obj);
+static void modest_identity_mgr_finalize (GObject * obj);
+
+static gchar *get_identity_keyname (const gchar * accname,
+ const gchar * name);
+
+/* list my signals */
+enum {
+ /* MY_SIGNAL_1, */
+ /* MY_SIGNAL_2, */
+ LAST_SIGNAL
+};
+
+typedef struct _ModestIdentityMgrPrivate ModestIdentityMgrPrivate;
+struct _ModestIdentityMgrPrivate {
+ ModestConf *modest_conf;
+};
+
+#define MODEST_IDENTITY_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+ MODEST_TYPE_IDENTITY_MGR, \
+ ModestIdentityMgrPrivate))
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+/* uncomment the following if you have defined any signals */
+/* static guint signals[LAST_SIGNAL] = {0}; */
+
+GType
+modest_identity_mgr_get_type (void)
+{
+ static GType my_type = 0;
+
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof (ModestIdentityMgrClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_identity_mgr_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof (ModestIdentityMgr),
+ 1, /* n_preallocs */
+ (GInstanceInitFunc) modest_identity_mgr_init,
+ };
+
+ my_type = g_type_register_static (G_TYPE_OBJECT,
+ "ModestIdentityMgr",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_identity_mgr_class_init (ModestIdentityMgrClass * klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = modest_identity_mgr_finalize;
+
+ g_type_class_add_private (gobject_class,
+ sizeof (ModestIdentityMgrPrivate));
+
+/* signal definitions go here, e.g.: */
+/* signals[MY_SIGNAL_1] = */
+/* g_signal_new ("my_signal_1",....); */
+/* signals[MY_SIGNAL_2] = */
+/* g_signal_new ("my_signal_2",....); */
+/* etc. */
+}
+
+
+static void
+modest_identity_mgr_init (ModestIdentityMgr * obj)
+{
+ ModestIdentityMgrPrivate *priv =
+ MODEST_IDENTITY_MGR_GET_PRIVATE (obj);
+ priv->modest_conf = NULL;
+}
+
+static void
+modest_identity_mgr_finalize (GObject * obj)
+{
+ ModestIdentityMgr *self = MODEST_IDENTITY_MGR (obj);
+ ModestIdentityMgrPrivate *priv =
+ MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+
+ g_object_unref (G_OBJECT (priv->modest_conf));
+ priv->modest_conf = NULL;
+}
+
+GObject *
+modest_identity_mgr_new (ModestConf * conf)
+{
+ GObject *obj;
+ ModestIdentityMgrPrivate *priv;
+
+ g_return_val_if_fail (conf, NULL);
+
+ obj = G_OBJECT (g_object_new (MODEST_TYPE_IDENTITY_MGR, NULL));
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (obj);
+
+ /*
+ * increase the ref count on the modest_conf. Normally, the
+ * ModestConf should outlive the ModestIdentityMgr though
+ */
+ g_object_ref (G_OBJECT (priv->modest_conf = conf));
+ return obj;
+}
+
+
+gboolean
+modest_identity_mgr_remove_identity (ModestIdentityMgr * self,
+ const gchar * name, GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+ gchar *key;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (name, FALSE);
+
+ if (!modest_identity_mgr_identity_exists (self, name, err)) {
+ g_warning ("identity doest not exist");
+ return FALSE;
+ }
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+ key = get_identity_keyname (name, NULL);
+
+ retval = modest_conf_remove_key (priv->modest_conf, key, NULL);
+
+ g_free (key);
+ return retval;
+}
+
+
+static const gchar *
+null_means_empty (const gchar * str)
+{
+ return str ? str : "";
+}
+
+
+gboolean
+modest_identity_mgr_add_identity (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * email,
+ const gchar * replyto,
+ const gchar * signature,
+ const gboolean use_signature,
+ const gchar * id_via,
+ const gboolean use_id_via)
+{
+ ModestIdentityMgrPrivate *priv;
+ gchar *id_key, *key;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (name, FALSE);
+
+ /* TODO: check already exists */
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+ id_key = g_strconcat (MODEST_IDENTITY_NAMESPACE, "/", name, NULL);
+
+ if (modest_conf_key_exists (priv->modest_conf, id_key, NULL)) {
+ g_warning ("identity %s already exists", name);
+ //g_free (id_key);
+ //return FALSE;
+ }
+
+ /* email */
+ key = g_strconcat (id_key, "/", MODEST_IDENTITY_EMAIL, NULL);
+ modest_conf_set_string (priv->modest_conf, key,
+ null_means_empty (email), NULL);
+ g_free (key);
+
+ /* replyto */
+ key = g_strconcat (id_key, "/", MODEST_IDENTITY_REPLYTO, NULL);
+ modest_conf_set_string (priv->modest_conf, key,
+ null_means_empty (replyto), NULL);
+ g_free (key);
+
+ /* signature */
+ key = g_strconcat (id_key, "/", MODEST_IDENTITY_SIGNATURE, NULL);
+ modest_conf_set_string (priv->modest_conf, key,
+ null_means_empty (signature), NULL);
+ g_free (key);
+
+ /* use_signature */
+ key = g_strconcat (id_key, "/", MODEST_IDENTITY_USE_SIGNATURE, NULL);
+ modest_conf_set_bool (priv->modest_conf, key, use_signature, NULL);
+ g_free (key);
+
+ /* signature */
+ key = g_strconcat (id_key, "/", MODEST_IDENTITY_ID_VIA, NULL);
+ modest_conf_set_string (priv->modest_conf, key,
+ null_means_empty (id_via), NULL);
+ g_free (key);
+
+ /* use_signature */
+ key = g_strconcat (id_key, "/", MODEST_IDENTITY_USE_ID_VIA, NULL);
+ modest_conf_set_bool (priv->modest_conf, key, use_id_via, NULL);
+ g_free (key);
+ g_free (id_key);
+
+ return TRUE; /* FIXME: better error checking */
+}
+
+/* strip the first /n/ character from each element */
+/* caller must make sure all elements are strings with
+ * length >= n, and also that data can be freed.
+ */
+/* this function is copied from modest-account-mgr. Maybe it should be moved
+ * to modest-list-utils or the like...
+ */
+static GSList *
+strip_prefix_from_elements (GSList * lst, guint n)
+{
+ GSList *cursor = lst;
+
+ while (cursor) {
+ gchar *str = (gchar *) cursor->data;
+
+ cursor->data = g_strdup (str + n);
+ g_free (str);
+ cursor = cursor->next;
+ }
+ return lst;
+}
+
+GSList *
+modest_identity_mgr_identity_names (ModestIdentityMgr * self, GError ** err)
+{
+ GSList *identities, *cursor;
+ ModestIdentityMgrPrivate *priv;
+ const size_t prefix_len = strlen (MODEST_IDENTITY_NAMESPACE "/");
+
+
+ g_return_val_if_fail (self, NULL);
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+
+ identities = modest_conf_list_subkeys (priv->modest_conf,
+ MODEST_IDENTITY_NAMESPACE,
+ err);
+ return strip_prefix_from_elements (identities, prefix_len);
+}
+
+
+gchar *
+modest_identity_mgr_get_identity_string (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * key, GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+
+ gchar *keyname;
+ gchar *retval;
+
+ g_return_val_if_fail (self, NULL);
+ g_return_val_if_fail (name, NULL);
+ g_return_val_if_fail (key, NULL);
+
+ keyname = get_identity_keyname (name, key);
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+ retval = modest_conf_get_string (priv->modest_conf, keyname, err);
+ g_free (keyname);
+
+ return retval;
+}
+
+
+gint
+modest_identity_mgr_get_identity_int (ModestIdentityMgr * self,
+ const gchar * name, const gchar * key,
+ GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+
+ gchar *keyname;
+ gint retval;
+
+ g_return_val_if_fail (self, -1);
+ g_return_val_if_fail (name, -1);
+ g_return_val_if_fail (key, -1);
+
+ keyname = get_identity_keyname (name, key);
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+ retval = modest_conf_get_int (priv->modest_conf, keyname, err);
+ g_free (keyname);
+
+ return retval;
+}
+
+
+
+gboolean
+modest_identity_mgr_get_identity_bool (ModestIdentityMgr * self,
+ const gchar * name, const gchar * key,
+ GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+
+ gchar *keyname;
+ gboolean retval;
+
+ g_return_val_if_fail (self, -1);
+ g_return_val_if_fail (name, -1);
+ g_return_val_if_fail (key, -1);
+
+ keyname = get_identity_keyname (name, key);
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+ retval = modest_conf_get_int (priv->modest_conf, keyname, err);
+ g_free (keyname);
+
+ return retval;
+}
+
+
+gboolean
+modest_identity_mgr_set_identity_string (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * key, const gchar * val,
+ GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+
+ gchar *keyname;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (name, FALSE);
+ g_return_val_if_fail (key, FALSE);
+
+ keyname = get_identity_keyname (name, key);
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+
+ retval = modest_conf_set_string (priv->modest_conf, keyname, val,
+ err);
+
+ g_free (keyname);
+ return retval;
+}
+
+
+gboolean
+modest_identity_mgr_set_identity_int (ModestIdentityMgr * self,
+ const gchar * name, const gchar * key,
+ const gint val, GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+
+ gchar *keyname;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (name, FALSE);
+ g_return_val_if_fail (key, FALSE);
+
+ keyname = get_identity_keyname (name, key);
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+
+ retval = modest_conf_set_int (priv->modest_conf, keyname, val, err);
+
+ g_free (keyname);
+ return retval;
+}
+
+
+gboolean
+modest_identy_mgr_set_identity_bool (ModestIdentityMgr * self,
+ const gchar * name, const gchar * key,
+ gboolean val, GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+
+ gchar *keyname;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (name, FALSE);
+ g_return_val_if_fail (key, FALSE);
+
+ keyname = get_identity_keyname (name, key);
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+
+ retval = modest_conf_set_bool (priv->modest_conf, keyname, val, err);
+
+ g_free (keyname);
+ return retval;
+}
+
+
+gboolean
+modest_identity_mgr_identity_exists (ModestIdentityMgr * self,
+ const gchar * name, GError ** err)
+{
+ ModestIdentityMgrPrivate *priv;
+
+ gchar *keyname;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (name, FALSE);
+
+ keyname = get_identity_keyname (name, NULL);
+
+ priv = MODEST_IDENTITY_MGR_GET_PRIVATE (self);
+ retval = modest_conf_key_exists (priv->modest_conf, keyname, err);
+
+ g_free (keyname);
+ return retval;
+}
+
+
+/* must be freed by caller */
+static gchar *
+get_identity_keyname (const gchar * idname, const gchar * name)
+{
+ if (name)
+ return g_strconcat
+ (MODEST_IDENTITY_NAMESPACE, "/",
+ idname, "/", name, NULL);
+ else
+ return g_strconcat
+ (MODEST_IDENTITY_NAMESPACE, "/", idname, NULL);
+}
--- /dev/null
+/* modest-identity-mgr.h */
+/* insert (c)/licensing information) */
+
+#ifndef __MODEST_IDENTITY_MGR_H__
+#define __MODEST_IDENTITY_MGR_H__
+
+#include <glib-object.h>
+#include "modest-conf.h"
+#include "modest-identity-keys.h"
+#include "modest-proto.h"
+
+G_BEGIN_DECLS
+/* convenience macros */
+#define MODEST_TYPE_IDENTITY_MGR (modest_identity_mgr_get_type())
+#define MODEST_IDENTITY_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_IDENTITY_MGR,ModestIdentityMgr))
+#define MODEST_IDENTITY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_IDENTITY_MGR,GObject))
+#define MODEST_IS_IDENTITY_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_IDENTITY_MGR))
+#define MODEST_IS_IDENTITY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_IDENTITY_MGR))
+#define MODEST_IDENTITY_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_IDENTITY_MGR,ModestIdentityMgrClass))
+typedef struct _ModestIdentityMgr ModestIdentityMgr;
+typedef struct _ModestIdentityMgrClass ModestIdentityMgrClass;
+
+
+struct _ModestIdentityMgr {
+ GObject parent;
+ /* insert public members, if any */
+};
+
+struct _ModestIdentityMgrClass {
+ GObjectClass parent_class;
+ /* insert signal callback declarations, eg. */
+ /* void (* my_event) (ModestIdentityMgr* obj); */
+};
+
+
+/**
+ * modest_ui_get_type:
+ *
+ * get the GType for ModestIdentityMgr
+ *
+ * Returns: the GType
+ */
+GType modest_identity_mgr_get_type (void) G_GNUC_CONST;
+
+
+/**
+ * modest_identity_mgr_new:
+ * @modest_conf: a ModestConf instance
+ *
+ * Returns: a new ModestIdentityMgr, or NULL in case of error
+ */
+GObject * modest_identity_mgr_new (ModestConf * modest_conf);
+
+
+/**
+ * modest_identity_mgr_add_identity:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name (id) for the identity
+ * @email: the user's email address which is used when sending email
+ * @replyto: the default replyto address
+ * @signature: the signature for this identity
+ * @use_signature: whether to use this signature instead of the default one
+ * @id_via: the transport to send emails for this identity via
+ * @use_id_via: whether to use this via instead of the default one
+ *
+ * add a user identity to the configuration
+ *
+ * Returns: TRUE if succeeded, FALSE otherwise,
+ */
+gboolean modest_identity_mgr_add_identity (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * email,
+ const gchar * replyto,
+ const gchar * signature,
+ const gboolean use_signature,
+ const gchar * id_via,
+ const gboolean use_id_via);
+
+
+/**
+ * modest_identity_mgr_remove_identity:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name of the identity to remove
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * remove identity from the configuration
+ * the identity with @name should exist
+ *
+ * Returns: TRUE if the removal succeeded, FALSE otherwise,
+ * @err gives details in case of error
+ */
+gboolean modest_identity_mgr_remove_identity (ModestIdentityMgr * self,
+ const gchar * name,
+ GError ** err);
+
+
+/**
+ * modest_identity_mgr_identity_names:
+ * @self: a ModestIdentityMgr instance
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * list all identities
+ *
+ * Returns: a newly allocated list of identities, or NULL in case of error or
+ * if there are no identities. The caller must free the returned GSList
+ * @err gives details in case of error
+ */
+GSList *modest_identity_mgr_identity_names (ModestIdentityMgr * self,
+ GError ** err);
+
+
+/**
+ * modest_identity_mgr_identity_exists:
+ * @self: a ModestIdentityMgr instance
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * check whether identity @name exists
+ *
+ * Returns: TRUE if the identity exists, FALSE otherwise (or in case of error)
+ * @err gives details in case of error
+ */
+gboolean modest_identity_mgr_identity_exists (ModestIdentityMgr * self,
+ const gchar * name,
+ GError ** err);
+
+
+/* identity specific functions */
+
+/**
+ * modest_identity_mgr_get_identity_string:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name of the identity
+ * @key: the key of the value to retrieve
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * get a config string from an identity
+ *
+ * Returns: a newly allocated string with the value for the key,
+ * or NULL in case of error. @err gives details in case of error
+ */
+gchar *modest_identity_mgr_get_identity_string (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * key,
+ GError ** err);
+
+
+/**
+ * modest_identity_mgr_get_identity_int:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name of the identity
+ * @key: the key of the value to retrieve
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * get a config int from an identity
+ *
+ * Returns: an integer with the value for the key, or -1 in case of
+ * error (but of course -1 does not necessarily imply an error)
+ * @err gives details in case of error
+ */
+gint modest_identity_mgr_get_identity_int (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * key,
+ GError ** err);
+
+
+/**
+ * modest_identity_mgr_get_identity_bool:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name of the identity
+ * @key: the key of the value to retrieve
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * get a config boolean from an identity
+ *
+ * Returns: an boolean with the value for the key, or FALSE in case of
+ * error (but of course FALSE does not necessarily imply an error)
+ * @err gives details in case of error
+ */
+gboolean modest_identity_mgr_get_identity_bool (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * key,
+ GError ** err);
+
+
+/**
+ * modest_identity_mgr_set_identity_string:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name of the identity
+ * @key: the key of the value to set
+ * @val: the value to set
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * set a config string for an identity
+ *
+ * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
+ * @err gives details in case of error
+ */
+gboolean modest_identity_mgr_set_identity_string (ModestIdentityMgr *
+ self,
+ const gchar * name,
+ const gchar * key,
+ const gchar * val,
+ GError ** err);
+
+
+/**
+ * modest_identity_mgr_set_identity_int:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name of the identity
+ * @key: the key of the value to set
+ * @val: the value to set
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * set a config int for an identity
+ *
+ * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
+ * @err gives details in case of error
+ */
+gboolean modest_identity_mgr_set_identity_int (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * key,
+ gint val, GError ** err);
+
+
+/**
+ * modest_identity_mgr_set_identity_bool:
+ * @self: a ModestIdentityMgr instance
+ * @name: the name of the identity
+ * @key: the key of the value to set
+ * @val: the value to set
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * set a config bool for an identity
+ *
+ * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
+ * @err gives details in case of error
+ */
+gboolean modest_identity_mgr_set_identity_bool (ModestIdentityMgr * self,
+ const gchar * name,
+ const gchar * key,
+ gboolean val,
+ GError ** err);
+
+
+G_END_DECLS
+#endif /* __MODEST_IDENTITY_MGR_H__ */