jdnsshared.h

00001 /*
00002  * Copyright (C) 2006,2007  Justin Karneges
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301  USA
00018  *
00019  */
00020 
00021 #ifndef JDNSSHARED_H
00022 #define JDNSSHARED_H
00023 
00024 #include "jdns/qjdns.h"
00025 
00026 class JDnsShared;
00027 class JDnsSharedPrivate;
00028 class JDnsSharedRequestPrivate;
00029 class JDnsSharedDebugPrivate;
00030 
00064 class JDnsSharedDebug : public QObject
00065 {
00066         Q_OBJECT
00067 public:
00071         JDnsSharedDebug(QObject *parent = 0);
00072 
00076         ~JDnsSharedDebug();
00077 
00085         QStringList readDebugLines();
00086 
00087 signals:
00093         void readyRead();
00094 
00095 private:
00096         friend class JDnsShared;
00097         friend class JDnsSharedPrivate;
00098         friend class JDnsSharedDebugPrivate;
00099         JDnsSharedDebugPrivate *d;
00100 };
00101 
00197 class JDnsSharedRequest : public QObject
00198 {
00199         Q_OBJECT
00200 public:
00204         enum Type
00205         {
00206                 Query,   
00207                 Publish  
00208         };
00209 
00213         enum Error
00214         {
00215                 ErrorNoNet,     
00216                 ErrorGeneric,   
00217                 ErrorNXDomain,  
00218                 ErrorTimeout,   
00219                 ErrorConflict   
00220         };
00221 
00225         JDnsSharedRequest(JDnsShared *jdnsShared, QObject *parent = 0);
00226 
00232         ~JDnsSharedRequest();
00233 
00237         Type type();
00238 
00242         void query(const QByteArray &name, int type);
00243 
00247         void publish(QJDns::PublishMode m, const QJDns::Record &record);
00248 
00252         void publishUpdate(const QJDns::Record &record);
00253 
00257         void cancel();
00258 
00262         bool success() const;
00263 
00267         Error error() const;
00268 
00272         QList<QJDns::Record> results() const;
00273 
00274 signals:
00280         void resultsReady();
00281 
00282 private:
00283         friend class JDnsShared;
00284         friend class JDnsSharedPrivate;
00285         friend class JDnsSharedRequestPrivate;
00286         JDnsSharedRequestPrivate *d;
00287 };
00288 
00404 class JDnsShared : public QObject
00405 {
00406         Q_OBJECT
00407 public:
00411         enum Mode
00412         {
00416                 UnicastInternet,
00417 
00421                 UnicastLocal,
00422 
00428                 Multicast
00429         };
00430 
00434         JDnsShared(Mode mode, QObject *parent = 0);
00435 
00439         ~JDnsShared();
00440 
00446         void setDebug(JDnsSharedDebug *db, const QString &name);
00447 
00457         bool addInterface(const QHostAddress &addr);
00458 
00462         void removeInterface(const QHostAddress &addr);
00463 
00471         void shutdown();
00472 
00478         static QList<QByteArray> domains();
00479 
00497         static void waitForShutdown(const QList<JDnsShared*> instances);
00498 
00499 signals:
00503         void shutdownFinished();
00504 
00505 private:
00506         friend class JDnsSharedRequest;
00507         friend class JDnsSharedPrivate;
00508         JDnsSharedPrivate *d;
00509 };
00510 
00511 #endif

Generated on Sun Mar 18 17:58:50 2007 for IrisNet by  doxygen 1.4.6