1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into readline

This commit is contained in:
James Booth 2015-02-23 23:46:40 +00:00
commit 93b5ca7a1f
3 changed files with 17 additions and 7 deletions

View File

@ -88,11 +88,12 @@ jid_create(const gchar * const str)
if (slashp != NULL) { if (slashp != NULL) {
result->resourcepart = g_strdup(slashp + 1); result->resourcepart = g_strdup(slashp + 1);
result->domainpart = g_utf8_substring(domain_start, 0, g_utf8_pointer_to_offset(domain_start, slashp)); result->domainpart = g_utf8_substring(domain_start, 0, g_utf8_pointer_to_offset(domain_start, slashp));
result->barejid = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp)); char *barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp));
result->barejid = g_utf8_strdown(barejidraw, -1);
result->fulljid = g_strdup(trimmed); result->fulljid = g_strdup(trimmed);
} else { } else {
result->domainpart = g_strdup(domain_start); result->domainpart = g_strdup(domain_start);
result->barejid = g_strdup(trimmed); result->barejid = g_utf8_strdown(trimmed, -1);
} }
if (result->domainpart == NULL) { if (result->domainpart == NULL) {
@ -144,7 +145,9 @@ jid_is_valid_room_form(Jid *jid)
char * char *
create_fulljid(const char * const barejid, const char * const resource) create_fulljid(const char * const barejid, const char * const resource)
{ {
gchar *barejidlower = g_utf8_strdown(barejid, -1);
GString *full_jid = g_string_new(barejid); GString *full_jid = g_string_new(barejid);
g_free(barejidlower);
g_string_append(full_jid, "/"); g_string_append(full_jid, "/");
g_string_append(full_jid, resource); g_string_append(full_jid, resource);

View File

@ -91,7 +91,7 @@ roster_update_presence(const char * const barejid, Resource *resource,
assert(barejid != NULL); assert(barejid != NULL);
assert(resource != NULL); assert(resource != NULL);
PContact contact = g_hash_table_lookup(contacts, barejid); PContact contact = roster_get_contact(barejid);
if (contact == NULL) { if (contact == NULL) {
return FALSE; return FALSE;
} }
@ -109,14 +109,18 @@ roster_update_presence(const char * const barejid, Resource *resource,
PContact PContact
roster_get_contact(const char * const barejid) roster_get_contact(const char * const barejid)
{ {
return g_hash_table_lookup(contacts, barejid); gchar *barejidlower = g_utf8_strdown(barejid, -1);
PContact contact = g_hash_table_lookup(contacts, barejidlower);
g_free(barejidlower);
return contact;
} }
gboolean gboolean
roster_contact_offline(const char * const barejid, roster_contact_offline(const char * const barejid,
const char * const resource, const char * const status) const char * const resource, const char * const status)
{ {
PContact contact = g_hash_table_lookup(contacts, barejid); PContact contact = roster_get_contact(barejid);
if (contact == NULL) { if (contact == NULL) {
return FALSE; return FALSE;
@ -212,7 +216,7 @@ void
roster_update(const char * const barejid, const char * const name, roster_update(const char * const barejid, const char * const name,
GSList *groups, const char * const subscription, gboolean pending_out) GSList *groups, const char * const subscription, gboolean pending_out)
{ {
PContact contact = g_hash_table_lookup(contacts, barejid); PContact contact = roster_get_contact(barejid);
assert(contact != NULL); assert(contact != NULL);
p_contact_set_subscription(contact, subscription); p_contact_set_subscription(contact, subscription);
@ -239,7 +243,7 @@ gboolean
roster_add(const char * const barejid, const char * const name, GSList *groups, roster_add(const char * const barejid, const char * const name, GSList *groups,
const char * const subscription, gboolean pending_out) const char * const subscription, gboolean pending_out)
{ {
PContact contact = g_hash_table_lookup(contacts, barejid); PContact contact = roster_get_contact(barejid);
if (contact != NULL) { if (contact != NULL) {
return FALSE; return FALSE;
} }

View File

@ -285,6 +285,8 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
} }
} }
g_free(barejid_lower);
return 1; return 1;
} }
@ -324,6 +326,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
log_warning("Attempt to add contact twice: %s", barejid_lower); log_warning("Attempt to add contact twice: %s", barejid_lower);
} }
g_free(barejid_lower);
item = xmpp_stanza_get_next(item); item = xmpp_stanza_get_next(item);
} }