コード例 #1
0
void DownloadItem::metaDataChanged()
{
    if (m_reply->hasRawHeader(QByteArray("Content-Disposition"))) {
        QByteArray header = m_reply->rawHeader(QByteArray("Content-Disposition"));
        int index = header.indexOf("filename=");
        if (index >= 0) {
            header = header.mid(index+9);
            if (header.startsWith("\"") || header.startsWith("'"))
                header = header.mid(1);
            if (header.endsWith("\"") || header.endsWith("'"))
                header.chop(1);
            m_fileName = QUrl::fromPercentEncoding(header);
        }
        // Sometimes "filename=" and "filename*=UTF-8''" is set.
        // So, search for this too.
        index = header.indexOf("filename*=UTF-8''");
        if (index >= 0) {
            header = header.mid(index+17);
            if (header.startsWith("\"") || header.startsWith("'"))
                header = header.mid(1);
            if (header.endsWith("\"") || header.endsWith("'"))
                header.chop(1);
            m_fileName = QUrl::fromPercentEncoding(header);
        }
    }

    QVariant statusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
    if (!statusCode.isValid())
        return;
    int status = statusCode.toInt();
    if (status != 200) {
        QString reason = m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
        qDebug() << reason;
    }
}
コード例 #2
0
ファイル: Helper.cpp プロジェクト: marc-sturm/cppCORE
QStringList Helper::loadTextFile(QSharedPointer<QFile> file, bool trim_lines, QChar skip_header_char, bool skip_empty_lines)
{
	QStringList output;
	while (!file->atEnd())
	{
		QByteArray line = file->readLine();

		//remove newline or trim
		if (trim_lines)
		{
			line = line.trimmed();
		}
		else
		{
			while (line.endsWith('\n') || line.endsWith('\r')) line.chop(1);
		}

		//skip empty lines
		if (skip_empty_lines && line.count()==0) continue;

		//skip header lines
		if (skip_header_char!=QChar::Null && line.count()!=0 && line[0]==skip_header_char.toLatin1()) continue;

		output.append(line);
	}

	return output;
}
コード例 #3
0
void ImapMessageTest::testMailAddressFormat()
{
    QFETCH( Imap::Message::MailAddress, addr );
    QFETCH( QString, pretty );
    QFETCH( QByteArray, addrspec );
    QFETCH( bool, should2047 );

    QCOMPARE( addr.prettyName(Imap::Message::MailAddress::FORMAT_READABLE), pretty );
    QCOMPARE( addr.asSMTPMailbox(), addrspec );
    
    QByteArray full = addr.asMailHeader();
    QByteArray bracketed;
    bracketed.append(" <").append(addrspec).append(">");
    QVERIFY( full.endsWith(bracketed) );
    full.remove(full.size() - bracketed.size(), bracketed.size());
    
    if (should2047) {
        QVERIFY( full.startsWith("=?") );
        QVERIFY( full.endsWith("?=") );
        QCOMPARE( addr.name, Imap::decodeRFC2047String(full) );
    } else {
        QVERIFY( !full.contains("=?") );
        QVERIFY( !full.contains("?=") );
    }
}
コード例 #4
0
//static
QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
    if (entry.isAbsolute() && entry.isClean())
        return entry;

    QByteArray orig = entry.nativeFilePath();
    QByteArray result;
    if (orig.isEmpty() || !orig.startsWith('/')) {
        QFileSystemEntry cur(currentPath());
        result = cur.nativeFilePath();
    }
    if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) {
        if (!result.isEmpty() && !result.endsWith('/'))
            result.append('/');
        result.append(orig);
    }

    if (result.length() == 1 && result[0] == '/')
        return QFileSystemEntry(result, QFileSystemEntry::FromNativePath());
    const bool isDir = result.endsWith('/');

    /* as long as QDir::cleanPath() operates on a QString we have to convert to a string here.
     * ideally we never convert to a string since that loses information. Please fix after
     * we get a QByteArray version of QDir::cleanPath()
     */
    QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath());
    QString stringVersion = QDir::cleanPath(resultingEntry.filePath());
    if (isDir)
        stringVersion.append(QLatin1Char('/'));
    return QFileSystemEntry(stringVersion);
}
コード例 #5
0
ファイル: TSVFileStream.cpp プロジェクト: marc-sturm/cppCORE
QList<QByteArray> TSVFileStream::readLine()
{
	//handle first content line
	if (!next_line_.isNull())
	{
		if (next_line_=="")
		{
			next_line_ = QByteArray();
			return QList<QByteArray>();
		}
		QList<QByteArray> parts = next_line_.split(separator_);
		if (parts.count()!=columns_)
		{
			THROW(FileParseException, "Expected " + QString::number(columns_) + " columns, but got " + QString::number(parts.count()) + " columns in line 1 of file " + filename_);
		}
		next_line_ = QByteArray();
		return parts;
	}

	//handle second to last content line
	QByteArray line = file_.readLine();
	while (line.endsWith('\n') || line.endsWith('\r')) line.chop(1);
	++line_;

	if (line=="")
	{
		return QList<QByteArray>();
	}
	QList<QByteArray> parts = line.split(separator_);
	if (parts.count()!=columns_)
	{
		THROW(FileParseException, "Expected " + QString::number(columns_) + " columns, but got " + QString::number(parts.count()) + " columns in line " + QString::number(line_) + " of file " + filename_);
	}
	return parts;
}
コード例 #6
0
qreal MStyleSheetAttribute::attributeToFloat(const QByteArray &attribute, bool *conversionOk)
{
    QByteArray value = attribute.trimmed();

    if (attribute.endsWith(units[PIXELS_UNIT])) {
        // strip "px" from the end
        value.truncate(value.length() - 2);
        return value.toFloat(conversionOk);
    }

    if (attribute.endsWith(units[MM_UNIT])) {
        // strip "mm" from the end
        value.truncate(value.length() - 2);

        return MDeviceProfile::instance()->mmToPixelsF(value.toFloat(conversionOk));
    }

    if (attribute.endsWith(units[PT_UNIT])) {
        // strip "pt" from the end
        value.truncate(value.length() - 2);

        return MDeviceProfile::instance()->ptToPixelsF(value.toFloat(conversionOk));
    }

    return value.toFloat(conversionOk);
}
コード例 #7
0
/*!
    We compress small text and JavaScript files.
 */
