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

This is is part of datamodel for storing comments of user profiles. More...

#include <profilecommentmodel.h>

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

Signals

void error (MController::CAErrorSituation aError, const QString &aExplanation)
 
void contentReceived (const Hash &aHashOfContent, const Hash &aHashOfProfileCommented, const ProtocolItemType aTypeOfReceivdContent)
 
- Signals inherited from ModelBase
void error (MController::CAErrorSituation aError, const QString &aExplanation)
 

Public Member Functions

 ProfileCommentModel (MController *aMController, const MModelProtocolInterface &aModel)
 
 ~ProfileCommentModel ()
 
bool publishProfileComment (ProfileComment &aProfileComment)
 
ProfileCommentprofileCommentByFingerPrint (const Hash &aFingerPrint, bool aEmitOnEncryptionError=true)
 
bool commentDataByFingerPrint (const Hash &aFingerPrint, QByteArray &aResultingProfileCommentData, QByteArray &aResultingSignature, Hash *aResultingProfileFingerPrint, quint32 *aFlags, quint32 *aTimeOfPublish=NULL)
 
bool publishedProfileCommentReceived (const Hash &aFingerPrint, const Hash &aCommentedProfileFP, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode)
 
bool sentProfileCommentReceived (const Hash &aFingerPrint, const Hash &aCommentedProfileFP, const QByteArray &aContent, const QByteArray &aSignature, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &fromNode)
 
void fillBucket (QList< SendQueueItem > &aSendQueue, const Hash &aStartOfBucket, const Hash &aEndOfBucket, quint32 aLastMutualConnectTime, const Hash &aForNode)
 
QList< HashcommentsForProfile (const Hash &aProfileHash, const quint32 aSinceTimeStamp)
 
void reIndexAllCommentsIntoFTS ()
 
- Public Member Functions inherited from ModelBase
 ModelBase (QString aDataTableName, unsigned aMaxRowsToKeep)
 
 ~ModelBase ()
 
bool setTimeLastReference (const Hash &aObjectFingerPrint, quint32 aTimeWhenLastReferenced)
 
unsigned getMaxRowsToKeep ()
 
void setMaxRowsToKeep (unsigned aRows)
 
void truncateDataTableToMaxRows (void)
 
void updateDbTableRowCount ()
 

Private Member Functions

bool doHandlepublishedOrSentProfileComment (const Hash &aFingerPrint, const Hash &aCommentedProfileFP, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const unsigned char aFlags, const quint32 aTimeStamp, bool aWasPublish, const Hash &aFromNode)
 

Private Attributes

MControlleriController
 
const MModelProtocolInterfaceiModel
 

Additional Inherited Members

- Protected Attributes inherited from ModelBase
QString iDataTableName
 
unsigned iMaxRowsToKeep
 
unsigned iCurrentDbTableRowCount
 

Detailed Description

This is is part of datamodel for storing comments of user profiles.

This behaves largerly in same manner as profilemodel, data-carrier is different

Constructor & Destructor Documentation

◆ ProfileCommentModel()

ProfileCommentModel::ProfileCommentModel ( MController aMController,
const MModelProtocolInterface aModel 
)

◆ ~ProfileCommentModel()

ProfileCommentModel::~ProfileCommentModel ( )

Member Function Documentation

◆ commentDataByFingerPrint()

bool ProfileCommentModel::commentDataByFingerPrint ( const Hash aFingerPrint,
QByteArray &  aResultingProfileCommentData,
QByteArray &  aResultingSignature,
Hash aResultingProfileFingerPrint,
quint32 *  aFlags,
quint32 *  aTimeOfPublish = NULL 
)

Gets a comment. Because profile comment is signed .. and that means that a particular byte-stream (containing actually a serialized json object) gets signed those bytes can't be altered or signature will not verify. This methods gets the actual signed bytestream that has been checked against a public key.

Note that this method does not check the signature any more, idea is that we don't store into db profiles that fail the signature check so this method only gets the profile, does not set it.

Parameters
aFingerPrintprofile comment serial number
aResultingProfileCommentDatawill contain comment data
aResultingSignaturewill contain comment signature
aResultingProfileFingerPrintis output variable, that will have its value set to containt fingerprint of the profile that the comment is commenting.
aFlagswill be set to flags values ; bit 1 on means that content is encrypted.
aTimeOfPublishis also output variable, if non-NULL, will get its value set to time of publish of the comment
Returns
true if profile was found

◆ commentsForProfile()

QList<Hash> ProfileCommentModel::commentsForProfile ( const Hash aProfileHash,
const quint32  aSinceTimeStamp 
)

