INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM) { if (!hContact) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) ptrT roomID(getTStringA(hContact, "ChatRoomID")); if (roomID == NULL) return 0; if (ListGetItemPtr(LIST_ROSTER, roomID) == NULL) { ptrT group(db_get_tsa(hContact, "CList", "Group")); ptrT nick(getTStringA(hContact, "Nick")); AddContactToRoster(roomID, nick, group); if (m_options.AddRoster2Bookmarks == TRUE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID); if (item == NULL) { item = new JABBER_LIST_ITEM(); item->jid = mir_tstrdup(roomID); item->name = mir_tstrdup(nick); item->nick = getTStringA(hContact, "MyNick"); AddEditBookmark(item); delete item; } } } return 0; }
void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, HANDLE hContact) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrT(getTStringA(hContact, "jid"))); if (item == NULL) return; ptrT tszNick(db_get_tsa(hContact, "CList", "MyHandle")); if (tszNick == NULL) tszNick = getTStringA(hContact, "Nick"); if (tszNick == NULL) tszNick = JabberNickFromJID(item->jid); if (tszNick == NULL) return; if (cws->value.type == DBVT_DELETED) { if (item->group != NULL) { debugLogA("Group set to nothing"); AddContactToRoster(item->jid, tszNick, NULL); } } else { TCHAR *p = sttSettingToTchar(cws); if (cws->value.pszVal != NULL && lstrcmp(p, item->group)) { debugLogA("Group set to %S", p); if (p) AddContactToRoster(item->jid, tszNick, p); } mir_free(p); } }
void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING *cws, HANDLE hContact) { if (cws->value.type != DBVT_DELETED && !(cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) return; ptrT jid(getTStringA(hContact, "jid")); if (jid == NULL) return; debugLogA("Add %S permanently to list", jid); ptrT nick(db_get_tsa(hContact, "CList", "MyHandle")); if (nick == NULL) nick = getTStringA(hContact, "Nick"); if (nick == NULL) nick = JabberNickFromJID(jid); if (nick == NULL) return; AddContactToRoster(jid, nick, ptrT(db_get_tsa(hContact, "CList", "Group"))); XmlNode xPresence(_T("presence")); xPresence << XATTR(_T("to"), LPCTSTR(jid)) << XATTR(_T("type"), _T("subscribe")); ptrT myNick(getTStringA(NULL, "Nick")); if (myNick != NULL) xPresence << XCHILD(_T("nick"), LPCTSTR(myNick)) << XATTR(_T("xmlns"), JABBER_FEAT_NICK); m_ThreadInfo->send(xPresence); SendGetVcard(jid); db_unset(hContact, "CList", "Hidden"); }
void CJabberProto::ResolveTransportNicks(const TCHAR *jid) { // Set all contacts to offline MCONTACT hContact = m_ThreadInfo->resolveContact; if (hContact == NULL) hContact = db_find_first(m_szModuleName); for (; hContact != NULL; hContact = db_find_next(hContact, m_szModuleName)) { if (!getByte(hContact, "IsTransported", 0)) continue; ptrT dbJid( getTStringA(hContact, "jid")); if (dbJid == NULL) continue; ptrT dbNick( getTStringA(hContact, "Nick")); if (dbNick == NULL) continue; TCHAR *p = _tcschr(dbJid, '@'); if (p == NULL) continue; *p = 0; if (!lstrcmp(jid, p+1) && !lstrcmp(dbJid, dbNick)) { *p = '@'; m_ThreadInfo->resolveID = SendGetVcard(dbJid); m_ThreadInfo->resolveContact = hContact; return; } } m_ThreadInfo->resolveID = -1; m_ThreadInfo->resolveContact = NULL; }
void CJabberProto::SearchDeleteFromRecent(const TCHAR *szAddr, BOOL deleteLastFromDB) { //search in recent for (int i=0; i<10; i++) { char key[30]; mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", i); ptrT szValue( getTStringA(key)); if (szValue == NULL || _tcsicmp(szAddr, szValue)) continue; for (int j=i; j < 10; j++) { mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j + 1); szValue = getTStringA(key); if (szValue != NULL) { mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j); setTString(NULL, key, szValue); } else { if (deleteLastFromDB) { mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j); delSetting(NULL,key); } break; } } break; } }
INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM hContact, LPARAM, LPARAM res) { if (!m_bJabberOnline || !hContact) return 0; TCHAR *jid, text[1024]; ptrT tszJid(getTStringA(hContact, "jid")); if (tszJid == NULL) { ptrT roomid(getTStringA(hContact, "ChatRoomID")); if (roomid == NULL) return 0; JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, roomid); if (item == NULL) return 0; mir_sntprintf(text, _T("%s/%s"), item->jid, item->nick); jid = text; } else jid = tszJid; CMString szValue; if (EnterString(szValue, TranslateT("Status Message"), ESF_MULTILINE)) SendPresenceTo(res, jid, NULL, szValue); return 0; }
MCONTACT CIrcProto::CList_FindContact(CONTACT *user) { if (!user || !user->name) return 0; TCHAR* lowercasename = mir_tstrdup(user->name); CharLower(lowercasename); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (isChatRoom(hContact)) continue; MCONTACT hContact_temp = NULL; ptrT DBNick(getTStringA(hContact, "Nick")); ptrT DBUser(getTStringA(hContact, "UUser")); ptrT DBHost(getTStringA(hContact, "UHost")); ptrT DBDefault(getTStringA(hContact, "Default")); ptrT DBWildcard(getTStringA(hContact, "UWildcard")); if (DBWildcard) CharLower(DBWildcard); if (IsChannel(user->name)) { if (DBDefault && !lstrcmpi(DBDefault, user->name)) hContact_temp = (MCONTACT)-1; } else if (user->ExactNick && DBNick && !lstrcmpi(DBNick, user->name)) hContact_temp = hContact; else if (user->ExactOnly && DBDefault && !lstrcmpi(DBDefault, user->name)) hContact_temp = hContact; else if (user->ExactWCOnly) { if (DBWildcard && !lstrcmpi(DBWildcard, lowercasename) || (DBWildcard && !lstrcmpi(DBNick, lowercasename) && !WCCmp(DBWildcard, lowercasename)) || (!DBWildcard && !lstrcmpi(DBNick, lowercasename))) { hContact_temp = hContact; } } else if (_tcschr(user->name, ' ') == 0) { if ((DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) || DBWildcard && WCCmp(DBWildcard, lowercasename)) && (WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host))) { hContact_temp = hContact; } } if (hContact_temp != NULL) { mir_free(lowercasename); if (hContact_temp != (MCONTACT)-1) return hContact_temp; return 0; } } mir_free(lowercasename); return 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; }
INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM hContact, LPARAM, LPARAM res) { if (!m_bJabberOnline || !hContact) return 0; ptrT tszJid(getTStringA(hContact, "jid")); if (tszJid == NULL) return 0; JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, tszJid); if (LI == NULL) return 0; if (res == MENUITEM_LASTSEEN) { LI->m_pManualResource = NULL; LI->resourceMode = RSMODE_LASTSEEN; } else if (res == MENUITEM_SERVER) { LI->m_pManualResource = NULL; LI->resourceMode = RSMODE_SERVER; } else if (res >= MENUITEM_RESOURCES) { LI->m_pManualResource = LI->arResources[res - MENUITEM_RESOURCES]; LI->resourceMode = RSMODE_MANUAL; } UpdateMirVer(LI); MenuUpdateSrmmIcon(LI); return 0; }
void FacebookProto::OpenUrl(std::string url) { std::string::size_type pos = url.find(FACEBOOK_SERVER_DOMAIN); bool isFacebookUrl = (pos != std::string::npos); bool isRelativeUrl = (url.substr(0, 4) != "http"); if (isFacebookUrl || isRelativeUrl) { // Make realtive url if (!isRelativeUrl) { url = url.substr(pos + strlen(FACEBOOK_SERVER_DOMAIN)); // Strip eventual port pos = url.find("/"); if (pos != std::string::npos && pos != 0) url = url.substr(pos); } // Make absolute url bool useHttps = getByte(FACEBOOK_KEY_FORCE_HTTPS, 1) > 0; url = (useHttps ? HTTP_PROTO_SECURE : HTTP_PROTO_REGULAR) + facy.get_server_type() + url; } ptrT data( mir_utf8decodeT(url.c_str())); // Check if there is user defined browser for opening links ptrT browser(getTStringA(FACEBOOK_KEY_OPEN_URL_BROWSER)); if (browser != NULL) // If so, use it to open this link ForkThread(&FacebookProto::OpenUrlThread, new open_url(browser, data)); else // Or use Miranda's service CallService(MS_UTILS_OPENURL, (WPARAM)OUF_TCHAR, (LPARAM)data); }
/** * Sets statusbar text of hContact with last read time (from facy.readers map) */ void FacebookProto::MessageRead(MCONTACT hContact) { /*std::map<MCONTACT, time_t>::iterator it = facy.readers.find(hContact); if (it == facy.readers.end()) return;*/ // We may use this instead of checing map as we have this info already in memory (this value is resident) time_t time = getDword(hContact, FACEBOOK_KEY_MESSAGE_READ, 0); if (!time) return; TCHAR ttime[64]; _tcsftime(ttime, _countof(ttime), _T("%X"), localtime(&time)); StatusTextData st = { 0 }; st.cbSize = sizeof(st); st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("read")); if (isChatRoom(hContact)) { // Load readers names ptrT treaders(getTStringA(hContact, FACEBOOK_KEY_MESSAGE_READERS)); mir_sntprintf(st.tszText, TranslateT("Message read: %s by %s"), ttime, treaders ? treaders : _T("???")); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st); } else if (!ServiceExists(MS_MESSAGESTATE_UPDATE)){ mir_sntprintf(st.tszText, TranslateT("Message read: %s"), ttime); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st); } }
void WhatsAppProto::onGroupNewSubject(const std::string &gjid, const std::string &author, const std::string &newSubject, int ts) { WAChatInfo *pInfo = SafeGetChat(gjid); if (pInfo == NULL) return; ptrT tszText(str2t(newSubject)); ptrT tszTextDb(getTStringA(pInfo->hContact, WHATSAPP_KEY_NICK)); if (!mir_tstrcmp(tszText, tszTextDb)) // notify about subject change only if differs from the stored one return; ptrT tszUID(str2t(author)); ptrT tszNick(GetChatUserNick(author)); GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_TOPIC }; GCEVENT gce = { sizeof(gce), &gcd }; gce.dwFlags = GCEF_ADDTOLOG + ((ts == 0) ? GCEF_NOTNOTIFY : 0); gce.ptszUID = tszUID; gce.ptszNick = tszNick; gce.time = ts; gce.ptszText = tszText; CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); setTString(pInfo->hContact, WHATSAPP_KEY_NICK, tszText); }
INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam, LPARAM) { ptrT idT(wParam ? getTStringA(wParam, "ChatRoomID") : NULL); GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL }; gcd.ptszID = idT; GCEVENT gce = { sizeof(gce), &gcd }; gce.time = ::time(NULL); CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce)); CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, reinterpret_cast<LPARAM>(&gce)); if (!wParam) { facy.clear_chatrooms(); } else if (!IsSpecialChatRoom(wParam)) { ptrA threadId(getStringA(wParam, FACEBOOK_KEY_TID)); if (!threadId) return 0; auto it = facy.chat_rooms.find(std::string(threadId)); if (it != facy.chat_rooms.end()) { delete it->second; facy.chat_rooms.erase(it); } } return 0; }
INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam) { if (!isOnline()) return 1; MCONTACT hContact = MCONTACT(wParam); wall_data *wall = new wall_data(); wall->user_id = ptrA(getStringA(hContact, FACEBOOK_KEY_ID)); wall->isPage = false; if (wall->user_id == facy.self_.user_id) { wall->title = _tcsdup(TranslateT("Own wall")); } else wall->title = getTStringA(hContact, FACEBOOK_KEY_NICK); post_status_data *data = new post_status_data(this, wall); if (wall->user_id == facy.self_.user_id) { for (std::map<std::string, std::string>::iterator iter = facy.pages.begin(); iter != facy.pages.end(); ++iter) { data->walls.push_back(new wall_data(iter->first, mir_utf8decodeT(iter->second.c_str()), true)); } } HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(data)); ShowWindow(hDlg, SW_SHOW); return 0; }
int CJabberProto::OnContactDeleted(WPARAM wParam, LPARAM) { if (!m_bJabberOnline) // should never happen return 0; HANDLE hContact = (HANDLE)wParam; ptrT jid(getTStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid")); if (jid == NULL) return 0; if (ListGetItemPtr(LIST_ROSTER, jid)) { if (!_tcschr(jid, _T('@'))) { TCHAR szStrippedJid[JABBER_MAX_JID_LEN]; JabberStripJid(m_ThreadInfo->fullJID, szStrippedJid, SIZEOF(szStrippedJid)); TCHAR *szDog = _tcschr(szStrippedJid, _T('@')); if (szDog && _tcsicmp(szDog + 1, jid)) m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), jid) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD(_T("remove"))); } // Remove from roster, server also handles the presence unsubscription process. m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext()) << XQUERY(JABBER_FEAT_IQ_ROSTER) << XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("subscription"), _T("remove"))); } return 0; }
void CJabberProto::CheckAllContactsAreTransported() { for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { ptrT jid( getTStringA(hContact, "jid")); if (jid) DBCheckIsTransportedContact(jid, hContact); } }
INT_PTR FacebookProto::GetMyAwayMsg(WPARAM, LPARAM lParam) { ptrT statusMsg(getTStringA("StatusMsg")); if (statusMsg == NULL || statusMsg[0] == '\0') return 0; return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_t2u(statusMsg) : (INT_PTR)mir_t2a(statusMsg); }
void CJabberProto::AppendVcardFromDB(HXML n, char *tag, char *key) { if (n == NULL || tag == NULL || key == NULL) return; ptrT tszValue(getTStringA(key)); n << XCHILD(_A2T(tag), tszValue); }
void CSteamProto::OnGotRsaKey(const HttpResponse *response) { if (!CheckResponse(response)) return; // load rsa key parts JSONNode root = JSONNode::parse(response->pData); if (!root) return; if (!root["success"].as_bool()) return; std::string modulus = root["publickey_mod"].as_string(); // exponent "010001" is used as constant in CSteamProto::RsaEncrypt //std::string exponent = root["publickey_exp"].as_string(); std::string timestamp = root["timestamp"].as_string(); // encrcrypt password ptrA base64RsaEncryptedPassword; ptrA szPassword(getStringA("Password")); DWORD error = 0; DWORD encryptedSize = 0; if ((error = RsaEncrypt(modulus.c_str(), szPassword, NULL, encryptedSize)) != 0) { debugLogA("CSteamProto::OnGotRsaKey: encryption error (%lu)", error); return; } BYTE *encryptedPassword = (BYTE*)mir_calloc(encryptedSize); if ((error = RsaEncrypt(modulus.c_str(), szPassword, encryptedPassword, encryptedSize)) != 0) { debugLogA("CSteamProto::OnGotRsaKey: encryption error (%lu)", error); return; } base64RsaEncryptedPassword = mir_base64_encode(encryptedPassword, encryptedSize); mir_free(encryptedPassword); // run authorization request T2Utf username(getTStringA("Username")); ptrA guardId(getStringA("GuardId")); if (!guardId) guardId = mir_strdup(""); ptrA guardCode(getStringA("GuardCode")); if (!guardCode) guardCode = mir_strdup(""); ptrA captchaId(getStringA("CaptchaId")); if (!captchaId) captchaId = mir_strdup("-1"); ptrA captchaText(getStringA("CaptchaText")); if (!captchaText) captchaText = mir_strdup(""); PushRequest( new AuthorizationRequest(username, base64RsaEncryptedPassword, timestamp.c_str(), "", guardCode, guardId, captchaId, captchaText), &CSteamProto::OnAuthorization); }
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; }
void CSkypeProto::SetChatStatus(MCONTACT hContact, int iStatus) { ptrT tszChatID(getTStringA(hContact, "ChatRoomID")); if (tszChatID == NULL) return; GCDEST gcd = { m_szModuleName, tszChatID, GC_EVENT_CONTROL }; GCEVENT gce = { sizeof(gce), &gcd }; CallServiceSync(MS_GC_EVENT, (iStatus == ID_STATUS_OFFLINE) ? SESSION_OFFLINE : SESSION_ONLINE, (LPARAM)&gce); }
INT_PTR __cdecl CJabberProto::OnMenuRevokeAuth(WPARAM hContact, LPARAM) { if (hContact != NULL && m_bJabberOnline) { ptrT jid(getTStringA(hContact, "jid")); if (jid != NULL) m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), jid) << XATTR(_T("type"), _T("unsubscribed"))); } return 0; }
INT_PTR __cdecl CJabberProto::OnMenuSendNote(WPARAM wParam, LPARAM) { if (wParam) { CNoteItem *pItem = new CNoteItem(NULL, ptrT(getTStringA(wParam, "jid"))); CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote); pDlg->Show(); } return 0; }
HWND __cdecl CJabberProto::CreateExtendedSearchUI(HWND parent) { if (parent && hInst) { ptrT szServer( getTStringA("LoginServer")); if (szServer == NULL || _tcsicmp(szServer, _T("S.ms"))) return CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this); } return 0; // Failure }
int WhatsAppProto::OnDeleteChat(WPARAM hContact, LPARAM lParam) { if (isChatRoom(hContact) && isOnline()) { ptrT tszID(getTStringA(hContact, WHATSAPP_KEY_ID)); if (tszID) m_pConnection->sendJoinLeaveGroup(_T2A(tszID), false); } return 0; }
INT_PTR __cdecl CJabberProto::OnMenuTransportResolve(WPARAM hContact, LPARAM) { if (!getByte(hContact, "IsTransport", 0)) return 0; ptrT jid(getTStringA(hContact, "jid")); if (jid != NULL) ResolveTransportNicks(jid); return 0; }
INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam) { if (!m_options.EnableAvatars) return GAIR_NOAVATAR; PROTO_AVATAR_INFORMATIONT* AI = (PROTO_AVATAR_INFORMATIONT*)lParam; ptrA szHashValue( getStringA(AI->hContact, "AvatarHash")); if (szHashValue == NULL) { debugLogA("No avatar"); return GAIR_NOAVATAR; } TCHAR tszFileName[MAX_PATH]; GetAvatarFileName(AI->hContact, tszFileName, SIZEOF(tszFileName)); _tcsncpy(AI->filename, tszFileName, SIZEOF(AI->filename)); AI->format = (AI->hContact == NULL) ? PA_FORMAT_PNG : getByte(AI->hContact, "AvatarType", 0); if (::_taccess(AI->filename, 0) == 0) { ptrA szSavedHash( getStringA(AI->hContact, "AvatarSaved")); if (szSavedHash != NULL && !strcmp(szSavedHash, szHashValue)) { debugLogA("Avatar is Ok: %s == %s", szSavedHash, szHashValue); return GAIR_SUCCESS; } } if ((wParam & GAIF_FORCE) != 0 && AI->hContact != NULL && m_bJabberOnline) { ptrT tszJid( getTStringA(AI->hContact, "jid")); if (tszJid != NULL) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, tszJid); if (item != NULL) { BOOL isXVcard = getByte(AI->hContact, "AvatarXVcard", 0); TCHAR szJid[JABBER_MAX_JID_LEN]; szJid[0] = 0; if (item->arResources.getCount() != NULL && !isXVcard) if (TCHAR *bestResName = ListGetBestClientResourceNamePtr(tszJid)) mir_sntprintf(szJid, SIZEOF(szJid), _T("%s/%s"), tszJid, bestResName); if (szJid[0] == 0) _tcsncpy_s(szJid, SIZEOF(szJid), tszJid, _TRUNCATE); debugLogA("Rereading %s for %S", isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid); m_ThreadInfo->send((isXVcard) ? XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP) : XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetClientAvatar, JABBER_IQ_TYPE_GET, szJid)) << XQUERY(JABBER_FEAT_AVATAR)); return GAIR_WAITFOR; } } } debugLogA("No avatar"); return GAIR_NOAVATAR; }
INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd(WPARAM hContact, LPARAM) { if (!hContact) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) ptrT roomID(getTStringA(hContact, "ChatRoomID")); if (roomID == NULL) return 0; if (ListGetItemPtr(LIST_BOOKMARK, roomID) == NULL) { JABBER_LIST_ITEM *item = new JABBER_LIST_ITEM(); item->jid = mir_tstrdup(roomID); item->name = pcli->pfnGetContactDisplayName(hContact, 0); item->type = _T("conference"); item->nick = getTStringA(hContact, "MyNick"); AddEditBookmark(item); delete item; } return 0; }
INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; bool deleting = (lParam == 1); MCONTACT hContact = MCONTACT(wParam); // Ignore groupchats and, if deleting, also not-friends if (isChatRoom(hContact) || (deleting && getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE) != CONTACT_FRIEND)) return 0; ptrT tname(getTStringA(hContact, FACEBOOK_KEY_NICK)); if (tname == NULL) tname = getTStringA(hContact, FACEBOOK_KEY_ID); if (tname == NULL) return 1; TCHAR tstr[256]; mir_sntprintf(tstr, TranslateT("Do you want to cancel your friendship with '%s'?"), tname); if (MessageBox(0, tstr, m_tszUserName, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) { ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; std::string *val = new std::string(id); if (deleting) { facebook_user *fbu = facy.buddies.find(*val); if (fbu != NULL) fbu->handle = NULL; } ForkThread(&FacebookProto::DeleteContactFromServer, val); } return 0; }
INT_PTR __cdecl CJabberProto::OnLeaveChat(WPARAM hContact, LPARAM) { ptrT jid(getTStringA(hContact, "ChatRoomID")); if (jid != NULL) { if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid); if (item != NULL) GcQuit(item, 200, NULL); } } return 0; }