JDnsSharedRequest Class Reference

Performs a DNS operation using JDnsShared. More...

#include <jdnsshared.h>

List of all members.

Public Types

enum  Type { Query, Publish }
enum  Error {
  ErrorNoNet, ErrorGeneric, ErrorNXDomain, ErrorTimeout,
  ErrorConflict
}

Signals

void resultsReady ()

Public Member Functions

 JDnsSharedRequest (JDnsShared *jdnsShared, QObject *parent=0)
 ~JDnsSharedRequest ()
Type type ()
void query (const QByteArray &name, int type)
void publish (QJDns::PublishMode m, const QJDns::Record &record)
void publishUpdate (const QJDns::Record &record)
void cancel ()
bool success () const
Error error () const
QList< QJDns::Record > results () const

Friends

class JDnsShared


Detailed Description

Performs a DNS operation using JDnsShared.

Note:
Iris users should utilize NetNames for DNS capabilities, not JDnsSharedRequest. See the JDnsShared documentation for more information.
JDnsSharedRequest is used to perform DNS operations on a JDnsShared object. Many requests may be performed simultaneously, such that a single JDnsShared object can be "shared" across the application. Please see the JDnsShared documentation for more complete information about how the overall system works.

Call query() to perform a query. Call publish() (or publishUpdate()) to make DNS records available on the local network (JDnsShared::Multicast mode only). When the operation has something to report, the resultsReady() signal is emitted. Call success() to determine the status of the operation. If success() returns false, then the operation has failed and the reason for the failure can be determined with error(). If success() returns true, then the meaning differs depending on the type of operation being performed:

Here is how you might look up an A record:

JDnsSharedRequest *req = new JDnsSharedRequest(jdnsShared);
connect(req, SIGNAL(resultsReady()), SLOT(req_resultsReady()));
req->query("psi-im.org", QJDns::A);
...
void req_resultsReady()
{
        if(req->success())
        {
                // print all of the IP addresses obtained
                QList<QJDns::Record> results = req->results();
                foreach(QJDns::Record r, results)
                {
                        if(r.type == QJDns::A)
                                printf("%s\n", qPrintable(r.address.toString());
                }
        }
        else
                printf("Error resolving!\n");
}

Here is an example of publishing a record:

JDnsSharedRequest *pub = new JDnsSharedRequest(jdnsShared);
connect(pub, SIGNAL(resultsReady()), SLOT(pub_resultsReady()));

// let's publish an A record
QJDns::Record rec;
rec.owner = "SomeComputer.local.";
rec.type = QJDns::A;
rec.ttl = 120;
rec.haveKnown = true;
rec.address = QHostAddress("192.168.0.32");

pub->publish(QJDns::Unique, rec);
...
void pub_resultsReady()
{
        if(pub->success())
                printf("Record published\n");
        else
                printf("Error publishing!\n");
}

To update an existing record, use publishUpdate():

// the IP address of the host changed, so make a new record
QJDns::Record rec;
rec.owner = "SomeComputer.local.";
rec.type = QJDns::A;
rec.ttl = 120;
rec.haveKnown = true;
rec.address = QHostAddress("192.168.0.64");

// update it
pub->publishUpdate(rec);

As a special exception, the address value can be left unspecified for A and Aaaa record types, which tells JDnsShared to substitute the address value with the address of whatever interfaces the record gets published on. This is the preferred way to publish the IP address of your own machine, and in fact it is the only way to do so if you have multiple interfaces, because there will likely be a different IP address value for each interface (the record resolves to a different answer depending on which interface a query comes from).

// let's publish our own A record
QJDns::Record rec;
rec.owner = "MyComputer.local.";
rec.type = QJDns::A;
rec.ttl = 120;
rec.haveKnown = true;
rec.address = QHostAddress();

pub->publish(QJDns::Unique, rec);

When you want to unpublish, call cancel() or destroy the JDnsSharedRequest.

See also:
JDnsShared


Member Enumeration Documentation

enum JDnsSharedRequest::Error
 

Request error.

Enumerator:
ErrorNoNet  There are no available network interfaces to operate on. This happens if JDnsShared::addInterface() was not called.
ErrorGeneric  Generic error during the operation.
ErrorNXDomain  The name looked up does not exist.
ErrorTimeout  The operation timed out.
ErrorConflict  Attempt to publish an already published unique record.

enum JDnsSharedRequest::Type
 

Operation type.

Enumerator:
Query  Query operation, initiated by query().
Publish  Publish operation, initiated by publish() or publishUpdate().


Constructor & Destructor Documentation

JDnsSharedRequest::JDnsSharedRequest JDnsShared jdnsShared,
QObject *  parent = 0
 

Constructs a new object with the given jdnsShared and parent.

JDnsSharedRequest::~JDnsSharedRequest  ) 
 

Destroys the object.

If there is an active operation, it is cancelled.


Member Function Documentation

void JDnsSharedRequest::cancel  ) 
 

Cancels the current operation.

Error JDnsSharedRequest::error  )  const
 

Returns the reason for error.

void JDnsSharedRequest::publish QJDns::PublishMode  m,
const QJDns::Record &  record
 

Perform a publish operation.

void JDnsSharedRequest::publishUpdate const QJDns::Record &  record  ) 
 

Update a record that is currently published.

void JDnsSharedRequest::query const QByteArray &  name,
int  type
 

Perform a query operation.

QList<QJDns::Record> JDnsSharedRequest::results  )  const
 

Returns the results of the operation.

void JDnsSharedRequest::resultsReady  )  [signal]
 

Indicates that the operation has something to report.

After receiving this signal, call success() to check on the status of the operation, followed by results() or error() as appropriate.

bool JDnsSharedRequest::success  )  const
 

Indicates whether or not the operation was successful.

Type JDnsSharedRequest::type  ) 
 

The type of operation being performed.


The documentation for this class was generated from the following file:
Generated on Sun Mar 18 17:58:51 2007 for IrisNet by  doxygen 1.4.6