~ubuntu-branches/ubuntu/oneiric/psi/oneiric

« back to all changes in this revision

Viewing changes to iris/irisnet/jdns/qjdns.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2005,2006  Justin Karneges
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 
 * copy of this software and associated documentation files (the
6
 
 * "Software"), to deal in the Software without restriction, including
7
 
 * without limitation the rights to use, copy, modify, merge, publish,
8
 
 * distribute, sublicense, and/or sell copies of the Software, and to
9
 
 * permit persons to whom the Software is furnished to do so, subject to
10
 
 * the following conditions:
11
 
 *
12
 
 * The above copyright notice and this permission notice shall be included
13
 
 * in all copies or substantial portions of the Software.
14
 
 *
15
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
 
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
 
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
 
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
 
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
 
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
 
 */
23
 
 
24
 
// this is the Qt wrapper to jdns.  it requires Qt 4.1+
25
 
 
26
 
#ifndef QJDNS_H
27
 
#define QJDNS_H
28
 
 
29
 
#include <QtCore>
30
 
#include <QtNetwork>
31
 
 
32
 
class QJDns : public QObject
33
 
{
34
 
        Q_OBJECT
35
 
public:
36
 
        enum Mode
37
 
        {
38
 
                Unicast,
39
 
                Multicast
40
 
        };
41
 
 
42
 
        enum PublishMode
43
 
        {
44
 
                Unique,
45
 
                Shared
46
 
        };
47
 
 
48
 
        enum Type
49
 
        {
50
 
                A       = 1,
51
 
                Aaaa    = 28,
52
 
                Mx      = 15,
53
 
                Srv     = 33,
54
 
                Cname   = 5,
55
 
                Ptr     = 12,
56
 
                Txt     = 16,
57
 
                Hinfo   = 13,
58
 
                Ns      = 2,
59
 
                Any     = 255
60
 
        };
61
 
 
62
 
        enum Error
63
 
        {
64
 
                ErrorGeneric,
65
 
                ErrorNXDomain, // query only
66
 
                ErrorTimeout,  // query only
67
 
                ErrorConflict  // publish only
68
 
        };
69
 
 
70
 
        class NameServer
71
 
        {
72
 
        public:
73
 
                QHostAddress address;
74
 
                int port;
75
 
 
76
 
                NameServer();
77
 
        };
78
 
 
79
 
        class DnsHost
80
 
        {
81
 
        public:
82
 
                QByteArray name;
83
 
                QHostAddress address;
84
 
        };
85
 
 
86
 
        class SystemInfo
87
 
        {
88
 
        public:
89
 
                QList<NameServer> nameServers;
90
 
                QList<QByteArray> domains;
91
 
                QList<DnsHost> hosts;
92
 
        };
93
 
 
94
 
        class Record
95
 
        {
96
 
        public:
97
 
                QByteArray owner;
98
 
                int ttl;
99
 
                int type;
100
 
                QByteArray rdata;
101
 
                bool haveKnown;
102
 
 
103
 
                // known
104
 
                QHostAddress address;    // for A, Aaaa
105
 
                QByteArray name;         // for Mx, Srv, Cname, Ptr, Ns
106
 
                int priority;            // for Mx, Srv
107
 
                int weight;              // for Srv
108
 
                int port;                // for Srv
109
 
                QList<QByteArray> texts; // for Txt
110
 
                QByteArray cpu;          // for Hinfo
111
 
                QByteArray os;           // for Hinfo
112
 
 
113
 
                Record();
114
 
                bool verify() const;
115
 
        };
116
 
 
117
 
        class Response
118
 
        {
119
 
        public:
120
 
                QList<Record> answerRecords;
121
 
                QList<Record> authorityRecords;
122
 
                QList<Record> additionalRecords;
123
 
        };
124
 
 
125
 
        QJDns(QObject *parent = 0);
126
 
        ~QJDns();
127
 
 
128
 
        bool init(Mode mode, const QHostAddress &address);
129
 
        void shutdown();
130
 
        QStringList debugLines();
131
 
 
132
 
        static SystemInfo systemInfo();
133
 
        static QHostAddress detectPrimaryMulticast(const QHostAddress &address);
134
 
 
135
 
        void setNameServers(const QList<NameServer> &list);
136
 
 
137
 
        int queryStart(const QByteArray &name, int type);
138
 
        void queryCancel(int id);
139
 
 
140
 
        // for multicast mode only
141
 
        int publishStart(PublishMode m, const Record &record);
142
 
        void publishUpdate(int id, const Record &record);
143
 
        void publishCancel(int id);
144
 
 
145
 
signals:
146
 
        void resultsReady(int id, const QJDns::Response &results);
147
 
        void published(int id);
148
 
        void error(int id, QJDns::Error e);
149
 
        void shutdownFinished();
150
 
        void debugLinesReady();
151
 
 
152
 
private:
153
 
        class Private;
154
 
        friend class Private;
155
 
        Private *d;
156
 
};
157
 
 
158
 
#endif