void profortosi_progress_1_1::requestproFortosi()
 {
	QByteArray block;
	QDataStream out(&block,QIODevice::WriteOnly);
	out.setVersion(QDataStream::Qt_4_1);
	QString req_type="PRE";
	out << quint16(0)<<req_type<<QString(profortosi_id);
	qDebug()<<"FORTOSI_ID"<<profortosi_id;
	out.device()->seek(0);
	out<<quint16(block.size()-sizeof(quint16));
	client->write(block);

 }
Example #2
0
void board_2048::slotSendToServer()
{
    QByteArray arrBlock;
    QDataStream out(&arrBlock, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_5_4);

    out << quint16(0) << ui->curScore->text() << ui->bestScore->text();

    out.device()->seek(0);
    out << quint16(arrBlock.size() - sizeof(quint16));

    TcpSocket->write(arrBlock);
}
Example #3
0
void FrontClientSocket::sentToClient(int tag)
{
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_1);

    out << quint16(0);
    out << quint16(tag);

    out.device()->seek(0);
    out << quint16(block.size() - sizeof(quint16));
    write(block);
}
void TripPlanner::sendRequest()
  {
  QByteArray block;
  QDataStream out(&block, QIODevice::WriteOnly);
  out.setVersion(QDataStream::Qt_4_1);


  out << quint16(0) << quint8('B') << busID << busName;
  out.device()->seek(0); // Go to beginning of block.
  out << quint16(block.size() - sizeof(quint16));
  this->write(block);
  stopSearch();
}
void Client::sendLoginInfo(){
	QByteArray block;
	QDataStream out(&block, QIODevice::WriteOnly);
	out.setVersion(QDataStream::Qt_4_1);
	out << quint16(0) << quint8('L') << userLineEdit->text() << passLineEdit->text();

	out.device()->seek(0);
	out << quint16(block.size() - sizeof(quint16));
	tcpSocket->write(block);

	//ui.label->setText(tr("Sending request..."));
	//printf("Sending Request...\n");
}
void Profile_T::testConstructorEmpty()
{
    QSS::Profile p;
    QVERIFY(p.server.isEmpty());
    QCOMPARE(QString("127.0.0.1"), p.local_address);
    QVERIFY(p.method.isEmpty());
    QVERIFY(p.password.isEmpty());
    QCOMPARE(quint16(8388), p.server_port);
    QCOMPARE(quint16(1080), p.local_port);
    QCOMPARE(600, p.timeout);
    QVERIFY(!p.auth);
    QVERIFY(!p.debug);
    QVERIFY(!p.http_proxy);
}
Example #7
0
// Testing get/set functions
void tst_QAbstractSocket::getSetCheck()
{
    MyAbstractSocket obj1;
    // qint64 QAbstractSocket::readBufferSize()
    // void QAbstractSocket::setReadBufferSize(qint64)
    obj1.setReadBufferSize(qint64(0));
    QCOMPARE(qint64(0), obj1.readBufferSize());
    obj1.setReadBufferSize((Q_INT64_C(-9223372036854775807) - 1));
    QCOMPARE((Q_INT64_C(-9223372036854775807) - 1), obj1.readBufferSize());
    obj1.setReadBufferSize(Q_INT64_C(9223372036854775807));
    QCOMPARE(Q_INT64_C(9223372036854775807), obj1.readBufferSize());

    // quint16 QAbstractSocket::localPort()
    // void QAbstractSocket::setLocalPort(quint16)
    obj1.setLocalPort(quint16(0));
    QCOMPARE(quint16(0), obj1.localPort());
    obj1.setLocalPort(quint16(0xffff));
    QCOMPARE(quint16(0xffff), obj1.localPort());

    // quint16 QAbstractSocket::peerPort()
    // void QAbstractSocket::setPeerPort(quint16)
    obj1.setPeerPort(quint16(0));
    QCOMPARE(quint16(0), obj1.peerPort());
    obj1.setPeerPort(quint16(0xffff));
    QCOMPARE(quint16(0xffff), obj1.peerPort());
}
Example #8
0
void PlayerSocket::sendEnemyConnectionInf(const QSharedPointer<PlayerSocket>& enemy, bool serverFlag)
{
    QByteArray bytes;
    QDataStream request(&bytes, QIODevice::ReadWrite);
    request.setVersion(Protocol::QDataStreamVersion);

    request << quint16(0) << quint8(Protocol::GAME_FOUND) << serverFlag;
    request << enemy->getServerPort() << enemy->getHostName().toLatin1().data();
    request.device()->seek(0);
    request << quint16(bytes.size());

    socket->write(bytes);
    socket->flush();
}
Example #9
0
bool HciManager::sendConnectionParameterUpdateRequest(quint16 handle,
                                                      const QLowEnergyConnectionParameters &params)
{
    ConnectionUpdateData connUpdateData = connectionUpdateData(params);

    // Vol 3, part A, 4
    struct SignalingPacket {
        quint8 code;
        quint8 identifier;
        quint16 length;
    } signalingPacket;
    signalingPacket.code = 0x12;
    signalingPacket.identifier = ++sigPacketIdentifier;
    const quint16 sigPacketLen = sizeof connUpdateData;
    signalingPacket.length = qToLittleEndian(sigPacketLen);

    L2CapHeader l2CapHeader;
    const quint16 l2CapHeaderLen = sizeof signalingPacket + sigPacketLen;
    l2CapHeader.length = qToLittleEndian(l2CapHeaderLen);
    l2CapHeader.channelId = qToLittleEndian(quint16(SIGNALING_CHANNEL_ID));

    // Vol 2, part E, 5.4.2
    AclData aclData;
    aclData.handle = qToLittleEndian(handle); // Works because the next two values are zero.
    aclData.pbFlag = 0;
    aclData.bcFlag = 0;
    aclData.dataLen = qToLittleEndian(quint16(sizeof l2CapHeader + l2CapHeaderLen));

    struct iovec iv[5];
    quint8 packetType = HCI_ACL_PKT;
    iv[0].iov_base = &packetType;
    iv[0].iov_len  = 1;
    iv[1].iov_base = &aclData;
    iv[1].iov_len  = sizeof aclData;
    iv[2].iov_base = &l2CapHeader;
    iv[2].iov_len = sizeof l2CapHeader;
    iv[3].iov_base = &signalingPacket;
    iv[3].iov_len = sizeof signalingPacket;
    iv[4].iov_base = &connUpdateData;
    iv[4].iov_len = sizeof connUpdateData;
    while (writev(hciSocket, iv, sizeof iv / sizeof *iv) < 0) {
        if (errno == EAGAIN || errno == EINTR)
            continue;
        qCDebug(QT_BT_BLUEZ()) << "failure writing HCI ACL packet:" << strerror(errno);
        return false;
    }
    qCDebug(QT_BT_BLUEZ) << "Connection Update Request packet sent successfully";
    return true;
}
Example #10
0
void MadNet::sendKeyEvent(QKeyEvent * myEvent){
	QByteArray controls;
    QDataStream controlStream(&controls, QIODevice::ReadWrite);
    controlStream.setVersion(QDataStream::Qt_4_1);

    controlStream << quint16(0);
	controlStream	<< quint64(myEvent->type())
					<< quint64(myEvent->key())
					<< quint64(myEvent->modifiers());
	
	controlStream.device()->seek(0);
	controlStream << quint16(controls.size() - sizeof(quint16));	

	socket.write(controls);
}
 //Write to the server to verify the user infomation
