mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Fixed memleaks with otr policy and autoaway options
This commit is contained in:
parent
ad68bcfde2
commit
79ddf10484
@ -1413,10 +1413,13 @@ cmd_execute_default(const char * const inp)
|
||||
ui_current_print_line("You are not currently connected.");
|
||||
} else {
|
||||
#ifdef HAVE_LIBOTR
|
||||
if ((strcmp(otr_get_policy(recipient), "always") == 0) && !otr_is_secure(recipient)) {
|
||||
char *policy = otr_get_policy(recipient);
|
||||
if ((strcmp(policy, "always") == 0) && !otr_is_secure(recipient)) {
|
||||
cons_show_error("Failed to send message. Please check OTR policy");
|
||||
free(policy);
|
||||
return TRUE;
|
||||
}
|
||||
free(policy);
|
||||
if (otr_is_secure(recipient)) {
|
||||
char *encrypted = otr_encrypt_message(recipient, inp);
|
||||
if (encrypted != NULL) {
|
||||
|
@ -1033,6 +1033,7 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
message_send(msg, usr_jid);
|
||||
}
|
||||
ui_outgoing_msg("me", usr_jid, msg);
|
||||
free(policy);
|
||||
|
||||
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
|
@ -527,15 +527,15 @@ _otr_get_policy(const char * const recipient)
|
||||
// check contact specific setting
|
||||
if (g_list_find_custom(account->otr_manual, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
account_free(account);
|
||||
return "manual";
|
||||
return strdup("manual");
|
||||
}
|
||||
if (g_list_find_custom(account->otr_opportunistic, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
account_free(account);
|
||||
return "opportunistic";
|
||||
return strdup("opportunistic");
|
||||
}
|
||||
if (g_list_find_custom(account->otr_always, recipient, (GCompareFunc)g_strcmp0)) {
|
||||
account_free(account);
|
||||
return "always";
|
||||
return strdup("always");
|
||||
}
|
||||
|
||||
// check default account setting
|
||||
@ -551,7 +551,7 @@ _otr_get_policy(const char * const recipient)
|
||||
result = "always";
|
||||
}
|
||||
account_free(account);
|
||||
return result;
|
||||
return strdup(result);
|
||||
}
|
||||
account_free(account);
|
||||
|
||||
|
@ -219,6 +219,8 @@ _handle_idle_time()
|
||||
gint prefs_time = prefs_get_autoaway_time() * 60000;
|
||||
resource_presence_t current_presence = accounts_get_last_presence(jabber_get_account_name());
|
||||
unsigned long idle_ms = ui_get_idle_time();
|
||||
char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE);
|
||||
char *pref_autoaway_message = prefs_get_string(PREF_AUTOAWAY_MESSAGE);
|
||||
|
||||
if (!idle) {
|
||||
if ((current_presence == RESOURCE_ONLINE) || (current_presence == RESOURCE_CHAT)) {
|
||||
@ -226,13 +228,13 @@ _handle_idle_time()
|
||||
idle = TRUE;
|
||||
|
||||
// handle away mode
|
||||
if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "away") == 0) {
|
||||
presence_update(RESOURCE_AWAY, prefs_get_string(PREF_AUTOAWAY_MESSAGE), 0);
|
||||
if (strcmp(pref_autoaway_mode, "away") == 0) {
|
||||
presence_update(RESOURCE_AWAY, pref_autoaway_message, 0);
|
||||
ui_auto_away();
|
||||
|
||||
// handle idle mode
|
||||
} else if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "idle") == 0) {
|
||||
presence_update(RESOURCE_ONLINE, prefs_get_string(PREF_AUTOAWAY_MESSAGE), idle_ms / 1000);
|
||||
} else if (strcmp(pref_autoaway_mode, "idle") == 0) {
|
||||
presence_update(RESOURCE_ONLINE, pref_autoaway_message, idle_ms / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,16 +245,22 @@ _handle_idle_time()
|
||||
|
||||
// handle check
|
||||
if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) {
|
||||
if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "away") == 0) {
|
||||
if (strcmp(pref_autoaway_mode, "away") == 0) {
|
||||
presence_update(RESOURCE_ONLINE, NULL, 0);
|
||||
ui_end_auto_away();
|
||||
} else if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "idle") == 0) {
|
||||
} else if (strcmp(pref_autoaway_mode, "idle") == 0) {
|
||||
presence_update(RESOURCE_ONLINE, NULL, 0);
|
||||
ui_titlebar_presence(CONTACT_ONLINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pref_autoaway_mode != NULL) {
|
||||
free(pref_autoaway_mode);
|
||||
}
|
||||
if (pref_autoaway_message != NULL) {
|
||||
free(pref_autoaway_message);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -254,6 +254,7 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
|
||||
// internal OTR message
|
||||
if (newmessage == NULL) {
|
||||
free(policy);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -264,6 +265,7 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
cons_show("Attempting to start OTR session...");
|
||||
message_send(otr_query_message, from);
|
||||
}
|
||||
free(policy);
|
||||
|
||||
ui_incoming_msg(from, newmessage, NULL, priv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user