Classified ads
Static Public Member Functions | Static Private Member Functions | List of all members
ProtocolMessageFormatter Class Reference

This class produces items sent to peers over network. More...

#include <protocol_message_formatter.h>

Static Public Member Functions

static QByteArray nodeGreeting (const Node &aNode)
 
static QByteArray randomNumbers (void)
 
static QByteArray requestForNodesAroundHash (const Hash &aHash)
 
static QByteArray requestForBinaryBlob (const Hash &aHash)
 
static QByteArray requestForUserProfile (const Hash &aHash)
 
static QByteArray requestForUserProfileComment (const Hash &aIndividualCommentHash)
 
static QByteArray requestForClassifiedAd (const Hash &aHash)
 
static QByteArray requestForPrivateMessages (const Hash &aMessageHash)
 
static QByteArray requestForPrivateMessagesForProfile (const Hash &aProfileHash, const quint32 aTimeOfOldestMsgToSend)
 
static QByteArray requestForProfileComments (const Hash &aCommentedProfileHash, const quint32 aTimeOfOldestMsgToSend)
 
static QByteArray requestForAdsClassified (const Hash &aHashOfClassification, const quint32 aStartingTimestamp, const quint32 aEndingTimestamp)
 
static QByteArray contentPublish (const unsigned char aContentMagicNumber, const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aSigningKey, bool aIsContentEncrypted, bool aIsContentCompressed, quint32 aTimeStamp)
 
static QByteArray privMsgPublish (const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aDestination, const Hash &aRecipient, quint32 aTimeStamp)
 
static QByteArray privMsgSend (const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const Hash &aDestination, const Hash &aRecipient, quint32 aTimeStamp)
 
static QByteArray profileCommentPublish (const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aProfileCommented, quint32 aTimeStamp, quint32 aFlags)
 
static QByteArray profileCommentSend (const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const Hash &aProfileCommented, quint32 aTimeStamp, quint32 aFlags)
 
static QByteArray contentSend (const unsigned char aContentMagicNumber, const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QByteArray &aSigningKey, bool aIsContentEncrypted, bool aIsContentCompressed, quint32 aTimeStamp)
 
static QByteArray replyToAdsClassified (const Hash &aClassificationHash, const QList< QPair< Hash, quint32 > > &aListOfAds)
 
static QByteArray searchSend (const QString &aSearch, bool aSearchAds, bool aSearchProfiles, bool aSearchComments, const Hash &aSearchIdentifier)
 
static QByteArray searchResultsSend (const QList< SearchModel::SearchResultItem > &aResults, quint32 aSearchId)
 

Static Private Member Functions

static QByteArray doContentSendOrPublish (QByteArray &retval, const unsigned char aContentMagicNumber, const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aSigningKey, bool aIsContentEncrypted, bool aIsContentCompressed, quint32 aTimeStamp, bool aIsPublish)
 
static QByteArray doCommentSendOrPublish (const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aProfileCommented, quint32 aTimeStamp, quint32 aFlags, bool aIsPublish)
 

Detailed Description

This class produces items sent to peers over network.

Class that contains (static) methods for producing byte-streams of various messages.

Member Function Documentation

static QByteArray ProtocolMessageFormatter::contentPublish ( const unsigned char  aContentMagicNumber,
const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const QByteArray &  aSigningKey,
bool  aIsContentEncrypted,
bool  aIsContentCompressed,
quint32  aTimeStamp 
)
static

method for producing byte-array containing (some) published content

Parameters
aContentMagicNumbertells what kind of item this is. For example KProfilePublish (from protocol.h) if we're publishing a profile here
aContentHashhash of the content to be published. Reason this Hash here is given explicitly is that different object types have different hashing methods - for binary blob it is the content itself that makes the hash but for profile it is the fingerprint of the signing key etc.
aContentactual content
aSignaturesignature verifying aContent
aBangPathlist of low-order bits of hosts where this content has already been seen, 5 at max
aSigningKeycontains public encryption key used to sign the content ; while it over time will be mostly overhead it anyway allows reader to reach the poster that is great advantage over some overhead..
aIsContentEncryptedis true of aContent is protected with encryption
aIsContentCompressedis true of aContent is inside qCompress. if both compress+encryption, naturally the content is first compressed, only after that encrypted
aTimeStampmay be given for content where actual timestamp is inside encryption
Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::contentSend ( const unsigned char  aContentMagicNumber,
const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QByteArray &  aSigningKey,
bool  aIsContentEncrypted,
bool  aIsContentCompressed,
quint32  aTimeStamp 
)
static

this is almost same as .contentPublish but is reply to another node regarding request of content, not users own publishing so this has no bangpath but otherwise this behaves in about same way.

static QByteArray ProtocolMessageFormatter::doCommentSendOrPublish ( const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const Hash aProfileCommented,
quint32  aTimeStamp,
quint32  aFlags,
bool  aIsPublish 
)
staticprivate

