Allow building as monolithic app (no plugins) for easier developement.
[tagua/yd.git] / src / icsconnection.h
blobcaf1cdd8f6a1c12c845eb8dab2cf6aafea228b94
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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 typedef std::map<int, ICSGameData> GameList;
31 enum State {
32 Normal,
33 MoveListHeader,
34 MoveListMoves
35 } state;
37 // patterns
38 static QRegExp pressReturn;
39 static QRegExp creating;
40 static QRegExp game;
41 static QRegExp login;
42 static QRegExp password;
43 static QRegExp fics;
44 static QRegExp beep;
45 static QRegExp unexamine, unobserve;
46 static QRegExp move_list_start, move_list_players, move_list_game,
47 move_list_ignore1, move_list_ignore2, move_list_terminator;
48 static QRegExp observed_game;
49 static QRegExp goForward, goBack;
51 GameInfo* incomingGameInfo;
52 int m_processed_offset;
53 GameList m_games;
55 int m_move_list_game_num;
56 QStringList m_move_list_players;
57 GameInfo *m_move_list_game_info;
58 PositionInfo *m_move_list_position_info;
59 PoolInfo *m_move_list_pool_info;
60 QString m_move_list;
62 bool test(const QRegExp& pattern, const QString& str);
63 public:
64 ICSConnection();
66 void setListener(int gameNumber, const boost::weak_ptr<ICSListener>& listener);
67 void startup();
68 public Q_SLOTS:
69 void process(QString str);
70 void processPartialLine(QString str);
71 Q_SIGNALS:
72 void notification();
73 void moves(const PGN&);
74 void time(int, int);
75 void loginPrompt();
76 void passwordPrompt();
77 void prompt();
78 void registeredNickname();
79 void creatingGame(const GameInfo*, const PositionInfo&);
80 void creatingExaminedGame(const GameInfo*, const PositionInfo&);
81 void creatingObservedGame(const GameInfo*, const PositionInfo&);
82 void endingGame(const QString&, const QString&);
83 void endingExaminedGame(int);
84 void endingObservedGame(int);
87 #endif // ICSCONNECTION_H