blob: a5474def72582f35fc2f9357132d6f6121ab029c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/***************************************************************************
io_internet.h - description
-------------------
begin : Thu Aug 16 2001
copyright : (C) 2003 by Troy Corbin Jr.
email : tcorbin@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef IO_INTERNET_H
#define IO_INTERNET_H
/* Local */
#include "definitions.h"
#include "io_base.h"
#include "match_param.h"
#include "command.h"
/* Tabs */
#include "tabmanager.h"
#include "console.h"
#include "challenge_graph.h"
#include "tab_seeklist.h"
class KSocket;
class KProcess;
class resource;
class core;
class dlg_login;
class dlg_challenge;
#include <tqfile.h>
/**
*@author Troy Corbin Jr / Alexander Wels.
*/
struct MatchRecord
{
int knightsID;
int serverID;
bool observing;
bool examining;
bool finished;
};
const int READ_BUFFER_SIZE = 64 * 1024; /* 64k is max ip packet size */
const int LOGIN_STAGE_NAME = 1;
const int LOGIN_STAGE_PASSWORD = 2;
const int LOGIN_STAGE_LOGGED_IN = 3;
const unsigned int NORMAL_MODE = 1;
const unsigned int UPDATE_SOUGHT_MODE = 2;
const unsigned int NEW_GAME_MODE = 3;
const unsigned int OBSERVE_GAME_MODE = 4;
const unsigned int CHALLENGE_MODE = 5;
const unsigned int PARSE_MOVE_LIST_MODE = 6;
const unsigned int PARSE12_MODE_NEW = 1;
const unsigned int PARSE12_MODE_MOVE = 2;
typedef TQMap<TQWidget *, TQWidget *> TabMap;
class io_internet : public io_base
{
Q_OBJECT
public:
io_internet(TQWidget *parent = NULL, resource *Rsrc = NULL);
~io_internet();
public slots:
virtual void recvCMD(const Command& command);
void readCommand(KSocket *);
void sendUserName(void);
void sendPassword(void);
void send(const TQString&);
void nullifyChallenge( void );
void acceptChallenge( void );
void declineChallenge( void );
void processSeekTimer( void );
void connectToServer( void );
void selfDestruct( void );
void setUserInfo(TQString userName, TQString passWord);
signals:
virtual void sendCMD(const Command& command);
void setLastPrivateSource( const TQString& );
void setLastChannelSource( const TQString& );
protected:
void parseLine(TQString command);
void parseLoginData(TQString command);
void writeToConsole(TQString text, TQString tag);
void updateSoughtList(TQString text);
void parseStyle12(TQString line, const unsigned int mode);
void sendUserSettings(void);
void parseMoveList(TQString data);
void sendEndOfGameCommand(TQString line);
private:
dlg_login *loginDlg;
dlg_challenge *challenge;
/* These are used to handle the automagic seek command */
TQTimer *seekTimer;
/* These are used for the connection & logon */
TQFile *Log;
KSocket *socket;
KProcess *myTimeseal;
struct serverResource *myServer;
int loginStage;
unsigned int parseMode;
TQString lastTag;
int ficsMoveListNumber;
TQString lineBuffer;
bool connected;
TQString userName;
TQString passWord;
/* communication with the server */
TQStringList command_list; /* this is a temp buffer while waiting for the movelist */
bool waiting_for_move_list;
TQMap<match_param *, int> fics_ids;
TQMap<int, int> fics_to_knights; /* maps fics id's to knights id's */
TabMap myTabList; /* maintains the list of the tabs currently owned by this io_internet */
TQValueList<Command> myCommandBuffer; /* this is a buffer for all the commands io_internet received while not connected to a server */
};
#endif
|