void Sniffer::eventLoop() { if(isDead) return; if(_ticks > 50) //Check every 5 seconds { _ticks = 0; if(!isProcessRunning()) { _eventTimer->blockSignals(true); isDead = true; _packetList->refresh(); //Delete queue's as no one is going to reopen them (pid based) message_queue::remove(_packetName); message_queue::remove(_controlName); return; } } uint32 recvdSize, priority; while(_packetIpc->get_num_msg() > 0) //Get all packets from the queue if(_packetIpc->try_receive(recvPacket, MP_MAX_SIZE, recvdSize, priority)) //Try to receive a packet if(recvPacket->messagePacketSize() == recvdSize) //If it is all good { //Create the packet (in my thread) and add it to the model Packet *packet = new Packet(recvPacket); _packetList->addPacket(packet, _filterList->showInTable(packet)); } _ticks++; }
bool CSharedMem::IsDeadOpenHoldemProcess(int open_holdem_iD) { if (openholdem_PIDs[open_holdem_iD] == NULL) { return false; } if (isProcessRunning(openholdem_PIDs[open_holdem_iD])) { return false; } write_log(Preferences()->debug_sharedmem(), "[CSharedMem] Dead process %d %d detected\n", open_holdem_iD, openholdem_PIDs[open_holdem_iD]); return true; }
bool WareSrcWidgetCollection::closeAllWidgets() { if (isProcessRunning()) { QMessageBox::warning(nullptr,tr("Process running"), tr("Closing tab is not allowed while a configure or build process is running."), QMessageBox::Close,QMessageBox::Close); return false; } int Choice = QMessageBox::Discard; if (isModified()) { QMessageBox MsgBox; MsgBox.setText(tr("Documents have been modified.")); MsgBox.setInformativeText(tr("Do you want to save changes?")); MsgBox.setStandardButtons(QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel); MsgBox.setDefaultButton(QMessageBox::SaveAll); Choice = MsgBox.exec(); } switch (Choice) { case QMessageBox::SaveAll: for(WareSrcWidget* Ware : m_WareSrcWidgetByPath.values()) Ware->saveAllFileTabs(); /* fall through */ case QMessageBox::Discard: for(WareSrcWidget* Ware : m_WareSrcWidgetByPath.values()) { Ware->closeAllFileTabs(); closeWareTab(Ware); } return true; break; case QMessageBox::Cancel: default: return false; break; } }
void SshRemoteProcessRunner::sendSignalToProcess(SshRemoteProcess::Signal signal) { QSSH_ASSERT(isProcessRunning()); d->m_process->sendSignal(signal); }
void SshRemoteProcessRunner::writeDataToProcess(const QByteArray &data) { QSSH_ASSERT(isProcessRunning()); d->m_process->write(data); }
SshRemoteProcess::ExitStatus SshRemoteProcessRunner::processExitStatus() const { QSSH_ASSERT(!isProcessRunning()); return d->m_exitStatus; }
// constructor // Most of the interface is defined in the ui // // The UI dialog button box accept button is connected to the writeSettings // so slot so the settings on disk are always current to what is selected // and set using the UI // Settings::Settings(QWidget *parent) : QDialog(parent) { // setup the user interface ui.setupUi(this); // data members editor_string = QString(); // read the settings settings = new QSettings(ORG, APP, this); // preferences settings->beginGroup("Preferences"); ui.checkBox_usestartoptions->setChecked(settings->value("use_startoptions").toBool() ); ui.groupBox_startoptions->setEnabled(settings->value("use_startoptions").toBool() ); ui.checkBox_retainstate->setChecked(settings->value("retain_state").toBool() ); ui.checkBox_retainplaylist->setChecked(settings->value("retain_playlist").toBool() ); ui.checkBox_disabletooltips->setChecked(settings->value("disable_tooltips").toBool() ); ui.checkBox_disablexscreensaver->setChecked(settings->value("disable_xscreensaver").toBool() ); ui.checkBox_disabledpms->setChecked(settings->value("disable_dpms").toBool() ); ui.lineEdit_colorize->setText(settings->value("colorize_icons").toString() ); ui.checkBox_disableinternet->setChecked(settings->value("disable_internet").toBool() ); ui.checkBox_useyoutubedl->setChecked(settings->value("use_youtube-dl").toBool() ); ui.spinBox_youtubedl_timeout->setValue(settings->value("youtube-dl_timeout", 9).toInt() ); QDir res(":/stylesheets/stylesheets/"); QStringList styles = res.entryList(QDir::Files); styles << tr("None"); QString str = settings->value("style").toString(); styles.replaceInStrings(".qss", ""); if (! str.isEmpty() && ! styles.contains(str)) styles << str; styles.sort(Qt::CaseSensitive); ui.comboBox_style->clear(); ui.comboBox_style->addItems(styles); ui.comboBox_style->setCurrentText(str); settings->endGroup(); // notification settings settings->beginGroup("Notifications"); ui.checkBox_notifydaemon->setChecked(settings->value("use_notifications").toBool() ); settings->endGroup(); // start options settings->beginGroup("StartOptions"); ui.checkBox_fullscreen->setChecked(settings->value("start_fullscreen").toBool() ); ui.checkBox_shademode->setChecked(settings->value("start_shademode").toBool() ); ui.checkBox_gui->setChecked(settings->value("start_gui").toBool() ); ui.checkBox_icontheme->setChecked(settings->value("use_icon_theme").toBool() ); if (ui.checkBox_icontheme->isChecked() ) ui.lineEdit_icontheme->setEnabled(true); ui.lineEdit_icontheme->setText(settings->value("icon_theme_name").toString() ); ui.spinBox_loglevel->setValue(settings->value("log_level").toInt() ); ui.checkBox_visualizer->setChecked(settings->value("start_visualizer").toBool() ); ui.checkBox_nohardwaredecoding->setChecked(settings->value("no_hardware_decoding").toBool() ); ui.checkBox_subtitles->setChecked(settings->value("start_subtitles").toBool() ); ui.checkBox_streambuffering->setChecked(settings->value("use_stream_buffering").toBool() ); ui.checkBox_downloadbuffering->setChecked(settings->value("use_download_buffering").toBool() ); ui.lineEdit_audiocd->setText(settings->value("audio_cd_drive").toString() ); ui.lineEdit_dvd->setText(settings->value("dvd_drive").toString() ); ui.spinBox_connectionspeed->setValue(settings->value("connection_speed").toInt() ); ui.lineEdit_promoted->setText(settings->value("promoted-elements").toString() ); ui.lineEdit_blacklisted->setText(settings->value("blacklisted-elements").toString() ); settings->endGroup(); // external programs settings->beginGroup("ExternalPrograms"); editor_string = settings->value("text_editor").toString(); settings->endGroup(); // Set up the buttonGroup for the editing buttons bg01 = new QButtonGroup(this); bg01->addButton(ui.pushButton_editiconfile); bg01->addButton(ui.pushButton_editkeyfile); // Connect signals and slots connect(bg01, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(openEditor(QAbstractButton*))); connect(ui.toolButton_colorize, SIGNAL(clicked()), this, SLOT(callColorDialog())); connect(ui.lineEdit_colorize, SIGNAL(textChanged(const QString&)), this, SLOT(iconColorChanged(const QString&))); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(writeSettings())); // See if we can find XScreenSaver and enable or disable controls // based on what we can find. If XScreenSaver is running it controls // blanking and powersaving. if (isProcessRunning("xscreensaver") ) { ui.checkBox_disablexscreensaver->setEnabled(true); ui.checkBox_disabledpms->setEnabled(false); } else { ui.checkBox_disablexscreensaver->setEnabled(false); ui.checkBox_disabledpms->setEnabled(true); } // else // See if we can find youtube-dl and disable settings if we can't if (isProgramAvailable("youtube-dl") ) { ui.checkBox_useyoutubedl->setEnabled(true); } else { ui.checkBox_useyoutubedl->setEnabled(false); } // We may have changed settings finding XScreensaver and youtube-dl so // make sure everything is in sync. this->writeSettings(); return; }
int main(int argc, char *argv[]) { // This should be run as root since it does lots of things that require root privileges. if (getuid()) { // trying to obtain root UID setuid(0); if (getuid()) { string args; for (int i=1; i<argc; ++i) { args += string(argv[i]) + " "; } if (system("[ \"`sudo -l | grep " + string(argv[0]) + " | grep NOPASSWD`\" = \"\" ]")) return system("sudo " + string(argv[0]) + " " + args); else return system("xdg-su -c \"" + string(argv[0]) + " " + args + "\""); } } if (argc>1 && strcmp(argv[1], "-v")==0) verbose=1; // Check for already running process if (FileExists("/var/run/guisetup.pid")) { string pid_locked = ReadFile("/var/run/guisetup.pid").c_str(); if (isProcessRunning(pid_locked)) { fprintf(stderr, "Another setup process %s is alrealy running.\n", pid_locked.c_str()); return 1; } } // Store lock file pid_t pid = getpid(); if (FileExists("/var/run/guisetup_exec.pid")) { string pid_locked = ReadFile("/var/run/guisetup_exec.pid").c_str(); if (isProcessRunning(pid_locked)) { fprintf(stderr, "Another setup process %s is alrealy running.\n", pid_locked.c_str()); return 1; } } WriteFile("/var/run/guisetup_exec.pid", IntToStr(pid)); setupMode=true; simulate=false; forceSkipLinkMD5Checks=false; forceInInstallMD5Check = false; // We don't care of database integrity in case of installation failure half-way, so we can use fast mode. It has beed tested enough, and I think it is useful. // Warp drive active! _cmdOptions["ramwarp"]="no"; _cmdOptions["warpmode"]="yes"; if (FileExists("/tmp/sw1")) _cmdOptions["doinst_scrinst"]="yes"; if (FileExists("/tmp/sw2")) _cmdOptions["bashamp"]="yes"; noEject=true; setlocale(LC_ALL, ""); bindtextdomain( "mpkg", "/usr/share/locale"); textdomain("mpkg"); if (!FileExists("/usr/share/setup/packages.db")) { mError("Oops, no database template in /usr/share/setup/packages.db!"); return 1; } if (!FileExists("/usr/share/setup/mpkg-setup.xml")) { mError("Oops, no config template in /usr/share/setup/mpkg-setup.xml!"); return 1; } CONFIG_FILE="/usr/share/setup/mpkg-setup.xml"; mConfig.configName=CONFIG_FILE; unlink("/tmp/packages.db"); system("cp /usr/share/setup/packages.db /tmp/packages.db"); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QApplication a(argc, argv); QLocale lc; QTranslator translator; translator.load("guisetup_exec_" + lc.name(), "/usr/share/setup/l10n"); a.installTranslator(&translator); MainWindow w; w.show(); int ret = a.exec(); unlink("/var/run/guisetup_exec.pid"); return ret; }
bool UnicornUtils::iTunesIsOpen() { return isProcessRunning( "iTunes" ); }
bool UnicornUtils::isGrowlInstalled() { return isProcessRunning( "GrowlHelperApp" ); }
int main(int argc, char *argv[]) { // This should be run as root since libparted requires it. if (getuid()) { // trying to obtain root UID setuid(0); if (getuid()) { string args; for (int i=1; i<argc; ++i) { args += string(argv[i]) + " "; } // Check if we can run via sudo if (system("[ \"`sudo -l | grep " + string(argv[0]) + " | grep NOPASSWD`\" = \"\" ]")) return system("sudo " + string(argv[0]) + " " + args); else return system("xdg-su -c \"" + string(argv[0]) + " " + args + "\""); } } if (FileExists("/var/run/guisetup_exec.pid")) { string pid_locked = ReadFile("/var/run/guisetup_exec.pid").c_str(); if (isProcessRunning(pid_locked)) { fprintf(stderr, "Another setup process %s is alrealy running.\n", pid_locked.c_str()); return 1; } } pid_t pid = getpid(); if (FileExists("/var/run/guisetup.pid")) { string pid_locked = ReadFile("/var/run/guisetup.pid").c_str(); if (isProcessRunning(pid_locked)) { fprintf(stderr, "Another setup process %s is alrealy running.\n", pid_locked.c_str()); return 1; } } WriteFile("/var/run/guisetup.pid", IntToStr(pid)); setlocale(LC_ALL, ""); bindtextdomain( "mpkg", "/usr/share/locale"); textdomain("mpkg"); // For mpkg, note that we copy config to temp directory CONFIG_FILE="/tmp/mpkg.xml"; mConfig.configName=CONFIG_FILE; unlink("/tmp/packages.db"); unlink("/tmp/mpkg.xml"); if (!FileExists("/usr/share/setup/packages.db")) { mError("Oops, no database template in /usr/share/setup/packages.db!"); return 1; } if (!FileExists("/usr/share/setup/mpkg-setup.xml")) { mError("Oops, no config template in /usr/share/setup/mpkg-setup.xml!"); return 1; } system("cp /usr/share/setup/packages.db /tmp/packages.db"); system("cp /usr/share/setup/mpkg-setup.xml /tmp/mpkg.xml"); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QApplication a(argc, argv); QLocale lc; QTranslator translator; translator.load("guisetup_" + lc.name(), "/usr/share/setup/l10n"); a.installTranslator(&translator); MainWindow w; w.show(); return a.exec(); }