void RecognitionControl::run() { Q_ASSERT(recog); RecognitionConfiguration *cfg = setupConfig(); bool success = recog->init(cfg); delete cfg; if (!success) { emitError(i18n("Failed to setup recognition: %1", recog->getLastError())); return; } m_initialized=true; while (shouldBeRunning) { if (!queueLock.tryLock(500)) continue; QString file; if (!toRecognize.isEmpty()) file = toRecognize.dequeue(); queueLock.unlock(); if (file.isNull()) { QThread::msleep(100); } else { emit recognitionResult(file, recog->recognize(file)); emit recognitionDone(file); } } }
KUI_project::KUI_project(QWidget* parent): KMainWindow(parent) { model = 0; trayIcon = new KSystemTrayIcon("media-playback-stop", 0 ); connect(trayIcon, SIGNAL( activated(QSystemTrayIcon::ActivationReason)), this, SLOT( unhideSlot() ) ); path.append( QDir::homePath() ); recArea.setCoords( 0, 0, 0, 0); setupConfig(); this->resize( 700, 300 ); collection = new KActionCollection(this); setupCentralWidget(); menuBar = new KMenuBar; setupMenuFile(); setupMenuWindow(); setupMenuSettings(); menuBar->addMenu(helpMenu()); this->setMenuBar(menuBar); setupActions(); KToolBar *tools = new KToolBar(i18n("&Tools"), this); tools->addAction(collection->action("new_file")); tools->addAction(collection->action("open_file")); tools->addAction(collection->action("add")); collection->action("add")->setEnabled( false ); tools->addAction(collection->action("remove")); collection->action("remove")->setEnabled( false ); //tools->addAction(collection->action("save_file")); tools->setToolButtonStyle(Qt::ToolButtonIconOnly); playBar = new MainToolBar( collection, this); playBar->setAccessibleDescription("Play Bar"); this->addToolBar(Qt::BottomToolBarArea, playBar); connect( playBar->timeSlider, SIGNAL( sliderMoved(int) ), this, SLOT( seekSlot(int) ) ); }
/** * Startet den Server */ void Server::run() { std::cout << "Starting Mineserv" << std::endl;; std::cout << "Reading config file" << std::endl; setupConfig(); motd = getValue<std::string>("Server.motd"); maxplayers = getValue<int>("Server.maxplayers"); std::cout << "Searching for worlds" << std::endl; std::ifstream ifile((getValue<std::string>("Server.world") + "/level.dat").c_str(), std::ifstream::in); if (!ifile) { std::cout << "No level.dat found in world directory: " << std::endl; std::cout << getValue<std::string>("Server.world") << std::endl; std::cout << "Aborting" << std::endl; return; } World* world = new World(this, getValue<std::string>("Server.world")); //World* world = new World(this); worlds.push_back(world); world->initWorld(); world->startTickThread(); std::cout << "Loaded " << worlds.size() << " world(s)" << std::endl; curId = 0; // starting network: boost::asio::io_service io_service; boost::asio::ip::tcp::acceptor acceptor(io_service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), getValue<int>("Server.port"))); boost::thread tick(&Server::tickThread, this); std::cout << "Server started on port " << getValue<int>("Server.port") << std::endl; while(true) { boost::asio::ip::tcp::socket* sock = new boost::asio::ip::tcp::socket(io_service); acceptor.accept(*sock); boost::asio::ip::tcp::endpoint remote_ep = sock->remote_endpoint(); boost::thread connection(&createCon, sock, this, remote_ep.address().to_string()); } }
TonalChangeDetect::TonalChangeDetect(float fInputSampleRate) : Vamp::Plugin(fInputSampleRate), m_chromagram(0), m_step(0), m_block(0), m_stepDelay(0), m_origin(Vamp::RealTime::zeroTime), m_haveOrigin(false) { m_minMIDIPitch = 32; m_maxMIDIPitch = 108; m_tuningFrequency = 440; m_iSmoothingWidth = 5; setupConfig(); }
void TonalChangeDetect::setParameter(std::string param, float value) { if (param == "minpitch") { m_minMIDIPitch = lrintf(value); } else if (param == "maxpitch") { m_maxMIDIPitch = lrintf(value); } else if (param == "tuning") { m_tuningFrequency = value; } else if (param == "smoothingwidth") { m_iSmoothingWidth = int(value); } else { std::cerr << "WARNING: ChromagramPlugin::setParameter: unknown parameter \"" << param << "\"" << std::endl; } setupConfig(); }
int Supplicant::start() { if (setupConfig()) { LOGW("Unable to setup supplicant.conf"); } if (mServiceManager->start(SUPPLICANT_SERVICE_NAME)) { LOGE("Error starting supplicant (%s)", strerror(errno)); return -1; } wpa_ctrl_cleanup(); if (connectToSupplicant()) { LOGE("Error connecting to supplicant (%s)\n", strerror(errno)); return -1; } if (retrieveInterfaceName()) { LOGE("Error retrieving interface name (%s)\n", strerror(errno)); return -1; } return 0; }
int XzeroDaemon::run() { ::signal(SIGPIPE, SIG_IGN); unsigned generation = 1; if (const char* v = getenv("XZERO_UPGRADE")) { generation = atoi(v) + 1; unsetenv("XZERO_UPGRADE"); } #if defined(HAVE_SYSLOG_H) x0::SyslogSink::open("x0d", LOG_PID | LOG_NDELAY, LOG_DAEMON); #endif if (!parse()) return 1; eventHandler_ = new XzeroEventHandler(this, ev::default_loop(evFlags_)); server_ = new x0::HttpServer(eventHandler_->loop(), generation); // Load core plugins registerPlugin(core_ = new XzeroCore(this)); #ifndef XZERO_NDEBUG server_->logLevel(x0::Severity::debug3); #endif if (systemd_) { nofork_ = true; server_->setLogger(std::make_shared<x0::SystemdLogger>()); } else { if (logTarget_ == "file") { if (!logFile_.empty()) { auto logger = std::make_shared<x0::FileLogger>(logFile_, [this]() { return static_cast<time_t>(ev_now(server_->loop())); }); if (logger->handle() < 0) { fprintf(stderr, "Could not open log file '%s': %s\n", logFile_.c_str(), strerror(errno)); return 1; } server_->setLogger(logger); } else { server_->setLogger(std::make_shared<x0::SystemLogger>()); } } else if (logTarget_ == "console") { server_->setLogger(std::make_shared<x0::ConsoleLogger>()); } else if (logTarget_ == "syslog") { server_->setLogger(std::make_shared<x0::SystemLogger>()); } else if (logTarget_ == "systemd") { server_->setLogger(std::make_shared<x0::SystemdLogger>()); } } server_->logger()->setLevel(logLevel_); if (!setupConfig()) { log(x0::Severity::error, "Could not start x0d."); return -1; } unsetenv("XZERO_LISTEN_FDS"); if (dumpIR_) dumpIR(); if (!nofork_) daemonize(); if (!createPidFile()) return -1; if (group_.empty()) group_ = user_; if (!drop_privileges(user_, group_)) return -1; if (showGreeter_) { printf("\n\n" "\e[1;37m" " XXXXXXXXXXX\n" " XX XX XX XX\n" " XX XX XX XX\n" " XX XX XX XX\n" " XXX XX 0 XX - Web Server\n" " XX XX XX XX Version " PACKAGE_VERSION "\n" " XX XX XX XX\n" " XX XX XX XX\n" " XXXXXXXXXXX\n" "\n" " " PACKAGE_HOMEPAGE_URL "\e[0m" "\n\n" ); } eventHandler_->setState(XzeroState::Running); int rv = server_->run(); // remove PID-file, if exists and not in systemd-mode if (!systemd_ && !pidfile_.empty()) unlink(pidfile_.c_str()); return rv; }
/****************************************************** actEditCallback ******************************************************/ static void actEditCallback(Widget widget, XtPointer calldata, XtPointer cbs) { int item=(long)calldata; ALINK *area; GCLINK *link; GCLINK *next; GCLINK *configLink; int linkType; int command; GCLINK *tempLink; int tempLinkType; struct anyLine *treeLine; struct anyLine *groupLine; XtVaGetValues(widget, XmNuserData, &area, NULL); switch (item){ case MENU_EDIT_CLEAR: if (area->changed){ /* Display the config_changed warning dialog */ createActionDialog(area->form_main,XmDIALOG_WARNING, "Latest configuration changes have not been saved. Continue?" , (XtCallbackProc)actEditCallback, (XtPointer)MENU_EDIT_CLEAR_OK,(XtPointer)area); break; } case MENU_EDIT_CLEAR_OK: editUndoSet((GCLINK *)sllFirst(area->pmainGroup), GROUP, NULL, MENU_EDIT_UNDO_CLEAR, ALH_DELETE); area->managed = FALSE; area->pmainGroup->p1stgroup = NULL; setupConfig("",ACT,area); break; case MENU_EDIT_CUT: if (checkActiveSelection(area) ) break; if (checkActiveSelectionMainGroup(area) ) break; link = (GCLINK *)area->selectionLink; linkType = area->selectionType; editClipboardSet(link, linkType); editUndoSet(link, linkType, NULL, MENU_EDIT_UNDO_PASTE, ALH_DELETE); editCutLink(area,link,linkType); break; case MENU_EDIT_COPY: if (checkActiveSelection(area) ) break; link = (GCLINK *)area->selectionLink; linkType = area->selectionType; editClipboardSet(link, linkType); break; case MENU_EDIT_PASTE: if (checkActiveSelection(area) ) break; editClipboardGet(&link, &linkType); if (link) editPasteLink(area,link,linkType); break; case MENU_EDIT_UNDO: command = editUndoGetCommand(); switch (command){ case MENU_EDIT_UNDO_UPDATE_CLIPBOARD: editClipboardGet(&tempLink, &tempLinkType); editUndoGet(&link, &linkType, &configLink); editClipboardSet(link, linkType); editUndoSet(tempLink, tempLinkType, NULL, MENU_EDIT_UNDO_UPDATE_CLIPBOARD, KEEP); break; case MENU_EDIT_UNDO_PASTE: editUndoGet(&link, &linkType, &tempLink); next = (GCLINK *)sllNext((SNODE*)link); if (next){ ((struct subWindow *)area->groupWindow)->selectionLink=next; area->selectionLink=next; area->selectionType=linkType; area->selectionWindow=area->groupWindow; } else { ((struct subWindow *)area->treeWindow)->selectionLink=link->parent; area->selectionLink=link->parent; area->selectionType=GROUP; area->selectionWindow=area->treeWindow; } editPasteLink(area,link,linkType); /* restore selection */ groupLine = (struct anyLine *)link->lineGroupW; treeLine = (struct anyLine *)link->lineTreeW; if (groupLine){ markSelectedWidget( area->groupWindow, ((WLINE *)groupLine->wline)->name); markSelection( area->groupWindow, groupLine); } else if (treeLine) { markSelectedWidget( area->treeWindow, ((WLINE *)treeLine->wline)->name); markSelection( area->treeWindow, treeLine); } /* update dialog windows */ axUpdateDialogs(area); /* update undo values */ editUndoSet(NULL, linkType, link, MENU_EDIT_UNDO_CUT, KEEP); break; case MENU_EDIT_UNDO_PASTE_NOSELECT: editUndoGet(&link, &linkType, &tempLink); editPasteLink(area,link,linkType); /* update dialog windows */ axUpdateDialogs(area); /* update undo values */ editUndoSet(NULL, linkType, link, MENU_EDIT_UNDO_CUT_NOSELECT, KEEP); break; case MENU_EDIT_UNDO_CUT: if (checkActiveSelection(area) ) break; if (checkActiveSelectionMainGroup(area) ) break; link = (GCLINK *)area->selectionLink; linkType = area->selectionType; editClipboardSet(link, linkType); editUndoSet(link, linkType, NULL, MENU_EDIT_UNDO_PASTE, KEEP); editCutLink(area,link,linkType); break; case MENU_EDIT_UNDO_CUT_NOSELECT: editUndoGet(&tempLink, &linkType, &link); editCutLink(area, link, linkType); editUndoSet(link, linkType, NULL, MENU_EDIT_UNDO_PASTE_NOSELECT, KEEP); /* update dialog windows */ axUpdateDialogs(area); break; case MENU_EDIT_UNDO_PROPERTIES: propUndo(area); break; case MENU_EDIT_UNDO_CLEAR: link = (GCLINK *)sllFirst(area->pmainGroup); editUndoGet(&tempLink, &linkType, &configLink); area->pmainGroup->p1stgroup = (GLINK *)tempLink; editUndoSet(link, GROUP, 0, MENU_EDIT_UNDO_CLEAR, KEEP); setParentLink(area->treeWindow,area->pmainGroup->p1stgroup); setParentLink(area->groupWindow,area->pmainGroup->p1stgroup); ((struct subWindow *)area->treeWindow)->viewOffset = 0; setViewConfigCount(area->treeWindow,area->pmainGroup->p1stgroup->viewCount); /* redraw main windows */ redraw(area->treeWindow,0); defaultTreeSelection(area); /* update dialog windows */ axUpdateDialogs(area); break; default: createDialog(area->form_main,XmDIALOG_INFORMATION, "Selection not implemented yet."," "); break; } break; default: createDialog(area->form_main,XmDIALOG_INFORMATION,"Selection not implemented yet."," "); break; } }
/****************************************************** actFileCallback ******************************************************/ static void actFileCallback(Widget widget, XtPointer calldata, XtPointer cbs) { ALINK *area; int item=(long)calldata; XtVaGetValues(widget, XmNuserData, &area, NULL); switch (item){ case MENU_FILE_NEW: break; case MENU_FILE_OPEN: /* Display the config_changed warning dialog */ if (area->changed){ createActionDialog(area->form_main,XmDIALOG_WARNING, "Latest configuration changes have not been saved. Continue?" , (XtCallbackProc)actFileCallback,(XtPointer)MENU_FILE_OPEN_OK,(XtPointer)area); break; } area->managed = FALSE; createFileDialog(area->form_main,(void *)fileSetupCallback, (XtPointer)FILE_CONFIG,(void *)fileCancelCallback, (XtPointer)area, (XtPointer)area, "Config File",CONFIG_PATTERN,psetup.configDir); break; case MENU_FILE_OPEN_OK: area->managed = FALSE; createFileDialog(area->form_main,(void *)fileSetupCallback, (XtPointer)FILE_CONFIG,(void *)fileCancelCallback, (XtPointer)area, (XtPointer)area, "Config File",CONFIG_PATTERN,psetup.configDir); break; case MENU_FILE_CLOSE: break; case MENU_FILE_CLOSEALL: break; case MENU_FILE_SAVEAS: /* New Name for Save Config File */ createFileDialog(area->form_main,(void *)fileSetupCallback, (XtPointer)FILE_SAVEAS,(void *)XtUnmanageChild,(XtPointer)0, (XtPointer)area, "Save Config File",CONFIG_PATTERN,'\0'); break; case MENU_FILE_SAVE: alLogOpModMessage(0,0, "Setup Save New Config: %s",psetup.configFile); alWriteConfig(psetup.configFile,area->pmainGroup); break; case MENU_FILE_ALH: if (alhArea) alhArea->managed = FALSE; setupConfig("",ALH,area); /* Display the config_changed warning dialog */ /* if (area->changed){ createActionDialog(area->form_main,XmDIALOG_WARNING, "Latest configuration changes have not been saved. Continue?" , (XtCallbackProc)actInvokeAlhCallback, (XtPointer)area,(XtPointer)area); break; } */ break; case MENU_FILE_PRINT: /* Name for PrintTree Report */ createFileDialog(area->form_main,(void *)fileSetupCallback, (XtPointer)FILE_PRINT,(void *)XtUnmanageChild,(XtPointer)0, (XtPointer)area, "Report File ",TREEREPORT_PATTERN,'\0'); break; case MENU_FILE_QUIT: if (area->changed){ /* Display the config_changed warning dialog */ createActionDialog(area->form_main,XmDIALOG_WARNING, "Latest configuration changes have not been saved! Exit Alarm Configuration Tool?", (XtCallbackProc)exit_quit, (XtPointer)area, (XtPointer)area); break; } createActionDialog(area->form_main,XmDIALOG_WARNING,"Exit Alarm Configuration Tool?", (XtCallbackProc)exit_quit, (XtPointer)area, (XtPointer)area); break; default: createDialog(area->form_main,XmDIALOG_INFORMATION,"Selection not implemented yet."," "); break; } }