[frogr] Provide API for setting/getting the version for a FrogrAccount
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Provide API for setting/getting the version for a FrogrAccount
- Date: Wed, 4 Apr 2012 19:14:11 +0000 (UTC)
commit 3df71dc2e000fc3884e95a29a69098afca217c2f
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Wed Apr 4 21:12:06 2012 +0200
Provide API for setting/getting the version for a FrogrAccount
src/frogr-account.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/frogr-account.h | 5 +++++
src/frogr-config.c | 7 +++++++
3 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/src/frogr-account.c b/src/frogr-account.c
index 720bee0..8c73b11 100644
--- a/src/frogr-account.c
+++ b/src/frogr-account.c
@@ -40,6 +40,7 @@ struct _FrogrAccountPrivate
gchar *id;
gchar *username;
gchar *fullname;
+ gchar *version;
gboolean is_active;
/* Following properties won't be persistent */
@@ -59,6 +60,7 @@ enum {
PROP_ID,
PROP_USERNAME,
PROP_FULLNAME,
+ PROP_VERSION,
PROP_IS_ACTIVE,
PROP_REMAINING_BANDWIDTH,
PROP_MAX_BANDWIDTH,
@@ -103,6 +105,10 @@ _frogr_account_set_property (GObject *object,
frogr_account_set_fullname (self, g_value_get_string (value));
break;
+ case PROP_VERSION:
+ frogr_account_set_version (self, g_value_get_string (value));
+ break;
+
case PROP_IS_ACTIVE:
frogr_account_set_is_active (self, g_value_get_boolean (value));
break;
@@ -162,6 +168,10 @@ _frogr_account_get_property (GObject *object,
g_value_set_string (value, priv->fullname);
break;
+ case PROP_VERSION:
+ g_value_set_string (value, priv->version);
+ break;
+
case PROP_IS_ACTIVE:
g_value_set_boolean (value, priv->is_active);
break;
@@ -198,6 +208,7 @@ _frogr_account_finalize (GObject *object)
g_free (priv->id);
g_free (priv->username);
g_free (priv->fullname);
+ g_free (priv->version);
/* Call superclass */
G_OBJECT_CLASS (frogr_account_parent_class)->finalize (object);
@@ -255,6 +266,13 @@ frogr_account_class_init (FrogrAccountClass *klass)
G_PARAM_READWRITE);
g_object_class_install_property (obj_class, PROP_FULLNAME, pspec);
+ pspec = g_param_spec_string ("version",
+ "version",
+ "Version of the format used to store"
+ "the details for an account",
+ "",
+ G_PARAM_READWRITE);
+ g_object_class_install_property (obj_class, PROP_VERSION, pspec);
pspec = g_param_spec_boolean ("is-active",
"is-active",
@@ -304,6 +322,7 @@ frogr_account_init (FrogrAccount *self)
priv->id = NULL;
priv->username = NULL;
priv->fullname = NULL;
+ priv->version = NULL;
priv->is_active = FALSE;
priv->remaining_bandwidth = G_MAXULONG;
priv->max_bandwidth = G_MAXULONG;
@@ -610,6 +629,29 @@ frogr_account_is_valid (FrogrAccount *self)
return TRUE;
}
+const gchar*
+frogr_account_get_version (FrogrAccount *self)
+{
+ FrogrAccountPrivate *priv = NULL;
+
+ g_return_val_if_fail (FROGR_IS_ACCOUNT (self), FALSE);
+
+ priv = FROGR_ACCOUNT_GET_PRIVATE (self);
+ return priv->version;
+}
+
+void
+frogr_account_set_version (FrogrAccount *self, const gchar *version)
+{
+ FrogrAccountPrivate *priv = NULL;
+
+ g_return_if_fail (FROGR_IS_ACCOUNT (self));
+
+ priv = FROGR_ACCOUNT_GET_PRIVATE (self);
+ g_free (priv->version);
+ priv->version = g_strdup (version);
+}
+
gboolean
frogr_account_equal (FrogrAccount *self, FrogrAccount *other)
{
@@ -647,6 +689,9 @@ frogr_account_equal (FrogrAccount *self, FrogrAccount *other)
if (g_strcmp0 (priv_a->fullname, priv_b->fullname))
return FALSE;
+ if (g_strcmp0 (priv_a->version, priv_b->version))
+ return FALSE;
+
if (priv_a->remaining_bandwidth != priv_b->remaining_bandwidth)
return FALSE;
diff --git a/src/frogr-account.h b/src/frogr-account.h
index 053d326..35b2014 100644
--- a/src/frogr-account.h
+++ b/src/frogr-account.h
@@ -114,6 +114,11 @@ void frogr_account_set_is_pro (FrogrAccount *self, gboolean is_pro);
gboolean frogr_account_is_valid (FrogrAccount *self);
+const gchar* frogr_account_get_version (FrogrAccount *self);
+
+void frogr_account_set_version (FrogrAccount *self,
+ const gchar *version);
+
gboolean frogr_account_equal (FrogrAccount *self, FrogrAccount *other);
G_END_DECLS
diff --git a/src/frogr-config.c b/src/frogr-config.c
index ea76b29..5503abb 100644
--- a/src/frogr-config.c
+++ b/src/frogr-config.c
@@ -636,6 +636,13 @@ _load_account_xml (FrogrAccount *faccount,
frogr_account_set_is_active (faccount, is_active);
}
+ if (xmlStrcmp (node->name, (const xmlChar*) "version") == 0)
+ {
+ content = xmlNodeGetContent (node);
+ if (content != NULL && content[0] != '\0')
+ frogr_account_set_version (faccount, (gchar *)content);
+ }
+
if (content != NULL)
xmlFree (content);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]