コード例 #1
0
void PlatformDomainNameAddressQuery::runBlocking() {
	//std::cout << "PlatformDomainNameResolver::doRun()" << std::endl;
	boost::asio::ip::tcp::resolver resolver(ioService);
	boost::asio::ip::tcp::resolver::query query(hostname, "5222");
	try {
		//std::cout << "PlatformDomainNameResolver::doRun(): Resolving" << std::endl;
		boost::asio::ip::tcp::resolver::iterator endpointIterator = resolver.resolve(query);
		//std::cout << "PlatformDomainNameResolver::doRun(): Resolved" << std::endl;
		if (endpointIterator == boost::asio::ip::tcp::resolver::iterator()) {
			//std::cout << "PlatformDomainNameResolver::doRun(): Error 1" << std::endl;
			emitError();
		}
		else {
			std::vector<HostAddress> results;
			for ( ; endpointIterator != boost::asio::ip::tcp::resolver::iterator(); ++endpointIterator) {
				boost::asio::ip::address address = (*endpointIterator).endpoint().address();
				results.push_back(address.is_v4() ? HostAddress(&address.to_v4().to_bytes()[0], 4) : HostAddress(&address.to_v6().to_bytes()[0], 16));
			}

			//std::cout << "PlatformDomainNameResolver::doRun(): Success" << std::endl;
			eventLoop->postEvent(
					boost::bind(boost::ref(onResult), results, boost::optional<DomainNameResolveError>()), 
					shared_from_this());
		}
	}
	catch (...) {
		//std::cout << "PlatformDomainNameResolver::doRun(): Error 2" << std::endl;
		emitError();
	}
}
コード例 #2
0
SGMXASScanActionControllerFileWriter::SGMXASScanActionControllerFileWriter(const QString &filePath, bool hasRank2Data, QObject *parent) :
	QObject(parent)
{
	filePath_ = filePath;
	hasRank2Data_ = hasRank2Data;

	QFileInfo rank1FileInfo(filePath+".dat");
	if(rank1FileInfo.exists())
		emitError(SGMXASScanActionControllerFileWriter::AlreadyExistsError);

	rank1File_ = new QFile(rank1FileInfo.filePath());
	if(!rank1File_->open(QIODevice::WriteOnly | QIODevice::Text))
		emitError(SGMXASScanActionControllerFileWriter::CouldNotOpenError);
	else
		QTimer::singleShot(0, this, SLOT(emitFileWriterIsBusy()));

	rank2File_ = 0; //NULL
	if(hasRank2Data_){
		QFileInfo rank2FileInfo(filePath+"_spectra.dat");
		if(rank2FileInfo.exists())
			emitError(SGMXASScanActionControllerFileWriter::AlreadyExistsError);

		rank2File_ = new QFile(rank2FileInfo.filePath());
		if(!rank2File_->open(QIODevice::WriteOnly | QIODevice::Text))
			emitError(SGMXASScanActionControllerFileWriter::CouldNotOpenError);
	}
}
コード例 #3
0
ファイル: qpython.cpp プロジェクト: M4rtinK/pyotherside
QVariant
QPython::getattr(QVariant obj, QString attr) {
    if (!SINCE_API_VERSION(1, 4)) {
        emitError(QString("Import PyOtherSide 1.4 or newer to use getattr()"));
        return QVariant();
    }

    ENSURE_GIL_STATE;

    PyObjectRef pyobj(convertQVariantToPyObject(obj), true);

    if (!pyobj) {
        emitError(QString("Failed to convert %1 to python object: '%1' (%2)").arg(obj.toString()).arg(priv->formatExc()));
        return QVariant();
    }

    QByteArray byteArray = attr.toUtf8();
    const char *attrStr = byteArray.data();

    PyObjectRef o(PyObject_GetAttrString(pyobj.borrow(), attrStr), true);

    if (!o) {
        emitError(QString("Attribute not found: '%1' (%2)").arg(attr).arg(priv->formatExc()));
        return QVariant();
    }

    return convertPyObjectToQVariant(o.borrow());
}
コード例 #4
0
//
//  We need to verify that all of its possible values
//  (in the enum list) 
//   is distinct and
//   refer to valid notations if toValidateNotation is set on
//
void DTDValidator::checkTokenList(const XMLAttDef&  curAttDef
                                ,       bool        toValidateNotation)
{

    XMLCh* list = XMLString::replicate(curAttDef.getEnumeration(), getScanner()->getMemoryManager());
    ArrayJanitor<XMLCh> janList(list, getScanner()->getMemoryManager());

    //
    //  Search forward for a space or a null. If a null,
    //  we are done. If a space, cap it and look it up.
    //
    bool    breakFlag = false;
    XMLCh*  listPtr = list;
    XMLCh*  lastPtr = listPtr;
    while (true)
    {
        while (*listPtr && (*listPtr != chSpace))
            listPtr++;

        //
        //  If at the end, indicate we need to break after
        //  this one. Else, cap it off here.
        //
        if (!*listPtr)
            breakFlag = true;
        else
            *listPtr++ = chNull;

        //distinction check
        //there should be no same token found in the remaining list
        if (XMLString::isInList(lastPtr, listPtr))
        {
            emitError
                (
                XMLValid::AttrDupToken
                , curAttDef.getFullName()
                , lastPtr
                );
        }

        if (toValidateNotation && !fDTDGrammar->getNotationDecl(lastPtr))
        {
            emitError
                (
                XMLValid::UnknownNotRefAttr
                , curAttDef.getFullName()
                , lastPtr
                );
        }

        // Break out if we hit the end last time
        if (breakFlag)
            break;

        // Else move upwards and try again
        lastPtr = listPtr;
    }
}
コード例 #5
0
ファイル: f3_launcher.cpp プロジェクト: pabloab/f3-qt
void f3_launcher::startCheck(QString devPath)
{
    if (stage != 0)
        stopCheck();

    f3_cui_output.clear();
    progress = 0;
    status = f3_launcher_running;
    emit f3_launcher_status_changed(f3_launcher_running);

    this->devPath = devPath;
    QString command;
    QStringList args;
    if (getOption("mode") == "quick")
    {
        command = QString(F3_PROBE_COMMAND);
        if (!probeCommand(command))
        {
            emitError(f3_launcher_no_quick);
            status = f3_launcher_stopped;
            emit f3_launcher_status_changed(f3_launcher_stopped);
            return;
        }
        if (getOption("memory") == "minimum")
            args << QString(F3_OPTION_MIN_MEM);
        if (getOption("destructive") == "true")
            args << QString(F3_OPTION_DESTRUCTIVE);
        args << QString(F3_OPTION_TIME);
        stage = 11;
        emit f3_launcher_status_changed(f3_launcher_staged);
    }
    else
    {
        command = QString(F3_WRITE_COMMAND);
        stage = 1;
        if (getOption("cache") == "write")
        {
            if (probeDiskFull(devPath) && probeCacheFile(devPath))
            {
                command = QString(F3_READ_COMMAND);
                stage = 2;
            }
            else
                emitError(f3_launcher_cache_nofound);
        }
        if (showProgress)
            args << QString(F3_OPTION_SHOW_PROGRESS);
        emit f3_launcher_status_changed(f3_launcher_staged);
    }
    args << devPath;
    f3_cui.start(command, args);

    if (showProgress)
    {
        timer.start();
    }
}
コード例 #6
0
void TrkDevice::tryTrkRead()
{
#ifdef Q_OS_WIN
    const DWORD BUFFERSIZE = 1024;
    char buffer[BUFFERSIZE];
    DWORD charsRead;
    DWORD totalCharsRead = 0;

    while (TryReadFile(d->hdevice, buffer, BUFFERSIZE, &charsRead, NULL)) {
        totalCharsRead += charsRead;
        d->trkReadBuffer.append(buffer, charsRead);
        if (isValidTrkResult(d->trkReadBuffer, d->serialFrame))
            break;
    }
    if (verbose() && totalCharsRead)
        logMessage("Read" + d->trkReadBuffer.toHex());
    if (!totalCharsRead)
        return;
    const ushort len = trk::isValidTrkResult(d->trkReadBuffer, d->serialFrame);
    if (!len) {
        const QString msg = QString::fromLatin1("Partial message: %1").arg(stringFromArray(d->trkReadBuffer));
        emitError(msg);
        return;
    }
#else
    const int size = bytesAvailable(d->file.handle());
    if (!size)
        return;
    const QByteArray data = d->file.read(size);
    if (verbose())
        logMessage("READ " + data.toHex());
    d->trkReadBuffer.append(data);
    const ushort len = trk::isValidTrkResult(d->trkReadBuffer, d->serialFrame);
    if (!len) {
        if (d->trkReadBuffer.size() > 10) {
            const QString msg = QString::fromLatin1("Unable to extract message from '%1' '%2'").
                             arg(QLatin1String(d->trkReadBuffer.toHex())).arg(QString::fromAscii(d->trkReadBuffer));
            emitError(msg);
        }
        return;
    }
#endif // Q_OS_WIN
    trk::TrkResult r;
    QByteArray rawData;
    while (extractResult(&d->trkReadBuffer, d->serialFrame, &r, &rawData)) {
        if (verbose())
            logMessage("Read TrkResult " + r.data.toHex());
        emit messageReceived(r);
        if (!rawData.isEmpty())
            emit rawDataReceived(rawData);
    }
}
コード例 #7
0
bool ConsoleProcess::start(const QString &program, const QString &args)
{
    if (isRunning())
        return false;

    d->m_errorString.clear();
    d->m_error = QProcess::UnknownError;

    QString pcmd;
    QString pargs;
    if (d->m_mode != Run) { // The debugger engines already pre-process the arguments.
        pcmd = program;
        pargs = args;
    } else {
        QtcProcess::Arguments outArgs;
        QtcProcess::prepareCommand(program, args, &pcmd, &outArgs, OsTypeWindows,
                                   &d->m_environment, &d->m_workingDir);
        pargs = outArgs.toWindowsArgs();
    }

    const QString err = stubServerListen();
    if (!err.isEmpty()) {
        emitError(QProcess::FailedToStart, msgCommChannelFailed(err));
        return false;
    }

    QStringList env = d->m_environment.toStringList();
    if (!env.isEmpty()) {
        d->m_tempFile = new QTemporaryFile();
        if (!d->m_tempFile->open()) {
            stubServerShutdown();
            emitError(QProcess::FailedToStart, msgCannotCreateTempFile(d->m_tempFile->errorString()));
            delete d->m_tempFile;
            d->m_tempFile = 0;
            return false;
        }
        QTextStream out(d->m_tempFile);
        out.setCodec("UTF-16LE");
        out.setGenerateByteOrderMark(false);
        foreach (const QString &var, fixWinEnvironment(env))
            out << var << QChar(0);
        out << QChar(0);
        out.flush();
        if (out.status() != QTextStream::Ok) {
            stubServerShutdown();
            emitError(QProcess::FailedToStart, msgCannotWriteTempFile());
            delete d->m_tempFile;
            d->m_tempFile = 0;
            return false;
        }
    }
コード例 #8
0
ファイル: itemeditor.cpp プロジェクト: fade2gray/CopyQ
void ItemEditor::close()
{
    // check if file was modified before closing
    if ( m_modified || fileModified() )
        emit fileModified(m_data, m_mime);

    if (m_editor && m_editor->exitCode() != 0 ) {
        emitError( tr("editor exit code is %1").arg(m_editor->exitCode()) );
        const QByteArray errors = m_editor->readAllStandardError();
        if ( !errors.isEmpty() )
            emitError( QString::fromUtf8(errors) );
    }

    emit closed(this);
}
コード例 #9
0
void AddCollectionTask::doStart(KIMAP::Session *session)
{
    if (parentCollection().remoteId().isEmpty()) {
        qCWarning(IMAPRESOURCE_LOG) << "Parent collection has no remote id, aborting." << collection().name() << parentCollection().name();
        emitError(i18n("Cannot add IMAP folder '%1' for a non-existing parent folder '%2'.",
                       collection().name(),
                       parentCollection().name()));
        changeProcessed();
        return;
    }

    const QChar separator = separatorCharacter();
    m_pendingJobs = 0;
    m_session = session;
    m_collection = collection();
    m_collection.setName(m_collection.name().replace(separator, QString()));
    m_collection.setRemoteId(separator + m_collection.name());

    QString newMailBox = mailBoxForCollection(parentCollection());

    if (!newMailBox.isEmpty()) {
        newMailBox += separator;
    }

    newMailBox += m_collection.name();

    qCDebug(IMAPRESOURCE_LOG) << "New folder: " << newMailBox;

    KIMAP::CreateJob *job = new KIMAP::CreateJob(session);
    job->setMailBox(newMailBox);

    connect(job, &KIMAP::CreateJob::result, this, &AddCollectionTask::onCreateDone);

    job->start();
}
コード例 #10
0
void Transmitter::sendKeyPacket()
{
	char *out;
	int keylen = rsa->getPeerPublicKeyLen();
	try
	{
		if (keylen > 0)
		{
			if (blowfish)
			{
				int len = rsa->encrypt(blowfish->getPass(), blowfish->getPassLen(), &out);
				sendSpecialPacket(out, len, DRTA_INFO_NEW_KEY);
				free(out);
			}
		}
		else
		{
			sendResetPacket();
		}
	}
	catch (Error e)
	{
		emitError(e.getText());
	}
}
コード例 #11
0
ファイル: recognitioncontrol.cpp プロジェクト: KDE/simon
void RecognitionControl::run()
{
  Q_ASSERT(recog);

  RecognitionConfiguration *cfg = setupConfig();
  bool success = recog->init(cfg);
  delete cfg;
  if (!success) {
    emitError(i18n("Failed to setup recognition: %1", recog->getLastError()));
    return;
  }

  m_initialized=true;

  while (shouldBeRunning)
  {
    if (!queueLock.tryLock(500)) continue;
    QString file;
    if (!toRecognize.isEmpty())
      file = toRecognize.dequeue();
    queueLock.unlock();
    if (file.isNull()) {
      QThread::msleep(100);
    } else {
      emit recognitionResult(file, recog->recognize(file));
      emit recognitionDone(file);
    }
  }
}
コード例 #12
0
ファイル: Expr.cpp プロジェクト: scunz/pas2c
    bool Expr::parseUnaryExpression() {
        PARSER_FLOW_TRACER();
        /* left associative */

        switch (ahead().type()) {
        case T_AT_SIGN:
            emitError("addr-of-operator unsupported");
            // ### @foo (addr-of operator)
            return false;

        case T_MINUS:
        case T_PLUS:
        case T_NOT: {
            Model::ExprUnary::Ptr result = new Model::ExprUnary;
            result->setUnaryOperator(tokenToUnary(ahead().type()));
            next();
            FAIL_IF_NOT(parsePrimaryExpression());
            result->setOperand(model());
            setModel(result);
            return true; }

        default:
            return parsePrimaryExpression();
        }
    }
コード例 #13
0
void ListCommand::execute(const QVariantMap options)
{
    DbFilter queryFilter = options.value(OPTION_DB_FILTER).value<DbFilter>();
    CommandFileList cmd(getSession());
    cmd.setAutoDelete(true);
    cmd.setFields("items(fileSize,id,title,modifiedDate,createdDate,downloadUrl, headRevisionId)");
    QString query = QueryEntry::getEntries(queryFilter);

    // Keepass db folder is set to root in Google drive if user did not customize  it
    if (config()->get("cloud/GdriveKeepassFolder").toString().length()
        > 0) cmd.execForFolder(config()->get(
                                   "cloud/GdriveKeepassFolder").toString(), query);
    else cmd.exec(query);
    cmd.waitForFinish(false);
    if (cmd.error() == Errors::NO_ERROR) {
        qRegisterMetaType<GoogleDrive::FileInfoList>("GoogleDrive::FileInfoList");
        qRegisterMetaType<GoogleDrive::FileInfo>("GoogleDrive::FileInfo");
        GoogleDrive::FileInfoList dbList = cmd.files();
        RemoteFileList remoteFileList = RemoteFileImpl::fromGDriveFileInfoList(dbList);
        setResult(KeePassxDriveSync::ResultBuilder().addValue(remoteFileList).build());
        emitSuccess();
    } else {
        emitError(Errors::FileError::LIST_FILES_PROBLEM,
            QString("Failed to list files for keepass directory"));
    }
}
コード例 #14
0
ファイル: qpython.cpp プロジェクト: M4rtinK/pyotherside
void
QPython::receive(QVariant variant)
{
    QVariantList list = variant.toList();
    QString event = list[0].toString();
    if (handlers.contains(event)) {
        QJSValue callback = handlers[event];
        QJSValueList args;
        for (int i=1; i<list.size(); i++) {
            args << callback.engine()->toScriptValue(list[i]);
        }
        QJSValue result = callback.call(args);
        if (result.isError()) {
            // Ideally we would throw the error back to Python (so that the
            // pyotherside.send() method fails, as this is where the call
            // originated). We can't do this, because the pyotherside.send()
            // call is asynchronous (it returns before we call into JS), so do
            // the next best thing and report the error to our error handler in
            // QML instead.
            emitError("pyotherside.send() failed handler: " +
                    result.property("fileName").toString() + ":" +
                    result.property("lineNumber").toString() + ": " +
                    result.toString());
        }
    } else {
        // Default action
        emit received(variant);
    }
}
コード例 #15
0
ファイル: server.cpp プロジェクト: tstandley/DSN4
void Server::manageError(QString address, int port, QAbstractSocket::SocketError error){


    int playerIndex = getPlayerIndex(address, port);

    if(networkAnswers[playerIndex].isEmpty()){
        nbNetworkAnswers++;
    }
    else{
        qDebug() << "Server::manageError() : SUPER WEIRD, player sent first message "
                 << networkAnswers[playerIndex] << " then error " <<  error;
    }

    switch(waitingForMessage){
    case(WAITING_FOR_MESSAGE::INFO):
    case(WAITING_FOR_MESSAGE::START):
        emit playerReady(playerIndex, false);
        break;
    case(WAITING_FOR_MESSAGE::PLAY):
        moves[playerIndex] = "";
        break;
    default:
        break;
    }

    if(nbNetworkAnswers == addresses.size()){
        handleTransition();
    }

    emit emitError(playerIndex, error);
}
コード例 #16
0
ファイル: qpython.cpp プロジェクト: M4rtinK/pyotherside
void
QPython::addImportPath(QString path)
{
    ENSURE_GIL_STATE;

    // Strip leading "file://" (for use with Qt.resolvedUrl())
    if (path.startsWith("file://")) {
#ifdef WIN32
        // On Windows, path would be "file:///C:\...", so strip 8 chars to get
        // a Windows-compatible absolute filename to be used as import path
        path = path.mid(8);
#else
        path = path.mid(7);
#endif
    }

    if (SINCE_API_VERSION(1, 3) && path.startsWith("qrc:")) {
        const char *module = "pyotherside.qrc_importer";
        QString filename = "/io/thp/pyotherside/qrc_importer.py";
        QString errorMessage = priv->importFromQRC(module, filename);
        if (!errorMessage.isNull()) {
            emitError(errorMessage);
        }
    }

    QByteArray utf8bytes = path.toUtf8();

    PyObject *sys_path = PySys_GetObject((char*)"path");

    PyObjectRef cwd(PyUnicode_FromString(utf8bytes.constData()), true);
    PyList_Insert(sys_path, 0, cwd.borrow());
}
コード例 #17
0
// MEMBER FUNCTION
int Trick::MemoryManager::ref_assignment( REF2* R, V_TREE* V) {

    int ret = 0;
    UCFn *cf = NULL;

    // Create a units conversion function if necessary.
    if (R->units) {
        try {
            Unit *from_units = new Unit(R->units);
            Unit *to_units = new Unit(R->attr->units);
            // This Conversion_to call allocates a new UCFn
            cf = from_units->Conversion_to( to_units);
            delete from_units;
            delete to_units;
        } catch (Unit::CONVERSION_ERROR) {
            std::stringstream message;
            message << "Can't convert \"" << R->units << "\" to \"" << R->attr->units << "\".";
            emitError(message.str());
            cf = NULL;
            return TRICK_UNITS_CONVERSION_ERROR ;
        }
    }

    // R->num_index is badly named. It is really the current dimension
    ret = assign_recursive( R->address, R->attr, R->num_index, 0, V, cf);
    delete cf ;

    return ( ret);

}
コード例 #18
0
// MEMBER FUNCTION
void Trick::MemoryManager::clear_var( void* address) {

    ATTRIBUTES* reference_attr;
    ALLOC_INFO* alloc_info;

    pthread_mutex_lock(&mm_mutex);
    alloc_info = get_alloc_info_at( address);
    if (alloc_info != NULL) {
        reference_attr = make_reference_attr( alloc_info);
        if (alloc_info->type == TRICK_STRUCTURED ) {
            if (alloc_info->num_index != 0) {
                clear_arrayed_class( (char*)(alloc_info->start), reference_attr, 0, 0) ;
            } else {
                clear_class( (char*)(alloc_info->start), alloc_info->attr) ;
            }
        } else {
            clear_rvalue( alloc_info->start, reference_attr, 0, 0 );
        }
        free_reference_attr( reference_attr);
    } else {
        std::stringstream message;
        message << "Cannot clear the variable at address " << address
                << "because memory manager knows nothing about it." ;
        emitError(message.str());
    }
    pthread_mutex_unlock(&mm_mutex);
}
コード例 #19
0
    bool createImportDir(const KUrl url)
    {
        Q_ASSERT(url.isLocalFile());
        // FIXME: Support remote urls

        if (!KStandardDirs::makeDir(url.toLocalFile())) {
            emitError(i18n("Could not create destination folder."));
            return false;
        }
        QString message;
        mTempImportDir = FileUtils::createTempDir(url.toLocalFile(), ".gwenview_importer-", &message);
        if (mTempImportDir.isEmpty()) {
            emitError(i18n("Could not create temporary upload folder:\n%1", message));
            return false;
        }
        return true;
    }
AMContinuousScanActionControllerAMDSClientDataRequestFileWriter::AMContinuousScanActionControllerAMDSClientDataRequestFileWriter(const QString &filePath, QObject *parent) :
	QObject(parent)
{
	filePath_ = filePath;
	QFileInfo clientDataRequestFileInfo(filePath+".cdr");

	if(clientDataRequestFileInfo.exists())
		emitError(AMScanActionControllerBasicFileWriter::AlreadyExistsError);

	clientDataRequestFile_ = new QFile(clientDataRequestFileInfo.filePath());

	if(!clientDataRequestFile_->open(QIODevice::WriteOnly))
		emitError(AMScanActionControllerBasicFileWriter::CouldNotOpenError);

	else
		QTimer::singleShot(0, this, SLOT(emitFileWriterIsBusy()));
}
コード例 #21
0
void AuthorizedCommand::refreshTokenFinished()
{
    CommandRefreshToken* cmd = qobject_cast<CommandRefreshToken*>(sender());
    if (cmd->error() == NoError)
        reexecuteQuery();
    else
        emitError(AuthorizationNeeded, cmd->errorString());
}
コード例 #22
0
void HttpDownloadWorker::doWork()
{
	if(!mapFile2Memory()) //Ó³ÉäÎļþµ½ÄÚ´æ
	{
		emitError(error());
		return;
	}
	downloadSmallPiece();
}
コード例 #23
0
ファイル: SQLCache.cpp プロジェクト: KDE/trojita
bool SQLCache::childMailboxesFresh(const QString &mailbox) const
{
    queryChildMailboxesFresh.bindValue(0, mailboxName(mailbox));
    if (! queryChildMailboxesFresh.exec()) {
        emitError(QObject::tr("Query queryChildMailboxesFresh failed"), queryChildMailboxesFresh);
        return false;
    }
    return queryChildMailboxesFresh.first();
}
コード例 #24
0
ファイル: Expr.cpp プロジェクト: scunz/pas2c
    bool Expr::parsePrimaryExpression() {
        PARSER_FLOW_TRACER();

        switch(ahead().type()) {
        case T_LEFT_PAREN: {
            REQUIRE_TOKEN(T_LEFT_PAREN);
            FAIL_IF_NOT(parseExpression());
            REQUIRE_TOKEN(T_RIGHT_PAREN);
            return true; }

        case T__NUMBER: {
            next();
            setModel(new Model::ExprConstNumber(current().number()));
            return true; }

        case T__STRING: {
            next();
            setModel(new Model::ExprConstString(QString::fromUtf8(current().text().constData())));
            return true; }

        case T__FLOAT:
            next();
            setModel(new Model::ExprConstDouble(current().numberFloat()));
            return true;

        case T__IDENTIFIER: {

            Model::Decl::Ptr decl = curCtx()->lookup(ahead().identifier());
            if (!decl) {
                emitError(QLatin1Literal("Unknown identifier: ") %
                          Model::Identifier(ahead().identifier()).toString());
                return false;
            }

            if (decl->type() == Model::oDeclConst) {
                next();

                Model::ExprConstConst::Ptr ecc = new Model::ExprConstConst;
                ecc->setDecl(decl.scast<Model::DeclConst>());
                setModel(ecc);

                return true;
            }

            LValue lvp(this);
            lvp.setOptions(LValue::AllowFunctionCall);
            FAIL_IF_NOT(lvp());

            Model::ExprLValue::Ptr elv = new Model::ExprLValue;
            elv->setLValue(lvp.model());
            setModel(elv);
            return true; }

        default:
            return false;
        }
    }
コード例 #25
0
ファイル: DeviceDS18B20.cpp プロジェクト: aquaforum/ctrl2
DallasError DeviceDS18B20::readConfiguration()
{
	QMutexLocker locker(busMutex);
	DallasError error = ds18b20GetResolution(&id, &m_resolution);
	if (error != DALLAS_NO_ERROR) {
		QString message(dallasGetErrorText(error));
		emitError(message);
	}
	return error;
}
コード例 #26
0
ファイル: DeviceDS18B20.cpp プロジェクト: aquaforum/ctrl2
DallasError DeviceDS18B20::writeConfiguration()
{
	QMutexLocker locker(busMutex);
	DallasError error = ds18b20Setup(&id, m_resolution, DS18B20_NO_ALARM_LOW, DS18B20_NO_ALARM_HIGH);
	if (error != DALLAS_NO_ERROR) {
		QString message(dallasGetErrorText(error));
		emitError(message);
	}
	return error;
}
コード例 #27
0
// MEMBER FUNCTION
void* Trick::MemoryManager::
      declare_extern_var( void*       address,
                          const char* element_definition,
                          int         n_elems) {

    void* res_address = NULL;
    int cdims[8];
    int n_cdims;

    ADefParseContext* context = NULL;
    std::stringstream alloc_decl_sstream;

    /** We know that our array will be at least one dimensional and that dimension contains n_elems elements. */
    cdims[0] = n_elems;
    n_cdims = 1;

    alloc_decl_sstream << element_definition;

    /** @li Create a parse context. */
    context = new ADefParseContext( &alloc_decl_sstream);

    if (context != NULL) {

    /** @li Parse the allocation definition and ensure that the dimension is at least one less than the maximum of 8. */
        if (( ADEF_parse( context) == 0) && (context->n_cdims < 8) ){
            int ii;

            /** @li Add the dimensions of the element definition. */
            for (ii=0 ; ii < context->n_cdims ; ii++) {
                cdims[ii+1] = context->cdims[ii];
                n_cdims ++;
            }

            /** @li Call the general form of declare_var to perform the allocation. */
            res_address = declare_extern_var( address,
                                              context->type,
                                              context->user_type_name,
                                              context->n_stars,
                                              context->var_name,
                                              n_cdims,
                                              cdims);

            /** @li Delete the parse context. */
            delete( context);
        } else {
            std::stringstream message;
            message << "declare_extern_var( \"" << element_definition
                    << "\"," << n_elems << ") failed.";
            emitError(message.str());
        }
    }
    /** @li Return the address of the allocation. */
    return ( res_address);
}
コード例 #28
0
bool TrkWriteQueueDevice::trkWriteRawMessage(const TrkMessage &msg)
{
    const QByteArray ba = trk::frameMessage(msg.code, msg.token, msg.data, serialFrame());
    if (verbose())
        logMessage("WRITE: " + trk::stringFromArray(ba));
    QString errorMessage;
    const bool rc = write(ba, &errorMessage);
    if (!rc)
        emitError(errorMessage);
    return rc;
}
コード例 #29
0
ファイル: f3_launcher.cpp プロジェクト: pabloab/f3-qt
f3_launcher::f3_launcher()
{
    errCode = f3_launcher_ok;
    float version = probeVersion();
    if (version == 0)
    {
        emitError(f3_launcher_no_cui);
        return;
    }
    if (version < 4.0 || !probeCommand(F3_PROBE_COMMAND))
    {
        emitError(f3_launcher_no_quick);
    }
    if (version <= 6.0)
    {
        emitError(f3_launcher_no_progress);
        showProgress = false;
    }
    else
    {
        emit f3_launcher_status_changed(f3_launcher_ready);
        showProgress = true;
    }

    options["mode"] = "legacy";
    options["cache"] = "none";
    options["memory"] = "full";
    options["destructive"] = "no";

    stage = 0;
    connect(&f3_cui,
            SIGNAL(finished(int,QProcess::ExitStatus)),
            this,
            SLOT(on_f3_cui_finished()));
    connect(&timer,
            SIGNAL(timeout()),
            this,
            SLOT(on_timer_timeout()));
    timer.setInterval(1500);

}
コード例 #30
0
ファイル: GeomConvHelper.cpp プロジェクト: cathyyul/sumo-0.18
// ===========================================================================
// method definitions
// ===========================================================================
PositionVector
GeomConvHelper::parseShapeReporting(const std::string& shpdef, const std::string& objecttype,
                                    const char* objectid, bool& ok, bool allowEmpty, bool report) {
    if (shpdef == "") {
        if (!allowEmpty) {
            emitError(report, "Shape", objecttype, objectid, "the shape is empty");
            ok = false;
        }
        return PositionVector();
    }
    StringTokenizer st(shpdef, " ");
    PositionVector shape;
    while (st.hasNext()) {
        StringTokenizer pos(st.next(), ",");
        if (pos.size() != 2 && pos.size() != 3) {
            emitError(report, "Shape", objecttype, objectid, "the position is neither x,y nor x,y,z");
            ok = false;
            return PositionVector();
        }
        try {
            SUMOReal x = TplConvert::_2SUMOReal(pos.next().c_str());
            SUMOReal y = TplConvert::_2SUMOReal(pos.next().c_str());
            if (pos.size() == 2) {
                shape.push_back(Position(x, y));
            } else {
                SUMOReal z = TplConvert::_2SUMOReal(pos.next().c_str());
                shape.push_back(Position(x, y, z));
            }
        } catch (NumberFormatException&) {
            emitError(report, "Shape", objecttype, objectid, "not numeric position entry");
            ok = false;
            return PositionVector();
        } catch (EmptyData&) {
            emitError(report, "Shape", objecttype, objectid, "empty position entry");
            ok = false;
            return PositionVector();
        }
    }
    return shape;
}