Qt 4.8
Public Functions | Protected Functions | Protected Variables | List of all members
RequestAnalyzer Class Reference

#include <qtransportauth_qws.h>

Public Functions

qint64 bytesAnalyzed () const
 
QString operator() (QByteArray *data)
 
 RequestAnalyzer ()
 
bool requireMoreData () const
 
virtual ~RequestAnalyzer ()
 

Protected Functions

virtual QString analyze (QByteArray *)
 Analzye the data in themsgQueue according to some protocol and produce a request string for policy analysis. More...
 

Protected Variables

qint64 dataSize
 
bool moreData
 

Detailed Description

Definition at line 175 of file qtransportauth_qws.h.

Constructors and Destructors

◆ RequestAnalyzer()

RequestAnalyzer::RequestAnalyzer ( )

Definition at line 787 of file qtransportauth_qws.cpp.

788  : moreData( false )
789  , dataSize( 0 )
790 {
791 }

◆ ~RequestAnalyzer()

RequestAnalyzer::~RequestAnalyzer ( )
virtual

Definition at line 793 of file qtransportauth_qws.cpp.

794 {
795 }

Functions

◆ analyze()

QString RequestAnalyzer::analyze ( QByteArray msgQueue)
protectedvirtual

Analzye the data in themsgQueue according to some protocol and produce a request string for policy analysis.

If enough data is in the queue for analysis of a complete message, return a non-null string, and set a flag so requireMoreData() will return false; otherwise return a null string and requireMoreData() return true.

The amount of bytes analyzed is then available via bytesAnalyzed().

A null string is also returned in the case where the message was corrupt and could not be analyzed. In this case requireMoreData() returns false.

Note: this method will modify the msgQueue and pull off the data deemed to be corrupt, in the case of corrupt data.

In all other cases the msgQueue is left alone. The calling code should then pull off the analyzed data. Use bytesAnalzyed() to find how much data to pull off the queue.

Definition at line 819 of file qtransportauth_qws.cpp.

820 {
821 #ifdef Q_WS_QWS
822  dataSize = 0;
823  moreData = false;
824  QBuffer cmdBuf( msgQueue );
826  QWSCommand::Type command_type = (QWSCommand::Type)(qws_read_uint( &cmdBuf ));
827  QWSCommand *command = QWSCommand::factory(command_type);
828  // if NULL, factory will have already printed warning for bogus
829  // command_type just purge the bad stuff and attempt to recover
830  if ( command == NULL )
831  {
832  *msgQueue = msgQueue->mid( sizeof(int) );
833  return QString();
834  }
835  QString request = QLatin1String(qws_getCommandTypeString(command_type));
836 #ifndef QT_NO_COP
837  if ( !command->read( &cmdBuf ))
838  {
839  // not all command arrived yet - come back later
840  delete command;
841  moreData = true;
842  return QString();
843  }
844  if ( command_type == QWSCommand::QCopSend )
845  {
846  QWSQCopSendCommand *sendCommand = static_cast<QWSQCopSendCommand*>(command);
847  request += QString::fromLatin1("/QCop/%1/%2").arg( sendCommand->channel ).arg( sendCommand->message );
848  }
849  if ( command_type == QWSCommand::QCopRegisterChannel )
850  {
851  QWSQCopRegisterChannelCommand *registerCommand = static_cast<QWSQCopRegisterChannelCommand*>(command);
852  request += QString::fromLatin1("/QCop/RegisterChannel/%1").arg( registerCommand->channel );
853  }
854 #endif
855  dataSize = QWS_PROTOCOL_ITEM_SIZE( *command );
856  delete command;
857  return request;
858 #else
859  Q_UNUSED(msgQueue);
860  return QString();
861 #endif
862 }
static QWSCommand * factory(int type)
int qws_read_uint(QIODevice *socket)
Definition: qwsutils_qws.h:73
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool read(QIODevice *s)
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
#define QWS_PROTOCOL_ITEM_SIZE(item)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
const char * qws_getCommandTypeString(QWSCommand::Type tp)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ bytesAnalyzed()

qint64 RequestAnalyzer::bytesAnalyzed ( ) const
inline

Definition at line 182 of file qtransportauth_qws.h.

Referenced by QAuthDevice::authorizeMessage().

182 { return dataSize; }

◆ operator()()

QString RequestAnalyzer::operator() ( QByteArray data)
inline

Definition at line 180 of file qtransportauth_qws.h.

180 { return analyze( data ); }
virtual QString analyze(QByteArray *)
Analzye the data in themsgQueue according to some protocol and produce a request string for policy an...

◆ requireMoreData()

bool RequestAnalyzer::requireMoreData ( ) const
inline

Definition at line 181 of file qtransportauth_qws.h.

Referenced by QAuthDevice::authorizeMessage().

181 { return moreData; }

Properties

◆ dataSize

qint64 RequestAnalyzer::dataSize
protected

Definition at line 186 of file qtransportauth_qws.h.

Referenced by analyze().

◆ moreData

bool RequestAnalyzer::moreData
protected

Definition at line 185 of file qtransportauth_qws.h.

Referenced by analyze().


The documentation for this class was generated from the following files: