Classified ads
|
This is is part of datamodel for storing comments of user profiles. More...
#include <profilecommentmodel.h>
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) |
ProfileComment * | profileCommentByFingerPrint (const Hash &aFingerPrint) |
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< Hash > | commentsForProfile (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 | |
MController * | iController |
const MModelProtocolInterface & | iModel |
Additional Inherited Members | |
Protected Attributes inherited from ModelBase | |
QString | iDataTableName |
unsigned | iMaxRowsToKeep |
unsigned | iCurrentDbTableRowCount |
This is is part of datamodel for storing comments of user profiles.
This behaves largerly in same manner as profilemodel, data-carrier is different
ProfileCommentModel::ProfileCommentModel | ( | MController * | aMController, |
const MModelProtocolInterface & | aModel | ||
) |
ProfileCommentModel::~ProfileCommentModel | ( | ) |
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.
aFingerPrint | profile comment serial number |
aResultingProfileCommentData | will contain comment data |
aResultingSignature | will contain comment signature |
aResultingProfileFingerPrint | is output variable, that will have its value set to containt fingerprint of the profile that the comment is commenting. |
aFlags | will be set to flags values ; bit 1 on means that content is encrypted. |
aTimeOfPublish | is also output variable, if non-NULL, will get its value set to time of publish of the comment |
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
|
signal |
emitted when new comment is received
|
private |
Workhorse of methods publishedProfileCommentReceived and sentProfileCommentReceived
|
signal |
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.
aSendQueue | is send-queue of the connection that serves particular node |
aStartOfBucket | is hash where bucket of that peer starts. In practice it is the hash of the node itself. |
aEndOfBucket | is 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. |
aLastMutualConnectTime | time when node was last in contact. In practice we'll fill the bucket items published after this time. |
ProfileComment* ProfileCommentModel::profileCommentByFingerPrint | ( | const Hash & | aFingerPrint | ) |
gets a comment or null. whoever calls this method is obliged to delete the returned comments.
aFingerPrint | profile serial number |
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 absense 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
aFingerPrint | is the content Hash received from protocol header |
aCommentedProfileFP | is fingerprint hash of the profile that the comment concerns |
aContent | is actual profile data |
aSignature | is digital signature of the aContent |
aBangPath | is list of last nodes where this content has been, idea is to prevent re-sending content to somewhere where it has already been |
aFlag | possible flags telling about encyption and compression |
aTimeStamp | timestamp of profile (if encrypted, it must be carried outside..) |
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.
aProfileComment | is the profile to publish |
void ProfileCommentModel::reIndexAllCommentsIntoFTS | ( | ) |
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
aFingerPrint | is the profile Hash received from protocol header |
aCommentedProfileFP | is fingerprint hash of the profile that the comment concerns |
aContent | is actual comment data |
aSignature | is digital signature of the aContent |
aProfileCommentPublicKey | is 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. |
aFlag | possible flags telling about encyption and compression |
aTimeStamp | timestamp of profile (if encrypted, it must be carried outside..) |
|
private |
|
private |