~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/qt3support/network/q3dns.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

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