Classified ads
privmsgmodel.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 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_PRIVMSGMODEL_H
21 #define CLASSIFIED_PRIVMSGMODEL_H
22 #include <QSqlDatabase>
23 #include "../mcontroller.h" // because enum from there is needed
24 #include "../net/protocol.h" // for SendQueueItem
25 #include "datamodelbase.h"
26 
27 class Hash ;
29 class PrivMessage ;
30 
50 class PrivMessageModel : public ModelBase {
51  Q_OBJECT
52 
53 public:
54  PrivMessageModel(MController *aMController,
55  const MModelProtocolInterface &aModel) ;
57 
74  bool publishPrivMessage(PrivMessage& aPrivMessage,
75  const Hash& aDestinationNode = KNullHash ) ;
76 
83  PrivMessage* messageByFingerPrint(const Hash& aFingerPrint) ;
84 
111  bool messageDataByFingerPrint(const Hash& aFingerPrint,
112  QByteArray& aResultingPrivMessageData,
113  QByteArray& aResultingSignature,
114  Hash* aResultingDestinationNode,
115  Hash* aResultingRecipient,
116  quint32* aTimeOfPublish = NULL) ;
132  bool publishedPrivMessageReceived(const Hash& aFingerPrint,
133  const QByteArray& aContent,
134  const QByteArray& aSignature,
135  const QList<quint32>& aBangPath,
136  const Hash& aDestinationNode,
137  const Hash& aRecipient,
138  const quint32 aTimeStamp,
139  const Hash& aFromNode) ;
152  bool sentPrivMessageReceived(const Hash& aFingerPrint,
153  const QByteArray& aContent,
154  const QByteArray& aSignature,
155  const Hash& aDestinationNode,
156  const Hash& aRecipient,
157  const quint32 aTimeStamp,
158  const Hash& fromNode ) ;
159 
191  void fillBucket(QList<SendQueueItem>& aSendQueue,
192  const Hash& aStartOfBucket,
193  const Hash& aEndOfBucket,
194  quint32 aLastMutualConnectTime,
195  const Hash& aForNode );
208  QList<Hash> messagesForProfile(const Hash& aProfileHash,
209  const quint32 aLastMutualConnectTime) ;
210 
212  void setAsRead(const Hash& aMessageHash, bool aIsRead ) ;
213 private: // methods
219  bool doHandlepublishedOrSentPrivMessage(const Hash& aFingerPrint,
220  const QByteArray& aContent,
221  const QByteArray& aSignature,
222  const QList<quint32>& aBangPath,
223  const Hash& aDestinationNode,
224  const Hash& aRecipient,
225  const quint32 aTimeStamp,
226  bool aWasPublish,
227  const Hash& aFromNode ) ;
228  signals:
230  const QString& aExplanation) ;
232  void contentReceived(const Hash& aHashOfContent,
233  const Hash& aHashOfRecipientProfile,
234  const ProtocolItemType aTypeOfReceivdContent) ;
235 private: // member variables:
238 } ;
239 #endif
Carrier-class for private msg inside classified ads.
Definition: privmsg.h:35
void setAsRead(const Hash &aMessageHash, bool aIsRead)
void error(MController::CAErrorSituation aError, const QString &aExplanation)
bool doHandlepublishedOrSentPrivMessage(const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aDestinationNode, const Hash &aRecipient, const quint32 aTimeStamp, bool aWasPublish, const Hash &aFromNode)
const MModelProtocolInterface & iModel
Definition: privmsgmodel.h:237
This is is part of datamodel for storing private messages.
Definition: privmsgmodel.h:50
void fillBucket(QList< SendQueueItem > &aSendQueue, const Hash &aStartOfBucket, const Hash &aEndOfBucket, quint32 aLastMutualConnectTime, const Hash &aForNode)
QList< Hash > messagesForProfile(const Hash &aProfileHash, const quint32 aLastMutualConnectTime)
void contentReceived(const Hash &aHashOfContent, const Hash &aHashOfRecipientProfile, const ProtocolItemType aTypeOfReceivdContent)
Hash is class that carries 160-bit digest.
Definition: hash.h:37
CAErrorSituation
Definition: mcontroller.h:48
bool messageDataByFingerPrint(const Hash &aFingerPrint, QByteArray &aResultingPrivMessageData, QByteArray &aResultingSignature, Hash *aResultingDestinationNode, Hash *aResultingRecipient, quint32 *aTimeOfPublish=NULL)
ProtocolItemType
Definition: protocol.h:124
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:44
bool publishedPrivMessageReceived(const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aDestinationNode, const Hash &aRecipient, const quint32 aTimeStamp, 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
Hash KNullHash
MController * iController
Definition: privmsgmodel.h:236
PrivMessageModel(MController *aMController, const MModelProtocolInterface &aModel)
bool sentPrivMessageReceived(const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const Hash &aDestinationNode, const Hash &aRecipient, const quint32 aTimeStamp, const Hash &fromNode)
bool publishPrivMessage(PrivMessage &aPrivMessage, const Hash &aDestinationNode=KNullHash)
PrivMessage * messageByFingerPrint(const Hash &aFingerPrint)