bool Greeter::start() { // check flag if (m_started) return false; if (daemonApp->testing()) { // create process m_process = new QProcess(this); // delete process on finish connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished())); connect(m_process, SIGNAL(readyReadStandardOutput()), SLOT(onReadyReadStandardOutput())); connect(m_process, SIGNAL(readyReadStandardError()), SLOT(onReadyReadStandardError())); // log message qDebug() << "Greeter starting..."; // set process environment QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("DISPLAY", m_display->name()); env.insert("XAUTHORITY", m_authPath); env.insert("XCURSOR_THEME", mainConfig.Theme.CursorTheme.get()); m_process->setProcessEnvironment(env); // start greeter QStringList args; if (daemonApp->testing()) args << "--test-mode"; args << "--socket" << m_socket << "--theme" << m_theme; m_process->start(QString("%1/sddm-greeter").arg(BIN_INSTALL_DIR), args); //if we fail to start bail immediately, and don't block in waitForStarted if (m_process->state() == QProcess::NotRunning) { qCritical() << "Greeter failed to launch."; return false; } // wait for greeter to start if (!m_process->waitForStarted()) { // log message qCritical() << "Failed to start greeter."; // return fail return false; } // log message qDebug() << "Greeter started."; // set flag m_started = true; } else {
void ArchiverProcess::onFinished(int code,UnixProcess::ExitStatus status) { setReadChannel(UnixProcess::StandardOutput); bool at_end = atEnd(); setReadChannel(UnixProcess::StandardError); if (at_end && atEnd() && !isReading) { if (code != 0) { if (wasTerminated()) m_errors.clear(); if (!m_errors.isEmpty()) emit error(m_errors); else emit error(((status == UnixProcess::CrashExit) && !wasTerminated())?FlushedProcess::errorString():""); } else emit finished(); m_errors.clear(); deleteLater(); active_processes.removeAll(this); } else { if (!isReading) { onReadyReadStandardOutput(); onReadyReadStandardError(); } QMetaObject::invokeMethod(this,"onFinished",Qt::QueuedConnection,Q_ARG(int,code),Q_ARG(UnixProcess::ExitStatus,status)); } }
bool Greeter::start() { // check flag if (m_started) return false; // themes QString xcursorTheme = mainConfig.Theme.CursorTheme.get(); if (m_themeConfig->contains(QLatin1String("cursorTheme"))) xcursorTheme = m_themeConfig->value(QLatin1String("cursorTheme")).toString(); QString platformTheme; if (m_themeConfig->contains(QLatin1String("platformTheme"))) platformTheme = m_themeConfig->value(QLatin1String("platformTheme")).toString(); QString style; if (m_themeConfig->contains(QLatin1String("style"))) style = m_themeConfig->value(QLatin1String("style")).toString(); // greeter command QStringList args; args << QLatin1String("--socket") << m_socket << QLatin1String("--theme") << m_themePath; if (!platformTheme.isEmpty()) args << QLatin1String("-platformtheme") << platformTheme; if (!style.isEmpty()) args << QLatin1String("-style") << style; if (daemonApp->testing()) { // create process m_process = new QProcess(this); // delete process on finish connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished())); connect(m_process, SIGNAL(readyReadStandardOutput()), SLOT(onReadyReadStandardOutput())); connect(m_process, SIGNAL(readyReadStandardError()), SLOT(onReadyReadStandardError())); // log message qDebug() << "Greeter starting..."; // set process environment QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert(QStringLiteral("DISPLAY"), m_display->name()); env.insert(QStringLiteral("XAUTHORITY"), m_authPath); env.insert(QStringLiteral("XCURSOR_THEME"), xcursorTheme); env.insert(QStringLiteral("QT_IM_MODULE"), mainConfig.InputMethod.get()); m_process->setProcessEnvironment(env); // start greeter if (daemonApp->testing()) args << QStringLiteral("--test-mode"); m_process->start(QStringLiteral("%1/sddm-greeter").arg(QStringLiteral(BIN_INSTALL_DIR)), args); //if we fail to start bail immediately, and don't block in waitForStarted if (m_process->state() == QProcess::NotRunning) { qCritical() << "Greeter failed to launch."; return false; } // wait for greeter to start if (!m_process->waitForStarted()) { // log message qCritical() << "Failed to start greeter."; // return fail return false; } // log message qDebug() << "Greeter started."; // set flag m_started = true; } else {
void Connection::connectPPTP(QString serverIP, QString inUsername, QString inPassword) { if (process_) { process_->waitForFinished(); delete process_; process_ = NULL; } process_ = new QProcess(this); QString strPath; strPath += "pkexec pppd "; strPath += "pty \"pptp pl-vpn-00.glbls.net --nolaunchpppd --nobuffer\" "; strPath += "user next "; strPath += "password \"next\" "; strPath += "linkname poland "; strPath += "lock "; strPath += "refuse-pap "; strPath += "refuse-chap "; strPath += "refuse-mschap "; strPath += "refuse-eap "; strPath += "usepeerdns "; strPath += "nodeflate "; strPath += "nobsdcomp "; strPath += "noauth "; strPath += "nopcomp "; strPath += "noaccomp "; strPath += "require-mppe-128 "; strPath += "defaultroute "; strPath += "replacedefaultroute "; strPath += "debug dump nodetach"; QObject::connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(onReadyReadStandardOutput())); QObject::connect(process_, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(onFinished())); process_->start(strPath); //process.start("pkexec pppd call aaa debug dump nodetach"); //process.waitForFinished(); //qDebug() << process.readAllStandardOutput(); /*if (!m_pptpServiceId) m_pptpServiceId = initService( kSCNetworkInterfaceTypePPTP , m_pptpServiceName ); if (!m_pptpServiceId) return; std::string username = inUsername.toStdString(); std::string password = inPassword.toStdString(); std::string hostname = serverIP.toStdString(); CFStringRef cfUsername = CFStringCreateWithCString( NULL , username.c_str() , kCFStringEncodingUTF8 ); CFStringRef cfPassword = CFStringCreateWithCString( NULL , password.c_str() , kCFStringEncodingUTF8 ); CFStringRef cfHostname = CFStringCreateWithCString( NULL , hostname.c_str() , kCFStringEncodingUTF8 ); CFIndex index = 0; const void *pppKeys[3], *pppVals[3]; pppKeys[index] = (void*) kSCPropNetPPPAuthName; pppVals[index] = (void*) cfUsername; index++; pppKeys[index] = (void*) kSCPropNetPPPAuthPassword; pppVals[index] = (void*) cfPassword; index++; pppKeys[index] = (void*) kSCPropNetPPPCommRemoteAddress; pppVals[index] = (void*) cfHostname; index++; CFDictionaryRef pppDialOptions; pppDialOptions = CFDictionaryCreate( NULL , pppKeys , pppVals , index , &kCFTypeDictionaryKeyCallBacks , &kCFTypeDictionaryValueCallBacks ); CFStringRef keys[] = { kSCEntNetPPP }; CFDictionaryRef vals[] = { pppDialOptions }; CFDictionaryRef optionsForDial; optionsForDial = CFDictionaryCreate( NULL , (const void **) &keys , (const void **) &vals , 1 , &kCFTypeDictionaryKeyCallBacks , &kCFTypeDictionaryValueCallBacks ); bConnected_ = false; if (m_connection) { SCNetworkConnectionUnscheduleFromRunLoop(m_connection, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); CFRelease(m_connection); m_connection = NULL; } m_connection = initConnection( m_pptpServiceId, optionsForDial );*/ }
void ArchiverProcess::init_connections() { connect(this,SIGNAL(error(UnixProcess::ProcessError)),this,SLOT(onError(UnixProcess::ProcessError))); connect(this,SIGNAL(finished(int,UnixProcess::ExitStatus)),this,SLOT(onFinished(int,UnixProcess::ExitStatus)),Qt::QueuedConnection); connect(this,SIGNAL(readyReadStandardError()),this,SLOT(onReadyReadStandardError())); connect(this,SIGNAL(readyReadStandardOutput()),this,SLOT(onReadyReadStandardOutput())); }