method for producing list of profile comments that comment aProfileHash and that are more recent than aSinceTimeStamp

◆ contentReceived

void ProfileCommentModel::contentReceived ( const Hash aHashOfContent,
const Hash aHashOfProfileCommented,
const ProtocolItemType  aTypeOfReceivdContent 
)
signal

emitted when new comment is received

◆ doHandlepublishedOrSentProfileComment()

bool ProfileCommentModel::doHandlepublishedOrSentProfileComment ( const Hash aFingerPrint,
const Hash aCommentedProfileFP,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const unsigned char  aFlags,
const quint32  aTimeStamp,
bool  aWasPublish,
const Hash aFromNode 
)
private

Workhorse of methods publishedProfileCommentReceived and sentProfileCommentReceived

Returns
true on success

◆ error

void ProfileCommentModel::error ( MController::CAErrorSituation  aError,
const QString &  aExplanation 
)
signal

◆ fillBucket()

void ProfileCommentModel::fillBucket ( QList< SendQueueItem > &  aSendQueue,
const Hash aStartOfBucket,
const Hash aEndOfBucket,
quint32  aLastMutualConnectTime,
const Hash aForNode 
)

Method for filling connected peers send queue with items that we have and that belong to said peers bucket.

Parameters
aSendQueueis send-queue of the connection that serves particular node
aStartOfBucketis hash where bucket of that peer starts. In practice it is the hash of the node itself.
aEndOfBucketis hash where bucket of that peer ends. That in turn depends on network size, or number of active nodes in the network. See method NodeModel::bucketEndHash for details.
aLastMutualConnectTimetime when node was last in contact. In practice we'll fill the bucket items published after this time.

◆ profileCommentByFingerPrint()

ProfileComment* ProfileCommentModel::profileCommentByFingerPrint ( const Hash aFingerPrint,
bool  aEmitOnEncryptionError = true 
)

gets a comment or null. whoever calls this method is obliged to delete the returned comments.

Parameters
aFingerPrintprofile serial number
aEmitOnEncryptionErrorif set to false, will return NULL when no suitable encryption key is found and will not emit error message that would be catched by UI and shown to user
Returns
profile or NULL

◆ publishedProfileCommentReceived()

bool ProfileCommentModel::publishedProfileCommentReceived ( const Hash aFingerPrint,
const Hash aCommentedProfileFP,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const unsigned char  aFlags,
const quint32  aTimeStamp,
const Hash aFromNode 
)

called by protocol parser when a profile comment is received. note the absence of signing key. if the profile commented is public, the key is found inside the comment. if the profile commented is private, the comment behaves like a private message, the recipient needs to first open the encryption before she can verify that the comment is from certain operator

Parameters
aFingerPrintis the content Hash received from protocol header
aCommentedProfileFPis fingerprint hash of the profile that the comment concerns
aContentis actual profile data
aSignatureis digital signature of the aContent
aBangPathis list of last nodes where this content has been, idea is to prevent re-sending content to somewhere where it has already been
aFlagpossible flags telling about encyption and compression
aTimeStamptimestamp of profile (if encrypted, it must be carried outside..)
Returns
true on success

◆ publishProfileComment()

bool ProfileCommentModel::publishProfileComment ( ProfileComment aProfileComment)

sends profile comment to selected nodes in network for others to retrieve. As a side-effect will set iFingerPrint of the comment.

Parameters
aProfileCommentis the profile to publish
Returns
true if things went all right

◆ reIndexAllCommentsIntoFTS()

void ProfileCommentModel::reIndexAllCommentsIntoFTS ( )

◆ sentProfileCommentReceived()

bool ProfileCommentModel::sentProfileCommentReceived ( const Hash aFingerPrint,
const Hash aCommentedProfileFP,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const unsigned char  aFlags,
const quint32  aTimeStamp,
const Hash fromNode 
)

called by protocol parser when a comment is received by "send" protocol type

Parameters
aFingerPrintis the profile Hash received from protocol header
aCommentedProfileFPis fingerprint hash of the profile that the comment concerns
aContentis actual comment data
aSignatureis digital signature of the aContent
aProfileCommentPublicKeyis the key that was used to sign the profile. that is transferred outside profile just because the recipient might not have the key beforehand ; if she does, the existing key will be used in verifying process.
aFlagpossible flags telling about encyption and compression
aTimeStamptimestamp of profile (if encrypted, it must be carried outside..)
Returns
true on success

Member Data Documentation

◆ iController

MController* ProfileCommentModel::iController
private

◆ iModel

const MModelProtocolInterface& ProfileCommentModel::iModel
private

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