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 <qobject.h> 00031 #include <qstring.h> 00032 00033 #include "ksocketaddress.h" 00034 00035 namespace KNetwork { 00036 00037 class KReverseResolverPrivate; 00050 class KDECORE_EXPORT KReverseResolver: public QObject 00051 { 00052 Q_OBJECT 00053 00054 public: 00074 enum Flags 00075 { 00076 NumericHost = 0x01, 00077 NumericService = 0x02, 00078 NodeNameOnly = 0x04, 00079 Datagram = 0x08, 00080 NumericScope = 0x10, 00081 ResolutionRequired = 0x20 00082 }; 00083 00090 KReverseResolver(const KSocketAddress& addr, int flags = 0, 00091 QObject * = 0L, const char * = 0L); 00092 00096 virtual ~KReverseResolver(); 00097 00101 bool isRunning() const; 00102 00107 bool success() const; 00108 00113 bool failure() const; 00114 00119 QString node() const; 00120 00125 QString service() const; 00126 00130 const KSocketAddress& address() const; 00131 00136 bool start(); 00137 00141 virtual bool event(QEvent* ); 00142 00143 signals: 00149 void finished(const KReverseResolver& obj); 00150 00151 public: 00167 static bool resolve(const KSocketAddress& addr, QString& node, 00168 QString& serv, int flags = 0); 00169 00186 static bool resolve(const struct sockaddr* sa, Q_UINT16 salen, 00187 QString& node, QString& serv, int flags = 0); 00188 00189 private: 00190 KReverseResolverPrivate* d; 00191 }; 00192 00193 } // namespace KNetwork 00194 00195 #endif