42 #ifndef QWSCOMMAND_QWS_P_H 43 #define QWSCOMMAND_QWS_P_H 60 #define MAX_COMMAND_SIZE (16 * 1024) 62 #include <QtCore/qbytearray.h> 63 #include <QtGui/qwsutils_qws.h> 64 #include <QtGui/qfont.h> 65 #include <QtCore/qdatastream.h> 66 #include <QtCore/qvariant.h> 67 #include <QtCore/qrect.h> 68 #include <QtGui/qregion.h> 69 #include <QtCore/qvector.h> 70 #include <QtCore/qvarlengtharray.h> 71 #include <QtGui/qwsevent_qws.h> 85 #ifndef QT_NO_QWS_MULTIPROCESS 136 #endif // QT_NO_DEBUG 148 sizeof(simpleData), reinterpret_cast<char *>(&simpleData))
150 simpleData.idLen = 0;
151 simpleData.idLock = -1;
154 void setData(
const char *
d,
int len,
bool allocateMem) {
158 qWarning(
"Identify command - name length %d - too big!", simpleData.idLen );
161 if ( simpleData.idLen *
int(
sizeof(
QChar)) > len )
163 qWarning(
"Identify command - name length %d - buffer size %d - buffer overrun!", simpleData.idLen, len );
167 id =
QString(reinterpret_cast<const QChar*>(d), simpleData.idLen);
174 simpleData.idLen =
id.
length();
175 simpleData.idLock =
lock;
176 setData(reinterpret_cast<const char*>(
id.unicode()), simpleData.idLen*2,
true);
190 reinterpret_cast<char *>(&count)), count(n) {}
198 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
200 void setData(
const char *
d,
int len,
bool allocateMem) {
204 qWarning(
"region name command - name length too big!" );
209 qWarning(
"region name command - caption length too big!" );
212 if ( simpleData.nameLen + simpleData.captionLen > len )
214 qWarning(
"region name command - name length %d - caption length %d - buffer size %d - buffer overrun!",
215 simpleData.nameLen, simpleData.captionLen, len );
220 name =
QString(reinterpret_cast<const QChar*>(d), simpleData.nameLen/2);
221 d += simpleData.nameLen;
222 caption =
QString(reinterpret_cast<const QChar*>(d), simpleData.captionLen/2);
230 int l = simpleData.nameLen =
name.length()*2;
231 l += simpleData.captionLen = caption.length()*2;
232 char *
d =
new char[
l];
233 memcpy(d,
name.unicode(), simpleData.nameLen);
234 memcpy(d+simpleData.nameLen, caption.unicode(), simpleData.captionLen);
252 reinterpret_cast<char*>(&simpleData)) {}
254 void setData(
const char *
d,
int len,
bool allocateMem =
true) {
257 if( simpleData.nrectangles *
int(
sizeof(
QRect)) + simpleData.surfacekeylength *
int(
sizeof(
QChar)) + simpleData.surfacedatalength *
int(
sizeof(
char)) > len )
259 qWarning(
"region command - rectangle count %d - surface key length %d - region data size %d - buffer size %d - buffer overrun!",
260 simpleData.nrectangles, simpleData.surfacekeylength, simpleData.surfacedatalength, len );
266 region.setRects(reinterpret_cast<QRect*>(ptr), simpleData.nrectangles);
267 ptr += simpleData.nrectangles *
sizeof(
QRect);
269 surfaceKey =
QString(reinterpret_cast<QChar*>(ptr),
270 simpleData.surfacekeylength);
271 ptr += simpleData.surfacekeylength *
sizeof(
QChar);
273 surfaceData =
QByteArray(ptr, simpleData.surfacedatalength);
286 simpleData.windowid = id;
287 simpleData.surfacekeylength = key.
size();
288 simpleData.surfacedatalength = data.
size();
289 simpleData.nrectangles = rects.
count();
322 reinterpret_cast<char*>(&simpleData)) {}
334 reinterpret_cast<char*>(&simpleData)) {}
348 reinterpret_cast<char*>(&simpleData)) {}
402 reinterpret_cast<char*>(&simpleData)) {
data = 0; }
404 void setData(
const char *
d,
int len,
bool allocateMem =
true) {
420 reinterpret_cast<char*>(&simpleData)) {}
422 void setData(
const char *
d,
int len,
bool allocateMem =
true) {
425 if( simpleData.nrectangles *
int(
sizeof(
QRect)) > len )
427 qWarning(
"repaint region command - region rectangle count %d - buffer size %d - buffer overrun",
428 simpleData.nrectangles, len );
430 simpleData.nrectangles = len /
sizeof(
QRect);
472 sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
476 int hour, minute,
sec, ms;
485 sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
499 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
501 void setData(
const char *
d,
int len,
bool allocateMem =
true) {
504 if (simpleData.height * ((simpleData.width+7) / 8) > len) {
505 qWarning(
"define cursor command - width %d height %d- buffer size %d - buffer overrun",
506 simpleData.width, simpleData.height, len );
507 simpleData.width = simpleData.height = 0;
526 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
538 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
550 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
562 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
575 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
577 void setData(
const char *
d,
int len,
bool allocateMem) {
599 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
601 void setData(
const char *
d,
int len,
bool allocateMem) {
605 qWarning(
"Command channel name too large!" );
608 if( simpleData.chLen *
int(
sizeof(
QChar)) > len )
610 qWarning(
"register qcop channel command - channel name length %d - buffer size %d - buffer overrun!", simpleData.chLen, len );
614 channel =
QString(reinterpret_cast<const QChar*>(d), simpleData.chLen);
621 simpleData.chLen = channel.
length();
622 setData(reinterpret_cast<const char*>(channel.unicode()), simpleData.chLen*2,
true);
635 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
637 void setData(
const char *
d,
int len,
bool allocateMem) {
640 if( simpleData.clen *
int(
sizeof(
QChar)) + simpleData.mlen *
int(
sizeof(
QChar)) + simpleData.dlen *
int(
sizeof(
char)) > len )
642 qWarning(
"qcop send command - channel name length %d - message name length %d - data size %d - buffer size %d - buffer overrun!",
643 simpleData.clen, simpleData.mlen, simpleData.dlen, len );
647 const QChar *cd =
reinterpret_cast<const QChar*
>(
d);
648 channel =
QString(cd,simpleData.clen); cd += simpleData.clen;
649 message =
QString(cd,simpleData.mlen);
650 d += simpleData.clen*
sizeof(
QChar) + simpleData.mlen*
sizeof(
QChar);
661 simpleData.clen = c.
length();
662 simpleData.mlen = m.
length();
663 simpleData.dlen = data.
size();
664 int l = simpleData.clen*
sizeof(
QChar);
665 l += simpleData.mlen*
sizeof(
QChar);
666 l += simpleData.dlen;
667 char *tmp =
new char[
l];
670 d += simpleData.clen*
sizeof(
QChar);
672 d += simpleData.mlen*
sizeof(
QChar);
673 memcpy(d, data.
data(), simpleData.dlen);
691 #ifndef QT_NO_QWS_INPUTMETHODS 697 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
711 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
713 void setData(
const char *
d,
int len,
bool allocateMem) {
741 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
752 #ifndef QT_NO_QWSEMBEDWIDGET 757 reinterpret_cast<char*>(&simpleData))
760 void setData(
const char *
d,
int len,
bool allocateMem =
true)
764 if( simpleData.rects *
int(
sizeof(
QRect)) > len )
766 qWarning(
"embed command - region rectangle count %d - buffer size %d - buffer overrun!",
767 simpleData.rects, len );
771 region.setRects(reinterpret_cast<QRect*>(
rawDataPtr),
779 simpleData.embedder = embedder;
780 simpleData.embedded = embedded;
781 simpleData.type =
type;
785 simpleData.rects = rects.
count();
800 #endif // QT_NO_QWSEMBEDWIDGET 811 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
813 void setData(
const char *
d,
int len,
bool allocateMem) {
835 sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
839 simpleData.screen = screen;
840 simpleData.transformation = transformation;
851 #endif // QWSCOMMAND_QWS_P_H The QVariant class acts like a union for the most common Qt data types.
The QDebug class provides an output stream for debugging information.
const T * constData() const
QWSRegionDestroyCommand()
void setData(int id, const QString &key, const QByteArray &data, const QRegion ®)
#define QT_END_NAMESPACE
This macro expands to.
void setData(const char *d, int len, bool allocateMem=true)
QWSRepaintRegionCommand()
char * data()
Returns a pointer to the data stored in the byte array.
void setData(const char *d, int len, bool allocateMem)
static QWSCommand * factory(int type)
void setChannel(const QString &n)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
QWSChangeAltitudeCommand()
virtual void setData(const char *data, int len, bool allocateMem=true)
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
void setData(const char *d, int len, bool allocateMem=true)
void setFileName(const QString &n)
QWSCreateCommand(int n=1)
The QString class provides a Unicode character string.
void setData(const char *d, int len, bool allocateMem)
The QChar class provides a 16-bit Unicode character.
void setId(const QString &i, int lock)
void setData(const char *d, int len, bool allocateMem=true)
void setFontName(const QByteArray &name)
void setData(const char *d, int len, bool allocateMem)
QWSPositionCursorCommand()
bool qws_read_command(QIODevice *socket, char *&simpleData, int &simpleLen, char *&rawData, int &rawLen, int &bytesRead)
void setName(const QString &n, const QString &c)
#define QT_BEGIN_NAMESPACE
This macro expands to.
void setData(const char *d, int len, bool allocateMem)
void setMessage(const QString &c, const QString &m, const QByteArray &data)
void qws_write_command(QIODevice *socket, int type, char *simpleData, int simpleLen, char *rawData, int rawLen)
int size() const
Returns the number of characters in this string.
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
QWSConvertSelectionCommand()
void setData(const char *d, int len, bool allocateMem)
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
Q_CORE_EXPORT void qWarning(const char *,...)
void setResult(const QVariant &v)
static const char * data(const QByteArray &arr)
void setData(WId embedder, WId embedded, QWSEmbedEvent::Type type, const QRegion reg=QRegion())
void setData(const char *d, int len, bool allocateMem)
The QRegion class specifies a clip region for a painter.
const T * ptr(const T &t)
const char * qws_getCommandTypeString(QWSCommand::Type tp)
void setData(const char *d, int len, bool allocateMem=true)
const char * constData() const
Returns a pointer to the data stored in the byte array.
void setData(const char *d, int len, bool allocateMem=true)
QWSSetSelectionOwnerCommand()
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
static QReadWriteLock lock
The QRect class defines a rectangle in the plane using integer precision.
int size() const
Returns the number of bytes in this byte array.
QWSQCopRegisterChannelCommand()
QWSRemovePropertyCommand()
The QDataStream class provides serialization of binary data to a QIODevice.
const T * constData() const
Returns a const pointer to the data stored in the vector.
QDebug & operator<<(QDebug &dbg, QWSCommand::Type tp)
The QIODevice class is the base interface class of all I/O devices in Qt.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
void setData(const char *d, int len, bool allocateMem)
QWSCommand(int t, int len, char *ptr)