workhorse of .profileCommentPublish and .profileCommentSend has parameter telling which action to take

static QByteArray ProtocolMessageFormatter::doContentSendOrPublish ( QByteArray &  retval,
const unsigned char  aContentMagicNumber,
const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const QByteArray &  aSigningKey,
bool  aIsContentEncrypted,
bool  aIsContentCompressed,
quint32  aTimeStamp,
bool  aIsPublish 
)
staticprivate

workhorse of .contentPublish and .contentSend has parameter telling which action to take

static QByteArray ProtocolMessageFormatter::nodeGreeting ( const Node aNode)
static

method for producing node greeting message

Parameters
aNodeis greeting about the node concerned, usually "this" node
Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::privMsgPublish ( const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const Hash aDestination,
const Hash aRecipient,
quint32  aTimeStamp 
)
static

separate publish-formatter for private messages as they're quite different from rest of the content

static QByteArray ProtocolMessageFormatter::privMsgSend ( const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const Hash aDestination,
const Hash aRecipient,
quint32  aTimeStamp 
)
static

separate send-formatter for private messages as they're quite different from rest of the content. Similar to publish but no bangpath

static QByteArray ProtocolMessageFormatter::profileCommentPublish ( const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const Hash aProfileCommented,
quint32  aTimeStamp,
quint32  aFlags 
)
static

separate publish-formatter for profile comments as they're quite different from rest of the content. in case of comments for public profiles they behave a bit like classified ads but comments commenting private profiles need to behave more-or-less like private messages as that's what they are ; private messages with more than 1 recipient .. or it is possible to have private profile with 0 readers and then comment it self. monologue ensues.

static QByteArray ProtocolMessageFormatter::profileCommentSend ( const Hash aContentHash,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const Hash aProfileCommented,
quint32  aTimeStamp,
quint32  aFlags 
)
static

separate send-formatter for profile comment as they're quite different from rest of the content.

static QByteArray ProtocolMessageFormatter::randomNumbers ( void  )
static

method for producing random number message

Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::replyToAdsClassified ( const Hash aClassificationHash,
const QList< QPair< Hash, quint32 > > &  aListOfAds 
)
static
static QByteArray ProtocolMessageFormatter::requestForAdsClassified ( const Hash aHashOfClassification,
const quint32  aStartingTimestamp,
const quint32  aEndingTimestamp 
)
static

Classified ads have classification, the "intent-object-location" triplet shown in UI and it also has a hash. When user chooses this triplet, it might be nice to query surrounding nodes about classified ads regarding that triplet. This method is for sending such a request. Its response will contain hashes of the ads in that classification, possibly followed by the articles too.

Parameters
aHashOfClassificationhash calculated over "intent-object-location" string
aStartingTimestamppossible starting timestamp for the articles. Currently not implemented in protocol, sender will limit the number of ads it sends
aEndingTimestamppossible ending timestamp for the articles Currently not implemented in protocol, sender will limit the number of ads it sends
Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForBinaryBlob ( const Hash aHash)
static

method for producing binary blob request message

Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForClassifiedAd ( const Hash aHash)
static

method for producing operator classified ad request message

Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForNodesAroundHash ( const Hash aHash)
static

method for producing nodegreeting request message

Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForPrivateMessages ( const Hash aMessageHash)
static

method for sending request to other nodes regarding private messages having given hash

Parameters
aProfileHashhash of message that is to be found
Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForPrivateMessagesForProfile ( const Hash aProfileHash,
const quint32  aTimeOfOldestMsgToSend 
)
static

method for sending request to other nodes regarding private messages destined to given profile

Parameters
aProfileHashhash of profile whose messages are searched
aTimeOfOldesMsgToSendsince when to send msgs from
Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForProfileComments ( const Hash aCommentedProfileHash,
const quint32  aTimeOfOldestMsgToSend 
)
static

method for sending request to other nodes regarding comments about specified profile. in practice parser (upon receipt) will make calls that check not only for new comments, but also if there has been an update at the profile itself. Call to this method is result of RequestForProfilePoll being put into network request queue.

Parameters
aCommentedProfileHashhash of profile whose comments are searched
aTimeOfOldesMsgToSendsince when to send comments from
Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForUserProfile ( const Hash aHash)
static

method for producing operator profile request message

Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::requestForUserProfileComment ( const Hash aIndividualCommentHash)
static

method for producing message to other node that asks it to send an individual profile comment

Returns
bytearray that is ready to be sent over socket so that other end will understand.
static QByteArray ProtocolMessageFormatter::searchResultsSend ( const QList< SearchModel::SearchResultItem > &  aResults,
quint32  aSearchId 
)
static

method for formatting a network search results

static QByteArray ProtocolMessageFormatter::searchSend ( const QString &  aSearch,
bool  aSearchAds,
bool  aSearchProfiles,
bool  aSearchComments,
const Hash aSearchIdentifier 
)
static

method for formatting a network search query


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