KVIrc  4.9.2
DeveloperAPIs
KviDnsResolverNew.h
Go to the documentation of this file.
1 #ifndef _KviDnsResolver_h_
2 #define _KviDnsResolver_h_
3 //=============================================================================
4 //
5 // File : KviDnsResolver.h
6 // Creation date : Sat Jul 21 2000 13:59:11 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 // This is a nicely working DNS resolver that uses the QHostInfo interface
28 // and thus gets rid of all the ugly OS dependencies we have.
29 // It should be sufficient to rename this file and use this class
30 // instead of the old KviDnsResolver.
31 
32 // However at present time (04.01.2010) QHostInfo doesn't seem to support
33 // IPv6. Despite the documentation saying that IPv6 addresses are supported
34 // the query performed by QHostInfo::lookupHost() asks only for the A record.
35 //
36 // Check it again with newer Qt versions and verify.
37 
38 #include "kvi_settings.h"
39 
40 #include <KviError.h> // FIXME: Get rid of this at all..
41 #include <KviPointerList.h>
42 
43 #include <QObject>
44 
46 
47 class QHostInfo;
48 
55 class KVILIB_API KviDnsResolver : public QObject
56 {
57  Q_OBJECT
58 
59 public:
63  KviDnsResolver(QObject * pParent = NULL);
64 
69  virtual ~KviDnsResolver();
70 
71 public:
72  enum QueryType
73  {
74  IPv4,
75  IPv6,
76  Any
77  };
78 
79  enum State
80  {
81  Idle,
82  Busy,
83  Failure,
84  Success
85  };
86 
87 private:
89 
90 public:
94  State state() const;
95 
100  bool lookup(const QString & szQuery, QueryType eType);
101 
102  // Results (return always non null-data..but valid results only if state() == Success or Failure)
103  KviError::Code error() const; // DEPRECATED use errorString()
104  const QString & errorString() const;
105 
106  const QString & hostName() const;
107  const QString & firstIpAddress();
108  int ipAddressCount() const;
109  KviPointerList<QString> * ipAddressList();
110  const QString & query() const;
111  bool isRunning() const;
112 
113 private slots:
114  void slotHostLookupTerminated(const QHostInfo & oHostInfo);
115 
116 signals:
117  void lookupDone(KviDnsResolver *);
118 
119 }; // class KviDnsResolver
120 
121 #endif
char * NULL
Definition: KviIrcNumericCodes.h:391
KviDnsResolverPrivate * m_pPrivateData
Definition: KviDnsResolverNew.h:88
Code
Contains all error codes.
Definition: KviError.h:47
Definition: KviDnsResolverNew.cpp:33
The KviDnsResolver class.
Definition: KviDnsResolver.h:93
C++ Template based double linked pointer list class.
Error List.
QueryType
Definition: KviDnsResolver.h:102
This file contains compile time settings.
#define KVILIB_API
Definition: kvi_settings.h:125
Definition: Idle.h:32
const QString & firstIpAddress()
State
Definition: KviDnsResolver.h:108
Definition: KviError.h:49