Classified ads
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Jarvinen 2013.
4  This file is part of Classified Ads.
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.
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  Lesser General Public License for more details.
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 */
23 #include <QSqlDatabase>
24 #include "../mcontroller.h" // because enum from there is needed
25 #include "../net/connection.h"
26 #include "datamodelbase.h"
28 class Hash ;
29 class BinaryFile ;
31 class Profile ;
39 class BinaryFileModel : public ModelBase {
42 public:
43  BinaryFileModel(MController *aMController,
44  const MModelProtocolInterface &aModel) ;
83  Hash publishBinaryFile(const Profile& aPublishingProfile,
84  const QString& aFileName,
85  const QString& aDescription,
86  const QString& aMimeType,
87  const QString& aOwner,
88  const QString& aLicense,
89  const QByteArray& aContents,
90  bool aIsCompressed,
91  bool aNoEncryption = false,
92  const QList<Hash>* aBinaryRecipientList = NULL ) ;
106  BinaryFile* binaryFileByFingerPrint(const Hash& aFingerPrint) ;
126  bool binaryFileDataByFingerPrint(const Hash& aFingerPrint,
127  const Hash& aPresumedSender,
128  QByteArray& aResultingBinaryFileData,
129  QByteArray& aResultingSignature,
130  bool* aIsBinaryFilePrivate ) ;
150  bool publishedBinaryFileReceived(const Hash& aFingerPrint,
151  const QByteArray& aContent,
152  const QByteArray& aSignature,
153  const QList<quint32>& aBangPath,
154  const QByteArray& aKeyOfPublisher,
155  const unsigned char aFlags,
156  const quint32 aTimeStamp,
157  const Hash& aFromNode ) ;
172  bool sentBinaryFileReceived(const Hash& aFingerPrint,
173  const QByteArray& aContent,
174  const QByteArray& aSignature,
175  const QByteArray& aKeyOfPublisher,
176  const unsigned char aFlags,
177  const quint32 aTimeStamp,
178  const Hash& aFromNode ) ;
186  bool binaryFileDataForPublish(const Hash& aFingerPrint,
187  QByteArray& aResultingBinaryFileData,
188  QByteArray& aResultingSignature,
189  QByteArray& aPublicKeyOfPublisher,
190  bool* aIsBinaryFilePrivate,
191  bool* iIsBinaryFileCompressed ) ;
198  bool binaryFileDataForSend(const Hash& aFingerPrint,
199  QByteArray& aResultingBinaryFileData,
200  QByteArray& aResultingSignature,
201  QByteArray& aPublicKeyOfPublisher,
202  bool* aIsBinaryFilePrivate,
203  bool* aIsBinaryFileCompressed,
204  quint32* aTimeOfPublish) ;
228  void fillBucket(QList<SendQueueItem>& aSendQueue,
229  const Hash& aStartOfBucket,
230  const Hash& aEndOfBucket,
231  quint32 aLastMutualConnectTime,
232  const Hash& aForNode );
233 signals:
235  const QString& aExplanation) ;
236  void contentReceived(const Hash& aHashOfContent,
237  const ProtocolItemType aTypeOfReceivdContent) ;
238 private: // methods
240  bool doFindBinaryFileForPublishOrSend(const Hash& aFingerPrint,
241  QByteArray& aResultingBinaryFileData,
242  QByteArray& aResultingSignature,
243  QByteArray& aPublicKeyOfPublisher,
244  bool* aIsBinaryFilePrivate,
245  bool* aIsBinaryFileCompressed,
246  quint32* aTimeOfPublish) ;
250  bool doHandleReceivedFile(const Hash& aFingerPrint,
251  const QByteArray& aContent,
252  const QByteArray& aSignature,
253  const QList<quint32>& aBangPath,
254  const QByteArray& aKeyOfPublisher,
255  const unsigned char aFlags,
256  const quint32 aTimeStamp,
257  const bool aWasPublish,
258  const Hash& aFromNode ) ;
259 private: // member variables:
262 } ;
263 #endif
bool binaryFileDataByFingerPrint(const Hash &aFingerPrint, const Hash &aPresumedSender, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, bool *aIsBinaryFilePrivate)
MController * iController
Definition: binaryfilemodel.h:260
bool sentBinaryFileReceived(const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode)
bool doFindBinaryFileForPublishOrSend(const Hash &aFingerPrint, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, QByteArray &aPublicKeyOfPublisher, bool *aIsBinaryFilePrivate, bool *aIsBinaryFileCompressed, quint32 *aTimeOfPublish)
Hash is class that carries 160-bit digest.
Definition: hash.h:38
Definition: mcontroller.h:52
void error(MController::CAErrorSituation aError, const QString &aExplanation)
Definition: protocol.h:150
Carrier-class for binary blob.
Definition: binaryfile.h:37
bool binaryFileDataForSend(const Hash &aFingerPrint, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, QByteArray &aPublicKeyOfPublisher, bool *aIsBinaryFilePrivate, bool *aIsBinaryFileCompressed, quint32 *aTimeOfPublish)
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:45
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
void contentReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivdContent)
const MModelProtocolInterface & iModel
Definition: binaryfilemodel.h:261
bool binaryFileDataForPublish(const Hash &aFingerPrint, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, QByteArray &aPublicKeyOfPublisher, bool *aIsBinaryFilePrivate, bool *iIsBinaryFileCompressed)
BinaryFile * binaryFileByFingerPrint(const Hash &aFingerPrint)
bool doHandleReceivedFile(const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const bool aWasPublish, const Hash &aFromNode)
bool publishedBinaryFileReceived(const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode)
Carrier-class for user-profile data.
Definition: profile.h:37
BinaryFileModel(MController *aMController, const MModelProtocolInterface &aModel)
Hash publishBinaryFile(const Profile &aPublishingProfile, const QString &aFileName, const QString &aDescription, const QString &aMimeType, const QString &aOwner, const QString &aLicense, const QByteArray &aContents, bool aIsCompressed, bool aNoEncryption=false, const QList< Hash > *aBinaryRecipientList=NULL)
void fillBucket(QList< SendQueueItem > &aSendQueue, const Hash &aStartOfBucket, const Hash &aEndOfBucket, quint32 aLastMutualConnectTime, const Hash &aForNode)
This is part of datamodel for any binary blobs.
Definition: binaryfilemodel.h:39