KVIrc  4.9.2
DeveloperAPIs
DccMarshal.h
Go to the documentation of this file.
1 #ifndef _MARSHAL_H_
2 #define _MARSHAL_H_
3 //=============================================================================
4 //
5 // File DccMarshal.h
6 // Creation date : Sun Sep 17 2000 10:44:20 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "KviCString.h"
28 #include "KviError.h"
29 #include "kvi_sockettype.h"
30 #include "kvi_inttypes.h"
31 
32 #include <QObject>
33 #include <QSocketNotifier>
34 #include <QTimer>
35 
36 class KviWindow;
37 class DccMarshal;
38 
39 #ifdef COMPILE_SSL_SUPPORT
40 #include "KviSSLMaster.h"
41 #endif
42 
44 {
45  friend class DccMarshal;
46 
47 public:
50 
51 protected:
52  virtual KviWindow * dccMarshalOutputWindow() = 0;
53  virtual const char * dccMarshalOutputContextString() = 0;
54 };
55 
56 class DccMarshal : public QObject
57 {
58  Q_OBJECT
59 public:
61  ~DccMarshal();
62 
63 protected:
64  // DCC DESCRIPTOR
65  QString m_szIp; // Dcc initiator ip address (the one that listens)
66  QString m_szPort; // Dcc initiator port (the one that listens)
67  // other info
68  bool m_bIPv6; // Dcc mode
69  kvi_u32_t m_uPort; // Dcc initiator port
70  bool m_bOutgoing; // true if WE have connected to the remote host (so m_szIp is the remote host ip)
71  QString m_szSecondaryIp; // Ip of the client that has connected to the remote host
72  QString m_szSecondaryPort; // Port of the client that has connected to the remote host
73  // internals
74  kvi_socket_t m_fd; // socket
75  QSocketNotifier * m_pSn;
77  QTimer * m_pTimeoutTimer;
78 #ifdef COMPILE_SSL_SUPPORT
79  KviSSL * m_pSSL;
80  bool m_bUseSSL;
81 #endif
83 
84 public:
85  const QString & dccIp() const { return m_szIp; };
86  const QString & dccPort() const { return m_szPort; };
87  const QString & localIp() const { return m_bOutgoing ? m_szSecondaryIp : m_szIp; };
88  const QString & localPort() const { return m_bOutgoing ? m_szSecondaryPort : m_szPort; };
89  const QString & remoteIp() const { return m_bOutgoing ? m_szIp : m_szSecondaryIp; };
90  const QString & remotePort() const { return m_bOutgoing ? m_szPort : m_szSecondaryPort; };
91  KviError::Code dccListen(const QString & ip, const QString & port, bool bUseTimeout, bool bUseSSL = false);
92  KviError::Code dccConnect(const char * ip, const char * port, bool bUseTimeout, bool bUseSSL = false);
94 #ifdef COMPILE_SSL_SUPPORT
95  KviSSL * releaseSSL();
96 #endif
97  void abort();
98 
99 private:
100  void reset();
101  //#ifdef COMPILE_SSL_SUPPORT
102  // bool trySSLCertificate();
103  //#endif
104 private slots:
105  void doSSLHandshake(int);
106  // void doListenSSLHandshake();
107  void snActivated(int);
108  void connectionTimedOut();
109  void doListen();
110  void doConnect();
111 signals:
112  void startingSSLHandshake();
113  void sslError(const char * msg);
114  void connected();
115  void inProgress();
116  void error(KviError::Code);
117 };
118 
119 #endif //_MARSHAL_H_
QString m_szSecondaryPort
Definition: DccMarshal.h:72
void connected()
int kvi_socket_t
Definition: kvi_sockettype.h:40
void doListen()
Definition: DccMarshal.cpp:136
void doSSLHandshake(int)
Definition: DccMarshal.cpp:587
void inProgress()
const QString & remotePort() const
Definition: DccMarshal.h:90
QString m_szPort
Definition: DccMarshal.h:66
kvi_u32_t m_uPort
Definition: DccMarshal.h:69
void sslError(const char *msg)
const QString & dccIp() const
Definition: DccMarshal.h:85
QSocketNotifier * m_pSn
Definition: DccMarshal.h:75
kvi_socket_t m_fd
Definition: DccMarshal.h:74
virtual KviWindow * dccMarshalOutputWindow()=0
bool m_bIPv6
Definition: DccMarshal.h:68
KviError::Code dccConnect(const char *ip, const char *port, bool bUseTimeout, bool bUseSSL=false)
Definition: DccMarshal.cpp:306
const QString & localPort() const
Definition: DccMarshal.h:88
void doConnect()
Definition: DccMarshal.cpp:327
Definition: DccMarshal.h:43
void error(KviError::Code)
void reset()
Definition: DccMarshal.cpp:78
virtual ~DccMarshalOutputContext()
Definition: DccMarshal.h:49
Definition: DccMarshal.h:56
Code
Contains all error codes.
Definition: KviError.h:47
QTimer * m_pTimeoutTimer
Definition: DccMarshal.h:77
void snActivated(int)
Definition: DccMarshal.cpp:451
DccMarshalOutputContext()
Definition: DccMarshal.h:48
void startingSSLHandshake()
DccMarshalOutputContext * m_pOutputContext
Definition: DccMarshal.h:82
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
~DccMarshal()
Definition: DccMarshal.cpp:57
QString m_szSecondaryIp
Definition: DccMarshal.h:71
void abort()
Definition: DccMarshal.cpp:665
bool m_bUseTimeout
Definition: DccMarshal.h:76
bool m_bOutgoing
Definition: DccMarshal.h:70
DccMarshal(DccMarshalOutputContext *ctx)
Definition: DccMarshal.cpp:39
KviError::Code dccListen(const QString &ip, const QString &port, bool bUseTimeout, bool bUseSSL=false)
Definition: DccMarshal.cpp:107
virtual const char * dccMarshalOutputContextString()=0
Error List.
const QString & dccPort() const
Definition: DccMarshal.h:86
kvi_socket_t releaseSocket()
Definition: DccMarshal.cpp:62
const QString & localIp() const
Definition: DccMarshal.h:87
QString m_szIp
Definition: DccMarshal.h:65
const QString & remoteIp() const
Definition: DccMarshal.h:89
void connectionTimedOut()
Definition: DccMarshal.cpp:670