//----------------------------------------------------------------------------- //VOXOX CHANGE CJC SEND MESSAGE AUTOMATICALLY WHEN OPENING AN ACCOUNT bool PurpleIMChat::createSessionAndSendMessageCbk(void * dataIn) { #if (defined OS_WINDOWS) Mutex::ScopedLock lock(PurpleIMChat::_mutex); #endif PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; PurpleIMChat* imChat = cbData->getPurpleIMChat(); IMContactSet* imContactSet = cbData->getIMContactSet(); PurpleAccount* gAccount = getPurpleAccount( imChat->getIMAccount() ); // const char * message = (const char *)((misc_t *)data)->data_ptr2; // std::string realMessage = message; //VOXOX CHANGE CJC TO BE ABLE TO SEND THIS VALUES TO PURPLECHATMNGR AND SEND MESSAGE AUTOMATICALLY IMContactSet::const_iterator it; if (imContactSet->empty()) { LOG_FATAL("imContactSet is empty"); } else if (imContactSet->size() == 1) { it = imContactSet->begin(); std::string contactId = (*it).getContactId(); PurpleConversation *gConv = NULL; if ((gConv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, contactId.c_str(), gAccount))) { mConvInfo_t *mConv = (mConvInfo_t *)gConv->ui_data; imChat->newIMChatAndSendMessageSessionCreatedEvent(*imChat, *(mConv->conv_session), cbData->getMessage(), false); //VOXOX - JRT - 2009.07.09 timeoutRemove( cbData ); delete cbData; return FALSE; } purple_conversation_new(PURPLE_CONV_TYPE_IM, gAccount, contactId.c_str()); } timeoutRemove( cbData ); delete cbData; return TRUE; }
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; }
//----------------------------------------------------------------------------- //VOXOX - CJC - 2009.05.07 Add session form AskImVoxOxCom bool PurpleIMChat::createChatToEmailSessionCbk(void * dataIn) { #if (defined OS_WINDOWS) Mutex::ScopedLock lock(PurpleIMChat::_mutex); #endif PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; PurpleIMChat* imChat = cbData->getPurpleIMChat(); IMContactSet* imContactSet = cbData->getIMContactSet(); PurpleAccount* gAccount = getPurpleAccount( imChat->getIMAccount() ); IMContactSet::const_iterator askImContact; if (imContactSet->empty()) { LOG_FATAL("imContactSet is empty"); } else if (imContactSet->size() == 1) { askImContact = imContactSet->begin(); std::string askId = (*askImContact).getContactId(); PurpleConversation *gConv = NULL; if ((gConv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, askId.c_str(), gAccount))) { mConvInfo_t *mConv = (mConvInfo_t *)gConv->ui_data; imChat->newIMChatToEmailSessionCreatedEvent(*imChat, *(mConv->conv_session)); //VOXOX - JRT - 2009.07.09 timeoutRemove( cbData ); delete cbData; return FALSE; } purple_conversation_new(PURPLE_CONV_TYPE_IM, gAccount, askId.c_str()); } timeoutRemove( cbData ); delete cbData; return TRUE; }
//----------------------------------------------------------------------------- //VOXOX CHANGE CJC ADD SKYPE CALL SUPPORT //TODO: THIS SHOULD NOT BE HERE bool PurpleIMChat::callSkypeContactCbk(void * dataIn) { Mutex::ScopedLock lock(PurpleIMChat::_mutex); PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; PurpleIMChat* imChat = cbData->getPurpleIMChat(); IMContactSet* imContactSet = cbData->getIMContactSet(); PurpleAccount* gAccount = getPurpleAccount( imChat->getIMAccount() ); PurplePluginProtocolInfo* prpl_info = NULL; PurpleConnection* gc = purple_account_get_connection(gAccount); PurplePlugin* prpl = NULL; IMContactSet::const_iterator it; if (imContactSet->size() == 1) { it = imContactSet->begin(); std::string contactId = (*it).getContactId(); if (gc != NULL) prpl = purple_connection_get_prpl(gc); if (prpl != NULL) prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); if (prpl_info != NULL && prpl_info->set_info != NULL) prpl_info->set_info(NULL,contactId.c_str()); } timeoutRemove( cbData ); delete cbData; return TRUE; }
bool PurpleIMChat::createSessionCbk(void * dataIn) { Mutex::ScopedLock lock(PurpleIMChat::_mutex); PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; PurpleIMChat* imChat = cbData->getPurpleIMChat(); IMContactSet* imContactSet = cbData->getIMContactSet(); // PurpleAccount* gAccount = purple_accounts_find(imChat->getIMAccount().getLogin().c_str(), // PurpleIMPrcl::GetPrclId(imChat->getIMAccount().getProtocol())); PurpleAccount* gAccount = getPurpleAccount( imChat->getIMAccount() ); IMContactSet::const_iterator it; if (imContactSet->empty()) { LOG_FATAL("imContactSet is empty"); } else { switch( imChat->getIMChatType() ) { case IMChat::Chat: { it = imContactSet->begin(); std::string contactId = (*it).getContactId(); PurpleConversation *gConv = NULL; gConv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, contactId.c_str(), gAccount); //If converation already exists, we still do the CreatedEvent so UI responds properly, // then we remove the task from queue. if ( gConv ) { mConvInfo_t *mConv = (mConvInfo_t *)gConv->ui_data; imChat->newIMChatSessionCreatedEvent(*imChat, *(mConv->conv_session)); //VOXOX - JRT - 2009.07.09 timeoutRemove( cbData ); delete cbData; return FALSE; } purple_conversation_new(PURPLE_CONV_TYPE_IM, gAccount, contactId.c_str()); break; } case IMChat::ChatGroup: { //Capture invitees. They will be handled later. PurpleConnection *gGC = purple_account_get_connection(gAccount); GList *mlist = NULL; for (it = imContactSet->begin(); it != imContactSet->end(); it++) { mlist = g_list_append(mlist, strdup(it->getContactId().c_str()) ); } //Does this group chat already exist? std::string chatRoomName = imChat->getGroupChatInfo().getAlias(); //VOXOX - JRT - 2009.06.18 - TODO: use getChatRoom() PurpleConversation *gConv = NULL; gConv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chatRoomName.c_str(), gAccount); //If converation already exists, we still do the CreatedEvent so UI responds properly, // then we remove the task from queue. if ( gConv ) { mConvInfo_t *mConv = (mConvInfo_t *)gConv->ui_data; imChat->newIMChatSessionCreatedEvent(*imChat, *(mConv->conv_session)); //VOXOX - JRT - 2009.07.09 timeoutRemove( cbData ); delete cbData; return FALSE; } //Create new chat. // purple_conversation_new(PURPLE_CONV_TYPE_CHAT, gAccount, contactId.c_str()); createPurpleChat(gGC, 0, mlist, *imChat, gAccount ); //VOXOX - JRT - 2009.07.10 break; } default: LOG_FATAL("IMChat:IMChatType is improper: ", imChat->getIMChatType()); } } timeoutRemove( cbData ); delete cbData; return TRUE; }