Esempio n. 1
0
void qws_write_command(QIODevice *socket, int type, char *simpleData, int simpleLen,
                       char *rawData, int rawLen)
{
#ifdef QWSCOMMAND_DEBUG
    if (simpleLen) qDebug() << "WRITE simpleData " << QWSHexDump(simpleData, simpleLen);
    if (rawLen > 0) qDebug() << "WRITE rawData " << QWSHexDump(rawData, rawLen);
#endif

#ifndef QT_NO_SXE
    QTransportAuth *a = QTransportAuth::getInstance();
    // ###### as soon as public API can be modified get rid of horrible casts
    QIODevice *ad = a->passThroughByClient(reinterpret_cast<QWSClient*>(socket));
    if (ad)
        socket = ad;
#endif

    qws_write_uint(socket, type);

    if (rawLen > MAX_COMMAND_SIZE) {
        qWarning("qws_write_command: Message of size %d too big. "
                 "Truncated to %d", rawLen, MAX_COMMAND_SIZE);
        rawLen = MAX_COMMAND_SIZE;
    }

    qws_write_uint(socket, rawLen == -1 ? 0 : rawLen);

    if (simpleData && simpleLen)
        socket->write(simpleData, simpleLen);

    if (rawLen && rawData)
        socket->write(rawData, rawLen);
}
Esempio n. 2
0
void qws_write_command( QWSSocket *socket, int type,
			       char *simpleData, int simpleLen, char *rawData, int rawLen )
{
    qws_write_uint( socket, type );
    qws_write_uint( socket, rawLen == -1 ? 0 : rawLen );
    if ( simpleData && simpleLen )
	socket->writeBlock( simpleData, simpleLen );
    if ( rawLen && rawData )
	socket->writeBlock( rawData, rawLen );
}