home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qdns.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  4KB  |  168 lines

  1. /****************************************************************************
  2. ** $Id$
  3. **
  4. ** Definition of QDns class.
  5. **
  6. ** Created : 991122
  7. **
  8. ** Copyright (C) 1999-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the network module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition licenses may use this
  22. ** file in accordance with the Qt Commercial License Agreement provided
  23. ** with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QDNS_H
  39. #define QDNS_H
  40.  
  41. #ifndef QT_H
  42. #include "qobject.h"
  43. #include "qhostaddress.h"
  44. #include "qsocketnotifier.h"
  45. #include "qstringlist.h"
  46. #endif // QT_H
  47.  
  48. #if !defined( QT_MODULE_NETWORK ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_NETWORK )
  49. #define QM_EXPORT_DNS
  50. #else
  51. #define QM_EXPORT_DNS Q_EXPORT
  52. #endif
  53.  
  54. #ifndef QT_NO_DNS
  55.  
  56. //#define Q_DNS_SYNCHRONOUS
  57.  
  58. class QDnsPrivate;
  59.  
  60. class QM_EXPORT_DNS QDns: public QObject {
  61.     Q_OBJECT
  62. public:
  63.     enum RecordType {
  64.     None,
  65.     A, Aaaa,
  66.     Mx, Srv,
  67.     Cname,
  68.     Ptr,
  69.     Txt
  70.     };
  71.  
  72.     QDns();
  73.     QDns( const QString & label, RecordType rr = A );
  74.     QDns( const QHostAddress & address, RecordType rr = Ptr );
  75.     virtual ~QDns();
  76.  
  77.     // to set/change the query
  78.     virtual void setLabel( const QString & label );
  79.     virtual void setLabel( const QHostAddress & address );
  80.     QString label() const { return l; }
  81.  
  82.     virtual void setRecordType( RecordType rr = A );
  83.     RecordType recordType() const { return t; }
  84.  
  85.     // whether something is happening behind the scenes
  86.     bool isWorking() const;
  87.  
  88.     // to query for replies
  89.     QValueList<QHostAddress> addresses() const;
  90.  
  91.     class QM_EXPORT_DNS MailServer {
  92.     public:
  93.     MailServer( const QString & n=QString::null, Q_UINT16 p=0 )
  94.         :name(n), priority(p) {}
  95.     QString name;
  96.     Q_UINT16 priority;
  97. #if defined(Q_FULL_TEMPLATE_INSTANTIATION)
  98.     bool operator==( const MailServer& ) const { return FALSE; }
  99. #endif
  100.     };
  101.     QValueList<MailServer> mailServers() const;
  102.  
  103.     class QM_EXPORT_DNS Server {
  104.     public:
  105.     Server(const QString & n=QString::null, Q_UINT16 p=0, Q_UINT16 w=0, Q_UINT16 po=0 )
  106.         : name(n), priority(p), weight(w), port(po) {}
  107.     QString name;
  108.     Q_UINT16 priority;
  109.     Q_UINT16 weight;
  110.     Q_UINT16 port;
  111. #if defined(Q_FULL_TEMPLATE_INSTANTIATION)
  112.     bool operator==( const Server& ) const { return FALSE; }
  113. #endif
  114.     };
  115.     QValueList<Server> servers() const;
  116.  
  117.     QStringList hostNames() const;
  118.  
  119.     QStringList texts() const;
  120.  
  121.     QString canonicalName() const; // ### real-world but uncommon: QStringList
  122.  
  123.     QStringList qualifiedNames() const { return n; }
  124.  
  125. #if defined(Q_DNS_SYNCHRONOUS)
  126. protected:
  127.     void connectNotify( const char *signal );
  128. #endif
  129.  
  130. signals:
  131.     void resultsReady();
  132.  
  133. private slots:
  134.     void startQuery();
  135.  
  136. private:
  137.     void setStartQueryTimer();
  138.     QString toInAddrArpaDomain( const QHostAddress &address );
  139. #if defined(Q_DNS_SYNCHRONOUS)
  140.     void doSynchronousLookup();
  141. #endif
  142.  
  143.     QString l;
  144.     QStringList n;
  145.     RecordType t;
  146.     QDnsPrivate * d;
  147. };
  148.  
  149.  
  150. // QDnsSocket are sockets that are used for DNS lookup
  151.  
  152. class QDnsSocket: public QObject {
  153.     Q_OBJECT
  154.     // note: Private not public.  This class contains NO public API.
  155. protected:
  156.     QDnsSocket( QObject *, const char * );
  157.     virtual ~QDnsSocket();
  158.  
  159. private slots:
  160.     virtual void cleanCache();
  161.     virtual void retransmit();
  162.     virtual void answer();
  163. };
  164.  
  165. #endif // QT_NO_DNS
  166.  
  167. #endif // QDNS_H
  168.