예제 #1
0
SliderDialog::SliderDialog(QWidget* parent, const char* name, bool modal, Qt::WFlags fl):
  CWindowInterface(parent, fl),
  mpParentWindow(NULL),
  mpContextMenu(NULL),
  mpCurrSlider(NULL),
  mSliderMap(),
  mTaskMap(),
  mCurrentFolderId(0),
  mSliderValueChanged(false),
  mSliderPressed(false),
  mFramework(0),
  mChanged(false)
{
#ifndef Darwin
  setWindowIcon(CQIconResource::icon(CQIconResource::copasi));
#endif // not Darwin

  setupUi(this);

  addToMainWindow(mpParentWindow);

  setObjectName(QString::fromUtf8(name));
  setWindowTitle("Slider Window");

  mpSliderBox->layout()->addItem(new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::Expanding));

  this->mpContextMenu = new QMenu(this);
  mpaCreateNewSlider = this->mpContextMenu->addAction("Add New Slider", this, SLOT(createNewSlider()));
  mpaRemoveSlider = this->mpContextMenu->addAction("Remove Slider", this, SLOT(removeSlider()));
  mpaEditSlider = this->mpContextMenu->addAction("Edit Slider", this, SLOT(editSlider()));
  mpaResetValue = this->mpContextMenu->addAction("Reset Value", this, SLOT(resetValue()));
  mpaSetDefault = this->mpContextMenu->addAction("Set new default value", this, SLOT(setDefault()));

  this->mSliderMap[C_INVALID_INDEX].push_back(new QLabel("<p>There are no sliders available for this task. If you select one of the tasks that supports sliders in the copasi object tree, this dialog will become active.</p>", mpSliderBox));

  this->mTaskMap[23] = &SliderDialog::runTimeCourse;
  this->mTaskMap[21] = &SliderDialog::runSteadyStateTask;
  this->mTaskMap[31] = &SliderDialog::runScanTask;
  this->mTaskMap[24] = &SliderDialog::runMCATask;
  this->mTaskMap[35] = &SliderDialog::runLNATask;
  this->mTaskMap[33] = &SliderDialog::runParameterEstimationTask;
  this->mTaskMap[32] = &SliderDialog::runOptimizationTask;
  this->mTaskMap[28] = &SliderDialog::runCrossSectionTask;

  connect(this->mpRunTaskButton, SIGNAL(clicked()), this, SLOT(runTask()));
  connect(this->mpNewSliderButton, SIGNAL(clicked()), this, SLOT(createNewSlider()));
  this->setCurrentFolderId(C_INVALID_INDEX);
  init();
}
예제 #2
0
QString Netctl::getExtIp(const QString cmd)
{
    if (debug) qDebug() << PDEBUG;
    if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;

    // test network connection
    if (!isNetworkActive()) return QString("N\\A");
    TaskResult process = runTask(cmd);
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
    if (process.exitCode != 0)
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
    QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();

    return extIp;
}
예제 #3
0
파일: AsyncTask.cpp 프로젝트: joydit/cutter
void AsyncTask::run()
{
    runningMutex.lock();

    running = true;

    logBuffer = "";
    emit logChanged(logBuffer);
    runTask();

    running = false;

    emit finished();

    runningMutex.unlock();
}
예제 #4
0
void Task::run()
{
    try
    {
        runTask();
    }
    catch (Error const &er)
    {
        LOG_AS("Task");
        LOG_WARNING("Aborted due to exception: ") << er.asText();
    }

    // Cleanup.
    if (_pool) _pool->taskFinishedRunning(*this);
    Log::disposeThreadLog();
}
예제 #5
0
/**
 * @fn startWpaSupplicant
 */
