Mercurial > hg
changeset 2341:c78988260b9f
Don't remove otr policies if they match the default policy
This was not neither obvious to the user nor documented.
author | franky |
---|---|
date | Sun, 19 May 2019 09:59:38 +0200 |
parents | 6eeef7be58f3 |
children | d7b52c883ca4 |
files | mcabber/mcabber/settings.c |
diffstat | 1 files changed, 8 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabber/settings.c Sun May 19 09:45:53 2019 +0200 +++ b/mcabber/mcabber/settings.c Sun May 19 09:59:38 2019 +0200 @@ -655,39 +655,23 @@ /* otr settings */ -#ifdef HAVE_LIBOTR -static void remove_default_policies(char *k, char *policy, void *defaultp) -{ - if (*(enum otr_policy *)policy == *(enum otr_policy *)defaultp) { - g_hash_table_remove(otrpolicy, k); - } -} -#endif - void settings_otr_setpolicy(const char *bjid, guint value) { #ifdef HAVE_LIBOTR enum otr_policy *otrdata; - if (!bjid) { + if (!bjid) { // no jid -> default policy default_policy = value; - /* refresh hash */ - settings_foreach(SETTINGS_TYPE_OTR, &remove_default_policies, &value); - return; - } - - otrdata = g_hash_table_lookup(otrpolicy, bjid); + } else { //policy for some specific jid + otrdata = g_hash_table_lookup(otrpolicy, bjid); - if (value == default_policy) { if (otrdata) { - g_hash_table_remove(otrpolicy, bjid); + *otrdata = value; + } else { + otrdata = g_new(enum otr_policy, 1); + *otrdata = value; + g_hash_table_insert(otrpolicy, g_strdup(bjid), otrdata); } - } else if (otrdata) { - *otrdata = value; - } else { - otrdata = g_new(enum otr_policy, 1); - *otrdata = value; - g_hash_table_insert(otrpolicy, g_strdup(bjid), otrdata); } #endif }