Classified ads
protocol_message_formatter.h
Go to the documentation of this file.
1 /* -*-C++-*-
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
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 
42 public:
51  static QByteArray nodeGreeting(const Node& aNode) ;
58  static QByteArray randomNumbers(void) ;
59 
66  static QByteArray requestForNodesAroundHash (const Hash& aHash) ;
67 
74  static QByteArray requestForBinaryBlob(const Hash& aHash) ;
81  static QByteArray requestForUserProfile(const Hash& aHash) ;
89  static QByteArray requestForUserProfileComment(const Hash& aIndividualCommentHash) ;
96  static QByteArray requestForClassifiedAd(const Hash& aHash) ;
105  static QByteArray requestForPrivateMessages(const Hash& aMessageHash) ;
115  static QByteArray requestForPrivateMessagesForProfile(const Hash& aProfileHash,
116  const quint32 aTimeOfOldestMsgToSend) ;
131  static QByteArray requestForProfileComments(const Hash& aCommentedProfileHash,
132  const quint32 aTimeOfOldestMsgToSend) ;
153  static QByteArray requestForAdsClassified(const Hash& aHashOfClassification,
154  const quint32 aStartingTimestamp,
155  const quint32 aEndingTimestamp) ;
189  static QByteArray contentPublish(const unsigned char aContentMagicNumber,
190  const Hash& aContentHash,
191  const QByteArray& aContent,
192  const QByteArray& aSignature,
193  const QList<quint32>& aBangPath,
194  const QByteArray& aSigningKey,
195  bool aIsContentEncrypted,
196  bool aIsContentCompressed,
197  quint32 aTimeStamp ) ;
202  static QByteArray privMsgPublish(const Hash& aContentHash,
203  const QByteArray& aContent,
204  const QByteArray& aSignature,
205  const QList<quint32>& aBangPath,
206  const Hash& aDestination,
207  const Hash& aRecipient,
208  quint32 aTimeStamp ) ;
214  static QByteArray privMsgSend(const Hash& aContentHash,
215  const QByteArray& aContent,
216  const QByteArray& aSignature,
217  const Hash& aDestination,
218  const Hash& aRecipient,
219  quint32 aTimeStamp ) ;
230  static QByteArray profileCommentPublish(const Hash& aContentHash,
231  const QByteArray& aContent,
232  const QByteArray& aSignature,
233  const QList<quint32>& aBangPath,
234  const Hash& aProfileCommented,
235  quint32 aTimeStamp,
236  quint32 aFlags ) ;
241  static QByteArray profileCommentSend(const Hash& aContentHash,
242  const QByteArray& aContent,
243  const QByteArray& aSignature,
244  const Hash& aProfileCommented,
245  quint32 aTimeStamp,
246  quint32 aFlags ) ;
253  static QByteArray contentSend(const unsigned char aContentMagicNumber,
254  const Hash& aContentHash,
255  const QByteArray& aContent,
256  const QByteArray& aSignature,
257  const QByteArray& aSigningKey,
258  bool aIsContentEncrypted,
259  bool aIsContentCompressed,
260  quint32 aTimeStamp ) ;
261 
262  static QByteArray replyToAdsClassified(const Hash& aClassificationHash,
263  const QList<QPair<Hash,quint32> >& aListOfAds ) ;
264 
268  static QByteArray searchSend(const QString& aSearch,
269  bool aSearchAds,
270  bool aSearchProfiles,
271  bool aSearchComments,
272  const Hash& aSearchIdentifier) ;
273 
277  static QByteArray searchResultsSend(const QList<SearchModel::SearchResultItem>& aResults,
278  quint32 aSearchId) ;
279 
290  static QByteArray voiceCall(const VoiceCall& aCall,
291  MController& aController,
292  const Hash& aSelectedProfile,
293  bool aDoSign = true ) ;
303  static QByteArray voiceCallRtData(quint32 aCallId,
304  quint32 aSeqNo,
305  VoiceCallEngine::PayloadType aPayloadType,
306  const QByteArray& aPayload ) ;
307 
308 private:
314  static QByteArray doContentSendOrPublish(QByteArray& retval,
315  const unsigned char aContentMagicNumber,
316  const Hash& aContentHash,
317  const QByteArray& aContent,
318  const QByteArray& aSignature,
319  const QList<quint32>& aBangPath,
320  const QByteArray& aSigningKey,
321  bool aIsContentEncrypted,
322  bool aIsContentCompressed,
323  quint32 aTimeStamp,
324  bool aIsPublish) ;
330  static QByteArray doCommentSendOrPublish(const Hash& aContentHash,
331  const QByteArray& aContent,
332  const QByteArray& aSignature,
333  const QList<quint32>& aBangPath,
334  const Hash& aProfileCommented,
335  quint32 aTimeStamp,
336  quint32 aFlags,
337  bool aIsPublish) ;
338 } ;
339 
340 #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 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 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:43
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 requestForAdsClassified(const Hash &aHashOfClassification, const quint32 aStartingTimestamp, const quint32 aEndingTimestamp)
This class produces items sent to peers over network.
Definition: protocol_message_formatter.h:41
static QByteArray searchResultsSend(const QList< SearchModel::SearchResultItem > &aResults, quint32 aSearchId)
Class that represents a network connection.
Definition: connection.h:43
static QByteArray requestForUserProfile(const Hash &aHash)
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)