Esempio n. 1
0
INT_PTR CSkypeProto::OnJoinChatRoom(WPARAM hContact, LPARAM)
{
	if (hContact)
	{
		ptrT idT(getTStringA(hContact, "ChatRoomID"));
		ptrT nameT(getTStringA(hContact, "Nick"));
		StartChatRoom(idT, nameT != NULL ? nameT : idT);
	}
	return 0;
}
Esempio n. 2
0
INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM)
{
	if (!m_enableChat || IsSpecialChatRoom(hContact))
		return 0;

	ptrT idT(getTStringA(hContact, "ChatRoomID"));
	ptrT nameT(getTStringA(hContact, "Nick"));
	ptrA threadId(getStringA(hContact, FACEBOOK_KEY_TID));

	if (!idT || !nameT || !threadId)
		return 0;

	facebook_chatroom *fbc;
	std::string tthread_id = threadId;

	auto it = facy.chat_rooms.find(tthread_id);
	if (it != facy.chat_rooms.end()) {
		fbc = it->second;
	}
	else {
		// We don't have this chat loaded in memory yet, lets load some info (name, list of users)
		fbc = new facebook_chatroom(tthread_id);
		LoadChatInfo(fbc);
		facy.chat_rooms.insert(std::make_pair(tthread_id, fbc));
	}

	// RM TODO: better use check if chatroom exists/is in db/is online... no?
	// like: if (ChatIDToHContact(tthread_id) == NULL) {
	ptrA users(GetChatUsers(tthread_id.c_str()));
	if (users == NULL) {
		// Add chatroom
		AddChat(fbc->thread_id.c_str(), fbc->chat_name.c_str());

		// Add chat contacts
		for (std::map<std::string, std::string>::iterator jt = fbc->participants.begin(); jt != fbc->participants.end(); ++jt) {
			AddChatContact(fbc->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
		}

		// Load last messages
		delSetting(hContact, FACEBOOK_KEY_MESSAGE_ID); // We're creating new chatroom so we want load all recent messages
		ForkThread(&FacebookProto::LoadLastMessages, new MCONTACT(hContact));
	}

	return 0;
}