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 dbRecordPublish (const CaDbRecord &aRecord, const QList< quint32 > &aBangPath)
 
static QByteArray dbRecordSend (const CaDbRecord &aRecord)
 
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 QByteArray dbSearchTerms (const CaDbRecord::SearchTerms aSearchTerms)
 
static QByteArray voiceCall (const VoiceCall &aCall, MController &aController, const Hash &aSelectedProfile, bool aDoSign=true)
 
static QByteArray voiceCallRtData (quint32 aCallId, quint32 aSeqNo, VoiceCallEngine::PayloadType aPayloadType, const QByteArray &aPayload)
 

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)
 
static QByteArray doDbRecordPublishOrSend (const CaDbRecord &aRecord, const QList< quint32 > &aBangPath, 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

◆ contentPublish()

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.

◆ contentSend()

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.

◆ dbRecordPublish()

static QByteArray ProtocolMessageFormatter::dbRecordPublish ( const CaDbRecord aRecord,
const QList< quint32 > &  aBangPath 
)
static

Method that constructs byte-stream from db record for publish purpose.

Parameters
aRecordis the record
aBangPathshort list of nodes where the record came to us, will be included in byte-stream

◆ dbRecordSend()

static QByteArray ProtocolMessageFormatter::dbRecordSend ( const CaDbRecord aRecord)
static

Method that constructs byte-stream from db record for send purpose.

Parameters
aRecordis the record

◆ dbSearchTerms()

static QByteArray ProtocolMessageFormatter::dbSearchTerms ( const CaDbRecord::SearchTerms  aSearchTerms)
static

method for serializing a database search so that it can be sent to other nodes

◆ doCommentSendOrPublish()

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

◆ doContentSendOrPublish()

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

◆ doDbRecordPublishOrSend()

static QByteArray ProtocolMessageFormatter::doDbRecordPublishOrSend ( const CaDbRecord aRecord,
const QList< quint32 > &  aBangPath,
bool  aIsPublish 
)
staticprivate

Workhorse-method that constructs byte-stream based on db record publish- or send-operation.

Parameters
aRecordis the record
aBangPathshort list of nodes where the record came to us, will be included in byte-stream
aIsPublishis set to false if record is merely sent. If false, aBangPath is ignored and may be empty.

◆ nodeGreeting()

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.

◆ privMsgPublish()

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

◆ privMsgSend()

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

◆ profileCommentPublish()

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.

◆ profileCommentSend()

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.

◆ randomNumbers()

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.

◆ replyToAdsClassified()

static QByteArray ProtocolMessageFormatter::replyToAdsClassified ( const Hash aClassificationHash,
const QList< QPair< Hash, quint32 > > &  aListOfAds 
)
static

◆ requestForAdsClassified()

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.

◆ requestForBinaryBlob()

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.

◆ requestForClassifiedAd()

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.

◆ requestForNodesAroundHash()

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.

◆ requestForPrivateMessages()

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.

◆ requestForPrivateMessagesForProfile()

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.

◆ requestForProfileComments()

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.

◆ requestForUserProfile()

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.

◆ requestForUserProfileComment()

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.

◆ searchResultsSend()

static QByteArray ProtocolMessageFormatter::searchResultsSend ( const QList< SearchModel::SearchResultItem > &  aResults,
quint32  aSearchId 
)
static

method for formatting network search results

◆ searchSend()

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

method for formatting a network search query

◆ voiceCall()

static QByteArray ProtocolMessageFormatter::voiceCall ( const VoiceCall aCall,
MController aController,
const Hash aSelectedProfile,
bool  aDoSign = true 
)
static

Method for formatting voice call status object

Parameters
aCallis the call status object
aControlleris application controller instance
aSelectedProfileis hash of the profile who will sign the serialized object
aDoSignif set to true, normal signature will be added. If false, zero-len signature will be used.
Returns
serialized bytes of call status

◆ voiceCallRtData()

static QByteArray ProtocolMessageFormatter::voiceCallRtData ( quint32  aCallId,
quint32  aSeqNo,
VoiceCallEngine::PayloadType  aPayloadType,
const QByteArray &  aPayload 
)
static

Method for formatting voice call real-time data like audio

Parameters
aCallIdcall (stream) identifier
aSeqNosequence number of payload in stream
aPayloadTypetype payload
aPayloadactual payload bytes to send, like call audio
Returns
serialized bytes of call status

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