JDNS
qjdnsshared.h
1 /*
2  * Copyright (C) 2006,2007 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 #ifndef QJDNSSHARED_H
25 #define QJDNSSHARED_H
26 
27 #include "qjdns.h"
28 
29 class QJDnsShared;
30 class QJDnsSharedPrivate;
31 class QJDnsSharedRequestPrivate;
32 class QJDnsSharedDebugPrivate;
33 
72 class JDNS_EXPORT QJDnsSharedDebug : public QObject
73 {
74  Q_OBJECT
75 public:
79  QJDnsSharedDebug(QObject *parent = 0);
80 
85 
95  QStringList readDebugLines();
96 
97 signals:
103  void readyRead();
104 
105 private:
106  friend class QJDnsShared;
107  friend class QJDnsSharedPrivate;
108  friend class QJDnsSharedDebugPrivate;
109  QJDnsSharedDebugPrivate *d;
110 };
111 
231 class JDNS_EXPORT QJDnsSharedRequest : public QObject
232 {
233  Q_OBJECT
234 public:
238  enum Type
239  {
241  Publish
242  };
243 
247  enum Error
248  {
249  ErrorNoNet,
254  ErrorConflict
255  };
256 
260  QJDnsSharedRequest(QJDnsShared *jdnsShared, QObject *parent = 0);
261 
268 
272  Type type();
273 
277  void query(const QByteArray &name, int type);
278 
282  void publish(QJDns::PublishMode m, const QJDns::Record &record);
283 
287  void publishUpdate(const QJDns::Record &record);
288 
292  void cancel();
293 
297  bool success() const;
298 
302  Error error() const;
303 
307  QList<QJDns::Record> results() const;
308 
309 signals:
316  void resultsReady();
317 
318 private:
319  friend class QJDnsShared;
320  friend class QJDnsSharedPrivate;
321  friend class QJDnsSharedRequestPrivate;
322  QJDnsSharedRequestPrivate *d;
323 };
324 
520 class JDNS_EXPORT QJDnsShared : public QObject
521 {
522  Q_OBJECT
523 public:
527  enum Mode
528  {
534 
540 
548  Multicast
549  };
550 
554  QJDnsShared(Mode mode, QObject *parent = 0);
555 
559  ~QJDnsShared();
560 
567  void setDebug(QJDnsSharedDebug *db, const QString &name);
568 
580  bool addInterface(const QHostAddress &addr);
581 
585  void removeInterface(const QHostAddress &addr);
586 
596  void shutdown();
597 
603  static QList<QByteArray> domains();
604 
627  static void waitForShutdown(const QList<QJDnsShared*> &instances);
628 
629 signals:
633  void shutdownFinished();
634 
635 private:
636  friend class QJDnsSharedRequest;
637  friend class QJDnsSharedPrivate;
638  QJDnsSharedPrivate *d;
639 };
640 
641 #endif
QJDnsShared
Abstraction layer on top of QJDns.
Definition: qjdnsshared.h:520
QJDnsSharedRequest::Error
Error
Request error.
Definition: qjdnsshared.h:247
QJDnsSharedRequest
Performs a DNS operation using QJDnsShared.
Definition: qjdnsshared.h:231
QJDnsSharedRequest::ErrorNXDomain
@ ErrorNXDomain
The name looked up does not exist.
Definition: qjdnsshared.h:252
QJDns::Record
Definition: qjdns.h:95
QJDnsShared::Mode
Mode
The mode to operate in.
Definition: qjdnsshared.h:527
QJDnsSharedRequest::Query
@ Query
Query operation, initiated by query()
Definition: qjdnsshared.h:240
QJDnsSharedRequest::Type
Type
Operation type.
Definition: qjdnsshared.h:238
QJDnsSharedDebug
Collects debugging information from QJDnsShared.
Definition: qjdnsshared.h:72
QJDnsSharedRequest::ErrorTimeout
@ ErrorTimeout
The operation timed out.
Definition: qjdnsshared.h:253
QJDnsShared::UnicastLocal
@ UnicastLocal
Perform regular DNS resolution using the Multicast DNS address.
Definition: qjdnsshared.h:539
QJDnsShared::UnicastInternet
@ UnicastInternet
For regular DNS resolution.
Definition: qjdnsshared.h:533
QJDnsSharedRequest::ErrorGeneric
@ ErrorGeneric
Generic error during the operation.
Definition: qjdnsshared.h:251