bool WpaSup::startWpaSupplicant()
{
    if (debug) qDebug() << PDEBUG;
    if (ctrlDir.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
        return false;
    }
    if (ctrlGroup.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find group";
        return false;
    }
    if (pidFile.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
        return false;
    }
    if (wpaDrivers.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find drivers";
        return false;
    }
    if (wpaSupPath.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_supplicant";
        return false;
    }
    if (netctlCommand == nullptr) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
        return false;
    }
    QStringList interfaces = netctlCommand->getWirelessInterfaceList();
    if (interfaces.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find interfaces";
        return false;
    }

    if (QFile(pidFile).exists()) return true;
    QString cmd = QString("%1 %2 -B -P \"%3\" -i %4 -D %5 -C \"DIR=%6 GROUP=%7\"")
                    .arg(sudoCommand).arg(wpaSupPath).arg(pidFile).arg(interfaces[0])
                    .arg(wpaDrivers).arg(ctrlDir).arg(ctrlGroup);
    if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
    TaskResult process = runTask(cmd, useSuid);
    waitForProcess(1);
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
    if (process.exitCode != 0)
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;

    return (process.exitCode == 0);
}
예제 #6
0
void Scheduler::process()
{
    // uint64	frameStartTime = mClock->UpdateAndGetTime();

    // while(runTask() && ((mClock->UpdateAndGetTime() - frameStartTime) < mProcessTimeLimit));
    uint64	frameStartTime = mClock->getLocalTime();

    //Check for throttle
    if(frameStartTime < (mLastProcessTime + mThrottleLimit))
    {
        return;
    }

    while(runTask() && ((mClock->getLocalTime() - frameStartTime) < mProcessTimeLimit));

    //Set internal Clock so we know when the last call was
    mLastProcessTime = mClock->getLocalTime();
}
예제 #7
0
void DatabaseTasks::run()
{
	std::unique_lock<std::mutex> taskLockUnique(taskLock, std::defer_lock);
	while (threadState != THREAD_STATE_TERMINATED) {
		taskLockUnique.lock();
		if (tasks.empty()) {
			taskSignal.wait(taskLockUnique);
		}

		if (!tasks.empty()) {
			DatabaseTask task = std::move(tasks.front());
			tasks.pop_front();
			taskLockUnique.unlock();
			runTask(task);
		} else {
			taskLockUnique.unlock();
		}
	}
}
예제 #8
0
/**
 * @fn removeProfile
 */
bool NetctlProfile::removeProfile(const QString profile)
{
    if (debug) qDebug() << PDEBUG;
    if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
    if (profileDirectory == nullptr) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
        return false;
    }

    QString profilePath = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName());
    QString cmd = QString("%1 /usr/bin/rm \"%2\"").arg(sudoCommand).arg(profilePath);
    if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
    TaskResult process = runTask(cmd, useSuid);
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
    if (process.exitCode != 0)
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;

    return (process.exitCode == 0);
}
예제 #9
0
/**
 * @fn copyProfile
 */
