~ubuntu-branches/ubuntu/maverick/qgo/maverick

« back to all changes in this revision

Viewing changes to src/igsconnection.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin A. Godisch
  • Date: 2005-01-01 23:07:10 UTC
  • Revision ID: james.westby@ubuntu.com-20050101230710-fhng6yidm47xlb2i
Tags: upstream-1.0.0-r2
ImportĀ upstreamĀ versionĀ 1.0.0-r2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
 * igsconnection.h
 
4
 
 
5
 */
 
6
 
 
7
#ifndef IGSCONNECTION_H
 
8
#define IGSCONNECTION_H
 
9
 
 
10
#include "igsinterface.h"
 
11
#include <qobject.h>
 
12
#include <qsocket.h>
 
13
#include <qstring.h>
 
14
 
 
15
#define MAX_LINESIZE 512
 
16
 
 
17
class IGSConnection : public QObject, public IGSInterface
 
18
{
 
19
        Q_OBJECT
 
20
 
 
21
public:
 
22
        IGSConnection();
 
23
        virtual ~IGSConnection();
 
24
 
 
25
        // Implementation of IGSInterface virtual functions
 
26
        virtual bool isConnected();
 
27
        virtual bool openConnection(const char *host, unsigned port,
 
28
                                                                const char *user=0, const char *pass=0);
 
29
        virtual bool closeConnection();
 
30
        virtual void sendTextToHost(const char *txt);
 
31
        virtual void sendTextToHost(QString *txt);
 
32
        
 
33
        virtual const char* getUsername();
 
34
 
 
35
signals:
 
36
        // for statistics reason
 
37
        void signal_setBytesIn(int);
 
38
        void signal_setBytesOut(int);
 
39
 
 
40
protected:
 
41
        virtual bool checkPrompt();
 
42
//      void convertBlockToLines();
 
43
        
 
44
        void sendTextToApp(const char *txt, unsigned int size);
 
45
        void sendTextToApp(const char *s);
 
46
        void sendTextToApp(QString *txt);
 
47
        void sendTextToApp(QCString *txt);
 
48
 
 
49
private slots:
 
50
        void OnHostFound();
 
51
        void OnConnected();
 
52
        void OnReadyRead();
 
53
        void OnConnectionClosed();
 
54
        void OnDelayedCloseFinish();
 
55
        void OnBytesWritten(int);
 
56
        void OnError(int);
 
57
 
 
58
private:
 
59
        QSocket *qsocket;
 
60
 
 
61
        //struct USERINFO {
 
62
        QString username;
 
63
        QString password;
 
64
        //}  userInfo;
 
65
 
 
66
        enum {
 
67
                LOGIN,  // parse will search for login prompt
 
68
                PASSWORD,       // parse will search for password prompt
 
69
                SESSION,        // logged in
 
70
                AUTH_FAILED     // wrong user/pass  
 
71
        } authState;
 
72
 
 
73
        QString bufferLineRest;
 
74
};
 
75
 
 
76
#endif
 
77