• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • network
k3resolver.h
Go to the documentation of this file.
1 /* -*- mode: C++; coding: utf-8; -*-
2  * Copyright (C) 2003,2005 Thiago Macieira <thiago@kde.org>
3  *
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KRESOLVER_H
26 #define KRESOLVER_H
27 
29 // Needed includes
30 #include <QtCore/QList>
31 #include <QtCore/QObject>
32 #include <QtCore/QSharedDataPointer>
33 #include "k3socketaddress.h"
34 
35 
37 // Forward declarations
38 struct sockaddr;
39 class QString;
40 class QByteArray;
41 template<typename T> class QSet;
42 
44 // Our definitions
45 
46 namespace KNetwork {
47 
48  namespace Internal { class KResolverManager; }
49 
50 class KResolverEntryPrivate;
68 class KDECORE_EXPORT_DEPRECATED KResolverEntry
69 {
70 public:
75  KResolverEntry();
76 
89  KResolverEntry(const KSocketAddress& addr, int socktype, int protocol,
90  const QString& canonName = QString(),
91  const QByteArray& encodedName = QByteArray());
92 
106  KResolverEntry(const struct sockaddr *sa, quint16 salen, int socktype,
107  int protocol, const QString& canonName = QString(),
108  const QByteArray& encodedName = QByteArray());
109 
115  KResolverEntry(const KResolverEntry &other);
116 
123  ~KResolverEntry();
124 
128  KSocketAddress address() const;
129 
133  quint16 length() const;
134 
138  int family() const;
139 
144  QString canonicalName() const;
145 
156  QByteArray encodedName() const;
157 
161  int socketType() const;
162 
166  int protocol() const;
167 
174  KResolverEntry& operator=(const KResolverEntry& other);
175 
176 #ifdef MAKE_KDECORE_LIB
177 
181  KDE_DUMMY_COMPARISON_OPERATOR(KResolverEntry)
182 #endif
183 
184 private:
185  QSharedDataPointer<KResolverEntryPrivate> d;
186 };
187 
188 #ifdef MAKE_KDECORE_LIB
189 KDE_DUMMY_QHASH_FUNCTION(KResolverEntry)
190 #endif
191 
192 class KResolverResultsPrivate;
212 class KDECORE_EXPORT_DEPRECATED KResolverResults: public QList<KResolverEntry>
213 {
214 public:
220  KResolverResults();
221 
228  KResolverResults(const KResolverResults& other);
229 
235  virtual ~KResolverResults();
236 
243  KResolverResults& operator=(const KResolverResults& other);
244 
249  int error() const;
250 
255  int systemError() const;
256 
263  void setError(int errorcode, int systemerror = 0);
264 
268  QString nodeName() const;
269 
273  QString serviceName() const;
274 
278  void setAddress(const QString& host, const QString& service);
279 
280 protected:
282  virtual void virtual_hook( int id, void* data );
283 private:
284  QSharedDataPointer<KResolverResultsPrivate> d;
285 };
286 
287 class KResolverPrivate;
312 class KDECORE_EXPORT_DEPRECATED KResolver: public QObject
313 {
314  Q_OBJECT
315 
316 public:
317 
334  enum SocketFamilies
335  {
336  UnknownFamily = 0x0001,
337 
338  UnixFamily = 0x0002,
339  LocalFamily = UnixFamily,
340 
341  IPv4Family = 0x0004,
342  IPv6Family = 0x0008,
343  InternetFamily = IPv4Family | IPv6Family,
344  InetFamily = InternetFamily,
345 
346  KnownFamily = ~UnknownFamily,
347  AnyFamily = KnownFamily | UnknownFamily
348  };
349 
367  enum Flags
368  {
369  Passive = 0x01,
370  CanonName = 0x02,
371  NoResolve = 0x04,
372  NoSrv = 0x08,
373  Multiport = 0x10
374  };
375 
397  enum ErrorCodes
398  {
399  // note: if you change this enum, take a look at KResolver::errorString
400  NoError = 0,
401  AddrFamily = -1,
402  TryAgain = -2,
403  NonRecoverable = -3,
404  BadFlags = -4,
405  Memory = -5,
406  NoName = -6,
407  UnsupportedFamily = -7,
408  UnsupportedService = -8,
409  UnsupportedSocketType = -9,
410  UnknownError = -10,
411  SystemError = -11,
412  Canceled = -100
413  };
414 
435  enum StatusCodes
436  {
437  Idle = 0,
438  Queued = 1,
439  InProgress = 5,
440  PostProcessing = 6,
441  Success = 10,
442  //Canceled = -100, // already defined above
443  Failed = -101
444  };
445 
455  KResolver(QObject *parent = 0L);
456 
468  explicit KResolver(const QString& nodename, const QString& servicename = QString(),
469  QObject *parent = 0L);
470 
478  virtual ~KResolver();
479 
485  int status() const;
486 
497  int error() const;
498 
506  int systemError() const;
507 
511  QString errorString() const;
512 
516  bool isRunning() const;
517 
521  QString nodeName() const;
522 
526  QString serviceName() const;
527 
534  void setNodeName(const QString& nodename);
535 
542  void setServiceName(const QString& service);
543 
551  void setAddress(const QString& node, const QString& service);
552 
558  int flags() const;
559 
567  int setFlags(int flags);
568 
575  void setFamily(int families);
576 
596  void setSocketType(int type);
597 
622  void setProtocol(int protonum, const char *name = 0L);
623 
642  bool start();
643 
665  bool wait(int msec = 0);
666 
678  void cancel(bool emitSignal = true);
679 
690  KResolverResults results() const;
691 
700  virtual bool event(QEvent*);
701 
702 Q_SIGNALS:
703  // signals
704 
721  void finished(const KNetwork::KResolverResults& results);
722 
723 private:
724  void emitFinished();
725 
726 public:
727  // Static functions
728 
737  static QString errorString(int errorcode, int syserror = 0);
738 
762  static KResolverResults resolve(const QString& host, const QString& service,
763  int flags = 0, int families = KResolver::InternetFamily);
764 
799  static bool resolveAsync(QObject* userObj, const char *userSlot,
800  const QString& host, const QString& service,
801  int flags = 0, int families = KResolver::InternetFamily);
802 
819  static QByteArray domainToAscii(const QString& unicodeDomain);
820 
839  static QString domainToUnicode(const QByteArray& asciiDomain);
840 
848  static QString domainToUnicode(const QString& asciiDomain);
849 
873  static QString normalizeDomain(const QString& domain);
874 
884  static QList<QByteArray> protocolName(int protonum);
885 
893  static QList<QByteArray> protocolName(const char *protoname);
894 
901  static int protocolNumber(const char *protoname);
902 
910  static int servicePort(const char *servname, const char *protoname);
911 
922  static QList<QByteArray> serviceName(const char *servname, const char *protoname);
923 
934  static QList<QByteArray> serviceName(int port, const char *protoname);
935 
941  static QString localHostName();
942 
943 protected:
944 
948  void setError(int errorcode, int systemerror = 0);
949 
951  virtual void virtual_hook( int id, void* data );
952 private:
953  KResolverPrivate* const d;
954  friend class KResolverResults;
955  friend class ::KNetwork::Internal::KResolverManager;
956 };
957 
958 } // namespace KNetwork
959 
960 #endif
k3socketaddress.h
QEvent
QByteArray
KNetwork::KResolver::ErrorCodes
ErrorCodes
Error codes.
Definition: k3resolver.h:397
KNetwork::KResolverEntry
One resolution entry.
Definition: k3resolver.h:68
KNetwork::KResolver
Name and service resolution class.
Definition: k3resolver.h:312
KNetwork::KSocketAddress
A generic socket address.
Definition: k3socketaddress.h:414
KNetwork::KResolverResults
Name and service resolution results.
Definition: k3resolver.h:212
KNetwork::KResolverPrivate
Definition: k3resolver_p.h:101
setError
static void setError(QAbstractSocket *socket, QAbstractSocket::SocketError error, const QString &errorString)
Definition: ksocketfactory.cpp:44
KDE_DUMMY_QHASH_FUNCTION
#define KDE_DUMMY_QHASH_FUNCTION(C)
The KDE_DUMMY_QHASH_FUNCTION defines a simple hash-function for classes.
Definition: kdemacros.h.cmake:409
QObject
KDE_DUMMY_COMPARISON_OPERATOR
#define KDE_DUMMY_COMPARISON_OPERATOR(C)
The KDE_DUMMY_COMPARISON_OPERATOR defines a simple compare operator for classes.
Definition: kdemacros.h.cmake:408
KNetwork::Internal::KResolverManager
Definition: k3resolver_p.h:156
QSet
Definition: k3resolver.h:41
QString
QList
Definition: kaboutdata.h:33
KNetwork::KResolver::InternetFamily
Definition: k3resolver.h:343
KNetwork::KResolver::Flags
Flags
Flags for the resolution.
Definition: k3resolver.h:367
KShell::NoError
Success.
Definition: kshell.h:89
KNetwork::KResolver::SocketFamilies
SocketFamilies
Address family selection types.
Definition: k3resolver.h:334
QSharedDataPointer< KResolverEntryPrivate >
KNetwork::KResolver::StatusCodes
StatusCodes
Status codes.
Definition: k3resolver.h:435
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal