Beispiel #1
0
    void inflatorOstreamTest()
    {
      // test 
      std::stringstream deflatetarget;
      zim::DeflateStream deflator(deflatetarget);
      deflator << testtext << std::flush;

      {
        std::ostringstream msg;
        msg << "teststring with " << testtext.size() << " bytes compressed into " << deflatetarget.str().size() << " bytes";
        reportMessage(msg.str());
      }

      std::ostringstream inflatetarget;
      zim::InflateStream inflator(inflatetarget); // inflator is a ostream here
      inflator << deflatetarget.str() << std::flush;

      {
        std::ostringstream msg;
        msg << "teststring uncompressed to " << inflatetarget.str().size() << " bytes";
        reportMessage(msg.str());
      }

      CXXTOOLS_UNIT_ASSERT_EQUALS(testtext, inflatetarget.str());
    }
Beispiel #2
0
    void bunzip2OstreamTest()
    {
        // test
        std::stringstream bzip2target;

        {
            zim::Bzip2Stream compressor(bzip2target);
            compressor << testtext << std::flush;
            compressor.end();
        }

        {
            std::ostringstream msg;
            msg << "teststring with " << testtext.size() << " bytes compressed into " << bzip2target.str().size() << " bytes";
            reportMessage(msg.str());
        }

        std::ostringstream bunzip2target;

        {
            zim::Bunzip2Stream bunzip2(bunzip2target); // bunzip2 is a ostream here
            bunzip2 << bzip2target.str() << std::flush;
        }

        {
            std::ostringstream msg;
            msg << "teststring uncompressed to " << bunzip2target.str().size() << " bytes";
            reportMessage(msg.str());
        }

        CXXTOOLS_UNIT_ASSERT_EQUALS(testtext, bunzip2target.str());
    }
