//************************************************************************ // removes a contact from the list //************************************************************************ void CContactList::RemoveContact(HANDLE hContact) { CListContainer<CContactListEntry*,CContactListGroup*> *pGroup = NULL; ///tstring strGroup = GetContactGroupPath(hContact); CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry) { return; } if( !CConfig::GetBoolSetting(CLIST_USEGROUPS)){ if(pContactEntry->GetType() == ITEM) RemoveItem(((CListItem<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetItemData()); else RemoveGroup(((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetGroupData()); } else { pGroup = (CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent(); ASSERT(pGroup != NULL); CContactListEntry *pEntry = GetContactData(pContactEntry); if(!pEntry) { return; } // Update the contacts group if it has one if(pGroup->GetType() != ROOT) { if(!CAppletManager::IsSubContact(hContact) && pEntry->iStatus != ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1); if(!CAppletManager::IsSubContact(hContact) && pEntry->iMessages > 0) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,0,-pEntry->iMessages); } if(pContactEntry->GetType() == ITEM) pGroup->RemoveItem(((CListItem<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetItemData()); else { pGroup->RemoveGroup(((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetGroupData()); // Reenumerate all subcontacts (maybe MetaContacts was disabled int numContacts = CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hContact,0); HANDLE hSubContact = NULL; for(int i=0;i<numContacts;i++) { hSubContact = (HANDLE *) CallService(MS_MC_GETSUBCONTACT,(WPARAM)hContact, (LPARAM)i); if(!FindContact(hSubContact)) { AddContact(hSubContact); } } } CListContainer<CContactListEntry*,CContactListGroup*> *pParent = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent(); while(pParent != NULL && pGroup->IsEmpty() && !pGroup->GetGroupData()->hMetaContact) { pParent->RemoveGroup(pGroup->GetGroupData()); pGroup = pParent; pParent = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent(); } } }
MCONTACT CSteamProto::AddToList(int, PROTOSEARCHRESULT* psr) { MCONTACT hContact = NULL; ptrA steamId(mir_u2a(psr->id.t)); if (psr->cbSize == sizeof(PROTOSEARCHRESULT)) { if (!FindContact(steamId)) { //hContact = AddContact(steamId, true); //ForkThread(&CSteamProto::UpdateContactsThread, (void*)mir_strdup(steamId)); ptrA token(getStringA("TokenSecret")); PushRequest( new GetUserSummariesRequest(token, steamId), &CSteamProto::OnGotUserSummaries); } } else if (psr->cbSize == sizeof(STEAM_SEARCH_RESULT)) { STEAM_SEARCH_RESULT *ssr = (STEAM_SEARCH_RESULT*)psr; hContact = AddContact(steamId, true); UpdateContact(hContact, ssr->data); } return hContact; }
int UCMeetingProxy::RemoveParticipant(const UCSDKContact& member, const std::string& convId) { DEBUG_LOG() << "--- ENTER"; INFO_PARAM2(member.uri_, convId); //获取conversation uc::model::conversation::Conversation* pConversation = GetConversation(convId); if (NULL == pConversation) { ERROR_LOG() << "Get conversation failed."; DEBUG_LOG() << "--- LEAVE"; return UCSDK_Fail; } //查找联系人 Contact contact; int iRet = FindContact(contact, member); if (UCSDK_Succ != iRet) { ERROR_LOG() << "Find contact failed."; DEBUG_LOG() << "--- LEAVE"; return iRet; } //删除与会人 if (!pConversation->RemoveParticipant(contact)) { ERROR_LOG() << "Remove participant failed."; DEBUG_LOG() << "--- LEAVE"; return UCSDK_Fail; } DEBUG_LOG() << "--- LEAVE"; return UCSDK_Succ; }
void CSkypeProto::ProcessUserPresence(const JSONNode &node) { debugLogA("CSkypeProto::ProcessUserPresenceRes"); std::string selfLink = node["selfLink"].as_string(); std::string status = node["status"].as_string(); CMStringA skypename = UrlToSkypename(selfLink.c_str()); if (!skypename.IsEmpty()) { if (IsMe(skypename)) { int iNewStatus = SkypeToMirandaStatus(status.c_str()); if (iNewStatus == ID_STATUS_OFFLINE) return; int old_status = m_iStatus; m_iDesiredStatus = iNewStatus; m_iStatus = iNewStatus; if (old_status != iNewStatus) { ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, iNewStatus); } } else { MCONTACT hContact = FindContact(skypename); if (hContact != NULL) SetContactStatus(hContact, SkypeToMirandaStatus(status.c_str())); } } }
//{"firstname":"Echo \/ Sound Test Service", "lastname" : null, "birthday" : null, "gender" : null, "country" : null, "city" : null, "language" : null, "homepage" : null, "about" : null, "province" : null, "jobtitle" : null, "emails" : [], "phoneMobile" : null, "phoneHome" : null, "phoneOffice" : null, "mood" : null, "richMood" : null, "avatarUrl" : null, "username" : "echo123"} void CSkypeProto::LoadProfile(const NETLIBHTTPREQUEST *response) { if (response == NULL) return; JSONNode root = JSONNode::parse(response->pData); if (!root) return; std::string username = root["username"].as_string(); MCONTACT hContact = NULL; if (!IsMe(username.c_str())) hContact = FindContact(username.c_str()); UpdateProfileFirstName(root, hContact); UpdateProfileLastName(root, hContact); UpdateProfileDisplayName(root, hContact); UpdateProfileGender(root, hContact); UpdateProfileBirthday(root, hContact); UpdateProfileCountry(root, hContact); UpdateProfileState(root, hContact); UpdateProfileCity(root, hContact); UpdateProfileLanguage(root, hContact); UpdateProfileHomepage(root, hContact); UpdateProfileAbout(root, hContact); //jobtitle UpdateProfileEmails(root, hContact); UpdateProfilePhoneMobile(root, hContact); UpdateProfilePhoneHome(root, hContact); UpdateProfilePhoneOffice(root, hContact); UpdateProfileStatusMessage(root, hContact); //richMood UpdateProfileAvatar(root, hContact); }
void CMLan::Check() { while(1) { Sleep(MLAN_SLEEP); EnterCriticalSection(&m_csAccessClass); TContact* cont = m_pRootContact; while (cont) { if (cont->m_status != ID_STATUS_OFFLINE) { if (cont->m_time) cont->m_time--; if (cont->m_time==MLAN_TIMEOUT) RequestStatus(true, cont->m_addr.S_un.S_addr); if (!cont->m_time) { cont->m_status = ID_STATUS_OFFLINE; MCONTACT hContact = FindContact(cont->m_addr, cont->m_nick, false, false, false); if (hContact) { db_set_w(hContact,PROTONAME,"Status",ID_STATUS_OFFLINE); } } } cont = cont->m_prev; } LeaveCriticalSection(&m_csAccessClass); } }
HANDLE CDatabase::AddContact(const wchar_t* uri, const wchar_t* nick, bool temporary) const { MTLASSERT(uri); MTLASSERT(0 == FindContact(uri)); HANDLE hContact = reinterpret_cast<HANDLE>(CallService(MS_DB_CONTACT_ADD, 0, 0)); if(hContact) { if(S_OK == CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)g_env.ProtocolName())) { DBWriteContactSettingWString(hContact, g_env.ProtocolName(), "uri", uri); DBWriteContactSettingWString(hContact, g_env.ProtocolName(), "Nick", nick && nick[0] ? nick : ComposeNickByUri(uri)); if(temporary) { DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1); } } else { CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); MTLASSERT(false); hContact = 0; } } MTLASSERT(hContact); return hContact; }
MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary) { MCONTACT hContact = FindContact(skypename); if (!hContact) { hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); Proto_AddToContact(hContact, m_szModuleName); setString(hContact, SKYPE_SETTINGS_ID, skypename); DBVARIANT dbv; if (!getTString(SKYPE_SETTINGS_GROUP, &dbv)) { db_set_ts(hContact, "CList", "Group", dbv.ptszVal); db_free(&dbv); } setByte(hContact, "Auth", 1); setByte(hContact, "Grant", 1); if (isTemporary) db_set_b(hContact, "CList", "NotOnList", 1); } return hContact; }
// adds a new group if it doesn't exist yet; returns its hItem HTREEITEM CCList::AddGroup(TCString GroupName) { if (GroupName == L"") return TVI_ROOT; MGROUP hGroupId = Clist_GroupExists(GroupName); if (hGroupId == NULL) return nullptr; MCONTACT hContact = UINT_PTR(hGroupId) - 1 + HCONTACT_ISGROUP; HTREEITEM hGroupItem = FindContact(hContact); if (hGroupItem) return hGroupItem; // exists already, just return its handle TVINSERTSTRUCT tvIns = {}; tvIns.hParent = TVI_ROOT; tvIns.item.pszText = wcsrchr(GroupName, '\\'); if (tvIns.item.pszText) { TCString ParentGroupName(L""); tvIns.hParent = AddGroup(ParentGroupName.DiffCat(GroupName, tvIns.item.pszText)); tvIns.item.pszText++; } else tvIns.item.pszText = GroupName; tvIns.hInsertAfter = TVI_ROOT; tvIns.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvIns.item.state = tvIns.item.stateMask = TVIS_BOLD | TVIS_EXPANDED; tvIns.item.iImage = tvIns.item.iSelectedImage = IMAGE_GROUPOPEN; tvIns.item.lParam = Items.AddElem(CCLItemData(hContact)); return TreeView_InsertItem(hTreeView, &tvIns); }
IDispatchPtr COutlookButton::FindContact(MAPIFolderPtr pFolder, _bstr_t query) { _ItemsPtr pItems; _ContactItemPtr pContact; _FoldersPtr folders; if (pFolder->GetDefaultItemType()==olContactItem) { pItems=pFolder->GetItems(); if (pItems) { pContact = pItems->Find(query); if (pContact) { return pContact; } } } folders = pFolder->GetFolders(); pFolder = folders->GetFirst(); while (pFolder!=NULL) { pContact = FindContact(pFolder, query); if (pContact) return pContact; pFolder = folders->GetNext(); } return NULL; }
void CSteamProto::OnGotHistoryMessages(const HttpResponse *response, void *arg) { MCONTACT hContact = FindContact((char*)arg); if (!hContact) return; if (!ResponseHttpOk(response)) return; JSONROOT root(response->pData); if (root == NULL) return; JSONNode *node = json_get(root, "response"); JSONNode *messages = json_get(node, "messages"); JSONNode *nmessages = json_as_array(messages); // Self SteamID ptrA steamId(getStringA("SteamID")); for (size_t i = json_size(nmessages); i > 0; i--) { JSONNode *message = json_at(nmessages, i - 1); node = json_get(message, "accountid"); const char *authorSteamId = AccountIdToSteamId(_ttoi64(ptrT(json_as_string(node)))); node = json_get(message, "message"); ptrT text(json_as_string(node)); T2Utf szMessage(text); node = json_get(message, "timestamp"); time_t timestamp = _ttoi64(ptrT(json_as_string(node))); // Ignore already existing messages if (timestamp <= m_lastMessageTS) continue; PROTORECVEVENT recv = { 0 }; recv.timestamp = timestamp; recv.szMessage = szMessage; if (strcmp(steamId, authorSteamId)) { // Received message ProtoChainRecvMsg(hContact, &recv); } else { // Sent message recv.flags = PREF_SENT; Proto_RecvMessage(hContact, &recv); } } json_delete(nmessages); }
/* * request for info replies come here. We request info from the UI if * the user wants info or if we need to know the AUTH flag so we can * decide wether to ask for authorization */ static void HandleInfoReply( int flag, int type, char *data) { static USER_INFO user; CONTACT_INFO *contact; int len = 0,i; inforeplymaskbyte |= type; if (flag == SUCCESS) { inforeplysuccessbyte |= type; if (type == UI_BASIC) { /* load basic info */ FillUserInfo(&user,data); contact = FindContact(Chars_2_DW(data)); if (contact && (contact->flags & FL_WAITING_FOR_ACK)) { /* if we get here we are going to try to add him to our contact * list. */ strcpy(contact->nick,user.nick); if (!user.auth) { /* Don't need auth, just notify him and do it */ contact->flags &= ~(FL_WAITING_FOR_ACK | FL_NOT_IN_LIST); icq_Notify_Added(contact->ci.uin); icq_callback(IM_NOTIFYADDED,0,contact,0,0); snd_contact_list(); } else { /* Need auth, go ask for it. */ icq_Ask_For_Authorize(contact->ci.uin,""); icq_callback(IM_ASKFORAUTH,0,contact,0,0); } inforeplymaskbyte = 0; return; } } else if (type == UI_EXTENDED) { /* load extended info */ len = 4 + GetString(user.city,data+4,20); user.country = Chars_2_Word(&data[len]); len += 2; user.timezone = data[len]; len ++; len += GetString(user.state,data+len,6); user.age = Chars_2_Word(&data[len]); len += 2; user.sex = data[len++]; len += GetString(user.phone,data+len,20); len += GetString(user.homepage,data+len,80); len += GetString(user.about,data+len,400); } } else user.uin = Chars_2_DW(data); if (inforeplymaskbyte == (UI_BASIC | UI_EXTENDED)) icq_callback(IM_INFORESPONSE,inforeplysuccessbyte,0,&user,0); }
HANDLE CDatabase::FindOrAddContact(const wchar_t* uri, const wchar_t* nick, bool temporary) const { MTLASSERT(uri); HANDLE hContact = FindContact(uri); if(!hContact) hContact = AddContact(uri, nick, temporary); MTLASSERT(hContact); return hContact; }
//************************************************************************ // returns the contact's status //************************************************************************ int CContactList::GetContactStatus(MCONTACT hContact) { CListEntry<CContactListEntry *,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry) return ID_STATUS_OFFLINE; CContactListEntry *pEntry = GetContactData(pContactEntry); if(!pEntry) { return ID_STATUS_OFFLINE; } return pEntry->iStatus; }
//************************************************************************ // called when a contacts hidden flag has changed //************************************************************************ void CContactList::OnContactHiddenChanged(MCONTACT hContact, bool bHidden) { CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry && !bHidden) { AddContact(hContact); return; } else if(!pContactEntry) return; if(!IsVisible(GetContactData(pContactEntry))) RemoveContact(hContact); }
void CDatabase::SetContactStatus(const wchar_t* uri, int status) const { HANDLE hContact = FindContact(uri); if(hContact) { const char* protocol = reinterpret_cast<const char*>(CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); if(protocol && !lstrcmpA(protocol, g_env.ProtocolName())) { DBWriteContactSettingWord(hContact, g_env.ProtocolName(), "Status", status); } else MTLASSERT(!"Not RTC contact"); } }
//************************************************************************ // called when the contacts message count has changed //************************************************************************ void CContactList::OnMessageCountChanged(MCONTACT hContact) { CListEntry<CContactListEntry *,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry) { AddContact(hContact); return; } UpdateMessageCounter(pContactEntry); if(!IsVisible(GetContactData(pContactEntry))) RemoveContact(hContact); ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent())->sort(CContactList::CompareEntries); }
//************************************************************************ // called when a contacts status has changed //************************************************************************ void CContactList::OnStatusChange(MCONTACT hContact,int iStatus) { // find the entry in the list CListEntry<CContactListEntry *,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry) { AddContact(hContact); return; } CContactListEntry *pItemData = GetContactData(pContactEntry); if(!pItemData) { return; } // get the old status int iOldStatus = pItemData->iStatus; // Update the list entry TCHAR *szStatus = pcli->pfnGetStatusModeDescription(iStatus, 0); if(szStatus != NULL) pItemData->strStatus =toTstring(szStatus); pItemData->iStatus = iStatus; // update the contacts group CListContainer<CContactListEntry*,CContactListGroup*>* pGroup = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent()); if(pGroup->GetType() != ROOT) { if(!db_mc_isSub(hContact) && iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1); else if(!db_mc_isSub(hContact) && iStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1); } // check if the entry is still visible if(!IsVisible(pItemData)) { RemoveContact(hContact); return; } // sort the list pGroup->sort(CContactList::CompareEntries); }
//************************************************************************ // called when a contacts status has changed //************************************************************************ void CContactList::OnStatusChange(HANDLE hContact,int iStatus) { // find the entry in the list CListEntry<CContactListEntry *,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry) { AddContact(hContact); return; } CContactListEntry *pItemData = GetContactData(pContactEntry); if(!pItemData) { return; } // get the old status int iOldStatus = pItemData->iStatus; // Update the list entry char *szStatus = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iStatus, 0); if(szStatus != NULL) pItemData->strStatus =toTstring(szStatus); pItemData->iStatus = iStatus; // update the contacts group CListContainer<CContactListEntry*,CContactListGroup*>* pGroup = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent()); if(pGroup->GetType() != ROOT) { if(!CAppletManager::IsSubContact(hContact) && iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1); else if(!CAppletManager::IsSubContact(hContact) && iStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1); } // check if the entry is still visible if(!IsVisible(pItemData)) { RemoveContact(hContact); return; } // sort the list pGroup->sort(CContactList::CompareEntries); }
// adds a new contact if it doesn't exist yet; returns its hItem HTREEITEM CCList::AddContact(MCONTACT hContact) { _ASSERT(IsHContactContact(hContact)); HTREEITEM hContactItem = FindContact(hContact); if (hContactItem) return hContactItem; TVINSERTSTRUCT tvIns; memset(&tvIns, 0, sizeof(tvIns)); tvIns.hParent = AddGroup(db_get_s(hContact, "CList", "Group", L"")); tvIns.item.pszText = Clist_GetContactDisplayName(hContact); tvIns.hInsertAfter = TVI_ROOT; tvIns.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvIns.item.iImage = tvIns.item.iSelectedImage = Clist_GetContactIcon(hContact); tvIns.item.lParam = Items.AddElem(CCLItemData(hContact)); return TreeView_InsertItem(hTreeView, &tvIns); }
void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response) { if (response == NULL || response->pData == NULL) return; JSONNode root = JSONNode::parse(response->pData); if (!root) return; const JSONNode &metadata = root["_metadata"]; const JSONNode &conversations = root["conversations"].as_array(); int totalCount = metadata["totalCount"].as_int(); std::string syncState = metadata["syncState"].as_string(); if (totalCount >= 99 || conversations.size() >= 99) PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), li), &CSkypeProto::OnSyncHistory); for (size_t i = 0; i < conversations.size(); i++) { const JSONNode &conversation = conversations.at(i); const JSONNode &lastMessage = conversation["lastMessage"]; if (lastMessage) { std::string strConversationLink = lastMessage["conversationLink"].as_string(); if (strConversationLink.find("/8:") != -1) { CMStringA szSkypename = UrlToSkypename(strConversationLink.c_str()); time_t composeTime(IsoToUnixTime(lastMessage["composetime"].as_string().c_str())); MCONTACT hContact = FindContact(szSkypename); if (hContact != NULL) { if (db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) < composeTime) { PushRequest(new GetHistoryRequest(szSkypename, 100, false, 0, li), &CSkypeProto::OnGetServerHistory); } } } } } m_bHistorySynced = true; }
/* get here if a server has sent a time-stamped text message * (CMD 220) */ static void Recv_Message( BYTE * pak ) { RECV_MESSAGE_PTR r_mesg; CONTACT_INFO *contact; DWORD uin; struct tm tms; time_t thetime; /* gather the time */ r_mesg = ( RECV_MESSAGE_PTR )pak; tms.tm_sec = 0; tms.tm_min = r_mesg->minute; tms.tm_hour = r_mesg->hour; tms.tm_mday = r_mesg->day-1; tms.tm_mon = r_mesg->month-1; tms.tm_year = Chars_2_Word(r_mesg->year)-1900; thetime = mktime(&tms); thetime += our_user.timezone * 3600*2; uin = Chars_2_DW( r_mesg->uin ); /* process the message */ Do_Msg(Chars_2_Word( r_mesg->type ), Chars_2_Word( r_mesg->len ), ( r_mesg->len + 2 ), uin, 1, thetime ); /* register the user if he is not in our list */ contact = FindContact(uin); if (!contact) { contact = FindEmptyContact(); if (!contact) return; contact->flags = FL_RECEIVED_FROM | FL_NOT_IN_LIST; contact->ci.uin = uin; contact->ci.status = STATUS_OFFLINE; contact->last_time = MINUSONE; contact->ci.ip[0] = 0xff; contact->ci.ip[1] = 0xff; contact->ci.ip[2] = 0xff; contact->ci.ip[3] = 0xff; contact->ci.port = 0; snd_contact_list(); } else contact->flags |= FL_RECEIVED_FROM; }
int UCMeetingProxy::UnMute(const UCSDKContact& member, const std::string& convId) { DEBUG_LOG() << "--- ENTER"; INFO_PARAM2(member.uri_, convId); //获取AVsession uc::model::conversation::AVSession* pAVSession = GetAVSession(convId); if (NULL == pAVSession) { ERROR_LOG() << "Get av session failed."; DEBUG_LOG() << "--- LEAVE"; return UCSDK_Fail; } //查找联系人 Contact contact; int iRet = FindContact(contact, member); if (UCSDK_Succ != iRet) { ERROR_LOG() << "Find contact failed."; DEBUG_LOG() << "--- LEAVE"; return iRet; } uc::model::conversation::Participant part_; CopyContactToContact(contact, part_.contact_); std::vector<uc::model::conversation::Participant> partlist_; partlist_.push_back(part_); //静音 if (!pAVSession->UnMute(partlist_)) { ERROR_LOG() << "UnMute failed."; DEBUG_LOG() << "--- LEAVE"; return UCSDK_Fail; } DEBUG_LOG() << "--- LEAVE"; return UCSDK_Succ; }
//************************************************************************ // called when a contacts nickname has changed //************************************************************************ void CContactList::OnContactNickChanged(MCONTACT hContact, tstring strNick) { CListEntry<CContactListEntry *,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry) return; if(pContactEntry->GetType() == CONTAINER) { CListContainer *pGroup = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry); pGroup->GetGroupData()->strName = strNick; tstring strPath = GetContactGroupPath(hContact); pGroup->GetGroupData()->strPath = strPath + (strPath.empty()?_T(""):_T("\\")) + strNick; } CContactListEntry* pEntry = GetContactData(pContactEntry); if(!pEntry) { return; } pEntry->strName = strNick; ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent())->sort(CContactList::CompareEntries); }
// adds a new group if it doesn't exist yet; returns its hItem HTREEITEM CCList::AddGroup(TCString GroupName) { if (GroupName == _T("")) return TVI_ROOT; sGroupEnumData GroupEnumData; GroupEnumData.GroupName = GroupName; GroupEnumData.hGroup = NULL; DBCONTACTENUMSETTINGS dbEnum; memset(&dbEnum, 0, sizeof(dbEnum)); dbEnum.lParam = (LPARAM)&GroupEnumData; dbEnum.pfnEnumProc = GroupEnum; dbEnum.szModule = "CListGroups"; CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum); if (!GroupEnumData.hGroup) // means there is no such group in the groups list return NULL; HTREEITEM hGroupItem = FindContact((UINT_PTR)GroupEnumData.hGroup); if (hGroupItem) return hGroupItem; // exists already, just return its handle TVINSERTSTRUCT tvIns = { 0 }; tvIns.hParent = TVI_ROOT; tvIns.item.pszText = _tcsrchr(GroupName, '\\'); if (tvIns.item.pszText) { TCString ParentGroupName(_T("")); tvIns.hParent = AddGroup(ParentGroupName.DiffCat(GroupName, tvIns.item.pszText)); tvIns.item.pszText++; } else tvIns.item.pszText = GroupName; tvIns.hInsertAfter = TVI_ROOT; tvIns.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvIns.item.state = tvIns.item.stateMask = TVIS_BOLD | TVIS_EXPANDED; tvIns.item.iImage = tvIns.item.iSelectedImage = IMAGE_GROUPOPEN; tvIns.item.lParam = Items.AddElem(CCLItemData((UINT_PTR)GroupEnumData.hGroup)); return TreeView_InsertItem(hTreeView, &tvIns); }
//************************************************************************ // refreshes the list //************************************************************************ void CContactList::RefreshList() { if((db_get_b(NULL,"MetaContacts","Enabled",1) != 0) != m_bUseMetaContacts || CConfig::GetBoolSetting(CLIST_USEGROUPS) != m_bUseGroups) { InitializeGroupObjects(); Clear(); } m_bUseGroups = CConfig::GetBoolSetting(CLIST_USEGROUPS); m_bUseMetaContacts = db_get_b(NULL,"MetaContacts","Enabled",1) != 0; CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry = NULL; MCONTACT hContact = db_find_first(); while(hContact != NULL) { pContactEntry = FindContact(hContact); if(!pContactEntry) AddContact(hContact); else if(pContactEntry && !IsVisible(GetContactData(pContactEntry))) RemoveContact(hContact); hContact = db_find_next(hContact); } }
IDispatchPtr COutlookButton::FindContact(_bstr_t query) { std::vector<MAPIFolderPtr> loaded_folders; _ContactItemPtr pContact = NULL; try { _FoldersPtr folders = m_OLAppPtr->GetNamespace(_bstr_t("MAPI"))->GetFolders(); MAPIFolderPtr pFolder = folders->GetFirst(); //Personal folders (root folder) bool bFound; while (pFolder!=NULL) { bFound = false; for (int i=0; i<loaded_folders.size(); i++) { if (loaded_folders[i]==pFolder) { bFound=true; break; } } if (bFound) { pFolder = folders->GetNext(); } else { pContact = FindContact(pFolder, query); if (pContact) return pContact; pFolder = folders->GetNext(); loaded_folders.push_back(pFolder); } } } catch(_com_error &e) { MessageBox(NULL, (char *)e.Description(), APP_NAME, MB_ICONERROR); } return pContact; }
void CNetwork::UpdateQunContacts(HWND hwndDlg, unsigned int qunid) { if (Qun* qun=m_qunList.getQun(qunid)) { std::list<FriendItem> list=qun->getMembers(); HANDLE hContact=FindContact(qunid); unsigned int creator=READC_D2("Creator"); DBVARIANT dbv; TCHAR* pszNick; TCHAR szTemp[MAX_PATH]; char szID[16]; HWND hControl=GetDlgItem(hwndDlg,IDC_QUNINFO_MEMBERLIST); SendMessage(hControl,LB_RESETCONTENT,(WPARAM)NULL,(LPARAM)NULL); for (std::list<FriendItem>::iterator iter=list.begin(); iter!=list.end(); ++iter) { ultoa(iter->getQQ(),szID,10); if (READC_S2(szID,&dbv)) { // Nick not found swprintf(szTemp,L" [%s] %u",iter->isOnline()?TranslateT("Online"):TranslateT("Offline"),iter->getQQ()); } else { // Nick found pszNick=mir_a2u_cp(dbv.pszVal,936); swprintf(szTemp,L" [%s] %s(%u)",iter->isOnline()?TranslateT("Online"):TranslateT("Offline"),pszNick,iter->getQQ()); mir_free(pszNick); DBFreeVariant(&dbv); } if (creator==iter->getQQ()) *szTemp=_T('*'); else if (qun->isAdmin(iter->getQQ())) *szTemp=_T('+'); SendMessage(hControl,LB_ADDSTRING,(WPARAM)NULL,(LPARAM)szTemp); } } }
void CSkypeProto::ProcessEndpointPresence(const JSONNode &node) { debugLogA("CSkypeProto::ProcessEndpointPresenceRes"); std::string selfLink = node["selfLink"].as_string(); CMStringA skypename(UrlToSkypename(selfLink.c_str())); MCONTACT hContact = FindContact(skypename); if (hContact == NULL) return; const JSONNode &publicInfo = node["publicInfo"]; const JSONNode &privateInfo = node["privateInfo"]; CMStringA MirVer; if (publicInfo) { std::string skypeNameVersion = publicInfo["skypeNameVersion"].as_string(); std::string version = publicInfo["version"].as_string(); std::string typ = publicInfo["typ"].as_string(); int iTyp = atoi(typ.c_str()); switch (iTyp) { case 0: case 1: MirVer.AppendFormat("Skype (Web) %s", ParseUrl(version.c_str(), "/")); break; case 10: MirVer.AppendFormat("Skype (XBOX) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 17: MirVer.AppendFormat("Skype (Android) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 16: MirVer.AppendFormat("Skype (iOS) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 12: MirVer.AppendFormat("Skype (WinRT) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 15: MirVer.AppendFormat("Skype (WP) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 13: MirVer.AppendFormat("Skype (OSX) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 11: MirVer.AppendFormat("Skype (Windows) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 14: MirVer.AppendFormat("Skype (Linux) %s", ParseUrl(skypeNameVersion.c_str(), "/")); break; case 125: MirVer.AppendFormat("Miranda NG Skype %s", version.c_str()); break; default: MirVer.Append("Skype (Unknown)"); } } if (privateInfo != NULL) { std::string epname = privateInfo["epname"].as_string(); if (!epname.empty()) { MirVer.AppendFormat(" [%s]", epname.c_str()); } } db_set_s(hContact, m_szModuleName, "MirVer", MirVer); }
void CSteamProto::ParsePollData(JSONNode *data) { JSONNode *node, *item = NULL; std::string steamIds; for (size_t i = 0; i < json_size(data); i++) { item = json_at(data, i); if (item == NULL) break; node = json_get(item, "steamid_from"); ptrA steamId(mir_t2a(ptrT(json_as_string(node)))); node = json_get(item, "utc_timestamp"); time_t timestamp = atol(ptrA(mir_t2a(ptrT(json_as_string(node))))); node = json_get(item, "type"); ptrT type(json_as_string(node)); if (!lstrcmpi(type, _T("saytext")) || !lstrcmpi(type, _T("emote")) || !lstrcmpi(type, _T("my_saytext")) || !lstrcmpi(type, _T("my_emote"))) { MCONTACT hContact = FindContact(steamId); if (!hContact) continue; node = json_get(item, "text"); ptrT text(json_as_string(node)); T2Utf szMessage(text); if (_tcsstr(type, _T("my_")) == NULL) { PROTORECVEVENT recv = { 0 }; recv.timestamp = timestamp; recv.szMessage = szMessage; ProtoChainRecvMsg(hContact, &recv); } else { AddDBEvent(hContact, EVENTTYPE_MESSAGE, timestamp, DBEF_UTF | DBEF_SENT, (int)mir_strlen(szMessage) + 1, (PBYTE)(char*)szMessage); } } else if (!lstrcmpi(type, _T("typing"))) { MCONTACT hContact = FindContact(steamId); if (hContact) { CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)STEAM_TYPING_TIME); } } else if (!lstrcmpi(type, _T("personastate"))) { node = json_get(item, "persona_state"); int status = node ? SteamToMirandaStatus(json_as_int(node)) : -1; if (IsMe(steamId)) { node = json_get(item, "persona_name"); setTString("Nick", ptrT(json_as_string(node))); if (status == -1 || status == ID_STATUS_OFFLINE) continue; if (status != m_iStatus) { debugLog(_T("CSteamProto::ParsePollData: Change own status to %i"), status); int oldStatus = m_iStatus; m_iStatus = m_iDesiredStatus = status; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); } continue; } MCONTACT hContact = FindContact(steamId); if (hContact == NULL) continue; // probably this is info about random player playing on same server, so we ignore it if (status != -1) SetContactStatus(hContact, status); node = json_get(item, "persona_name"); setTString(hContact, "Nick", ptrT(json_as_string(node))); // todo: find difference between state changing and info changing steamIds.append(steamId).append(","); } else if (!lstrcmpi(type, _T("personarelationship"))) { node = json_get(item, "persona_state"); int state = json_as_int(node); switch (state) { case 0: {// removed MCONTACT hContact = FindContact(steamId); if (hContact) { ContactIsRemoved(hContact); } } break; case 1: {// ignored MCONTACT hContact = FindContact(steamId); if (hContact) { ContactIsIgnored(hContact); } } break; case 2: {// auth request /*MCONTACT hContact = FindContact(steamId); if (!hContact) hContact = AddContact(steamId, true);*/ //RaiseAuthRequestThread((void*)hContact); ptrA token(getStringA("TokenSecret")); PushRequest( new GetUserSummariesRequest(token, steamId), &CSteamProto::OnAuthRequested, mir_strdup(steamId), MirFreeArg); } break; case 3: // add to list // todo break; default: continue; } } /*else if (!lstrcmpi(type, _T("leftconversation"))) { }*/ else { continue; } } if (!steamIds.empty()) { steamIds.pop_back(); ptrA token(getStringA("TokenSecret")); PushRequest( new GetUserSummariesRequest(token, steamIds.c_str()), &CSteamProto::OnGotUserSummaries); } }