kreverseresolver.h
00001 /* -*- C++ -*- 00002 * Copyright (C) 2003 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 KREVERSERESOLVER_H 00026 #define KREVERSERESOLVER_H 00027 00029 // Needed includes 00030 #include <tqobject.h> 00031 #include <tqstring.h> 00032 00033 #include "ksocketaddress.h" 00034 00035 namespace KNetwork { 00036 00037 class KReverseResolverPrivate; 00050 class KDECORE_EXPORT KReverseResolver: public TQObject 00051 { 00052 Q_OBJECT 00053 TQ_OBJECT 00054 00055 public: 00075 enum Flags 00076 { 00077 NumericHost = 0x01, 00078 NumericService = 0x02, 00079 NodeNameOnly = 0x04, 00080 Datagram = 0x08, 00081 NumericScope = 0x10, 00082 ResolutionRequired = 0x20 00083 }; 00084 00091 KReverseResolver(const KSocketAddress& addr, int flags = 0, 00092 TQObject * = 0L, const char * = 0L); 00093 00097 virtual ~KReverseResolver(); 00098 00102 bool isRunning() const; 00103 00108 bool success() const; 00109 00114 bool failure() const; 00115 00120 TQString node() const; 00121 00126 TQString service() const; 00127 00131 const KSocketAddress& address() const; 00132 00137 bool start(); 00138 00142 virtual bool event(TQEvent* ); 00143 00144 signals: 00150 void finished(const KReverseResolver& obj); 00151 00152 public: 00168 static bool resolve(const KSocketAddress& addr, TQString& node, 00169 TQString& serv, int flags = 0); 00170 00187 static bool resolve(const struct sockaddr* sa, TQ_UINT16 salen, 00188 TQString& node, TQString& serv, int flags = 0); 00189 00190 private: 00191 KReverseResolverPrivate* d; 00192 }; 00193 00194 } // namespace KNetwork 00195 00196 #endif