void SystemMonitor::initialize() { d = new SystemMonitorPrivate(this); QAbstractEventDispatcher::instance()->installNativeEventFilter(d); connect(&d->network, SIGNAL(online()), this, SIGNAL(online())); connect(&d->network, SIGNAL(offline()), this, SIGNAL(offline())); connect(&d->screen, SIGNAL(screenLocked()), this, SIGNAL(screenLocked())); connect(&d->screen, SIGNAL(screenUnlocked()), this, SIGNAL(screenUnlocked())); connect(&d->screen, SIGNAL(screenSaverStarted()), this, SIGNAL(screenSaverStarted())); connect(&d->screen, SIGNAL(screenSaverStopped()), this, SIGNAL(screenSaverStopped())); }
// Tray functions void MainWindow::setupTray() { trayIcon = new QSystemTrayIcon(this); trayIcon->setIcon(StatusIcon::getStatusIcon(UserStatus::Offline)); trayIcon->show(); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(onTrayIconActivated(QSystemTrayIcon::ActivationReason))); trayMenu = new QMenu(this); openTvAction = trayMenu->addAction(tr(OPEN_TV_MENU_ITEM)); connect(openTvAction, SIGNAL(triggered()), this, SLOT(showWindow())); trayMenu->addSeparator(); onlineAction = trayMenu->addAction(StatusIcon::getStatusIcon(UserStatus::Online), tr(ONLINE_MENU_ITEM)); connect(onlineAction, SIGNAL(triggered()), this, SLOT(relogon())); offlineAction = trayMenu->addAction(StatusIcon::getStatusIcon(UserStatus::Offline), tr(OFFLINE_MENU_ITEM)); connect(offlineAction, SIGNAL(triggered()), this, SLOT(offline())); networkSettingsAction = trayMenu->addAction(tr(NETWORK_SETTINGS_MENU_ITEM)); connect(networkSettingsAction, SIGNAL(triggered()), this, SLOT(showSettings())); trayMenu->addSeparator(); signOutAction = trayMenu->addAction(tr(SIGNOUT_MENU_ITEM)); connect(signOutAction, SIGNAL(triggered()), this, SLOT(logout())); exitAction = trayMenu->addAction(tr(EXIT_MENU_ITEM)); connect(exitAction, SIGNAL(triggered()), this, SLOT(shutDown())); }
void TorProtocolManager::setState(ProtocolManager::State state) { const auto old = state_; state_ = state; if (old != state_) { LFLOG_DEBUG << "TorProtocolManager changing state from " << getName(old) << " to " << getName(state); emit stateChanged(old, state_); switch(state) { case ProtocolManager::State::OFFLINE: emit offline(); break; case ProtocolManager::State::CONNECTING: emit connecting(); break; case ProtocolManager::State::CONNECTED: emit connected(); break; case ProtocolManager::State::ONLINE: emit online(); break; case ProtocolManager::State::SHUTTINGDOWN: emit shutdown(); break; } } }
bool MainWindow::logout(bool isShuttingDown) { if (isShuttingDown) { this->isShuttingDown = true; } offline(!isShuttingDown); if (isShuttingDown) { trayIcon->setVisible(false); hide(); } resetChildWindows(); buttonsFrame->hide(); saveSettings(); cleanup(); if(!isShuttingDown) { updateWindowTitle(); showLogonWidget(); } return true; }
void MainWindow::onServerError(ServerResponseHandler::ServerError error) { QMessageBox *messageDialog; QPushButton *installButton; QPushButton *cancelButton; switch(error) { case MoodBoxCustomServer::Disconnect: Q_ASSERT_X(INFOMANAGER->isUserOnline(), "MainWindow::onServerError", "User is offline, but got Disconnect"); offline(false); QMessageBox::information(this, tr(DISCONNECT_TITLE), tr(DISCONNECT_TEXT)); break; case MoodBoxCustomServer::UnsupportedClientVersion: offline(false); messageDialog = new QMessageBox(QMessageBox::Information, tr(NOT_SUPPORTED_TITLE), tr(NOT_SUPPORTED_TEXT)); installButton = messageDialog->addButton(tr(INSTALL_NEW_VERSION_BUTTON), QMessageBox::YesRole); cancelButton = messageDialog->addButton(tr(CANCEL_TEXT), QMessageBox::NoRole); messageDialog->exec(); if (messageDialog->clickedButton() == installButton) { startInstallNewVersion(); }; messageDialog->deleteLater(); break; case MoodBoxCustomServer::NotAuthenticated: Q_ASSERT_X(INFOMANAGER->isUserOnline() || isLoggingOn, "MainWindow::onServerError", "User is offline and not logging on, but got NotAuthenticated"); if(INFOMANAGER->isUserOnline() || isLoggingOn) { relogon(); } break; case MoodBoxCustomServer::NotificationServerRegistrationFailed: Q_ASSERT_X(INFOMANAGER->isUserOnline() || isLoggingOn, "MainWindow::onServerError", "User is offline and not logging on, but got NotificationServerRegistrationFailed"); if(INFOMANAGER->isUserOnline() || isLoggingOn) { relogon(); } break; } }
void RenderAf::deregister( JobContainer * jobs, MonitorContainer * monitoring ) { if( isOffline()) { appendLog("Render deregister request - offline already."); return; } appendLog("Render deregister request."); offline( jobs, af::TaskExec::UPRenderDeregister, monitoring); }
void anonymous_hugepage(char *name, int flags) { char buf[100]; char *p = alloc_anonymous_hugepage(HPS, 1); printf("anonymous hugepage\n"); *(volatile int *)p = 1; offline(ndesc(buf, "anonymous hugepage", name), p); *(volatile int *)p = 1; free_anonymous_hugepage(p, HPS); }
void anonymous(char *name, int flags) { char buf[100]; char *p = checked_mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|flags, 0, 0); printf("anonymous\n"); *(volatile int *)p = 1; offline(ndesc(buf, "anonymous", name), p); *(volatile int *)p = 1; munmap(p, PS); }
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { char subcmd = toupper(parameters[0][0]); if (subcmd == '+') { if (parameters.size() > 1) HandlePlus(user, parameters[1]); } else if (subcmd == '-') { if (parameters.size() > 1) HandleMinus(user, parameters[1]); } else if (subcmd == 'C') { manager.UnwatchAll(user); } else if (subcmd == 'L') { user->CommandFloodPenalty += ListPenalty; const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); ReplyBuilder out(user, RPL_MONLIST); for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i) { IRCv3::Monitor::Entry* entry = *i; out.Add(entry->GetNick()); } out.Flush(); user->WriteNumeric(RPL_ENDOFMONLIST, "End of MONITOR list"); } else if (subcmd == 'S') { user->CommandFloodPenalty += ListPenalty; ReplyBuilder online(user, RPL_MONONLINE); ReplyBuilder offline(user, RPL_MONOFFLINE); const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i) { IRCv3::Monitor::Entry* entry = *i; ReplyBuilder& out = (IRCv3::Monitor::Manager::FindNick(entry->GetNick()) ? online : offline); out.Add(entry->GetNick()); } online.Flush(); offline.Flush(); } else return CMD_FAILURE; return CMD_SUCCESS; }
void shm_hugepage(char *name, int flags) { int shmid = 0; char buf[100]; char *p = alloc_shm_hugepage(&shmid, HPS); if (!p) errmsg("failed in alloc_shm_hugepage\n"); printf("shm hugepage\n"); *(volatile int *)p = 1; offline(ndesc(buf, "shm hugepage", name), p); *(volatile int *)p = 1; free_shm_hugepage(shmid, p); }
void disk_backed(char *name, int flags) { char fn[100]; snprintf(fn, sizeof fn, TMPDIR "~test%u", getpid()); printf("shared, diskbacked\n"); int fd = open(fn, O_RDWR|O_CREAT|O_TRUNC, 0644); if (fd < 0) err("open tmpfile"); write(fd, empty, sizeof empty); char *p = checked_mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_SHARED|flags, fd, 0); *(volatile int *)p = 1; offline(ndesc(fn, "disk backed", name), p); munmap(p, PS); }
void filebacked_hugepage(char *name, int flags) { int fd; char path[100]; char fn[100]; snprintf(path, sizeof path, "%s/~test-hugepage%u", hugetlbfsdir, getpid()); char *p = alloc_filebacked_hugepage(path, HPS, 0, &fd); printf("file backed hugepage\n"); *(volatile int *)p = 1; offline(ndesc(fn, "file backed hugepage", name), p); *(volatile int *)p = 1; free_filebacked_hugepage(p, HPS, fd, path); }
// Child windows functions void MainWindow::createChildWindows() { currentRecipient = ALL_FRIENDS_ID; // Creating drawing window drawingWindow = new DrawingWindow(this); connect(drawingWindow, SIGNAL(clipartWindowRequest()), this, SLOT(onShowClipart())); connect(drawingWindow, SIGNAL(messageSent()), this, SLOT(onMessageSent())); connect(drawingWindow, SIGNAL(replyChanged()), tvWidget, SLOT(replyChanged())); drawingWindow->updatePosition(this); historyWindow = new HistoryWindow(this); historyWindow->setTvWidget(tvWidget); connect(historyWindow, SIGNAL(beginOfPreview(const MessageKey &)), tvWidget, SLOT(showHistoryMessage(const MessageKey &))); connect(historyWindow, SIGNAL(endOfPreview()), tvWidget, SLOT(stopShowingHistory())); connect(historyWindow, SIGNAL(clicked(const MessageKey &)), tvWidget, SLOT(scrollToMessage(const MessageKey &))); connect(historyWindow, SIGNAL(deleteMessages(const QList<MessageKey> &)), tvWidget, SLOT(deleteMessages(const QList<MessageKey> &))); connect(historyWindow, SIGNAL(saveMessage()), tvWidget, SLOT(saveMessage())); connect(historyWindow, SIGNAL(copyMessage()), tvWidget, SLOT(copyMessage())); connect(tvWidget, SIGNAL(publishRequest(const MessageKey &)), historyWindow, SLOT(publishMessage(const MessageKey &))); historyWindow->updatePosition(this); contactList = new NewContactListWindow(this); contactList->updatePosition(this); contactList->initAutoUpdater(&autoUpdater); // Connect menu signals connect(contactList, SIGNAL(goOnline()), this, SLOT(relogon())); connect(contactList, SIGNAL(goOffline()), this, SLOT(offline())); connect(contactList, SIGNAL(goLogout()), this, SLOT(logout())); connect(contactList, SIGNAL(goExit()), this, SLOT(shutDown())); connect(contactList, SIGNAL(contactSelected(qint32)), this, SLOT(onContactSelected(qint32))); connect(contactList, SIGNAL(contactImageDrop(qint32, const QImage &)), this, SLOT(onContactImageDrop(qint32, const QImage &))); connect(contactList, SIGNAL(soundStateChanged(const bool)), this, SLOT(onSoundStateChanged(const bool))); connect(contactList, SIGNAL(unreadContacts(int)), contactListButton, SLOT(update(int))); #ifdef Q_WS_MAC connect(contactList, SIGNAL(unreadContacts(int)), DockIconHandler::instance(), SLOT(unreadCountChanged(int))); #endif connect(contactList, SIGNAL(historyCleared()), tvWidget, SLOT(reload())); connect(welcomeWidget, SIGNAL(showProfileDialog()), contactList, SLOT(onShowProfileDialog())); connect(welcomeWidget, SIGNAL(showFindFriendsDialog()), contactList, SLOT(onShowFindDialog())); }
void ChatClient::clientStateChanged(int state, int previousState) { if (previousState == Online) emit offline(); if (state == Online) { if (!m_id.isEmpty() && m_id != serverId()) { server()->data().clear(); server()->feeds().clear(); channel()->data().clear(); channel()->feeds().clear(); } m_id = serverId(); emit online(); } }
bool DEVICE::offline_or_rewind() { if (m_fd < 0) { return false; } if (has_cap(CAP_OFFLINEUNMOUNT)) { return offline(); } else { /* * Note, this rewind probably should not be here (it wasn't * in prior versions of Bareos), but on FreeBSD, this is * needed in the case the tape was "frozen" due to an error * such as backspacing after writing and EOF. If it is not * done, all future references to the drive get and I/O error. */ clrerror(MTREW); return rewind(NULL); } }
void HandlePlus(LocalUser* user, const std::string& input) { ReplyBuilder online(user, RPL_MONONLINE); ReplyBuilder offline(user, RPL_MONOFFLINE); irc::commasepstream ss(input); for (std::string nick; ss.GetToken(nick); ) { IRCv3::Monitor::Manager::WatchResult result = manager.Watch(user, nick, maxmonitor); if (result == IRCv3::Monitor::Manager::WR_TOOMANY) { // List is full, send error which includes the remaining nicks that were not processed user->WriteNumeric(ERR_MONLISTFULL, maxmonitor, InspIRCd::Format("%s%s%s", nick.c_str(), (ss.StreamEnd() ? "" : ","), ss.GetRemaining().c_str()), "Monitor list is full"); break; } else if (result != IRCv3::Monitor::Manager::WR_OK) continue; // Already added or invalid nick ReplyBuilder& out = (IRCv3::Monitor::Manager::FindNick(nick) ? online : offline); out.Add(nick); } online.Flush(); offline.Flush(); }
int MoodBox::MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: onUserAccountUpdated(); break; case 1: onUserStatusChanged((*reinterpret_cast< UserStatus::UserStatusEnum(*)>(_a[1]))); break; case 2: onServerError((*reinterpret_cast< ServerResponseHandler::ServerError(*)>(_a[1]))); break; case 3: onShowExceptionDialogSendingMessage((*reinterpret_cast< ContactResultCode::ContactResultCodeEnum(*)>(_a[1])),(*reinterpret_cast< qint32(*)>(_a[2]))); break; case 4: onLogonStarted(); break; case 5: onLogonStopped(); break; case 6: onLogonSuccess(); break; case 7: showWindow(); break; case 8: shutDown(); break; case 9: onLogoutCompleted(); break; case 10: relogon(); break; case 11: offline((*reinterpret_cast< bool(*)>(_a[1]))); break; case 12: offline(); break; case 13: { bool _r = logout((*reinterpret_cast< bool(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 14: { bool _r = logout(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 15: showSettings(); break; case 16: ipcMessage((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 17: addFriendByLogin(); break; case 18: forceQuit(); break; case 19: onTrayIconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break; case 20: on_contactListButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break; case 21: on_drawButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break; case 22: on_historyButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break; case 23: onDownloadNewVersion(); break; case 24: onInviteCodeAccepted(); break; case 25: onRegistrationSuccess(); break; case 26: onResetPassword(); break; case 27: onShowClipart(); break; case 28: onReply((*reinterpret_cast< const QImage(*)>(_a[1]))); break; case 29: showTvWidget(); break; case 30: showLogonWidget((*reinterpret_cast< bool(*)>(_a[1]))); break; case 31: showLogonWidget(); break; case 32: showInviteCodeWidget(); break; case 33: showRegistrationWidget(); break; case 34: showForgotPasswordWidget(); break; case 35: showInfoWidget(); break; case 36: showWaitingWidget(); break; case 37: stopWaitingWidget(); break; case 38: hideWaitingWidget(); break; case 39: cancelWaitingWidget(); break; case 40: onRegistrationBack(); break; case 41: onInviteCodeNeeded(); break; case 42: onContactSelected((*reinterpret_cast< qint32(*)>(_a[1]))); break; case 43: onContactImageDrop((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const QImage(*)>(_a[2]))); break; case 44: onSoundStateChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 45: onPrivateMessageReceived((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const MessageKey(*)>(_a[2]))); break; case 46: onChannelMessageReceived((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const MessageKey(*)>(_a[2]))); break; case 47: onFriendsMessageReceived((*reinterpret_cast< const MessageKey(*)>(_a[1]))); break; case 48: onMessageSent(); break; case 49: showHelp(); break; case 50: requestFinished((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break; case 51: dataProcessedProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break; case 52: cancelHttpRequest(); break; default: ; } _id -= 53; } return _id; }
int vtape::tape_op(struct mtop *mt_com) { int result=0; int count = mt_com->mt_count; if (!online) { errno = ENOMEDIUM; return -1; } switch (mt_com->mt_op) { case MTRESET: case MTNOP: case MTSETDRVBUFFER: break; default: case MTRAS1: case MTRAS2: case MTRAS3: case MTSETDENSITY: errno = ENOTTY; result = -1; break; case MTFSF: /* Forward space over mt_count filemarks. */ do { result = fsf(); } while (--count > 0 && result == 0); break; case MTBSF: /* Backward space over mt_count filemarks. */ do { result = bsf(); } while (--count > 0 && result == 0); break; case MTFSR: /* Forward space over mt_count records (tape blocks). */ /* file number = 1 block number = 0 file number = 1 block number = 1 mt: /dev/lto2: Erreur d'entree/sortie file number = 2 block number = 0 */ /* tester si on se trouve a la fin du fichier */ result = fsr(mt_com->mt_count); break; case MTBSR: /* Backward space over mt_count records (tape blocks). */ result = bsr(mt_com->mt_count); break; case MTWEOF: /* Write mt_count filemarks. */ do { result = weof(); } while (result == 0 && --count > 0); break; case MTREW: /* Rewind. */ Dmsg0(dbglevel, "rewind vtape\n"); check_eof(); atEOF = atEOD = false; atBOT = true; current_file = 0; current_block = 0; lseek(fd, 0, SEEK_SET); result = !read_fm(VT_READ_EOF); break; case MTOFFL: /* put tape offline */ result = offline(); break; case MTRETEN: /* Re-tension tape. */ result = 0; break; case MTBSFM: /* not used by bareos */ errno = EIO; result = -1; break; case MTFSFM: /* not used by bareos */ errno = EIO; result = -1; break; case MTEOM:/* Go to the end of the recorded media (for appending files). */ while (next_FM) { lseek(fd, next_FM, SEEK_SET); if (read_fm(VT_READ_EOF)) { current_file++; } } boffset_t l; while (::read(fd, &l, sizeof(l)) > 0) { if (l) { lseek(fd, l, SEEK_CUR); } else { ASSERT(0); } Dmsg0(dbglevel, "skip 1 block\n"); } current_block = -1; atEOF = false; atEOD = true; /* file number = 3 block number = -1 */ /* Can be at EOM */ break; case MTERASE: /* not used by bareos */ atEOD = true; atEOF = false; atEOT = false; current_file = 0; current_block = -1; lseek(fd, 0, SEEK_SET); read_fm(VT_READ_EOF); truncate_file(); break; case MTSETBLK: break; case MTSEEK: break; case MTTELL: break; case MTFSS: break; case MTBSS: break; case MTWSM: break; case MTLOCK: break; case MTUNLOCK: break; case MTLOAD: break; case MTUNLOAD: break; case MTCOMPRESSION: break; case MTSETPART: break; case MTMKPART: break; } return result == 0 ? 0 : -1; }
void *accepted(void *csd){ PEER *p = (PEER *) csd; DATA *data = malloc(sizeof(DATA)); DATA *reply = malloc(sizeof(DATA)); int client_sd = p->client_sd; int len, status; int id = p->id; while(1){ printf("B4 recv data\n"); data = recv_data(client_sd,(unsigned int *)&len,&status); printf("AFTER recv data\n"); switch(status){ case -1: case -2: printf("Status = error(%d)\n", status); close(client_sd); offline(id); printf("[Disconnected] Client %s:%d\n", getClientAddr(&p->client_addr), ntohs(p->client_addr.sin_port)); return 0; default: break; } printf("DATA command: %d\n", data->command); switch(data->command){ case LOGIN: printf("Client %s:%d: [LOGIN] Username="******"\n"); data->arg->ip = ntohl(p->client_addr.sin_addr.s_addr); status = online(data->arg, id); if(status >= 0 && status < 10){ reply = newHeader(); reply->command = LOGIN_OK; reply->length = 1; if(!send_data(client_sd,reply,(unsigned int*)&len)) return 0; }else{ printf("[ERROR] Client %s:%d ", getClientAddr(&p->client_addr), ntohs(p->client_addr.sin_port)); reply = newHeader(); reply->command = ERROR; switch(status){ case -1: printf("maximum connection exceed!"); reply->error = TOO_MUCH_CONN; break; case -2: printf("duplication of name!"); reply->error = SAME_NAME; break; case -3: printf("duplication of port and IP address!"); reply->error = SAME_CONN; } printf("\n"); reply->length = 7; if(!send_data(client_sd,reply,(unsigned int*)&len)) return 0; close(client_sd); printf("[Disconnected] Client %s:%d\n", getClientAddr(&p->client_addr), ntohs(p->client_addr.sin_port)); return 0; } break; case GET_LIST: printf("Client %s:%d: GET_LIST\n", getClientAddr(&p->client_addr), ntohs(p->client_addr.sin_port)); reply = newHeader(); reply->command = GET_LIST_OK; getOnlineList(reply); reply->length += 7; if(!send_data(client_sd,reply,(unsigned int*)&len)) return 0; break; default: printf("Client %s:%d: Unknown command\n", getClientAddr(&p->client_addr), ntohs(p->client_addr.sin_port)); break; } } if(client_sd) close(client_sd); offline(id); printOnlineList(); printf("[Disconnected] Client %s:%d\n", getClientAddr(&p->client_addr), p->client_addr.sin_port); }
void RenderAf::v_action( Action & i_action) { const JSON & operation = (*i_action.data)["operation"]; if( operation.IsObject()) { std::string type; af::jr_string("type", type, operation); if( type == "exit") { if( false == isOnline()) return; appendLog("Exit by " + i_action.author); exitClient("exit", i_action.jobs, i_action.monitors); return; } else if( type == "launch_cmd") { if( false == isOnline()) return; std::string cmd; if( af::jr_string("cmd", cmd, operation)) { bool exit = false; af::jr_bool("exit", exit, operation); if( exit ) appendLog("Launch command and exit request by " + i_action.author + "\n" + cmd); else appendLog("Launch command request by " + i_action.author + "\n" + cmd); launchAndExit( cmd, exit, i_action.jobs, i_action.monitors); } else { appendLog("Launch command exit request by " + i_action.author + "has no 'cmd'"); } return; } else if( type == "eject_tasks") { if( false == isBusy()) return; appendLog("Task(s) ejected by " + i_action.author); ejectTasks( i_action.jobs, i_action.monitors, af::TaskExec::UPEject); return; } else if( type == "eject_tasks_keep_my") { if( false == isBusy()) return; appendLog("Task(s) ejected keeping own by " + i_action.author); ejectTasks( i_action.jobs, i_action.monitors, af::TaskExec::UPEject, &i_action.user_name); return; } else if( type == "delete") { if( isOnline() ) return; appendLog( std::string("Deleted by ") + i_action.author); offline( NULL, 0, i_action.monitors, true); //AFCommon::QueueDBDelItem( this); return; } else if( type == "reboot") { if( false == isOnline() ) return; appendLog( std::string("Reboot computer by ") + i_action.author); exitClient("reboot", i_action.jobs, i_action.monitors); return; } else if( type == "shutdown") { if( false == isOnline() ) return; appendLog( std::string("Shutdown computer by ") + i_action.author); exitClient("shutdown", i_action.jobs, i_action.monitors); return; } else if( type == "wol_sleep") wolSleep( i_action.monitors); else if( type == "wol_wake") wolWake( i_action.monitors); else if( type == "service") { af::RegExp service_mask; bool enable; af::jr_regexp("name", service_mask, operation); af::jr_bool("enable", enable, operation); for (int i = 0 ; i < m_host.getServicesNum() ; ++i) { std::string service = m_host.getServiceName(i); if( service_mask.match( service)) setService( service, enable); } } else if( type == "restore_defaults") { m_max_tasks = -1; m_capacity = -1; m_services_disabled.clear(); disableServices(); // Dirty check exists in that function } else { appendLog("Unknown operation \"" + type + "\" by " + i_action.author); return; } appendLog("Operation \"" + type + "\" by " + i_action.author); i_action.monitors->addEvent( af::Monitor::EVT_renders_change, m_id); store(); return; } const JSON & params = (*i_action.data)["params"]; if( params.IsObject()) jsonRead( params, &i_action.log); if( i_action.log.size() ) { store(); i_action.monitors->addEvent( af::Monitor::EVT_renders_change, m_id); } }
void MainWindow::relogon() { offline(false); logonWidget->relogon(); }
void RenderAf::v_refresh( time_t currentTime, AfContainer * pointer, MonitorContainer * monitoring) { if( isLocked() ) return; JobContainer * jobs = (JobContainer*)pointer; if( isOnline() && (getTimeUpdate() < (currentTime - af::Environment::getRenderZombieTime()))) { appendLog( std::string("ZOMBIETIME: ") + af::itos(af::Environment::getRenderZombieTime()) + " seconds."); AFCommon::QueueLog( std::string("Render: \"") + getName() + "\" - ZOMBIETIME"); /* if( isBusy()) { printf("Was busy:\n"); for( std::list<af::TaskExec*>::iterator it = tasks.begin(); it != tasks.end(); it++) (*it)->stdOut(); }*/ offline( jobs, af::TaskExec::UPRenderZombie, monitoring); return; } // Later auto nimby operations not needed if render is not online: if( isOffline()) { m_busy_time = currentTime; m_idle_time = currentTime; return; } // Update busy with no task time: if(( isFree() == false ) || isBusy()) // already nimby or has task(s) { m_busy_time = currentTime; } else { int cpu=0,mem=0,swp=0,hgb=0,hio=0,net=0; // CPU % busy: if(( m_host.m_nimby_busy_cpu <= 0 ) || (( 100 - m_hres.cpu_idle ) < m_host.m_nimby_busy_cpu )) cpu = 1; // Mem % used: if(( m_hres.mem_total_mb <= 0 ) || ( m_host.m_nimby_busy_mem <= 0 ) || (( 100 * ( m_hres.mem_total_mb - m_hres.mem_free_mb ) / m_hres.mem_total_mb ) < m_host.m_nimby_busy_mem )) mem = 1; // Swap % used: if(( m_hres.swap_total_mb <= 0 ) || (( m_host.m_nimby_busy_swp <= 0 ) || ( 100 * m_hres.swap_used_mb / m_hres.swap_total_mb ) < m_host.m_nimby_busy_swp )) swp = 1; // Hdd free GB: if(( m_hres.hdd_total_gb <= 0 ) || ( m_host.m_nimby_busy_hddgb <= 0 ) || ( m_hres.hdd_free_gb > m_host.m_nimby_busy_hddgb )) hgb = 1; // Hdd I/O %: if(( m_host.m_nimby_busy_hddio <= 0 ) || ( m_hres.hdd_busy < m_host.m_nimby_busy_hddio )) hio = 1; // Net Mb/s: if(( m_host.m_nimby_busy_netmbs <= 0 ) || ( m_hres.net_recv_kbsec + m_hres.net_send_kbsec < 1024 * m_host.m_nimby_busy_netmbs )) net = 1; // Render will be treated as 'not busy' if all params are 'not busy' if( cpu & mem & swp & hio & hgb & net ) { m_busy_time = currentTime; } else if(( m_host.m_nimby_busyfree_time > 0 ) && ( currentTime - m_busy_time > m_host.m_nimby_busyfree_time )) { // Automatic Nimby ON: std::string log("Automatic Nimby: "); log += "\n Busy since: " + af::time2str( m_busy_time);// + " CPU >= " + af::itos( m_host.m_nimby_busy_cpu) + "%"; log += "\n Nimby busy free time = " + af::time2strHMS( m_host.m_nimby_busyfree_time, true ); appendLog( log); setNIMBY(); monitoring->addEvent( af::Monitor::EVT_renders_change, m_id); store(); } //printf("BUSY: %li-%li=%li\n", currentTime, m_busy_time, currentTime-m_busy_time); } // Update idle time: if( isBusy()) { m_idle_time = currentTime; } else if(( m_host.m_nimby_idle_cpu <= 0 ) && ( m_host.m_nimby_idle_mem <= 0 ) && ( m_host.m_nimby_idle_swp <= 0 ) && ( m_host.m_nimby_idle_hddgb <= 0 ) && ( m_host.m_nimby_idle_hddio <= 0 ) && ( m_host.m_nimby_idle_netmbs <= 0 )) { // If all params are 'off' there is no 'idle': m_idle_time = currentTime; } else { int cpu=0,mem=0,swp=0,hgb=0,hio=0,net=0; // CPU % busy: if(( m_host.m_nimby_idle_cpu > 0 ) && (( 100 - m_hres.cpu_idle) > m_host.m_nimby_idle_cpu )) cpu = 1; // Mem % used: if(( m_hres.mem_total_mb > 0 ) && ( m_host.m_nimby_idle_mem > 0 ) && (( 100 * ( m_hres.mem_total_mb - m_hres.mem_free_mb ) / m_hres.mem_total_mb ) > m_host.m_nimby_idle_mem )) mem = 1; // Swap % used: if(( m_hres.swap_total_mb ) && ( m_host.m_nimby_idle_swp > 0 ) && (( 100 * m_hres.swap_used_mb / m_hres.swap_total_mb ) > m_host.m_nimby_idle_swp )) swp = 1; // Hdd free GB: if(( m_hres.hdd_total_gb > 0 ) && ( m_host.m_nimby_idle_hddgb > 0 ) && ( m_hres.hdd_free_gb < m_host.m_nimby_idle_hddgb )) hgb = 1; // Hdd I/O %: if(( m_host.m_nimby_idle_hddio > 0 ) && ( m_hres.hdd_busy > m_host.m_nimby_idle_hddio )) hio = 1; // Net Mb/s: if(( m_host.m_nimby_idle_netmbs > 0 ) && ( m_hres.net_recv_kbsec + m_hres.net_send_kbsec > 1024 * m_host.m_nimby_idle_netmbs )) net = 1; // it will be treated as 'not idle' any param is 'not idle' if( cpu | mem | swp | hio | hgb | net ) { m_idle_time = currentTime; } else { // Automatic WOL sleep: if(( m_host.m_wol_idlesleep_time > 0 ) && isOnline() && ( isWOLSleeping() == false) && ( isWOLFalling() == false) && ( currentTime - m_idle_time > m_host.m_wol_idlesleep_time )) { std::string log("Automatic WOL Sleep: "); log += "\n Idle since: " + af::time2str( m_idle_time); log += "\n WOL idle sleep time = " + af::time2strHMS( m_host.m_wol_idlesleep_time, true ); appendLog( log); wolSleep( monitoring); } // Automatic Nimby Free: if(( m_host.m_nimby_idlefree_time > 0 ) && isOnline() && ( isNimby() || isNIMBY()) && ( currentTime - m_idle_time > m_host.m_nimby_idlefree_time )) { std::string log("Automatic Nimby Free: "); log += "\n Idle since: " + af::time2str( m_idle_time); log += "\n Nimby idle free time = " + af::time2strHMS( m_host.m_nimby_idlefree_time, true ); appendLog( log); setFree(); monitoring->addEvent( af::Monitor::EVT_renders_change, m_id); store(); } } //printf("IDLE: %li-%li=%li\n", currentTime, m_idle_time, currentTime-m_idle_time); } }
void MainWindow::onLogonStopped() // NOTE we will not reach here if got StopRequests fault reaction { offline(false); }
void Slave::startup() { registerBuiltinBurners(); loadEmbeddedPython(); LOG_5( "Slave::startup()" ); mHost = Host::currentHost(); mSpooler = new Spooler( this ); if( !mHost.isRecord() ) { if( mAutoRegister ) { LOG_3( "Slave::startup: no host record, auto-registering" ); mHost = Host::autoRegister(); } else { LOG_3( "Slave::startup: no host record, uh oh!" ); exit(-1); } } else mHost.updateHardwareInfo(); mHostStatus = mHost.hostStatus(); if( !mHostStatus.isRecord() ) { if( mAutoRegister ) { LOG_3( "Slave::startup: No host status record(are all your triggers installed?), creating one" ); mHostStatus.setHost( mHost ); mHostStatus.setOnline( 1 ); } else { LOG_3( "Slave::startup: no host status record, uh oh!" ); exit(-1); } } mHostStatus.setAvailableMemory( mHost.memory() ); mHostStatus.commit(); connect( Database::current()->connection(), SIGNAL( connectionLost() ), SLOT( slotConnectionLost() ) ); connect( Database::current()->connection(), SIGNAL( connected() ), SLOT( slotConnected() ) ); // The rest of the initialization is only for normal mode where we moniter and manipulate // the hosts status. In burn only mode we simply execute a job and exit if( mBurnOnlyJobAssignmentKey ) { burn( JobAssignment(mBurnOnlyJobAssignmentKey) ); return; } mService = Service::ensureServiceExists("Assburner"); // Start remote log server and set port in our Assburner HostService record RemoteLogServer * rls = new RemoteLogServer(); HostService hs = HostService::recordByHostAndService( mHost, mService ); if( hs.isRecord() && rls->tcpServer()->isListening() ) { hs.setRemoteLogPort( rls->tcpServer()->serverPort() ); hs.commit(); } // Set host version string. mHost.setAbVersion( "v" + QString(VERSION)); mHost.commit(); // Reset any frame assignments and set our host status // to ready. Do we need this anymore? The reaper // should now detect and re-assign frames if we are // offline, and this prevents a client-update from // happening when assburner starts. // // Nope, this doesn't f**k with the status, so it is // safe. It just clears fkeyJob to slaveFrames. And // returns any frames that have fkeyHost=this mHostStatus.returnSlaveFrames(); loadForbiddenProcesses(); mTimer = new QTimer( this ); connect( mTimer, SIGNAL( timeout() ), SLOT( loop() ) ); // Default 5000ms, min 200ms, max 600,000ms - 10 minutes mLoopTime = qMax( 200, qMin( 1000 * 60 * 10, Config::getInt( "assburnerLoopTime", 5000 ) ) ); // Default mLoopTime / 2, min 100ms, max mLoopTime mQuickLoopTime = qMax( 100, qMin( mLoopTime, Config::getInt( "assburnerQuickLoopTime", mLoopTime / 2 ) ) ); // Default 60 seconds, min 10 seconds. mPulsePeriod = qMax( 10, Config::getInt( "arsenalPulsePeriod", 600 ) ); // Default 60 seconds, min 10 seconds. mMemCheckPeriod = qMax( 10, Config::getInt( "abMemCheckPeriod", 60 ) ); IniConfig & c = config(); c.pushSection( "BackgroundMode" ); mBackgroundModeEnabled = c.readBool( "Enabled", true ); c.popSection(); // Pulse right away. pulse(); // We need to set our host status to offline when assburner quits connect( qApp, SIGNAL( aboutToQuit() ), SLOT( offlineFromAboutToQuit() ) ); if( mUseGui ) { mIdle = new Idle(); connect( mIdle, SIGNAL( secondsIdle( int ) ), SLOT( slotSecondsIdle( int ) ) ); mIdle->start(); } if( mHostStatus.slaveStatus() == "client-update-offline" ) offline(); else if( mHostStatus.slaveStatus() == "client-update" ) clientUpdate(); else { // Store the current status QString currentStatus = mHostStatus.slaveStatus(); // We run the host through the online method first online(); // Check if the old host status wasn't empty if( !currentStatus.isEmpty() ) { // Resume the state the host was in. LOG_3("Slave::startup() Resuming previous status of " + currentStatus); handleStatusChange(currentStatus, ""); } } // Create a timer for logged in user checks mUserTimer = new QTimer( this ); connect( mUserTimer, SIGNAL( timeout() ), SLOT( updateLoggedUsers() ) ); // Set it to trigger every 5 mins mUserTimer->start(300000); LOG_5( "Slave::startup() done" ); }
MissionWidget::MissionWidget(QWidget *parent, QString mName, JoystickWidget *joystick, Ui::NautilusCommander *gui, SendAction *sa) : QWidget(parent) { this->missionName=mName; this->ui=gui; m_sSettingsFile = QString("%1/%2/settings.ini").arg(createPath("Missions")).arg(missionName); loadSettings(); //Create Mission Folder. QString missionFolder=QString("%1/%2").arg(createPath("Missions")).arg(missionName); if(!QDir(missionFolder).exists()){ QDir().mkdir(missionFolder); } lblLightsOff=ui->label_switchOff; lblLightsOn=ui->label_switchOn; lblLightsOn->setVisible(false); islightsOn=false; righLeft=-1; upDown=-1; statusVideoOff=ui->statusVideoOff; statusVideoOff->setVisible(true); isRecording=false; lblScreenShot=ui->label_toastSS; lblScreenShot->setVisible(false); missionNameLabel=ui->lblMissionName; missionNameLabel->setText(missionName); batteryROVPB=ui->progressBattRov; panCamera=ui->panCamera; tiltCamera=ui->tiltCamera; statusErrorBox=ui->statusErrorBox; statusErrorBox->setVisible(false); lblError=ui->lblError; sendAction=sa; connect(this->sendAction,SIGNAL(offline()),this,SLOT(robotDisconnected())); status=checkStatus(); if(status!=-1) sendAction->sendComando(START_ROBOT); //ReEnable the robot /******************************** Joystick *****************************************************/ this->joystick=joystick; connect(joystick,SIGNAL(updateStatus(bool)),this,SLOT(updateControlStatus(bool))); connect(this->joystick,SIGNAL(joystickAxisEvent(QString,int)),this,SLOT(axisEvent(QString,int))); connect(this->joystick,SIGNAL(joystickButtonEvent(QString, QGameControllerButtonEvent*)),this,SLOT(buttonEvent(QString,QGameControllerButtonEvent*))); rtsp=new openRTSP(0,missionName,numVideos); connect(this,SIGNAL(saveVideo()),rtsp,SLOT(saveVideo())); dataThread=new DataThread(ui->progressBattControl, ui->progressBattRov,ui->labelDepthValue); dataThread->start(); mplayer=ui->mplayerWG; //connect(mplayer,SIGNAL(stateChanged(int)),this,SLOT(updatePlayerStatus(int))); mplayer->start(); mplayer->load("rtsp://*****:*****@10.5.5.110:554"); mplayer->setVisible(true); isCameraOnline=true; speedDial=ui->dial; speedDial->setNotchesVisible(false); speeds[0][0]=3;speeds[0][1]=10;speeds[0][2]=14;speeds[0][3]=20;//speeds[0][4]=13;//speeds[0][5]=15;speeds[0][6]=18;speeds[0][7]=22; speeds[1][0]=1580;speeds[1][1]=1610;speeds[1][2]=1640;speeds[1][3]=1670;//speeds[1][4]=1670; speeds[2][0]=1420;speeds[2][1]=1390;speeds[2][2]=1360;speeds[2][3]=1330;//speeds[2][4]=1330; y = 3000-x dialIndex=0; lastCommand=""; speedDial->setValue(speeds[0][0]); }