void CSkypeProto::OnGetChatInfo(const NETLIBHTTPREQUEST *response, void *p) { TCHAR *topic = (TCHAR*)p; if (response == NULL || response->pData == NULL) return; JSONNode root = JSONNode::parse(response->pData); if (!root) return; const JSONNode &members = root["members"]; const JSONNode &properties = root["properties"]; if (!properties["capabilities"] || properties["capabilities"].empty()) return; CMStringA chatId(ChatUrlToName(root["messages"].as_string().c_str())); StartChatRoom(_A2T(chatId), topic); for (size_t i = 0; i < members.size(); i++) { const JSONNode &member = members.at(i); CMStringA username(ContactUrlToName(member["userLink"].as_string().c_str())); std::string role = member["role"].as_string(); if (!IsChatContact(_A2T(chatId), username)) AddChatContact(_A2T(chatId), username, username, _A2T(role.c_str()), true); } PushRequest(new GetHistoryRequest(m_szRegToken, chatId, 15, true, 0, m_szServer), &CSkypeProto::OnGetServerHistory); mir_free(topic); }
void FacebookProto::AddChatContact(const char *chat_id, const char *id, const char *name) { if (IsChatContact(chat_id, id)) return; ptrT tchat_id(mir_a2t(chat_id)); ptrT tnick(mir_a2t_cp(name, CP_UTF8)); ptrT tid(mir_a2t(id)); GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN }; GCEVENT gce = { sizeof(gce), &gcd }; gce.pDest = &gcd; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tnick; gce.ptszUID = tid; gce.time = ::time(NULL); gce.bIsMe = !mir_strcmp(id, facy.self_.user_id.c_str()); if (gce.bIsMe) { gce.ptszStatus = TranslateT("Myself"); } else { MCONTACT hContact = ContactIDToHContact(id); if (hContact == NULL || getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE) != CONTACT_FRIEND) gce.ptszStatus = TranslateT("User"); else { gce.ptszStatus = TranslateT("Friend"); } } CallServiceSync(MS_GC_EVENT, 0, reinterpret_cast<LPARAM>(&gce)); }
void CSkypeProto::AddChatContact(const TCHAR *tchat_id, const char *id, const char *name, const TCHAR *role, bool isChange) { if (IsChatContact(tchat_id, id)) return; ptrT tnick(mir_a2t_cp(name, CP_UTF8)); ptrT tid(mir_a2t(id)); GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN }; GCEVENT gce = { sizeof(gce), &gcd }; gce.pDest = &gcd; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tnick; gce.ptszUID = tid; gce.time = !isChange ? time(NULL) : NULL; gce.bIsMe = IsMe(id); gce.ptszStatus = TranslateTS(role); CallServiceSync(MS_GC_EVENT, 0, reinterpret_cast<LPARAM>(&gce)); }