ircctcpparser.h
1 //------------------------------------------------------------------------------
2 // ircctcpparser.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2014 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef id14670887_AF0E_4EAD_9A495B9E413C6723
24 #define id14670887_AF0E_4EAD_9A495B9E413C6723
25 
26 #include "dptr.h"
27 
28 #include <QObject>
29 #include <QString>
30 
31 class IRCNetworkAdapter;
32 
33 class IRCCtcpParser : public QObject
34 {
35  Q_OBJECT
36 
37 public:
38  enum CtcpEcho
39  {
40  PrintAsNormalMessage,
41  DisplayInServerTab,
42  DisplayThroughGlobalMessage,
43  DontShow
44  };
45 
47  {
56  };
57 
58  IRCCtcpParser(IRCNetworkAdapter *network, const QString &sender,
59  const QString &recipient, const QString &msg, MessageType msgType);
60  ~IRCCtcpParser() override;
61 
62  CtcpEcho echo() const;
63  bool parse();
64  const QString &printable() const;
65  const QString &reply() const;
66 
67 private:
69 
70  bool isCommand(const QString &candidate);
71  bool isCtcp() const;
75  void tokenizeMsg();
76  QString typeToName() const;
77 };
78 
79 
80 #endif