mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-26 22:36:21 +00:00
Added deallocation function for string prefs, added otr policy enum
This commit is contained in:
@@ -520,43 +520,56 @@ _otr_get_their_fingerprint(const char * const recipient)
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
static prof_otrpolicy_t
|
||||
_otr_get_policy(const char * const recipient)
|
||||
{
|
||||
ProfAccount *account = accounts_get_account(jabber_get_account_name());
|
||||
// check contact specific setting
|
||||
if (g_list_find_custom(account->otr_manual, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
account_free(account);
|
||||
return strdup("manual");
|
||||
return PROF_OTRPOLICY_MANUAL;
|
||||
}
|
||||
if (g_list_find_custom(account->otr_opportunistic, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
account_free(account);
|
||||
return strdup("opportunistic");
|
||||
return PROF_OTRPOLICY_OPPORTUNISTIC;
|
||||
}
|
||||
if (g_list_find_custom(account->otr_always, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
account_free(account);
|
||||
return strdup("always");
|
||||
return PROF_OTRPOLICY_ALWAYS;
|
||||
}
|
||||
|
||||
// check default account setting
|
||||
if (account->otr_policy != NULL) {
|
||||
char *result;
|
||||
prof_otrpolicy_t result;
|
||||
if (g_strcmp0(account->otr_policy, "manual") == 0) {
|
||||
result = "manual";
|
||||
result = PROF_OTRPOLICY_MANUAL;
|
||||
}
|
||||
if (g_strcmp0(account->otr_policy, "opportunistic") == 0) {
|
||||
result = "opportunistic";
|
||||
result = PROF_OTRPOLICY_OPPORTUNISTIC;
|
||||
}
|
||||
if (g_strcmp0(account->otr_policy, "always") == 0) {
|
||||
result = "always";
|
||||
result = PROF_OTRPOLICY_ALWAYS;
|
||||
}
|
||||
account_free(account);
|
||||
return strdup(result);
|
||||
return result;
|
||||
}
|
||||
account_free(account);
|
||||
|
||||
// check global setting
|
||||
return prefs_get_string(PREF_OTR_POLICY);
|
||||
char *pref_otr_policy = prefs_get_string(PREF_OTR_POLICY);
|
||||
|
||||
// pref defaults to manual
|
||||
prof_otrpolicy_t result = PROF_OTRPOLICY_MANUAL;
|
||||
|
||||
if (strcmp(pref_otr_policy, "opportunistic") == 0) {
|
||||
result = PROF_OTRPOLICY_OPPORTUNISTIC;
|
||||
} else if (strcmp(pref_otr_policy, "always") == 0) {
|
||||
result = PROF_OTRPOLICY_ALWAYS;
|
||||
}
|
||||
|
||||
prefs_free_string(pref_otr_policy);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
||||
@@ -28,6 +28,12 @@
|
||||
|
||||
#include "config/accounts.h"
|
||||
|
||||
typedef enum {
|
||||
PROF_OTRPOLICY_MANUAL,
|
||||
PROF_OTRPOLICY_OPPORTUNISTIC,
|
||||
PROF_OTRPOLICY_ALWAYS
|
||||
} prof_otrpolicy_t;
|
||||
|
||||
void otr_init_module(void);
|
||||
|
||||
OtrlUserState otr_userstate(void);
|
||||
@@ -63,6 +69,6 @@ char * (*otr_decrypt_message)(const char * const from, const char * const messag
|
||||
|
||||
void (*otr_free_message)(char *message);
|
||||
|
||||
char * (*otr_get_policy)(const char * const recipient);
|
||||
prof_otrpolicy_t (*otr_get_policy)(const char * const recipient);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -93,7 +93,7 @@ cb_otr_error_message_free(void *opdata, const char *err_msg)
|
||||
static void
|
||||
cb_timer_control(void *opdata, unsigned int interval)
|
||||
{
|
||||
current_interval = interval;
|
||||
current_interval = interval;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -139,7 +139,7 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
|
||||
ui_smp_answer_success(context->username);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case OTRL_SMPEVENT_FAILURE:
|
||||
if (context->smstate->received_question == 0) {
|
||||
if (nextMsg == OTRL_SMP_EXPECT3) {
|
||||
|
||||
Reference in New Issue
Block a user