bool NetctlProfile::copyProfile(const QString oldPath)
{
    if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]";
    if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Path" << oldPath;
    if (profileDirectory == 0) {
        if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Could not find directory";
        return false;
    }

    QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
    QString cmd = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
    if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << cmd;
    TaskResult process = runTask(cmd);
    if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Cmd returns" << process.exitCode;

    if (process.exitCode == 0)
        return true;
    else
        return false;
}
예제 #10
0
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
{
    if (debug) qDebug() << PDEBUG;

    TaskResult process = runTask(cmdNetctlAuto + QString(" list"));
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
    if (process.exitCode != 0)
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
    QString status;
    QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
    if (cmdOutput.isEmpty()) {
        netctlAutoStatus = false;
        status = QString("false");
    } else {
        netctlAutoStatus = true;
        status = QString("true");
    }

    return status;
}
예제 #11
0
void GenGraphForm::taskFinished()
{
    std::cout << "TASK FINISHED" << std::endl;
    if (currentTask == NULL) return;
//#ifdef SOFA_QT4
//	if (currentTask->state() != QProcess::NotRunning) return;
//#else
//	if (currentTask->isRunning()) return;
//#endif
    delete currentTask;
    currentTask = NULL;
    if (tasks.empty())
    {
        displayButton->setEnabled(true);
        exportButton->setText("&Export");
    }
    else
    {
        runTask();
    }
}
예제 #12
0
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
{
    if (debug) qDebug() << PDEBUG;
    getNetctlAutoStatus(cmdNetctlAuto);

    QString cmd;
    if (netctlAutoStatus)
        cmd = cmdNetctlAuto;
    else
        cmd = cmdNetctl;
    if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
    TaskResult process = runTask(cmd + QString(" list"));
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
    if (process.exitCode != 0)
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
    QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
    QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
    for (int i=0; i<profileList.count(); i++)
        profileList[i].remove(0, 2);

    return profileList;
}
예제 #13
0
QVariantHash PlayerSource::getPlayerMpdInfo(const QString mpdAddress) const
{
    qCDebug(LOG_ESM) << "MPD" << mpdAddress;

    QVariantHash info = defaultInfo();

    // build cmd
    QString cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl "
                          "--connect-timeout 1 -fsm 3 telnet://%1\"")
                      .arg(mpdAddress);
    qCInfo(LOG_ESM) << "cmd" << cmd;
    TaskResult process = runTask(cmd);
    qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
    qCInfo(LOG_ESM) << "Error" << process.error;

    QString qoutput
        = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
    for (auto str : qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
        if (str.split(QString(": "), QString::SkipEmptyParts).count() == 2) {
            // "Metadata: data"
            QString metadata = str.split(QString(": "), QString::SkipEmptyParts)
                                   .first()
                                   .toLower();
            QString data = str.split(QString(": "), QString::SkipEmptyParts)
                               .last()
                               .trimmed();
            // there are one more time...
            if ((metadata == QString("time")) && (data.contains(QChar(':')))) {
                QStringList times = data.split(QString(":"));
                info[QString("player/duration")] = times.at(0).toInt();
                info[QString("player/progress")] = times.at(1).toInt();
            } else if (m_metadata.contains(metadata)) {
                info[QString("player/%1").arg(metadata)] = data;
            }
        }
    }

    return info;
}
예제 #14
0
/**
 * @fn wpaCliCall
 */
