当前位置: 首页>>代码示例>>C++>>正文


C++ QByteArray::toHex方法代码示例

本文整理汇总了C++中QByteArray::toHex方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::toHex方法的具体用法?C++ QByteArray::toHex怎么用?C++ QByteArray::toHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QByteArray的用法示例。


在下文中一共展示了QByteArray::toHex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: launch

void DBusBackendWrapper::launch()
{
    Q_D(DBusBackendWrapper);

    if (identifier().isEmpty()) {
        setLastError("No identifier was set");
        setStatus(Invalid);
        return;
    }

    QByteArray object = QCryptographicHash::hash(identifier().toLocal8Bit(),
                                                 QCryptographicHash::Md5);
    QString dbusIdentifier = QString::fromLocal8Bit(object.toHex());

    // Register to DBus
    d->dbusObjectPath = DBUS_BACKEND_PATH_PREFIX;
    d->dbusObjectPath.append(dbusIdentifier);

    new Pt2Adaptor(this);
    if (!QDBusConnection::sessionBus().registerObject(d->dbusObjectPath, this)) {
        setLastError(QString("Failed to register object on path %1").arg(d->dbusObjectPath));
        setStatus(Invalid);
        return;
    }

    // Launch the backend
    setStatus(Launching);
    d->process->setWorkingDirectory(APPLICATION_FOLDER);
    QString trueExecutable = executable();
    trueExecutable.replace("$PROVIDER", QString(PROVIDER_PATH) + " --plugin ");
    trueExecutable.append(QString(" --identifier %1 ").arg(dbusIdentifier));

    debug("dbus-backend-wrapper") << "starting" << trueExecutable;

    d->process->start(trueExecutable);
}
开发者ID:SfietKonstantin,项目名称:pt2,代码行数:36,代码来源:dbusbackendwrapper.cpp

示例2: fillInfo