void LoginDialog::verify()
{
    qDebug("Connected to server...");
    ui->loginButton->setDisabled(true);

    QByteArray block;
    QDataStream out(&block,QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_7);
    out << quint16(0) << QString("Verify") << m_userName.trimmed() << m_password.trimmed();
    out.device()->seek(0);
    out << quint16(block.size() - sizeof(quint16));
    qDebug() << block.size();
    client->write(block);

}
Example #12
0
void Client::slotSendToServer()
{
    QByteArray  arrBlock;
    QDataStream out(&arrBlock, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_2);
    QString str = "message " + ui->m_ptxtInput->text();
    out << quint16(0) <<QTime::currentTime() << str;

    out.device()->seek(0);
    out << quint16(arrBlock.size() - sizeof(quint16));

    ui->m_ptxtInfo->append("you: " + ui->m_ptxtInput->text());
    m_pTcpSocket->write(arrBlock);
    ui->m_ptxtInput->setText("");
}
Example #13
0
void Server::sendToClient(int number)
{
    QByteArray arrBlock;
    QDataStream out(&arrBlock, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_5_2);
    out << quint16(0) << QString::number(number);

    out.device()->seek(0);
    out << quint16(arrBlock.size() - sizeof(quint16));

    sender->write(arrBlock);
    txtInfo->append("<b>You:</b>");
    txtInfo->append(QString::number(number));
    field->lockButtons();
}
Example #14
0
bool TestManager::editTest(const QString &catName, const QString &testName, const quint32 numVis, const bool vis)
{
	if(!tests->editTest(catName, testName, numVis, vis))
		return false;
	
	Test test = getTest(catName, testName);
	test.setNumVis(numVis);
	if(vis)
		test.setVis();
	else
		test.setNoVis();
	
	QString testFileName = tests->getFileNameTest(catName, testName);
	
	QFile file(testsDir + "/" + testFileName);
	if(!file.open(QIODevice::WriteOnly))
	{
		qDebug() << "Can not open file " << (testsDir + "/" + testFileName) << " for writing. Error: " << file.errorString();
		return false;
	}
	
	QDataStream out(&file);
	out << quint32(magicNumber) << quint16(out.version());
	out << test;
	return true;
	
}
void ProjectorShutterBlock::resetConnection() {
    m_tcpSocket->abort();
    m_tcpSocket->connectToHost(m_ipAddress, quint16(m_port));
    m_projectorName = "";
    m_powerStatus = 0;
    m_passwordIsWrong = false;
}
void ProjectorShutterBlock::connectToProjector() {
    if (m_tcpSocket->isOpen()) {
        m_tcpSocket->disconnectFromHost();
        m_connected = false;
    }
    m_tcpSocket->connectToHost(m_ipAddress, quint16(m_port));
}
Example #17
0
bool Writer::writeHeader()
{
	Q_ASSERT(m_file->isOpen());

	// Format identification
	const char *MAGIC = "DPREC";
	m_file->write(MAGIC, 6);

	// Metadata block
	QJsonObject metadata;
	QJsonObject version;
	version["major"] = DRAWPILE_PROTO_MAJOR_VERSION;
	version["minor"] = DRAWPILE_PROTO_MINOR_VERSION;
	version["str"] = DRAWPILE_VERSION;
	metadata["version"] = version;

	// Write metadata
	QByteArray metadatabuf = QJsonDocument(metadata).toJson(QJsonDocument::Compact);

	uchar lenbuf[2];
	qToBigEndian(quint16(metadatabuf.length()), lenbuf);
	m_file->write((const char*)lenbuf, 2);

	m_file->write(metadatabuf);

	return true;
}
Example #18
0
//SLOTS:
void ConnectionWidget::connectToRobot()
{

    //Connect Code HERE
    QHostAddress address = QHostAddress(robotName);
    quint16 port = quint16(8533);
    udpSocket->bind(QHostAddress::Any, port);
    const char* data = "1";

    if(udpSocket->writeDatagram (data, 1, address, port) == -1)
    {
        statusNetworkLabel->setText("Disconnect Error: Unable to send packet.");
        disconnectButton->setEnabled(false);
        connectButton->setEnabled(true);
    }
    else
    {
        QString text = QString("Connected to: ");
        text.append(robotName);
        statusNetworkLabel->setText(text);
        disconnectButton->setEnabled(true);
        connectButton->setEnabled(false);
    }

}
Example #19
0
void ClientCore::sendBlock(quint8 command, QByteArray *data)
{
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);

    out << quint16(0);
    out << command;
    if (data!=NULL){
        block.append(*data);
    }

    out.device()->seek(0);
    out << quint16(block.size() - sizeof(quint16));

    mainSocket->write(block);
}
Example #20
0
void OS2LPlugin::setParameter(quint32 universe, quint32 line, Capability type,
                             QString name, QVariant value)
{
    /** This method is provided to QLC+ to set the plugin specific settings.
     *  Those settings are saved in a project workspace and when it is loaded,
     *  this method is called after QLC+ has opened the input/output lines
     *  mapped in the project workspace as well.
     */

    if (name == OS2L_HOST_ADDRESS)
    {

    }
    else if (name == OS2L_HOST_PORT)
    {
        if (value.toInt() != m_hostPort)
        {
            m_hostPort = quint16(value.toUInt());

            /** restart the TCP server and listen on new port */
            enableTCPServer(false);
            enableTCPServer(true);
        }
    }

    /** Remember to call the base QLCIOPlugin method to actually inform
     *  QLC+ to store the parameter in the project workspace XML */
    QLCIOPlugin::setParameter(universe, line, type, name, value);
}
Example #21
0
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    app.addLibraryPath(app.applicationDirPath() + "/lib");

    QCommandLineParser parser;
    QList<QCommandLineOption> optionList;
    optionList.append({{"d", "debug"}, "Log debug messages."});
    optionList.append({{"c", "console"}, "Output log to the console."});
    optionList.append({{"p", "port"}, "Application connection port.", "port", "1067"});
    optionList.append({"database", "The name of the database file.", "database", "softphoneDatabase.db3"});
    parser.addOptions(optionList);
    parser.process(app);

    bool debugOutput = parser.isSet("debug");
    Logger::getInstance().enableDebugOutput(debugOutput);

    bool consoleOutput = parser.isSet("console");
    Logger::getInstance().enableConsoleOutput(consoleOutput);

    SpThreadServer *server = new SpThreadServer();
    server->setPort(quint16(parser.value("port").toInt()));
    server->setDatabasePath(parser.value("database"));
    server->start();

    app.exec();
    server->deleteLater();
}
void Profile_T::testConstructorURI()
{
    // ss://bf-cfb-auth:test@192.168.100.1:8888
    QSS::Profile p("ss://YmYtY2ZiLWF1dGg6dGVzdEAxOTIuMTY4LjEwMC4xOjg4ODg#Tést");
    QCOMPARE(QString("Tést"), p.nameTag);
    QCOMPARE(QString("192.168.100.1"), p.server);
    QCOMPARE(QString("127.0.0.1"), p.local_address);
    QCOMPARE(QString("bf-cfb"), p.method);
    QCOMPARE(QString("test"), p.password);
    QCOMPARE(quint16(8888), p.server_port);
    QCOMPARE(quint16(1080), p.local_port);
    QCOMPARE(600, p.timeout);
    QVERIFY(p.auth);
    QVERIFY(!p.debug);
    QVERIFY(!p.http_proxy);
}
Example #23
0
msgEncode::msgEncode(QString msg){
    Nickname=msg;
    for (int i=0;i<Nickname.length();i++){
        if (Nickname[i]==':'){
            message=Nickname.right(Nickname.length()-i-1);
            Nickname.resize(i);
            break;
        }
    }
    QDataStream out(&block, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_8);
    out<<quint16(0);
    out<<Nickname+":"+message;
    out.device()->seek(0);
    out<<quint16(block.size()-sizeof(quint16));
}
Example #24
0
void tst_QBluetoothUuid::tst_conversion_data()
{
    QTest::addColumn<bool>("constructUuid16");
    QTest::addColumn<quint16>("uuid16");
    QTest::addColumn<bool>("constructUuid32");
    QTest::addColumn<quint32>("uuid32");
    QTest::addColumn<bool>("constructUuid128");
    QTest::addColumn<quint128>("uuid128");
    QTest::addColumn<QString>("uuidS");

    NEWROW32("base uuid", 0x00, 0x00, 0x00, 0x00, "00000000" BASEUUID);
    NEWROW16("0x0001", 0x00, 0x01, "00000001" BASEUUID);
    NEWROW16("0xffff", 0xff, 0xff, "0000FFFF" BASEUUID);
    NEWROW32("0x00010000", 0x00, 0x01, 0x00, 0x00, "00010000" BASEUUID);
    NEWROW32("0x0001ffff", 0x00, 0x01, 0xff, 0xff, "0001FFFF" BASEUUID);
    NEWROW32("0xffff0000", 0xff, 0xff, 0x00, 0x00, "FFFF0000" BASEUUID);
    NEWROW32("0xffffffff", 0xff, 0xff, 0xff, 0xff, "FFFFFFFF" BASEUUID);

    {
        quint128 uuid128 = {
            {
                0x00, 0x11, 0x22, 0x33,
                0x44, 0x55,
                0x66, 0x77,
                0x88, 0x99,
                0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
            }
        };

        QTest::newRow("00112233-4455-6677-8899-AABBCCDDEEFF")
            << false << quint16(0) << false << quint32(0) << true << uuid128
            << QString(QLatin1String("{00112233-4455-6677-8899-AABBCCDDEEFF}"));
    }
}
Example #25
0
QModbusResponse QModbusServerPrivate::processReadFifoQueueRequest(const QModbusRequest &request)
{
    CHECK_SIZE_LESS_THAN(request);
    quint16 address;
    request.decodeData(&address);

    quint16 fifoCount;
    if (!q_func()->data(QModbusDataUnit::HoldingRegisters, address, &fifoCount)) {
        return QModbusExceptionResponse(request.functionCode(),
                                        QModbusExceptionResponse::IllegalDataAddress);
    }

    if (fifoCount > 31u) {
        return QModbusExceptionResponse(request.functionCode(),
                                        QModbusExceptionResponse::IllegalDataValue);
    }

    QModbusDataUnit fifoRegisters(QModbusDataUnit::HoldingRegisters, address + 1u, fifoCount);
    if (!q_func()->data(&fifoRegisters)) {
        return QModbusExceptionResponse(request.functionCode(),
                                        QModbusExceptionResponse::IllegalDataAddress);
    }

    return QModbusResponse(request.functionCode(), quint16((fifoCount * 2) + 2u), fifoCount,
                           fifoRegisters.values());
}
Example #26
0
int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);

	if (4 != argc)
	{
		usage();
		return 1;
	}
	else
	{
		QString const server_ip_str(argv[1]);
		QString const server_port_str(argv[2]);
		QString const local_port_str(argv[3]);

		QHostAddress const server_ip(server_ip_str);
		quint16 const server_port = server_port_str.toShort();
		quint16 const local_port = local_port_str.toShort();

		worker w(local_port);
		if (!w.connect_to_server(server_ip, quint16(server_port)))
			return 1;

		return a.exec();
	}
}
Example #27
0
void WorldSession::SendEnterWorld()
{
    Character* character = GetCharacter();
    if (!character)
        return;

    WorldPacket data(SMSG_ENTER_WORLD);
    data << quint64(character->GetGuid());
    data.StartBlock<quint16>();
    {
        // Char part Id
        data << quint8(15);

        // NATION_ID
        data << quint32(0); // Nation Id

        // NATION_SYNCHRO
        data << quint64(0); // Ranks
        data << quint64(0); // Jobs
        data << quint64(0); // Votedate
        data << quint8(0); // Government Opionion => TODO : aWj.java
        data << quint8(0); // IsCandidate (bool)

        // GUILD_LOCAL_INFO
        data << quint16(0); // Guild info
        data << quint32(66); // havenWorldId
        data << float(0.0f); // moderationBonusLearningFactor
    }
    data.EndBlock<quint16>();

    SendPacket(data);
}
Example #28
0
void tst_QXmppJingleIq::testCandidate()
{
    const QByteArray xml(
        "<candidate component=\"1\""
        " foundation=\"1\""
        " generation=\"0\""
        " id=\"el0747fg11\""
        " ip=\"10.0.1.1\""
        " network=\"1\""
        " port=\"8998\""
        " priority=\"2130706431\""
        " protocol=\"udp\""
        " type=\"host\"/>");

    QXmppJingleCandidate candidate;
    parsePacket(candidate, xml);
    QCOMPARE(candidate.foundation(), QLatin1String("1"));
    QCOMPARE(candidate.generation(), 0);
    QCOMPARE(candidate.id(), QLatin1String("el0747fg11"));
    QCOMPARE(candidate.host(), QHostAddress("10.0.1.1"));
    QCOMPARE(candidate.network(), 1);
    QCOMPARE(candidate.port(), quint16(8998));
    QCOMPARE(candidate.priority(), 2130706431);
    QCOMPARE(candidate.protocol(), QLatin1String("udp"));
    QCOMPARE(candidate.type(), QXmppJingleCandidate::HostType);
    serializePacket(candidate, xml);
};
Example #29
0
void User::sendUserList()
{
    QByteArray outBlock;
    QDataStream out(&outBlock, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_8);
    out << quint16(0) << User::_action_UserList;

    QStringList userList = _serverUser->getUserList();
    out << userList.length();
    for (int i = 0; i < userList.length(); ++i)
        out << userList.at(i);

    out.device()->seek(0);
    out << quint16(outBlock.size() - sizeof(quint16));
    _socketUser->write(outBlock);
}
void Client::sendSearchInfo(){
	QByteArray block;
	QDataStream out(&block, QIODevice::WriteOnly);
	out.setVersion(QDataStream::Qt_4_1);
	//if(!userLineEdit->text().isEmpty()){
		out << quint16(0) << quint8('S') << userLineEdit->text();
		out.device()->seek(0);
		out << quint16(block.size() - sizeof(quint16));
		tcpSocket->write(block);
	//}else{
	//	statusLabel->setText("Please enter a file to search for");
	//}

	//ui.label->setText(tr("Sending request..."));
	//printf("Sending Request...\n");
}