bool QCacheItem::canCompress() const
{
    bool sizeOk = false;
    bool typeOk = false;
    foreach (const QNetworkCacheMetaData::RawHeader &header, metaData.rawHeaders()) {
        if (header.first.toLower() == "content-length") {
            qint64 size = header.second.toLongLong();
            if (size > MAX_COMPRESSION_SIZE)
                return false;
            else
                sizeOk = true;
        }

        if (header.first.toLower() == "content-type") {
            QByteArray type = header.second;
            if (type.startsWith("text/")
                    || (type.startsWith("application/")
                        && (type.endsWith("javascript") || type.endsWith("ecmascript"))))
                typeOk = true;
            else
                return false;
        }
        if (sizeOk && typeOk)
            return true;
    }
    return false;
}
void ProjectorShutterBlock::onMessageReceived() {
    QByteArray data = m_tcpSocket->readAll();

    if (data.startsWith(QString("PJLINK 0").toUtf8())) {
        // -> connection established, no authentication required
        m_authenticationToken = "";
        m_authenticated = true;
        m_passwordIsWrong = false;
        sendCommand("%1NAME ?\r");

    } else if (data.startsWith(QString("PJLINK 1").toUtf8())) {
        // -> connection established, received random number for authentification
        if (data.size() < 18) {
            qWarning() << "Received invalid response from projector.";
            return;
        }
        QString randomNumber = data.mid(9, 8);
        m_authenticationToken = md5(randomNumber + m_password);
        m_authenticated = true;
        m_passwordIsWrong = false;
        sendCommand("%1NAME ?\r");

    } else if (data.startsWith(QString("PJLINK ERRA").toUtf8())) {
        m_authenticated = false;
        m_passwordIsWrong = true;

    } else if (data.startsWith(QString("%1NAME=").toUtf8())) {
        m_projectorName = QString::fromUtf8(data.mid(7, data.size() - 8));
        checkPower();

    } else if (data.endsWith(QString("=OK\r").toUtf8())) {
        // ignore
    } else if (data.endsWith(QString("=ERR1\r").toUtf8())) {
        qDebug() << "Projector reports undefined command.";
    } else if (data.endsWith(QString("=ERR2\r").toUtf8())) {
        qDebug() << "Projector reports out-of-parameter.";
    } else if (data.endsWith(QString("=ERR3\r").toUtf8())) {
        qWarning() << "Projector unavailable.";
    } else if (data.endsWith(QString("=ERR4\r").toUtf8())) {
        qWarning() << "Projector reports failure.";
    } else if (data.startsWith(QString("%1POWR=").toUtf8())) {
        if (data.size() < 9) {
            qWarning() << "Projector responded with invalid power status.";
            return;
        }
        m_powerStatus = QString(data.mid(7, 1)).toInt();

    } else if (data.startsWith(QString("%1AVMT=").toUtf8())) {
        if (data.size() < 10) {
            qWarning() << "Projector responded with invalid shutter status.";
            return;
        }
        m_shutterIsOpen = data.mid(7, 2) == QString("30").toUtf8() // audio and video mute OFF
                || data.mid(7, 2) == QString("21").toUtf8();  // audio mute ON video mute OFF

    } else {
        qDebug() << "Received response from projector:" << QString::fromUtf8(data);
    }
}
コード例 #9
0
QByteArray sizeofTypeExpression(const QByteArray &type)
{
    if (type.endsWith('*'))
        return "sizeof(void*)";
    if (type.endsWith('>'))
        return "sizeof(" + type + ')';
    return "sizeof(" + gdbQuoteTypes(type) + ')';
}
コード例 #10
0
ファイル: kgrgameio.cpp プロジェクト: KDE/kgoldrunner
char KGrGameIO::getALine (const bool kgr3, QByteArray & line)
{
    char c;
    line = "";
    while (openFile.getChar (&c)) {
        line = line.append (c);
        if (c == '\n') {
            break;
        }
    }

    // kDebug() << "Raw line:" << line;
    if (line.size() <= 0) {
        // Return a '\0' byte if end-of-file.
        return ('\0');
    }
    if (kgr3) {
        // In KGr 3 format, strip off leading and trailing syntax.
        if (line.startsWith ("// ")) {
            line = line.right (line.size() - 3);
            // kDebug() << "Stripped comment is:" << line;
        }
        else {
            if (line.startsWith (" i18n(\"")) {
                line = ' ' + line.right (line.size() - 7);
            }
            else if (line.startsWith (" NOTi18n(\"")) {
                line = ' ' + line.right (line.size() - 10);
            }
            else if (line.startsWith (" \"")) {
                line = ' ' + line.right (line.size() - 2);
            }
            if (line.endsWith ("\");\n")) {
                line = line.left (line.size() - 4) + '\n';
            }
            else if (line.endsWith ("\\n\"\n")) {
                line = line.left (line.size() - 4) + '\n';
            }
            else if (line.endsWith ("\"\n")) {
                line = line.left (line.size() - 2);
            }
            // kDebug() << "Stripped syntax is:" << line;
        }
        // In Kgr 3 format, return the first byte if not end-of-file.
        c = line.at (0);
        line = line.right (line.size() - 1);
    }
    else {
        // In KGr 2 format, return a space if not end-of-file.
        c = ' ';
        if (line.startsWith (".")) {	// Line to set an option.
            c = line.at (0);
            line = line.right (line.size() - 1);
        }
    }
    return (c);
}
コード例 #11
0
ファイル: watchutils.cpp プロジェクト: Lykurg/qt-creator
QByteArray stripPointerType(QByteArray type)
{
    if (type.endsWith('*'))
        type.chop(1);
    if (type.endsWith("* const"))
        type.chop(7);
    if (type.endsWith(' '))
        type.chop(1);
    return type;
}
コード例 #12
0
ファイル: signal_promise.cpp プロジェクト: unkstar/skuld
static inline QByteArray paramType(const QByteArray &ptype, bool *out)
{
	*out = ptype.endsWith('&') || ptype.endsWith("**");
	if (*out) {
		QByteArray res(ptype);
		res.truncate(res.length() - 1);
		return res;
	}

	return ptype;
}
コード例 #13
0
ファイル: cipher.cpp プロジェクト: fuzzball81/quassel
QByteArray Cipher::parseInitKeyX(QByteArray key)
{
    QCA::Initializer init;
    bool isCBC = false;

    if (key.endsWith(" CBC")) {
        isCBC = true;
        key.chop(4);
    }

    if (key.length() != 181)
        return QByteArray();

    QCA::SecureArray remoteKey = QByteArray::fromBase64(key.left(180));
    QCA::DLGroup group(m_primeNum, QCA::BigInteger(2));
    QCA::DHPrivateKey privateKey = QCA::KeyGenerator().createDH(group).toDH();

    if (privateKey.isNull())
        return QByteArray();

    QByteArray publicKey = privateKey.y().toArray().toByteArray();

    // remove leading 0
    if (publicKey.length() > 135 && publicKey.at(0) == '\0')
        publicKey = publicKey.mid(1);

    QCA::DHPublicKey remotePub(group, remoteKey);

    if (remotePub.isNull())
        return QByteArray();

    QByteArray sharedKey = privateKey.deriveKey(remotePub).toByteArray();
    sharedKey = QCA::Hash("sha256").hash(sharedKey).toByteArray().toBase64();

    // remove trailing = because mircryption and fish think it's a swell idea.
    while (sharedKey.endsWith('='))
        sharedKey.chop(1);

    if (isCBC)
        sharedKey.prepend("cbc:");

    bool success = setKey(sharedKey);

    if (!success)
        return QByteArray();

    return publicKey.toBase64().append('A');
}
コード例 #14
0
    virtual bool visit(ClassSpecifierAST *ast)
    {
        Class *klass = ast->symbol;
        const QByteArray className = id_cast(ast->name);
        if (! className.endsWith("AST"))
            return false;

        const Identifier *clone_id = control()->identifier("clone");
        Symbol *cloneMethod = klass->find(clone_id);
        for (; cloneMethod; cloneMethod = cloneMethod->next()) {
            if (cloneMethod->identifier() != clone_id)
                continue;

            if (checkMethod(cloneMethod))
                break;
        }

        if (! cloneMethod)
            return true;

        classMap.insert(className, ast);

        out << "virtual bool visit(" << className.constData() << " *ast)" << endl
            << "{" << endl;

        visitMembers(klass);

        out << "    return false;" << endl
            << "}" << endl << endl;

        return false;
    }
