diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command/cmd_funcs.c | 6 | ||||
-rw-r--r-- | src/event/client_events.c | 7 | ||||
-rw-r--r-- | src/event/server_events.c | 6 | ||||
-rw-r--r-- | src/log.c | 119 | ||||
-rw-r--r-- | src/omemo/omemo.c | 8 | ||||
-rw-r--r-- | src/ui/chatwin.c | 6 | ||||
-rw-r--r-- | src/xmpp/connection.c | 12 | ||||
-rw-r--r-- | src/xmpp/message.c | 8 | ||||
-rw-r--r-- | src/xmpp/muc.c | 6 | ||||
-rw-r--r-- | src/xmpp/roster.c | 8 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 1 |
11 files changed, 96 insertions, 91 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 27416108..83a050ed 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -3431,17 +3431,17 @@ cmd_caps(ProfWin *window, const char *const command, gchar **args) static void _send_software_version_iq_to_fulljid(char *request) { - Jid *myJid = jid_create(connection_get_fulljid()); + char *mybarejid = connection_get_barejid(); Jid *jid = jid_create(request); if (jid == NULL || jid->fulljid == NULL) { cons_show("You must provide a full jid to the /software command."); - } else if (g_strcmp0(jid->barejid, myJid->barejid) == 0) { + } else if (g_strcmp0(jid->barejid, mybarejid) == 0) { cons_show("Cannot request software version for yourself."); } else { iq_send_software_version(jid->fulljid); } - jid_destroy(myJid); + free(mybarejid); jid_destroy(jid); } diff --git a/src/event/client_events.c b/src/event/client_events.c index e57f3875..a7ee3028 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -84,10 +84,9 @@ cl_ev_connect_account(ProfAccount *account) void cl_ev_disconnect(void) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); - cons_show("%s logged out successfully.", jidp->barejid); - jid_destroy(jidp); + char *mybarejid = connection_get_barejid(); + cons_show("%s logged out successfully.", mybarejid); + free(mybarejid); ui_close_all_wins(); ev_disconnect_cleanup(); diff --git a/src/event/server_events.c b/src/event/server_events.c index ac93a951..542a974e 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -630,11 +630,11 @@ sv_ev_incoming_message(ProfMessage *message) char *looking_for_jid = message->from_jid->barejid; if (message->is_mam) { - Jid *my_jid = jid_create(connection_get_fulljid()); - if (g_strcmp0(my_jid->barejid, message->from_jid->barejid) == 0) { + char *mybarejid = connection_get_barejid(); + if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) { looking_for_jid = message->to_jid->barejid; } - jid_destroy(my_jid); + free(mybarejid); } chatwin = wins_get_chat(looking_for_jid); diff --git a/src/log.c b/src/log.c index 9e097698..3ca80750 100644 --- a/src/log.c +++ b/src/log.c @@ -290,10 +290,9 @@ void chat_log_msg_out(const char *const barejid, const char *const msg, const char *const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); - _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource); - jid_destroy(jidp); + char *mybarejid = connection_get_barejid(); + _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); + free(mybarejid); } } @@ -301,16 +300,15 @@ void chat_log_otr_msg_out(const char *const barejid, const char *const msg, const char *const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); if (strcmp(pref_otr_log, "on") == 0) { - _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource); + _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); } else if (strcmp(pref_otr_log, "redact") == 0) { - _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); + _chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); } prefs_free_string(pref_otr_log); - jid_destroy(jidp); + free(mybarejid); } } @@ -318,16 +316,15 @@ void chat_log_pgp_msg_out(const char *const barejid, const char *const msg, const char *const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG); if (strcmp(pref_pgp_log, "on") == 0) { - _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource); + _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); } else if (strcmp(pref_pgp_log, "redact") == 0) { - _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); + _chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); } prefs_free_string(pref_pgp_log); - jid_destroy(jidp); + free(mybarejid); } } @@ -335,16 +332,15 @@ void chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const char *const resource) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(pref_omemo_log, "on") == 0) { - _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource); + _chat_log_chat(mybarejid, barejid, msg, PROF_OUT_LOG, NULL, resource); } else if (strcmp(pref_omemo_log, "redact") == 0) { - _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); + _chat_log_chat(mybarejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource); } prefs_free_string(pref_omemo_log); - jid_destroy(jidp); + free(mybarejid); } } @@ -352,24 +348,23 @@ void chat_log_otr_msg_in(ProfMessage *message) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); if (message->enc == PROF_MSG_ENC_NONE || (strcmp(pref_otr_log, "on") == 0)) { if (message->type == PROF_MSG_TYPE_MUCPM) { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } else { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); } } else if (strcmp(pref_otr_log, "redact") == 0) { if (message->type == PROF_MSG_TYPE_MUCPM) { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } else { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); + _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); } } prefs_free_string(pref_otr_log); - jid_destroy(jidp); + free(mybarejid); } } @@ -377,24 +372,23 @@ void chat_log_pgp_msg_in(ProfMessage *message) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG); if (strcmp(pref_pgp_log, "on") == 0) { if (message->type == PROF_MSG_TYPE_MUCPM) { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } else { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); } } else if (strcmp(pref_pgp_log, "redact") == 0) { if (message->type == PROF_MSG_TYPE_MUCPM) { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } else { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); + _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, NULL); } } prefs_free_string(pref_pgp_log); - jid_destroy(jidp); + free(mybarejid); } } @@ -402,24 +396,23 @@ void chat_log_omemo_msg_in(ProfMessage *message) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(pref_omemo_log, "on") == 0) { if (message->type == PROF_MSG_TYPE_MUCPM) { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } else { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); } } else if (strcmp(pref_omemo_log, "redact") == 0) { if (message->type == PROF_MSG_TYPE_MUCPM) { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } else { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, "[redacted]", PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } } prefs_free_string(pref_omemo_log); - jid_destroy(jidp); + free(mybarejid); } } @@ -427,15 +420,15 @@ void chat_log_msg_in(ProfMessage *message) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); if (message->type == PROF_MSG_TYPE_MUCPM) { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, message->from_jid->resourcepart); } else { - _chat_log_chat(jidp->barejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); + _chat_log_chat(mybarejid, message->from_jid->barejid, message->plain, PROF_IN_LOG, message->timestamp, NULL); } - jid_destroy(jidp); + + free(mybarejid); } } @@ -524,11 +517,10 @@ void groupchat_log_msg_out(const gchar *const room, const gchar *const msg) { if (prefs_get_boolean(PREF_GRLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *mynick = muc_nick(room); - _groupchat_log_chat(jidp->barejid, room, mynick, msg); - jid_destroy(jidp); + _groupchat_log_chat(mybarejid, room, mynick, msg); + free(mybarejid); } } @@ -536,10 +528,9 @@ void groupchat_log_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) { if (prefs_get_boolean(PREF_GRLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); - _groupchat_log_chat(jidp->barejid, room, nick, msg); - jid_destroy(jidp); + char *mybarejid = connection_get_barejid(); + _groupchat_log_chat(mybarejid, room, nick, msg); + free(mybarejid); } } @@ -547,17 +538,18 @@ void groupchat_log_omemo_msg_out(const gchar *const room, const gchar *const msg) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); char *mynick = muc_nick(room); + if (strcmp(pref_omemo_log, "on") == 0) { - _groupchat_log_chat(jidp->barejid, room, mynick, msg); + _groupchat_log_chat(mybarejid, room, mynick, msg); } else if (strcmp(pref_omemo_log, "redact") == 0) { - _groupchat_log_chat(jidp->barejid, room, mynick, "[redacted]"); + _groupchat_log_chat(mybarejid, room, mynick, "[redacted]"); } + prefs_free_string(pref_omemo_log); - jid_destroy(jidp); + free(mybarejid); } } @@ -565,16 +557,17 @@ void groupchat_log_omemo_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) { if (prefs_get_boolean(PREF_CHLOG)) { - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + char *mybarejid = connection_get_barejid(); char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG); + if (strcmp(pref_omemo_log, "on") == 0) { - _groupchat_log_chat(jidp->barejid, room, nick, msg); + _groupchat_log_chat(mybarejid, room, nick, msg); } else if (strcmp(pref_omemo_log, "redact") == 0) { - _groupchat_log_chat(jidp->barejid, room, nick, "[redacted]"); + _groupchat_log_chat(mybarejid, room, nick, "[redacted]"); } + prefs_free_string(pref_omemo_log); - jid_destroy(jidp); + free(mybarejid); } } diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index b570b3e0..0718a287 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -373,16 +373,16 @@ omemo_publish_crypto_materials(void) return; } - Jid *jid = jid_create(connection_get_fulljid()); + char *barejid = connection_get_barejid(); /* Ensure we get our current device list, and it gets updated with our * device_id */ - g_hash_table_insert(omemo_ctx.device_list_handler, strdup(jid->barejid), _handle_own_device_list); - omemo_devicelist_request(jid->barejid); + g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_own_device_list); + omemo_devicelist_request(barejid); omemo_bundle_publish(true); - jid_destroy(jid); + free(barejid); } void diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 260b9f06..5c17b0d4 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -259,13 +259,13 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr int num = wins_get_num(window); char *display_name; - Jid *my_jid = jid_create(connection_get_fulljid()); - if (g_strcmp0(my_jid->barejid, message->from_jid->barejid) == 0) { + char *mybarejid = connection_get_barejid(); + if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) { display_name = strdup("me"); } else { display_name = roster_get_msg_display_name(message->from_jid->barejid, message->from_jid->resourcepart); } - jid_destroy(my_jid); + free(mybarejid); gboolean is_current = wins_is_current(window); gboolean notify = prefs_do_chat_notify(is_current); diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 013a09e1..18b177c6 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -411,6 +411,18 @@ connection_get_fulljid(void) } } +char* +connection_get_barejid(void) { + const char *jid = connection_get_fulljid(); + char *result; + + Jid *jidp = jid_create(jid); + result = strdup(jidp->barejid); + jid_destroy(jidp); + + return result; +} + void connection_features_received(const char *const jid) { diff --git a/src/xmpp/message.c b/src/xmpp/message.c index b8f4c367..c293a8f3 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -1075,9 +1075,9 @@ _handle_carbons(xmpp_stanza_t *const stanza) return TRUE; } - Jid *my_jid = jid_create(connection_get_fulljid()); + char *mybarejid = connection_get_barejid(); const char *const stanza_from = xmpp_stanza_get_from(stanza); - if (g_strcmp0(my_jid->barejid, stanza_from) != 0) { + if (g_strcmp0(mybarejid, stanza_from) != 0) { log_warning("Invalid carbon received, from: %s", stanza_from); return TRUE; } @@ -1143,7 +1143,7 @@ _handle_carbons(xmpp_stanza_t *const stanza) //TODO: now that profmessage has from_jid AND to_jid we should save both. and maybe also add is_carbon so we can decide later on. if (message->plain || message->encrypted || message->body) { // if we are the recipient, treat as standard incoming message - if (g_strcmp0(my_jid->barejid, jid_to->barejid) == 0) { + if (g_strcmp0(mybarejid, jid_to->barejid) == 0) { jid_destroy(jid_to); message->from_jid = jid_from; sv_ev_incoming_carbon(message); @@ -1158,7 +1158,7 @@ _handle_carbons(xmpp_stanza_t *const stanza) out: message_free(message); - jid_destroy(my_jid); + free(mybarejid); return TRUE; } diff --git a/src/xmpp/muc.c b/src/xmpp/muc.c index 172bdb80..85f90ae6 100644 --- a/src/xmpp/muc.c +++ b/src/xmpp/muc.c @@ -886,11 +886,11 @@ muc_members_add(const char *const room, const char *const jid) if (g_hash_table_insert(chat_room->members, strdup(jid), NULL)) { #ifdef HAVE_OMEMO if(chat_room->anonymity_type == MUC_ANONYMITY_TYPE_NONANONYMOUS ) { - Jid *our_jid = jid_create(connection_get_fulljid()); - if (strcmp(jid, our_jid->barejid) != 0) { + char *our_barejid = connection_get_barejid(); + if (strcmp(jid, our_barejid) != 0) { omemo_start_session(jid); } - jid_destroy(our_jid); + free(our_barejid); } #endif } diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index dd1b3747..64099335 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -211,14 +211,14 @@ roster_set_handler(xmpp_stanza_t *const stanza) } // if from attribute exists and it is not current users barejid, ignore push - Jid *my_jid = jid_create(connection_get_fulljid()); + char *mybarejid = connection_get_barejid(); const char *from = xmpp_stanza_get_from(stanza); - if (from && (strcmp(from, my_jid->barejid) != 0)) { + if (from && (strcmp(from, mybarejid) != 0)) { log_warning("Received alleged roster push from: %s", from); - jid_destroy(my_jid); + free(mybarejid); return; } - jid_destroy(my_jid); + free(mybarejid); const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID); gchar *barejid_lower = g_utf8_strdown(barejid, -1); diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 235df25d..5fd56733 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -175,6 +175,7 @@ jabber_conn_status_t connection_get_status(void); char *connection_get_presence_msg(void); void connection_set_presence_msg(const char *const message); const char* connection_get_fulljid(void); +char* connection_get_barejid(void); char* connection_create_uuid(void); void connection_free_uuid(char *uuid); #ifdef HAVE_LIBMESODE |