bool WpaSup::wpaCliCall(const QString commandLine)
{
    if (debug) qDebug() << PDEBUG;
    if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
    if (ctrlDir.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find directory";
        return false;
    }
    if (pidFile.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find PID file";
        return false;
    }
    if (wpaCliPath.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find wpa_cli";
        return false;
    }
    if (netctlCommand == nullptr) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
        return false;
    }
    QStringList interfaces = netctlCommand->getWirelessInterfaceList();
    if (interfaces.isEmpty()) {
        if (debug) qDebug() << PDEBUG << ":" << "Could not find interfaces";
        return false;
    }

    QString interface = interfaces[0];
    QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
            QString(" -P ") + pidFile + QString(" ") + commandLine;
    if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
    TaskResult process = runTask(cmd);
    waitForProcess(1);
    if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
    if (process.exitCode != 0)
        if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;

    return (process.exitCode == 0);
}
예제 #15
0
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
    if (debug) qDebug() << PDEBUG;
    getNetctlAutoStatus(cmdNetctlAuto);

    QStringList status;
    if (netctlAutoStatus)
        status.append(QString("netctl-auto"));
    else {
        QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
        for (int i=0; i<profiles.count(); i++) {
            TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
            if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
            if (process.exitCode != 0)
                if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
            if (process.exitCode == 0)
                status.append(QString("enabled"));
            else
                status.append(QString("static"));
        }
    }

    return status;
}
예제 #16
0
QVariant HDDTemperatureSource::data(QString source)
{
    qCDebug(LOG_ESM) << "Source" << source;

    QString device = source.remove(QString("hdd/temperature"));
    float value = 0.0;
    // run cmd
    TaskResult process = runTask(QString("%1 %2").arg(m_cmd).arg(device));
    qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
    qCInfo(LOG_ESM) << "Error" << process.error;

    // parse
    QString qoutput
        = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
    if (m_smartctl) {
        for (auto str : qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
            if (!str.startsWith(QString("194")))
                continue;
            if (str.split(QChar(' '), QString::SkipEmptyParts).count() < 9)
                break;
            value = str.split(QChar(' '), QString::SkipEmptyParts)
                        .at(9)
                        .toFloat();
            break;
        }
    } else {
        if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
            QString temp
                = qoutput.split(QChar(':'), QString::SkipEmptyParts).at(2);
            temp.remove(QChar(0260)).remove(QChar('C'));
            value = temp.toFloat();
        }
    }

    return value;
}
예제 #17
0
void Dispatcher::thread() {
	std::unique_lock<std::mutex> uniqueLock(_mutex, std::defer_lock);

	while (_state == State::STARTED) {
		uniqueLock.lock();

		if (_tasks.empty()) {
			_signal.wait(uniqueLock);
		}

		if (_state != State::STARTED || _tasks.empty()) {
			uniqueLock.unlock();
			continue;
		}

		auto task = std::move(_tasks.front());
		_tasks.pop_front();

		uniqueLock.unlock();

		auto& game = server.game();
		auto messagePool = OutputMessagePool::getInstance();

		runTask(*task, game, messagePool);
	}

	_mutex.lock();
	auto tasks = std::move(_tasks);
	_mutex.unlock();

	runTasks(tasks);

	_mutex.lock();
	_state = State::STOPPED;
	_mutex.unlock();
}
예제 #18
0
void IOThreadPoolExecutor::add(
    Func func,
    std::chrono::milliseconds expiration,
    Func expireCallback) {
  RWSpinLock::ReadHolder{&threadListLock_};
  if (threadList_.get().empty()) {
    throw std::runtime_error("No threads available");
  }
  auto thread = threadList_.get()[nextThread_++ % threadList_.get().size()];
  auto ioThread = std::static_pointer_cast<IOThread>(thread);

  auto moveTask = folly::makeMoveWrapper(
      Task(std::move(func), expiration, std::move(expireCallback)));
  auto wrappedFunc = [this, ioThread, moveTask] () mutable {
    runTask(ioThread, std::move(*moveTask));
    ioThread->pendingTasks--;
  };

  ioThread->pendingTasks++;
  if (!ioThread->eventBase->runInEventBaseThread(std::move(wrappedFunc))) {
    ioThread->pendingTasks--;
    throw std::runtime_error("Unable to run func in event base thread");
  }
}
예제 #19
0
void GenGraphForm::addTask(QStringList argv)
{
    tasks.push_back(argv);
    if (currentTask == NULL)
        runTask();
}
예제 #20
0
void taskTask() {
  const char *res = runTask("ls -l -a");
  printf("%s\n", res);
}
예제 #21
0
void Queue::runTask(const Kernel& kernel, Event& event) {
  runTask(queue, kernel.getId(), 0, NULL, event.getId());
}
예제 #22
0
void ScriptCore::executeString(const char* string)
{
	runTask(new RunString(m_pInternal, string));
}
예제 #23
0
void ThreadTask::run()
{
	Q_ASSERT(!autoDelete());
	runTask();
	ThreadTaskCourier::notify(this);
}
예제 #24
0
void RunnerTask::run()
{
    runTask();

    emit finished( this );
}
예제 #25
0
int BusyMode_RunTasks(BusyTask* tasks, int numTasks)
{
    const char* currentTaskName = NULL;
    BusyTask* task;
    int i, mode;
    int result = 0;

    if(BusyMode_Active())
    {
        App_Error("BusyMode: Internal error, already busy...");
        exit(1); // Unreachable.
    }

    if(!tasks || numTasks <= 0) return result; // Hmm, no work?

    // Pick the first task.
    task = tasks;

    int initialMode = task->mode;
    preBusySetup(initialMode);

    // Process tasks.
    for(i = 0; i < numTasks; ++i, task++)
    {
        // If no new task name is specified, continue using the name of the previous task.
        if(task->name)
        {
            if(task->name[0])
                currentTaskName = task->name;
            else // Clear the name.
                currentTaskName = NULL;
        }

        mode = task->mode;
        /// @todo Kludge: Force BUSYF_STARTUP here so that the animation of one task
        ///       is not drawn on top of the last frame of the previous.
        if(numTasks > 1)
        {
            mode |= BUSYF_STARTUP;
        }
        // kludge end

        // Null tasks are not processed (implicit success).
        if(!task->worker) continue;

        /**
         * Process the work.
         */
#ifdef __CLIENT__
        // Is the worker updating its progress?
        if(task->maxProgress > 0)
            Con_InitProgress2(task->maxProgress, task->progressStart, task->progressEnd);
#endif
        // Invoke the worker in a new thread.
        /// @todo Kludge: Presently a temporary local task is needed so that we can modify
        ///       the task name and mode flags.
        { BusyTask* tmp = newTask(mode, task->worker, task->workerData, currentTaskName);
        result = runTask(tmp);
        // We are now done with this task.
        deleteTask(tmp);

        if(result) break;
        }
        // kludge end.
    }

    postBusyCleanup();

    return result;
}
예제 #26
0
void Queue::runTask(const Kernel& kernel) {
  runTask(queue, kernel.getId(), 0, NULL, NULL);
}
예제 #27
0
/**
 * @fn getRecommendedConfiguration
 */
