bool PurpleIMChat::addContactCbk(void * dataIn) { Mutex::ScopedLock lock(PurpleIMChat::_mutex); PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; PurpleIMChat* imChat = cbData->getPurpleIMChat(); IMChatSession* chatSession = cbData->getIMChatSession(); PurpleAccount* gAccount = getPurpleAccount( imChat->getIMAccount() ); // const char * contactId = (const char *)((misc_t *)data)->data_ptr2; mConvInfo_t *mConv = FindChatStructById(chatSession->getId()); int BuddyNbr = chatSession->getIMContactSet().size(); PurpleConversation *gConv = NULL; if (mConv) gConv = mConv->purple_conv_session; //VOXOX - JRT - 2009.07.09 else LOG_FATAL("ConvInfo not created !!!"); if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_IM) { GList *mlist = NULL; IMContactSet& chatContact = const_cast<IMContactSet&>(chatSession->getIMContactSet()); IMContactSet::const_iterator it = chatContact.begin(); const std::string & firstContactId = it->getContactId(); PurpleConnection *gGC; gConv = mConv->purple_conv_session; //VOXOX - JRT - 2009.07.09 gGC = purple_conversation_get_gc(gConv); mlist = g_list_append(mlist, const_cast<char*>(cbData->getContactId().c_str()) ); mlist = g_list_append(mlist, (char *) firstContactId.c_str()); createPurpleChat(gGC, chatSession->getId(), mlist, *imChat, gAccount); //VOXOX - JRT - 2009.07.10 } else if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_CHAT) { serv_chat_invite(purple_conversation_get_gc(gConv), purple_conv_chat_get_id(PURPLE_CONV_CHAT(gConv)), NULL, cbData->getContactId().c_str() ); } timeoutRemove( cbData ); delete cbData; return TRUE; }
void PurpleChatMngr::ChatAddUsersCbk(PurpleConversation *conv, GList *users, gboolean new_arrivals) { GList *l; PurpleAccount *gAccount = purple_conversation_get_account(conv); const char *gPrclId = purple_account_get_protocol_id(gAccount); IMAccount *account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId)); mConvInfo_t *mConv = NULL; IMChatSession *chatSession = NULL; PurpleIMChat *mChat = FindIMChat(*account); if (!mChat) LOG_FATAL("Can't find IMChat !"); mConv = (mConvInfo_t *) conv->ui_data; chatSession = mConv->conv_session; //VOXOX - JRT - 2009.07.09 for (l = users; l != NULL; l = l->next) { PurpleConvChatBuddy *gCCBuddy = (PurpleConvChatBuddy *) l->data; if (gCCBuddy && strcmp(purple_account_get_username(gAccount), (char *) gCCBuddy->name)) { std::string buddy((char *) gCCBuddy->name); IMContact imContact(*account, buddy); if (chatSession->getIMContactSet().find(imContact) != chatSession->getIMContactSet().end()) { LOG_DEBUG("IMContact for " + imContact.getContactId() + " already in IMContactSet"); } else { ((IMContactSet &) chatSession->getIMContactSet()).insert(imContact); if (chatSession->getIMContactSet().size() == 1) { //Create session when first contact is added. mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession); } LOG_DEBUG("IMContact " + imContact.getContactId() + " added to IMContactSet"); } mChat->contactAddedEvent(*mChat, *chatSession, imContact); } } }
bool ParticipantList::includeInCandidateList( const ContactProfile& contactProfile, const IMChatSession& chatSession, bool& bInChatSession ) { bool bInclude = true; const IMContact* imContact = NULL; bInChatSession = false; if ( _includeOnlyOnline ) { imContact = contactProfile.getFirstAvailableIMContact( const_cast<IMChatSession&>(chatSession) ); //This seems wrong. } else { imContact = contactProfile.getPreferredIMContact(); } if ( imContact ) { IMContact* imContact2 = chatSession.getIMContactSet().findByContact( *imContact ); //Don't add IMContacts already in chatsession. //Jabber IMContacts for Group Chats are not built correctly (missing domain), so try a second find. if ( imContact2 == NULL ) { std::string accountId = imContact->getIMAccountId(); std::string contactId = imContact->getContactId(); imContact2 = chatSession.getIMContactSet().findBy( accountId, contactId, true ); } bInChatSession = (imContact2 != NULL); if ( _sameNetworkOnly ) { bInclude = (imContact->getProtocol() == chatSession.getIMContactSet().begin()->getProtocol() ); //OK use of getProtocol(). } } return bInclude; }
void GaimChatMngr::ChatRemoveUsersCbk(GaimConversation *conv, GList *users) { GList *l; GaimAccount *gAccount = gaim_conversation_get_account(conv); const char *gPrclId = gaim_account_get_protocol_id(gAccount); IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount), GaimIMPrcl::GetEnumIMProtocol(gPrclId)); mConvInfo_t *mConv = NULL; IMChatSession *chatSession = NULL; GaimIMChat *mChat = FindIMChat(*account); if (!mChat) LOG_FATAL("Can't find IMChat !"); mConv = (mConvInfo_t *) conv->ui_data; chatSession = (IMChatSession *) mConv->conv_session; for (l = users; l != NULL; l = l->next) { if (strcmp(gaim_account_get_username(gAccount), (char *) l->data)) { std::string buddy((char *) l->data); IMContact imContact(*account, buddy); if (chatSession->getIMContactSet().find(imContact) == chatSession->getIMContactSet().end()) { LOG_ERROR("IMContact for " + imContact.getContactId() + " not in IMContactSet"); } else { LOG_DEBUG("IMContact " + imContact.getContactId() + " removed from IMContactSet"); mChat->contactRemovedEvent(*mChat, *chatSession, buddy); } } } }
void GaimChatMngr::CreateConversationCbk(GaimConversation *conv, bool userCreated) { GaimAccount *gAccount = gaim_conversation_get_account(conv); GaimConversationType chatType = gaim_conversation_get_type(conv); const char *gPrclId = gaim_account_get_protocol_id(gAccount); IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount), GaimIMPrcl::GetEnumIMProtocol(gPrclId)); GaimIMChat *mChat = FindIMChat(*account); mConvInfo_t *mConv; if (chatType == GAIM_CONV_TYPE_IM) { IMChatSession *chatSession = NULL; // Check if it's a jabber contact, and remove his ressource std::string contactId = cleanContactId(std::string(gaim_conversation_get_name(conv)), GaimIMPrcl::GetEnumIMProtocol(gPrclId)); IMContact imContact(*account, contactId); mConv = mChat->CreateChatSession(userCreated, *mChat); mConv->gaim_conv_session = conv; conv->ui_data = mConv; chatSession = (IMChatSession *) mConv->conv_session; ((IMContactSet &) chatSession->getIMContactSet()).insert(imContact); mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession); mChat->contactAddedEvent(*mChat, *chatSession, imContact); } else if (chatType == GAIM_CONV_TYPE_CHAT) { int id = GetGaimConversationId(gaim_conversation_get_name(conv)); if ((mConv = mChat->FindChatStructById(id)) == NULL) { mConv = mChat->CreateChatSession(userCreated, *mChat); } if (mConv->gaim_conv_session) gaim_conversation_destroy((GaimConversation *)mConv->gaim_conv_session); mConv->gaim_conv_session = conv; conv->ui_data = mConv; } }
void PurpleChatMngr::ChatRemoveUsersCbk(PurpleConversation *conv, GList *users) { GList *l; PurpleAccount *gAccount = purple_conversation_get_account(conv); const char *gPrclId = purple_account_get_protocol_id(gAccount); IMAccount *account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId)); mConvInfo_t *mConv = NULL; IMChatSession *chatSession = NULL; PurpleIMChat *mChat = FindIMChat(*account); if (!mChat) LOG_FATAL("Can't find IMChat !"); mConv = (mConvInfo_t *) conv->ui_data; chatSession = mConv->conv_session; //VOXOX - JRT - 2009.07.09 for (l = users; l != NULL; l = l->next) { if (strcmp(purple_account_get_username(gAccount), (char *) l->data)) { std::string buddy((char *) l->data); IMContact imContact(*account, buddy); IMContact* imContact2 = chatSession->getIMContactSet().findBy( account->getKey(), buddy ); // if (chatSession->getIMContactSet().find(imContact) == chatSession->getIMContactSet().end()) if ( imContact2 == NULL ) { LOG_ERROR("IMContact for " + imContact.getContactId() + " not in IMContactSet"); } else { LOG_DEBUG("IMContact " + imContact.getContactId() + " removed from IMContactSet"); mChat->contactRemovedEvent(*mChat, *chatSession, buddy); } } } }
void PurpleChatMngr::CreateConversationCbk(PurpleConversation *conv, bool userCreated) { PurpleAccount* gAccount = purple_conversation_get_account(conv); PurpleConversationType chatType = purple_conversation_get_type(conv); const char* gPrclId = purple_account_get_protocol_id(gAccount); IMAccount* account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId)); //VOXOX - JRT - 2009.07.20 - We seem to get a lot of crashes through here, via skype_find_chat. I suspect account is not being found. if ( account == NULL ) { std::string username = purple_account_get_username(gAccount); LOG_ERROR(" account == NULL for " + username + "\n"); } PurpleIMChat* mChat = FindIMChat(*account); mConvInfo_t* mConv = NULL; if (chatType == PURPLE_CONV_TYPE_IM) { IMChatSession *chatSession = NULL; // Check if it's a jabber contact, remove the resource std::string contactId = cleanContactId(std::string(purple_conversation_get_name(conv)), PurpleIMPrcl::GetEnumIMProtocol(gPrclId)); IMContact imContact(*account, contactId); mConv = mChat->CreateChatSession(userCreated, *mChat); mConv->purple_conv_session = conv; conv->ui_data = mConv; // chatSession = (IMChatSession *) mConv->conv_session; chatSession = mConv->conv_session; //VOXOX - JRT - 2009.07.09 - changed def from void* to IMChatSession* ((IMContactSet &) chatSession->getIMContactSet()).insert(imContact); //VOXOX CHANGE CJC - validate if message don't have to be sent automatically if(userCreated) { if(mChat->getAutoMessage() != "") { mChat->newIMChatAndSendMessageSessionCreatedEvent(*mChat, *((IMChatSession *)(mConv->conv_session)),mChat->getAutoMessage(),true); } else { switch( mChat->getIMChatType() ) { case IMChat::ChatToEmail: mChat->newIMChatToEmailSessionCreatedEvent(*mChat, *(mConv->conv_session)); //VOXOX - JRT - 2009.07.09 mChat->contactAddedEvent(*mChat, *chatSession, imContact); break; case IMChat::ChatToSMS: mChat->newIMChatToSMSSessionCreatedEvent(*mChat, *(mConv->conv_session)); //VOXOX - JRT - 2009.07.09 mChat->contactAddedEvent(*mChat, *chatSession, imContact); break; case IMChat::Chat: case IMChat::ChatGroup: //VOXOX - JRT - 2009.06.15 - we don't really expect this type. mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession); mChat->contactAddedEvent(*mChat, *chatSession, imContact); break; default: assert(false); //New IMChatType? } } } else { mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession); mChat->contactAddedEvent(*mChat, *chatSession, imContact); } } else if (chatType == PURPLE_CONV_TYPE_CHAT) { // int id = GetPurpleConversationId(purple_conversation_get_name(conv)); //VOXOX - JRT - 2009.06.16 - This does not work because it relies on CR name having ID as part of name. // int id = mChat->getGroupChatInfo().getId(); // if ((mConv = mChat->FindChatStructById(id)) == NULL) if ((mConv = mChat->FindChatStructByName( conv->name )) == NULL) { mConv = mChat->CreateChatSession(userCreated, *mChat); IMChatSession* chatSession = mConv->conv_session; //VOXOX - JRT - 2009.07.09 if ( chatSession ) { chatSession->setIMChatType( IMChat::ChatGroup ); // GroupChatInfo& gcInfo = chatSession->getIMChat().getGroupChatInfo(); GroupChatInfo& gcInfo = chatSession->getGroupChatInfo(); gcInfo.setId ( mConv->conv_id ); gcInfo.setChatRoom( conv->name ); } } if (mConv->purple_conv_session) purple_conversation_destroy(mConv->purple_conv_session); //VOXOX - JRT - 2009.07.09 mConv->purple_conv_session = conv; conv->ui_data = mConv; } }