1
/****************************************************************************
2
* Copyright (C) 2014 by Jens Nissen jens-chessx@gmx.net *
3
****************************************************************************/
5
#include "ficsclient.h"
8
FicsClient::FicsClient(QObject *parent):
13
void FicsClient::startSession()
15
QString account = AppSettings->getValue("/FICS/userName").toString();
16
QString passwd = AppSettings->getValue("/FICS/passWord").toString();
17
connectHost("freechess.org", 5000, account, passwd);
20
void FicsClient::sendAccept()
22
sendFicsCommand("accept");
25
void FicsClient::sendHistory()
27
sendFicsCommand("history");
30
void FicsClient::sendPlayRequest(int gameId)
32
QString cmd = QString("play %1").arg(gameId);
36
void FicsClient::sendCommand(QString s)
41
void FicsClient::sendObserve(int gameId)
43
QString cmd = QString("observe %1").arg(gameId);
47
void FicsClient::sendUnobserve(int gameId)
49
QString cmd = QString("unobserve %1").arg(gameId);
53
void FicsClient::sendFicsCommand(QString s)
58
void FicsClient::sendFicsCommandWithId(QString s, int id)
60
s.prepend(QString("%1 ").arg(id));
64
void FicsClient::OnSessionStarted()
66
sendFicsCommand("set seek 0");
67
sendFicsCommand("set style 12");
68
sendFicsCommand("set shout 0");
69
sendFicsCommand("set cshout 0");
70
sendFicsCommand("set gin 0");
71
sendFicsCommand("set pin 0");
72
sendFicsCommand("set mailmess 1");
73
sendFicsCommand("- channel 1");
74
sendFicsCommand("- channel 2");
75
sendFicsCommand("- channel 50");
76
sendFicsCommand("iset block 1");
77
sendFicsCommandWithId("history",1);
78
sendFicsCommandWithId("games",2);
81
void FicsClient::OnReceiveTelnetMessage(QString s)
83
if (s.startsWith(StartReply))
85
switch (s[3].toLatin1())
89
emit addNewHistoryEntry(s);
94
emit addNewGameEntry(s);