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
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_PRIVMSGMODEL_H
22 #define CLASSIFIED_PRIVMSGMODEL_H
23 #include <QSqlDatabase>
24 #include "../mcontroller.h" // because enum from there is needed
25 #include "../net/protocol.h" // for SendQueueItem
26 #include "datamodelbase.h"
27 
28 class Hash ;
30 class PrivMessage ;
31 
51 class PrivMessageModel : public ModelBase {
52  Q_OBJECT
53 
54 public:
55  PrivMessageModel(MController *aMController,
56  const MModelProtocolInterface &aModel) ;
58 
75  bool publishPrivMessage(PrivMessage& aPrivMessage,
76  const Hash& aDestinationNode = KNullHash ) ;
77 
84  PrivMessage* messageByFingerPrint(const Hash& aFingerPrint) ;
85 
112  bool messageDataByFingerPrint(const Hash& aFingerPrint,
113  QByteArray& aResultingPrivMessageData,
114  QByteArray& aResultingSignature,
115  Hash* aResultingDestinationNode,
116  Hash* aResultingRecipient,
117  quint32* aTimeOfPublish = NULL) ;
133  bool publishedPrivMessageReceived(const Hash& aFingerPrint,
134  const QByteArray& aContent,
135  const QByteArray& aSignature,
136  const QList<quint32>& aBangPath,
137  const Hash& aDestinationNode,
138  const Hash& aRecipient,
139  const quint32 aTimeStamp,
140  const Hash& aFromNode) ;
153  bool sentPrivMessageReceived(const Hash& aFingerPrint,
154  const QByteArray& aContent,
155  const QByteArray& aSignature,
156  const Hash& aDestinationNode,
157  const Hash& aRecipient,
158  const quint32 aTimeStamp,
159  const Hash& fromNode ) ;
160 
192  void fillBucket(QList<SendQueueItem>& aSendQueue,
193  const Hash& aStartOfBucket,
194  const Hash& aEndOfBucket,
195  quint32 aLastMutualConnectTime,
196  const Hash& aForNode );
209  QList<Hash> messagesForProfile(const Hash& aProfileHash,
210  const quint32 aLastMutualConnectTime) ;
211 
213  void setAsRead(const Hash& aMessageHash, bool aIsRead ) ;
214 private: // methods
220  bool doHandlepublishedOrSentPrivMessage(const Hash& aFingerPrint,
221  const QByteArray& aContent,
222  const QByteArray& aSignature,
223  const QList<quint32>& aBangPath,
224  const Hash& aDestinationNode,
225  const Hash& aRecipient,
226  const quint32 aTimeStamp,
227  bool aWasPublish,
228  const Hash& aFromNode ) ;
229 signals:
231  const QString& aExplanation) ;
233  void contentReceived(const Hash& aHashOfContent,
234  const Hash& aHashOfRecipientProfile,
235  const ProtocolItemType aTypeOfReceivdContent) ;
236 private: // member variables:
239 } ;
240 #endif
Carrier-class for private msg inside classified ads.
Definition: privmsg.h:36
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:238
This is is part of datamodel for storing private messages.
Definition: privmsgmodel.h:51
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:38
CAErrorSituation
Definition: mcontroller.h:57
bool messageDataByFingerPrint(const Hash &aFingerPrint, QByteArray &aResultingPrivMessageData, QByteArray &aResultingSignature, Hash *aResultingDestinationNode, Hash *aResultingRecipient, quint32 *aTimeOfPublish=NULL)
ProtocolItemType
Definition: protocol.h:157
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:46
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:48
datamodel-parts common part. this is inherited and contains common funcs
Definition: datamodelbase.h:39
Hash KNullHash
MController * iController
Definition: privmsgmodel.h:237
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)