Classified ads
protocol_message_formatter.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 2013-2017.
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 
22 
23 #ifndef PROTOCOL_MESSAGE_FORMATTER_H
24 #define PROTOCOL_MESSAGE_FORMATTER_H
25 #include "protocol.h"
26 #include <QByteArray>
27 #include <QPair>
28 #include "../datamodel/searchmodel.h"
29 #include "voicecallengine.h" // for payload type
30 
31 class Connection ;
32 class Node ;
33 class VoiceCall ; // from datamodel
34 class CaDbRecord ;
35 
43 public:
52  static QByteArray nodeGreeting(const Node& aNode) ;
59  static QByteArray randomNumbers(void) ;
60 
67  static QByteArray requestForNodesAroundHash (const Hash& aHash) ;
68 
75  static QByteArray requestForBinaryBlob(const Hash& aHash) ;
82  static QByteArray requestForUserProfile(const Hash& aHash) ;
90  static QByteArray requestForUserProfileComment(const Hash& aIndividualCommentHash) ;
97  static QByteArray requestForClassifiedAd(const Hash& aHash) ;
106  static QByteArray requestForPrivateMessages(const Hash& aMessageHash) ;
116  static QByteArray requestForPrivateMessagesForProfile(const Hash& aProfileHash,
117  const quint32 aTimeOfOldestMsgToSend) ;
132  static QByteArray requestForProfileComments(const Hash& aCommentedProfileHash,
133  const quint32 aTimeOfOldestMsgToSend) ;
154  static QByteArray requestForAdsClassified(const Hash& aHashOfClassification,
155  const quint32 aStartingTimestamp,
156  const quint32 aEndingTimestamp) ;
190  static QByteArray contentPublish(const unsigned char aContentMagicNumber,
191  const Hash& aContentHash,
192  const QByteArray& aContent,
193  const QByteArray& aSignature,
194  const QList<quint32>& aBangPath,
195  const QByteArray& aSigningKey,
196  bool aIsContentEncrypted,
197  bool aIsContentCompressed,
198  quint32 aTimeStamp ) ;
203  static QByteArray privMsgPublish(const Hash& aContentHash,
204  const QByteArray& aContent,
205  const QByteArray& aSignature,
206  const QList<quint32>& aBangPath,
207  const Hash& aDestination,
208  const Hash& aRecipient,
209  quint32 aTimeStamp ) ;
215  static QByteArray privMsgSend(const Hash& aContentHash,
216  const QByteArray& aContent,
217  const QByteArray& aSignature,
218  const Hash& aDestination,
219  const Hash& aRecipient,
220  quint32 aTimeStamp ) ;
231  static QByteArray profileCommentPublish(const Hash& aContentHash,
232  const QByteArray& aContent,
233  const QByteArray& aSignature,
234  const QList<quint32>& aBangPath,
235  const Hash& aProfileCommented,
236  quint32 aTimeStamp,
237  quint32 aFlags ) ;
238 
243  static QByteArray profileCommentSend(const Hash& aContentHash,
244  const QByteArray& aContent,
245  const QByteArray& aSignature,
246  const Hash& aProfileCommented,
247  quint32 aTimeStamp,
248  quint32 aFlags ) ;
255  static QByteArray dbRecordPublish(const CaDbRecord& aRecord,
256  const QList<quint32>& aBangPath) ;
261  static QByteArray dbRecordSend(const CaDbRecord& aRecord) ;
262 
269  static QByteArray contentSend(const unsigned char aContentMagicNumber,
270  const Hash& aContentHash,
271  const QByteArray& aContent,
272  const QByteArray& aSignature,
273  const QByteArray& aSigningKey,
274  bool aIsContentEncrypted,
275  bool aIsContentCompressed,
276  quint32 aTimeStamp ) ;
277 
278  static QByteArray replyToAdsClassified(const Hash& aClassificationHash,
279  const QList<QPair<Hash,quint32> >& aListOfAds ) ;
280 
284  static QByteArray searchSend(const QString& aSearch,
285  bool aSearchAds,
286  bool aSearchProfiles,
287  bool aSearchComments,
288  const Hash& aSearchIdentifier) ;
289 
293  static QByteArray searchResultsSend(const QList<SearchModel::SearchResultItem>& aResults,
294  quint32 aSearchId) ;
295 
300  static QByteArray dbSearchTerms(const CaDbRecord::SearchTerms aSearchTerms) ;
301 
312  static QByteArray voiceCall(const VoiceCall& aCall,
313  MController& aController,
314  const Hash& aSelectedProfile,
315  bool aDoSign = true ) ;
325  static QByteArray voiceCallRtData(quint32 aCallId,
326  quint32 aSeqNo,
327  VoiceCallEngine::PayloadType aPayloadType,
328  const QByteArray& aPayload ) ;
329 
330 private:
336  static QByteArray doContentSendOrPublish(QByteArray& retval,
337  const unsigned char aContentMagicNumber,
338  const Hash& aContentHash,
339  const QByteArray& aContent,
340  const QByteArray& aSignature,
341  const QList<quint32>& aBangPath,
342  const QByteArray& aSigningKey,
343  bool aIsContentEncrypted,
344  bool aIsContentCompressed,
345  quint32 aTimeStamp,
346  bool aIsPublish) ;
352  static QByteArray doCommentSendOrPublish(const Hash& aContentHash,
353  const QByteArray& aContent,
354  const QByteArray& aSignature,
355  const QList<quint32>& aBangPath,
356  const Hash& aProfileCommented,
357  quint32 aTimeStamp,
358  quint32 aFlags,
359  bool aIsPublish) ;
360 
370  static QByteArray doDbRecordPublishOrSend(const CaDbRecord& aRecord,
371  const QList<quint32>& aBangPath,
372  bool aIsPublish ) ;
373 } ;
374 
375 #endif
static QByteArray requestForProfileComments(const Hash &aCommentedProfileHash, const quint32 aTimeOfOldestMsgToSend)
static QByteArray requestForPrivateMessagesForProfile(const Hash &aProfileHash, const quint32 aTimeOfOldestMsgToSend)
Node is a peer in network.
Definition: node.h:40
static QByteArray replyToAdsClassified(const Hash &aClassificationHash, const QList< QPair< Hash, quint32 > > &aListOfAds)
static QByteArray voiceCallRtData(quint32 aCallId, quint32 aSeqNo, VoiceCallEngine::PayloadType aPayloadType, const QByteArray &aPayload)
static QByteArray profileCommentPublish(const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aProfileCommented, quint32 aTimeStamp, quint32 aFlags)
static QByteArray doDbRecordPublishOrSend(const CaDbRecord &aRecord, const QList< quint32 > &aBangPath, bool aIsPublish)
static QByteArray profileCommentSend(const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const Hash &aProfileCommented, quint32 aTimeStamp, quint32 aFlags)
Carrier-class handling audio negotiation setup and data.
Definition: voicecall.h:40
static QByteArray voiceCall(const VoiceCall &aCall, MController &aController, const Hash &aSelectedProfile, bool aDoSign=true)
Hash is class that carries 160-bit digest.
Definition: hash.h:38
static QByteArray requestForUserProfileComment(const Hash &aIndividualCommentHash)
static QByteArray randomNumbers(void)
static QByteArray doCommentSendOrPublish(const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aProfileCommented, quint32 aTimeStamp, quint32 aFlags, bool aIsPublish)
static QByteArray requestForPrivateMessages(const Hash &aMessageHash)
static QByteArray dbRecordPublish(const CaDbRecord &aRecord, const QList< quint32 > &aBangPath)
static QByteArray requestForClassifiedAd(const Hash &aHash)
static QByteArray requestForBinaryBlob(const Hash &aHash)
static QByteArray searchSend(const QString &aSearch, bool aSearchAds, bool aSearchProfiles, bool aSearchComments, const Hash &aSearchIdentifier)
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:48
static QByteArray contentPublish(const unsigned char aContentMagicNumber, const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aSigningKey, bool aIsContentEncrypted, bool aIsContentCompressed, quint32 aTimeStamp)
PayloadType
Definition: mvoicecallengine.h:63
static QByteArray doContentSendOrPublish(QByteArray &retval, const unsigned char aContentMagicNumber, const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aSigningKey, bool aIsContentEncrypted, bool aIsContentCompressed, quint32 aTimeStamp, bool aIsPublish)
static QByteArray privMsgPublish(const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aDestination, const Hash &aRecipient, quint32 aTimeStamp)
static QByteArray nodeGreeting(const Node &aNode)
static QByteArray contentSend(const unsigned char aContentMagicNumber, const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const QByteArray &aSigningKey, bool aIsContentEncrypted, bool aIsContentCompressed, quint32 aTimeStamp)
static QByteArray dbSearchTerms(const CaDbRecord::SearchTerms aSearchTerms)
static QByteArray requestForAdsClassified(const Hash &aHashOfClassification, const quint32 aStartingTimestamp, const quint32 aEndingTimestamp)
This class produces items sent to peers over network.
Definition: protocol_message_formatter.h:42
static QByteArray searchResultsSend(const QList< SearchModel::SearchResultItem > &aResults, quint32 aSearchId)
Class that represents a network connection.
Definition: connection.h:43
static QByteArray dbRecordSend(const CaDbRecord &aRecord)
Data record in distributed database.
Definition: cadbrecord.h:35
static QByteArray requestForUserProfile(const Hash &aHash)
Definition: cadbrecord.h:40
static QByteArray requestForNodesAroundHash(const Hash &aHash)
static QByteArray privMsgSend(const Hash &aContentHash, const QByteArray &aContent, const QByteArray &aSignature, const Hash &aDestination, const Hash &aRecipient, quint32 aTimeStamp)