void EmbeddedFilesDock::fillInfo()
{
    m_table->setHorizontalHeaderLabels(
        QStringList() << tr("Name") << tr("Description") << tr("Size") << tr("Creation date")
        << tr("Modification date") << tr("Checksum"));
    if (!document()->hasEmbeddedFiles()) {
        m_table->setItem(0, 0, new QTableWidgetItem(tr("No files")));
        return;
    }

    const QList<Poppler::EmbeddedFile*> files = document()->embeddedFiles();
    m_table->setRowCount(files.count());
    int i = 0;
    Q_FOREACH(Poppler::EmbeddedFile *file, files) {
        m_table->setItem(i, 0, new QTableWidgetItem(file->name()));
        m_table->setItem(i, 1, new QTableWidgetItem(file->description()));
        m_table->setItem(i, 2, new QTableWidgetItem(QString::number(file->size())));
        m_table->setItem(i, 3, new QTableWidgetItem(file->createDate().toString(Qt::SystemLocaleDate)));
        m_table->setItem(i, 4, new QTableWidgetItem(file->modDate().toString(Qt::SystemLocaleDate)));
        const QByteArray checksum = file->checksum();
        const QString checksumString = !checksum.isEmpty() ? QString::fromAscii(checksum.toHex()) : QString::fromLatin1("n/a");
        m_table->setItem(i, 5, new QTableWidgetItem(checksumString));
        ++i;
    }
开发者ID:rgfernandes,项目名称:qtdesktop,代码行数:24,代码来源:embeddedfiles.cpp

示例3: save

void Settings::save()
{
	QSettings settings;
	settings.setValue("settings/configFileName", m_configFileName);
	settings.setValue("settings/multipleconfig", m_multipleConfigs);

	if ( multipleConfigs() && !configFileName().isEmpty() )
	{
		QByteArray hash = QCryptographicHash::hash( configFileName().toLocal8Bit(), QCryptographicHash::Md5 );
		settings.beginGroup( hash.toHex() );
	}

	settings.setValue("buildPath", m_buildPath);
	settings.setValue("includePath", m_includePath);
	settings.setValue("installPath", m_installPath);
	settings.setValue("sourceDirectory", m_sourceDir);
	settings.setValue("applicationDirectory", m_appDir);
	settings.setValue("targetPlatform", m_targetPlatform);
	settings.setValue("toolPath", m_toolPath);
	settings.setValue("programmer", m_programmer);
	settings.setValue("absolutePathInSamples", m_absolutePathInSamples);
	settings.setValue("clearLogBeforeBuild", m_clearLogBeforeBuild);
	settings.setValue("verboseBuild", m_verboseBuild);
}
开发者ID:Astralix,项目名称:ethernut32,代码行数:24,代码来源:settings.cpp

示例4: FileToHash

QString TDownlad::CalcSha1(QString Path)
{
        QFile FileToHash(Path);
        QByteArray ba;
        QString HashOutput;
        QCryptographicHash CPU(QCryptographicHash::Sha1);
        if (FileToHash.open(QIODevice::ReadOnly))
        {
                while (!FileToHash.atEnd())
                {
                        ba = FileToHash.read(1024);
                        CPU.addData(ba);
                }
                FileToHash.close();
                ba = CPU.result();
                HashOutput = ba.toHex();
                return HashOutput;
        }
        else
        {
                HashOutput = "ERR";
                return HashOutput;
        }
}
开发者ID:mefest,项目名称:apdvmupdater,代码行数:24,代码来源:tdownlad.cpp

示例5: QDir

Ztamp::Ztamp(QByteArray const& ztampID)
{
	// Check ztamps folder
	QDir ztampsDir = QDir(QCoreApplication::applicationDirPath());
	if (!ztampsDir.cd("ztamps"))
	{
		if (!ztampsDir.mkdir("ztamps"))
		{
			LogError("Unable to create ztamps directory !\n");
			exit(-1);
		}
		ztampsDir.cd("ztamps");
	}
	id = ztampID;
	configFileName = ztampsDir.absoluteFilePath(ztampID.toHex()+".dat");

	// Check if config file exists and load it
	if (QFile::exists(configFileName))
		LoadConfig();

	saveTimer = new QTimer(this);
	connect(saveTimer, SIGNAL(timeout()), this, SLOT(SaveConfig()));
	saveTimer->start(5*60*1000); // 5min
}
开发者ID:boowin,项目名称:OpenJabNab,代码行数:24,代码来源:ztamp.cpp

示例6: insert_row_in_table

void PacketTable::insert_row_in_table(QByteArray data)
{
    bool isOk;
    int i, length;
    QString mac_dst, mac_src, stream;

    qDebug() << "[data]" << data.toHex();

    if (data.size() <= 14)
        return;

    int row = ui->tableWidget->rowCount();
    ui->tableWidget->insertRow(row);

    mac_dst = QString::number(data.mid(0,6).toHex().toLongLong(&isOk,16), 16).toUpper();
    qDebug() << mac_dst;
    mac_src = QString::number(data.mid(6,6).toHex().toLongLong(&isOk,16), 16).toUpper();
    qDebug() << mac_src;
    length = data.mid(12,2).toHex().toInt(&isOk,16);
    qDebug() << length;
    for(i = 14; (i < 14 + length) && (i<data.size()); i++ )
      stream.append(QString::number((uchar)data[i], 16));

    qDebug() << stream;
    QTableWidgetItem *newItem = new QTableWidgetItem(mac_dst);
    ui->tableWidget->setItem(row, 0, newItem);

    newItem = new QTableWidgetItem(mac_src);
    ui->tableWidget->setItem(row, 1, newItem);

    newItem = new QTableWidgetItem(QString::number(length));
    ui->tableWidget->setItem(row, 2, newItem);

    newItem = new QTableWidgetItem(stream);
    ui->tableWidget->setItem(row, 3, newItem);
}
开发者ID:simakvladimir,项目名称:qt-projects,代码行数:36,代码来源:packettable.cpp

示例7: variantToTextValue

static QString variantToTextValue(const QVariant &value, const QString &typeNs, const QString &type)
{
    switch (value.userType()) {
    case QVariant::Char:
    // fall-through
    case QVariant::String:
        return value.toString();
    case QVariant::Url:
        // xmlpatterns/data/qatomicvalue.cpp says to do this:
        return value.toUrl().toString();
    case QVariant::ByteArray: {
        const QByteArray data = value.toByteArray();
        if (typeNs == KDSoapNamespaceManager::xmlSchema1999() || typeNs == KDSoapNamespaceManager::xmlSchema2001()) {
            if (type == QLatin1String("hexBinary")) {
                const QByteArray hb = data.toHex();
                return QString::fromLatin1(hb.constData(), hb.size());
            }
        }
        // default to base64Binary, like variantToXMLType() does.
        const QByteArray b64 = value.toByteArray().toBase64();
        return QString::fromLatin1(b64.constData(), b64.size());
    }
    case QVariant::Int:
    // fall-through
    case QVariant::LongLong:
    // fall-through
    case QVariant::UInt:
        return QString::number(value.toLongLong());
    case QVariant::ULongLong:
        return QString::number(value.toULongLong());
    case QVariant::Bool:
    case QMetaType::Float:
    case QVariant::Double:
        return value.toString();
    case QVariant::Time: {
        const QTime time = value.toTime();
        if (time.msec()) {
            // include milli-seconds
            return time.toString(QLatin1String("hh:mm:ss.zzz"));
        } else {
            return time.toString(Qt::ISODate);
        }
    }
    case QVariant::Date:
        return value.toDate().toString(Qt::ISODate);
    case QVariant::DateTime: // http://www.w3.org/TR/xmlschema-2/#dateTime
        return KDDateTime(value.toDateTime()).toDateString();
    case QVariant::Invalid:
        qDebug() << "ERROR: Got invalid QVariant in a KDSoapValue";
        return QString();
    default:
        if (value.canConvert<KDDateTime>()) {
            return value.value<KDDateTime>().toDateString();
        }

        if (value.userType() == qMetaTypeId<float>()) {
            return QString::number(value.value<float>());
        }

        qDebug() << QString::fromLatin1("QVariants of type %1 are not supported in "
                                        "KDSoap, see the documentation").arg(QLatin1String(value.typeName()));
        return value.toString();
    }
}
开发者ID:Knarf64,项目名称:KDSoap,代码行数:64,代码来源:KDSoapValue.cpp

示例8: writeThenRead

void TCS34725Driver::getID()
{
    QByteArray result = writeThenRead(TCS34725Address_, ID, 1);
    qDebug() << QString(result.toHex());
}
开发者ID:skvark,项目名称:ChameleonHalf,代码行数:5,代码来源:TCS34725Driver.cpp

示例9: paintEvent

void FastoHexEdit::paintEvent(QPaintEvent *event) {
  if (mode_ == HEX_MODE) {
    QPainter painter(viewport());

    QSize areaSize = viewport()->size();
    QSize widgetSize = fullSize();

    const int charW = charWidth();
    const int charH = charHeight();

    int firstLineIdx = verticalScrollBar()->value();
    int lastLineIdx = firstLineIdx + areaSize.height() / charH;

    const QRect rect = stableRect(event->rect());
    const int yPosStart = rect.top();
    const int xPosStart = rect.left();
    const int yPosEnd = rect.bottom();
    const int xPosEnd = rect.right();

    const int wid = xPosEnd - xPosStart;
    const int height = yPosEnd - yPosStart;
    const int widchars = wid - TextMarginXY * 2;
    const int acharInLine = asciiCharInLine(widchars);
    if (acharInLine <= 0) {
      return;
    }

    const int xPosAscii = widchars/4 * 3;  // line pos
    const int xPosAsciiStart = xPosAscii + TextMarginXY;

    int indexCount = data_.size() / acharInLine;
    if (lastLineIdx > indexCount) {
      lastLineIdx = indexCount;
      if (data_.size() % acharInLine) {
        lastLineIdx++;
      }
    }
    verticalScrollBar()->setPageStep(areaSize.height() / charH);
    verticalScrollBar()->setRange(0, (widgetSize.height() - areaSize.height()) / charH + 1);

    painter.setPen(Qt::gray);
    painter.drawLine(xPosAscii, yPosStart, xPosAscii, yPosEnd);

    painter.setPen(Qt::black);

    int size = data_.size();
    for (int lineIdx = firstLineIdx, yPos = yPosStart;
         lineIdx < lastLineIdx; lineIdx += 1, yPos += charH) {
      QByteArray part = data_.begin() + (lineIdx * acharInLine);
      int part_size = size / acharInLine ? acharInLine : size % acharInLine;
      part.resize(part_size);
      size -= part_size;
      QByteArray hex = part.toHex();

      painter.setBackgroundMode(Qt::OpaqueMode);
      for (int xPos = xPosStart, i = 0; i < hex.size(); i++, xPos += 3 * charW) {
        QString val = hex.mid(i * 2, 2);
        QRect hexrect(xPos, yPos, 3 * charW, charH);
        painter.drawText(hexrect, Qt::AlignLeft, val);
        char ch = part[i];
        if ((ch < 0x20) || (ch > 0x7e)) {
          part[i] = '.';
        }
      }

      painter.setBackgroundMode(Qt::TransparentMode);
      QRect asciirect(xPosAsciiStart, yPos, acharInLine * charW, charH);
      painter.drawText(asciirect, Qt::AlignLeft, part);
    }
  } else {
    base_class::paintEvent(event);
  }
}
开发者ID:kunyuqiushuang,项目名称:fastonosql,代码行数:73,代码来源:fasto_hex_edit.cpp

示例10:

 /* md5 of string */
 inline QString md5( const QByteArray& src )
 {
   QByteArray const digest = QCryptographicHash::hash( src, QCryptographicHash::Md5 );
   return QString::fromLatin1( digest.toHex() ).rightJustified( 32, '0' ).toLower();
 }
开发者ID:RavetcoFX,项目名称:Yarock,代码行数:6,代码来源:lastfm.cpp

示例11: ProcessFrames

void WebSocketWorker::ProcessFrames(QTcpSocket *socket)
{
    while (m_isRunning && socket && socket->bytesAvailable() >= 2) // No header? Return and wait for more
    {
        uint8_t headerSize = 2; // Smallest possible header size is 2 bytes, greatest is 14 bytes

        QByteArray header = socket->peek(headerSize); // Read header to establish validity and size of frame

        WebSocketFrame frame;
        // FIN
        frame.finalFrame = (bool)(header[0] & 0x80);
        // Reserved bits
        if (header.at(0) & 0x70)
        {
            LOG(VB_GENERAL, LOG_ERR, "WebSocketWorker::ProcessFrames() "
                                     "- Invalid data in reserved fields");
            SendClose(kCloseProtocolError, "Invalid data in reserved fields");
            return;
        }
        // Operation code
        uint8_t opCode = (header.at(0) & 0xF);
        if ((opCode > WebSocketFrame::kOpBinaryFrame &&
             opCode < WebSocketFrame::kOpClose) ||
             (opCode > WebSocketFrame::kOpPong))
        {
            LOG(VB_GENERAL, LOG_ERR, QString("WebSocketWorker::ProcessFrames() "
                                             "- Invalid OpCode (%1)")
                                            .arg(QString::number(opCode, 16)));
            SendClose(kCloseProtocolError, "Invalid OpCode");
            return;
        }
        frame.opCode = (WebSocketFrame::OpCode)opCode;
        frame.isMasked = (header.at(1) >> 7) & 0xFE;

        if (frame.isMasked)
            headerSize += 4; // Add 4 bytes for the mask

        frame.payloadSize = (header.at(1) & 0x7F);
        // Handle 16 or 64bit payload size headers
        if (frame.payloadSize >= 126)
        {
            uint8_t payloadHeaderSize = 2; // 16bit payload size
            if (frame.payloadSize == 127)
                payloadHeaderSize = 8; // 64bit payload size

            headerSize += payloadHeaderSize; // Add bytes for extended payload size

            if (socket->bytesAvailable() < headerSize)
                return; // Return and wait for more

            header = socket->peek(headerSize); // Peek the entire header
            QByteArray payloadHeader = header.mid(2,payloadHeaderSize);
            frame.payloadSize = 0;
            for (int i = 0; i < payloadHeaderSize; i++)
            {
                frame.payloadSize |= ((uint8_t)payloadHeader.at(i) << ((payloadHeaderSize - (i + 1)) * 8));
            }
        }
        else
        {
            if (socket->bytesAvailable() < headerSize)
                return; // Return and wait for more
            header = socket->peek(headerSize); // Peek the entire header including mask
        }

        while ((uint64_t)socket->bytesAvailable() < (frame.payloadSize + header.length()))
        {
            if (!socket->waitForReadyRead(2000)) // Wait 2 seconds for the next chunk of the frame
            {

                m_errorCount++;

                if (m_errorCount == 5)
                {
                    LOG(VB_GENERAL, LOG_ERR, "WebSocketWorker::ProcessFrames() - Timed out waiting for rest of frame to arrive.");
                    SendClose(kCloseBadData);
                }
                return;
            }
        }

        if (frame.opCode == WebSocketFrame::kOpContinuation)
             m_readFrame.payloadSize += frame.payloadSize;

        LOG(VB_HTTP, LOG_DEBUG, QString("Read Header: %1").arg(QString(header.toHex())));
        LOG(VB_HTTP, LOG_DEBUG, QString("Final Frame: %1").arg(frame.finalFrame ? "Yes" : "No"));
        LOG(VB_HTTP, LOG_DEBUG, QString("Op Code: %1").arg(QString::number(frame.opCode)));
        LOG(VB_HTTP, LOG_DEBUG, QString("Payload Size: %1 Bytes").arg(QString::number(frame.payloadSize)));
        LOG(VB_HTTP, LOG_DEBUG, QString("Total Payload Size: %1 Bytes").arg(QString::number( m_readFrame.payloadSize)));

        if (!m_fuzzTesting &&
            frame.payloadSize > qPow(2,20)) // Set 1MB limit on payload per frame
        {
            LOG(VB_GENERAL, LOG_ERR, "WebSocketWorker::ProcessFrames() - Frame payload larger than limit of 1MB");
            SendClose(kCloseTooLarge, "Frame payload larger than limit of 1MB");
            return;
        }

        if (!m_fuzzTesting &&
            m_readFrame.payloadSize > qPow(2,22)) // Set 4MB limit on total payload
//.........这里部分代码省略.........
开发者ID:garybuhrmaster,项目名称:mythtv,代码行数:101,代码来源:websocket.cpp

示例12: message

void NfcWorker::doIso7816Test(const QVariant &aid, const QVariant &hex_cla, const QVariant &hex_ins, const QVariant &hexp1p2, const QVariant &hex_lc,
		const QVariant &hex_command, const QVariant &hex_le) {
	emit message(QString("ISO7816-4 test starts"));

	QString _aid = aid.toString();
	QString _hex_cla = hex_cla.toString();
	QString _hex_ins = hex_ins.toString();
	QString _hex_p1p2 = hexp1p2.toString();
	QString _hex_lc = hex_lc.toString();
	QString _hex_command = hex_command.toString();
	QString _hex_le = hex_le.toString();

	emit message(QString("Le: '%1'").arg(_hex_le));
	emit message(QString("COMMAND: '%1'").arg(_hex_command));
	emit message(QString("Lc: '%1'").arg(_hex_lc));
	emit message(QString("P1 P2: '%1'").arg(_hex_p1p2));
	emit message(QString("INS: '%1'").arg(_hex_ins));
	emit message(QString("CLA: '%1'").arg(_hex_cla));
	emit message(QString("AID: '%1'").arg(_aid));
	emit message(QString("ISO7816-4 request APDU:"));

	// variables for handles
	uint32_t hSESession;
	uint32_t seChannel;
	uint32_t uiccSeReaderID;

	// variables for retrieving the Readers, holders of possible secure elements
	uint32_t numberOfReaders = 0;
	uint32_t *phReaders = NULL;
	static int DEF_LEN = 10;
	char readerName[DEF_LEN];
	uint32_t len = 10;

	//variables for opening and exchanging data
	fcp_type_t fcpResponseType;
	int32_t openResponseLen;
	uint32_t exchangeResponseLen;
	uint32_t nReceiveAPDUBufferSize;
	uint8_t* result;

	QByteArray hex_encoded = QByteArray(aid.toByteArray());
	QByteArray the_aid = QByteArray::fromHex(hex_encoded);

	uint8_t fixed_aid[14] = { 0xA0, 0x00, 0x00, 0x00, 0x18, 0x30, 0x80, 0x05, 0x00, 0x65, 0x63, 0x68, 0x6F, 0x00 };
	uint8_t command_apdu_len = 5;
	uint8_t command_apdu[5] = { 0x10, 0x41, 0x11, 0x22, 0x00 };

	// loop variable
	uint32_t i;

	// Call nfc_se_service_get_num_readers() with the handle acquired in previous step to get the number of available Readers in the system
	CHECK(nfc_se_service_get_num_readers(&numberOfReaders));
	emit message(QString("number of readers=%1").arg(numberOfReaders));

	// Allocate space for the readers
	phReaders = (uint32_t*) malloc(sizeof(uint32_t) * numberOfReaders);
	emit message(QString("space allocated for readers"));

	// get the handles for the readers
	CHECK(nfc_se_service_get_readers(phReaders, &numberOfReaders));
	emit message(QString("got handles for readers"));

	// Iterate through the readers to find the SIM reader.
	for (i = 0; i < numberOfReaders; i++) {
		len = 10;
		CHECK(nfc_se_reader_get_name(phReaders[i], readerName, &len));
		if ((len == 3) && (strcmp(readerName, "SIM") == 0)) {
			uiccSeReaderID = phReaders[i];
			emit message(QString("got handle to UICC SE reader"));
			break;
		}
	}

	// Deallocate the array for holding the readers.
	free(phReaders);
	emit message(QString("deallocated space allocated for readers"));

	// Open a session with the SIM Reader
	// Note: You may hold onto this session for the lifetime
	// of you application.
	CHECK(nfc_se_reader_open_session( uiccSeReaderID,&hSESession ));
	emit message(QString("opened session with UICC reader"));

	// Open a channel to AID
	fcpResponseType = OPEN_NO_FCP_INFO;
	openResponseLen = 0;

//	uint8_t[] aid_as_int = reinterpret_cast<unsigned char*>(the_aid.data());
	CHECK(nfc_se_session_open_logical_channel(hSESession, fixed_aid, 12, fcpResponseType, &seChannel, &openResponseLen));
	emit message(QString("opened logical channel"));

	// send APDU command
	QByteArray apduBytes = QByteArray::fromRawData(reinterpret_cast<const char *>(command_apdu), command_apdu_len);
	QString apduBytesAsHex = QString::fromAscii(apduBytes.toHex());
	emit message(QString("transmit:%1").arg(apduBytesAsHex));

	CHECK(nfc_se_channel_transmit_apdu( seChannel, command_apdu, command_apdu_len, &exchangeResponseLen ));

	// response length not working on Dev Alpha at present
	// so hard coding length which should be 7 for my test SIM (temporary code)
//.........这里部分代码省略.........
开发者ID:ch4,项目名称:Cascades-Community-Samples,代码行数:101,代码来源:NfcWorker.cpp

示例13: dump

void HexDump::dump(QByteArray* raw, const char* func, int line)
{
    qDebug() << func << line << "RawDump: BEGIN";
	//qDebug() << raw->size() << raw->toHex();

	unsigned int size = raw->size();

	int ze = 0;
	while(size!=0 && ze < 8)
	{
		size /= 10;
		ze++;
	}

	int lines = ceil(raw->size()/8.0);
	//qDebug() << lines;
	int pos=0;

	QByteArray part;
	QString out;

	for( int i=0 ; i<lines ; i++ )
	{
		out.clear();
		part.clear();
		part = raw->mid(pos, 8);

		out.append("0x");
		out.append(QString("%1").arg(pos,ze,16,QChar('0')));
		out.append(" / ");
		out.append(QString("%1").arg(pos,ze,10,QChar('0')));
		out.append(" - ");
		out.append(part.toHex());

		if(part.size() != 8)
		{
			int padd = 8-part.size();
			while(padd!=0)
			{
				out.append("  ");
				padd--;
			}
		}

		out.append(" - ");

		for( int p=0 ; p<part.size() ; p++ )
		{
			char c = part[p];
			if(c >= 0x20 && c <= 0x7E)
			{
				out.append(c);
			}
			else
			{
				out.append(' ');

			}
		}

		//qDebug() << out << part.toHex();
		qDebug() << out;
		pos +=8;
	}

	qDebug() << func << line << "RawDump: END";
}
开发者ID:jsiei97,项目名称:FT_EDS,代码行数:67,代码来源:HexDump.cpp

示例14: readUDP

void UdpManager::readUDP()
{
    QByteArray Temp;
    Temp.resize(socket->pendingDatagramSize());

    QHostAddress sender;
    quint16 senderPort;
    socket->readDatagram(Temp.data(),Temp.size(),&sender,&senderPort);

    QString debugMessage = "Got \"" + QString(Temp.data()) + "\" from " + sender.toString() + ":"+ QString::number(senderPort) + " (UDP)";
    emit updateClientGUIConsole(debugMessage);

    QString compareString = "BLENDER";
    QString message;
    if(Temp.data() == compareString)
    {
        if (workerIsBusy)
            message = "BLENDER0";       //is busy
        else{
            if (isGPUWorker)
                message = "BLENDER2";   // is available GPU-Worker
            else
                message = "BLENDER1";   // is available CPU-Worker
        }
        writeUDP(message, sender);
    }
    else if( QString(Temp.data()).at(0) == '#' && !workerIsBusy )
    {
        message = "";

        QString filepathToBlend = QDir::currentPath() + "/awesome.blend";

        QByteArray fileData;

        QFile file( filepathToBlend ); //e.g.: /.../build/awesome.blend
        if( file.open(QIODevice::ReadOnly) )
        {
            fileData = file.readAll();
            file.close();

            //Generate MD5 Hash
            QByteArray hashData = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
            file_hash = hashData.toHex();

            qDebug() << "Hex-Hash: " << hashData.toHex();

        }
        else
        {
            //Error
            file_hash = "Th15I5Th3DummymD5HasH0fGSORF.0RG";
        }

        //Send UDP Response
        writeUDP( "#" + file_hash, sender );
        if(file_hash==QString(Temp.data()).remove('#') )
        {
            emit setFileCached(true);
        }
        else
        {
            emit setFileCached(false);
        }
    }
    else if( QString(Temp.data()).startsWith("killall"))
    {
    qDebug()<<"Bye Bye Blender";
    QProcess *myProcess = new QProcess(this);
    myProcess->start("killall blender");
    myProcess->waitForFinished();
    }


    emit setServerAddress(sender);

}
开发者ID:GSORF,项目名称:renderfarm,代码行数:76,代码来源:udpmanager.cpp

示例15: detectOS

	coex::typeOS detectOS(QString inputFolder)
	{
		QList<fileos> listfiles;
		QList<fileos> checkfiles;

		// Windows XP
		listfiles << fileos( coex::ceWindowsXP, "5.1.2600.5512", "/WINDOWS/system32/kernel32.dll", "d612ee36f95da6d1179f7567b2b77d77");
		listfiles << fileos( coex::ceWindowsXP, "5.1.2600.5512", "/WINDOWS/system32/kernel32.dll", "800937D2446728367B713F5AC0B9BAC0"); // ??
		listfiles << fileos( coex::ceWindowsXP, "5.1.2600.5781", "/WINDOWS/system32/kernel32.dll", "E1E261C6D29F87FAFCC88F94952ED8D5");
		listfiles << fileos( coex::ceWindowsXP, "5.1.2600.6293", "/WINDOWS/system32/kernel32.dll", "9CB5C708CFBD8B007BE2C8A44A3DDE25");
		listfiles << fileos( coex::ceWindowsXP, "5.1.2600.6293", "/WINDOWS/system32/kernel32.dll", "D056B67FCC32221681438A6240DB3E1A");
		listfiles << fileos( coex::ceWindowsXP, "5.2.3790.4480", "/WINDOWS/system32/kernel32.dll", "43301E4453581691B791855934BFF7C5");
		listfiles << fileos( coex::ceWindowsXP, "5.2.3790.4480", "/WINDOWS/system32/kernel32.dll", "B4B82A9E888B1A8964D136AD227C6428");
		listfiles << fileos( coex::ceWindowsXP, "5.2.3790.5069", "/WINDOWS/system32/kernel32.dll", "23A6C522DF754CAD344D737AA45CBD03");
		listfiles << fileos( coex::ceWindowsXP, "5.2.3790.5069", "/WINDOWS/system32/kernel32.dll", "B6D45BB7311512B268064C1A203C003E");
		listfiles << fileos( coex::ceWindowsXP, "5.2.3790.5069", "/WINDOWS/system32/kernel32.dll", "2836EF1A4A12D5149D085833AC84A006");
		
		// Windows Vista
		listfiles << fileos( coex::ceWindowsVista , "6.0.6002.18704", "/Windows/system32/kernel32.dll", "A02EB771DAE80667E3C877CF19E3F6EE");		
		listfiles << fileos( coex::ceWindowsVista , "6.0.6002.18449", "/Windows/system32/KERNEL32.dll", "2299078C1E59FE69ADDF49897D6A373A");
		listfiles << fileos( coex::ceWindowsVista , "6.0.6002.18449", "/Windows/syswow64/kernel32.dll", "7F4CAEAC24592FA9F574E1F8CD1D0604");
		listfiles << fileos( coex::ceWindowsVista , "6.0.6002.18740", "/Windows/system32/kernel32.dll", "14EED915B63F7AB64A1E367BCB6973D0");
		listfiles << fileos( coex::ceWindowsVista , "6.0.6002.18740", "/Windows/system32/kernel32.dll", "12A16A6E0883D403FA78D1D825BB9824");
		listfiles << fileos( coex::ceWindowsVista , "6.0.6002.18740", "/Windows/system32/kernel32.dll", "A8EAB98AC1E987C925EF518E6065A36C");

		// Windows 7
		listfiles << fileos( coex::ceWindows7 , "6.1.7600.16385", "/Windows/system32/kernel32.dll", "5b4b379ad10deda4eda01b8c6961b193");
		listfiles << fileos( coex::ceWindows7 , "6.1.7600.16385", "/Windows/SYSTEM32/kernel32.dll", "4605F7EE9805F7E1C98D6C959DD2949C"); // ?? HW32.Laneul.xkyw
		listfiles << fileos( coex::ceWindows7 , "6.1.7600.16385", "/Windows/SysWOW64/kernel32.dll", "606ECB76A424CC535407E7A24E2A34BC");
		listfiles << fileos( coex::ceWindows7 , "6.1.7600.16850", "/Windows/system32/kernel32.dll", "DDBD24DC04DA5FD0EDF45CF72B7C01E2");
		listfiles << fileos( coex::ceWindows7 , "6.1.7600.17206", "/Windows/system32/kernel32.dll", "43DB3433F141F01E53D1C5AA0F434098");
		listfiles << fileos( coex::ceWindows7 , "6.1.7600.17206", "/Windows/SysWOW64/kernel32.dll", "385BE92E3106491BBB542F8F1C06C606");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17514", "/Windows/system32/kernel32.dll", "7A6326D96D53048FDEC542DF23D875A0");		
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17514", "/Windows/SysWOW64/kernel32.dll", "e80758cf485db142fca1ee03a34ead05");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17651", "/Windows/system32/kernel32.dll", "B9B42A302325537D7B9DC52D47F33A73");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17651", "/Windows/SysWOW64/kernel32.dll", "99C3F8E9CC59D95666EB8D8A8B4C2BEB");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17932", "/Windows/system32/kernel32.dll", "EAF41CFBA5281834CBC383C710AC7965");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17932", "/Windows/SysWOW64/kernel32.dll", "9B98D47916EAD4F69EF51B56B0C2323C");		
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17965", "/Windows/system32/kernel32.dll", "1DC3504CA4C57900F1557E9A3F01D272");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.17965", "/Windows/SysWOW64/kernel32.dll", "D4F3176082566CEFA633B4945802D4C4");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.18015", "/Windows/system32/kernel32.dll", "65C113214F7B05820F6D8A65B1485196");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.18015", "/Windows/system32/kernel32.dll", "AE09B85158C66E2C154C5C9B3C0027B3"); // HW32.Laneul.gqke
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.18015", "/Windows/SysWOW64/kernel32.dll", "AC0B6F41882FC6ED186962D770EBF1D2");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.18229", "/Windows/system32/kernel32.dll", "D8973E71F1B35CD3F3DEA7C12D49D0F0");
		listfiles << fileos( coex::ceWindows7 , "6.1.7601.18229", "/Windows/SysWOW64/kernel32.dll", "365A5034093AD9E04F433046C4CDF6AB");
		
		// windows 8
		listfiles << fileos( coex::ceWindows8 , "6.2.9200.16384", "/Windows/System32/kernel32.dll", "3C6933B638BB812F4084CF44AE698704");
		listfiles << fileos( coex::ceWindows8 , "6.2.9200.16384", "/Windows/System32/kernel32.dll", "744B34F13E730805E63076622418CCB8");
		listfiles << fileos( coex::ceWindows8 , "6.2.9200.16384", "/Windows/SysWOW64/kernel32.dll", "1C5F50F98291B7545391BB57C406E615");		
		listfiles << fileos( coex::ceWindows8 , "6.2.9200.16627", "/Windows/System32/kernel32.dll", "e1ff9d65e6b86f7ebb531ae36c5af635");

		for(int i = 0; i < listfiles.size(); i++)
		{
			QFileInfo fi(inputFolder + listfiles[i].filePath);
			if(fi.exists())
			{
				QFile file(fi.absoluteFilePath());
				if (file.open(QIODevice::ReadOnly)) 
				{
					QByteArray fileData = file.readAll();
					QByteArray hashData = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
					QString str = hashData.toHex();
							 
					if(str.toLower() == listfiles[i].hash.toLower())
						checkfiles << listfiles[i];
				}
			}
		}

		if(checkfiles.size() == 0)
			return coex::ceUnknown;


		coex::typeOS os_result = coex::ceUnknown;
		// check on conflicts
		{
			int nCounter = 0;
			for(int x = 0; x < checkfiles.size()-1; x++)
				for(int y = x+1; y < checkfiles.size(); y++)
				{
					if(checkfiles[x].os != checkfiles[y].os)
					{
						std::cout << " conflict between: \n\t " 
						<< checkfiles[x].toString().toStdString() 
						<< "\n\t and " << checkfiles[y].toString().toStdString() << "\n";
						nCounter++;
					};
				};
			if(nCounter == 0) 
			{
				std::cout << "\n  OS was detected";
				std::cout << checkfiles[0].toBigString().toStdString() << "\n";
				os_result = checkfiles[0].os;
			}
		};

    return os_result;
  };  
开发者ID:forensictool,项目名称:coex,代码行数:99,代码来源:coex_detectOS.cpp


注:本文中的QByteArray::toHex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。