Beispiel #3
0
void CodaSignalHandler::tcfEvent(const Coda::CodaEvent &event)
{
    reportMessage(tr("CODA event: Type: %1 Message: %2").arg(event.type()).arg(event.toString()));

    switch (event.type()) {
    case Coda::CodaEvent::LocatorHello:
        handleConnected(event);
        break;
    case Coda::CodaEvent::ProcessExitedEvent:
        handleAppExited(event);
        break;
    default:
        reportMessage(tr("CODA unhandled event: Type: %1 Message: %2").arg(event.type()).arg(event.toString()));
        break;
    }
}
//
// FatalError::Reporter
//
void FatalError::Reporter::onFatalError (
    char const* message, char const* stackBacktrace, char const* filePath, int lineNumber)
{
    String formattedMessage = formatMessage (
        message, stackBacktrace, filePath, lineNumber);

    reportMessage (formattedMessage);
}
Beispiel #5
0
void CodaSignalHandler::handleSymbianInstall(const Coda::CodaCommandResult &result)
{
    if (result.type == Coda::CodaCommandResult::SuccessReply) {
        reportMessage(tr("Installation has finished."));
        d->action = static_cast<CodaAction>(d->action & ~ActionInstall);
        handleActions();
    } else {
        reportError(tr("Installation failed: %1").arg(result.errorString()));
    }
}
Beispiel #6
0
void CodaSignalHandler::handleDebugSessionControlStart(const Coda::CodaCommandResult &result)
{
    if (result.type == Coda::CodaCommandResult::SuccessReply) {
        d->codaDevice->sendRunProcessCommand(Coda::CodaCallback(this, &CodaSignalHandler::handleAppRunning),
                                             d->appFileName.toAscii(),
                                             d->commandLineArgs.split(' '));
        reportMessage(tr("Launching %1...").arg(QFileInfo(d->appFileName).fileName()));
    } else {
        reportError(tr("Failed to start CODA debug session control."));
    }
}
Beispiel #7
0
void CodaSignalHandler::handleAppRunning(const Coda::CodaCommandResult &result)
{
    if (result.type == Coda::CodaCommandResult::SuccessReply) {
        reportMessage(tr("Running..."));

        Coda::JsonValue value = result.values.at(0);
        readAppId(value);
    } else {
        reportError(tr("Launch failed: %1").arg(result.toString()));
    }
}
Beispiel #8
0
void CodaSignalHandler::initFileDownloading()
{
    if (!d->codaDevice || d->dlSrcFileName.isEmpty()) {
        emit done();
        return;
    }

    d->codaDevice->sendFileSystemOpenCommand(Coda::CodaCallback(this, &CodaSignalHandler::handleFileSystemOpen),
                                             d->dlSrcFileName.toAscii(), Coda::CodaDevice::FileSystem_TCF_O_READ);
    reportMessage(tr("Downloading %1...").arg(QFileInfo(d->dlSrcFileName).fileName()));
}
Beispiel #9
0
void CodaSignalHandler::initFileInstallation()
{
    if (!d->codaDevice || d->copyDstFileName.isEmpty()) {
        emit done();
        return;
    }

    QString installationDrive = "C";
    d->codaDevice->sendSymbianInstallSilentInstallCommand(Coda::CodaCallback(this, &CodaSignalHandler::handleSymbianInstall),
                                                          d->copyDstFileName.toAscii(),
                                                          installationDrive.toAscii());
    reportMessage(tr("Installing package \"%1\" on drive %2...").arg(QFileInfo(d->copyDstFileName).fileName(), installationDrive));
}
Beispiel #10
0
void CodaSignalHandler::handleFileSystemClose(const Coda::CodaCommandResult &result)
{
    if (result.type == Coda::CodaCommandResult::SuccessReply) {
        reportMessage(tr("File closed."));
        if (d->action & ActionCopy) {
            d->action = static_cast<CodaAction>(d->action & ~ActionCopy);
        } else if (d->action & ActionDownload) {
            d->action = static_cast<CodaAction>(d->action & ~ActionDownload);
        }
        handleActions();
    } else {
        reportError(tr("Failed to close the remote file: %1").arg(result.toString()));
    }
}
Beispiel #11
0
void CSMDoc::Operation::executeStage()
{
    Messages messages;

    while (mCurrentStage!=mStages.end())
    {
        if (mCurrentStep>=mCurrentStage->second)
        {
            mCurrentStep = 0;
            ++mCurrentStage;
        }
        else
        {
            try
            {
                mCurrentStage->first->perform (mCurrentStep++, messages);
            }
            catch (const std::exception& e)
            {
                emit reportMessage (CSMWorld::UniversalId(), e.what(), "", mType);
                abort();
            }

            ++mCurrentStepTotal;
            break;
        }
    }

    emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType);

    for (Messages::Iterator iter (messages.begin()); iter!=messages.end(); ++iter)
        emit reportMessage (iter->mId, iter->mMessage, iter->mHint, mType);

    if (mCurrentStage==mStages.end())
        exit();
}
Beispiel #12
0
void CodaSignalHandler::initFileSending()
{
    if (!d->codaDevice || d->copySrcFileName.isEmpty()) {
        emit done();
        return;
    }

    const unsigned flags =
            Coda::CodaDevice::FileSystem_TCF_O_WRITE
            |Coda::CodaDevice::FileSystem_TCF_O_CREAT
            |Coda::CodaDevice::FileSystem_TCF_O_TRUNC;
    d->putWriteOk = false;
    d->codaDevice->sendFileSystemOpenCommand(Coda::CodaCallback(this, &CodaSignalHandler::handleFileSystemOpen),
                                             d->copyDstFileName.toAscii(), flags);
    reportMessage(tr("Copying %1...").arg(QFileInfo(d->copyDstFileName).fileName()));
}
Beispiel #13
0
int CodaSignalHandler::run()
{
    d->codaDevice = SymbianUtils::SymbianDeviceManager::instance()->getCodaDevice(d->serialPortName);
    bool ok = d->codaDevice && d->codaDevice->device()->isOpen();
    if (!ok) {
        QString deviceError = "No such port";
        if (d->codaDevice)
            deviceError = d->codaDevice->device()->errorString();
        reportError(tr("Could not open serial device: %1").arg(deviceError));
        SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(d->codaDevice);
        return 1;
    }

    TextTraceHandler *traceHandler = new TextTraceHandler(
                SymbianUtils::SymbianDeviceManager::instance()->getOstChannel(d->serialPortName, 2), this);

    if (d->loglevel > 1) {
        d->codaDevice->setVerbose(1);
    }

    connect(d->codaDevice.data(), SIGNAL(error(const QString &)), this, SLOT(error(const QString &)));
    connect(d->codaDevice.data(), SIGNAL(logMessage(const QString &)), this, SLOT(logMessage(const QString &)));
    connect(d->codaDevice.data(), SIGNAL(serialPong(const QString &)), this, SLOT(serialPong(const QString &)));
    connect(d->codaDevice.data(), SIGNAL(tcfEvent(const Coda::CodaEvent &)), this, SLOT(tcfEvent(const Coda::CodaEvent &)));
    connect(this, SIGNAL(done()), this, SLOT(finished()));

    d->codaDevice->sendSerialPing(false);
    QTimer timer;
    if (d->timeout > 0) {
        connect(&timer, SIGNAL(timeout()), this, SLOT(timeout()));
        timer.setSingleShot(true);
        timer.start(d->timeout);
    }
    d->eventLoop = new QEventLoop();
    d->eventLoop->exec();
    timer.stop();
    int result = d->result;
    reportMessage(tr("Done."));

    delete traceHandler;
    disconnect(d->codaDevice.data(), 0, this, 0);
    SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(d->codaDevice);

    return result;
}
Beispiel #14
0
void Node::readMessage() {
  if (!this->messages.empty()) {
    pthread_mutex_lock(&(this->mutex));
    message msg = this->messages.front();
    this->messages.pop();
    int i;
    for (i = 0; i < this->numEdges; ++i) {
      if (this->edges[i].weight == msg.weight)
        break;
    }
    pthread_mutex_unlock(&(this->mutex));
    if(this->state == 0)
      this->wakeup();

    switch(msg.id) {
      case 0:
        connect(msg.args[0], i);
        break;
      case 1:
        initiate(msg.args[0], msg.args[1], msg.args[2], i);
        break;
      case 2:
        testMessage(msg.args[0], msg.args[1], i);
        break;
      case 3:
        accept(i);
        break;
      case 4:
        reject(i);
        break;
      case 5:
        reportMessage(msg.args[0], i);
        break;
      case 6:
        changeRootMessage(i);
        break;
      case 7:
        this->wakeup();
    }
  }
}
void SVGDocumentExtensions::reportError(const String& message)
{
    reportMessage(m_document, ErrorMessageLevel, "Error: " + message);
}
void SVGDocumentExtensions::reportWarning(const String& message)
{
    reportMessage(m_document, WarningMessageLevel, "Warning: " + message);
}
Beispiel #17
0
void CodaSignalHandler::logMessage(const QString &logMessage)
{
    reportMessage(tr("CODA log: %1").arg(logMessage));
}
Beispiel #18
0
void CodaSignalHandler::serialPong(const QString &codaVersion)
{
    reportMessage(tr("CODA version: %1").arg(codaVersion));
}