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 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_PROFILECOMMENTMODEL_H
21 #define CLASSIFIED_PROFILECOMMENTMODEL_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 ProfileComment ;
30 
38  Q_OBJECT
39 
40 public:
41  ProfileCommentModel(MController *aMController,
42  const MModelProtocolInterface &aModel) ;
44 
53  bool publishProfileComment(ProfileComment& aProfileComment) ;
54 
61  ProfileComment* profileCommentByFingerPrint(const Hash& aFingerPrint) ;
62 
86  bool commentDataByFingerPrint(const Hash& aFingerPrint,
87  QByteArray& aResultingProfileCommentData,
88  QByteArray& aResultingSignature,
89  Hash* aResultingProfileFingerPrint,
90  quint32* aFlags,
91  quint32* aTimeOfPublish = NULL ) ;
111  bool publishedProfileCommentReceived(const Hash& aFingerPrint,
112  const Hash& aCommentedProfileFP,
113  const QByteArray& aContent,
114  const QByteArray& aSignature,
115  const QList<quint32>& aBangPath,
116  const unsigned char aFlags,
117  const quint32 aTimeStamp,
118  const Hash& aFromNode) ;
134  bool sentProfileCommentReceived(const Hash& aFingerPrint,
135  const Hash& aCommentedProfileFP,
136  const QByteArray& aContent,
137  const QByteArray& aSignature,
138  const unsigned char aFlags,
139  const quint32 aTimeStamp,
140  const Hash& fromNode ) ;
141 
160  void fillBucket(QList<SendQueueItem>& aSendQueue,
161  const Hash& aStartOfBucket,
162  const Hash& aEndOfBucket,
163  quint32 aLastMutualConnectTime,
164  const Hash& aForNode );
165 
166 
171  QList<Hash> commentsForProfile(const Hash& aProfileHash,
172  const quint32 aSinceTimeStamp) ;
173 
174  void reIndexAllCommentsIntoFTS() ;
175 private: // methods
180  bool doHandlepublishedOrSentProfileComment(const Hash& aFingerPrint,
181  const Hash& aCommentedProfileFP,
182  const QByteArray& aContent,
183  const QByteArray& aSignature,
184  const QList<quint32>& aBangPath,
185  const unsigned char aFlags,
186  const quint32 aTimeStamp,
187  bool aWasPublish,
188  const Hash& aFromNode ) ;
189 signals:
191  const QString& aExplanation) ;
193  void contentReceived(const Hash& aHashOfContent,
194  const Hash& aHashOfProfileCommented,
195  const ProtocolItemType aTypeOfReceivdContent) ;
196 private: // member variables:
199 } ;
200 #endif
Carrier-class for comments of a profile.
Definition: profilecomment.h:37
bool publishProfileComment(ProfileComment &aProfileComment)
ProfileComment * profileCommentByFingerPrint(const Hash &aFingerPrint)
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:37
void error(MController::CAErrorSituation aError, const QString &aExplanation)
Hash is class that carries 160-bit digest.
Definition: hash.h:37
CAErrorSituation
Definition: mcontroller.h:48
ProtocolItemType
Definition: protocol.h:124
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:44
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:39
datamodel-parts common part. this is inherited and contains common funcs
Definition: datamodelbase.h:38
const MModelProtocolInterface & iModel
Definition: profilecommentmodel.h:198
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:197
ProfileCommentModel(MController *aMController, const MModelProtocolInterface &aModel)
QList< Hash > commentsForProfile(const Hash &aProfileHash, const quint32 aSinceTimeStamp)
void reIndexAllCommentsIntoFTS()