• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

kresolver.h
00001 /*  -*- mode: C++; coding: utf-8; -*-
00002  *  Copyright (C) 2003,2005 Thiago Macieira <thiago.macieira@kdemail.net>
00003  *
00004  *
00005  *  Permission is hereby granted, free of charge, to any person obtaining
00006  *  a copy of this software and associated documentation files (the
00007  *  "Software"), to deal in the Software without restriction, including
00008  *  without limitation the rights to use, copy, modify, merge, publish,
00009  *  distribute, sublicense, and/or sell copies of the Software, and to
00010  *  permit persons to whom the Software is furnished to do so, subject to
00011  *  the following conditions:
00012  *
00013  *  The above copyright notice and this permission notice shall be included 
00014  *  in all copies or substantial portions of the Software.
00015  *
00016  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00017  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00018  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00019  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00020  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00021  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00022  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 #ifndef KRESOLVER_H
00026 #define KRESOLVER_H
00027 
00029 // Needed includes
00030 #include <tqvaluelist.h>
00031 #include <tqobject.h>
00032 #include "ksocketaddress.h"
00033 
00034 
00036 // Forward declarations
00037 struct sockaddr;
00038 class TQString;
00039 class TQCString;
00040 class TQStrList;
00041 
00043 // Our definitions
00044 
00045 namespace KNetwork {
00046 
00047   namespace Internal { class KResolverManager; }
00048 
00049 class KResolverEntryPrivate;
00066 class KDECORE_EXPORT KResolverEntry
00067 {
00068 public:
00073   KResolverEntry();
00074 
00087   KResolverEntry(const KSocketAddress& addr, int socktype, int protocol,
00088         const TQString& canonName = TQString::null,
00089         const TQCString& encodedName = TQCString());
00090 
00104   KResolverEntry(const struct sockaddr *sa, TQ_UINT16 salen, int socktype,
00105         int protocol, const TQString& canonName = TQString::null,
00106         const TQCString& encodedName = TQCString());
00107 
00113   KResolverEntry(const KResolverEntry &other);
00114 
00121   ~KResolverEntry();
00122 
00126   KSocketAddress address() const;
00127 
00131   TQ_UINT16 length() const;
00132 
00136   int family() const;
00137 
00142   TQString canonicalName() const;
00143 
00154   TQCString encodedName() const;
00155 
00159   int socketType() const;
00160 
00164   int protocol() const;
00165 
00172   KResolverEntry& operator=(const KResolverEntry& other);
00173 
00174 private:
00175   KResolverEntryPrivate* d;
00176 };
00177 
00178 class KResolverResultsPrivate;
00197 class KDECORE_EXPORT KResolverResults: public TQValueList<KResolverEntry>
00198 {
00199 public:
00205   KResolverResults();
00206 
00213   KResolverResults(const KResolverResults& other);
00214 
00220   virtual ~KResolverResults();
00221 
00228   KResolverResults& operator=(const KResolverResults& other);
00229 
00234   int error() const;
00235 
00240   int systemError() const;
00241 
00248   void setError(int errorcode, int systemerror = 0);
00249 
00253   TQString nodeName() const;
00254 
00258   TQString serviceName() const;
00259 
00263   void setAddress(const TQString& host, const TQString& service);
00264 
00265 protected:
00266   virtual void virtual_hook( int id, void* data );
00267 private:
00268   KResolverResultsPrivate* d;
00269 };
00270 
00271 class KResolverPrivate;
00295 class KDECORE_EXPORT KResolver: public TQObject
00296 {
00297   Q_OBJECT
00298   TQ_OBJECT
00299 
00300 public:
00301 
00318   enum SocketFamilies
00319   {
00320     UnknownFamily = 0x0001,
00321 
00322     UnixFamily = 0x0002,
00323     LocalFamily = UnixFamily,
00324 
00325     IPv4Family = 0x0004,
00326     IPv6Family = 0x0008,
00327     InternetFamily = IPv4Family | IPv6Family,
00328     InetFamily = InternetFamily,
00329 
00330     KnownFamily = ~UnknownFamily,
00331     AnyFamily = KnownFamily | UnknownFamily
00332   };
00333 
00352   enum Flags
00353     {
00354       Passive = 0x01,
00355       CanonName = 0x02,
00356       NoResolve = 0x04,
00357       NoSrv = 0x08,
00358       Multiport = 0x10,
00359       UseSrv = 0x20
00360     };
00361 
00383   enum ErrorCodes
00384     {
00385       // note: if you change this enum, take a look at KResolver::errorString
00386       NoError = 0,
00387       AddrFamily = -1,
00388       TryAgain = -2,
00389       NonRecoverable = -3,
00390       BadFlags = -4,
00391       Memory = -5,
00392       NoName = -6,
00393       UnsupportedFamily = -7,
00394       UnsupportedService = -8,
00395       UnsupportedSocketType = -9,
00396       UnknownError = -10,
00397       SystemError = -11,
00398       Canceled = -100
00399     };
00400 
00421   enum StatusCodes
00422     {
00423       Idle = 0,
00424       Queued = 1,
00425       InProgress = 5,
00426       PostProcessing = 6,
00427       Success = 10,
00428       //Canceled = -100,    // already defined above
00429       Failed = -101
00430     };
00431 
00439   KResolver(TQObject * = 0L, const char * = 0L);
00440 
00451   KResolver(const TQString& nodename, const TQString& servicename = TQString::null,
00452         TQObject * = 0L, const char * = 0L);
00453 
00461   virtual ~KResolver();
00462 
00468   int status() const;
00469 
00480   int error() const;
00481 
00489   int systemError() const;
00490 
00494   inline TQString errorString() const
00495   { return errorString(error(), systemError()); }
00496 
00500   bool isRunning() const;
00501 
00505   TQString nodeName() const;
00506 
00510   TQString serviceName() const;
00511 
00518   void setNodeName(const TQString& nodename);
00519 
00526   void setServiceName(const TQString& service);
00527 
00535   void setAddress(const TQString& node, const TQString& service);
00536 
00542   int flags() const;
00543 
00551   int setFlags(int flags);
00552 
00559   void setFamily(int families);
00560 
00580   void setSocketType(int type);
00581 
00606   void setProtocol(int protonum, const char *name = 0L);
00607 
00626   bool start();
00627 
00649   bool wait(int msec = 0);
00650 
00662   void cancel(bool emitSignal = true);
00663 
00674   KResolverResults results() const;
00675 
00684   virtual bool event(TQEvent*);
00685 
00686 signals:
00687   // signals
00688 
00705   void finished(KResolverResults results);
00706 
00707 private:
00708   void emitFinished();
00709 
00710 public:
00711   // Static functions
00712 
00721   static TQString errorString(int errorcode, int syserror = 0);
00722 
00746   static KResolverResults resolve(const TQString& host, const TQString& service,
00747                  int flags = 0, int families = KResolver::InternetFamily);
00748 
00783   static bool resolveAsync(TQObject* userObj, const char *userSlot,
00784                const TQString& host, const TQString& service,
00785                int flags = 0, int families = KResolver::InternetFamily);
00786 
00803   static TQCString domainToAscii(const TQString& unicodeDomain);
00804 
00823   static TQString domainToUnicode(const TQCString& asciiDomain);
00824 
00832   static TQString domainToUnicode(const TQString& asciiDomain);
00833 
00857   static TQString normalizeDomain(const TQString& domain);
00858 
00868   static TQStrList protocolName(int protonum);
00869 
00877   static TQStrList protocolName(const char *protoname);
00878 
00885   static int protocolNumber(const char *protoname);
00886 
00894   static int servicePort(const char *servname, const char *protoname);
00895 
00906   static TQStrList serviceName(const char *servname, const char *protoname);
00907 
00918   static TQStrList serviceName(int port, const char *protoname);
00919 
00926   static TQString localHostName();
00927 
00928 protected:
00929 
00933   void setError(int errorcode, int systemerror = 0);
00934 
00935   virtual void virtual_hook( int id, void* data );
00936 private:
00937   KResolverPrivate* d;
00938   friend class KResolverResults;
00939   friend class ::KNetwork::Internal::KResolverManager;
00940   
00941   static TQStringList *idnDomains;
00942 };
00943 
00944 }               // namespace KNetwork
00945 
00946 #endif

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |