diff --git a/telegram-adium/TelegramAccount.m b/telegram-adium/TelegramAccount.m index bf507d9..e9dbc4c 100644 --- a/telegram-adium/TelegramAccount.m +++ b/telegram-adium/TelegramAccount.m @@ -103,19 +103,6 @@ intValue]); } -/**! - * @brief Returns the name passed to new_purple_buddy, when adding a new contact - * - * This function is called when creating a new contact from the purple GUI. - */ -- (NSString *)_UIDForAddingObject:(AIListContact *)object -{ - // The contact UID in Adium was encoded with decomposoed unicode codepoints (see http://unicode.org/reports/tr15/). - // Since libtgl and libpurple (and apparently the rest of the world) encode with composed code points, the name - // needs to be converted to the composed format to prevent inequality in binary string comparison. - return [object.UID precomposedStringWithCanonicalMapping]; -} - #pragma mark Action Menu -(NSMenu*)actionMenuForChat:(AIChat*)chat { diff --git a/tgp-blist.c b/tgp-blist.c index 27e8572..ee9770a 100644 --- a/tgp-blist.c +++ b/tgp-blist.c @@ -45,6 +45,10 @@ const char *tgp_blist_lookup_purple_name (struct tgl_state *TLS, tgl_peer_id_t i } void tgp_blist_lookup_add (struct tgl_state *TLS, tgl_peer_id_t id, const char *purple_name) { + + // to avoid issues with differences in string normalization, always store in composed form this helps to avoid + // issues with clients like Adium, that will store strings in decomposed format by default + const char *name = g_utf8_normalize (purple_name, -1, G_NORMALIZE_DEFAULT_COMPOSE); g_hash_table_replace (tls_get_data (TLS)->id_to_purple_name, GINT_TO_POINTER(tgl_get_peer_id (id)), g_strdup (name)); @@ -53,7 +57,8 @@ void tgp_blist_lookup_add (struct tgl_state *TLS, tgl_peer_id_t id, const char * } static tgl_peer_id_t *tgp_blist_lookup_get_id (struct tgl_state *TLS, const char *purple_name) { - return g_hash_table_lookup (tls_get_data (TLS)->purple_name_to_id, purple_name); + return g_hash_table_lookup (tls_get_data (TLS)->purple_name_to_id, + g_utf8_normalize (purple_name, -1, G_NORMALIZE_DEFAULT_COMPOSE)); } tgl_peer_t *tgp_blist_lookup_peer_get (struct tgl_state *TLS, const char *purple_name) {