Classified ads
|
This is part of datamodel for storage/retrieval of classified ads. More...
#include <camodel.h>
Classes | |
class | CAObserver |
Public Types | |
enum | PurposeOfAd { ToBeBought =0, ToBeSold =1, ToBeGivenAway =2, IsWanted =3, ToBeRented =4, ToBeAnnounced =5 } |
enum | ConcernOfAd { ConcerningCars =0, ConcerningBoats =1, ConcerningBikes =2, ConcerningOtherVehicles =3, ConcerningVehicleParts =4, ConcerningHabitation =5, ConcerningHouseholdAppliances =6, ConcerningFurniture =7, ConcerningClothing =8, ConcerningTools =9, ConcerningSports =10, ConcerningMusic =11, ConcerningBooks =12, ConcerningMovies =13, ConcerningAnimals =14, ConcerningElectronics =15, ConcerningJobs =16, ConcerningTransportation =17, ConcerningServices =18, ConcerningHealthcare =19, ConcerningFoodstuff =20, ConcerningSoftware =21, ConcerningEvents =22, ConcerningEducation =23, ConcerningFinance =24, ConcerningJewelry =25, ConcerningReligiousRituals =26, ConcerningPhilosophy =27 } |
Signals | |
void | error (MController::CAErrorSituation aError, const QString &aExplanation) |
void | contentReceived (const Hash &aHashOfContent, const Hash &aHashOfClassification, const ProtocolItemType aTypeOfReceivdContent) |
Signals inherited from ModelBase | |
void | error (MController::CAErrorSituation aError, const QString &aExplanation) |
Public Member Functions | |
ClassifiedAdsModel (MController *aMController, const MModelProtocolInterface &aModel) | |
~ClassifiedAdsModel () | |
const QString & | purposeOfAdString (PurposeOfAd aPurpose) const |
QString | localizedPurposeOfAdString (PurposeOfAd aPurpose) const |
const QString & | concernOfAdString (ConcernOfAd aConcern) const |
QString | localizedConcernOfAdString (ConcernOfAd aConcern) const |
Hash | publishClassifiedAd (const Profile &aPublishingProfile, CA &aAd) |
bool | caDataForPublish (const Hash &aFingerPrint, QByteArray &aResultingCaData, QByteArray &aResultingSignature, QByteArray &aPublicKeyOfPublisher, quint32 *aTimeOfPublish=NULL) |
CA | caByHash (const Hash &aFingerPrint) |
bool | publishedCAReceived (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode) |
bool | sentCAReceived (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode) |
void | installCAObserver (CAObserver *aObserver) |
void | removeCAObserver (CAObserver *aObserver) |
void | fillBucket (QList< SendQueueItem > &aSendQueue, const Hash &aStartOfBucket, const Hash &aEndOfBucket, quint32 aLastMutualConnectTime, const Hash &aForNode) |
void | caListingByClassification (const Hash &aClassificationHash, quint32 aStartDate, quint32 aEndDate, QList< QPair< Hash, quint32 > > &aResultingArticles, const Hash &aRequestingNode) |
bool | caListingByClassificationReceived (QList< QPair< Hash, quint32 > > &aReceivedArticles, const Hash &aRequestingNode, const Hash &aClassification) |
void | reIndexAllAdsIntoFTS () |
const QStringList & | aboutComboBoxTexts () const |
const QStringList & | regardingComboBoxTexts () const |
const QStringList & | whereComboBoxTexts () const |
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 | doHandleReceivedCA (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, bool aWasPublish, const Hash &aFromNode) |
void | initComboBoxTexts () |
Private Attributes | |
MController * | iController |
const MModelProtocolInterface & | iModel |
QList< CAObserver * > * | iNewCaObservers |
QStringList | iAboutComboBoxTexts |
QStringList | iRegardingComboBoxTexts |
QStringList | iWhereComboBoxTexts |
Additional Inherited Members | |
Protected Attributes inherited from ModelBase | |
QString | iDataTableName |
unsigned | iMaxRowsToKeep |
unsigned | iCurrentDbTableRowCount |
This is part of datamodel for storage/retrieval of classified ads.
This is persistent storage and search and retrieval of objects that are the classified ads that this program is about.
Another classification for an classified ad: what item/real life stuff the ad concerns
In classified ads the ads are classified. The classifications are defined here, first start about purpose of the ad
ClassifiedAdsModel::ClassifiedAdsModel | ( | MController * | aMController, |
const MModelProtocolInterface & | aModel | ||
) |
Constructor
aMController | is application controller |
aModel | is datamodel |
ClassifiedAdsModel::~ClassifiedAdsModel | ( | ) |
destructor
const QStringList& ClassifiedAdsModel::aboutComboBoxTexts | ( | ) | const |
returns ui texts
method for getting CA data for any purpose, like display
bool ClassifiedAdsModel::caDataForPublish | ( | const Hash & | aFingerPrint, |
QByteArray & | aResultingCaData, | ||
QByteArray & | aResultingSignature, | ||
QByteArray & | aPublicKeyOfPublisher, | ||
quint32 * | aTimeOfPublish = NULL |
||
) |
method for getting ca data for publish purpose
aTimeOfPublish | if non-NULL will have its value set to publish time of the CA |
void ClassifiedAdsModel::caListingByClassification | ( | const Hash & | aClassificationHash, |
quint32 | aStartDate, | ||
quint32 | aEndDate, | ||
QList< QPair< Hash, quint32 > > & | aResultingArticles, | ||
const Hash & | aRequestingNode | ||
) |
Method for fetching list of classified ads whose classification matches given hash. This method produces content of reply to protocol item KAdsClassifiedAtHash.
bool ClassifiedAdsModel::caListingByClassificationReceived | ( | QList< QPair< Hash, quint32 > > & | aReceivedArticles, |
const Hash & | aRequestingNode, | ||
const Hash & | aClassification | ||
) |
method for handling list of classified ads produced by method caListingByClassification. The thing is that we come to this method when other node has sent us a list of ads available. We may want to store the article fingerprints and try to obtain them (the actual articles) later. For this reason the classified_ads database table allows null values in content ; that may be fetched later. Justification for this stupidity of not sending the article with the hash is bandwidht: there may be a node keeping the list of articles and rest of the ring keeping the articles.
This will modify contents of aReceivedArticles to not contain articles already found from db
const QString& ClassifiedAdsModel::concernOfAdString | ( | ConcernOfAd | aConcern | ) | const |
|
signal |
emitted when new classified ad is received.
aHashOfContent | is fingerprint of the article |
aHashOfClassification | fingerprint of classification |
aTypeOfReceivdContent | Type of content. This model mostly emits ClassifiedAd -types |
|
private |
this method is called from publishedCAReceived and also on method where CA that is sent to us is to be handled
|
signal |
void ClassifiedAdsModel::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. |
|
private |
initializes string lists used for classification comboboxes
void ClassifiedAdsModel::installCAObserver | ( | CAObserver * | aObserver | ) |
method for installing observer for new ads
QString ClassifiedAdsModel::localizedConcernOfAdString | ( | ConcernOfAd | aConcern | ) | const |
QString ClassifiedAdsModel::localizedPurposeOfAdString | ( | PurposeOfAd | aPurpose | ) | const |
string returned is displayed to user. idea is that when hash of the classification is constructed, non-localized string from purposeOfAdString is used and same hash will be obtained regardless of the language used
sends a classified ads to selected nodes in network for others to retrieve.
aPublishingProfile | is the publishing profile ; it is used to sign the content |
aAd | is the meat being thrown |
bool ClassifiedAdsModel::publishedCAReceived | ( | const Hash & | aFingerPrint, |
const QByteArray & | aContent, | ||
const QByteArray & | aSignature, | ||
const QList< quint32 > & | aBangPath, | ||
const QByteArray & | aKeyOfPublisher, | ||
const unsigned char | aFlags, | ||
const quint32 | aTimeStamp, | ||
const Hash & | aFromNode | ||
) |
called by protocol parser when a CA is received due to publish
aFingerPrint | is the profile Hash received from protocol header |
aContent | is actual ca data |
aSignature | is digital signature of the aContent |
aBangPath | is list of low-order bits of hashes of nodes where this content has been. This is for preventing sending content back to nodes where it has already been. |
aKeyOfPublisher | is the key that was used to sign the file. that is transferred outside file just because the recipient might not have the key beforehand ; if she does, the existing key will be used in verifying process. |
aFlags | possible flags telling about encyption and compression |
aTimeStamp | timestamp of file (if encrypted, it must be carried outside..) |
const QString& ClassifiedAdsModel::purposeOfAdString | ( | PurposeOfAd | aPurpose | ) | const |
string returned here is used for constructing hash of the classification
const QStringList& ClassifiedAdsModel::regardingComboBoxTexts | ( | ) | const |
returns ui texts
void ClassifiedAdsModel::reIndexAllAdsIntoFTS | ( | ) |
debug method, more or less. reads all ads and feeds them to indexer
void ClassifiedAdsModel::removeCAObserver | ( | CAObserver * | aObserver | ) |
method for removing previously installed observer for new ads
bool ClassifiedAdsModel::sentCAReceived | ( | const Hash & | aFingerPrint, |
const QByteArray & | aContent, | ||
const QByteArray & | aSignature, | ||
const QByteArray & | aKeyOfPublisher, | ||
const unsigned char | aFlags, | ||
const quint32 | aTimeStamp, | ||
const Hash & | aFromNode | ||
) |
called by protocol parser when a CA is received due to send
aFingerPrint | is the profile Hash received from protocol header |
aContent | is actual ca data |
aSignature | is digital signature of the aContent |
aKeyOfPublisher | is the key that was used to sign the file. that is transferred outside file just because the recipient might not have the key beforehand ; if she does, the existing key will be used in verifying process. |
aFlags | possible flags telling about encyption and compression |
aTimeStamp | timestamp of file (if encrypted, it must be carried outside..) |
const QStringList& ClassifiedAdsModel::whereComboBoxTexts | ( | ) | const |
returns ui texts
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |