Classified ads
|
M of the MVC pattern. Handles permanent storage. More...
#include <model.h>
Public Types | |
enum | RingtoneSetting { BowRingTone = 0, ElectricalRingTone = 1, AcousticRingTone = 2, BeepRingTone = 3, NoRingTone = 4 } |
enum | CallAcceptanceSetting { AcceptAllCalls = 0, AcceptCallsFromTrusted = 1, AcceptNoCalls = 2 } |
Public Slots | |
void | notifyOfContentReceived (const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivdContent) |
void | notifyOfContentReceived (const Hash &aHashOfContent, const Hash &aHashOfClassification, const ProtocolItemType aTypeOfReceivdContent) |
Signals | |
void | error (MController::CAErrorSituation aError, const QString &aExplanation) |
Protected Member Functions | |
void | timerEvent (QTimerEvent *event) |
Private Member Functions | |
bool | openDB () |
QSqlError | lastError () |
bool | createTables () |
bool | createTablesV2 () |
bool | createTablesV3 () |
bool | createTablesV4 () |
void | initPseudoRandom () |
Private Attributes | |
MController * | iController |
QSqlDatabase | iDb |
QMutex * | iMutex |
QList< Connection * > * | iConnections |
NodeModel * | iNodeModel |
NetworkRequestExecutor * | iNetReqExecutor |
QList< NetworkRequestExecutor::NetworkRequestQueueItem > * | iNetReqQueue |
ContentEncryptionModel * | iContentEncryptionModel |
ProfileModel * | iProfileModel |
BinaryFileModel * | iBinaryFileModel |
ClassifiedAdsModel * | iCaModel |
int | iTimerId |
PrivMessageModel * | iPrivMsgModel |
ProfileCommentModel * | iProfileCommentModel |
SearchModel * | iSearchModel |
CaDbRecordModel * | iCaDbRecordModel |
TrustTreeModel * | iTrustTreeModel |
time_t | iTimeOfLastNetworkAddrCheck |
TclModel * | iTclModel |
M of the MVC pattern. Handles permanent storage.
All permanent data storage inside classified ads goes somehow via this class here. If user wants to display data, view gets it from here, if a peer wants to leech a phile, it comes from here
Model::Model | ( | MController * | aMController | ) |
Model::~Model | ( | ) |
void Model::addItemToBePublished | ( | ProtocolItemType | aType, |
const Hash & | aHash, | ||
const QList< quint32 > & | aBangPath, | ||
const Hash & | aSecondaryAddr = KNullHash |
||
) |
Method for marking item already in datamodel to be published via PublishingEngine class. For example, if publishing a profile user must first insert the profile into profilemodel, and only after that call this method here.
aType | tells type of an item - profile,privmsg,binary blob etc. |
aHash | fingerprint for identifies object |
aBangPath | list of low-order hash-bits of nodes where this content is already supposed to be found |
aSecondaryAddr | is possible 2nd publish addr, used for CA and comment. for private messages this is the destination node, if known. |
void Model::addItemToSend | ( | const Hash & | aDestinationNode, |
QByteArray * | aBytesToSend | ||
) |
Method that other parts of this program use to append items into send queue of node connection.
aDestinationNode | specifies the node to receive bytes |
aBytesToSend | contains the message. Ownership of bytes is transferred to datamodel i.e. after this method is called, the caller is not supposed to delete the bytes itself but that task is left to datamodel to do. |
|
virtual |
method for adding a network request
aRequest | is the request to add |
Implements MModelProtocolInterface.
PublishItem Model::addNodeToPublishedItem | ( | const Hash & | aContentHash, |
const Hash & | aNodeHash | ||
) |
When publishing-engine is doing its job, it uses this method to update the list of nodes that have received the published content.
aContentHash | identifies the published content that has been pushed into one node |
aNodeHash | identifies the node where content was pushed to |
void Model::addOpenNetworkConnection | ( | Connection * | aConnection | ) |
Method for adding newly created peer-connection to list kept by datamodel
|
virtual |
method for getting binary-blob datamodel
Implements MModelProtocolInterface.
|
virtual |
method for getting distributed database model part
Implements MModelProtocolInterface.
|
virtual |
method for getting the ads datamodel
Implements MModelProtocolInterface.
void Model::closeAllConnections | ( | bool | aDeleteAlso | ) |
Close all connections that might be open. Called before deletia.
aDeleteAlso | if set to true, will delete remaining connections. if that needs to be done, results easily in SEGFAULT as connections are threads .. they should be closed so that threads no longer run, run() returns and thread cleans up itself.. |
void Model::connectionStateChanged | ( | Connection::ConnectionState | aState, |
Connection * | aConnection | ||
) |
method for communicating the fact that socket is open or closed
|
virtual |
method for getting content-encryption-specific datamodel
Implements MModelProtocolInterface.
|
private |
|
private |
|
private |
|
private |
|
signal |
Model::CallAcceptanceSetting Model::getCallAcceptanceSetting | ( | ) |
getter method for users call-acceptance-setting
const QList<Connection *>& Model::getConnections | ( | ) | const |
Currently open connections. Caller does not own the returned list and should not try adding/removing items from it.
NetworkRequestExecutor* Model::getNetReqExecutor | ( | ) |
pointer to class handling network requests
QList<NetworkRequestExecutor::NetworkRequestQueueItem>& Model::getNetRequests | ( | ) | const |
Currently pending network requests. Even as this returns a pointer, not a reference, ownership of the list is not transferred ; caller may modiify content but is not supposed to delete
Model::RingtoneSetting Model::getRingtoneSetting | ( | ) |
getter method for users ringtone-setting
|
private |
just calls srand()
|
private |
|
virtual |
From MModelProtocolInterface. thread sync: this claims access to datamodel
Implements MModelProtocolInterface.
PublishItem Model::nextItemToPublish | ( | bool * | aFound | ) |
method for getting next item to publish
aFound | will be set to true if there is an item to publish |
|
virtual |
From MModelProtocolInterface.
method for getting node-specific datamodel
Implements MModelProtocolInterface.
|
slot |
notification of content received
|
slot |
notification of classified ads received
|
private |
|
virtual |
method for getting the priv msg datamodel
Implements MModelProtocolInterface.
|
virtual |
method for getting the comment datamodel
Implements MModelProtocolInterface.
|
virtual |
method for getting profile-specific datamodel
Implements MModelProtocolInterface.
void Model::removeOpenNetworkConnection | ( | Connection * | aDeletedConnection | ) |
Method for telling datamodel about a existing network connection has been closed for any reason that is valid for a socket.
aConnection | is pointer to the connection |
|
virtual |
method for getting the full text search datamodel
Implements MModelProtocolInterface.
void Model::setCallAcceptanceSetting | ( | Model::CallAcceptanceSetting | aAcceptance | ) |
getter method for users call-acceptance-setting
void Model::setRingtoneSetting | ( | Model::RingtoneSetting | aRingTone | ) |
getter method for users ringtone-setting
|
virtual |
method for getting the storage of TCL programs
Implements MModelProtocolInterface.
|
protected |
for periodical stuff inside datamodel
|
virtual |
method for getting the trust tree datamodel
|
virtual |
From MModelProtocolInterface. thread sync: releases data model to other threads
Implements MModelProtocolInterface.
|
private |
Random binary blob storage
|
private |
distributed general-purpose database
|
private |
Classified ads storage
|
private |
|
private |
cryptographic animal
|
private |
|
private |
actual storage here
|
private |
this mutex protects access to this datamodel
|
private |
|
private |
have datamodel own network request queue, this is our queue of pending tasks
|
private |
Network connections currently open datamodel about our peers
|
private |
storage of private messages
|
private |
comments data storage
|
private |
Profile data storage
|
private |
full text search model part
|
private |
TCL scripts storage
|
private |
timestamp of local addr update
|
private |
id of our periodical timer
|
private |
trust list handling model