Example #1
0
void InjectorStylePlugin::inject()
{
  const QByteArray probeDllPath = qgetenv("GAMMARAY_STYLEINJECTOR_PROBEDLL");
  if (probeDllPath.isEmpty()) {
    qWarning("No probe DLL specified.");
    return;
  }

  QLibrary probeDll(QString::fromLocal8Bit(probeDllPath));
  probeDll.setLoadHints(QLibrary::ResolveAllSymbolsHint);
  if (!probeDll.load()) {
    qWarning() << "Loading probe DLL failed:" << probeDll.errorString();
    return;
  }

  const QByteArray probeFunc = qgetenv("GAMMARAY_STYLEINJECTOR_PROBEFUNC");
  if (probeFunc.isEmpty()) {
    qWarning("No probe function specified.");
    return;
  }

  QFunctionPointer probeFuncHandle = probeDll.resolve(probeFunc);
  if (probeFuncHandle) {
    reinterpret_cast<void(*)()>(probeFuncHandle)();
  } else {
    qWarning() << "Resolving probe function failed:" << probeDll.errorString();
  }
}
Example #2
0
void MainWindow::on_VTPREFB_Input_editingFinished()
{
    tprefb=ui->VTPREFB_Input->text();
    QByteArray datagram = "-tprefb "+ tprefb.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #3
0
void MainWindow::on_SENDMAC_Input_editingFinished()
{
    Send_Mac=ui->SENDMAC_Input->text();
    QByteArray datagram = "-send_mac "+ Send_Mac.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #4
0
void MainWindow::on_ISHAPERTEST_Input_editingFinished()
{
    shapertest=ui->ISHAPERTEST_Input->text();
    QByteArray datagram = "-shapertest "+ shapertest.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #5
0
void MainWindow::on_ITPBUFFEROUT_Input_editingFinished()
{
    tpbufferout=ui->ITPBUFFEROUT_Input->text();
    QByteArray datagram = "-tpbuffout "+ tpbufferout.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #6
0
void MainWindow::on_Polarity_Input_currentIndexChanged(int index)
{
    Polarity.setNum(index);
    QByteArray datagram = "-polarity "+ Polarity.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #7
0
void MainWindow::on_IPREAMP_Input_editingFinished()
{
    preamp=ui->IPREAMP_Input->text();
    QByteArray datagram = "-preamp "+ preamp.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #8
0
int InjectedAudioStream::parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples) {
    // setup a data stream to read from this packet
    QDataStream packetStream(packetAfterSeqNum);

    // skip the stream identifier
    packetStream.skipRawData(NUM_BYTES_RFC4122_UUID);

    // pull the loopback flag and set our boolean
    uchar shouldLoopback;
    packetStream >> shouldLoopback;
    _shouldLoopbackForNode = (shouldLoopback == 1);

    // use parsePositionalData in parent PostionalAudioRingBuffer class to pull common positional data
    packetStream.skipRawData(parsePositionalData(packetAfterSeqNum.mid(packetStream.device()->pos())));

    // pull out the radius for this injected source - if it's zero this is a point source
    packetStream >> _radius;

    quint8 attenuationByte = 0;
    packetStream >> attenuationByte;
    _attenuationRatio = attenuationByte / (float)MAX_INJECTOR_VOLUME;

    int numAudioBytes = packetAfterSeqNum.size() - packetStream.device()->pos();
    numAudioSamples = numAudioBytes / sizeof(int16_t);

    return packetStream.device()->pos();
}
Example #9
0
QByteArray MyXmlDoc::save()
{
   QByteArray baDoc;
   baDoc.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r");
   baDoc.append(saveTag(m_root));
   return baDoc;
}
Example #10
0
void SendNetworkPackets(unsigned int i, unsigned int j, unsigned int k) { //sends desired data over UDP to the robot. I used it to send the # of squares and the ms required to render each frame. (It uses the time data to know when to read for UDP packets and hence the for loop iteration essentially stands for the # of frames it wants to read from the odroid.
    static QUdpSocket udpSocket; //create socket
    
    QByteArray datagram = QByteArray::number(i) + " " + QByteArray::number(j) + " " + QByteArray::number(k) + " "; //create data stream
    
    udpSocket.writeDatagram(datagram.data(), datagram.size(), QHostAddress(QstringTargetIPAddress), TargetPortNumber); //send that data stream over UDP to the TargetIpAddress with the given TargetPortNumber
}
Example #11
0
void ConnectionBackend::setSuspended(bool enable)
{
    if (state != Connected) {
        return;
    }
    Q_ASSERT(socket);
    Q_ASSERT(!localServer);     // !tcpServer as well

    if (enable) {
        //qCDebug(KIO_CORE) << socket << "suspending";
        socket->setReadBufferSize(1);
    } else {
        //qCDebug(KIO_CORE) << socket << "resuming";
        // Calling setReadBufferSize from a readyRead slot leads to a bug in Qt, fixed in 13c246ee119
#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
        socket->setReadBufferSize(StandardBufferSize);
#endif
        if (socket->bytesAvailable() >= HeaderSize) {
            // there are bytes available
            QMetaObject::invokeMethod(this, "socketReadyRead", Qt::QueuedConnection);
        }

        // We read all bytes here, but we don't use readAll() because we need
        // to read at least one byte (even if there isn't any) so that the
        // socket notifier is reenabled
        QByteArray data = socket->read(socket->bytesAvailable() + 1);
        for (int i = data.size(); --i >= 0;) {
            socket->ungetChar(data[i]);
        }
        // Workaround Qt5 bug, readyRead isn't always emitted here...
        QMetaObject::invokeMethod(this, "socketReadyRead", Qt::QueuedConnection);
    }
}
Example #12
0
void KSharedDataCacheTest::simpleInsert()
{
    const QLatin1String cacheName("myTestCache");
    const QLatin1String key("mypic");
    // clear the cache
    QString cacheFile = KGlobal::dirs()->locateLocal("cache", cacheName + QLatin1String(".kcache"));
    QFile file(cacheFile);
    if (file.exists())
        QVERIFY(file.remove());
    // insert something into it
    KSharedDataCache cache(cacheName, 5*1024*1024);
    QVERIFY(file.exists()); // make sure we got the cache filename right
    QByteArray data;
    data.resize(9228);
    strcpy(data.data(), "Hello world");
    QVERIFY(cache.insert(key, data));
    // read it out again
    QByteArray result;
    QVERIFY(cache.find(key, &result));
    QCOMPARE(result, data);
    // another insert
    strcpy(data.data(), "Hello KDE");
    QVERIFY(cache.insert(key, data));
    // and another read
    QVERIFY(cache.find(key, &result));
    QCOMPARE(result, data);
}
Example #13
0
void PsMainWindow::psInitSize() {
	setMinimumWidth(st::wndMinWidth);
	setMinimumHeight(st::wndMinHeight);

	TWindowPos pos(cWindowPos());
	QRect avail(QDesktopWidget().availableGeometry());
	bool maximized = false;
	QRect geom(avail.x() + (avail.width() - st::wndDefWidth) / 2, avail.y() + (avail.height() - st::wndDefHeight) / 2, st::wndDefWidth, st::wndDefHeight);
	if (pos.w && pos.h) {
		QList<QScreen*> screens = App::app()->screens();
		for (QList<QScreen*>::const_iterator i = screens.cbegin(), e = screens.cend(); i != e; ++i) {
			QByteArray name = (*i)->name().toUtf8();
			if (pos.moncrc == hashCrc32(name.constData(), name.size())) {
				QRect screen((*i)->geometry());
				int32 w = screen.width(), h = screen.height();
				if (w >= st::wndMinWidth && h >= st::wndMinHeight) {
					if (pos.w > w) pos.w = w;
					if (pos.h > h) pos.h = h;
					pos.x += screen.x();
					pos.y += screen.y();
					if (pos.x < screen.x() + screen.width() - 10 && pos.y < screen.y() + screen.height() - 10) {
						geom = QRect(pos.x, pos.y, pos.w, pos.h);
					}
				}
				break;
			}
		}

		if (pos.y < 0) pos.y = 0;
		maximized = pos.maximized;
	}
	setGeometry(geom);
}
bool QAndroidPlatformOpenGLContext::needsFBOReadBackWorkaround()
{
    static bool set = false;
    static bool needsWorkaround = false;

    if (!set) {
        QByteArray env = qgetenv("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND");
        needsWorkaround = env.isEmpty() || env == "0" || env == "false";

        if (!needsWorkaround) {
            const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
            needsWorkaround =
                    qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450
                    || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205
                    || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)'
                    || qstrncmp(rendererString, "Adreno (TM) 30x", 14) == 0 // Adreno 302, 305
                    || qstrncmp(rendererString, "Adreno 30x", 9) == 0 // Same as above but without the '(TM)'
                    || qstrcmp(rendererString, "GC800 core") == 0
                    || qstrcmp(rendererString, "GC1000 core") == 0
                    || qstrcmp(rendererString, "Immersion.16") == 0;
        }

        set = true;
    }

    return needsWorkaround;
}
Example #15
0
void MainWindow::on_Disc_CSM_SPM_Input_currentIndexChanged(int index)
{
    Disc_CSM_SPM.setNum(index);
    QByteArray datagram = "-discsel "+ Disc_CSM_SPM.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #16
0
QByteArray PropertyHandler::setter() const
{
    QByteArray result = name();
    result[0] = toupper(result[0]);
    result.prepend("set");
    return result;
}
Example #17
0
void MainWindow::on_Gain_Mode_Input_currentIndexChanged(int index)
{
    Gain_Mode.setNum(index);
    QByteArray datagram = "-gainmode "+ Gain_Mode.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #18
0
void ProfileInner::onUpdatePhoto() {
	saveError();

	QStringList imgExtensions(cImgExtensions());	
	QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;All files (*.*)"));

	QImage img;
	QString file;
	QByteArray remoteContent;
	if (filedialogGetOpenFile(file, remoteContent, lang(lng_choose_images), filter)) {
		if (!remoteContent.isEmpty()) {
			img = App::readImage(remoteContent);
		} else {
			if (!file.isEmpty()) {
				img = App::readImage(file);
			}
		}
	} else {
		return;
	}

	if (img.isNull() || img.width() > 10 * img.height() || img.height() > 10 * img.width()) {
		saveError(lang(lng_bad_photo));
		return;
	}
	PhotoCropBox *box = new PhotoCropBox(img, _peer->id);
	connect(box, SIGNAL(closed()), this, SLOT(onPhotoUpdateStart()));
	App::wnd()->showLayer(box);
}
Example #19
0
void MainWindow::on_TH7_Input_editingFinished()
{
    th7=ui->TH7_Input->text();
    QByteArray datagram = "-dacth7 "+ th7.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
void AdBlockSubscription::subscriptionDownloaded() {
  if (m_reply != qobject_cast<QNetworkReply*>(sender())) {
    return;
  }

  bool error = false;
  const QByteArray response = QString::fromUtf8(m_reply->readAll()).toUtf8();

  if (m_reply->error() != QNetworkReply::NoError || !response.startsWith(QByteArray("[Adblock")) || !saveDownloadedData(response)) {
    error = true;
  }

  m_reply->manager()->deleteLater();
  m_reply->deleteLater();
  m_reply = 0;

  if (error) {
    emit subscriptionError(tr("Cannot load subscription!"));

    return;
  }

  loadSubscription(AdBlockManager::instance()->disabledRules());
  emit subscriptionUpdated();
  emit subscriptionChanged();
}
Example #21
0
void MainWindow::on_IKRUM_Input_editingFinished()
{
    ikrum=ui->IKRUM_Input->text();
    QByteArray datagram = "-ikrum "+ ikrum.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #22
0
void ItemCreateJob::doHandleResponse( const QByteArray & tag, const QByteArray & data )
{
    Q_D( ItemCreateJob );

    if ( tag == "+" ) { // ready for literal data
        d->writeData( d->mData );
        if ( !d->mData.endsWith( '\n' ) )
            d->writeData( "\n" );
        return;
    }
    if ( tag == d->tag() ) {
        int uidNextPos = data.indexOf( "UIDNEXT" );
        if ( uidNextPos != -1 ) {
            bool ok = false;
            ImapParser::parseNumber( data, d->mUid, &ok, uidNextPos + 7 );
            if ( !ok ) {
                kDebug() << "Invalid UIDNEXT response to APPEND command: "
                         << tag << data;
            }
        }
        int dateTimePos = data.indexOf( "DATETIME" );
        if ( dateTimePos != -1 ) {
            int resultPos = ImapParser::parseDateTime( data, d->mDatetime, dateTimePos + 8 );
            if ( resultPos == (dateTimePos + 8) ) {
                kDebug() << "Invalid DATETIME response to APPEND command: "
                         << tag << data;
            }
        }
    }
}
Example #23
0
void MainWindow::on_IDELAY_Input_editingFinished()
{
    delay=ui->IDELAY_Input->text();
    QByteArray datagram = "-delay "+ delay.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #24
0
void MainWindow::on_Aquire_Time_Input_editingFinished()
{
    Time=ui->Aquire_Time_Input->text();
    QByteArray datagram = "-time "+ Time.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #25
0
void MainWindow::on_VCAS_Input_editingFinished()
{
    cas=ui->VCAS_Input->text();
    QByteArray datagram = "-cas "+ cas.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #26
0
void MainWindow::on_NImages_Input_editingFinished()
{
    NImage=ui->NImages_Input->text();
    QByteArray datagram = "-frames "+ NImage.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #27
0
void MainWindow::on_HOSTNETMASK_Input_editingFinished()
{
    Host_Net=ui->HOSTNETMASK_Input->text();
    QByteArray datagram = "-host_net "+ Host_Net.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
Example #28
0
void MainWindow::on_Read_Counter_Input_currentIndexChanged(int index)
{
    RCount.setNum(index);
    QByteArray datagram = "-readcounter "+ RCount.toUtf8();
    udpSocket->writeDatagram(datagram.data(),datagram.size(),Address_Transmit, COMPORT);
    ui->ready_bar->setValue(50);
}
    QByteArray RotationMatrixAndVectorsStdMessage::ToByteArray() const
    {
        QByteArray result;
        if (!_isCorrect)
        {
            return result;
        }

        result.append(headToByteArray());

        _serializer.Serialize(_time, result);
        _serializer.Serialize(_q00, result);
        _serializer.Serialize(_q01, result);
        _serializer.Serialize(_q02, result);
        _serializer.Serialize(_q12, result);
        _serializer.Serialize(_rms, result);
        _serializer.Serialize(_solType, result);
        _serializer.Serialize(_flag, result);
        _serializer.Serialize(_bl0, result);
        _serializer.Serialize(_bl1, result);
        _serializer.Serialize(_bl2, result);
        _serializer.Serialize(_cs, result);
        
        assert(result.size() == Size());
        return result;
    }
Example #30
0
void DialogClient::ReadStructDataAndShow()
{
    QString strMsg;
    QByteArray dataArray = m_pTCPClient->readAll();
    if(dataArray.length() != sizeof(NetData))
    {
        //长度不对
        strMsg = tr("Receive error, struct length is %1 B, recv length is %2 B")
                 .arg(sizeof(NetData)).arg(dataArray.length());

        qDebug()<<strMsg;
        //
        return;
    }
    //接收长度正确
    const NetData* pData = (NetData*)(dataArray.data());
    //显示
    QString strShow = tr("NetData: \r\n");
    strShow += tr("Length = %1\r\n").arg(pData->length);
    strShow += tr("n1 = %1\r\n").arg(pData->n1);
    strShow += tr("d1 = %1\r\n").arg(pData->d1);
    strShow += tr("d2 = %1\r\n").arg(pData->d2);
    strShow += tr("name = %1\r\n").arg(pData->name);
    //显示
    ui->labelShow->setText(strShow);

}