~ubuntu-branches/ubuntu/trusty/znc/trusty

« back to all changes in this revision

Viewing changes to Listener.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-05-06 09:18:27 UTC
  • mfrom: (21.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20130506091827-08sixjiyy3hjfx6b
Tags: 1.0-4
* Change section from znc-tcl to interpreters.
* Uploading to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2004-2011  See the AUTHORS file for details.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify it
5
 
 * under the terms of the GNU General Public License version 2 as published
6
 
 * by the Free Software Foundation.
7
 
 */
8
 
 
9
 
#ifndef _LISTENER_H
10
 
#define _LISTENER_H
11
 
 
12
 
#include "zncconfig.h"
13
 
#include "Socket.h"
14
 
 
15
 
// Forward Declarations
16
 
class CRealListener;
17
 
// !Forward Declarations
18
 
 
19
 
class CListener {
20
 
public:
21
 
        typedef enum {
22
 
                ACCEPT_IRC,
23
 
                ACCEPT_HTTP,
24
 
                ACCEPT_ALL
25
 
        } EAcceptType;
26
 
 
27
 
        CListener(unsigned short uPort, const CString& sBindHost, bool bSSL, EAddrType eAddr, EAcceptType eAccept) {
28
 
                m_uPort = uPort;
29
 
                m_sBindHost = sBindHost;
30
 
                m_bSSL = bSSL;
31
 
                m_eAddr = eAddr;
32
 
                m_pListener = NULL;
33
 
                m_eAcceptType = eAccept;
34
 
        }
35
 
 
36
 
        ~CListener();
37
 
 
38
 
        // Getters
39
 
        bool IsSSL() const { return m_bSSL; }
40
 
        EAddrType GetAddrType() const { return m_eAddr; }
41
 
        unsigned short GetPort() const { return m_uPort; }
42
 
        const CString& GetBindHost() const { return m_sBindHost; }
43
 
        CRealListener* GetRealListener() const { return m_pListener; }
44
 
        EAcceptType GetAcceptType() const { return m_eAcceptType; }
45
 
        // !Getters
46
 
 
47
 
        // It doesn't make sense to change any of the settings after Listen()
48
 
        // except this one, so don't add other setters!
49
 
        void SetAcceptType(EAcceptType eType) { m_eAcceptType = eType; }
50
 
 
51
 
        bool Listen();
52
 
        void ResetRealListener();
53
 
 
54
 
private:
55
 
protected:
56
 
        bool            m_bSSL;
57
 
        EAddrType       m_eAddr;
58
 
        unsigned short  m_uPort;
59
 
        CString         m_sBindHost;
60
 
        CRealListener*  m_pListener;
61
 
        EAcceptType     m_eAcceptType;
62
 
};
63
 
 
64
 
class CRealListener : public CZNCSock {
65
 
public:
66
 
        CRealListener(CListener *pParent) : CZNCSock(), m_pParent(pParent) {}
67
 
        virtual ~CRealListener();
68
 
 
69
 
        virtual bool ConnectionFrom(const CString& sHost, unsigned short uPort);
70
 
        virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort);
71
 
        virtual void SockError(int iErrno);
72
 
 
73
 
private:
74
 
        CListener* m_pParent;
75
 
};
76
 
 
77
 
class CIncomingConnection : public CZNCSock {
78
 
public:
79
 
        CIncomingConnection(const CString& sHostname, unsigned short uPort, CListener::EAcceptType eAcceptType);
80
 
        virtual ~CIncomingConnection() {}
81
 
        virtual void ReadLine(const CString& sData);
82
 
        virtual void ReachedMaxBuffer();
83
 
 
84
 
private:
85
 
        CListener::EAcceptType m_eAcceptType;
86
 
};
87
 
 
88
 
#endif // !_LISTENER_H