Fixed: choose filetransfer transport by priority (thanks Dealer_WeARE)
[iris.git] / src / jdns / qjdns.h
blob6db0ccc31c95a0fa3495e732b45908405ee6edb9
1 /*
2 * Copyright (C) 2005,2006 Justin Karneges
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:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
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.
24 // this is the Qt wrapper to jdns. it requires Qt 4.1+
26 #ifndef QJDNS_H
27 #define QJDNS_H
29 #include <QtCore>
30 #include <QtNetwork>
32 class QJDns : public QObject
34 Q_OBJECT
35 public:
36 enum Mode
38 Unicast,
39 Multicast
42 enum PublishMode
44 Unique,
45 Shared
48 enum Type
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
62 enum Error
64 ErrorGeneric,
65 ErrorNXDomain, // query only
66 ErrorTimeout, // query only
67 ErrorConflict // publish only
70 class NameServer
72 public:
73 QHostAddress address;
74 int port;
76 NameServer();
79 class DnsHost
81 public:
82 QByteArray name;
83 QHostAddress address;
86 class SystemInfo
88 public:
89 QList<NameServer> nameServers;
90 QList<QByteArray> domains;
91 QList<DnsHost> hosts;
94 class Record
96 public:
97 QByteArray owner;
98 int ttl;
99 int type;
100 QByteArray rdata;
101 bool haveKnown;
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
113 Record();
114 bool verify() const;
117 class Response
119 public:
120 QList<Record> answerRecords;
121 QList<Record> authorityRecords;
122 QList<Record> additionalRecords;
125 QJDns(QObject *parent = 0);
126 ~QJDns();
128 bool init(Mode mode, const QHostAddress &address);
129 void shutdown();
130 QStringList debugLines();
132 static SystemInfo systemInfo();
133 static QHostAddress detectPrimaryMulticast(const QHostAddress &address);
135 void setNameServers(const QList<NameServer> &list);
137 int queryStart(const QByteArray &name, int type);
138 void queryCancel(int id);
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);
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();
152 private:
153 class Private;
154 friend class Private;
155 Private *d;
158 #endif