#include <QueryHits.h> [code]
Inherits Gnutella::Packets::Packet.
Inheritance diagram for Gnutella::Packets::QueryHits:


The table below presents the data fields stored in a query hits' payload and how they can be accessed using the QueryHits 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 | # of Hits | N/A | N/A |
| 1..2 | Port | N/A | N/A |
| 3..6 | IP Address | N/A | N/A |
| 7..10 | Speed | N/A | N/A |
| 11..10+N | Result Set | N/A | N/A |
| 11+N..L-17 | Optional QueryHits Data | N/A | N/A |
| L-16..L-1 | Servent ID | N/A | N/A |
The speed field may contain a number of flags as described in the table below. If bit 15 is set to 1, then the flags are set as by the specification. If it is not set, then the field contains just the maximum upload speed.
| Bit | Flag Name | getFunction | setFunction |
| 15 | Enable flags | N/A | N/A |
| 14 | Firewalled Indicator | N/A | N/A |
| 13 | XML Metadata | N/A | N/A |
| 12 | Leaf-Guided Dynamic Query | N/A | N/A |
| 11 | GGEP "H" Allowed | N/A | N/A |
| 10 | Out of Band Query | N/A | N/A |
Use the function xxx() to access the results from the result set. Each result entry has the structure below:
| Byte Offset | Field Name | getFunction | setFunction |
| 0..3 | File Index | N/A | N/A |
| 4..7 | File Size | N/A | N/A |
| 8..7+K | Shared File Name | N/A | N/A |
| 8+K | NUL (0x00) Terminator | N/A | N/A |
| 9+K..R-2 | Optional Result Data | N/A | N/A |
| R-1 | NUL (0x00) Terminator | N/A | N/A |
The optional QueryHits data field has the following structure:
| Byte Offset | Field Name | getFunction | setFunction |
| 0..3 | Vendor Code | N/A | N/A |
| 4 | Open area size | N/A | N/A |
| 5 | "Knows" flags byte | N/A | N/A |
| 6 | "Sets" flags byte | N/A | N/A |
| 7..8 | XML size + 1 | N/A | N/A |
| 9 | Private Vendor Flag | N/A | N/A |
| 10..P-1 | GGEP block | N/A | N/A |
| P..K-1 | XML data + NULL | N/A | N/A |
If the open area size is exactly equal to two, then only the two flag bytes are there. The XML size field should not be read out. The GGEP block will be there only if the corresponding bits in the flags bytes are set.
The tables below describe the meaning of each bit in the two flag bytes. The first byte marks which flags are recognized, whereas the second marks whether the corresponding flag is set or not. The Push flag is an exception to this rule - secong byte's bit determines whether the first byte's bit is meaningful.
| Bit | Flag Name | getFunction | setFunction |
| 7 | Reserved | N/A | N/A |
| 6 | Reserved | N/A | N/A |
| 5 | GGEP Block in QueryHits Data | N/A | N/A |
| 4 | Speed is Average Upload Speed | N/A | N/A |
| 3 | Have Uploaded | N/A | N/A |
| 2 | Busy | N/A | N/A |
| 1 | Reserved | N/A | N/A |
| 0 | Push | N/A | N/A |
Implement the query hits data extension.
Substitute Result::fileName with QFileInfo. It provides functions to get the extension, path, etc.
Add setter functions.
Forbid changing the result entries. Payload would need to be invalidated.
Definition at line 126 of file QueryHits.h.
Public Types | |
| typedef Extensions::ExtensionBlock | ResultData |
Public Member Functions | |
| QueryHits (const QByteArray &rawHeader, const QByteArray &rawPayload) | |
| QueryHits () | |
| ~QueryHits () | |
| QueryHits * | copy () const |
| A virtual copy contructor. | |
| QString | name () const |
| uchar | numberOfHits () const |
| quint16 | port () const |
| QHostAddress | ipAddress () const |
| quint32 | speed () const |
| const Result & | result (int &index) const |
| const QUuid & | serventId () const |
| Gets the servent ID payload field. | |
| void | setPort (quint16 port) |
| void | setIpAddress (const QHostAddress &ipAddress) |
| void | setSpeed (quint32 speed) |
| void | setServentId (const QUuid &serventId) |
| void | appendResult (Result &result) |
Static Public Member Functions | |
| static QueryHits & | castFrom (Packet &packet) |
| static const QueryHits & | castFrom (const Packet &packet) |
Protected Member Functions | |
| bool | prepareReadPayload (const QByteArray &rawPayload) |
| Verifies the structure of the rawPayload. | |
| bool | prepareReadQueryHitsData (const QByteArray &rawQueryHitsData) |
| void | readPayload (QDataStream &stream) |
| Reads the payload fields from the stream. The structure of the data in the stream is already verified by verifyPayload(). | |
| void | readQueryHitsData (QDataStream &stream) |
| int | prepareWritePayload () const |
| Gets ready to write the payload and returns the payload length. | |
| int | prepareWriteQueryHitsData () const |
| void | writePayload (QDataStream &stream) const |
| Writes the payload fields into the stream. | |
| void | writeQueryHitsData (QDataStream &stream) const |
Private Types | |
| typedef QList< Result > | ResultSet |
Private Attributes | |
| Gnutella::Packets::QueryHits::Data | p |
Classes | |
| struct | Data |
| struct | QueryHitsData |
| struct | Result |
|
|
Definition at line 129 of file QueryHits.h. |
|
|
Definition at line 202 of file QueryHits.h. |
|
||||||||||||
|
Creates a QueryHits object from the raw bytes in rawHeader and rawPayload. Definition at line 42 of file QueryHits.cpp. |
|
|
Definition at line 48 of file QueryHits.cpp. |
|
|
Definition at line 57 of file QueryHits.cpp. |
|
|
Definition at line 379 of file QueryHits.cpp. |
|
|
Definition at line 149 of file QueryHits.h. |
|
|
Definition at line 148 of file QueryHits.h. |
|
|
A virtual copy contructor.
Implements Gnutella::Packets::Packet. Definition at line 155 of file QueryHits.h. |
|
|
Definition at line 162 of file QueryHits.h. |
|
|
Implements Gnutella::Packets::Packet. Definition at line 157 of file QueryHits.h. |
|
|
Definition at line 160 of file QueryHits.h. |
|
|
Definition at line 161 of file QueryHits.h. |
|
|
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 72 of file QueryHits.cpp. |
|
|
Definition at line 181 of file QueryHits.cpp. |
|
|
Gets ready to write the payload and returns the payload length.
Implements Gnutella::Packets::Packet. Definition at line 139 of file QueryHits.cpp. |
|
|
Definition at line 255 of file QueryHits.cpp. |
|
|
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 110 of file QueryHits.cpp. |
|
|
Definition at line 224 of file QueryHits.cpp. |
|
|
Definition at line 316 of file QueryHits.cpp. |
|
|
Gets the servent ID payload field.
Definition at line 166 of file QueryHits.h. |
|
|
Definition at line 355 of file QueryHits.cpp. |
|
|
Definition at line 349 of file QueryHits.cpp. |
|
|
Definition at line 367 of file QueryHits.cpp. |
|
|
Definition at line 361 of file QueryHits.cpp. |
|
|
Definition at line 163 of file QueryHits.h. |
|
|
Writes the payload fields into the stream.
Implements Gnutella::Packets::Packet. Definition at line 159 of file QueryHits.cpp. |
|
|
Definition at line 286 of file QueryHits.cpp. |
|
|
|