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 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_PARSER_H
23 #define PROTOCOL_MESSAGE_PARSER_H
24 #include "protocol.h"
25 #include <QObject>
26 #include <QHostAddress> // Q_IPV6ADDR
27 #include "node.h" // KNullIpv6Addr
28 #include "connection.h"
29 class MController ;
32 class Connection ;
39 class ProtocolMessageParser : public QObject {
40  Q_OBJECT
41 public:
42  ProtocolMessageParser (MController &aController,
43  MModelProtocolInterface &aModel) ;
44 
50  bool parseMessage(const QByteArray& aGoodFood,
51  Connection& aConnection ) ;
52 private: // private methods for doing the actual work
54  bool parseNodeGreetingV1(const QByteArray& aSingleNodeGreeting,
55  const Connection &aConnection ) ;
61  bool parseMultipleNodeGreetingsV1(const QByteArray& aGoodFood,
62  const Connection& aConnection ) ;
73  bool uintFromPosition(const QByteArray& aGoodFood,
74  const int aPos,
75  quint32* aResult) const ;
85  bool hashFromPosition(const QByteArray& aGoodFood,
86  const int aPos,
87  Hash* aResultHash) const ;
88 
93  bool parseRequestForObjectsAroundHash(const QByteArray& aNodeRefRequest,
94  const Connection &aConnection ) ;
104  bool parseContentPublishedOrSent(const unsigned char aProtocolItemType,
105  const QByteArray& aPublishedContent,
106  const Connection &aConnection ) ;
112  bool parsePrivMsgPublishedOrSent(const unsigned char aProtocolItemType,
113  const QByteArray& aPublishedContent,
114  const Connection &aConnection ) ;
115 
121  bool parseProfileCommentPublishedOrSent(const unsigned char aProtocolItemType,
122  const QByteArray& aPublishedContent,
123  const Connection &aConnection ) ;
124 
125 
132  bool parseAdsClassifiedAtHash( const QByteArray& aQueryBytes,
133  const Connection &aConnection) ;
139  bool parseListOfAdsClassifiedAtHash( const QByteArray& aQueryBytes,
140  const Connection &aConnection) ;
151  bool parseSearchRequest( const QByteArray& aQueryBytes,
152  Connection& aConnection) ;
162  bool parseSearchResults( const QByteArray& aQueryBytes,
163  const Connection& aConnection) ;
164 private:
167 } ;
168 #endif
Class containing routines for parsing protocol messages. Methods are mainly called from network conne...
Definition: protocol_message_parser.h:39
MModelProtocolInterface & iModel
Definition: protocol_message_parser.h:166
bool parseNodeGreetingV1(const QByteArray &aSingleNodeGreeting, 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:37
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:44
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:39
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:165
Pure-virtual interface of nodemodel.
Definition: mnodemodelprotocolinterface.h:38
bool parseProfileCommentPublishedOrSent(const unsigned char aProtocolItemType, const QByteArray &aPublishedContent, const Connection &aConnection)
Class that represents a network connection.
Definition: connection.h:41
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