Classified ads
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ProtocolMessageParser Class Reference

Class containing routines for parsing protocol messages. Methods are mainly called from network connection instances and this class will forward the parsed protocol entities to datamodel. More...

#include <protocol_message_parser.h>

Inheritance diagram for ProtocolMessageParser:
Inheritance graph
[legend]
Collaboration diagram for ProtocolMessageParser:
Collaboration graph
[legend]

Public Member Functions

 ProtocolMessageParser (MController &aController, MModelProtocolInterface &aModel)
 
bool parseMessage (const QByteArray &aGoodFood, Connection &aConnection)
 

Private Member Functions

bool parseNodeGreetingV1 (const QByteArray &aSingleNodeGreeting, const Connection &aConnection)
 
bool parseMultipleNodeGreetingsV1 (const QByteArray &aGoodFood, const Connection &aConnection)
 
bool uintFromPosition (const QByteArray &aGoodFood, const int aPos, quint32 *aResult) const
 
bool hashFromPosition (const QByteArray &aGoodFood, const int aPos, Hash *aResultHash) const
 
bool parseRequestForObjectsAroundHash (const QByteArray &aNodeRefRequest, const Connection &aConnection)
 
bool parseContentPublishedOrSent (const unsigned char aProtocolItemType, const QByteArray &aPublishedContent, const Connection &aConnection)
 
bool parsePrivMsgPublishedOrSent (const unsigned char aProtocolItemType, const QByteArray &aPublishedContent, const Connection &aConnection)
 
bool parseProfileCommentPublishedOrSent (const unsigned char aProtocolItemType, const QByteArray &aPublishedContent, const Connection &aConnection)
 
bool parseAdsClassifiedAtHash (const QByteArray &aQueryBytes, const Connection &aConnection)
 
bool parseListOfAdsClassifiedAtHash (const QByteArray &aQueryBytes, const Connection &aConnection)
 
bool parseSearchRequest (const QByteArray &aQueryBytes, Connection &aConnection)
 
bool parseSearchResults (const QByteArray &aQueryBytes, const Connection &aConnection)
 
bool parseVoiceCall (const QByteArray &aQueryBytes, const Connection &aConnection)
 
bool parseCallRtData (const QByteArray &aQueryBytes, const Connection &aConnection)
 

Private Attributes

MControlleriController
 
MModelProtocolInterfaceiModel
 

Detailed Description

Class containing routines for parsing protocol messages. Methods are mainly called from network connection instances and this class will forward the parsed protocol entities to datamodel.

Constructor & Destructor Documentation

ProtocolMessageParser::ProtocolMessageParser ( MController aController,
MModelProtocolInterface aModel 
)

Member Function Documentation

bool ProtocolMessageParser::hashFromPosition ( const QByteArray &  aGoodFood,
const int  aPos,
Hash aResultHash 
) const
private

utility method: extract hash from bytearray.

Parameters
aGoodFoodis the bytearray from which to extract
aPosis the position where integer is expected to be found
aResultHashis the hash that will have its value set from contents of aGoodFood
Returns
true if success
bool ProtocolMessageParser::parseAdsClassifiedAtHash ( const QByteArray &  aQueryBytes,
const Connection aConnection 
)
private

method for parsing request that requests for classified ads whose classification matches given hash

Parameters
aQueryBytescontains the query
aConnectionis the requester
bool ProtocolMessageParser::parseCallRtData ( const QByteArray &  aQueryBytes,
const Connection aConnection 
)
private

Method for parsing voice call data. This parses actual data stream like audio, not call control data.

Parameters
aQueryBytesserialized call data
aConnectionis connection of the node whose operator made a statement.
Returns
true if things went all right.
bool ProtocolMessageParser::parseContentPublishedOrSent ( const unsigned char  aProtocolItemType,
const QByteArray &  aPublishedContent,
const Connection aConnection 
)
private

Method for parsing published content. Content-type is given as parameter ; single method as the structure is anyway same, handling is different..

This method is also used to parse content sent ; it differs from published content so, that it has no bangpath but otherwise the format is the same.

bool ProtocolMessageParser::parseListOfAdsClassifiedAtHash ( const QByteArray &  aQueryBytes,
const Connection aConnection 
)
private

Method for parsing list of headers of classified ads. In practice this parses the protocol message sent with id KListOfAdsClassifiedAtHash.

bool ProtocolMessageParser::parseMessage ( const QByteArray &  aGoodFood,
Connection aConnection 
)

the open mouth

Parameters
aGoodFoodis the message
Returns
false if such a fatal error that peer needs to be disconnected
bool ProtocolMessageParser::parseMultipleNodeGreetingsV1 ( const QByteArray &  aGoodFood,
const Connection aConnection 
)
private

Peer number of hello messages

Parameters
aGoodFoodat least one node greeting
aConnectionthe orignating connection
bool ProtocolMessageParser::parseNodeGreetingV1 ( const QByteArray &  aSingleNodeGreeting,
const Connection aConnection 
)
private

Peer hello message

bool ProtocolMessageParser::parsePrivMsgPublishedOrSent ( const unsigned char  aProtocolItemType,
const QByteArray &  aPublishedContent,
const Connection aConnection 
)
private

Method for parsing published private message. Does about same work as parseContentPublishedOrSent but structure of private messages is somewhat different.

bool ProtocolMessageParser::parseProfileCommentPublishedOrSent ( const unsigned char  aProtocolItemType,
const QByteArray &  aPublishedContent,
const Connection aConnection 
)
private

Method for parsing published profile comments. Does about same work as parseContentPublishedOrSent but structure of profile commentss is somewhat different.

bool ProtocolMessageParser::parseRequestForObjectsAroundHash ( const QByteArray &  aNodeRefRequest,
const Connection aConnection 
)
private

Method for parsing request to send one or more objects specified by a hash.

bool ProtocolMessageParser::parseSearchRequest ( const QByteArray &  aQueryBytes,
Connection aConnection 
)
private

Method for parsing a search request from remote node. If parse is successful, this method will also ask searchmodel to perform the search and place possible results immediately into send-queue of aConnection so search works slightly differently compared to rest of the network requests

Parameters
aQueryBytesserialized query-description
aConnectionis connection of the node who sent the request
Returns
true if things went all right.
bool ProtocolMessageParser::parseSearchResults ( const QByteArray &  aQueryBytes,
const Connection aConnection 
)
private

Method for parsing a search result from remote node. In this case this node made a search request and this is reply (containing list of objects matching the query).

Parameters
aQueryBytesserialized query-description
aConnectionis connection of the node who sent the request
Returns
true if things went all right.
bool ProtocolMessageParser::parseVoiceCall ( const QByteArray &  aQueryBytes,
const Connection aConnection 
)
private

Method for parsing voice call status data. This parses call status, not call realtime (audio) data.

Parameters
aQueryBytesserialized call-status data
aConnectionis connection of the node who sent the request
Returns
true if things went all right.
bool ProtocolMessageParser::uintFromPosition ( const QByteArray &  aGoodFood,
const int  aPos,
quint32 *  aResult 
) const
private

utility method: extract integer from bytearray. integer will be returned in host byte order e.g.

Parameters
aGoodFoodis the bytearray from which to extract
aPosis the position where integer is expected to be found
aResultis the quint32 where result will be written e.g. this is the output variable
Returns
true if reading succeeded

Member Data Documentation

MController& ProtocolMessageParser::iController
private
MModelProtocolInterface& ProtocolMessageParser::iModel
private

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