int CJabberProto::WsSend(JABBER_SOCKET hConn, char* data, int datalen, int flags) { m_lastTicks = ::GetTickCount(); int len; if ((len = Netlib_Send(hConn, data, datalen, flags)) == SOCKET_ERROR || len != datalen) { debugLogA("Netlib_Send() failed, error=%d", WSAGetLastError()); return SOCKET_ERROR; } return len; }
int CVkProto::Authorize(MEVENT hDbEvent) { debugLogA("CVkProto::Authorize"); if (!IsOnline()) return 1; MCONTACT hContact = MContactFromDbEvent(hDbEvent); if (hContact == INVALID_CONTACT_ID) return 1; return AuthRequest(hContact, NULL); }
int CVkProto::AuthDeny(MEVENT hDbEvent, const TCHAR*) { debugLogA("CVkProto::AuthDeny"); if (!IsOnline()) return 1; MCONTACT hContact = MContactFromDbEvent(hDbEvent); if (hContact == INVALID_CONTACT_ID) return 1; return SvcDeleteFriend(hContact,(LPARAM)true); }
INT_PTR __cdecl CVkProto::SvcWallPost(WPARAM hContact, LPARAM) { debugLogA("CVkProto::SvcWallPost"); WALLPOST_FORM_PARAMS param(db_get_tsa(hContact, m_szModuleName, "Nick")); if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WALLPOST), NULL, WallPostFormDlgProc, (LPARAM)¶m) == 0) return 1; WallPost((MCONTACT)hContact, param.ptszMsg, param.ptszUrl, param.bFriendsOnly); return 0; }
void CIcqProto::handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread_info *info) { char szKey[64] = {0}; mir_md5_state_t state; BYTE digest[16]; debugLogA("Received %s", "ICQ_SIGNON_AUTH_KEY"); if (wPacketLen < 2) { debugLogA("Malformed %s", "ICQ_SIGNON_AUTH_KEY"); icq_LogMessage(LOG_FATAL, LPGEN("Secure login failed.\nInvalid server response.")); SetCurrentStatus(ID_STATUS_OFFLINE); return; } size_t wKeyLen; unpackWord(&buf, &wKeyLen); wPacketLen -= 2; if (!wKeyLen || wKeyLen > wPacketLen || wKeyLen > sizeof(szKey)) { debugLogA("Invalid length in %s: %u", "ICQ_SIGNON_AUTH_KEY", wKeyLen); icq_LogMessage(LOG_FATAL, LPGEN("Secure login failed.\nInvalid key length.")); SetCurrentStatus(ID_STATUS_OFFLINE); return; } unpackString(&buf, szKey, wKeyLen); mir_md5_init(&state); mir_md5_append(&state, info->szAuthKey, (int)info->wAuthKeyLen); mir_md5_finish(&state, digest); mir_md5_init(&state); mir_md5_append(&state, (LPBYTE)szKey, (int)wKeyLen); mir_md5_append(&state, digest, 16); mir_md5_append(&state, (LPBYTE)CLIENT_MD5_STRING, sizeof(CLIENT_MD5_STRING)-1); mir_md5_finish(&state, digest); debugLogA("Sending ICQ_SIGNON_LOGIN_REQUEST to login server"); sendClientAuth((char*)digest, 0x10, TRUE); }
void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq) { CMStringA str; do { pReq->bNeedsRestart = false; pReq->szUrl = pReq->m_szUrl.GetBuffer(); if (!pReq->m_szParam.IsEmpty()) { if (pReq->requestType == REQUEST_GET) { str.Format("%s?%s", pReq->m_szUrl, pReq->m_szParam); pReq->szUrl = str.GetBuffer(); } else { pReq->pData = mir_strdup(pReq->m_szParam); pReq->dataLength = pReq->m_szParam.GetLength(); } } debugLogA("CVkProto::ExecuteRequest \n====\n%s\n====\n", pReq->szUrl); NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)pReq); if (reply != NULL) { if (pReq->m_pFunc != NULL) (this->*(pReq->m_pFunc))(reply, pReq); // may be set pReq->bNeedsRestart CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply); } else if (pReq->bIsMainConn) { if (IsStatusConnecting(m_iStatus)) ConnectionFailed(LOGINERR_NONETWORK); else if (pReq->m_iRetry && !m_bTerminated) { pReq->bNeedsRestart = true; Sleep(1000); //Pause for fix err pReq->m_iRetry--; debugLogA("CVkProto::ExecuteRequest restarting (retry = %d)", MAX_RETRIES - pReq->m_iRetry); } else { debugLogA("CVkProto::ExecuteRequest ShutdownSession"); ShutdownSession(); } } debugLogA("CVkProto::ExecuteRequest pReq->bNeedsRestart = %d", (int)pReq->bNeedsRestart); } while (pReq->bNeedsRestart && !m_bTerminated); delete pReq; }
void CIcqProto::handleMigration(serverthread_info *info) { // Check the data that was saved when the migration was announced debugLogA("Migrating to %s", info->newServer); if (!info->newServer || !info->cookieData) { icq_LogMessage(LOG_FATAL, LPGEN("You have been disconnected from the ICQ network because the current server shut down.")); SAFE_FREE(&info->newServer); SAFE_FREE((void**)&info->cookieData); info->isNewServerReady = info->isMigrating = false; } }
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; }
void CIcqProto::handlePrivacyRightsReply(unsigned char *pBuffer, size_t wBufferLength) { if (wBufferLength >= 12) { oscar_tlv_chain* pChain = readIntoTLVChain(&pBuffer, wBufferLength, 0); if (pChain) { WORD wMaxVisibleContacts = pChain->getWord(0x0001, 1); WORD wMaxInvisibleContacts = pChain->getWord(0x0002, 1); WORD wMaxTemporaryVisibleContacts = pChain->getWord(0x0003, 1); disposeChain(&pChain); debugLogA("PRIVACY: Max visible %u, max invisible %u, max temporary visible %u items.", wMaxVisibleContacts, wMaxInvisibleContacts, wMaxTemporaryVisibleContacts); // Success return; } } // Failure debugLogA("Warning: Malformed SRV_PRIVACY_RIGHTS_REPLY"); }
void CToxProto::TryConnect() { if (tox_self_get_connection_status(tox) != TOX_CONNECTION_NONE) { isConnected = true; debugLogA(__FUNCTION__": successfuly connected to DHT"); ForkThread(&CToxProto::LoadFriendList, NULL); m_iStatus = m_iDesiredStatus; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus); tox_self_set_status(tox, MirandaToToxStatus(m_iStatus)); debugLogA(__FUNCTION__": changing status from %i to %i", ID_STATUS_CONNECTING, m_iDesiredStatus); } else if (m_iStatus++ > TOX_MAX_CONNECT_RETRIES) { SetStatus(ID_STATUS_OFFLINE); ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, (HANDLE)NULL, LOGINERR_NONETWORK); debugLogA(__FUNCTION__": failed to connect to DHT"); } }
void CVkProto::UnInitMenus() { debugLogA("CVkProto::UnInitMenus"); for (int i = 0; i < PMI_COUNT; i++) Menu_RemoveItem(g_hProtoMenuItems[i]); for (int i = 0; i < CHMI_COUNT; i++) Menu_RemoveItem(g_hContactHistoryMenuItems[i]); for (int i = 0; i < CMI_COUNT; i++) Menu_RemoveItem(g_hContactMenuItems[i]); }
void CVkProto::OnLoggedIn() { debugLogA("CVkProto::OnLoggedIn"); m_bOnline = true; SetServerStatus(m_iDesiredStatus); // initialize online timer CallFunctionAsync(VKSetTimer, this); db_unset(NULL, m_szModuleName, "LastNewsReqTime"); db_unset(NULL, m_szModuleName, "LastNotificationsReqTime"); }
void WhatsAppProto::sentinelLoop(void*) { while (WaitForSingleObjectEx(update_loop_lock_, 1000, true) == WAIT_TIMEOUT) { if (m_iStatus != ID_STATUS_OFFLINE && m_pConnection != NULL && m_iDesiredStatus == m_iStatus) { // #TODO Quiet after pong or tree read? int quietInterval = difftime(time(NULL), m_tLastWriteTime); if (quietInterval >= MAX_SILENT_INTERVAL) { try { debugLogA("send ping"); m_tLastWriteTime = time(NULL); m_pConnection->sendPing(); } catch (exception &e) { debugLogA("Exception: %s", e.what()); } } } } ResetEvent(update_loop_lock_); debugLogA("Exiting sentinel loop"); }
INT_PTR __cdecl CVkProto::SvcSetStatusMsg(WPARAM, LPARAM) { debugLogA("CVkProto::SvcSetStatusMsg"); if (!IsOnline()) return 1; MsgPopup(NULL, TranslateT("Loading status message from vk.com.\nThis may take some time."), TranslateT("Waiting...")); Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/status.get.json", true, &CVkProto::OnReceiveStatusMsg)); return 0; }
int YAHOO_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr) { NETLIBHTTPPROXYINFO nlhpi; debugLogA("YAHOO_httpGatewayInit!!!"); memset(&nlhpi, 0, sizeof(nlhpi)); nlhpi.cbSize = sizeof(nlhpi); nlhpi.szHttpPostUrl = "http://shttp.msg.yahoo.com/notify/"; return CallService(MS_NETLIB_SETHTTPPROXYINFO, (WPARAM)hConn, (LPARAM)&nlhpi); }
void CVkProto::MarkMessagesRead(const MCONTACT hContact) { debugLogA("CVkProto::MarkMessagesRead (hContact)"); if (!IsOnline() || !hContact) return; LONG userID = getDword(hContact, "ID", -1); if (userID == -1 || userID == VK_FEED_USER) return; Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.markAsRead.json", true, &CVkProto::OnReceiveSmth, AsyncHttpRequest::rpLow) << INT_PARAM("peer_id", userID)); }
MCONTACT CVkProto::AddToList(int, PROTOSEARCHRESULT* psr) { debugLogA("CVkProto::AddToList"); int uid = _ttoi(psr->id.t); if (!uid) return NULL; MCONTACT hContact = FindUser(uid, true); RetrieveUserInfo(uid); return hContact; }
void FacebookProto::MessageLoop(void *) { time_t tim = ::time(NULL); debugLogA(">>> Entering Facebook::MessageLoop[%d]", tim); while (facy.channel()) { if (isOffline() || m_signingOut) break; // If we're not idle, send activity_ping every few minutes... if (!m_idleTS && (::time(NULL) - m_pingTS) > FACEBOOK_PING_TIME) { debugLogA("*** FacebookProto::MessageLoop[%d] pinging...", tim); facy.activity_ping(); } debugLogA("*** FacebookProto::MessageLoop[%d] refreshing...", tim); } debugLogA("<<< Exiting FacebookProto::MessageLoop[%d]", tim); }
INT_PTR __cdecl CVkProto::SvcWallPost(WPARAM hContact, LPARAM) { debugLogA("CVkProto::SvcWallPost"); WALLPOST_FORM_PARAMS param(db_get_tsa(hContact, m_szModuleName, "Nick")); CVkWallPostForm dlg(this, ¶m); if (!dlg.DoModal()) return 1; WallPost((MCONTACT)hContact, param.ptszMsg, param.ptszUrl, param.bFriendsOnly); return 0; }
void CVkProto::RetrieveUserInfo(LONG userID) { debugLogA("CVkProto::RetrieveUserInfo (%d)", userID); if (userID == VK_FEED_USER || !IsOnline()) return; CMString code(FORMAT, _T("var userIDs=\"%i\";var res=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});return{\"freeoffline\":0,\"norepeat\":1,\"usercount\":res.length,\"users\":res};"), userID, CMString(fieldsName)); Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo) << TCHAR_PARAM("code", code) << VER_API); }
std::string FacebookProto::ThreadIDToContactID(std::string thread_id) { std::string user_id; for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!IsMyContact(hContact)) continue; ptrA tid(getStringA(hContact, FACEBOOK_KEY_TID)); if (tid && !strcmp(tid, thread_id.c_str())) { user_id = ptrA( getStringA(hContact, FACEBOOK_KEY_ID)); return user_id; } } // We don't have any contact with thish thread_id cached, we must ask server std::string data = "client=mercury"; data += "&__user="******"&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0"); data += "&__a=1&__dyn=&__req=&ttstamp=0"; data += "&threads[thread_ids][0]=" + utils::url::encode(thread_id); http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); if (resp.code == HTTP_CODE_OK) { CODE_BLOCK_TRY facebook_json_parser* p = new facebook_json_parser(this); p->parse_thread_info(&resp.data, &user_id); delete p; debugLogA("***** Thread info processed"); CODE_BLOCK_CATCH debugLogA("***** Error processing thread info: %s", e.what()); CODE_BLOCK_END }
GGPROTO::~GGPROTO() { #ifdef DEBUGMODE debugLogA("~GGPROTO(): destroying protocol interface"); #endif // Destroy modules block_uninit(); img_destroy(); keepalive_destroy(); gc_destroy(); Popup_UnregisterClass(hPopupError); Popup_UnregisterClass(hPopupNotify); if (hMenuRoot) CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)hMenuRoot, 0); // Close handles Netlib_CloseHandle(m_hNetlibUser); // Destroy mutexes DeleteCriticalSection(&sess_mutex); DeleteCriticalSection(&ft_mutex); DeleteCriticalSection(&img_mutex); DeleteCriticalSection(&modemsg_mutex); DeleteCriticalSection(&avatar_mutex); DeleteCriticalSection(&sessions_mutex); #ifdef DEBUGMODE debugLogA("~GGPROTO(): DeleteCriticalSections. OK"); #endif // Free status messages if (modemsg.online) mir_free(modemsg.online); if (modemsg.away) mir_free(modemsg.away); if (modemsg.dnd) mir_free(modemsg.dnd); if (modemsg.freechat) mir_free(modemsg.freechat); if (modemsg.invisible) mir_free(modemsg.invisible); if (modemsg.offline) mir_free(modemsg.offline); }
int CVkProto::PollServer() { debugLogA("CVkProto::PollServer"); NETLIBHTTPREQUEST req = { sizeof(req) }; req.requestType = REQUEST_GET; req.szUrl = NEWSTR_ALLOCA(CMStringA().Format("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken)); req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT; req.timeout = 30000; req.nlc = m_pollingConn; NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req); if (reply == NULL) { m_pollingConn = NULL; return 0; } int retVal = 0; if (reply->resultCode == 200) { JSONROOT pRoot(reply->pData); JSONNODE *pFailed = json_get(pRoot, "failed"); if (pFailed != NULL && json_as_int(pFailed) == 2) { RetrievePollingInfo(); retVal = -1; debugLogA("Polling key expired, restarting polling thread"); } else if (CheckJsonResult(NULL, reply, pRoot)) { m_pollingTs = mir_t2a(ptrT(json_as_string(json_get(pRoot, "ts")))); JSONNODE *pUpdates = json_get(pRoot, "updates"); if (pUpdates != NULL) PollUpdates(pUpdates); retVal = 1; } } m_pollingConn = reply->nlc; CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply); return retVal; }
HANDLE GGPROTO::dccfileallow(HANDLE hTransfer, const PROTOCHAR* szPath) { struct gg_dcc *dcc = (struct gg_dcc *) hTransfer; char fileName[MAX_PATH], *path = mir_t2a(szPath); strncpy(fileName, path, sizeof(fileName)); strncat(fileName, (char*)dcc->file_info.filename, sizeof(fileName) - strlen(fileName)); dcc->folder = _strdup((char *) path); dcc->tick = 0; mir_free(path); // Remove transfer from waiting list gg_EnterCriticalSection(&ft_mutex, "dccfileallow", 38, "ft_mutex", 1); list_remove(&transfers, dcc, 0); gg_LeaveCriticalSection(&ft_mutex, "dccfileallow", 38, 1, "ft_mutex", 1); // Open file for appending and check if ok if ((dcc->file_fd = _open(fileName, _O_WRONLY | _O_APPEND | _O_BINARY | _O_CREAT, _S_IREAD | _S_IWRITE)) == -1) { debugLogA("dccfileallow(): Failed to create file \"%s\". errno=%d: %s", fileName, errno, strerror(errno)); TCHAR error[512]; mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot create transfer file. ERROR: %d: %s (dcc)\n%s"), errno, _tcserror(errno), szPath); showpopup(m_tszUserName, error, GG_POPUP_ERROR); ProtoBroadcastAck(dcc->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc, 0); // Free transfer gg_free_dcc(dcc); return 0; } // Put an offset to the file dcc->offset = _lseek(dcc->file_fd, 0, SEEK_END); // Add to watches and start transfer gg_EnterCriticalSection(&ft_mutex, "dccfileallow", 39, "ft_mutex", 1); list_add(&watches, dcc, 0); gg_LeaveCriticalSection(&ft_mutex, "dccfileallow", 39, 1, "ft_mutex", 1); debugLogA("dccfileallow(): Receiving file \"%s\" from %d.", dcc->file_info.filename, dcc->peer_uin); return hTransfer; }
void CVkProto::RetrieveStatusMusic(const CMString &StatusMsg) { debugLogA("CVkProto::RetrieveStatusMusic"); if (!IsOnline() || m_iStatus == ID_STATUS_INVISIBLE || m_vkOptions.iMusicSendMetod == MusicSendMetod::sendNone) return; CMString code; CMString tszOldStatusMsg(db_get_tsa(0, m_szModuleName, "OldStatusMsg")); if (StatusMsg.IsEmpty()) { if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastOnly) code = "API.audio.setBroadcast();return null;"; else { CMString codeformat("API.status.set({text:\"%s\"});return null;"); code.AppendFormat(codeformat, tszOldStatusMsg); } m_bSetBroadcast = false; } else { if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastOnly) { CMString codeformat("var StatusMsg=\"%s\";var CntLmt=100;var OldMsg=API.status.get();" "var Tracks=API.audio.search({\"q\":StatusMsg,\"count\":CntLmt,\"search_own\":1});" "var Cnt=Tracks.count;if(Cnt>CntLmt){Cnt=CntLmt;}" "if(Cnt==0){API.audio.setBroadcast();}" "else{var i=0;var j=0;var Track=\" \";" "while(i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track==StatusMsg){j=i;}i=i+1;}" "Track=Tracks.items[j].owner_id+\"_\"+Tracks.items[j].id;API.audio.setBroadcast({\"audio\":Track});" "};return OldMsg;"); code.AppendFormat(codeformat, StatusMsg); } else if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendStatusOnly) { CMString codeformat("var StatusMsg=\"♫ %s\";var OldMsg=API.status.get();" "API.status.set({\"text\":StatusMsg});" "return OldMsg;"); code.AppendFormat(codeformat, StatusMsg); } else if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastAndStatus) { CMString codeformat("var StatusMsg=\"%s\";var CntLmt=100;var Track=\" \";var OldMsg=API.status.get();" "var Tracks=API.audio.search({\"q\":StatusMsg,\"count\":CntLmt,\"search_own\":1});" "var Cnt=Tracks.count;if(Cnt>CntLmt){Cnt=CntLmt;}" "if(Cnt==0){Track=\"♫ \"+StatusMsg;API.status.set({\"text\":Track});}" "else{var i=0;var j=-1;" "while(i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track==StatusMsg){j=i;}i=i+1;}" "if(j==-1){Track=\"♫ \"+StatusMsg;API.status.set({\"text\":Track});}else{" "Track=Tracks.items[j].owner_id+\"_\"+Tracks.items[j].id;};API.audio.setBroadcast({\"audio\":Track});" "};return OldMsg;"); code.AppendFormat(codeformat, StatusMsg); } m_bSetBroadcast = true; } Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveStatus) << TCHAR_PARAM("code", code)); }
//////////////////////////////////////////////////////////////////////////////// // Inits Gadu-Gadu groupchat module using chat.dll // int GGPROTO::gc_init() { if (ServiceExists(MS_GC_REGISTER)) { char service[64]; // Register Gadu-Gadu proto GCREGISTER gcr = { sizeof(gcr) }; gcr.ptszDispName = m_tszUserName; gcr.pszModule = m_szModuleName; CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr); HookProtoEvent(ME_GC_EVENT, &GGPROTO::gc_event); gc_enabled = TRUE; // create & hook event mir_snprintf(service, GG_GC_GETCHAT, m_szModuleName); debugLogA("gc_init(): Registered with groupchat plugin."); } else debugLogA("gc_init(): Cannot register with groupchat plugin !!!"); return 1; }
bool MinecraftDynmapProto::handleError(const std::string &method, const std::string &error, bool force_disconnect) { increment_error(); debugLogA("!!!!! Quitting %s() with error: %s", method.c_str(), !error.empty() ? error.c_str() : "Something went wrong"); if (!force_disconnect && error_count_ <= (UINT)db_get_b(NULL, m_szModuleName, MINECRAFTDYNMAP_KEY_TIMEOUTS_LIMIT, MINECRAFTDYNMAP_TIMEOUTS_LIMIT)) { return true; } reset_error(); SetStatus(ID_STATUS_OFFLINE); return false; }
void CVkProto::OnChatDestroy(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnChatDestroy %d", reply->resultCode); if (reply->resultCode == 200) { CVkChatInfo *cc = (CVkChatInfo*)pReq->pUserInfo; GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_QUIT }; GCEVENT gce = { sizeof(GCEVENT), &gcd }; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); CallService(MS_DB_CONTACT_DELETE, (WPARAM)cc->m_hContact, 0); } }
void OmegleProto::StopChat(bool disconnect) { if (facy.state_ == STATE_WAITING) { UpdateChat(NULL, TranslateT("Connecting canceled."), false); } else if (facy.state_ == STATE_ACTIVE || facy.state_ == STATE_SPY) { bool spy = facy.state_ == STATE_SPY; if (disconnect) { facy.state_ = STATE_DISCONNECTING; UpdateChat(NULL, TranslateT("Disconnecting..."), true); if (facy.stop()) debugLogA("***** Disconnected from stranger %s", facy.chat_id_.c_str()); else debugLogA("***** Error in disconnecting from stranger %s", facy.chat_id_.c_str()); } if (spy) { DeleteChatContact(TranslateT("Stranger 1")); DeleteChatContact(TranslateT("Stranger 2")); } else { DeleteChatContact(TranslateT("Stranger")); } SetTopic(); // reset topic content CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)GetChatHandle(), NULL); } else { // disconnecting or inactive return; } facy.state_ = STATE_INACTIVE; facy.chat_id_.clear(); }
void MinecraftDynmapProto::EventsLoop(void *) { ScopedLock s(events_loop_lock_); time_t tim = ::time(NULL); debugLogA(">>>>> Entering %s[%d]", __FUNCTION__, tim); while (doEvents()) { if (!isOnline()) break; if (WaitForSingleObjectEx(events_loop_event_, m_updateRate, true) != WAIT_TIMEOUT) // FIXME: correct timeout break; debugLogA("***** %s[%d] refreshing...", __FUNCTION__, tim); } ResetEvent(events_loop_event_); ResetEvent(events_loop_lock_); debugLogA("<<<<< Exiting %s[%d]", __FUNCTION__, tim); }