コード例 #15
0
ファイル: at_command.cpp プロジェクト: chenhbzl/BooxApp
int main(int argc, char * argv[])
{
    if (argc < 2)
    {
        printf("Usage at_command <command> ...\n");
        return -1;
    }

    QApplication app(argc, argv);

    ModemMap mm;
    SerialPort sp(mm.signalChannel().toAscii());
    Reporter * reporter = 0;
    if (mm.provider() == "ZTE")
    {
        reporter = new ZTEReport(mm);
    }
    else
    {
        reporter = new HuaWeiReport(mm);
    }
    QByteArray data;
    data.append(argv[1]);
    if (!data.endsWith('\r'))
    {
        data.append('\r');
    }
    reporter->sendCommand(sp, data, 5000);
    qDebug("Result:");
    qDebug() << data;

    return 0;
}
コード例 #16
0
ファイル: qterminal_pty.cpp プロジェクト: spthaolt/qscite
void QTerminal::doOSCommand(const QByteArray & cmd) {
  int termLength = (cmd.endsWith("\x1b\\") ? 2 : 1);
  int firstParam = cmd.left(cmd.indexOf(';')).toInt();
  QByteArray textParam = cmd.left(cmd.length() - termLength).mid(cmd.indexOf(';') + 1);
  QPalette activePalette = this->palette();
  /* TODO: XTerm technically allows a series of ;-separated color specifications,
   * with subsequent colors being assigned to subsequent slots.
   * The old code didn't try, and this doesn't try yet.
   */
  switch (firstParam) {
    case 10:
      /* Qt displays "green" as #008000. Anyone using it as a text color
       * probably has a dark background and wants the traditional X11 #00FF00.
       */
      activePalette.setColor(QPalette::Text,
          (textParam.toLower() == "green") ? QColor(0x00FF00) : QColor(textParam.constData()));
      this->setPalette(activePalette);
      break;
    case 11:
      activePalette.setColor(QPalette::Text, QColor(textParam.constData()));
      this->setPalette(activePalette);
      break;
    default:
      qDebug("No Can Do ESC ] %s", cmd.toHex().constData());
      break;
  }
}
コード例 #17
0
bool AmosePluginsManager::loadPlugins()
{
  ABSTRACTFACTORYPATTERNLOGINIT;
  LINFO << "AmosePluginsManager::loadPlugins";
//   DynamicLibrariesManager::changeable().addSearchPath("c:\amose\lib");;
  // open LIMA_CONF/plugins file
  QDir pluginsDir(QString::fromUtf8(qgetenv("LIMA_CONF").constData()==0?"":qgetenv("LIMA_CONF").constData()) + "/plugins");
  QStringList pluginsFiles = pluginsDir.entryList(QDir::Files);
  Q_FOREACH(QString pluginsFile, pluginsFiles)
  {
    LINFO << "AmosePluginsManager::loadPlugins loding plugins file " << pluginsFile.toUtf8().data();
    QFile file(pluginsDir.path() + "/" + pluginsFile);
    if (!file.open(QIODevice::ReadOnly))
      return false;
    // for each entry, call load library
    while (!file.atEnd()) 
    {
      QByteArray line = file.readLine();
      if (line.endsWith('\n')) line.chop(1);
      // Allows empty and comment lines
      if ( !line.isEmpty() && !line.startsWith('#') )
      {
#ifdef WIN32
        QString strline = QString(line.data()) + ".dll";
#else
        QString strline = QString("lib") + line.data() + ".so";
#endif
        LDEBUG << "AmosePluginsManager::loadPlugins loading plugin '" << line.data() << "'";
        DynamicLibrariesManager::changeable().loadLibrary(line.data());
      }
    }
  }
コード例 #18
0
ファイル: cipher.cpp プロジェクト: fuzzball81/quassel
bool Cipher::parseFinishKeyX(QByteArray key)
{
    QCA::Initializer init;

    if (key.length() != 181)
        return false;

    QCA::SecureArray remoteKey = QByteArray::fromBase64(key.left(180));
    QCA::DLGroup group(m_primeNum, QCA::BigInteger(2));

    QCA::DHPublicKey remotePub(group, remoteKey);

    if (remotePub.isNull())
        return false;

    if (m_tempKey.isNull())
        return false;

    QByteArray sharedKey = m_tempKey.deriveKey(remotePub).toByteArray();
    sharedKey = QCA::Hash("sha256").hash(sharedKey).toByteArray().toBase64();

    // remove trailng = because mircryption and fish think it's a swell idea.
    while (sharedKey.endsWith('='))
        sharedKey.chop(1);

    bool success = setKey(sharedKey);

    return success;
}
コード例 #19
0
ファイル: trashsizecache.cpp プロジェクト: KDE/kde-runtime
void TrashSizeCache::add( const QString &directoryName, qulonglong directorySize )
{
    kDebug() << directoryName << directorySize;
    const QByteArray encodedDir = QFile::encodeName(directoryName).toPercentEncoding();
    const QByteArray spaceAndDirAndNewline = ' ' + encodedDir + '\n';
    QFile file( mTrashSizeCachePath );
    KSaveFile out( mTrashSizeCachePath );
    if (out.open(QIODevice::WriteOnly)) {
        if (file.open(QIODevice::ReadOnly)) {
            while (!file.atEnd()) {
                const QByteArray line = file.readLine();
                if (line.endsWith(spaceAndDirAndNewline)) {
                    // Already there!
                    out.abort();
                    kDebug() << "already there!";
                    return;
                }
                out.write(line);
            }
        }

        const QString fileInfoPath = mTrashPath + "/info/" + directoryName + ".trashinfo";
        QDateTime mtime = QFileInfo(fileInfoPath).lastModified();
        QByteArray newLine = QByteArray::number(directorySize) + ' ' + QByteArray::number(mtime.toMSecsSinceEpoch()) + spaceAndDirAndNewline;
        out.write(newLine);
        out.finalize();
    }
    kDebug() << mTrashSizeCachePath << "exists:" << QFile::exists(mTrashSizeCachePath);
}
コード例 #20
0
ファイル: serializer.cpp プロジェクト: delgor/Core
bool Nuria::Serializer::writeField (void *object, Nuria::MetaField &field, const QVariantMap &data) {
	QVariant value = data.value (QString::fromLatin1 (field.name ()));
	QByteArray typeName = field.typeName ();
	bool isPointer = typeName.endsWith ('*');
	bool ignored = false;
	int pointerId = 0;
	
	if (isPointer) {
		pointerId = QMetaType::type (typeName.constData ());
		typeName.chop (1);
	}
	
	int sourceId = value.userType ();
	int targetId = QMetaType::type (typeName.constData ());
	
	if (sourceId != targetId && targetId != QMetaType::QVariant) {
		variantToField (value, typeName, targetId, sourceId, pointerId, ignored);
		
		if (ignored) {
			return true;
		}
		
	}
	
	if ((isPointer && value.isValid ()) || value.userType () == targetId ||
	    targetId == QMetaType::QVariant) {
		return field.write (object, value);
	}
	
	// 
	return false;
	
}
コード例 #21
0
ファイル: uch_mydev_feed.cpp プロジェクト: kitech/snsnotify
void UCHome_Main_SiteConst::clean_my_name_lable()
{
    //<my:name uid="1673222" />
    //<my:name uid="1673222"></my:name>

    //QString unis = this->codec->toUnicode(this->feed_page_html);
    //QByteArray u8s = this->u8codec->fromUnicode(unis);
    //unis = u8s;
    QByteArray tarr = this->feed_page_html;

    QRegExp exp1 ("<my:name uid=\"[0-9]{1,12}\" />");
    QRegExp exp2 ( "<my:name uid=\"[0-9]{1,12}\"></my:name>");
    
    tarr = tarr.trimmed();
    if(tarr.startsWith("f5b")) {
        tarr = tarr.right(tarr.length()-3);
    }
    if(tarr.endsWith("0")) {
        tarr = tarr.left(tarr.length()-1);
    }
    //unis = unis.replace(exp1, QString(""));
    //unis = unis.replace(exp2, QString(""));
    
    //u8s = this->u8codec->fromUnicode(unis);
    QString unis = this->codec->toUnicode(tarr);

    this->feed_page_utf8_html = this->u8codec->fromUnicode(unis);

    this->feed_page_utf8_html = this->u8codec->fromUnicode(this->codec->toUnicode(this->feed_page_html));
}
コード例 #22
0
/**
 * Redirects the standard output (prime numbers or prime k-tuplets) of
 * the primeSieveProcess_ to the TextEdit.
 */
void PrimeSieveGUI::printProcessOutput() {
  QByteArray buffer;
  buffer.reserve(PRINT_BUFFER_SIZE + 256);
  while (ui->cancelButton->isEnabled() && primeSieveProcess_->canReadLine()) {
    buffer.clear();
    while (primeSieveProcess_->canReadLine() && buffer.size() < PRINT_BUFFER_SIZE)
      buffer.append(primeSieveProcess_->readLine(256));
    // remove "\r\n" or '\n', '\r' at the back
    while (buffer.endsWith('\n') ||
           buffer.endsWith('\r'))
      buffer.chop(1);
    if (!buffer.isEmpty())
      ui->textEdit->appendPlainText(buffer);
/// @brief   Keep the GUI responsive.
/// @bug     processEvents() crashes on Windows with MSVC 2010 and Qt 5 beta.
/// @warning QApplication::processEvents() must not be used on
///          operating systems that use signal recursion (like Linux
///          X11) otherwise the stack will explode!
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_IOS)
    QApplication::processEvents();
#else
    ui->textEdit->repaint();
#endif
  }
}
コード例 #23
0
ファイル: toxsave.cpp プロジェクト: ACKino/qTox
void toxSaveEventHandler(const QByteArray& eventData)
{
    if (!eventData.endsWith(".tox"))
        return;

    handleToxSave(eventData);
}
コード例 #24
0
ファイル: qaxserver.cpp プロジェクト: RSATom/Qt
static QByteArray convertTypes(const QByteArray &qtype, bool *ok)
{
    qRegisterMetaType<IDispatch *>("IDispatch*");
    qRegisterMetaType<IUnknown *>("IUnknown*");

    *ok = false;

    int i = 0;
    while (type_map[i][0]) {
        if (qtype == type_map[i][0] && type_map[i][1]) {
            *ok = true;
            return type_map[i][1];
        }
        ++i;
    }
    if (enums.contains(qtype)) {
        *ok = true;
        return "enum " + qtype;
    }
    if (subtypes.contains(qtype)) {
        *ok = true;
    } else if (qtype.endsWith('*')) {
        QByteArray cleanType = qtype.left(qtype.length() - 1);
        const QMetaObject *mo = qAxFactory()->metaObject(QString::fromLatin1(cleanType.constData()));
        if (mo) {
            cleanType = qax_clean_type(QString::fromLatin1(cleanType), mo).toLatin1();
            if (subtypes.contains(cleanType)) {
                *ok = true;
                return cleanType + '*';
            }
        }
    }
    return qtype;
}
コード例 #25
0
ファイル: kmime_content.cpp プロジェクト: pvuorela/kcalcore
void Content::setHead( const QByteArray &head )
{
  d_ptr->head = head;
  if ( !head.endsWith( '\n' ) ) {
    d_ptr->head += '\n';
  }
}
コード例 #26
0
ファイル: serializer.cpp プロジェクト: delgor/Core
bool Nuria::Serializer::fieldToVariant (QVariant &value, bool &ignore) {
	QByteArray typeName = QByteArray (value.typeName (), -1);
	MetaObject *meta = this->d->finder (typeName);
	
	if (meta) {
		void *dataPtr = value.data ();
		
		if (typeName.endsWith ('*')) {
			dataPtr = *reinterpret_cast< void ** > (dataPtr);
		}
		
		if (this->d->curDepth == 1) {
			ignore = true;
		} else {
			value = serializeImpl (dataPtr, meta);
		}
		
		return true;
	}
	
	// Variant::convert() triggers QVariant conversion internally
	QVariant conv = Nuria::Variant::convert (value, QMetaType::QString);
	if (conv.isValid ()) {
		value = conv;
		return true;
	}
	
	return false;
}
コード例 #27
0
void test_can_decoder::run()
{
    QFile data("/home/ghaith/developement/workspace/MgCarDashboard/MgCarDashboard/test_data/data");
    bool ok = data.open(QFile::ReadOnly | QFile::Text);

    qDebug()<<"file open"<<ok;

    QByteArray line;


    MgPrius2CanMessagesDecoder decoder;

    do
    {
        line = data.readLine();
        if(line.endsWith('\n'))
            line.remove(line.size()-1,1);

        if(line .isEmpty() || line.isNull())
            break;

        decoder.decodeMessage(line);

    }
    while(true);


    qDebug()<<"closing file";


    data.close();


}
コード例 #28
0
ファイル: main.cpp プロジェクト: KubaO/stackoverflown
bool appendBinFix(QByteArray &buf, const char *src, int size) {
   bool okData = true;
   if (!size) return okData;
   constexpr char CR = '\x0d';
   constexpr char LF = '\x0a';
   bool hasCR = buf.endsWith(CR);
   buf.resize(buf.size() + size);
   char *dst = buf.end() - size;
   const char *lastSrc = src;
   for (const char *const end = src + size; src != end; src++) {
      char const c = *src;
      if (c == LF) {
         if (hasCR) {
            std::copy(lastSrc, src, dst);
            dst += (src - lastSrc);
            dst[-1] = LF;
            lastSrc = src + 1;
         } else
            okData = false;
      }
      hasCR = (c == CR);
   }
   dst = std::copy(lastSrc, src, dst);
   buf.resize(dst - buf.constData());
   return okData;
}
コード例 #29
0
/*!
    \property bool IrcPrivateMessage::request
    This property is \c true if the message is a request; otherwise \c false.

    \par Access functions:
    \li bool <b>isRequest</b>() const
 */
bool IrcPrivateMessage::isRequest() const
{
    Q_D(const IrcMessage);
    QByteArray msg = d->parser.params().value(1);
    if (d->flags & (Identified | Unidentified))
        msg.remove(0, 1);
    return msg.startsWith('\1') && msg.endsWith('\1') && !isAction();
}
コード例 #30
0
void ProcessCheckoutJob::slotOutput()
{
    const QByteArray data = d->process->readAllStandardOutput();
    const QString s = QString::fromLocal8Bit(data, data.endsWith('\n') ? data.size() - 1: data.size());
    if (debug)
        qDebug() << s;
    emit output(s);
}