Classified ads
profilecommentmodel.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_PROFILECOMMENTMODEL_H
22 #define CLASSIFIED_PROFILECOMMENTMODEL_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 ProfileComment ;
31 
39  Q_OBJECT
40 
41 public:
42  ProfileCommentModel(MController *aMController,
43  const MModelProtocolInterface &aModel) ;
45 
54  bool publishProfileComment(ProfileComment& aProfileComment) ;
55 
66  ProfileComment* profileCommentByFingerPrint(const Hash& aFingerPrint,
67  bool aEmitOnEncryptionError=true) ;
68 
92  bool commentDataByFingerPrint(const Hash& aFingerPrint,
93  QByteArray& aResultingProfileCommentData,
94  QByteArray& aResultingSignature,
95  Hash* aResultingProfileFingerPrint,
96  quint32* aFlags,
97  quint32* aTimeOfPublish = NULL ) ;
117  bool publishedProfileCommentReceived(const Hash& aFingerPrint,
118  const Hash& aCommentedProfileFP,
119  const QByteArray& aContent,
120  const QByteArray& aSignature,
121  const QList<quint32>& aBangPath,
122  const unsigned char aFlags,
123  const quint32 aTimeStamp,
124  const Hash& aFromNode) ;
140  bool sentProfileCommentReceived(const Hash& aFingerPrint,
141  const Hash& aCommentedProfileFP,
142  const QByteArray& aContent,
143  const QByteArray& aSignature,
144  const unsigned char aFlags,
145  const quint32 aTimeStamp,
146  const Hash& fromNode ) ;
147 
166  void fillBucket(QList<SendQueueItem>& aSendQueue,
167  const Hash& aStartOfBucket,
168  const Hash& aEndOfBucket,
169  quint32 aLastMutualConnectTime,
170  const Hash& aForNode );
171 
172 
177  QList<Hash> commentsForProfile(const Hash& aProfileHash,
178  const quint32 aSinceTimeStamp) ;
179 
181 private: // methods
186  bool doHandlepublishedOrSentProfileComment(const Hash& aFingerPrint,
187  const Hash& aCommentedProfileFP,
188  const QByteArray& aContent,
189  const QByteArray& aSignature,
190  const QList<quint32>& aBangPath,
191  const unsigned char aFlags,
192  const quint32 aTimeStamp,
193  bool aWasPublish,
194  const Hash& aFromNode ) ;
195 signals:
197  const QString& aExplanation) ;
199  void contentReceived(const Hash& aHashOfContent,
200  const Hash& aHashOfProfileCommented,
201  const ProtocolItemType aTypeOfReceivdContent) ;
202 private: // member variables:
205 } ;
206 #endif
Carrier-class for comments of a profile.
Definition: profilecomment.h:38
bool publishProfileComment(ProfileComment &aProfileComment)
void contentReceived(const Hash &aHashOfContent, const Hash &aHashOfProfileCommented, const ProtocolItemType aTypeOfReceivdContent)
bool commentDataByFingerPrint(const Hash &aFingerPrint, QByteArray &aResultingProfileCommentData, QByteArray &aResultingSignature, Hash *aResultingProfileFingerPrint, quint32 *aFlags, quint32 *aTimeOfPublish=NULL)
bool sentProfileCommentReceived(const Hash &aFingerPrint, const Hash &aCommentedProfileFP, const QByteArray &aContent, const QByteArray &aSignature, 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)
This is is part of datamodel for storing comments of user profiles.
Definition: profilecommentmodel.h:38
void error(MController::CAErrorSituation aError, const QString &aExplanation)
Hash is class that carries 160-bit digest.
Definition: hash.h:38
CAErrorSituation
Definition: mcontroller.h:52
ProfileComment * profileCommentByFingerPrint(const Hash &aFingerPrint, bool aEmitOnEncryptionError=true)
ProtocolItemType
Definition: protocol.h:150
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:45
bool doHandlepublishedOrSentProfileComment(const Hash &aFingerPrint, const Hash &aCommentedProfileFP, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const unsigned char aFlags, const quint32 aTimeStamp, bool aWasPublish, const Hash &aFromNode)
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:43
datamodel-parts common part. this is inherited and contains common funcs
Definition: datamodelbase.h:39
const MModelProtocolInterface & iModel
Definition: profilecommentmodel.h:204
bool publishedProfileCommentReceived(const Hash &aFingerPrint, const Hash &aCommentedProfileFP, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode)
MController * iController
Definition: profilecommentmodel.h:203
ProfileCommentModel(MController *aMController, const MModelProtocolInterface &aModel)
QList< Hash > commentsForProfile(const Hash &aProfileHash, const quint32 aSinceTimeStamp)
void reIndexAllCommentsIntoFTS()