QMap<QString, QString> WpaSup::getRecommendedConfiguration()
{
    QMap<QString, QString> settings;
    int size = 99;
    TaskResult process;
    QStringList recommended;
    // ctrl directory
    // nothing to do
    settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
    // ctrl group
    // check group list and find out 'network', 'users', 'root'
    settings[QString("CTRL_GROUP")] = QString("");
    gid_t gtpList[99];
    int grpSize = getgroups(size, gtpList);
    recommended.clear();
    recommended.append("network");
    recommended.append("users");
    recommended.append("root");
    for (int i=0; i<recommended.count(); i++) {
        for (int j=0; j<grpSize; j++)
            if (recommended[i] == QString(getgrgid(gtpList[j])->gr_name)) {
                settings[QString("CTRL_GROUP")] = recommended[i];
                break;
            }
        if (!settings[QString("CTRL_GROUP")].isEmpty()) break;
    }
    // force sudo
    // find out helper exe
    settings[QString("FORCE_SUDO")] = QString("true");
    recommended.clear();
    recommended.append(QString("netctlgui-helper"));
    recommended.append(QString("netctlgui-helper-suid"));
    for (int i=0; i<recommended.count(); i++) {
        process = runTask(QString("which %1").arg(recommended[i]), false);
        if (process.exitCode == 0) {
            settings[QString("FORCE_SUDO")] = QString("false");
            break;
        }
    }
    // pid file
    // nothing to do
    settings[QString("PID_FILE")] = QString("/run/wpa_supplicant_netctl-gui.pid");
    // sudo path
    // find out sudo, kdesu, gksu exes
    settings[QString("SUDO_PATH")] = QString("");
    recommended.clear();
    recommended.append("sudo");
    recommended.append("kdesu");
    recommended.append("gksu");
    for (int i=0; i<recommended.count(); i++) {
        process = runTask(QString("which %1").arg(recommended[i]), false);
        if (process.exitCode == 0) {
            settings[QString("SUDO_PATH")] = process.output.trimmed();
            break;
        }
    }
    // wpa_cli path
    // find out wpa_cli exe
    settings[QString("WPACLI_PATH")] = QString("true");
    recommended.clear();
    recommended.append("wpa_cli");
    for (int i=0; i<recommended.count(); i++) {
        process = runTask(QString("which %1").arg(recommended[i]), false);
        if (process.exitCode == 0) {
            settings[QString("WPACLI_PATH")] = process.output.trimmed();
            break;
        }
    }
    // wpa drivers
    // nothing to do
    settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
    // wpa_supplicant path
    // find out wpa_supplicant exe
    settings[QString("WPASUP_PATH")] = QString("true");
    recommended.clear();
    recommended.append("wpa_supplicant");
    for (int i=0; i<recommended.count(); i++) {
        process = runTask(QString("which %1").arg(recommended[i]), false);
        if (process.exitCode == 0) {
            settings[QString("WPASUP_PATH")] = process.output.trimmed();
            break;
        }
    }

    return settings;
}