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 
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 
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:
638 
639 private:
640  friend class QJDnsSharedRequest;
641  friend class QJDnsSharedPrivate;
642  QJDnsSharedPrivate *d;
643 };
644 
645 #endif
QJDnsSharedRequest::publish
void publish(QJDns::PublishMode m, const QJDns::Record &record)
Perform a publish operation.
QJDnsSharedRequest::publishUpdate
void publishUpdate(const QJDns::Record &record)
Update a record that is currently published.
QJDnsShared::removeInterface
void removeInterface(const QHostAddress &addr)
Removes a previously-added interface.
QJDnsSharedDebug::~QJDnsSharedDebug
~QJDnsSharedDebug()
Destroys the object.
QJDnsSharedRequest::results
QList< QJDns::Record > results() const
Returns the results of the operation.
QJDnsShared
Abstraction layer on top of QJDns.
Definition: qjdnsshared.h:525
qjdns.h
QJDnsShared::setDebug
void setDebug(QJDnsSharedDebug *db, const QString &name)
Sets the debug object to report to.
QJDnsSharedRequest::Error
Error
Request error.
Definition: qjdnsshared.h:252
QJDnsShared::shutdownFinished
void shutdownFinished()
Indicates the object has been shut down.
QJDnsSharedRequest
Performs a DNS operation using QJDnsShared.
Definition: qjdnsshared.h:236
QJDnsSharedRequest::ErrorNXDomain
@ ErrorNXDomain
The name looked up does not exist.
Definition: qjdnsshared.h:256
QJDnsSharedRequest::success
bool success() const
Indicates whether or not the operation was successful.
QJDnsSharedDebug::readDebugLines
QStringList readDebugLines()
Read the available debug information.
QJDns::Record
Definition: qjdns.h:100
QJDnsSharedRequest::cancel
void cancel()
Cancels the current operation.
QJDnsShared::Mode
Mode
The mode to operate in.
Definition: qjdnsshared.h:532
QJDnsSharedRequest::Query
@ Query
Query operation, initiated by query()
Definition: qjdnsshared.h:244
QJDnsSharedRequest::Type
Type
Operation type.
Definition: qjdnsshared.h:243
QJDnsSharedDebug
Collects debugging information from QJDnsShared.
Definition: qjdnsshared.h:77
QJDnsSharedDebug::QJDnsSharedDebug
QJDnsSharedDebug(QObject *parent=0)
Constructs a new object with the given parent.
QJDnsSharedRequest::query
void query(const QByteArray &name, int type)
Perform a query operation.
QJDnsShared::addInterface
bool addInterface(const QHostAddress &addr)
Adds an interface to operate on.
QJDnsShared::QJDnsShared
QJDnsShared(Mode mode, QObject *parent=0)
Constructs a new object with the given mode and parent.
QJDnsShared::waitForShutdown
static void waitForShutdown(const QList< QJDnsShared * > &instances)
Performs a blocking shutdown of many QJDnsShared instances.
QJDnsShared::~QJDnsShared
~QJDnsShared()
Destroys the object.
QJDnsShared::shutdown
void shutdown()
Shuts down the object.
QJDnsSharedRequest::~QJDnsSharedRequest
~QJDnsSharedRequest()
Destroys the object.
QJDnsSharedRequest::error
Error error() const
Returns the reason for error.
QJDnsSharedRequest::type
Type type()
The type of operation being performed.
QJDnsSharedRequest::QJDnsSharedRequest
QJDnsSharedRequest(QJDnsShared *jdnsShared, QObject *parent=0)
Constructs a new object with the given jdnsShared and parent.
QJDnsSharedRequest::ErrorTimeout
@ ErrorTimeout
The operation timed out.
Definition: qjdnsshared.h:257
QJDnsShared::domains
static QList< QByteArray > domains()
The domains to search in.
QJDnsShared::UnicastLocal
@ UnicastLocal
Perform regular DNS resolution using the Multicast DNS address.
Definition: qjdnsshared.h:543
QJDnsSharedDebug::readyRead
void readyRead()
Emitted when there is debug information to report.
QJDnsSharedRequest::resultsReady
void resultsReady()
Indicates that the operation has something to report.
QJDnsShared::UnicastInternet
@ UnicastInternet
For regular DNS resolution.
Definition: qjdnsshared.h:537
QJDnsSharedRequest::ErrorGeneric
@ ErrorGeneric
Generic error during the operation.
Definition: qjdnsshared.h:255