diff --git a/telegram-adium/TelegramAccount.m b/telegram-adium/TelegramAccount.m index 31be859..5885038 100644 --- a/telegram-adium/TelegramAccount.m +++ b/telegram-adium/TelegramAccount.m @@ -171,7 +171,6 @@ } #pragma mark Group Chats - void chat_buddy_joined (PurpleConversation *conv, const char *name, PurpleConvChatBuddyFlags flags, gboolean new_arrival, void *data) { @@ -188,7 +187,6 @@ void chat_buddy_joined (PurpleConversation *conv, const char *name, service:nil]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{ - NSLog(@"Injecting chat participant alias: %s", P->print_name); [chat setAlias:[NSString stringWithUTF8String:P->print_name] forContact:dummy]; [chat resortParticipants]; diff --git a/telegram-adium/TelegramJoinChatViewController.m b/telegram-adium/TelegramJoinChatViewController.m index 2419094..65e70c3 100644 --- a/telegram-adium/TelegramJoinChatViewController.m +++ b/telegram-adium/TelegramJoinChatViewController.m @@ -95,12 +95,15 @@ static void tgl_peer_iterator_cb (tgl_peer_t *peer, void *extra) { PurpleConnection *gc = purple_account_get_connection(pa); if (gc && PURPLE_CONNECTION_IS_CONNECTED(gc)) { connection_data *conn = purple_connection_get_protocol_data (gc); - NSString *link = [textField_joinByLink stringValue]; + // Join by link + NSString *link = [textField_joinByLink stringValue]; if ([link length]) { import_chat_link_checked (conn->TLS, [link UTF8String]); return; } + + // Create a new chat with provided participants NSString *createChatName = [textField_createChatName stringValue]; NSArray *tokens = [tokenField_createChatUsers objectValue]; if ([createChatName length] && [tokens count]) { @@ -114,14 +117,17 @@ static void tgl_peer_iterator_cb (tgl_peer_t *peer, void *extra) { return; } - NSString *room = [[popupButton_existingChat selectedItem] title]; - NSDictionary *chatCreationInfo = [NSDictionary - dictionaryWithObjectsAndKeys:room, @"subject", nil]; - [self doJoinChatWithName:room - onAccount:inAccount - chatCreationInfo:chatCreationInfo - invitingContacts:@[] - withInvitationMessage:@""]; + // Pass the joining to the prpl + const char *name = [[[popupButton_existingChat selectedItem] title] UTF8String]; + PurpleChat *purpleChat = purple_blist_find_chat (conn->pa, name); + if (purpleChat) { + serv_join_chat (conn->gc, purple_chat_get_components (purpleChat)); + } else { + GHashTable *chatCreationInfo = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); + g_hash_table_insert (chatCreationInfo, "subject", g_strdup (name)); + serv_join_chat (conn->gc, chatCreationInfo); + g_hash_table_destroy (chatCreationInfo); + } } } diff --git a/telegram-adium/TelegramService.m b/telegram-adium/TelegramService.m index 74bcaf7..1976f95 100644 --- a/telegram-adium/TelegramService.m +++ b/telegram-adium/TelegramService.m @@ -93,16 +93,18 @@ return NO; } -- (AIServiceImportance)serviceImportance{ - return AIServiceSecondary; +- (AIServiceImportance)serviceImportance +{ + return AIServiceSecondary; } - (NSCharacterSet *)allowedCharacters{ return [[NSCharacterSet illegalCharacterSet] invertedSet]; } + - (NSCharacterSet *)allowedCharactersForAccountName { - return ([NSCharacterSet characterSetWithCharactersInString: @"+1234567890"]); + return ([NSCharacterSet characterSetWithCharactersInString: @"+1234567890"]); } - (NSUInteger)allowedLengthForAccountName @@ -131,7 +133,8 @@ return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"telegram"]; } -- (void)registerStatuses { +- (void)registerStatuses +{ #define ADDSTATUS(name, type) \ [adium.statusController registerStatus:name \ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:name] \ @@ -144,4 +147,10 @@ ofType:type forService:self] ADDSTATUS(STATUS_NAME_OFFLINE, AIOfflineStatusType); } +- (NSString *)normalizeChatName:(NSString *)inChatName +{ + // prevent Adium from normalizing chat names, which would break searching chats by user names + return inChatName; +} + @end