void RenderAf::setRegistered() { getFarmHost(); if( isFromStore()) { appendLog("Initialized from store."); } else { m_time_register = time( NULL); setStoreDir( AFCommon::getStoreDirRender( *this)); store(); appendLog("Registered."); } af::Client::setRegisterTime(); m_task_start_finish_time = 0; m_wol_operation_time = 0; m_idle_time = time(NULL); m_busy_time = m_idle_time; if( isOnline()) appendLog("Registered online."); else appendLog("Registered offline."); }
void WhatsAppProto::ChatLogMenuHook(WAChatInfo *pInfo, struct GCHOOK *gch) { switch (gch->dwData) { case IDM_INVITE: InviteChatUser(pInfo); break; case IDM_TOPIC: EditChatSubject(pInfo); break; case IDM_CPY_RJID: utils::copyText(pcli->hwndContactList, pInfo->tszJid); break; case IDM_CPY_TOPIC: utils::copyText(pcli->hwndContactList, pInfo->tszNick); break; case IDM_LEAVE: if (isOnline()) m_pConnection->sendJoinLeaveGroup(_T2A(pInfo->tszJid), false); break; case IDM_AVATAR: SetChatAvatar(pInfo); break; } }
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; }
void RenderAf::wolWake( MonitorContainer * i_monitoring, const std::string & i_msg) { if( i_msg.size()) appendLog( i_msg); if( isOnline()) { appendLog("Can't wake up online render."); return; } if( isWOLFalling()) { appendLog("Can't wake up render which is just falling a sleep."); return; } if( m_netIFs.size() < 1) { appendLog("Can't perform Wake-On-Line operations. No network interfaces information."); return; } appendLog("Sending WOL wake request."); setWOLWaking( true); m_wol_operation_time = time( NULL); store(); if( i_monitoring ) i_monitoring->addEvent( af::Monitor::EVT_renders_change, m_id); std::ostringstream str; v_jsonWrite( str, af::Msg::TRendersList); SysJob::AddWOLCommand( str.str(), "", m_name, m_name); }
void DVRServer::toggleOnline() { if (isOnline()) m_api->logout(); else login(); }
// This is called when the user presses the upload button void MainWindow::upload() { QSettings settings("Entomologist"); bool noUploadDialog = settings.value("no-upload-confirmation", false).toBool(); bool reallyUpload = true; if (!isOnline()) { QMessageBox box; box.setText(tr("Sorry, you can only upload changes when you are connected to the Internet.")); box.exec(); return; } if (!noUploadDialog) { UploadDialog *newDialog = new UploadDialog(this); newDialog->setChangelog(getChangelog()); if (newDialog->exec() != QDialog::Accepted) reallyUpload = false; delete newDialog; } if (reallyUpload) { qDebug() << "Uploading..."; startAnimation(); mUploading = true; mSyncPosition = 0; syncNextTracker(); } }
int sendMessage(std::string toUser, std::string fromUser, std::string message){ bool onn = isOnline(toUser); if(!onn){ ERROR = E_OFFLINE; error_message = "offline"; #ifdef __DEBUG__ std::cout<<error_message<<std::endl; #endif return -1; } int targetSocket = getFromConnectionTable(toUser); message = "RECV:"+fromUser+":"+message; int sbytes = send(targetSocket, message.c_str(), message.length(), 0); if(sbytes<0){ ERROR = E_SEND; error_message = "e_send"; #ifdef __DEBUG__ std::cout<<error_message<<std::endl; #endif return -1; } return sbytes; }
int FacebookProto::UserIsTyping(MCONTACT hContact, int type) { if (hContact && isOnline()) ForkThread(&FacebookProto::SendTypingWorker, new send_typing(hContact, type)); return 0; }
void MainWindow::workOfflineTriggered() { QSettings settings("Entomologist"); settings.setValue("work-offline", ui->action_Work_Offline->isChecked()); isOnline(); }
static int brl_writeStatus (BrailleDisplay *brl, const unsigned char *status) { if (isOnline()) { if (status[GSC_FIRST] == GSC_MARKER) { unsigned char row = status[gscScreenCursorRow]; unsigned char column = status[gscScreenCursorColumn]; row = MAX(1, MIN(row, screenHeight)) - 1; column = MAX(1, MIN(column, screenWidth)) - 1; if (deviceStatus < DEV_READY) { memset(targetImage, 0, sizeof(targetImage)); currentContext = KTB_CTX_DEFAULT; currentLine = row; cursorRow = screenHeight; cursorColumn = screenWidth; deviceStatus = DEV_READY; } if ((row != cursorRow) || (column != cursorColumn)) { logMessage(LOG_DEBUG, "cursor moved: [%d,%d] -> [%d,%d]", cursorColumn, cursorRow, column, row); cursorRow = row; cursorColumn = column; sendCursorRow(); } } } return 1; }
void Game::safeLogout() { if(!isOnline()) return; m_protocolGame->sendLogout(); }
QStringList Addressbook::onlineContacts() { QStringList contactUIDS; for( KABC::AddressBook::Iterator it = addressBook->begin(); it != addressBook->end(); ++it ) if(isOnline(*it)) contactUIDS.append((*it).uid()); return contactUIDS; }
void RenderAf::exitClient( const std::string & i_type, JobContainer * i_jobs, MonitorContainer * i_monitoring) { if( false == isOnline() ) return; m_re.m_instruction = i_type; // offline( i_jobs, af::TaskExec::UPRenderExit, i_monitoring); }
void DVRCamera::setOnline(bool on) { if (on == m_isOnline) return; m_isOnline = on; emit onlineChanged(isOnline()); }
void Client::onHistoryFull() { if (isOnline() && isAuthentificated()) { sendHistory(); getTagsRequest(); } }
void Client::sendHistory() { while(!m_history->isEmpty() && isOnline()) { sendLastCoordinate(); pause(250); } }
void Game::forceLogout() { if(!isOnline()) return; m_protocolGame->sendLogout(); processDisconnect(); }
int switchState(int type) { if (state == type) /* 跟上次是同一状态? */ sendCount++; else { state = type; sendCount = 0; } if (sendCount>=MAX_SEND_COUNT && type!=ID_ECHO) /* 超时太多次? */ { switch (type) { case ID_START: printf(_(">> 找不到服务器,重启认证!\n")); break; case ID_IDENTITY: printf(_(">> 发送用户名超时,重启认证!\n")); break; case ID_CHALLENGE: printf(_(">> 发送密码超时,重启认证!\n")); break; case ID_WAITECHO: printf(_(">> 等候响应包超时,自行响应!\n")); return switchState(ID_ECHO); } return restart(); } switch (type) { case ID_DHCP: return renewIP(); case ID_START: return sendStartPacket(); case ID_IDENTITY: return sendIdentityPacket(); case ID_CHALLENGE: return sendChallengePacket(); case ID_WAITECHO: /* 塞尔的就不ping了,不好计时 */ return waitEchoPacket(); case ID_ECHO: if (pingHost && sendCount*echoInterval > 60) { /* 1分钟左右 */ if (isOnline() == -1) { printf(_(">> 认证掉线,开始重连!\n")); return switchState(ID_START); } sendCount = 1; } #ifndef NO_ARP if (gateMAC[0] != 0xFE) sendArpPacket(); #endif return sendEchoPacket(); case ID_DISCONNECT: return sendLogoffPacket(); } return 0; }
int WhatsAppProto::OnChatOutgoing(WPARAM wParam, LPARAM lParam) { GCHOOK *hook = reinterpret_cast<GCHOOK*>(lParam); char *text; char *id; if (strcmp(hook->pDest->pszModule,m_szModuleName)) return 0; switch(hook->pDest->iType) { case GC_USER_MESSAGE: { text = mir_t2a_cp(hook->ptszText,CP_UTF8); std::string msg = text; id = mir_t2a_cp(hook->pDest->ptszID,CP_UTF8); std::string chat_id = id; mir_free(text); mir_free(id); if (isOnline()) { MCONTACT hContact = this->ContactIDToHContact(chat_id); if (hContact) { debugLogA("**Chat - Outgoing message: %s", text); this->SendMsg(hContact, IS_CHAT, msg.c_str()); // #TODO Move to SendMsgWorker, otherwise all messages are "acknowledged" by Miranda GCDEST gcd = { m_szModuleName, hook->pDest->ptszID, GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof(gce), &gcd }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = mir_a2t(this->nick.c_str()); gce.ptszUID = mir_a2t(this->jid.c_str()); gce.time = time(NULL); gce.ptszText = hook->ptszText; gce.bIsMe = TRUE; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free((void*)gce.ptszUID); mir_free((void*)gce.ptszNick); } } break; } case GC_USER_LEAVE: case GC_SESSION_TERMINATE: { break; } } return 0; }
void Client::stopTrack() { if (m_timer->isActive()) { m_timer->stop(); m_additionalTimer->start(m_history->getHistoryLimit()*m_trackInterval*1000); } if (isOnline() && isAuthentificated() && !m_history->isEmpty()) sendHistory(); }
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 WhatsAppProto::OnUserInfo(WPARAM, LPARAM hContact) { ptrA jid(getStringA(hContact, WHATSAPP_KEY_ID)); if (jid && isOnline()) { m_pConnection->sendGetPicture((char*)jid, "image"); m_pConnection->sendPresenceSubscriptionRequest((char*)jid); } return 0; }
void RenderAf::launchAndExit( const std::string & i_cmd, bool i_exit, JobContainer * i_jobs, MonitorContainer * i_monitoring) { if( false == isOnline() ) return; m_re.m_instruction = ( i_exit ? "launch_exit" : "launch"); m_re.m_command = i_cmd; // if( i_exit ) // offline( i_jobs, af::TaskExec::UPRenderExit, i_monitoring); }
void WhatsAppProto::KickChatUser(WAChatInfo *pInfo, const TCHAR *ptszJid) { if (!isOnline()) return; std::string gjid((char*)_T2A(pInfo->tszJid)); std::vector<std::string> jids(1); jids[0] = (char*)_T2A(ptszJid); m_pConnection->sendRemoveParticipants(gjid, jids); }
QByteArray xtHelp::fileData(const QUrl &url) const { QByteArray returnVal; if (isOnline() || url.scheme() == "http") { QNetworkRequest req(url); QNetworkReply *rep = _nam->get(req); while(! rep->isFinished()) QCoreApplication::instance()->processEvents(); returnVal = rep->readAll(); } else returnVal = QHelpEngine::fileData(url); if (DEBUG) qDebug() << "xtHelp::fileData(" << url << " [ online?" << isOnline() << "]) returning" << returnVal.size() << "bytes:" << returnVal; return returnVal; }
void Game::processDisconnect() { if(isOnline()) processGameEnd(); if(m_protocolGame) { m_protocolGame->disconnect(); m_protocolGame = nullptr; } }
void WhatsAppProto::InviteChatUser(WAChatInfo *pInfo) { CInviteDialog dlg(this); if (!dlg.DoModal()) return; if (isOnline()) { m_pConnection->sendAddParticipants((char*)_T2A(pInfo->tszJid), m_szInviteJids); m_szInviteJids.clear(); } }
void LogicalRecoveryTxn::recoverParticipant( LogicalTxnParticipant *pLoggedParticipant) { if (isOnline()) { return; } LogicalTxnClassId classId; pTxnInputStream->readValue(classId); SharedLogicalTxnParticipant pRecoveredParticipant = pParticipantFactory->loadParticipant(classId,*pTxnInputStream); participantMap[pLoggedParticipant] = pRecoveredParticipant; }
LRESULT UsersFrame::onContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (reinterpret_cast<HWND>(wParam) == ctrlUsers && ctrlUsers.GetSelectedCount() > 0) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; if (pt.x == -1 && pt.y == -1) { WinUtil::getContextMenuPos(ctrlUsers, pt); } clearUserMenu(); // [+] IRainman fix. // [+] brain-ripper // Make menu dynamic, since its content depends of which // user selected (for add/remove favorites item) OMenu usersMenu; usersMenu.CreatePopupMenu(); usersMenu.AppendMenu(MF_STRING, IDC_EDIT, CTSTRING(PROPERTIES)); usersMenu.AppendMenu(MF_STRING, IDC_OPEN_USER_LOG, CTSTRING(OPEN_USER_LOG)); usersMenu.AppendMenu(MF_STRING, IDC_REMOVE_FROM_FAVORITES, CTSTRING(REMOVE_FROM_FAVORITES)); //[+] NightOrion tstring x; if (ctrlUsers.GetSelectedCount() == 1) { const auto user = ctrlUsers.getItemData(ctrlUsers.GetSelectedIndex())->getUser(); if (user->isOnline()) { usersMenu.AppendMenu(MF_SEPARATOR); x = user->getLastNickT(); reinitUserMenu(user, Util::emptyString); // TODO: add hub hint. if (!x.empty()) usersMenu.InsertSeparatorFirst(x); appendAndActivateUserItems(usersMenu); } } else { usersMenu.AppendMenu(MF_SEPARATOR); appendAndActivateUserItems(usersMenu); } usersMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd); if (!x.empty()) usersMenu.RemoveFirstItem(); return TRUE; } bHandled = FALSE; return FALSE; }
// This is triggered when the user selects File -> Add Tracker void MainWindow::addTrackerTriggered() { if (!isOnline()) { QMessageBox box; box.setText(tr("Sorry, you can only add a new tracker when you're connected to the Internet.")); box.exec(); return; } NewTracker t(this); if (t.exec() == QDialog::Accepted) { QMap<QString, QString> info = t.data(); QString cleanUrl = cleanupUrl(info["url"]); info["url"] = cleanUrl; #if 0 if (pDetectorProgress == NULL) pDetectorProgress = new QProgressDialog(tr("Detecting tracker version..."), tr("Cancel"), 0, 0); pDetectorProgress->setWindowModality(Qt::ApplicationModal); pDetectorProgress->setMinimumDuration(0); pDetectorProgress->setValue(2); #endif ui->syncingLabel->setText("Detecting tracker version..."); startAnimation(); if (info["tracker_type"] == "Bugzilla") { pNewTracker = new Bugzilla(cleanUrl); } else if (info["tracker_type"] == "Mantis") { pNewTracker = new Mantis(cleanUrl); } else if (info["tracker_type"] == "Trac") { pNewTracker = new Trac(cleanUrl, info["username"], info["password"]); } else { QMessageBox box; box.setText(tr("Something has gone horribly wrong. I have no idea what tracker you want to add!")); box.exec(); return; } pNewTracker->setName(info["name"]); pNewTracker->setUsername(info["username"]); pNewTracker->setPassword(info["password"]); checkVersion(pNewTracker); } }