Classified ads
protocol_message_parser.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 
22 
23 #ifndef PROTOCOL_MESSAGE_PARSER_H
24 #define PROTOCOL_MESSAGE_PARSER_H
25 #include "protocol.h"
26 #include <QObject>
27 #include <QHostAddress> // Q_IPV6ADDR
28 #include "node.h" // KNullIpv6Addr
29 #include "connection.h"
30 class MController ;
33 class Connection ;
40 class ProtocolMessageParser : public QObject {
41  Q_OBJECT
42 public:
43  ProtocolMessageParser (MController &aController,
44  MModelProtocolInterface &aModel) ;
45 
51  bool parseMessage(const QByteArray& aGoodFood,
52  Connection& aConnection ) ;
53 private: // private methods for doing the actual work
55  bool parseNodeGreetingV1(const QByteArray& aSingleNodeGreeting,
56  const Connection &aConnection ) ;
62  bool parseMultipleNodeGreetingsV1(const QByteArray& aGoodFood,
63  const Connection& aConnection ) ;
74  bool uintFromPosition(const QByteArray& aGoodFood,
75  const int aPos,
76  quint32* aResult) const ;
86  bool hashFromPosition(const QByteArray& aGoodFood,
87  const int aPos,
88  Hash* aResultHash) const ;
89 
94  bool parseRequestForObjectsAroundHash(const QByteArray& aNodeRefRequest,
95  const Connection &aConnection ) ;
105  bool parseContentPublishedOrSent(const unsigned char aProtocolItemType,
106  const QByteArray& aPublishedContent,
107  const Connection &aConnection ) ;
113  bool parsePrivMsgPublishedOrSent(const unsigned char aProtocolItemType,
114  const QByteArray& aPublishedContent,
115  const Connection &aConnection ) ;
116 
122  bool parseProfileCommentPublishedOrSent(const unsigned char aProtocolItemType,
123  const QByteArray& aPublishedContent,
124  const Connection &aConnection ) ;
125 
126 
133  bool parseAdsClassifiedAtHash( const QByteArray& aQueryBytes,
134  const Connection &aConnection) ;
140  bool parseListOfAdsClassifiedAtHash( const QByteArray& aQueryBytes,
141  const Connection &aConnection) ;
152  bool parseSearchRequest( const QByteArray& aQueryBytes,
153  Connection& aConnection) ;
163  bool parseSearchResults( const QByteArray& aQueryBytes,
164  const Connection& aConnection) ;
173  bool parseVoiceCall( const QByteArray& aQueryBytes,
174  const Connection& aConnection) ;
175 
185  bool parseCallRtData( const QByteArray& aQueryBytes,
186  const Connection& aConnection) ;
187 private:
190 } ;
191 #endif
Class containing routines for parsing protocol messages. Methods are mainly called from network conne...
Definition: protocol_message_parser.h:40
MModelProtocolInterface & iModel
Definition: protocol_message_parser.h:189
bool parseCallRtData(const QByteArray &aQueryBytes, const Connection &aConnection)
bool parseNodeGreetingV1(const QByteArray &aSingleNodeGreeting, const Connection &aConnection)
bool parseVoiceCall(const QByteArray &aQueryBytes, const Connection &aConnection)
bool parseRequestForObjectsAroundHash(const QByteArray &aNodeRefRequest, const Connection &aConnection)
bool parsePrivMsgPublishedOrSent(const unsigned char aProtocolItemType, const QByteArray &aPublishedContent, const Connection &aConnection)
bool parseAdsClassifiedAtHash(const QByteArray &aQueryBytes, const Connection &aConnection)
Hash is class that carries 160-bit digest.
Definition: hash.h:38
ProtocolMessageParser(MController &aController, MModelProtocolInterface &aModel)
bool parseSearchResults(const QByteArray &aQueryBytes, const Connection &aConnection)
Pure-virtual interface of datamodel for message parser to use.
Definition: mmodelprotocolinterface.h:45
bool uintFromPosition(const QByteArray &aGoodFood, const int aPos, quint32 *aResult) const
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:43
bool parseListOfAdsClassifiedAtHash(const QByteArray &aQueryBytes, const Connection &aConnection)
bool parseContentPublishedOrSent(const unsigned char aProtocolItemType, const QByteArray &aPublishedContent, const Connection &aConnection)
bool parseSearchRequest(const QByteArray &aQueryBytes, Connection &aConnection)
MController & iController
Definition: protocol_message_parser.h:188
Pure-virtual interface of nodemodel.
Definition: mnodemodelprotocolinterface.h:39
bool parseProfileCommentPublishedOrSent(const unsigned char aProtocolItemType, const QByteArray &aPublishedContent, const Connection &aConnection)
Class that represents a network connection.
Definition: connection.h:43
bool parseMessage(const QByteArray &aGoodFood, Connection &aConnection)
bool parseMultipleNodeGreetingsV1(const QByteArray &aGoodFood, const Connection &aConnection)
bool hashFromPosition(const QByteArray &aGoodFood, const int aPos, Hash *aResultHash) const