Classified ads
profilemodel.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Jarvinen 2013.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Classified Ads. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef CLASSIFIED_PROFILEMODEL_H
21 #define CLASSIFIED_PROFILEMODEL_H
22 #include <QSqlDatabase>
23 #include "../mcontroller.h" // because enum from there is needed
24 #include "../net/connection.h"
25 #include "datamodelbase.h"
26 
27 class Hash ;
29 class Profile ;
30 
38 class ProfileModel : public ModelBase {
39  Q_OBJECT
40 
41 public:
42  ProfileModel(MController *aMController,
43  const MModelProtocolInterface &aModel) ;
44  ~ProfileModel() ;
45 
62  bool publishProfile(const Profile& aProfile) ;
63 
70  Profile* profileByFingerPrint(const Hash& aFingerPrint) ;
71 
94  bool profileDataByFingerPrint(const Hash& aFingerPrint,
95  QByteArray& aResultingProfileData,
96  QByteArray& aResultingSignature,
97  bool* aIsProfilePrivate,
98  quint32* aTimeOfPublish = NULL,
99  QByteArray* aResultingPublicKey = NULL ) ;
116  bool publishedProfileReceived(const Hash& aFingerPrint,
117  const QByteArray& aContent,
118  const QByteArray& aSignature,
119  const QList<quint32>& aBangPath,
120  const QByteArray& aProfilePublicKey,
121  const unsigned char aFlags,
122  const quint32 aTimeStamp,
123  const Hash& aFromNode) ;
137  bool sentProfileReceived(const Hash& aFingerPrint,
138  const QByteArray& aContent,
139  const QByteArray& aSignature,
140  const QByteArray& aProfilePublicKey,
141  const unsigned char aFlags,
142  const quint32 aTimeStamp,
143  const Hash& fromNode ) ;
144 
163  void fillBucket(QList<SendQueueItem>& aSendQueue,
164  const Hash& aStartOfBucket,
165  const Hash& aEndOfBucket,
166  quint32 aLastMutualConnectTime,
167  const Hash& aForNode );
168 
180  Hash profileWithOldestTimeSinceMsgPoll(quint32* aLastPollTime) ;
181 
186  void setPrivateMessagePollTimeForProfile(const quint32 aTimeStamp,
187  const Hash& aProfile ) ;
188 
194  void setPrivateDataForProfile( const Hash& aProfile,
195  const QVariant& aPrivateData ) ;
196 
202  QVariant privateDataOfProfile( const Hash& aProfile ) ;
203 
207  time_t getLastProfileUpdateTime( const Hash& aProfile ) ;
208 
212  void setLastProfileUpdateTime( const Hash& aProfile,time_t aTime ) ;
213 
214  void reIndexAllProfilesIntoFTS() ;
215 private: // methods
220  bool doHandlepublishedOrSentProfile(const Hash& aFingerPrint,
221  const QByteArray& aContent,
222  const QByteArray& aSignature,
223  const QList<quint32>& aBangPath,
224  const QByteArray& aProfilePublicKey,
225  const unsigned char aFlags,
226  const quint32 aTimeStamp,
227  bool aWasPublish,
228  const Hash& aFromNode ) ;
232  virtual bool deleteOldestDataRowInTable() ;
233 signals:
235  const QString& aExplanation) ;
237  void contentReceived(const Hash& aHashOfContent,
238  const ProtocolItemType aTypeOfReceivdContent) ;
239 private: // member variables:
242 } ;
243 #endif
QVariant privateDataOfProfile(const Hash &aProfile)
bool profileDataByFingerPrint(const Hash &aFingerPrint, QByteArray &aResultingProfileData, QByteArray &aResultingSignature, bool *aIsProfilePrivate, quint32 *aTimeOfPublish=NULL, QByteArray *aResultingPublicKey=NULL)
bool publishProfile(const Profile &aProfile)
const MModelProtocolInterface & iModel
Definition: profilemodel.h:241
Hash is class that carries 160-bit digest.
Definition: hash.h:37
CAErrorSituation
Definition: mcontroller.h:48
ProfileModel(MController *aMController, const MModelProtocolInterface &aModel)
ProtocolItemType
Definition: protocol.h:124
time_t getLastProfileUpdateTime(const Hash &aProfile)
MController * iController
Definition: profilemodel.h:240
Hash profileWithOldestTimeSinceMsgPoll(quint32 *aLastPollTime)
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:44
void setPrivateMessagePollTimeForProfile(const quint32 aTimeStamp, const Hash &aProfile)
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:39
void fillBucket(QList< SendQueueItem > &aSendQueue, const Hash &aStartOfBucket, const Hash &aEndOfBucket, quint32 aLastMutualConnectTime, const Hash &aForNode)
datamodel-parts common part. this is inherited and contains common funcs
Definition: datamodelbase.h:38
bool sentProfileReceived(const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QByteArray &aProfilePublicKey, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &fromNode)
This is is part of datamodel for storing user profiles.
Definition: profilemodel.h:38
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)
virtual bool deleteOldestDataRowInTable()
void setLastProfileUpdateTime(const Hash &aProfile, time_t aTime)
Carrier-class for user-profile data.
Definition: profile.h:36
void error(MController::CAErrorSituation aError, const QString &aExplanation)
void contentReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivdContent)
Profile * profileByFingerPrint(const Hash &aFingerPrint)
void setPrivateDataForProfile(const Hash &aProfile, const QVariant &aPrivateData)
void reIndexAllProfilesIntoFTS()
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)