INT_PTR FacebookProto::RefreshBuddyList(WPARAM, LPARAM) { if (!isOffline()) { facy.client_notify(TranslateT("Refreshing buddy list...")); ForkThread(&FacebookProto::ProcessBuddyList, NULL); } return 0; }
MCONTACT TwitterProto::AddToList(int, PROTOSEARCHRESULT *psr) { if (m_iStatus != ID_STATUS_ONLINE) return 0; ForkThread(&TwitterProto::AddToListWorker, mir_utf8encodeT(psr->nick.t)); return AddToClientList(_T2A(psr->nick.t), ""); }
int FacebookProto::SendMsg(MCONTACT hContact, int, const char *msg) { std::string message = msg; unsigned int msgId = InterlockedIncrement(&facy.msgid_); ForkThread(&FacebookProto::SendMsgWorker, new send_direct(hContact, message, msgId)); return msgId; }
HANDLE GGPROTO::GetAwayMsg(MCONTACT hContact) { #ifdef DEBUGMODE debugLogA("GetAwayMsg(): ForkThread 17 GGPROTO::getawaymsgthread"); #endif ForkThread(&GGPROTO::getawaymsgthread, (void*)hContact); return (HANDLE)1; }
int TwitterProto::SendMsg(MCONTACT hContact, int, const char *msg) { if (m_iStatus != ID_STATUS_ONLINE) return 0; int seq = InterlockedIncrement(&g_msgid); ForkThread(&TwitterProto::SendSuccess, new send_direct(hContact, msg, seq)); return seq; }
INT_PTR FacebookProto::CheckNewsfeeds(WPARAM, LPARAM) { if (!isOffline()) { facy.client_notify(TranslateT("Loading newsfeeds...")); facy.last_feeds_update_ = 0; ForkThread(&FacebookProto::ProcessFeeds, NULL); } return 0; }
HANDLE FacebookProto::SearchByEmail(const PROTOCHAR* email) { if (isOffline()) return 0; TCHAR *temail = mir_tstrdup(email); ForkThread(&FacebookProto::SearchAckThread, temail); return temail; }
HANDLE FacebookProto::SearchBasic(const PROTOCHAR* id) { if (isOffline()) return 0; TCHAR *tid = mir_tstrdup(id); ForkThread(&FacebookProto::SearchIdAckThread, tid); return tid; }
HANDLE WhatsAppProto::SearchBasic( const PROTOCHAR* id ) { if (isOffline()) return 0; TCHAR* email = mir_tstrdup(id); ForkThread(&WhatsAppProto::SearchAckThread, email); return email; }
HANDLE __cdecl CMsnProto::GetAwayMsg(HANDLE hContact) { AwayMsgInfo* inf = (AwayMsgInfo*)mir_alloc(sizeof(AwayMsgInfo)); inf->hContact = hContact; inf->id = MSN_GenRandom(); ForkThread(&CMsnProto::MsnGetAwayMsgThread, inf); return (HANDLE)inf->id; }
HANDLE __cdecl CMsnProto::SearchBasic(const PROTOCHAR* id) { if (!msnLoggedIn) return 0; TCHAR* email = mir_tstrdup(id); ForkThread(&CMsnProto::MsnSearchAckThread, email); return email; }
HANDLE __cdecl CAimProto::SearchBasic(const PROTOCHAR* szId) { if (state != 1) return 0; //duplicating the parameter so that it isn't deleted before it's needed- e.g. this function ends before it's used ForkThread(&CAimProto::basic_search_ack_success, mir_t2a(szId)); return (HANDLE)1; }
INT_PTR CMsnProto::SetAvatar(WPARAM, LPARAM lParam) { TCHAR* szFileName = (TCHAR*)lParam; TCHAR tFileName[MAX_PATH]; MSN_GetAvatarFileName(NULL, tFileName, _countof(tFileName), NULL); _tremove(tFileName); if (szFileName == NULL) { delSetting("PictObject"); delSetting("AvatarHash"); ForkThread(&CMsnProto::msn_storeAvatarThread, NULL); } else { int fileId = _topen(szFileName, _O_RDONLY | _O_BINARY, _S_IREAD); if (fileId < 0) return 1; size_t dwPngSize = _filelengthi64(fileId); unsigned char* pData = (unsigned char*)mir_alloc(dwPngSize); if (pData == NULL) { _close(fileId); return 2; } _read(fileId, pData, (unsigned)dwPngSize); _close(fileId); TCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; _tsplitpath(szFileName, drive, dir, fname, ext); MSN_SetMyAvatar(fname, pData, dwPngSize); StoreAvatarData* par = (StoreAvatarData*)mir_alloc(sizeof(StoreAvatarData)); par->szName = mir_tstrdup(fname); par->data = pData; par->dataSize = dwPngSize; par->szMimeType = "image/png"; ForkThread(&CMsnProto::msn_storeAvatarThread, par); } MSN_SetServerStatus(m_iStatus); return 0; }
INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam, LPARAM) { if (wParam == NULL || isOffline()) return 1; MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); ForkThread(&FacebookProto::CancelFriendsRequest, hContact); return 0; }
INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam, LPARAM) { if (wParam == NULL || isOffline()) return 1; MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); ForkThread(&FacebookProto::ApproveContactToServer, hContact); return 0; }
INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam)); ForkThread(&FacebookProto::ApproveContactToServer, hContact); return 0; }
INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam)); ForkThread(&FacebookProto::CancelFriendsRequest, hContact); return 0; }
HANDLE __cdecl CYahooProto::SearchBasic( const TCHAR* nick ) { LOG(("[YahooBasicSearch] Searching for: %S", nick)); if ( !m_bLoggedIn ) return 0; ForkThread(&CYahooProto::search_simplethread, _tcsdup( nick )); return ( HANDLE )1; }
int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg) { debugLogA("CVkProto::SendMsg"); if (!IsOnline()) return 0; bool bIsChat = isChatRoom(hContact); LONG iUserID = getDword(hContact, bIsChat ? "vk_chat_id" : "ID" , -1); if (iUserID == -1 || iUserID == VK_FEED_USER) { ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact)); return 0; } int StickerId = 0; ptrA pszRetMsg(GetStickerId(szMsg, StickerId)); ULONG uMsgId = ::InterlockedIncrement(&m_msgId); AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, bIsChat? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh) << INT_PARAM(bIsChat ? "chat_id" : "user_id", iUserID) << INT_PARAM("guid", ((LONG) time(NULL)) * 100 + uMsgId % 100) << VER_API; pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded"); if (StickerId) pReq << INT_PARAM("sticker_id", StickerId); else pReq << CHAR_PARAM("message", szMsg); if (!bIsChat) pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId); Push(pReq); if (!m_bServerDelivery && !bIsChat) ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact, uMsgId)); if (!IsEmpty(pszRetMsg)) { Sleep(330); SendMsg(hContact, 0, pszRetMsg); } return uMsgId; }
HWND __cdecl CYahooProto::SearchAdvanced( HWND owner ) { LOG(("[YahooAdvancedSearch]")); if ( !m_bLoggedIn ) return 0; ForkThread( &CYahooProto::searchadv_thread, owner ); return ( HWND )1; }
HANDLE WhatsAppProto::SearchBasic(const TCHAR* id) { if (isOffline()) return 0; // fake - we always accept search SearchParam *param = new SearchParam(id, GetSerial()); ForkThread(&WhatsAppProto::SearchAckThread, param); return (HANDLE)param->id; }
INT_PTR __cdecl CYahooProto::SendNudge(WPARAM hContact, LPARAM lParam) { debugLogA("[YAHOO_SENDNUDGE]"); if (!m_bLoggedIn) {/* don't send nudge if we not connected! */ ForkThread(&CYahooProto::im_sendackfail, (void*)hContact); return 1; } DBVARIANT dbv; if (!getString(hContact, YAHOO_LOGINID, &dbv)) { send_msg(dbv.pszVal, getWord(hContact, "yprotoid", 0), "<ding>", 0); db_free(&dbv); ForkThread(&CYahooProto::im_sendacksuccess, (void*)hContact); return 1; } return 0; }
HANDLE CVkProto::SendFile(MCONTACT hContact, const TCHAR *desc, TCHAR **files) { debugLogA("CVkProto::SendFile"); LONG userID = getDword(hContact, "ID", -1); if (!IsOnline() || ((userID == -1 || userID == VK_FEED_USER) && !isChatRoom(hContact))) return (HANDLE)0; CVkFileUploadParam *fup = new CVkFileUploadParam(hContact, desc, files); ForkThread(&CVkProto::SendFileThread, (void *)fup); return (HANDLE)fup; }
HWND CToxProto::OnSearchAdvanced(HWND owner) { if (!IsOnline()) { // we cannot add someone to friend list while tox is offline return NULL; } std::smatch match; std::regex regex("^\\s*([A-Fa-f0-9]{76})\\s*$"); TCHAR text[MAX_PATH]; GetDlgItemText(owner, IDC_SEARCH, text, _countof(text)); const std::string query = T2Utf(text).str(); if (std::regex_search(query, match, regex)) { std::string address = match[1]; PROTOSEARCHRESULT psr = { sizeof(psr) }; psr.id.a = mir_strdup(query.c_str()); ADDCONTACTSTRUCT acs = { HANDLE_SEARCHRESULT }; acs.szProto = m_szModuleName; acs.psr = &psr; CallService(MS_ADDCONTACT_SHOW, (WPARAM)owner, (LPARAM)&acs); ForkThread(&CToxProto::SearchFailedAsync, NULL); } else { regex = "^\\s*(([^ @/:;()\"']+)(@[A-Za-z]+.[A-Za-z]{2,6})?)\\s*$"; if (std::regex_search(query, match, regex)) ForkThread(&CToxProto::SearchByNameAsync, mir_strdup(query.c_str())); else ForkThread(&CToxProto::SearchFailedAsync, NULL); } return (HWND)1; }
INT_PTR CAimProto::OnJoinChat(WPARAM hContact, LPARAM) { if (m_state != 1) return 0; DBVARIANT dbv; if (!getString(hContact, "ChatRoomID", &dbv)) { chatnav_param* par = new chatnav_param(dbv.pszVal, getWord(hContact, "Exchange", 4)); ForkThread(&CAimProto::chatnav_request_thread, par); db_free(&dbv); } return 0; }
HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id) { if (!isonline()) return (HANDLE)0; gg_pubdir50_t req; if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH))) { #ifdef DEBUGMODE debugLogA("SearchBasic(): ForkThread 10 GGPROTO::searchthread"); #endif ForkThread(&GGPROTO::searchthread, NULL); return (HANDLE)1; } char *id_utf8 = mir_utf8encodeT(id); // Add uin and search it gg_pubdir50_add(req, GG_PUBDIR50_UIN, id_utf8); gg_pubdir50_seq_set(req, GG_SEQ_SEARCH); mir_free(id_utf8); gg_EnterCriticalSection(&sess_mutex, "SearchBasic", 50, "sess_mutex", 1); if (!gg_pubdir50(sess, req)) { gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 1, "sess_mutex", 1); #ifdef DEBUGMODE debugLogA("SearchBasic(): ForkThread 11 GGPROTO::searchthread"); #endif ForkThread(&GGPROTO::searchthread, NULL); return (HANDLE)1; } gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 2, "sess_mutex", 1); debugLogA("SearchBasic(): Seq %d.", req->seq); gg_pubdir50_free(req); return (HANDLE)1; }
INT_PTR FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; ForkThread(&FacebookProto::AddContactToServer, new std::string(id)); return 0; }
void FacebookProto::OpenUrl(std::string url) { url = PrepareUrl(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 Utils_OpenUrlT(data); }
HANDLE __cdecl CYahooProto::GetAwayMsg(MCONTACT hContact) { debugLogA("[YahooGetAwayMessage] "); if (hContact && m_bLoggedIn) { if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) return 0; /* user offline, what Status message? */ ForkThread(&CYahooProto::get_status_thread, (void*)hContact); return (HANDLE)1; //Success } return 0; // Failure }
INT_PTR FacebookProto::Poke(WPARAM wParam,LPARAM lParam) { if (wParam == NULL || isOffline()) return 1; MCONTACT hContact = MCONTACT(wParam); ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == NULL) return 1; ForkThread(&FacebookProto::SendPokeWorker, new std::string(id)); return 0; }