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
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (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 GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Classified Ads; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef CLASSIFIED_PROFILEMODEL_H
22 #define CLASSIFIED_PROFILEMODEL_H
23 #include <QSqlDatabase>
24 #include "../mcontroller.h" // because enum from there is needed
25 #include "../net/connection.h"
26 #include "datamodelbase.h"
27 
28 class Hash ;
30 class Profile ;
31 
39 class ProfileModel : public ModelBase {
40  Q_OBJECT
41 
42 public:
43  ProfileModel(MController *aMController,
44  const MModelProtocolInterface &aModel) ;
45  ~ProfileModel() ;
46 
63  bool publishProfile(const Profile& aProfile) ;
64 
80  Profile* profileByFingerPrint(const Hash& aFingerPrint,
81  bool aEmitErrorOnEncryptionErrors = true,
82  bool aOmitImage = false ) ;
83 
106  bool profileDataByFingerPrint(const Hash& aFingerPrint,
107  QByteArray& aResultingProfileData,
108  QByteArray& aResultingSignature,
109  bool* aIsProfilePrivate,
110  quint32* aTimeOfPublish = NULL,
111  QByteArray* aResultingPublicKey = NULL ) ;
128  bool publishedProfileReceived(const Hash& aFingerPrint,
129  const QByteArray& aContent,
130  const QByteArray& aSignature,
131  const QList<quint32>& aBangPath,
132  const QByteArray& aProfilePublicKey,
133  const unsigned char aFlags,
134  const quint32 aTimeStamp,
135  const Hash& aFromNode) ;
149  bool sentProfileReceived(const Hash& aFingerPrint,
150  const QByteArray& aContent,
151  const QByteArray& aSignature,
152  const QByteArray& aProfilePublicKey,
153  const unsigned char aFlags,
154  const quint32 aTimeStamp,
155  const Hash& fromNode ) ;
156 
175  void fillBucket(QList<SendQueueItem>& aSendQueue,
176  const Hash& aStartOfBucket,
177  const Hash& aEndOfBucket,
178  quint32 aLastMutualConnectTime,
179  const Hash& aForNode );
180 
192  Hash profileWithOldestTimeSinceMsgPoll(quint32* aLastPollTime) ;
193 
198  void setPrivateMessagePollTimeForProfile(const quint32 aTimeStamp,
199  const Hash& aProfile ) ;
200 
206  void setPrivateDataForProfile( const Hash& aProfile,
207  const QVariant& aPrivateData ) ;
208 
214  QVariant privateDataOfProfile( const Hash& aProfile ) ;
215 
219  time_t getLastProfileUpdateTime( const Hash& aProfile ) ;
220 
224  void setLastProfileUpdateTime( const Hash& aProfile,time_t aTime ) ;
225 
227 private: // methods
232  bool doHandlepublishedOrSentProfile(const Hash& aFingerPrint,
233  const QByteArray& aContent,
234  const QByteArray& aSignature,
235  const QList<quint32>& aBangPath,
236  const QByteArray& aProfilePublicKey,
237  const unsigned char aFlags,
238  const quint32 aTimeStamp,
239  bool aWasPublish,
240  const Hash& aFromNode ) ;
244  virtual bool deleteOldestDataRowInTable() ;
245 signals:
247  const QString& aExplanation) ;
249  void contentReceived(const Hash& aHashOfContent,
250  const ProtocolItemType aTypeOfReceivdContent) ;
251 private: // member variables:
254 } ;
255 #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:253
Hash is class that carries 160-bit digest.
Definition: hash.h:38
CAErrorSituation
Definition: mcontroller.h:57
ProfileModel(MController *aMController, const MModelProtocolInterface &aModel)
ProtocolItemType
Definition: protocol.h:157
time_t getLastProfileUpdateTime(const Hash &aProfile)
MController * iController
Definition: profilemodel.h:252
Hash profileWithOldestTimeSinceMsgPoll(quint32 *aLastPollTime)
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:46
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:48
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:39
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:39
Profile * profileByFingerPrint(const Hash &aFingerPrint, bool aEmitErrorOnEncryptionErrors=true, bool aOmitImage=false)
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:37
void error(MController::CAErrorSituation aError, const QString &aExplanation)
void contentReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivdContent)
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)