Variants are not singletons anymore.
[tagua/yd.git] / src / icsconnection.h
blob2758f1955abd4076e3fc026e61110759878e2240
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef ICSCONNECTION_H
12 #define ICSCONNECTION_H
14 #include <map>
15 #include <boost/shared_ptr.hpp>
16 #include <QString>
17 #include <QStringList>
18 #include "connection.h"
19 #include "icsgamedata.h"
21 class GameInfo;
22 class PGN;
23 class PositionInfo;
24 class PoolInfo;
25 class ICSListener;
27 class ICSConnection : public Connection {
28 Q_OBJECT
29 private:
30 enum State {
31 Normal,
32 MoveListHeader,
33 MoveListMoves
34 } state;
36 // patterns
37 static QRegExp pressReturn;
38 static QRegExp creating;
39 static QRegExp game;
40 static QRegExp login;
41 static QRegExp password;
42 static QRegExp fics;
43 static QRegExp beep;
44 static QRegExp unexamine, unobserve;
45 static QRegExp move_list_start, move_list_players, move_list_game,
46 move_list_ignore1, move_list_ignore2, move_list_terminator;
47 static QRegExp observed_game;
48 static QRegExp goForward, goBack;
50 GameInfo* incomingGameInfo;
51 int m_processed_offset;
52 std::map<int, ICSGameData> m_games;
54 int m_move_list_game_num;
55 QStringList m_move_list_players;
56 GameInfo *m_move_list_game_info;
57 PositionInfo *m_move_list_position_info;
58 PoolInfo *m_move_list_pool_info;
59 QString m_move_list;
61 bool test(const QRegExp& pattern, const QString& str);
62 public:
63 ICSConnection();
65 void setListener(int gameNumber, const boost::weak_ptr<ICSListener>& listener);
66 void startup();
67 public Q_SLOTS:
68 void process(QString str);
69 void processPartialLine(QString str);
70 Q_SIGNALS:
71 void notification();
72 void moves(const PGN&);
73 void time(int, int);
74 void loginPrompt();
75 void passwordPrompt();
76 void prompt();
77 void registeredNickname();
78 void creatingGame(const GameInfo*, const PositionInfo&);
79 void creatingExaminedGame(const GameInfo*, const PositionInfo&);
80 void creatingObservedGame(const GameInfo*, const PositionInfo&);
81 void endingGame(const QString&, const QString&);
82 void endingExaminedGame(int);
83 void endingObservedGame(int);
86 #endif // ICSCONNECTION_H