home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / dnssd / remoteservice.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.3 KB  |  112 lines

  1. /* This file is part of the KDE project
  2.  *
  3.  * Copyright (C) 2004, 2005 Jakub Stachowski <qbast@go2.pl>
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public License
  16.  * along with this library; see the file COPYING.LIB.  If not, write to
  17.  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.  * Boston, MA 02110-1301, USA.
  19.  */
  20.  
  21. #ifndef DNSSDREMOTESERVICE_H
  22. #define DNSSDREMOTESERVICE_H
  23.  
  24. #include <qobject.h>
  25. #include <dnssd/servicebase.h>
  26.  
  27. class QDataStream;
  28. class KURL;
  29. namespace DNSSD
  30. {
  31. class RemoteServicePrivate;
  32.  
  33. /**
  34. RemoteService class allows to resolve service announced on remote machine. In most cases objects
  35. of this class are created by ServiceBrowser, but it is not required. Only fields valid before 
  36. service is resolved are name, type.and domain. 
  37.  
  38.  
  39. @short class representing service announced on remote machine.
  40. @author Jakub Stachowski
  41.  */
  42. class KDNSSD_EXPORT RemoteService : public QObject, public ServiceBase
  43. {
  44.     Q_OBJECT
  45. public:
  46.     typedef KSharedPtr<RemoteService> Ptr;
  47.     
  48.     /**
  49.     Creates unresolved service from given DNS label
  50.     @param label Data returned by PTR query - it is decoded into name, type and 
  51.     domain
  52.      */
  53.     RemoteService(const QString& label);
  54.     
  55.     /**
  56.     Creates unresolved remote service with given name, type and domain.
  57.      */
  58.     RemoteService(const QString& name,const QString& type,const QString& domain);
  59.     
  60.     /**
  61.     Creates resolved remote service from invitation URL constructed by PublicService::toInvitation.
  62.     If URL was invalid, service is set to unresolved and other fields should not be used.
  63.      */
  64.     RemoteService(const KURL& url);
  65.     
  66.     virtual ~RemoteService();
  67.     
  68.     /**
  69.     Resolves host name and port of service. Host name is not resolved into numeric
  70.     address - use KResolver for that. Signal resolved(bool) will be emitted 
  71.     when finished or even before return of this function - in case of immediate failure.
  72.      */
  73.     void resolveAsync();
  74.     
  75.     /**
  76.     Synchronous version of resolveAsync(). Note that resolved(bool) is emitted 
  77.     before this function returns, 
  78.     @return TRUE is successful
  79.      */
  80.     bool resolve();
  81.     
  82.     /**
  83.     Returns true if service has been successfully resolved
  84.      */
  85.     bool isResolved() const;
  86.     
  87. signals:
  88.     /**
  89.     Emitted when resolving is complete. Parameter is set to TRUE if it was successful.
  90.     If operating in asynchronous mode this signal can be emitted several times (when 
  91.     service change)
  92.      */
  93.     void resolved(bool);
  94.  
  95. protected:
  96.     virtual void virtual_hook(int id, void *data);
  97.     virtual void customEvent(QCustomEvent* event);
  98. private:
  99.     void resolveError();
  100.     void resolved(const char *host, unsigned short port, unsigned short txtlen,
  101.         const char* txtRecord);
  102.     RemoteServicePrivate *d;
  103.  
  104.     friend KDNSSD_EXPORT QDataStream & operator<< (QDataStream & s, const RemoteService & a);
  105.     friend KDNSSD_EXPORT QDataStream & operator>> (QDataStream & s, RemoteService & a);
  106.  
  107. };
  108.  
  109. }
  110.  
  111. #endif
  112.