KVIrc  4.9.2
DeveloperAPIs
KviIrcConnectionTargetResolver.h
Go to the documentation of this file.
1 #ifndef _KVI_IRCCONNECTIONTARGETRESOLVER_H_
2 #define _KVI_IRCCONNECTIONTARGETRESOLVER_H_
3 //=============================================================================
4 //
5 // File : KviIrcConnectionTargetResolver.h
6 // Creation date : Fri 11 May 2004 23:17:42 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2004-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 "kvi_settings.h"
28 #include "KviQString.h"
29 
30 #include <QObject>
31 
32 #ifdef Status
33 #undef Status
34 #endif
35 
36 #ifdef Success
37 #undef Success
38 #endif
39 
40 #ifdef Error
41 #undef Error
42 #endif
43 
44 class KviConsoleWindow;
45 class KviDnsResolver;
46 class KviIrcConnection;
48 
49 class QTimer;
50 
52 {
53  friend class KviIrcLink; // upper protocol in the stack
54  Q_OBJECT
55 protected:
58 
59 public:
60  enum Status
61  {
63  Error
64  };
65  enum State
66  {
69  Terminated
70  };
71 
72 private:
73  KviIrcConnection * m_pConnection; // shallow, never null
74  KviIrcConnectionTarget * m_pTarget; // shallow, never null
75  KviConsoleWindow * m_pConsole; // shallow, never null
78 
79  // Auxiliary stuff
80  QTimer * m_pStartTimer; // timer used to start the connection
81  KviDnsResolver * m_pProxyDns; // the dns object for the proxy hostnames
82  KviDnsResolver * m_pServerDns; // the dns object for the server hostnames
83 
84  char * m_pReadBuffer;
85  unsigned int m_uReadBufferLen;
86  unsigned int m_uReadPackets;
87 
89 
90 public:
92  // valid only after the terminated() signal
93  Status status() { return m_eStatus; };
94  int lastError() { return m_iLastError; };
95  // causes the resolver to terminate with iLastError == KviError_operationAborted
96  // the terminated() signal is emitted.
97  void abort();
98 protected slots:
99  void asyncStartResolve();
100  void serverLookupTerminated(KviDnsResolver *);
101  void proxyLookupTerminated(KviDnsResolver *);
102 
103 private:
104  void cleanup();
105  void lookupProxyHostname();
106  void lookupServerHostname();
107  void haveServerIp();
108  bool validateLocalAddress(const QString & szAddress, QString & szBuffer);
109  void terminate(Status s, int iLastError);
110 signals:
111  void terminated();
112 };
113 
114 #endif
Definition: KviConsoleWindow.h:75
#define KVIRC_API
Definition: kvi_settings.h:128
KviIrcConnection * m_pConnection
Definition: KviIrcConnectionTargetResolver.h:73
int lastError()
Definition: KviIrcConnectionTargetResolver.h:94
An abstraction of a connection to an IRC server.
Definition: KviIrcConnection.h:95
unsigned int m_uReadPackets
Definition: KviIrcConnectionTargetResolver.h:86
KviConsoleWindow * m_pConsole
Definition: KviIrcConnectionTargetResolver.h:75
Definition: KviIrcConnectionTargetResolver.h:62
Status
Definition: KviIrcConnectionTargetResolver.h:60
State
Definition: KviIrcConnectionTargetResolver.h:65
char s char s s
Definition: KviIrcNumericCodes.h:391
int m_iLastError
Definition: KviIrcConnectionTargetResolver.h:88
Definition: KviIrcConnectionTargetResolver.h:68
The KviDnsResolver class.
Definition: KviDnsResolver.h:93
unsigned int m_uReadBufferLen
Definition: KviIrcConnectionTargetResolver.h:85
QHashIterator< int, QFile * > t(getDict)
Status status()
Definition: KviIrcConnectionTargetResolver.h:93
KviDnsResolver * m_pServerDns
Definition: KviIrcConnectionTargetResolver.h:82
QTimer * m_pStartTimer
Definition: KviIrcConnectionTargetResolver.h:80
State m_eState
Definition: KviIrcConnectionTargetResolver.h:77
char * m_pReadBuffer
Definition: KviIrcConnectionTargetResolver.h:84
Status m_eStatus
Definition: KviIrcConnectionTargetResolver.h:76
Definition: KviIrcConnectionTargetResolver.h:51
KviIrcConnectionTarget * m_pTarget
Definition: KviIrcConnectionTargetResolver.h:74
char szBuffer[4096]
Definition: winamp.cpp:77
Definition: KviIrcConnectionTargetResolver.h:67
This file contains compile time settings.
Definition: KviIrcConnectionTarget.h:35
Helper functions for the QString class.
KviDnsResolver * m_pProxyDns
Definition: KviIrcConnectionTargetResolver.h:81