JDNS
qjdnsshared.h
Go to the documentation of this file.
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 
28 #ifndef QJDNSSHARED_H
29 #define QJDNSSHARED_H
30 
31 #include "qjdns.h"
32 
33 class QJDnsShared;
34 class QJDnsSharedPrivate;
35 class QJDnsSharedRequestPrivate;
36 class QJDnsSharedDebugPrivate;
37 
76 class JDNS_EXPORT QJDnsSharedDebug : public QObject
77 {
78  Q_OBJECT
79 public:
83  QJDnsSharedDebug(QObject *parent = 0);
84 
89 
99  QStringList readDebugLines();
100 
101 signals:
107  void readyRead();
108 
109 private:
110  friend class QJDnsShared;
111  friend class QJDnsSharedPrivate;
112  friend class QJDnsSharedDebugPrivate;
113  QJDnsSharedDebugPrivate *d;
114 };
115 
235 class JDNS_EXPORT QJDnsSharedRequest : public QObject
236 {
237  Q_OBJECT
238 public:
242  enum Type
243  {
245  Publish
246  };
247 
251  enum Error
252  {
253  ErrorNoNet,
258  ErrorConflict
259  };
260 
264  QJDnsSharedRequest(QJDnsShared *jdnsShared, QObject *parent = 0);
265 
272 
276  Type type();
277 
281  void query(const QByteArray &name, int type);
282 
286  void publish(QJDns::PublishMode m, const QJDns::Record &record);
287 
291  void publishUpdate(const QJDns::Record &record);
292 
296  void cancel();
297 
301  bool success() const;
302 
306  Error error() const;
307 
311  QList<QJDns::Record> results() const;
312 
313 signals:
320  void resultsReady();
321 
322 private:
323  friend class QJDnsShared;
324  friend class QJDnsSharedPrivate;
325  friend class QJDnsSharedRequestPrivate;
326  QJDnsSharedRequestPrivate *d;
327 };
328 
524 class JDNS_EXPORT QJDnsShared : public QObject
525 {
526  Q_OBJECT
527 public:
531  enum Mode
532  {
538 
544 
552  Multicast
553  };
554 
558  QJDnsShared(Mode mode, QObject *parent = 0);
559 
563  ~QJDnsShared();
564 
571  void setDebug(QJDnsSharedDebug *db, const QString &name);
572 
584  bool addInterface(const QHostAddress &addr);
585 
589  void removeInterface(const QHostAddress &addr);
590 
600  void shutdown();
601 
607  static QList<QByteArray> domains();
608 
631  static void waitForShutdown(const QList<QJDnsShared*> &instances);
632 
633 signals:
637  void shutdownFinished();
638 
639 private:
640  friend class QJDnsSharedRequest;
641  friend class QJDnsSharedPrivate;
642  QJDnsSharedPrivate *d;
643 };
644 
645 #endif
QJDnsShared
Abstraction layer on top of QJDns.
Definition: qjdnsshared.h:524
qjdns.h
QJDnsSharedRequest::Error
Error
Request error.
Definition: qjdnsshared.h:251
QJDnsSharedRequest
Performs a DNS operation using QJDnsShared.
Definition: qjdnsshared.h:235
QJDnsSharedRequest::ErrorNXDomain
@ ErrorNXDomain
The name looked up does not exist.
Definition: qjdnsshared.h:256
QJDns::Record
Definition: qjdns.h:99
QJDnsShared::Mode
Mode
The mode to operate in.
Definition: qjdnsshared.h:531
QJDnsSharedRequest::Query
@ Query
Query operation, initiated by query()
Definition: qjdnsshared.h:244
QJDnsSharedRequest::Type
Type
Operation type.
Definition: qjdnsshared.h:242
QJDnsSharedDebug
Collects debugging information from QJDnsShared.
Definition: qjdnsshared.h:76
QJDnsSharedRequest::ErrorTimeout
@ ErrorTimeout
The operation timed out.
Definition: qjdnsshared.h:257
QJDnsShared::UnicastLocal
@ UnicastLocal
Perform regular DNS resolution using the Multicast DNS address.
Definition: qjdnsshared.h:543
QJDnsShared::UnicastInternet
@ UnicastInternet
For regular DNS resolution.
Definition: qjdnsshared.h:537
QJDnsSharedRequest::ErrorGeneric
@ ErrorGeneric
Generic error during the operation.
Definition: qjdnsshared.h:255