Esempio n. 1
0
bool EncoderLame::init(){
	// Determine if lame is installed on the system or not.
	if ( KStandardDirs::findExe( "lame" ).isEmpty() )
		return false;

	// Ask lame for the list of genres it knows; otherwise it barfs when doing
	// e.g. lame --tg 'Vocal Jazz'
	KProcess proc;
	proc.setOutputChannelMode(KProcess::MergedChannels);
	proc << "lame" << "--genre-list";
	proc.execute();

	if(proc.exitStatus() != QProcess::NormalExit)
		return false;

	QByteArray array = proc.readAll();
	QString str = QString::fromLocal8Bit( array );
	d->genreList = str.split( '\n', QString::SkipEmptyParts );
	// Remove the numbers in front of every genre
	for( QStringList::Iterator it = d->genreList.begin(); it != d->genreList.end(); ++it ) {
		QString& genre = *it;
		int i = 0;
		while ( i < genre.length() && ( genre[i].isSpace() || genre[i].isDigit() ) )
			++i;
		genre = genre.mid( i );

	}
	//kDebug(7117) << "Available genres:" << d->genreList;

	return true;
}
Esempio n. 2
0
bool K3b::CdrskinProgram::scanFeatures(ExternalBin& bin) const
{
    KProcess fp;
    fp.setOutputChannelMode(KProcess::MergedChannels);
    fp << bin.path() << "-help";

    if (fp.execute() >= 0) {
        QByteArray output = fp.readAll();

        if (output.contains("gracetime"))
            bin.addFeature("gracetime");
        if (output.contains("-overburn"))
            bin.addFeature("overburn");
        if (output.contains("-text"))
            bin.addFeature("cdtext");
        if (output.contains("-clone"))
            bin.addFeature("clone");
        if (output.contains("-tao"))
            bin.addFeature("tao");
    }

#ifdef K3B_DEBUG
    qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << bin.version(); // 1.4.6 for example
#endif
    // TODO: cdrskin -help | grep XXX
    // Hello Thomas, please help me: the other version number dependent features 
    // need to be checked what they mean and whether cdrskin supports them.
    if (bin.version().suffix().endsWith("-dvd")) {
        bin.addFeature("dvd-patch");
        bin.setVersion(QString(bin.version().versionString()).remove("-dvd"));
    }

    // TODO: find . -name "*.cpp" | xargs grep plain-atapi
    // In src/k3bsystemproblemdialog.cpp there is Check for we have atapi support 
    // in some way in the kernel
    bin.addFeature("plain-atapi");
    // The same story
    bin.addFeature("hacked-atapi");

    bin.addFeature("burnfree");

    if (bin.version() >= K3b::Version(0, 6, 2)) {
#ifdef K3B_DEBUG
        qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << "Blu-ray support was complete in cdrskin-0.6.2, 20 Feb 2009";
#endif
        bin.addFeature("blu-ray");
    }

    bin.addFeature("dvd");
#ifdef K3B_DEBUG
    qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << bin.features();
#endif

    return SimpleExternalProgram::scanFeatures(bin);
}
Esempio n. 3
0
bool LldbDebugger::checkVersion()
{
    KProcess process;
    process.setProgram(debuggerBinary_, {"--versionLong"});
    process.setOutputChannelMode(KProcess::MergedChannels);
    process.start();
    process.waitForFinished(5000);
    auto output = QString::fromLatin1(process.readAll());
    qCDebug(DEBUGGERLLDB) << output;

    QRegularExpression rx("^Version: (\\d+).(\\d+).(\\d+).(\\d+)$", QRegularExpression::MultilineOption);
    auto match = rx.match(output);
    int version[] = {0, 0, 0, 0};
    if (match.hasMatch()) {
        for (int i = 0; i != 4; ++i) {
            version[i] = match.captured(i+1).toInt();
        }
    }

    // minimal version is 1.0.0.9
    bool ok = true;
    const int min_ver[] = {1, 0, 0, 9};
    for (int i = 0; i < 4; ++i) {
        if (version[i] < min_ver[i]) {
            ok = false;
            break;
        } else if (version[i] > min_ver[i]) {
            ok = true;
            break;
        }
    }

    if (!ok) {
        if (!qobject_cast<QGuiApplication*>(qApp))  {
            //for unittest
            qFatal("You need a graphical application.");
        }

        KMessageBox::error(
            qApp->activeWindow(),
            i18n("<b>You need lldb-mi 1.0.0.9 or higher.</b><br />"
            "You are using: %1", output),
            i18n("LLDB Error"));
    }

    return ok;
}
Esempio n. 4
0
ActionReply Helper::executeCommand(const QStringList &command)
{
    KProcess process;
    process.setProgram(command);
    process.setOutputChannelMode(KProcess::MergedChannels);

    qDebug() << "Executing" << command.join(" ");
    int exitCode = process.execute();

    ActionReply reply;
    if (exitCode != 0) {
        reply = ActionReply::HelperErrorReply();
        //TO BE FIXED
        reply.setErrorCode(ActionReply::Error::InvalidActionError);
    }
    reply.addData("command", command);
    reply.addData("output", process.readAll());
    return reply;
}
Esempio n. 5
0
bool K3b::CdrdaoProgram::scanFeatures( ExternalBin& bin ) const
{
    // probe features
    KProcess fp;
    fp.setOutputChannelMode( KProcess::MergedChannels );
    fp << bin.path() << "write" << "-h";

    if( fp.execute() >= 0 ) {
        QByteArray out = fp.readAll();
        if( out.contains( "--overburn" ) )
            bin.addFeature( "overburn" );
        if( out.contains( "--multi" ) )
            bin.addFeature( "multisession" );

        if( out.contains( "--buffer-under-run-protection" ) )
            bin.addFeature( "disable-burnproof" );

        // SuSE 9.0 ships with a patched cdrdao 1.1.7 which contains an updated libschily
        // Gentoo ships with a patched cdrdao 1.1.7 which contains scglib support
        if( bin.version() > K3b::Version( 1, 1, 7 ) ||
            bin.version() == K3b::Version( 1, 1, 7, "-gentoo" ) ||
            bin.version() == K3b::Version( 1, 1, 7, "-suse" ) ) {
            //    bin.addFeature( "plain-atapi" );
            bin.addFeature( "hacked-atapi" );
        }

        if( bin.version() >= K3b::Version( 1, 1, 8 ) )
            bin.addFeature( "plain-atapi" );

        return SimpleExternalProgram::scanFeatures( bin );
    }
    else {
        qDebug() << "could not start " << bin.path();
        return false;
    }
}
Esempio n. 6
0
QStringList gccSetupStandardIncludePaths(bool withStdCpp0x)
{
    QStringList includePaths;
    
    KProcess proc;
    proc.setOutputChannelMode(KProcess::MergedChannels);

    // The following command will spit out a bnuch of information we don't care
    // about before spitting out the include paths.  The parts we care about
    // look like this:
    // #include "..." search starts here:
    // #include <...> search starts here:
    //  /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2
    //  /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/i486-linux-gnu
    //  /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward
    //  /usr/local/include
    //  /usr/lib/gcc/i486-linux-gnu/4.1.2/include
    //  /usr/include
    // End of search list.
    proc << "gcc";
    if (withStdCpp0x) {
        // see also: https://bugs.kde.org/show_bug.cgi?id=298252
        proc << "-std=c++0x";
    }
    proc << "-xc++" << "-E" << "-v" << NULL_DEVICE;

    // We'll use the following constants to know what we're currently parsing.
    const short parsingInitial = 0;
    const short parsedFirstSearch = 1;
    const short parsingIncludes = 2;
    const short parsingFinished = 3;
    short parsingMode = parsingInitial;

    if (proc.execute(5000) == 0) {
        QString line;
        while (proc.canReadLine() && parsingMode != parsingFinished) {
            QByteArray buff = proc.readLine();
            if (!buff.isEmpty()) {
                line = buff;
                switch (parsingMode) {
                case parsingInitial:
                    if (line.indexOf("#include \"...\"") != -1) {
                        parsingMode = parsedFirstSearch;
                    }
                    break;
                case parsedFirstSearch:
                    if (line.indexOf("#include <...>") != -1) {
                        parsingMode = parsingIncludes;
                        break;
                    }
                case parsingIncludes:
                    //if (!line.indexOf(QDir::separator()) == -1 && line != "." ) {
                    //Detect the include-paths by the first space that is prepended. Reason: The list may contain relative paths like "."
                    if (!line.startsWith(" ") ) {
                        // We've reached the end of the list.
                        parsingMode = parsingFinished;
                    } else {
                        line = line.trimmed();
                        // This is an include path, add it to the list.
                        includePaths << QDir::cleanPath(line);
                    }
                    break;
                }
            }
        }
    } else if (withStdCpp0x) {
        // fallback to include-path computation without -std=c++0x arg for old gcc versions
        return gccSetupStandardIncludePaths(false);
    } else {
        kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
    }
    
    return includePaths;
}
Esempio n. 7
0
QVector<rpp::pp_macro*> computeGccStandardMacros(bool withStdCpp0x = true)
{
    QVector<rpp::pp_macro*> ret;
    //Get standard macros from gcc
    KProcess proc;
    proc.setOutputChannelMode(KProcess::MergedChannels);

    // The output of the following gcc commands is several line in the format:
    // "#define MACRO [definition]", where definition may or may not be present.
    // Parsing each line sequentially, we can easily build the macro set.
    proc << "gcc";
    if (withStdCpp0x) {
        // see also: https://bugs.kde.org/show_bug.cgi?id=298252
        proc << "-std=c++0x";
    }
    proc << "-xc++" << "-E" << "-dM" <<NULL_DEVICE;

    if (proc.execute(5000) == 0) {
        QString line;
        while (proc.canReadLine()) {
            QByteArray buff = proc.readLine();
            if (!buff.isEmpty()) {
                line = buff;
                if (line.startsWith("#define ")) {
                    line = line.right(line.length() - 8).trimmed();
                    int pos = line.indexOf(' ');
                    
                    ret.append(new rpp::pp_macro);
                    
                    rpp::pp_macro& macro(*ret.back());
                    if (pos != -1) {
                        macro.name = IndexedString( line.left(pos) );
                        macro.setDefinitionText( line.right(line.length() - pos - 1).toUtf8() );
                    } else {
                        macro.name = IndexedString( line );
                    }
                }
            }
        }
    } else if (withStdCpp0x) {
        // fallback to macro computation without -std=c++0x arg for old gcc versions
        return computeGccStandardMacros(false);
    } else {
        kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
    }
    return ret;
}
QVector<rpp::pp_macro*> computeGccStandardMacros()
{
    QVector<rpp::pp_macro*> ret;
    //Get standard macros from gcc
    KProcess proc;
    proc.setOutputChannelMode(KProcess::MergedChannels);
    proc.setTextModeEnabled(true);

    // The output of the following gcc commands is several line in the format:
    // "#define MACRO [definition]", where definition may or may not be present.
    // Parsing each line sequentially, we can easily build the macro set.
    proc <<"gcc" <<"-xc++" <<"-E" <<"-dM" <<"/dev/null";

    if (proc.execute(5000) == 0) {
        QString line;
        while (proc.canReadLine()) {
            QByteArray buff = proc.readLine();
            if (!buff.isEmpty()) {
                line = buff;
                if (line.startsWith("#define ")) {
                    line = line.right(line.length() - 8).trimmed();
                    int pos = line.indexOf(' ');
                    
                    ret.append(new rpp::pp_macro);
                    
                    rpp::pp_macro& macro(*ret.back());
                    if (pos != -1) {
                        macro.name = IndexedString( line.left(pos) );
                        macro.setDefinitionText( line.right(line.length() - pos - 1).toUtf8() );
                    } else {
                        macro.name = IndexedString( line );
                    }
                }
            }
        }
    } else {
        kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
    }
    return ret;
}