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

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

#include <profilemodel.h>

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

Signals

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

Public Member Functions

 ProfileModel (MController *aMController, const MModelProtocolInterface &aModel)
 
 ~ProfileModel ()
 
bool publishProfile (const Profile &aProfile)
 
ProfileprofileByFingerPrint (const Hash &aFingerPrint)
 
bool profileDataByFingerPrint (const Hash &aFingerPrint, QByteArray &aResultingProfileData, QByteArray &aResultingSignature, bool *aIsProfilePrivate, quint32 *aTimeOfPublish=NULL, QByteArray *aResultingPublicKey=NULL)
 
bool publishedProfileReceived (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aProfilePublicKey, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode)
 
bool sentProfileReceived (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QByteArray &aProfilePublicKey, 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)
 
Hash profileWithOldestTimeSinceMsgPoll (quint32 *aLastPollTime)
 
void setPrivateMessagePollTimeForProfile (const quint32 aTimeStamp, const Hash &aProfile)
 
void setPrivateDataForProfile (const Hash &aProfile, const QVariant &aPrivateData)
 
QVariant privateDataOfProfile (const Hash &aProfile)
 
time_t getLastProfileUpdateTime (const Hash &aProfile)
 
void setLastProfileUpdateTime (const Hash &aProfile, time_t aTime)
 
void reIndexAllProfilesIntoFTS ()
 
- 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 doHandlepublishedOrSentProfile (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aProfilePublicKey, const unsigned char aFlags, const quint32 aTimeStamp, bool aWasPublish, const Hash &aFromNode)
 
virtual bool deleteOldestDataRowInTable ()
 

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 user profiles.

Encryption keys related to profiles need to be done using ContentEncryptionModel but after it has done its job, this part of datamodel handles that actual profile-content

Constructor & Destructor Documentation

ProfileModel::ProfileModel ( MController aMController,
const MModelProtocolInterface aModel 
)
ProfileModel::~ProfileModel ( )

Member Function Documentation

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

emitted when new profile is received

virtual bool ProfileModel::deleteOldestDataRowInTable ( )
privatevirtual

Overridden from ModelBase

Reimplemented from ModelBase.

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

Workhorse of methods publishedProfileReceived and sentProfileReceived

Returns
true on success
void ProfileModel::error ( MController::CAErrorSituation  aError,
const QString &  aExplanation 
)
signal
void ProfileModel::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.
time_t ProfileModel::getLastProfileUpdateTime ( const Hash aProfile)

Gets time of last (successful) profile update+comment poll.

QVariant ProfileModel::privateDataOfProfile ( const Hash aProfile)

Getter-method for private data of a profile. This "Private data" is locally-stored settings-type of data specific to profile and it is not shared inside network.

Profile* ProfileModel::profileByFingerPrint ( const Hash aFingerPrint)

gets a profile. caller is supposed to delete the returned profile.

Parameters
aFingerPrintprofile serial number
Returns
profile or NULL
bool ProfileModel::profileDataByFingerPrint ( const Hash aFingerPrint,
QByteArray &  aResultingProfileData,
QByteArray &  aResultingSignature,
bool *  aIsProfilePrivate,
quint32 *  aTimeOfPublish = NULL,
QByteArray *  aResultingPublicKey = NULL 
)

Gets a profile. Because profile 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 serial number
aResultingProfileDatawill contain profile data
aResultingSignaturewill contain profile signature
aIsProfilePrivatewill be set to true if aResultingProfileData is encrypted.
aTimeOfPublishis also output variable, if non-NULL, will get its value set to time of publish of the profile
aResultingPublicKeyif non-NULL, will be written to contain the public key of the profile
Returns
true if profile was found
Hash ProfileModel::profileWithOldestTimeSinceMsgPoll ( quint32 *  aLastPollTime)

method for find a profile that we have private keys for and that has not had its private messages polled for given time (say, 15 minutes). See method NetworkConnectorEngine::createConnectionsToNodesStoringPrivateMessages

Parameters
aLastPollTimeoutput variable. this points to quint32 that (if profile is found) will have its value set to time of last message poll for the profile returned.
Returns
fingerprint of node or KNullHash if every profile with private keys has had its messages polled recently
bool ProfileModel::publishedProfileReceived ( const Hash aFingerPrint,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QList< quint32 > &  aBangPath,
const QByteArray &  aProfilePublicKey,
const unsigned char  aFlags,
const quint32  aTimeStamp,
const Hash aFromNode 
)

called by protocol parser when a profile is received

Parameters
aFingerPrintis the profile Hash received from protocol header
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
aProfilePublicKeyis 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
bool ProfileModel::publishProfile ( const Profile aProfile)

sends profile to selected nodes in network for others to retrieve.

The reason why this method is in model (and not for instance, in Controller) is that "publish" means that a particular profile is stored into and marked as "needs to be published". Before that happens we need to open network connections to nodes that are supposed to contain the profile and once connections are open, then same profile is pushed into several nodes until it is considered "published". That opening and pushing-part happens by networking-parts.

Parameters
aProfileis the profile to publish
Returns
true if things went all right
void ProfileModel::reIndexAllProfilesIntoFTS ( )
bool ProfileModel::sentProfileReceived ( const Hash aFingerPrint,
const QByteArray &  aContent,
const QByteArray &  aSignature,
const QByteArray &  aProfilePublicKey,
const unsigned char  aFlags,
const quint32  aTimeStamp,
const Hash fromNode 
)

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

Parameters
aFingerPrintis the profile Hash received from protocol header
aContentis actual profile data
aSignatureis digital signature of the aContent
aProfilePublicKeyis 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
void ProfileModel::setLastProfileUpdateTime ( const Hash aProfile,
time_t  aTime 
)

sets time of last (successful) profile update+comment poll.

void ProfileModel::setPrivateDataForProfile ( const Hash aProfile,
const QVariant &  aPrivateData 
)

Updates private data of a profile whose private key we stored locally. In first stage this private data includes contact list, later maybe trust settings etc.

void ProfileModel::setPrivateMessagePollTimeForProfile ( const quint32  aTimeStamp,
const Hash aProfile 
)

method that is called after successful message poll ; it set the message poll timestamp for a profile

Member Data Documentation

MController* ProfileModel::iController
private
const MModelProtocolInterface& ProfileModel::iModel
private

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