Debian Codegraph @

src/network/igsconnection.h

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2009 by The qGo Project *
3 * *
4 * This file is part of qGo. *
5 * *
6 * qGo 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 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 this program; if not, see <http://www.gnu.org/licenses/> *
18 * or write to the Free Software Foundation, Inc., *
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
21
22
23 #ifndef IGSCONNECTION_H
24 #define IGSCONNECTION_H
25 #include <QtNetwork>
26 #include "networkconnection.h"
27 #include "messages.h"
28 #include "gamedata.h"
29
30 class BoardDispatch;
31 class GameDialog;
32 class Talk;
33
34 class IGSConnection : public NetworkConnection
35 {
36 public:
37 IGSConnection(const ConnectionCredentials credentials);
38 ~IGSConnection();
39 virtual QString getPlaceString();
40 virtual void sendText(QString text);
41 virtual void sendText(const char * text);
42 virtual void sendDisconnect(void);
43 virtual void sendMsg(unsigned int game_id, QString text);
44 virtual void sendMsg(PlayerListing * player, QString text);
45 virtual void sendToggle(const QString & param, bool val);
46 virtual void sendObserve(const GameListing * game);
47 virtual void stopObserving(const GameListing * game);
48 virtual void stopReviewing(const GameListing * game);
49 virtual void sendStatsRequest(const PlayerListing * opponent);
50 virtual void sendPlayersRequest(void);
51 virtual void sendGamesRequest(void);
52 void sendRoomListRequest(void);
53 virtual void sendMatchInvite(const PlayerListing * player);
54 virtual void sendAddTime(int);
55 virtual void adjournGame(const GameListing * game);
56 virtual void sendMove(unsigned int game_id, class MoveRecord * move);
57 virtual void sendMatchRequest(class MatchRequest * mr);
58 virtual void declineMatchOffer(const PlayerListing * opponent);
59 virtual void acceptMatchOffer(const PlayerListing * opponent, class MatchRequest * mr);
60 virtual QTime gd_checkMainTime(TimeSystem s, const QTime & t);
61 virtual QTime gd_checkPeriodTime(TimeSystem s, const QTime & t);
62 virtual unsigned int gd_checkPeriods(TimeSystem s, unsigned int p);
63 virtual void sendAdjournRequest(void);
64 virtual void sendAdjourn(void);
65 virtual void sendRefuseAdjourn(void);
66 virtual void handlePendingData();
67 virtual void onReady(void);
68
69 virtual void sendJoinRoom(const RoomListing & room, const char * password = 0);
70 virtual void sendJoinChannel(const ChannelListing & channel);
71 virtual void sendSeek(class SeekCondition *);
72 virtual void sendSeekCancel(void);
73
74 BoardDispatch * getBoardFromAttrib(QString black_player, unsigned int black_captures, float black_komi, QString white_player, unsigned int white_captures, float white_komi);
75 BoardDispatch * getBoardFromOurOpponent(QString opponent);
76
77 virtual void requestGameInfo(unsigned int game_id);
78 virtual void requestGameStats(unsigned int game_id);
79
80 virtual unsigned int rankToScore(QString rank);
81 /* I thought we didn't start time until after first move
82 * but I check today and we do, so I'll change it... doublecheck */
83 virtual bool startTimerOnOpen(void) { return true; }
84 virtual bool flipCoords(void) { return false; }
85 virtual bool supportsRequestAdjourn(void) { return true; }
86 virtual bool supportsAddTime(void) { return true; }
87 virtual bool undoResetsScore(void) { return true; }
88 virtual bool supportsSeek(void) { return true; }
89 virtual unsigned long getPlayerListColumns(void) { return PL_NOWINSLOSSES; }
90 virtual bool supportsChannels(void) { return true; }
91 virtual bool supportsRefreshListsButtons(void) { return true; }
92 virtual bool consoleIsChat(void) { return false; }
93 virtual unsigned long getGameDialogFlags(void);
94 virtual unsigned long getRoomStructureFlags(void) { return (RS_SHORTROOMLIST | RS_ONEROOMATATIME); }
95
96 protected:
97 virtual void onAuthenticationNegotiated(void);
98 virtual void setKeepAlive(int);
99 void handleLogin(QString msg);
100 void handlePassword(QString msg);
101 void handleMessage(QString msg);
102
103 void handle_loginmsg(QString line);
104 void handle_prompt(QString line);
105 void handle_beep(QString line);
106 void handle_down(QString line);
107 void handle_error(QString line);
108 void handle_games(QString line);
109 void handle_file(QString line);
110 virtual void handle_info(QString line);
111 virtual void handle_kibitz(QString line);
112 void handle_messages(QString line);
113 void handle_move(QString line);
114 void handle_say(QString line);
115 void handle_score_m(QString line);
116 void handle_shout(QString line);
117 void handle_status(QString line);
118 void handle_stored(QString line);
119 void handle_tell(QString line);
120 void handle_thist(QString line);
121 void handle_who(QString line);
122 void handle_undo(QString line);
123 void handle_yell(QString line);
124 void handle_automatch(QString line);
125 void handle_serverinfo(QString line);
126 void handle_dot(QString line);
127 void handle_userlist(QString line);
128 void handle_removed(QString line);
129 void handle_ingamesay(QString line);
130 void handle_adjourndeclined(QString line);
131 void handle_seek(QString line);
132 void handle_review(QString line);
133
134 void handleRemovingAt(unsigned int game, QString pt);
135 void sendToggleClientOn(void);
136 void sendListChannels(void);
137
138 QString element(const QString &line, int index, const QString &del1, const QString &del2="", bool killblanks=false);
139 unsigned int idleTimeToSeconds(QString time);
140 void fixRankString(QString * rank);
141 PlayerListing * getPlayerListingNeverFail(QString & name);
142
143 int keepAliveTimer;
144 int playersListRefreshTimer;
145 int gamesListRefreshTimer;
146
147 QString protocol_save_string;
148 int protocol_save_int;
149 ChannelListing * channel;
150 int game_were_playing;
151 QString match_playerName;
152 TimeRecord * btime, * wtime;
153
154 //private:
155 int time_to_seconds(const QString & time);
156
157 QTextCodec * textCodec;
158
159 virtual void timerEvent(QTimerEvent*);
160 private:
161 void init(void);
162 void sendNmatchParameters(void);
163 void setCurrentRoom(const RoomListing & room) { currentRoom = &room; }
164 const RoomListing * getCurrentRoom(void) { return currentRoom; }
165
166 bool guestAccount;
167 bool needToSendClientToggle;
168 const RoomListing * currentRoom;
169 };
170
171 #endif //IGSCONNECTION_H