mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 17:06:21 +00:00
Added deallocation function for string prefs, added otr policy enum
This commit is contained in:
@@ -229,12 +229,12 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
gboolean was_decrypted = FALSE;
|
||||
char *newmessage;
|
||||
|
||||
char *policy = otr_get_policy(from);
|
||||
prof_otrpolicy_t policy = otr_get_policy(from);
|
||||
char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE);
|
||||
|
||||
if (!priv) {
|
||||
//check for OTR whitespace (opportunistic or always)
|
||||
if (strcmp(policy, "opportunistic") == 0 || strcmp(policy, "always") == 0) {
|
||||
if (policy == PROF_OTRPOLICY_OPPORTUNISTIC || policy == PROF_OTRPOLICY_ALWAYS) {
|
||||
if (whitespace_base) {
|
||||
if (strstr(message, OTRL_MESSAGE_TAG_V2) || strstr(message, OTRL_MESSAGE_TAG_V1)) {
|
||||
// Remove whitespace pattern for proper display in UI
|
||||
@@ -254,18 +254,16 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
|
||||
// internal OTR message
|
||||
if (newmessage == NULL) {
|
||||
free(policy);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
newmessage = message;
|
||||
}
|
||||
if (strcmp(policy, "always") == 0 && !was_decrypted && !whitespace_base) {
|
||||
if (policy == PROF_OTRPOLICY_ALWAYS && !was_decrypted && !whitespace_base) {
|
||||
char *otr_query_message = otr_start_query();
|
||||
cons_show("Attempting to start OTR session...");
|
||||
message_send(otr_query_message, from);
|
||||
}
|
||||
free(policy);
|
||||
|
||||
ui_incoming_msg(from, newmessage, NULL, priv);
|
||||
|
||||
@@ -274,11 +272,13 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
const char *jid = jabber_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
|
||||
if (!was_decrypted || (strcmp(prefs_get_string(PREF_OTR_LOG), "on") == 0)) {
|
||||
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||
if (!was_decrypted || (strcmp(pref_otr_log, "on") == 0)) {
|
||||
chat_log_chat(jidp->barejid, from_jid->barejid, newmessage, PROF_IN_LOG, NULL);
|
||||
} else if (strcmp(prefs_get_string(PREF_OTR_LOG), "redact") == 0) {
|
||||
} else if (strcmp(pref_otr_log, "redact") == 0) {
|
||||
chat_log_chat(jidp->barejid, from_jid->barejid, "[redacted]", PROF_IN_LOG, NULL);
|
||||
}
|
||||
prefs_free_string(pref_otr_log);
|
||||
|
||||
jid_destroy(jidp);
|
||||
jid_destroy(from_jid);
|
||||
@@ -394,6 +394,8 @@ handle_contact_offline(char *barejid, char *resource, char *status)
|
||||
}
|
||||
}
|
||||
}
|
||||
prefs_free_string(show_console);
|
||||
prefs_free_string(show_chat_win);
|
||||
jid_destroy(jid);
|
||||
}
|
||||
}
|
||||
@@ -433,6 +435,8 @@ handle_contact_online(char *barejid, Resource *resource,
|
||||
}
|
||||
}
|
||||
}
|
||||
prefs_free_string(show_console);
|
||||
prefs_free_string(show_chat_win);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,6 +497,7 @@ handle_room_member_presence(const char * const room,
|
||||
ui_room_member_presence(room, nick, show, status);
|
||||
ui_current_page_off();
|
||||
}
|
||||
prefs_free_string(muc_status_pref);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,6 +513,7 @@ handle_room_member_online(const char * const room, const char * const nick,
|
||||
ui_room_member_online(room, nick, show, status);
|
||||
ui_current_page_off();
|
||||
}
|
||||
prefs_free_string(muc_status_pref);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -521,6 +527,7 @@ handle_room_member_offline(const char * const room, const char * const nick,
|
||||
ui_room_member_offline(room, nick);
|
||||
ui_current_page_off();
|
||||
}
|
||||
prefs_free_string(muc_status_pref);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user