Gnutella::Packets::Query Class Reference

#include <Query.h> [code]

Inherits Gnutella::Packets::Packet.

Inheritance diagram for Gnutella::Packets::Query:

Inheritance graph
[legend]
Collaboration diagram for Gnutella::Packets::Query:

Collaboration graph
[legend]
List of all members.

Detailed Description

Encapsulates the Query Gnutella packet.

The table below presents the data fields stored in a query's payload and how they can be accessed using the Query interface. For a detailed documentation of all basic Gnutella packets and the usage of all their fileds please refer to The Annotated Gnutella Protocol Specification v0.4.

Byte Offset Field Name getFunction setFunction
0..1 Minimum Speed N/A N/A
2..N Search Criteria String N/A N/A
N+1 NUL (0x00) Terminator N/A N/A
N+2..L-1 Optional Query Data N/A N/A

Todo:
Implement the query data extension.

Definition at line 53 of file Query.h.

Public Member Functions

 Query (const QByteArray &rawHeader, const QByteArray &rawPayload)
 Query (const QString &searchCriteria=QString(), quint16 minimumSpeed=0)
 ~Query ()
Querycopy () const
 A virtual copy contructor.
QString name () const
quint16 minimumSpeed () const
QString searchCriteria () const
void setMinimumSpeed (const quint16 &minimumSpeed)
void setSearchCriteria (const QString &searchCriteria)

Static Public Member Functions

static QuerycastFrom (Packet &packet)
static const QuerycastFrom (const Packet &packet)

Protected Member Functions

bool prepareReadPayload (const QByteArray &rawPayload)
 Verifies the structure of the rawPayload.
void readPayload (QDataStream &stream)
 Reads the payload fields from the stream. The structure of the data in the stream is already verified by verifyPayload().
int prepareWritePayload () const
 Gets ready to write the payload and returns the payload length.
void writePayload (QDataStream &stream) const
 Writes the payload fields into the stream.

Private Types

typedef Extensions::ExtensionBlock QueryData

Private Attributes

Gnutella::Packets::Query::Data p

Classes

struct  Data


Member Typedef Documentation

typedef Extensions::ExtensionBlock Gnutella::Packets::Query::QueryData [private]
 

Definition at line 83 of file Query.h.


Constructor & Destructor Documentation

Query::Query const QByteArray &  rawHeader,
const QByteArray &  rawPayload
 

Creates a Query object from the raw bytes in rawHeader and rawPayload.

Definition at line 38 of file Query.cpp.

Query::Query const QString &  searchCriteria = QString(),
quint16  minimumSpeed = 0
 

Definition at line 44 of file Query.cpp.

Query::~Query  ) 
 

Definition at line 52 of file Query.cpp.


Member Function Documentation

static const Query& Gnutella::Packets::Query::castFrom const Packet packet  )  [inline, static]
 

Definition at line 57 of file Query.h.

static Query& Gnutella::Packets::Query::castFrom Packet packet  )  [inline, static]
 

Definition at line 56 of file Query.h.

Query* Gnutella::Packets::Query::copy  )  const [inline, virtual]
 

A virtual copy contructor.

Implements Gnutella::Packets::Packet.

Definition at line 63 of file Query.h.

quint16 Query::minimumSpeed  )  const
 

Definition at line 115 of file Query.cpp.

QString Gnutella::Packets::Query::name  )  const [inline, virtual]
 

Todo:
remove this?

Implements Gnutella::Packets::Packet.

Definition at line 65 of file Query.h.

bool Query::prepareReadPayload const QByteArray &  rawPayload  )  [protected, virtual]
 

Verifies the structure of the rawPayload.

Verifies if the rawPayload can be correctly parsed by readPayload(). The function just goes over the whole rawPayload and checks if the structure of the payload is correct. Some data may be gathered and stored to ease the work of readPayload(). For example, the size of the query hit data field can only be calculated with knowledge of the payloadLength, which is not available in the QDataStream object passed to readPayload(). The size of this field is read here and stored for use later in readPayload().

Implements Gnutella::Packets::Packet.

Definition at line 56 of file Query.cpp.

int Query::prepareWritePayload  )  const [protected, virtual]
 

Gets ready to write the payload and returns the payload length.

Implements Gnutella::Packets::Packet.

Definition at line 95 of file Query.cpp.

void Query::readPayload QDataStream &  stream  )  [protected, virtual]
 

Reads the payload fields from the stream. The structure of the data in the stream is already verified by verifyPayload().

Implements Gnutella::Packets::Packet.

Definition at line 82 of file Query.cpp.

QString Query::searchCriteria  )  const
 

Definition at line 120 of file Query.cpp.

void Query::setMinimumSpeed const quint16 &  minimumSpeed  ) 
 

Definition at line 130 of file Query.cpp.

void Query::setSearchCriteria const QString &  searchCriteria  ) 
 

Definition at line 136 of file Query.cpp.

void Query::writePayload QDataStream &  stream  )  const [protected, virtual]
 

Writes the payload fields into the stream.

Implements Gnutella::Packets::Packet.

Definition at line 102 of file Query.cpp.


Member Data Documentation

struct Gnutella::Packets::Query::Data Gnutella::Packets::Query::p [private]
 


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