mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Cleanup jid_destroy
to auto_jid
Remove unused variables Apply minor cleanups
This commit is contained in:
parent
8304ac86ff
commit
029f1caa52
@ -675,7 +675,7 @@ cmd_account_default(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
_account_set_jid(char* account_name, char* jid)
|
||||
{
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
if (jidp == NULL) {
|
||||
cons_show("Malformed jid: %s", jid);
|
||||
} else {
|
||||
@ -687,7 +687,6 @@ _account_set_jid(char* account_name, char* jid)
|
||||
}
|
||||
cons_show("");
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1259,7 +1258,7 @@ cmd_sub(ProfWin* window, const char* const command, gchar** args)
|
||||
jid = chatwin->barejid;
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
|
||||
if (strcmp(subcmd, "allow") == 0) {
|
||||
presence_subscription(jidp->barejid, PRESENCE_SUBSCRIBED);
|
||||
@ -1304,8 +1303,6 @@ cmd_sub(ProfWin* window, const char* const command, gchar** args)
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -2203,13 +2200,11 @@ cmd_msg(ProfWin* window, const char* const command, gchar** args)
|
||||
if (occupant) {
|
||||
// in case of non-anon muc send regular chatmessage
|
||||
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
|
||||
Jid* jidp = jid_create(occupant->jid);
|
||||
auto_jid Jid* jidp = jid_create(occupant->jid);
|
||||
|
||||
_cmd_msg_chatwin(jidp->barejid, msg);
|
||||
win_println(window, THEME_DEFAULT, "-", "Starting direct message with occupant \"%s\" from room \"%s\" as \"%s\".", usr, mucwin->roomjid, jidp->barejid);
|
||||
cons_show("Starting direct message with occupant \"%s\" from room \"%s\" as \"%s\".", usr, mucwin->roomjid, jidp->barejid);
|
||||
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
// otherwise send mucpm
|
||||
GString* full_jid = g_string_new(mucwin->roomjid);
|
||||
@ -3299,14 +3294,13 @@ cmd_status_get(ProfWin* window, const char* const command, gchar** args)
|
||||
} else {
|
||||
ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
|
||||
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||
Jid* jid = jid_create(privatewin->fulljid);
|
||||
auto_jid Jid* jid = jid_create(privatewin->fulljid);
|
||||
Occupant* occupant = muc_roster_item(jid->barejid, jid->resourcepart);
|
||||
if (occupant) {
|
||||
win_show_occupant(window, occupant);
|
||||
} else {
|
||||
win_println(window, THEME_DEFAULT, "-", "Error getting contact info.");
|
||||
}
|
||||
jid_destroy(jid);
|
||||
}
|
||||
break;
|
||||
case WIN_CONSOLE:
|
||||
@ -3389,14 +3383,13 @@ cmd_info(ProfWin* window, const char* const command, gchar** args)
|
||||
} else {
|
||||
ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
|
||||
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||
Jid* jid = jid_create(privatewin->fulljid);
|
||||
auto_jid Jid* jid = jid_create(privatewin->fulljid);
|
||||
Occupant* occupant = muc_roster_item(jid->barejid, jid->resourcepart);
|
||||
if (occupant) {
|
||||
win_show_occupant_info(window, jid->barejid, occupant);
|
||||
} else {
|
||||
win_println(window, THEME_DEFAULT, "-", "Error getting contact info.");
|
||||
}
|
||||
jid_destroy(jid);
|
||||
}
|
||||
break;
|
||||
case WIN_CONSOLE:
|
||||
@ -3431,9 +3424,8 @@ cmd_caps(ProfWin* window, const char* const command, gchar** args)
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
occupant = muc_roster_item(mucwin->roomjid, args[0]);
|
||||
if (occupant) {
|
||||
Jid* jidp = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]);
|
||||
cons_show_caps(jidp->fulljid, occupant->presence);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
cons_show("No such participant \"%s\" in room.", args[0]);
|
||||
}
|
||||
@ -3444,7 +3436,7 @@ cmd_caps(ProfWin* window, const char* const command, gchar** args)
|
||||
case WIN_CHAT:
|
||||
case WIN_CONSOLE:
|
||||
if (args[0]) {
|
||||
Jid* jid = jid_create(args[0]);
|
||||
auto_jid Jid* jid = jid_create(args[0]);
|
||||
|
||||
if (jid->fulljid == NULL) {
|
||||
cons_show("You must provide a full jid to the /caps command.");
|
||||
@ -3461,7 +3453,6 @@ cmd_caps(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
}
|
||||
}
|
||||
jid_destroy(jid);
|
||||
} else {
|
||||
cons_show("You must provide a jid to the /caps command.");
|
||||
}
|
||||
@ -3472,11 +3463,10 @@ cmd_caps(ProfWin* window, const char* const command, gchar** args)
|
||||
} else {
|
||||
ProfPrivateWin* privatewin = (ProfPrivateWin*)window;
|
||||
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||
Jid* jid = jid_create(privatewin->fulljid);
|
||||
auto_jid Jid* jid = jid_create(privatewin->fulljid);
|
||||
if (jid) {
|
||||
occupant = muc_roster_item(jid->barejid, jid->resourcepart);
|
||||
cons_show_caps(jid->resourcepart, occupant->presence);
|
||||
jid_destroy(jid);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3491,7 +3481,7 @@ static void
|
||||
_send_software_version_iq_to_fulljid(char* request)
|
||||
{
|
||||
auto_char char* mybarejid = connection_get_barejid();
|
||||
Jid* jid = jid_create(request);
|
||||
auto_jid Jid* jid = jid_create(request);
|
||||
|
||||
if (jid == NULL || jid->fulljid == NULL) {
|
||||
cons_show("You must provide a full jid to the /software command.");
|
||||
@ -3500,7 +3490,6 @@ _send_software_version_iq_to_fulljid(char* request)
|
||||
} else {
|
||||
iq_send_software_version(jid->fulljid);
|
||||
}
|
||||
jid_destroy(jid);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -3520,9 +3509,8 @@ cmd_software(ProfWin* window, const char* const command, gchar** args)
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
Occupant* occupant = muc_roster_item(mucwin->roomjid, args[0]);
|
||||
if (occupant) {
|
||||
Jid* jid = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]);
|
||||
auto_jid Jid* jid = jid_create_from_bare_and_resource(mucwin->roomjid, args[0]);
|
||||
iq_send_software_version(jid->fulljid);
|
||||
jid_destroy(jid);
|
||||
} else {
|
||||
cons_show("No such participant \"%s\" in room.", args[0]);
|
||||
}
|
||||
@ -3628,7 +3616,7 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Jid* room_arg = jid_create(args[0]);
|
||||
auto_jid Jid* room_arg = jid_create(args[0]);
|
||||
if (room_arg == NULL) {
|
||||
cons_show_error("Specified room has incorrect format.");
|
||||
cons_show("");
|
||||
@ -3663,7 +3651,6 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
||||
if (!parsed) {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
jid_destroy(room_arg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -3692,7 +3679,6 @@ cmd_join(ProfWin* window, const char* const command, gchar** args)
|
||||
ui_switch_to_room(room);
|
||||
}
|
||||
|
||||
jid_destroy(room_arg);
|
||||
account_free(account);
|
||||
|
||||
return TRUE;
|
||||
@ -4889,9 +4875,8 @@ cmd_disco(ProfWin* window, const char* const command, gchar** args)
|
||||
if (args[1]) {
|
||||
jid = g_string_append(jid, args[1]);
|
||||
} else {
|
||||
Jid* jidp = jid_create(connection_get_fulljid());
|
||||
auto_jid Jid* jidp = jid_create(connection_get_fulljid());
|
||||
jid = g_string_append(jid, jidp->domainpart);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "info") == 0) {
|
||||
@ -5089,13 +5074,12 @@ cmd_lastactivity(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
if ((g_strcmp0(args[0], "get") == 0)) {
|
||||
if (args[1] == NULL) {
|
||||
Jid* jidp = jid_create(connection_get_fulljid());
|
||||
auto_jid Jid* jidp = jid_create(connection_get_fulljid());
|
||||
GString* jid = g_string_new(jidp->domainpart);
|
||||
|
||||
iq_last_activity_request(jid->str);
|
||||
|
||||
g_string_free(jid, TRUE);
|
||||
jid_destroy(jidp);
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
@ -10057,10 +10041,9 @@ cmd_vcard_get(ProfWin* window, const char* const command, gchar** args)
|
||||
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
|
||||
// non-anon muc: get the user's jid and send vcard request to them
|
||||
Occupant* occupant = muc_roster_item(mucwin->roomjid, user);
|
||||
Jid* jid_occupant = jid_create(occupant->jid);
|
||||
auto_jid Jid* jid_occupant = jid_create(occupant->jid);
|
||||
|
||||
vcard_print(ctx, window, jid_occupant->barejid);
|
||||
jid_destroy(jid_occupant);
|
||||
} else {
|
||||
// anon muc: send the vcard request through the MUC's server
|
||||
GString* full_jid = g_string_new(mucwin->roomjid);
|
||||
@ -10126,10 +10109,9 @@ cmd_vcard_photo(ProfWin* window, const char* const command, gchar** args)
|
||||
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
|
||||
// non-anon muc: get the user's jid and send vcard request to them
|
||||
Occupant* occupant = muc_roster_item(mucwin->roomjid, user);
|
||||
Jid* jid_occupant = jid_create(occupant->jid);
|
||||
auto_jid Jid* jid_occupant = jid_create(occupant->jid);
|
||||
|
||||
jid = g_strdup(jid_occupant->barejid);
|
||||
jid_destroy(jid_occupant);
|
||||
} else {
|
||||
// anon muc: send the vcard request through the MUC's server
|
||||
jid = g_strdup_printf("%s/%s", mucwin->roomjid, user);
|
||||
|
@ -108,9 +108,8 @@ account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_password, gboo
|
||||
new_account->muc_service = muc_service;
|
||||
|
||||
if (muc_nick == NULL) {
|
||||
Jid* jidp = jid_create(new_account->jid);
|
||||
auto_jid Jid* jidp = jid_create(new_account->jid);
|
||||
new_account->muc_nick = strdup(jidp->domainpart);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
new_account->muc_nick = muc_nick;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
// set account name and resource
|
||||
const char* barejid = account_name;
|
||||
auto_gchar gchar* resource = jid_random_resource();
|
||||
Jid* jid = jid_create(account_name);
|
||||
auto_jid Jid* jid = jid_create(account_name);
|
||||
if (jid) {
|
||||
barejid = jid->barejid;
|
||||
if (jid->resourcepart) {
|
||||
@ -137,7 +137,6 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
}
|
||||
|
||||
if (g_key_file_has_group(accounts, account_name)) {
|
||||
jid_destroy(jid);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -157,7 +156,7 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
g_key_file_set_string(accounts, account_name, "auth.policy", auth_policy);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create(barejid);
|
||||
auto_jid Jid* jidp = jid_create(barejid);
|
||||
|
||||
if (jidp->localpart == NULL) {
|
||||
g_key_file_set_string(accounts, account_name, "muc.nick", jidp->domainpart);
|
||||
@ -165,8 +164,6 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
g_key_file_set_string(accounts, account_name, "muc.nick", jidp->localpart);
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
|
||||
g_key_file_set_string(accounts, account_name, "presence.last", "online");
|
||||
g_key_file_set_string(accounts, account_name, "presence.login", "online");
|
||||
g_key_file_set_integer(accounts, account_name, "priority.online", 0);
|
||||
@ -178,8 +175,6 @@ accounts_add(const char* account_name, const char* altdomain, const int port, co
|
||||
_save_accounts();
|
||||
autocomplete_add(all_ac, account_name);
|
||||
autocomplete_add(enabled_ac, account_name);
|
||||
|
||||
jid_destroy(jid);
|
||||
}
|
||||
|
||||
int
|
||||
@ -459,7 +454,7 @@ accounts_account_exists(const char* const account_name)
|
||||
void
|
||||
accounts_set_jid(const char* const account_name, const char* const value)
|
||||
{
|
||||
Jid* jid = jid_create(value);
|
||||
auto_jid Jid* jid = jid_create(value);
|
||||
if (jid) {
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "jid", jid->barejid);
|
||||
@ -475,8 +470,6 @@ accounts_set_jid(const char* const account_name, const char* const value)
|
||||
|
||||
_save_accounts();
|
||||
}
|
||||
|
||||
jid_destroy(jid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,11 +153,9 @@ log_database_add_incoming(ProfMessage* message)
|
||||
if (message->to_jid) {
|
||||
_add_to_db(message, NULL, message->from_jid, message->to_jid);
|
||||
} else {
|
||||
Jid* myjid = jid_create(connection_get_fulljid());
|
||||
auto_jid Jid* myjid = jid_create(connection_get_fulljid());
|
||||
|
||||
_add_to_db(message, NULL, message->from_jid, myjid);
|
||||
|
||||
jid_destroy(myjid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,11 +171,10 @@ _log_database_add_outgoing(char* type, const char* const id, const char* const b
|
||||
msg->timestamp = g_date_time_new_now_local(); // TODO: get from outside. best to have whole ProfMessage from outside
|
||||
msg->enc = enc;
|
||||
|
||||
Jid* myjid = jid_create(connection_get_fulljid());
|
||||
auto_jid Jid* myjid = jid_create(connection_get_fulljid());
|
||||
|
||||
_add_to_db(msg, type, myjid, msg->from_jid); // TODO: myjid now in profmessage
|
||||
|
||||
jid_destroy(myjid);
|
||||
message_free(msg);
|
||||
}
|
||||
|
||||
@ -206,7 +203,7 @@ log_database_get_limits_info(const gchar* const contact_barejid, gboolean is_las
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
gchar* query;
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* myjid = jid_create(jid);
|
||||
auto_jid Jid* myjid = jid_create(jid);
|
||||
if (!myjid)
|
||||
return NULL;
|
||||
|
||||
@ -221,8 +218,6 @@ log_database_get_limits_info(const gchar* const contact_barejid, gboolean is_las
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jid_destroy(myjid);
|
||||
|
||||
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
|
||||
if (rc != SQLITE_OK) {
|
||||
log_error("log_database_get_last_info(): unknown SQLite error");
|
||||
@ -252,7 +247,7 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s
|
||||
{
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* myjid = jid_create(jid);
|
||||
auto_jid Jid* myjid = jid_create(jid);
|
||||
if (!myjid)
|
||||
return NULL;
|
||||
|
||||
@ -270,8 +265,6 @@ log_database_get_previous_chat(const gchar* const contact_barejid, const char* s
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jid_destroy(myjid);
|
||||
|
||||
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
|
||||
if (rc != SQLITE_OK) {
|
||||
log_error("log_database_get_previous_chat(): unknown SQLite error");
|
||||
|
@ -395,10 +395,9 @@ sv_ev_room_message(ProfMessage* message)
|
||||
mucwin->last_msg_timestamp = g_date_time_new_now_local();
|
||||
|
||||
if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message->from_jid->resourcepart, message->plain, mention, triggers != NULL)) {
|
||||
Jid* jidp = jid_create(mucwin->roomjid);
|
||||
auto_jid Jid* jidp = jid_create(mucwin->roomjid);
|
||||
if (jidp) {
|
||||
notify_room_message(message->from_jid->resourcepart, jidp->localpart, num, message->plain);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -902,9 +901,8 @@ sv_ev_room_occupant_offline(const char* const room, const char* const nick,
|
||||
mucwin_occupant_offline(mucwin, nick);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create_from_bare_and_resource(room, nick);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(room, nick);
|
||||
ProfPrivateWin* privwin = wins_get_private(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
if (privwin != NULL) {
|
||||
privwin_occupant_offline(privwin);
|
||||
}
|
||||
@ -923,9 +921,8 @@ sv_ev_room_occupent_kicked(const char* const room, const char* const nick, const
|
||||
mucwin_occupant_kicked(mucwin, nick, actor, reason);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create_from_bare_and_resource(room, nick);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(room, nick);
|
||||
ProfPrivateWin* privwin = wins_get_private(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
if (privwin != NULL) {
|
||||
privwin_occupant_kicked(privwin, actor, reason);
|
||||
}
|
||||
@ -944,13 +941,11 @@ sv_ev_room_occupent_banned(const char* const room, const char* const nick, const
|
||||
mucwin_occupant_banned(mucwin, nick, actor, reason);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create_from_bare_and_resource(room, nick);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(room, nick);
|
||||
|
||||
muc_members_remove(room, jidp->fulljid);
|
||||
ProfPrivateWin* privwin = wins_get_private(jidp->fulljid);
|
||||
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (privwin != NULL) {
|
||||
privwin_occupant_banned(privwin, actor, reason);
|
||||
}
|
||||
@ -1003,11 +998,10 @@ sv_ev_muc_self_online(const char* const room, const char* const nick, gboolean c
|
||||
ui_room_join(room, TRUE);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create(room);
|
||||
auto_jid Jid* jidp = jid_create(room);
|
||||
if (jidp->domainpart) {
|
||||
muc_confserver_add(jidp->domainpart);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
|
||||
iq_room_info_request(room, FALSE);
|
||||
|
||||
@ -1122,9 +1116,8 @@ sv_ev_muc_occupant_online(const char* const room, const char* const nick, const
|
||||
}
|
||||
|
||||
if (mucwin) {
|
||||
Jid* jidp = jid_create_from_bare_and_resource(mucwin->roomjid, nick);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(mucwin->roomjid, nick);
|
||||
ProfPrivateWin* privwin = wins_get_private(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
if (privwin) {
|
||||
privwin_occupant_online(privwin);
|
||||
}
|
||||
@ -1230,7 +1223,7 @@ sv_ev_certfail(const char* const errormsg, const TLSCertificate* cert)
|
||||
void
|
||||
sv_ev_lastactivity_response(const char* const from, const int seconds, const char* const msg)
|
||||
{
|
||||
Jid* jidp = jid_create(from);
|
||||
auto_jid Jid* jidp = jid_create(from);
|
||||
|
||||
if (!jidp) {
|
||||
return;
|
||||
@ -1292,7 +1285,6 @@ sv_ev_lastactivity_response(const char* const from, const int seconds, const cha
|
||||
|
||||
g_date_time_unref(now);
|
||||
g_date_time_unref(active);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -447,9 +447,8 @@ omemo_start_muc_sessions(const char* const roomjid)
|
||||
GList* members = muc_members(roomjid);
|
||||
GList* iter;
|
||||
for (iter = members; iter != NULL; iter = iter->next) {
|
||||
Jid* jid = jid_create(iter->data);
|
||||
auto_jid Jid* jid = jid_create(iter->data);
|
||||
omemo_start_session(jid->barejid);
|
||||
jid_destroy(jid);
|
||||
}
|
||||
g_list_free(members);
|
||||
}
|
||||
@ -547,7 +546,7 @@ void
|
||||
omemo_set_device_list(const char* const from, GList* device_list)
|
||||
{
|
||||
log_debug("[OMEMO] Setting device list for %s", STR_MAYBE_NULL(from));
|
||||
Jid* jid;
|
||||
auto_jid Jid* jid;
|
||||
if (from) {
|
||||
jid = jid_create(from);
|
||||
} else {
|
||||
@ -595,7 +594,6 @@ omemo_set_device_list(const char* const from, GList* device_list)
|
||||
}
|
||||
}
|
||||
}
|
||||
jid_destroy(jid);
|
||||
}
|
||||
|
||||
GKeyFile*
|
||||
@ -754,7 +752,7 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
||||
{
|
||||
char* id = NULL;
|
||||
int res;
|
||||
Jid* jid = jid_create(connection_get_fulljid());
|
||||
auto_jid Jid* jid = jid_create(connection_get_fulljid());
|
||||
GList* keys = NULL;
|
||||
|
||||
unsigned char* key;
|
||||
@ -790,9 +788,8 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
||||
GList* members = muc_members(mucwin->roomjid);
|
||||
GList* iter;
|
||||
for (iter = members; iter != NULL; iter = iter->next) {
|
||||
Jid* jid = jid_create(iter->data);
|
||||
recipients = g_list_append(recipients, strdup(jid->barejid));
|
||||
jid_destroy(jid);
|
||||
auto_jid Jid* jidp = jid_create(iter->data);
|
||||
recipients = g_list_append(recipients, strdup(jidp->barejid));
|
||||
}
|
||||
g_list_free(members);
|
||||
} else {
|
||||
@ -932,7 +929,6 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
||||
}
|
||||
|
||||
out:
|
||||
jid_destroy(jid);
|
||||
g_list_free_full(keys, (GDestroyNotify)omemo_key_free);
|
||||
free(ciphertext);
|
||||
gcry_free(key);
|
||||
@ -949,11 +945,11 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
const unsigned char* const payload, size_t payload_len, gboolean muc, gboolean* trusted)
|
||||
{
|
||||
unsigned char* plaintext = NULL;
|
||||
Jid* sender = NULL;
|
||||
Jid* from = jid_create(from_jid);
|
||||
auto_jid Jid* sender = NULL;
|
||||
auto_jid Jid* from = jid_create(from_jid);
|
||||
if (!from) {
|
||||
log_error("[OMEMO][RECV] Invalid jid %s", from_jid);
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int res;
|
||||
@ -968,7 +964,7 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
|
||||
if (!key) {
|
||||
log_warning("[OMEMO][RECV] received a message with no corresponding key");
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (muc) {
|
||||
@ -984,7 +980,7 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
g_list_free(roster);
|
||||
if (!sender) {
|
||||
log_warning("[OMEMO][RECV] cannot find MUC message sender fulljid");
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
sender = jid_create(from->barejid);
|
||||
@ -1001,7 +997,7 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
res = session_cipher_create(&cipher, omemo_ctx.store, &address, omemo_ctx.signal);
|
||||
if (res != 0) {
|
||||
log_error("[OMEMO][RECV] cannot create session cipher");
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (key->prekey) {
|
||||
@ -1060,13 +1056,13 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
session_cipher_free(cipher);
|
||||
if (res != 0) {
|
||||
log_error("[OMEMO][RECV] cannot decrypt message key");
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (signal_buffer_len(plaintext_key) != AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH) {
|
||||
log_error("[OMEMO][RECV] invalid key length");
|
||||
signal_buffer_free(plaintext_key);
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t plaintext_len = payload_len;
|
||||
@ -1078,15 +1074,11 @@ omemo_on_message_recv(const char* const from_jid, uint32_t sid,
|
||||
if (res != 0) {
|
||||
log_error("[OMEMO][RECV] cannot decrypt message: %s", gcry_strerror(res));
|
||||
free(plaintext);
|
||||
plaintext = NULL;
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
plaintext[plaintext_len] = '\0';
|
||||
|
||||
out:
|
||||
jid_destroy(from);
|
||||
jid_destroy(sender);
|
||||
return (char*)plaintext;
|
||||
}
|
||||
|
||||
|
@ -660,7 +660,7 @@ plugins_on_room_history_message(const char* const barejid, const char* const nic
|
||||
char*
|
||||
plugins_pre_priv_message_display(const char* const fulljid, const char* message)
|
||||
{
|
||||
Jid* jidp = jid_create(fulljid);
|
||||
auto_jid Jid* jidp = jid_create(fulljid);
|
||||
char* new_message = NULL;
|
||||
char* curr_message = strdup(message);
|
||||
|
||||
@ -677,15 +677,13 @@ plugins_pre_priv_message_display(const char* const fulljid, const char* message)
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
g_list_free(values);
|
||||
|
||||
jid_destroy(jidp);
|
||||
return curr_message;
|
||||
}
|
||||
|
||||
void
|
||||
plugins_post_priv_message_display(const char* const fulljid, const char* message)
|
||||
{
|
||||
Jid* jidp = jid_create(fulljid);
|
||||
auto_jid Jid* jidp = jid_create(fulljid);
|
||||
|
||||
GList* values = g_hash_table_get_values(plugins);
|
||||
GList* curr = values;
|
||||
@ -695,14 +693,12 @@ plugins_post_priv_message_display(const char* const fulljid, const char* message
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
g_list_free(values);
|
||||
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
char*
|
||||
plugins_pre_priv_message_send(const char* const fulljid, const char* const message)
|
||||
{
|
||||
Jid* jidp = jid_create(fulljid);
|
||||
auto_jid Jid* jidp = jid_create(fulljid);
|
||||
char* new_message = NULL;
|
||||
char* curr_message = strdup(message);
|
||||
|
||||
@ -719,7 +715,6 @@ plugins_pre_priv_message_send(const char* const fulljid, const char* const messa
|
||||
} else {
|
||||
free(curr_message);
|
||||
g_list_free(values);
|
||||
jid_destroy(jidp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -728,14 +723,13 @@ plugins_pre_priv_message_send(const char* const fulljid, const char* const messa
|
||||
}
|
||||
g_list_free(values);
|
||||
|
||||
jid_destroy(jidp);
|
||||
return curr_message;
|
||||
}
|
||||
|
||||
void
|
||||
plugins_post_priv_message_send(const char* const fulljid, const char* const message)
|
||||
{
|
||||
Jid* jidp = jid_create(fulljid);
|
||||
auto_jid Jid* jidp = jid_create(fulljid);
|
||||
|
||||
GList* values = g_hash_table_get_values(plugins);
|
||||
GList* curr = values;
|
||||
@ -744,9 +738,8 @@ plugins_post_priv_message_send(const char* const fulljid, const char* const mess
|
||||
plugin->post_priv_message_send(plugin, jidp->barejid, jidp->resourcepart, message);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
g_list_free(values);
|
||||
|
||||
jid_destroy(jidp);
|
||||
g_list_free(values);
|
||||
}
|
||||
|
||||
char*
|
||||
|
@ -1141,9 +1141,8 @@ cons_show_account(ProfAccount* account)
|
||||
win_append(console, presence_colour, ", \"%s\"", resource->status);
|
||||
}
|
||||
win_appendln(console, THEME_DEFAULT, "");
|
||||
Jid* jidp = jid_create_from_bare_and_resource(account->jid, resource->name);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(account->jid, resource->name);
|
||||
EntityCapabilities* caps = caps_lookup(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (caps) {
|
||||
// show identity
|
||||
|
@ -1045,7 +1045,6 @@ ui_contact_offline(char* barejid, char* resource, char* status)
|
||||
{
|
||||
auto_gchar gchar* show_console = prefs_get_string(PREF_STATUSES_CONSOLE);
|
||||
auto_gchar gchar* show_chat_win = prefs_get_string(PREF_STATUSES_CHAT);
|
||||
Jid* jid = jid_create_from_bare_and_resource(barejid, resource);
|
||||
PContact contact = roster_get_contact(barejid);
|
||||
if (p_contact_subscription(contact)) {
|
||||
if (strcmp(p_contact_subscription(contact), "none") != 0) {
|
||||
@ -1080,8 +1079,6 @@ ui_contact_offline(char* barejid, char* resource, char* status)
|
||||
if (chatwin && chatwin->resource_override && (g_strcmp0(resource, chatwin->resource_override) == 0)) {
|
||||
FREE_SET_NULL(chatwin->resource_override);
|
||||
}
|
||||
|
||||
jid_destroy(jid);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1261,13 +1258,12 @@ void
|
||||
ui_show_software_version(const char* const jid, const char* const presence,
|
||||
const char* const name, const char* const version, const char* const os)
|
||||
{
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
ProfWin* window = NULL;
|
||||
ProfWin* chatwin = (ProfWin*)wins_get_chat(jidp->barejid);
|
||||
ProfWin* mucwin = (ProfWin*)wins_get_muc(jidp->barejid);
|
||||
ProfWin* privwin = (ProfWin*)wins_get_private(jidp->fulljid);
|
||||
ProfWin* console = wins_get_console();
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (chatwin) {
|
||||
if (wins_is_current(chatwin)) {
|
||||
|
@ -85,9 +85,8 @@ _occuptantswin_occupant(ProfLayoutSplit* layout, GList* item, gboolean showjid,
|
||||
gboolean wrap = prefs_get_boolean(PREF_OCCUPANTS_WRAP);
|
||||
|
||||
if (isoffline) {
|
||||
Jid* jid = jid_create(item->data);
|
||||
auto_jid Jid* jid = jid_create(item->data);
|
||||
g_string_append(msg, jid->barejid);
|
||||
jid_destroy(jid);
|
||||
} else {
|
||||
g_string_append(msg, occupant->nick);
|
||||
}
|
||||
@ -208,7 +207,7 @@ occupantswin_occupants(const char* const roomjid)
|
||||
g_string_free(role, TRUE);
|
||||
roster_curr = members;
|
||||
while (roster_curr) {
|
||||
Jid* jid = jid_create(roster_curr->data);
|
||||
auto_jid Jid* jid = jid_create(roster_curr->data);
|
||||
gboolean found = false;
|
||||
GList* iter = online_occupants;
|
||||
for (; iter != NULL; iter = iter->next) {
|
||||
@ -223,7 +222,6 @@ occupantswin_occupants(const char* const roomjid)
|
||||
offline_occupants = g_list_append(offline_occupants, jid->barejid);
|
||||
}
|
||||
|
||||
jid_destroy(jid);
|
||||
roster_curr = g_list_next(roster_curr);
|
||||
}
|
||||
g_list_free(members);
|
||||
|
@ -59,7 +59,7 @@ privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message)
|
||||
ProfWin* window = (ProfWin*)privatewin;
|
||||
int num = wins_get_num(window);
|
||||
|
||||
Jid* jidp = jid_create(privatewin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privatewin->fulljid);
|
||||
if (jidp == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -97,8 +97,6 @@ privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message)
|
||||
if (notify) {
|
||||
notify_message(jidp->resourcepart, num, message->plain);
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -133,9 +131,8 @@ privwin_occupant_offline(ProfPrivateWin* privwin)
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->occupant_offline = TRUE;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
win_println((ProfWin*)privwin, THEME_OFFLINE, "-", "<- %s has left the room.", jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -144,9 +141,8 @@ privwin_occupant_kicked(ProfPrivateWin* privwin, const char* const actor, const
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->occupant_offline = TRUE;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
GString* message = g_string_new(jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
g_string_append(message, " has been kicked from the room");
|
||||
if (actor) {
|
||||
g_string_append(message, " by ");
|
||||
@ -167,9 +163,8 @@ privwin_occupant_banned(ProfPrivateWin* privwin, const char* const actor, const
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->occupant_offline = TRUE;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
GString* message = g_string_new(jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
g_string_append(message, " has been banned from the room");
|
||||
if (actor) {
|
||||
g_string_append(message, " by ");
|
||||
@ -190,9 +185,8 @@ privwin_occupant_online(ProfPrivateWin* privwin)
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->occupant_offline = FALSE;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
win_println((ProfWin*)privwin, THEME_ONLINE, "-", "-- %s has joined the room.", jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -201,9 +195,8 @@ privwin_room_destroyed(ProfPrivateWin* privwin)
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->room_left = TRUE;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- %s has been destroyed.", jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -212,9 +205,8 @@ privwin_room_joined(ProfPrivateWin* privwin)
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->room_left = FALSE;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have joined %s.", jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -223,9 +215,8 @@ privwin_room_left(ProfPrivateWin* privwin)
|
||||
assert(privwin != NULL);
|
||||
|
||||
privwin->room_left = TRUE;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have left %s.", jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -235,9 +226,8 @@ privwin_room_kicked(ProfPrivateWin* privwin, const char* const actor, const char
|
||||
|
||||
privwin->room_left = TRUE;
|
||||
GString* message = g_string_new("Kicked from ");
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
g_string_append(message, jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
if (actor) {
|
||||
g_string_append(message, " by ");
|
||||
g_string_append(message, actor);
|
||||
@ -258,9 +248,8 @@ privwin_room_banned(ProfPrivateWin* privwin, const char* const actor, const char
|
||||
|
||||
privwin->room_left = TRUE;
|
||||
GString* message = g_string_new("Banned from ");
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
g_string_append(message, jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
if (actor) {
|
||||
g_string_append(message, " by ");
|
||||
g_string_append(message, actor);
|
||||
|
@ -113,11 +113,10 @@ rosterwin_roster(void)
|
||||
GList* curr = privchats;
|
||||
while (curr) {
|
||||
ProfPrivateWin* privwin = curr->data;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
if (!muc_active(jidp->barejid)) {
|
||||
orphaned_privchats = g_list_append(orphaned_privchats, privwin);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
@ -163,11 +162,10 @@ rosterwin_roster(void)
|
||||
GList* curr = privchats;
|
||||
while (curr) {
|
||||
ProfPrivateWin* privwin = curr->data;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
if (!muc_active(jidp->barejid)) {
|
||||
orphaned_privchats = g_list_append(orphaned_privchats, privwin);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
@ -677,13 +675,12 @@ _rosterwin_rooms_by_service(ProfLayoutSplit* layout)
|
||||
GList* services = NULL;
|
||||
while (curr) {
|
||||
char* roomjid = curr->data;
|
||||
Jid* jidp = jid_create(roomjid);
|
||||
auto_jid Jid* jidp = jid_create(roomjid);
|
||||
|
||||
if (!g_list_find_custom(services, jidp->domainpart, (GCompareFunc)g_strcmp0)) {
|
||||
services = g_list_insert_sorted(services, strdup(jidp->domainpart), (GCompareFunc)g_strcmp0);
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
@ -695,13 +692,12 @@ _rosterwin_rooms_by_service(ProfLayoutSplit* layout)
|
||||
curr = rooms;
|
||||
while (curr) {
|
||||
char* roomjid = curr->data;
|
||||
Jid* jidp = jid_create(roomjid);
|
||||
auto_jid Jid* jidp = jid_create(roomjid);
|
||||
|
||||
if (g_strcmp0(curr_service->data, jidp->domainpart) == 0) {
|
||||
filtered_rooms = g_list_append(filtered_rooms, strdup(jidp->barejid));
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
@ -754,9 +750,8 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin)
|
||||
|
||||
if (g_strcmp0(roombypref, "service") == 0) {
|
||||
if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
Jid* jidp = jid_create(mucwin->roomjid);
|
||||
auto_jid Jid* jidp = jid_create(mucwin->roomjid);
|
||||
g_string_append(msg, jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
}
|
||||
@ -770,15 +765,13 @@ _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin)
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
}
|
||||
} else {
|
||||
Jid* jidp = jid_create(mucwin->roomjid);
|
||||
auto_jid Jid* jidp = jid_create(mucwin->roomjid);
|
||||
|
||||
if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
g_string_append(msg, jidp->localpart);
|
||||
} else {
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -937,9 +930,8 @@ _rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats)
|
||||
g_string_append_printf(privmsg, " (%d)", privwin->unread);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(privwin->fulljid);
|
||||
Occupant* occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
|
||||
const char* presence = "offline";
|
||||
if (occupant) {
|
||||
|
@ -201,10 +201,9 @@ _create_tab(const int win, win_type_t wintype, char* identifier, gboolean highli
|
||||
if (pcontact_name) {
|
||||
tab->display_name = strdup(pcontact_name);
|
||||
} else {
|
||||
Jid* jidp = jid_create(tab->identifier);
|
||||
auto_jid Jid* jidp = jid_create(tab->identifier);
|
||||
if (jidp) {
|
||||
tab->display_name = jidp->localpart != NULL ? strdup(jidp->localpart) : strdup(jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
tab->display_name = strdup(tab->identifier);
|
||||
}
|
||||
@ -543,15 +542,13 @@ _status_bar_draw_maintext(int pos)
|
||||
return pos;
|
||||
}
|
||||
if (g_strcmp0(pref, "user") == 0) {
|
||||
Jid* jidp = jid_create(statusbar->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(statusbar->fulljid);
|
||||
mvwprintw(statusbar_win, 0, pos, "%s", jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
return pos;
|
||||
}
|
||||
if (g_strcmp0(pref, "barejid") == 0) {
|
||||
Jid* jidp = jid_create(statusbar->fulljid);
|
||||
auto_jid Jid* jidp = jid_create(statusbar->fulljid);
|
||||
mvwprintw(statusbar_win, 0, pos, "%s", jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
return pos;
|
||||
}
|
||||
|
||||
@ -655,9 +652,8 @@ _display_name(StatusBarTab* tab)
|
||||
} else if (tab->window_type == WIN_MUC) {
|
||||
auto_gchar gchar* pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
Jid* jidp = jid_create(tab->identifier);
|
||||
auto_jid Jid* jidp = jid_create(tab->identifier);
|
||||
char* room = strdup(jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
fullname = room;
|
||||
} else {
|
||||
fullname = strdup(tab->identifier);
|
||||
@ -667,9 +663,8 @@ _display_name(StatusBarTab* tab)
|
||||
GString* display_str = g_string_new("");
|
||||
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
Jid* jidp = jid_create(tab->identifier);
|
||||
auto_jid Jid* jidp = jid_create(tab->identifier);
|
||||
g_string_append(display_str, jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
g_string_append(display_str, tab->identifier);
|
||||
}
|
||||
@ -682,11 +677,10 @@ _display_name(StatusBarTab* tab)
|
||||
auto_gchar gchar* pref = prefs_get_string(PREF_STATUSBAR_ROOM);
|
||||
if (g_strcmp0("room", pref) == 0) {
|
||||
GString* display_str = g_string_new("");
|
||||
Jid* jidp = jid_create(tab->identifier);
|
||||
auto_jid Jid* jidp = jid_create(tab->identifier);
|
||||
g_string_append(display_str, jidp->localpart);
|
||||
g_string_append(display_str, "/");
|
||||
g_string_append(display_str, jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
char* result = strdup(display_str->str);
|
||||
g_string_free(display_str, TRUE);
|
||||
fullname = result;
|
||||
|
@ -976,9 +976,8 @@ win_show_occupant_info(ProfWin* window, const char* const room, Occupant* occupa
|
||||
win_println(window, THEME_DEFAULT, "!", " Affiliation: %s", occupant_affiliation);
|
||||
win_println(window, THEME_DEFAULT, "!", " Role: %s", occupant_role);
|
||||
|
||||
Jid* jidp = jid_create_from_bare_and_resource(room, occupant->nick);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(room, occupant->nick);
|
||||
EntityCapabilities* caps = caps_lookup(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (caps) {
|
||||
// show identity
|
||||
@ -1099,9 +1098,8 @@ win_show_info(ProfWin* window, PContact contact)
|
||||
}
|
||||
win_newline(window);
|
||||
|
||||
Jid* jidp = jid_create_from_bare_and_resource(barejid, resource->name);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(barejid, resource->name);
|
||||
EntityCapabilities* caps = caps_lookup(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (caps) {
|
||||
// show identity
|
||||
@ -1496,7 +1494,7 @@ win_print_history(ProfWin* window, const ProfMessage* const message)
|
||||
auto_gchar gchar* display_name;
|
||||
int flags = 0;
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
|
||||
if (g_strcmp0(jidp->barejid, message->from_jid->barejid) == 0) {
|
||||
display_name = strdup("me");
|
||||
@ -1505,8 +1503,6 @@ win_print_history(ProfWin* window, const ProfMessage* const message)
|
||||
flags = NO_ME;
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
|
||||
buffer_append(window->layout->buffer, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, NULL, message->plain, NULL, NULL);
|
||||
wins_add_urls_ac(window, message, FALSE);
|
||||
wins_add_quotes_ac(window, message->plain, FALSE);
|
||||
@ -1521,10 +1517,10 @@ win_print_old_history(ProfWin* window, const ProfMessage* const message)
|
||||
{
|
||||
g_date_time_ref(message->timestamp);
|
||||
|
||||
auto_gchar gchar* display_name;
|
||||
auto_char char* display_name;
|
||||
int flags = 0;
|
||||
const char* jid = connection_get_fulljid();
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
|
||||
if (g_strcmp0(jidp->barejid, message->from_jid->barejid) == 0) {
|
||||
display_name = strdup("me");
|
||||
@ -1533,8 +1529,6 @@ win_print_old_history(ProfWin* window, const ProfMessage* const message)
|
||||
flags = NO_ME;
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
|
||||
buffer_prepend(window->layout->buffer, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, NULL, message->plain, NULL, NULL);
|
||||
wins_add_urls_ac(window, message, TRUE);
|
||||
wins_add_quotes_ac(window, message->plain, TRUE);
|
||||
|
@ -276,13 +276,13 @@ wins_get_private_chats(const char* const roomjid)
|
||||
void
|
||||
wins_private_nick_change(const char* const roomjid, const char* const oldnick, const char* const newnick)
|
||||
{
|
||||
Jid* oldjid = jid_create_from_bare_and_resource(roomjid, oldnick);
|
||||
auto_jid Jid* oldjid = jid_create_from_bare_and_resource(roomjid, oldnick);
|
||||
|
||||
ProfPrivateWin* privwin = wins_get_private(oldjid->fulljid);
|
||||
if (privwin) {
|
||||
free(privwin->fulljid);
|
||||
|
||||
Jid* newjid = jid_create_from_bare_and_resource(roomjid, newnick);
|
||||
auto_jid Jid* newjid = jid_create_from_bare_and_resource(roomjid, newnick);
|
||||
privwin->fulljid = strdup(newjid->fulljid);
|
||||
win_println((ProfWin*)privwin, THEME_THEM, "!", "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart);
|
||||
|
||||
@ -290,11 +290,7 @@ wins_private_nick_change(const char* const roomjid, const char* const oldnick, c
|
||||
autocomplete_remove(wins_close_ac, oldjid->fulljid);
|
||||
autocomplete_add(wins_ac, newjid->fulljid);
|
||||
autocomplete_add(wins_close_ac, newjid->fulljid);
|
||||
|
||||
jid_destroy(newjid);
|
||||
}
|
||||
|
||||
jid_destroy(oldjid);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -93,11 +93,10 @@ bookmark_add(const char* jid, const char* nick, const char* password, const char
|
||||
{
|
||||
assert(jid != NULL);
|
||||
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
if (jidp->domainpart) {
|
||||
muc_confserver_add(jidp->domainpart);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (g_hash_table_contains(bookmarks, jid)) {
|
||||
return FALSE;
|
||||
@ -334,11 +333,10 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
sv_ev_bookmark_autojoin(bookmark);
|
||||
}
|
||||
|
||||
Jid* jidp = jid_create(barejid);
|
||||
auto_jid Jid* jidp = jid_create(barejid);
|
||||
if (jidp->domainpart) {
|
||||
muc_confserver_add(jidp->domainpart);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
@ -387,11 +385,10 @@ _send_bookmarks(void)
|
||||
xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, bookmark->name);
|
||||
} else {
|
||||
// use localpart of JID by if no name is specified
|
||||
Jid* jidp = jid_create(bookmark->barejid);
|
||||
auto_jid Jid* jidp = jid_create(bookmark->barejid);
|
||||
if (jidp->localpart) {
|
||||
xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, jidp->localpart);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
if (bookmark->autojoin) {
|
||||
|
@ -110,9 +110,8 @@ chat_session_get_jid(const char* const barejid)
|
||||
ChatSession* session = chat_session_get(barejid);
|
||||
char* jid = NULL;
|
||||
if (session) {
|
||||
Jid* jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
|
||||
jid = strdup(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
jid = strdup(barejid);
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ connection_shutdown(void)
|
||||
static gboolean
|
||||
_conn_apply_settings(const char* const jid, const char* const passwd, const char* const tls_policy, const char* const auth_policy)
|
||||
{
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
if (jidp == NULL) {
|
||||
log_error("Malformed JID not able to connect: %s", jid);
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
@ -189,7 +189,6 @@ _conn_apply_settings(const char* const jid, const char* const passwd, const char
|
||||
}
|
||||
|
||||
_compute_identifier(jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
|
||||
xmpp_ctx_set_verbosity(conn.xmpp_ctx, 0);
|
||||
xmpp_conn_set_jid(conn.xmpp_conn, jid);
|
||||
|
@ -1080,11 +1080,10 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||
auto_gchar gchar* item_jid_lower = NULL;
|
||||
if (item_jid) {
|
||||
Jid* jidp = jid_create(item_jid);
|
||||
auto_jid Jid* jidp = jid_create(item_jid);
|
||||
if (jidp && jidp->localpart) {
|
||||
item_jid_lower = g_utf8_strdown(jidp->localpart, -1);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
|
||||
auto_gchar gchar* item_name_lower = NULL;
|
||||
@ -1505,7 +1504,7 @@ _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
|
||||
xmpp_ctx_t* ctx = connection_get_ctx();
|
||||
|
||||
Jid* jidp = jid_create((char*)userdata);
|
||||
auto_jid Jid* jidp = jid_create((char*)userdata);
|
||||
|
||||
const char* presence = NULL;
|
||||
|
||||
@ -1543,8 +1542,6 @@ _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
ui_show_software_version(jidp->barejid, "online", name_str, version_str, os_str);
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (name_str)
|
||||
xmpp_free(ctx, name_str);
|
||||
if (version_str)
|
||||
|
@ -495,11 +495,10 @@ muc_roster_add(const char* const room, const char* const nick, const char* const
|
||||
g_hash_table_replace(chat_room->roster, strdup(nick), occupant);
|
||||
|
||||
if (jid) {
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
if (jidp->barejid) {
|
||||
autocomplete_add(chat_room->jid_ac, jidp->barejid);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -771,13 +770,12 @@ muc_jid_autocomplete_add_all(const char* const room, GSList* jids)
|
||||
GSList* curr_jid = jids;
|
||||
while (curr_jid) {
|
||||
const char* jid = curr_jid->data;
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
if (jidp) {
|
||||
if (jidp->barejid) {
|
||||
autocomplete_add(chat_room->jid_ac, jidp->barejid);
|
||||
}
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
curr_jid = g_slist_next(curr_jid);
|
||||
}
|
||||
}
|
||||
|
@ -389,21 +389,21 @@ omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted)
|
||||
size_t iv_len;
|
||||
iv_raw = g_base64_decode(iv_text, &iv_len);
|
||||
if (!iv_raw) {
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xmpp_stanza_t* payload = xmpp_stanza_get_child_by_name(encrypted, "payload");
|
||||
if (!payload) {
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
payload_text = xmpp_stanza_get_text(payload);
|
||||
if (!payload_text) {
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
size_t payload_len;
|
||||
payload_raw = g_base64_decode(payload_text, &payload_len);
|
||||
if (!payload_raw) {
|
||||
goto out;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xmpp_stanza_t* key_stanza;
|
||||
@ -415,27 +415,26 @@ omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted)
|
||||
omemo_key_t* key = malloc(sizeof(omemo_key_t));
|
||||
char* key_text = xmpp_stanza_get_text(key_stanza);
|
||||
if (!key_text) {
|
||||
goto skip;
|
||||
free(key);
|
||||
continue;
|
||||
}
|
||||
|
||||
const char* rid_text = xmpp_stanza_get_attribute(key_stanza, "rid");
|
||||
key->device_id = strtoul(rid_text, NULL, 10);
|
||||
if (!key->device_id) {
|
||||
goto skip;
|
||||
free(key);
|
||||
continue;
|
||||
}
|
||||
|
||||
key->data = g_base64_decode(key_text, &key->length);
|
||||
free(key_text);
|
||||
if (!key->data) {
|
||||
goto skip;
|
||||
free(key);
|
||||
continue;
|
||||
}
|
||||
key->prekey = g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "true") == 0
|
||||
|| g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "1") == 0;
|
||||
keys = g_list_append(keys, key);
|
||||
continue;
|
||||
|
||||
skip:
|
||||
free(key);
|
||||
}
|
||||
|
||||
const char* from = xmpp_stanza_get_from(stanza);
|
||||
@ -444,7 +443,6 @@ skip:
|
||||
keys, payload_raw, payload_len,
|
||||
g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0, trusted);
|
||||
|
||||
out:
|
||||
if (keys) {
|
||||
g_list_free_full(keys, (GDestroyNotify)omemo_key_free);
|
||||
}
|
||||
@ -610,8 +608,8 @@ _omemo_devicelist_configure_submit(xmpp_stanza_t* const stanza, void* const user
|
||||
form_set_value(form, "pubsub#access_model", "open");
|
||||
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
Jid* jid = jid_create(connection_get_fulljid());
|
||||
char* id = connection_create_stanza_id();
|
||||
auto_jid Jid* jid = jid_create(connection_get_fulljid());
|
||||
auto_char char* id = connection_create_stanza_id();
|
||||
xmpp_stanza_t* iq = stanza_create_pubsub_configure_submit(ctx, id, jid->barejid, STANZA_NS_OMEMO_DEVICELIST, form);
|
||||
|
||||
iq_id_handler_add(id, _omemo_devicelist_configure_result, NULL, NULL);
|
||||
@ -619,8 +617,6 @@ _omemo_devicelist_configure_submit(xmpp_stanza_t* const stanza, void* const user
|
||||
iq_send_stanza(iq);
|
||||
|
||||
xmpp_stanza_release(iq);
|
||||
free(id);
|
||||
jid_destroy(jid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -664,8 +660,8 @@ _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
|
||||
log_debug("[OMEMO] cannot publish bundle with open access model, trying to configure node");
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
Jid* jid = jid_create(connection_get_fulljid());
|
||||
char* id = connection_create_stanza_id();
|
||||
auto_jid Jid* jid = jid_create(connection_get_fulljid());
|
||||
auto_char char* id = connection_create_stanza_id();
|
||||
auto_gchar gchar* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
|
||||
log_debug("[OMEMO] node: %s", node);
|
||||
|
||||
@ -676,8 +672,6 @@ _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
iq_send_stanza(iq);
|
||||
|
||||
xmpp_stanza_release(iq);
|
||||
free(id);
|
||||
jid_destroy(jid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -706,8 +700,8 @@ _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdat
|
||||
form_set_value(form, "pubsub#access_model", "open");
|
||||
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
Jid* jid = jid_create(connection_get_fulljid());
|
||||
char* id = connection_create_stanza_id();
|
||||
auto_jid Jid* jid = jid_create(connection_get_fulljid());
|
||||
auto_char char* id = connection_create_stanza_id();
|
||||
auto_gchar gchar* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
|
||||
xmpp_stanza_t* iq = stanza_create_pubsub_configure_submit(ctx, id, jid->barejid, node, form);
|
||||
|
||||
@ -716,8 +710,6 @@ _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdat
|
||||
iq_send_stanza(iq);
|
||||
|
||||
xmpp_stanza_release(iq);
|
||||
free(id);
|
||||
jid_destroy(jid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ presence_subscription(const char* const jid, const jabber_subscr_t action)
|
||||
{
|
||||
assert(jid != NULL);
|
||||
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
autocomplete_remove(sub_requests_ac, jidp->barejid);
|
||||
|
||||
const char* type = NULL;
|
||||
@ -129,7 +129,6 @@ presence_subscription(const char* const jid, const jabber_subscr_t action)
|
||||
|
||||
xmpp_stanza_set_type(presence, type);
|
||||
xmpp_stanza_set_to(presence, jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
|
||||
_send_presence_stanza(presence);
|
||||
|
||||
@ -278,7 +277,7 @@ _send_room_presence(xmpp_stanza_t* presence)
|
||||
void
|
||||
presence_join_room(const char* const room, const char* const nick, const char* const passwd)
|
||||
{
|
||||
Jid* jid = jid_create_from_bare_and_resource(room, nick);
|
||||
auto_jid Jid* jid = jid_create_from_bare_and_resource(room, nick);
|
||||
log_debug("Sending room join presence to: %s", jid->fulljid);
|
||||
|
||||
resource_presence_t presence_type = accounts_get_last_presence(session_get_account_name());
|
||||
@ -296,7 +295,6 @@ presence_join_room(const char* const room, const char* const nick, const char* c
|
||||
_send_presence_stanza(presence);
|
||||
|
||||
xmpp_stanza_release(presence);
|
||||
jid_destroy(jid);
|
||||
}
|
||||
|
||||
void
|
||||
@ -415,13 +413,12 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
|
||||
error_cond = "unknown";
|
||||
}
|
||||
|
||||
Jid* fulljid = jid_create(from);
|
||||
auto_jid Jid* fulljid = jid_create(from);
|
||||
log_info("Error joining room: %s, reason: %s", fulljid->barejid, error_cond);
|
||||
if (muc_active(fulljid->barejid)) {
|
||||
muc_leave(fulljid->barejid);
|
||||
}
|
||||
cons_show_error("Error joining room %s, reason: %s", fulljid->barejid, error_cond);
|
||||
jid_destroy(fulljid);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -472,11 +469,9 @@ _unsubscribed_handler(xmpp_stanza_t* const stanza)
|
||||
}
|
||||
log_debug("Unsubscribed presence handler fired for %s", from);
|
||||
|
||||
Jid* from_jid = jid_create(from);
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
sv_ev_subscription(from_jid->barejid, PRESENCE_UNSUBSCRIBED);
|
||||
autocomplete_remove(sub_requests_ac, from_jid->barejid);
|
||||
|
||||
jid_destroy(from_jid);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -489,11 +484,9 @@ _subscribed_handler(xmpp_stanza_t* const stanza)
|
||||
}
|
||||
log_debug("Subscribed presence handler fired for %s", from);
|
||||
|
||||
Jid* from_jid = jid_create(from);
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
sv_ev_subscription(from_jid->barejid, PRESENCE_SUBSCRIBED);
|
||||
autocomplete_remove(sub_requests_ac, from_jid->barejid);
|
||||
|
||||
jid_destroy(from_jid);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -505,15 +498,13 @@ _subscribe_handler(xmpp_stanza_t* const stanza)
|
||||
}
|
||||
log_debug("Subscribe presence handler fired for %s", from);
|
||||
|
||||
Jid* from_jid = jid_create(from);
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
if (from_jid == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
sv_ev_subscription(from_jid->barejid, PRESENCE_SUBSCRIBE);
|
||||
autocomplete_add(sub_requests_ac, from_jid->barejid);
|
||||
|
||||
jid_destroy(from_jid);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -529,11 +520,9 @@ _unavailable_handler(xmpp_stanza_t* const stanza)
|
||||
}
|
||||
log_debug("Unavailable presence handler fired for %s", from);
|
||||
|
||||
Jid* my_jid = jid_create(jid);
|
||||
Jid* from_jid = jid_create(from);
|
||||
auto_jid Jid* my_jid = jid_create(jid);
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
if (my_jid == NULL || from_jid == NULL) {
|
||||
jid_destroy(my_jid);
|
||||
jid_destroy(from_jid);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -551,9 +540,6 @@ _unavailable_handler(xmpp_stanza_t* const stanza)
|
||||
connection_remove_available_resource(from_jid->resourcepart);
|
||||
}
|
||||
}
|
||||
|
||||
jid_destroy(my_jid);
|
||||
jid_destroy(from_jid);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -634,7 +620,7 @@ _available_handler(xmpp_stanza_t* const stanza)
|
||||
|
||||
xmpp_conn_t* conn = connection_get_conn();
|
||||
const char* my_jid_str = xmpp_conn_get_jid(conn);
|
||||
Jid* my_jid = jid_create(my_jid_str);
|
||||
auto_jid Jid* my_jid = jid_create(my_jid_str);
|
||||
|
||||
XMPPCaps* caps = stanza_parse_caps(stanza);
|
||||
if ((g_strcmp0(my_jid->fulljid, xmpp_presence->jid->fulljid) != 0) && caps) {
|
||||
@ -721,7 +707,6 @@ _available_handler(xmpp_stanza_t* const stanza)
|
||||
xmpp_free(ctx, pgpsig);
|
||||
}
|
||||
|
||||
jid_destroy(my_jid);
|
||||
stanza_free_presence(xmpp_presence);
|
||||
}
|
||||
|
||||
@ -752,7 +737,7 @@ static void
|
||||
_muc_user_self_handler(xmpp_stanza_t* stanza)
|
||||
{
|
||||
const char* from = xmpp_stanza_get_from(stanza);
|
||||
Jid* from_jid = jid_create(from);
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
|
||||
log_debug("Room self presence received from %s", from_jid->fulljid);
|
||||
|
||||
@ -823,8 +808,6 @@ _muc_user_self_handler(xmpp_stanza_t* stanza)
|
||||
}
|
||||
sv_ev_muc_self_online(room, nick, config_required, role, affiliation, actor, reason, jid, show_str, status_str);
|
||||
}
|
||||
|
||||
jid_destroy(from_jid);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -921,13 +904,11 @@ _muc_user_handler(xmpp_stanza_t* const stanza)
|
||||
return;
|
||||
}
|
||||
|
||||
Jid* from_jid = jid_create(from);
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
if (from_jid == NULL || from_jid->resourcepart == NULL) {
|
||||
log_warning("MUC User stanza received with invalid from attribute: %s", from);
|
||||
jid_destroy(from_jid);
|
||||
return;
|
||||
}
|
||||
jid_destroy(from_jid);
|
||||
|
||||
if (stanza_is_muc_self_presence(stanza, connection_get_fulljid())) {
|
||||
_muc_user_self_handler(stanza);
|
||||
|
@ -151,9 +151,8 @@ roster_update_presence(const char* const barejid, Resource* resource, GDateTime*
|
||||
p_contact_set_last_activity(contact, last_activity);
|
||||
}
|
||||
p_contact_set_presence(contact, resource);
|
||||
Jid* jid = jid_create_from_bare_and_resource(barejid, resource->name);
|
||||
auto_jid Jid* jid = jid_create_from_bare_and_resource(barejid, resource->name);
|
||||
autocomplete_add(roster->fulljid_ac, jid->fulljid);
|
||||
jid_destroy(jid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -237,9 +236,8 @@ roster_contact_offline(const char* const barejid, const char* const resource, co
|
||||
} else {
|
||||
gboolean result = p_contact_remove_resource(contact, resource);
|
||||
if (result == TRUE) {
|
||||
Jid* jid = jid_create_from_bare_and_resource(barejid, resource);
|
||||
auto_jid Jid* jid = jid_create_from_bare_and_resource(barejid, resource);
|
||||
autocomplete_remove(roster->fulljid_ac, jid->fulljid);
|
||||
jid_destroy(jid);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -123,9 +123,8 @@ session_connect_with_account(const ProfAccount* const account)
|
||||
|
||||
auto_char char* jid = NULL;
|
||||
if (account->resource) {
|
||||
Jid* jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
|
||||
auto_jid Jid* jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
|
||||
jid = strdup(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
jid = strdup(account->jid);
|
||||
}
|
||||
@ -175,16 +174,15 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
|
||||
}
|
||||
|
||||
// use 'profanity' when no resourcepart in provided jid
|
||||
Jid* jidp = jid_create(jid);
|
||||
auto_jid Jid* jidp = jid_create(jid);
|
||||
if (jidp->resourcepart == NULL) {
|
||||
jid_destroy(jidp);
|
||||
auto_gchar gchar* resource = jid_random_resource();
|
||||
jid_destroy(jidp);
|
||||
jidp = jid_create_from_bare_and_resource(jid, resource);
|
||||
saved_details.jid = strdup(jidp->fulljid);
|
||||
} else {
|
||||
saved_details.jid = strdup(jid);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
|
||||
// connect with fulljid
|
||||
log_info("Connecting without account, JID: %s", saved_details.jid);
|
||||
|
@ -1395,11 +1395,10 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
|
||||
// check if 'from' attribute identifies this user
|
||||
const char* from = xmpp_stanza_get_from(stanza);
|
||||
if (from) {
|
||||
Jid* from_jid = jid_create(from);
|
||||
auto_jid Jid* from_jid = jid_create(from);
|
||||
if (muc_active(from_jid->barejid)) {
|
||||
char* nick = muc_nick(from_jid->barejid);
|
||||
if (g_strcmp0(from_jid->resourcepart, nick) == 0) {
|
||||
jid_destroy(from_jid);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -1411,13 +1410,10 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
|
||||
char* nick = muc_nick(from_jid->barejid);
|
||||
char* old_nick = muc_old_nick(from_jid->barejid, new_nick);
|
||||
if (g_strcmp0(old_nick, nick) == 0) {
|
||||
jid_destroy(from_jid);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jid_destroy(from_jid);
|
||||
}
|
||||
|
||||
// self presence not found
|
||||
|
Loading…
Reference in New Issue
Block a user