~ubuntu-branches/ubuntu/maverick/znc/maverick

« back to all changes in this revision

Viewing changes to Listener.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2010-05-24 18:05:44 UTC
  • mfrom: (1.3.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100524180544-8e4s3f4nj0lhyw7n
Tags: 0.090~rc1-1
* New upstream release candidate.
  - Drop znc-webadmin package. It is now provided in the core source code.
  - Rename discon_kick module to disconkick.
  - Add charset and notes module.
* Add missing dependency on libc-ares-dev to znc-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2004-2010  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 "znc.h"
 
13
 
 
14
// Forward Declarations
 
15
class CRealListener;
 
16
// !Forward Declarations
 
17
 
 
18
class CListener {
 
19
public:
 
20
        typedef enum {
 
21
                ACCEPT_IRC,
 
22
                ACCEPT_HTTP,
 
23
                ACCEPT_ALL
 
24
        } EAcceptType;
 
25
 
 
26
        CListener(unsigned short uPort, const CString& sBindHost, bool bSSL, EAddrType eAddr, EAcceptType eAccept) {
 
27
                m_uPort = uPort;
 
28
                m_sBindHost = sBindHost;
 
29
                m_bSSL = bSSL;
 
30
                m_eAddr = eAddr;
 
31
                m_pListener = NULL;
 
32
                m_eAcceptType = eAccept;
 
33
        }
 
34
 
 
35
        ~CListener();
 
36
 
 
37
        // Getters
 
38
        bool IsSSL() const { return m_bSSL; }
 
39
        EAddrType GetAddrType() const { return m_eAddr; }
 
40
        unsigned short GetPort() const { return m_uPort; }
 
41
        const CString& GetBindHost() const { return m_sBindHost; }
 
42
        CRealListener* GetRealListener() const { return m_pListener; }
 
43
        EAcceptType GetAcceptType() const { return m_eAcceptType; }
 
44
        // !Getters
 
45
 
 
46
        // It doesn't make sense to change any of the settings after Listen()
 
47
        // except this one, so don't add other setters!
 
48
        void SetAcceptType(EAcceptType eType) { m_eAcceptType = eType; }
 
49
 
 
50
        bool Listen();
 
51
        void ResetRealListener();
 
52
 
 
53
private:
 
54
protected:
 
55
        bool            m_bSSL;
 
56
        EAddrType       m_eAddr;
 
57
        unsigned short  m_uPort;
 
58
        CString         m_sBindHost;
 
59
        CRealListener*  m_pListener;
 
60
        EAcceptType     m_eAcceptType;
 
61
};
 
62
 
 
63
class CRealListener : public CZNCSock {
 
64
public:
 
65
        CRealListener(CListener *pParent) : CZNCSock(), m_pParent(pParent) {}
 
66
        virtual ~CRealListener();
 
67
 
 
68
        virtual bool ConnectionFrom(const CString& sHost, unsigned short uPort);
 
69
        virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort);
 
70
        virtual void SockError(int iErrno);
 
71
 
 
72
private:
 
73
        CListener* m_pParent;
 
74
};
 
75
 
 
76
class CIncomingConnection : public CZNCSock {
 
77
public:
 
78
        CIncomingConnection(const CString& sHostname, unsigned short uPort, CListener::EAcceptType eAcceptType);
 
79
        virtual ~CIncomingConnection() {}
 
80
        virtual void ReadLine(const CString& sData);
 
81
 
 
82
private:
 
83
        CListener::EAcceptType m_eAcceptType;
 
84
};
 
85
 
 
86
#endif // !_LISTENER_H