50 #ifdef QWSCOMMAND_DEBUG 58 #ifdef QWSCOMMAND_DEBUG 60 # define QWSHEXDUMP_MAX 32 65 QWSHexDump(
const void *address,
int len,
int wrapAt = 16)
66 : wrap(wrapAt), dataSize(len)
69 data =
reinterpret_cast<const char*
>(address);
74 QWSHexDump(
const char *str,
int len = -1,
int wrapAt = 16)
75 : wrap(wrapAt), dataSize(len)
80 dataSize = str ? strlen(str) : 0;
83 QWSHexDump(
const QByteArray &array,
int wrapAt = 16)
88 dataSize = array.
size();
92 void setPrefix(
const char *str) { prefix = str; }
95 void setClusterSize(
uint num) { clustering = num; }
109 void sideviewDump(
int at);
120 char sideviewLayout[QWSHEXDUMP_MAX + 1];
130 if (wrap > QWSHEXDUMP_MAX)
131 wrap = QWSHEXDUMP_MAX;
134 void QWSHexDump::hexDump()
136 *outstrm <<
'(' << dataSize <<
" bytes):\n" << prefix;
137 sprintf(sideviewLayout,
" [%%-%us]", wrap);
138 dataWidth = (2 * wrap) + (wrap / clustering);
142 for (
uint i = 0; i < dataSize; i++) {
144 sideview[wrapIndex = i%wrap] = isprint(c) ?
c :
'.';
146 if (wrapIndex && (wrapIndex % clustering == 0))
149 outstrm->setFieldWidth(2);
150 outstrm->setPadChar(
'0');
152 *outstrm <<
hex <<
c;
155 if (wrapIndex == wrap-1) {
156 sideviewDump(wrapIndex);
159 *outstrm <<
endl << prefix;
163 sideviewDump(wrapIndex);
166 void QWSHexDump::sideviewDump(
int at)
172 int currentWidth = (2 *
at) + (at / clustering) - (at%clustering?0:1);
173 int missing =
qMax(dataWidth - currentWidth, 0);
178 outstrm->setPadChar(
' ');
179 outstrm->setFieldWidth(wrap);
181 *outstrm << sideview;
198 return dbg <<
"QWSHexDump(0x0)";
199 QString result = hd->toString();
219 const char * eventNames[N_EVENTS] = {
222 "Mouse",
"Focus",
"Key",
251 typeStr =
"Shutdown";
257 typeStr =
"RegionMove";
260 typeStr =
"RegionDestroy";
263 typeStr =
"SetProperty";
266 typeStr =
"AddProperty";
269 typeStr =
"RemoveProperty";
272 typeStr =
"GetProperty";
275 typeStr =
"SetSelectionOwner";
278 typeStr =
"ConvertSelection";
281 typeStr =
"RequestFocus";
284 typeStr =
"ChangeAltitude";
287 typeStr =
"SetOpacity";
290 typeStr =
"DefineCursor";
293 typeStr =
"SelectCursor";
296 typeStr =
"PositionCursor";
299 typeStr =
"GrabMouse";
302 typeStr =
"PlaySound";
305 typeStr =
"QCopRegisterChannel";
308 typeStr =
"QCopSend";
311 typeStr =
"RegionName";
314 typeStr =
"Identify";
317 typeStr =
"GrabKeyboard";
320 typeStr =
"RepaintRegion";
326 typeStr =
"IMUpdate";
329 typeStr =
"IMResponse";
349 #ifndef QT_NO_QWS_MULTIPROCESS 351 char *rawData,
int rawLen)
353 #ifdef QWSCOMMAND_DEBUG 354 if (simpleLen)
qDebug() <<
"WRITE simpleData " << QWSHexDump(simpleData, simpleLen);
355 if (rawLen > 0)
qDebug() <<
"WRITE rawData " << QWSHexDump(rawData, rawLen);
369 qWarning(
"qws_write_command: Message of size %d too big. " 376 if (simpleData && simpleLen)
377 socket->
write(simpleData, simpleLen);
379 if (rawLen && rawData)
380 socket->
write(rawData, rawLen);
389 char *&rawData,
int &rawLen,
int &bytesRead)
400 if (simpleLen && !rawData) {
403 int tmp = socket->
read(simpleData, simpleLen);
410 qWarning(
"qws_read_command: Won't read command of length %d, " 411 "connection closed.", rawLen);
416 if (rawLen && !rawData) {
417 rawData =
new char[rawLen];
420 if (bytesRead < rawLen && socket->bytesAvailable())
421 bytesRead += socket->
read(rawData + bytesRead, rawLen - bytesRead);
423 return (bytesRead == rawLen);
437 #ifndef QT_NO_QWS_MULTIPROCESS 439 #ifdef QWSCOMMAND_DEBUG 443 qDebug() <<
"QWSProtocolItem::write sending event " << (
type < N_EVENTS ? eventNames[
type] :
"unknown");
449 #ifdef QWSCOMMAND_DEBUG 454 qDebug() <<
"QWSProtocolItem::read reading event " << (
type < N_EVENTS ? eventNames[
type] :
"unknown") << reread;
457 bool b =
qws_read_command(s, simpleDataPtr, simpleLen, rawDataPtr, rawLen, bytesRead);
459 setData(rawDataPtr, rawLen,
false);
462 #ifdef QWSCOMMAND_DEBUG 470 #endif // QT_NO_QWS_MULTIPROCESS 482 delete [] rawDataPtr;
483 if (!data || len <= 0) {
489 rawDataPtr =
new char[len];
490 memcpy(rawDataPtr, data, len);
493 rawDataPtr =
const_cast<char *
>(
data);
576 #ifndef QT_NO_QWS_INPUTMETHODS 592 #ifndef QT_NO_QWSEMBEDWIDGET 604 qWarning(
"QWSCommand::factory : Type error - got %08x!", type);
The QDebug class provides an output stream for debugging information.
bool qws_read_command(QIODevice *socket, char *&simpleData, int &simpleLen, char *&rawData, int &rawLen, int &bytesRead)
#define QT_END_NAMESPACE
This macro expands to.
char * data()
Returns a pointer to the data stored in the byte array.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
static QWSCommand * factory(int type)
virtual void setData(const char *data, int len, bool allocateMem=true)
QDebug & nospace()
Clears the stream's internal flag that records whether the last character was a space and returns a r...
#define at(className, varName)
The QByteArray class provides an array of bytes.
void copyFrom(const QWSProtocolItem *item)
virtual ~QWSProtocolItem()
int qws_read_uint(QIODevice *socket)
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Q_CORE_EXPORT QTextStream & hex(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Q_CORE_EXPORT void qDebug(const char *,...)
static QString toString(Register *reg, int type, bool *ok=0)
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void qws_write_command(QIODevice *socket, int type, char *simpleData, int simpleLen, char *rawData, int rawLen)
The QWSServer class encapsulates a server process in Qt for Embedded Linux.
The QTextStream class provides a convenient interface for reading and writing text.
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
int size() const
Returns the number of bytes in this byte array.
const char * qws_getCommandTypeString(QWSCommand::Type tp)
QDataStream & operator<<(QDataStream &s, const QAxBase &c)
Authenticate a message transport.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
void qws_write_uint(QIODevice *socket, int i)
The QIODevice class is the base interface class of all I/O devices in Qt.
QIODevice * passThroughByClient(QWSClient *) const
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QWSServer Q_GUI_EXPORT * qwsServer
static QTransportAuth * getInstance()
Return a pointer to the instance of this process's QTransportAuth object.
Q_CORE_EXPORT QTextStream & endl(QTextStream &s)