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 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 
21 
22 #ifndef PROTOCOL_MESSAGE_FORMATTER_H
23 #define PROTOCOL_MESSAGE_FORMATTER_H
24 #include "protocol.h"
25 #include <QByteArray>
26 #include <QPair>
27 #include "../datamodel/searchmodel.h"
28 
29 class Connection ;
30 class Node ;
31 
39 public:
48  static QByteArray nodeGreeting(const Node& aNode) ;
55  static QByteArray randomNumbers(void) ;
56 
63  static QByteArray requestForNodesAroundHash (const Hash& aHash) ;
64 
71  static QByteArray requestForBinaryBlob(const Hash& aHash) ;
78  static QByteArray requestForUserProfile(const Hash& aHash) ;
86  static QByteArray requestForUserProfileComment(const Hash& aIndividualCommentHash) ;
93  static QByteArray requestForClassifiedAd(const Hash& aHash) ;
102  static QByteArray requestForPrivateMessages(const Hash& aMessageHash) ;
112  static QByteArray requestForPrivateMessagesForProfile(const Hash& aProfileHash,
113  const quint32 aTimeOfOldestMsgToSend) ;
128  static QByteArray requestForProfileComments(const Hash& aCommentedProfileHash,
129  const quint32 aTimeOfOldestMsgToSend) ;
150  static QByteArray requestForAdsClassified(const Hash& aHashOfClassification,
151  const quint32 aStartingTimestamp,
152  const quint32 aEndingTimestamp) ;
186  static QByteArray contentPublish(const unsigned char aContentMagicNumber,
187  const Hash& aContentHash,
188  const QByteArray& aContent,
189  const QByteArray& aSignature,
190  const QList<quint32>& aBangPath,
191  const QByteArray& aSigningKey,
192  bool aIsContentEncrypted,
193  bool aIsContentCompressed,
194  quint32 aTimeStamp ) ;
199  static QByteArray privMsgPublish(const Hash& aContentHash,
200  const QByteArray& aContent,
201  const QByteArray& aSignature,
202  const QList<quint32>& aBangPath,
203  const Hash& aDestination,
204  const Hash& aRecipient,
205  quint32 aTimeStamp ) ;
211  static QByteArray privMsgSend(const Hash& aContentHash,
212  const QByteArray& aContent,
213  const QByteArray& aSignature,
214  const Hash& aDestination,
215  const Hash& aRecipient,
216  quint32 aTimeStamp ) ;
227  static QByteArray profileCommentPublish(const Hash& aContentHash,
228  const QByteArray& aContent,
229  const QByteArray& aSignature,
230  const QList<quint32>& aBangPath,
231  const Hash& aProfileCommented,
232  quint32 aTimeStamp,
233  quint32 aFlags ) ;
238  static QByteArray profileCommentSend(const Hash& aContentHash,
239  const QByteArray& aContent,
240  const QByteArray& aSignature,
241  const Hash& aProfileCommented,
242  quint32 aTimeStamp,
243  quint32 aFlags ) ;
250  static QByteArray contentSend(const unsigned char aContentMagicNumber,
251  const Hash& aContentHash,
252  const QByteArray& aContent,
253  const QByteArray& aSignature,
254  const QByteArray& aSigningKey,
255  bool aIsContentEncrypted,
256  bool aIsContentCompressed,
257  quint32 aTimeStamp ) ;
258 
259  static QByteArray replyToAdsClassified(const Hash& aClassificationHash,
260  const QList<QPair<Hash,quint32> >& aListOfAds ) ;
261 
265  static QByteArray searchSend(const QString& aSearch,
266  bool aSearchAds,
267  bool aSearchProfiles,
268  bool aSearchComments,
269  const Hash& aSearchIdentifier) ;
270 
274  static QByteArray searchResultsSend(const QList<SearchModel::SearchResultItem>& aResults,
275  quint32 aSearchId) ;
276 
277 private:
283  static QByteArray doContentSendOrPublish(QByteArray& retval,
284  const unsigned char aContentMagicNumber,
285  const Hash& aContentHash,
286  const QByteArray& aContent,
287  const QByteArray& aSignature,
288  const QList<quint32>& aBangPath,
289  const QByteArray& aSigningKey,
290  bool aIsContentEncrypted,
291  bool aIsContentCompressed,
292  quint32 aTimeStamp,
293  bool aIsPublish) ;
299  static QByteArray doCommentSendOrPublish(const Hash& aContentHash,
300  const QByteArray& aContent,
301  const QByteArray& aSignature,
302  const QList<quint32>& aBangPath,
303  const Hash& aProfileCommented,
304  quint32 aTimeStamp,
305  quint32 aFlags,
306  bool aIsPublish) ;
307 } ;
308 
309 #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:39
static QByteArray replyToAdsClassified(const Hash &aClassificationHash, const QList< QPair< Hash, quint32 > > &aListOfAds)
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)
Hash is class that carries 160-bit digest.
Definition: hash.h:37
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)
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)
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:38
static QByteArray searchResultsSend(const QList< SearchModel::SearchResultItem > &aResults, quint32 aSearchId)
Class that represents a network connection.
Definition: connection.h:41
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)