1
0
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Removed _get_caps_key function

This commit is contained in:
James Booth 2014-09-21 00:22:03 +01:00
parent ae08e820d9
commit 06856ecea1
4 changed files with 12 additions and 71 deletions

View File

@ -59,8 +59,7 @@ void muc_complete_room_nick_change(const char * const room,
char * muc_get_old_nick(const char * const room, const char * const new_nick);
gboolean muc_add_to_roster(const char * const room, const char * const nick,
const char * const show, const char * const status,
const char * const caps_str);
const char * const show, const char * const status);
void muc_remove_from_roster(const char * const room, const char * const nick);
GList * muc_get_roster(const char * const room);
Autocomplete muc_get_roster_ac(const char * const room);

View File

@ -518,9 +518,9 @@ handle_room_roster_complete(const char * const room)
void
handle_room_member_presence(const char * const room,
const char * const nick, const char * const show,
const char * const status, const char * const caps_str)
const char * const status)
{
gboolean updated = muc_add_to_roster(room, nick, show, status, caps_str);
gboolean updated = muc_add_to_roster(room, nick, show, status);
if (updated) {
char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
@ -533,10 +533,9 @@ handle_room_member_presence(const char * const room,
void
handle_room_member_online(const char * const room, const char * const nick,
const char * const show, const char * const status,
const char * const caps_str)
const char * const show, const char * const status)
{
muc_add_to_roster(room, nick, show, status, caps_str);
muc_add_to_roster(room, nick, show, status);
char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
if (g_strcmp0(muc_status_pref, "none") != 0) {

View File

@ -74,10 +74,9 @@ void handle_room_destroy(const char * const room);
void handle_room_roster_complete(const char * const room);
void handle_room_member_presence(const char * const room,
const char * const nick, const char * const show,
const char * const status, const char * const caps_str);
const char * const status);
void handle_room_member_online(const char * const room, const char * const nick,
const char * const show, const char * const status,
const char * const caps_str);
const char * const show, const char * const status);
void handle_room_member_offline(const char * const room, const char * const nick,
const char * const show, const char * const status);
void handle_room_member_nick_change(const char * const room,

View File

@ -70,9 +70,8 @@ static int _muc_user_handler(xmpp_conn_t * const conn,
static int _presence_error_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata);
static char* _get_caps_key(xmpp_stanza_t * const stanza);
static void _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence);
void _send_caps_request(char *node, char *caps_key, char *id, char *from);
static void _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence);
void
presence_sub_requests_init(void)
@ -667,55 +666,6 @@ _send_caps_request(char *node, char *caps_key, char *id, char *from)
log_debug("No node string, not sending discovery IQ.");
}
}
static char *
_get_caps_key(xmpp_stanza_t * const stanza)
{
char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
char *hash_type = stanza_caps_get_hash(stanza);
char *node = stanza_get_caps_str(stanza);
char *caps_key = NULL;
char *id = NULL;
if (node == NULL) {
return NULL;
}
// xep-0115
if ((hash_type != NULL) && (strcmp(hash_type, "sha-1") == 0)) {
log_debug("Hash type %s supported.", hash_type);
caps_key = strdup(node);
id = create_unique_id("caps");
_send_caps_request(node, caps_key, id, from);
free(id);
// unsupported hash or legacy capabilities
} else {
if (hash_type != NULL) {
log_debug("Hash type %s unsupported.", hash_type);
} else {
log_debug("No hash type, using legacy capabilities.");
}
guint from_hash = g_str_hash(from);
char from_hash_str[9];
g_snprintf(from_hash_str, sizeof(from_hash_str), "%08x", from_hash);
caps_key = strdup(from_hash_str);
GString *id_str = g_string_new("capsreq_");
g_string_append(id_str, from_hash_str);
id = id_str->str;
_send_caps_request(node, caps_key, id, from);
g_string_free(id_str, TRUE);
}
g_free(node);
return caps_key;
}
static int
_muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
void * const userdata)
@ -768,11 +718,6 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
char *status_str;
char *caps_key = NULL;
if (stanza_contains_caps(stanza)) {
caps_key = _get_caps_key(stanza);
}
log_debug("Room presence received from %s", from_jid->fulljid);
status_str = stanza_get_status(stanza, NULL);
@ -792,19 +737,19 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
} else {
char *show_str = stanza_get_show(stanza, "online");
if (!muc_get_roster_received(from_room)) {
muc_add_to_roster(from_room, from_nick, show_str, status_str, caps_key);
muc_add_to_roster(from_room, from_nick, show_str, status_str);
} else {
char *old_nick = muc_complete_roster_nick_change(from_room, from_nick);
if (old_nick != NULL) {
muc_add_to_roster(from_room, from_nick, show_str, status_str, caps_key);
muc_add_to_roster(from_room, from_nick, show_str, status_str);
handle_room_member_nick_change(from_room, old_nick, from_nick);
free(old_nick);
} else {
if (!muc_nick_in_roster(from_room, from_nick)) {
handle_room_member_online(from_room, from_nick, show_str, status_str, caps_key);
handle_room_member_online(from_room, from_nick, show_str, status_str);
} else {
handle_room_member_presence(from_room, from_nick, show_str, status_str, caps_key);
handle_room_member_presence(from_room, from_nick, show_str, status_str);
}
}
}
@ -813,7 +758,6 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
}
free(status_str);
free(caps_key);
}
jid_destroy(from_jid);