grim/purple-spasm

Parents 52ab65385767
Children e19125aacad9
Don't open a new chat when joining an existing chat and casefold chat names
--- a/src/spasm-chat.c Thu May 14 03:54:05 2020 -0500
+++ b/src/spasm-chat.c Thu Jun 18 04:39:11 2020 -0500
@@ -38,7 +38,6 @@
GDataInputStream *input_stream;
GHashTable *handlers;
- gint id; /* used to track ids for this service */
GRegex *regex_message;
GRegex *regex_target;
@@ -174,12 +173,14 @@
if(purple_utf8_strcasecmp(nick, purple_account_get_username(account)) == 0) {
PurpleConnection *connection = spasm_account_get_connection(chat->sa);
+ gchar *lower = g_utf8_casefold(target, -1);
/* We initiated the join. */
- serv_got_joined_chat(connection, chat->id++, target);
+ serv_got_joined_chat(connection, g_str_hash(lower), lower);
g_free(nick);
g_free(target);
+ g_free(lower);
return;
} else {
@@ -647,15 +648,25 @@
GHashTable *components)
{
SpasmAccount *sa = NULL;
- SpasmChatService *chat = NULL;
+ PurpleConversation *conv = NULL;
+ gchar *lower = NULL;
const gchar *channel = NULL;
channel = g_hash_table_lookup(components, "channel");
+ lower = g_utf8_casefold(channel, -1);
sa = purple_connection_get_protocol_data(connection);
- chat = spasm_account_get_chat_service(sa);
- spasm_chat_service_real_send(chat, "JOIN #%s", channel);
+ conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, lower,
+ spasm_account_get_account(sa));
+ if(conv == NULL) {
+ SpasmChatService *chat = NULL;
+ chat = spasm_account_get_chat_service(sa);
+
+ spasm_chat_service_real_send(chat, "JOIN #%s", lower);
+ }
+
+ g_free(lower);
}
gchar *