about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/account.c11
-rw-r--r--src/config/account.h7
-rw-r--r--src/config/accounts.c34
3 files changed, 49 insertions, 3 deletions
diff --git a/src/config/account.c b/src/config/account.c
index d982fb88..e019bf83 100644
--- a/src/config/account.c
+++ b/src/config/account.c
@@ -34,7 +34,9 @@ account_new(const gchar * const name, const gchar * const jid,
     int port, const gchar * const resource, const gchar * const last_presence,
     const gchar * const login_presence, int priority_online, int priority_chat,
     int priority_away, int priority_xa, int priority_dnd,
-    const gchar * const muc_service, const gchar * const muc_nick, const gchar * const otr_policy)
+    const gchar * const muc_service, const gchar * const muc_nick,
+    const gchar * const otr_policy, GList *otr_manual, GList *otr_opportunistic,
+    GList *otr_always)
 {
     ProfAccount *new_account = malloc(sizeof(ProfAccount));
 
@@ -117,6 +119,10 @@ account_new(const gchar * const name, const gchar * const jid,
         new_account->otr_policy = NULL;
     }
 
+    new_account->otr_manual = otr_manual;
+    new_account->otr_opportunistic = otr_opportunistic;
+    new_account->otr_always = otr_always;
+
     return new_account;
 }
 
@@ -144,6 +150,9 @@ account_free(ProfAccount *account)
         free(account->muc_service);
         free(account->muc_nick);
         free(account->otr_policy);
+        g_list_free_full(account->otr_manual, g_free);
+        g_list_free_full(account->otr_opportunistic, g_free);
+        g_list_free_full(account->otr_always, g_free);
         free(account);
     }
 }
\ No newline at end of file
diff --git a/src/config/account.h b/src/config/account.h
index 549e9124..9943538f 100644
--- a/src/config/account.h
+++ b/src/config/account.h
@@ -43,6 +43,9 @@ typedef struct prof_account_t {
     gchar *muc_nick;
     gboolean enabled;
     gchar *otr_policy;
+    GList *otr_manual;
+    GList *otr_opportunistic;
+    GList *otr_always;
 } ProfAccount;
 
 ProfAccount* account_new(const gchar * const name, const gchar * const jid,
@@ -50,7 +53,9 @@ ProfAccount* account_new(const gchar * const name, const gchar * const jid,
     int port, const gchar * const resource, const gchar * const last_presence,
     const gchar * const login_presence, int priority_online, int priority_chat,
     int priority_away, int priority_xa, int priority_dnd,
-    const gchar * const muc_service, const gchar * const muc_nick, const gchar * const otr_policy);
+    const gchar * const muc_service, const gchar * const muc_nick,
+    const gchar * const otr_policy, GList *otr_manual, GList *otr_opportunistic,
+    GList *otr_always);
 
 char* account_create_full_jid(ProfAccount *account);
 
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 79b9eceb..56c1b5c8 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -220,10 +220,42 @@ _accounts_get_account(const char * const name)
             otr_policy = g_key_file_get_string(accounts, name, "otr.policy", NULL);
         }
 
+        gsize length;
+        GList *otr_manual = NULL;
+        gchar **manual = g_key_file_get_string_list(accounts, name, "otr.manual", &length, NULL);
+        if (manual != NULL) {
+            int i = 0;
+            for (i = 0; i < length; i++) {
+                otr_manual = g_list_append(otr_manual, strdup(manual[i]));
+            }
+            g_strfreev(manual);
+        }
+
+        GList *otr_opportunistic = NULL;
+        gchar **opportunistic = g_key_file_get_string_list(accounts, name, "otr.opportunistic", &length, NULL);
+        if (opportunistic != NULL) {
+            int i = 0;
+            for (i = 0; i < length; i++) {
+                otr_opportunistic = g_list_append(otr_opportunistic, strdup(opportunistic[i]));
+            }
+            g_strfreev(opportunistic);
+        }
+
+        GList *otr_always = NULL;
+        gchar **always = g_key_file_get_string_list(accounts, name, "otr.always", &length, NULL);
+        if (always != NULL) {
+            int i = 0;
+            for (i = 0; i < length; i++) {
+                otr_always = g_list_append(otr_always, strdup(always[i]));
+            }
+            g_strfreev(always);
+        }
+
         ProfAccount *new_account = account_new(name, jid, password, enabled,
             server, port, resource, last_presence, login_presence,
             priority_online, priority_chat, priority_away, priority_xa,
-            priority_dnd, muc_service, muc_nick, otr_policy);
+            priority_dnd, muc_service, muc_nick, otr_policy, otr_manual,
+            otr_opportunistic, otr_always);
 
         g_free(jid);
         g_free(password);