about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-23 23:46:40 +0000
committerJames Booth <boothj5@gmail.com>2015-02-23 23:46:40 +0000
commit93b5ca7a1f69c613f31374a71b13eadde3cb2937 (patch)
tree208c49aa2030fdded1e79341fcda5876962fb72e
parente22547fb19872bffeaedf69e03024c0e6057b429 (diff)
parent70b923a7fcc11011e536ffb741f6158798f2fb8e (diff)
downloadprofani-tty-93b5ca7a1f69c613f31374a71b13eadde3cb2937.tar.gz
Merge branch 'master' into readline
-rw-r--r--src/jid.c7
-rw-r--r--src/roster_list.c14
-rw-r--r--src/xmpp/roster.c3
3 files changed, 17 insertions, 7 deletions
diff --git a/src/jid.c b/src/jid.c
index d1c25ddb..e314b2cf 100644
--- a/src/jid.c
+++ b/src/jid.c
@@ -88,11 +88,12 @@ jid_create(const gchar * const str)
     if (slashp != NULL) {
         result->resourcepart = g_strdup(slashp + 1);
         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);
     } else {
         result->domainpart = g_strdup(domain_start);
-        result->barejid = g_strdup(trimmed);
+        result->barejid = g_utf8_strdown(trimmed, -1);
     }
 
     if (result->domainpart == NULL) {
@@ -144,7 +145,9 @@ jid_is_valid_room_form(Jid *jid)
 char *
 create_fulljid(const char * const barejid, const char * const resource)
 {
+    gchar *barejidlower = g_utf8_strdown(barejid, -1);
     GString *full_jid = g_string_new(barejid);
+    g_free(barejidlower);
     g_string_append(full_jid, "/");
     g_string_append(full_jid, resource);
 
diff --git a/src/roster_list.c b/src/roster_list.c
index b9a142cb..ad1864f1 100644
--- a/src/roster_list.c
+++ b/src/roster_list.c
@@ -91,7 +91,7 @@ roster_update_presence(const char * const barejid, Resource *resource,
     assert(barejid != NULL);
     assert(resource != NULL);
 
-    PContact contact = g_hash_table_lookup(contacts, barejid);
+    PContact contact = roster_get_contact(barejid);
     if (contact == NULL) {
         return FALSE;
     }
@@ -109,14 +109,18 @@ roster_update_presence(const char * const barejid, Resource *resource,
 PContact
 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
 roster_contact_offline(const char * const barejid,
     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) {
         return FALSE;
@@ -212,7 +216,7 @@ void
 roster_update(const char * const barejid, const char * const name,
     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);
 
     p_contact_set_subscription(contact, subscription);
@@ -239,7 +243,7 @@ gboolean
 roster_add(const char * const barejid, const char * const name, GSList *groups,
     const char * const subscription, gboolean pending_out)
 {
-    PContact contact = g_hash_table_lookup(contacts, barejid);
+    PContact contact = roster_get_contact(barejid);
     if (contact != NULL) {
         return FALSE;
     }
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index 1e943fb6..6de370aa 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -285,6 +285,8 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
         }
     }
 
+    g_free(barejid_lower);
+
     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);
             }
 
+            g_free(barejid_lower);
             item = xmpp_stanza_get_next(item);
         }