summaryrefslogtreecommitdiff
path: root/src/trg-prefs.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-10-19 20:21:19 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-10-19 20:21:19 +0000
commit3fa2dbf607db03b7f2535d7eb98ee6bdae0239dd (patch)
treec134603b54c23cd2dfc2a14650d8d39394dfd139 /src/trg-prefs.c
parenta04430bff79030690add518548677251816e3e71 (diff)
implement a TRG_PREFS_CONNECTION flag which gets prefs for the connected profile
Diffstat (limited to 'src/trg-prefs.c')
-rw-r--r--src/trg-prefs.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/trg-prefs.c b/src/trg-prefs.c
index 1501217..90d8887 100644
--- a/src/trg-prefs.c
+++ b/src/trg-prefs.c
@@ -39,6 +39,7 @@ struct _TrgPrefsPrivate {
JsonObject *defaultsObj;
JsonNode *user;
JsonObject *userObj;
+ JsonObject *connectionObj;
JsonObject *profile;
gchar *file;
};
@@ -213,8 +214,10 @@ JsonNode *trg_prefs_get_value(TrgPrefs *p, gchar *key, int type, int flags) {
JsonNode *res;
if ((flags & TRG_PREFS_PROFILE)) {
- JsonObject *profile = trg_prefs_get_profile(p);
- if ((res = trg_prefs_get_value_inner(profile, key, type, flags)))
+ if ((res = trg_prefs_get_value_inner(trg_prefs_get_profile(p), key, type, flags)))
+ return res;
+ } else if ((flags & TRG_PREFS_CONNECTION)) {
+ if ((res = trg_prefs_get_value_inner(priv->connectionObj, key, type, flags)))
return res;
} else {
if ((res = trg_prefs_get_value_inner(priv->userObj, key, type, flags)))
@@ -227,6 +230,19 @@ JsonNode *trg_prefs_get_value(TrgPrefs *p, gchar *key, int type, int flags) {
return NULL;
}
+void trg_prefs_set_connection(TrgPrefs *p, JsonObject *profile)
+{
+ TrgPrefsPrivate *priv = GET_PRIVATE(p);
+
+ if (priv->connectionObj)
+ json_object_unref(priv->connectionObj);
+
+ if (profile)
+ json_object_ref(profile);
+
+ priv->connectionObj = profile;
+}
+
gchar *trg_prefs_get_string(TrgPrefs *p, gchar *key, int flags) {
JsonNode *node = trg_prefs_get_value(p, key, JSON_NODE_VALUE, flags);
if (node)
@@ -337,6 +353,11 @@ JsonObject* trg_prefs_get_profile(TrgPrefs *p) {
return priv->profile;
}
+JsonObject* trg_prefs_get_connection(TrgPrefs *p) {
+ TrgPrefsPrivate *priv = GET_PRIVATE(p);
+ return priv->connectionObj;
+}
+
JsonArray* trg_prefs_get_profiles(TrgPrefs *p) {
TrgPrefsPrivate *priv = GET_PRIVATE(p);
return json_object_get_array_member(priv->userObj, TRG_PREFS_KEY_PROFILES);