コード例 #1
0
bool OscapScannerBase::tryToReadStdOutChar(QProcess& process)
{
    char readChar = '\0';
    if (!process.getChar(&readChar))
        return false;

    if (!mCapabilities.progressReporting())
        return true; // We did read something but it's not in a format we can parse.

    if (readChar == ':')
    {
        mLastRuleID = mReadBuffer;
        if (mReadingRuleID) // sanity check
        {
            emit progressReport(mLastRuleID, "processing");
        }
        else
        {
            emit warningMessage(QString(
                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                "':' encountered while not reading rule ID, newline and/or rule result are missing! "
                "Read buffer is '%1'.")).arg(mReadBuffer));
        }
        mReadBuffer = "";
        mReadingRuleID = false;
    }
    else if (readChar == '\n')
    {
        if (!mReadingRuleID) // sanity check
        {
            emit progressReport(mLastRuleID, mReadBuffer);
        }
        else
        {
            emit warningMessage(QString(
                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                "Newline encountered while reading rule ID, rule result and/or ':' are missing! "
                "Read buffer is '%1'.")).arg(mReadBuffer));
        }
        mReadBuffer = "";
        mReadingRuleID = true;
    }
    else
    {
        // we know for sure that buffer[0] can only contain ASCII characters
        // (IDs and special keywords regarding rule status)
        mReadBuffer.append(QChar::fromAscii(readChar));
    }

    return true;
}
コード例 #2
0
ファイル: MprRecorder.cpp プロジェクト: LordGaav/sipxecs
UtlBoolean MprRecorder::disable(Completion code)
{
   UtlBoolean res = FALSE;

   // Lock so that the file contents cannot be changed out
   // from under us while we are updating the file.
   OsLock lock(mMutex);

   if (mFileDescriptor > -1)
   {
      if (mRecFormat == WAV_PCM_16)
      {
         updateWaveHeaderLengths(mFileDescriptor);
      }
   }
   if (mStatus != code)
   {
      OsSysLog::add(FAC_MP, PRI_DEBUG, "MprRecorder::disable to report progress mState(%d) code(%d), mFileDescriptor(0x%08x)",
                     mStatus, code, mFileDescriptor);
      progressReport(code);
   }

   if (RECORDING == mStatus) {
      OsSysLog::add(FAC_MP, PRI_DEBUG, "MprRecorder::disable -- stopping recorder\n");
      progressReport(RECORD_STOPPED);
   } else {
      OsSysLog::add(FAC_MP, PRI_DEBUG, "MprRecorder::disable (not already recording)\n");
   }
   mConsecutiveInactive = 0;

   OsSysLog::add(FAC_MP, PRI_DEBUG, "MprRecorder::disable setting mpEvent (0x%p) to NULL", mpEvent);

   {
      if (mpEvent != NULL)
      {
         mpEvent = NULL;  // event may be released, do not signal the event any more,
      }

      if (mFileDescriptor > -1)
      {
         close(mFileDescriptor);
         mFileDescriptor = -1;
      }
      res = (MpResource::disable() && (mFileDescriptor == -1));
   }

   return res;
}
コード例 #3
0
ファイル: DeepScanner.cpp プロジェクト: tomazos/Folderscope
void DeepScanner::processFile(FIFile* pFile)
{
	Error error;
	class SkipFile {};

	try
	{
		Path path = pFile->getAbsolutePath(error, m_db.m_root);
		if (error)
			throw SkipFile();

		m_fProgress = Real64(m_iCurItem) / Real64(m_db.m_pFIFiles.size());
		progressReport(path);

		FileInputStream fis(error, path);
		if (error)
			throw SkipFile();

		FIIndex* pIndex = vivFileIndex(error, fis);

		if (error)
			throw SkipFile();

		pFile->setFIIndex(pIndex);
		pIndex->addFIFile(pFile);
	}
	catch (SkipFile&)
	{
		UTF16 sErrorMessage = (error ? UTF16(error) : L"Unknown Error");

		skipWarning(pFile->getPath(), error);
	}
}
コード例 #4
0
ファイル: MprRecorder.cpp プロジェクト: LordGaav/sipxecs
UtlBoolean MprRecorder::handleBegin()
{
   mTotalBytesWritten = 0;
   mTotalSamplesWritten = 0;
   progressReport(RECORDING);
   enable();
   return TRUE;
}
void MaemoPublishingResultPageFremantleFree::initializePage()
{
    cancelButton()->disconnect();
    connect(cancelButton(), SIGNAL(clicked()), SLOT(handleCancelRequest()));
    connect(m_publisher, SIGNAL(finished()), SLOT(handleFinished()));
    connect(m_publisher,
        SIGNAL(progressReport(QString,MaemoPublisherFremantleFree::OutputType)),
        SLOT(handleProgress(QString,MaemoPublisherFremantleFree::OutputType)));
    m_publisher->publish();
}
コード例 #6
0
bool OscapScannerBase::tryToReadStdOutChar(QProcess& process)
{
    char readChar = '\0';
    if (!process.getChar(&readChar))
        return false;

    if (!mCapabilities.progressReporting())
        return true; // We did read something but it's not in a format we can parse.

    if (readChar == ':')
    {
        switch (mReadingState)
        {
            case RS_READING_PREFIX:
                {
                    // Openscap <= 1.2.10 (60fb9f0c98eee) sends this message through stdout
                    if (mReadBuffer=="Downloading")
                    {
                         mReadingState = RS_READING_DOWNLOAD_FILE;
                    }
                    else
                    {
                        mLastRuleID = mReadBuffer;
                        emit progressReport(mLastRuleID, "processing");
                        mReadingState = RS_READING_RULE_RESULT;
                    }
                    mReadBuffer = "";
                }
                break;

            case RS_READING_RULE_RESULT:
                {
                    emit warningMessage(QString(
                                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                                    "':' encountered while not reading rule ID, newline and/or rule result are missing! "
                                    "Read buffer is '%1'.")).arg(mReadBuffer));
                    mReadBuffer = "";
                }
                break;
            case RS_READING_DOWNLOAD_FILE:
                {
                    // When fetching remote content, openscap will inform scap-workbench about
                    // resources being downloaded. Keep any colon found in URL of file being downloaded.
                    mReadBuffer.append(QChar::fromAscii(readChar));
                }
                break;

            default:
                // noop
                break;
        }
    }
    else if (readChar == '\n')
    {
        switch(mReadingState)
        {
            case RS_READING_PREFIX:
                // If we found a '\n' while reading prefix, we might have received an error or
                // warning message through stdout.
                if (mReadBuffer.contains("--fetch-remote-resources"))
                {
                    // If message is about --fetch-remote-resources, emit a nice warning.
                    // This is needed for workbench to be able to handle messages from machines
                    // running older versions of openscap.
                    // From openscap version 1.2.11, this message is sent through stderr
                    // and therefore is handled accordingly by workbench.
                    emit warningMessage(guiFriendlyMessage(mReadBuffer));
                }
                else
                {
                    // No other error or warning messages are expected through stdout,
                    // so it is likely that a parsing error occured.
                    emit warningMessage(QString(
                                QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. "
                                    "Newline encountered while reading rule ID, rule result and/or ':' are missing! "
                                    "Read buffer is '%1'.")).arg(mReadBuffer));
                }
                break;

            case RS_READING_RULE_RESULT:
                emit progressReport(mLastRuleID, mReadBuffer);
                break;

            case RS_READING_DOWNLOAD_FILE_STATUS:
                {
                    QString downloadStatus = mReadBuffer.mid(1);
                    if (downloadStatus == "ok")
                        emit infoMessage(QString("Downloading of \"%1\" finished: %2").arg(mLastDownloadingFile).arg(downloadStatus));
                    else
                        emit warningMessage(QString("Failed to download \"%1\"!").arg(mLastDownloadingFile));
                }
                break;
            default:
                // noop
                break;
        }
        mReadingState = RS_READING_PREFIX;
        mReadBuffer = "";
    }
    else if ( (readChar == '.') && (mReadingState == RS_READING_DOWNLOAD_FILE) && (mReadBuffer.endsWith(" ..")))
    {
        int urlLen = mReadBuffer.length();
        urlLen -= 1; // without first space
        urlLen -= 3; // without "progress dots"
        mLastDownloadingFile = mReadBuffer.mid(1, urlLen);

        emit infoMessage(QString("Downloading of \"%1\"...").arg(mLastDownloadingFile));

        mReadBuffer = "";
        mReadingState = RS_READING_DOWNLOAD_FILE_STATUS;
    }
    else
    {
        // we know for sure that buffer[0] can only contain ASCII characters
        // (IDs and special keywords regarding rule status)
        mReadBuffer.append(QChar::fromAscii(readChar));
    }

    return true;
}
コード例 #7
0
ファイル: Scenery3d.cpp プロジェクト: Stellarium/stellarium
void Scenery3d::updateProgress(const QString &str, int val, int min, int max) const
{
	emit progressReport(str,val,min,max);
}