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

tdecore

  • tdecore
  • network
kresolver.h
1/*
2 * Copyright (C) 2003,2005 Thiago Macieira <thiago.macieira@kdemail.net>
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 <tqvaluelist.h>
31#include <tqobject.h>
32#include "tdesocketaddress.h"
33
34
36// Forward declarations
37struct sockaddr;
38class TQString;
39class TQCString;
40class TQStrList;
41
43// Our definitions
44
45namespace KNetwork {
46
47 namespace Internal { class KResolverManager; }
48
49class KResolverEntryPrivate;
66class TDECORE_EXPORT KResolverEntry
67{
68public:
73 KResolverEntry();
74
87 KResolverEntry(const TDESocketAddress& addr, int socktype, int protocol,
88 const TQString& canonName = TQString::null,
89 const TQCString& encodedName = TQCString());
90
104 KResolverEntry(const struct sockaddr *sa, TQ_UINT16 salen, int socktype,
105 int protocol, const TQString& canonName = TQString::null,
106 const TQCString& encodedName = TQCString());
107
113 KResolverEntry(const KResolverEntry &other);
114
121 ~KResolverEntry();
122
126 TDESocketAddress address() const;
127
131 TQ_UINT16 length() const;
132
136 int family() const;
137
142 TQString canonicalName() const;
143
154 TQCString encodedName() const;
155
159 int socketType() const;
160
164 int protocol() const;
165
172 KResolverEntry& operator=(const KResolverEntry& other);
173
174private:
175 KResolverEntryPrivate* d;
176};
177
178class KResolverResultsPrivate;
197class TDECORE_EXPORT KResolverResults: public TQValueList<KResolverEntry>
198{
199public:
205 KResolverResults();
206
213 KResolverResults(const KResolverResults& other);
214
220 virtual ~KResolverResults();
221
228 KResolverResults& operator=(const KResolverResults& other);
229
234 int error() const;
235
240 int systemError() const;
241
248 void setError(int errorcode, int systemerror = 0);
249
253 TQString nodeName() const;
254
258 TQString serviceName() const;
259
263 void setAddress(const TQString& host, const TQString& service);
264
265protected:
266 virtual void virtual_hook( int id, void* data );
267private:
268 KResolverResultsPrivate* d;
269};
270
271class KResolverPrivate;
295class TDECORE_EXPORT KResolver: public TQObject
296{
297 TQ_OBJECT
298
299
300public:
301
318 enum SocketFamilies
319 {
320 UnknownFamily = 0x0001,
321
322 UnixFamily = 0x0002,
323 LocalFamily = UnixFamily,
324
325 IPv4Family = 0x0004,
326 IPv6Family = 0x0008,
327 InternetFamily = IPv4Family | IPv6Family,
328 InetFamily = InternetFamily,
329
330 KnownFamily = ~UnknownFamily,
331 AnyFamily = KnownFamily | UnknownFamily
332 };
333
352 enum Flags
353 {
354 Passive = 0x01,
355 CanonName = 0x02,
356 NoResolve = 0x04,
357 NoSrv = 0x08,
358 Multiport = 0x10,
359 UseSrv = 0x20
360 };
361
383 enum ErrorCodes
384 {
385 // note: if you change this enum, take a look at KResolver::errorString
386 NoError = 0,
387 AddrFamily = -1,
388 TryAgain = -2,
389 NonRecoverable = -3,
390 BadFlags = -4,
391 Memory = -5,
392 NoName = -6,
393 UnsupportedFamily = -7,
394 UnsupportedService = -8,
395 UnsupportedSocketType = -9,
396 UnknownError = -10,
397 SystemError = -11,
398 Canceled = -100
399 };
400
421 enum StatusCodes
422 {
423 Idle = 0,
424 Queued = 1,
425 InProgress = 5,
426 PostProcessing = 6,
427 Success = 10,
428 //Canceled = -100, // already defined above
429 Failed = -101
430 };
431
439 KResolver(TQObject * = 0L, const char * = 0L);
440
451 KResolver(const TQString& nodename, const TQString& servicename = TQString::null,
452 TQObject * = 0L, const char * = 0L);
453
461 virtual ~KResolver();
462
468 int status() const;
469
480 int error() const;
481
489 int systemError() const;
490
494 inline TQString errorString() const
495 { return errorString(error(), systemError()); }
496
500 bool isRunning() const;
501
505 TQString nodeName() const;
506
510 TQString serviceName() const;
511
518 void setNodeName(const TQString& nodename);
519
526 void setServiceName(const TQString& service);
527
535 void setAddress(const TQString& node, const TQString& service);
536
542 int flags() const;
543
551 int setFlags(int flags);
552
559 void setFamily(int families);
560
580 void setSocketType(int type);
581
606 void setProtocol(int protonum, const char *name = 0L);
607
626 bool start();
627
649 bool wait(int msec = 0);
650
662 void cancel(bool emitSignal = true);
663
674 KResolverResults results() const;
675
684 virtual bool event(TQEvent*);
685
686signals:
687 // signals
688
705 void finished(KResolverResults results);
706
707private:
708 void emitFinished();
709
710public:
711 // Static functions
712
721 static TQString errorString(int errorcode, int syserror = 0);
722
746 static KResolverResults resolve(const TQString& host, const TQString& service,
747 int flags = 0, int families = KResolver::InternetFamily);
748
783 static bool resolveAsync(TQObject* userObj, const char *userSlot,
784 const TQString& host, const TQString& service,
785 int flags = 0, int families = KResolver::InternetFamily);
786
803 static TQCString domainToAscii(const TQString& unicodeDomain);
804
823 static TQString domainToUnicode(const TQCString& asciiDomain);
824
832 static TQString domainToUnicode(const TQString& asciiDomain);
833
857 static TQString normalizeDomain(const TQString& domain);
858
868 static TQStrList protocolName(int protonum);
869
877 static TQStrList protocolName(const char *protoname);
878
885 static int protocolNumber(const char *protoname);
886
894 static int servicePort(const char *servname, const char *protoname);
895
906 static TQStrList serviceName(const char *servname, const char *protoname);
907
918 static TQStrList serviceName(int port, const char *protoname);
919
926 static TQString localHostName();
927
928protected:
929
933 void setError(int errorcode, int systemerror = 0);
934
935 virtual void virtual_hook( int id, void* data );
936private:
937 KResolverPrivate* d;
938 friend class KResolverResults;
939 friend class ::KNetwork::Internal::KResolverManager;
940
941 static TQStringList *idnDomains;
942};
943
944} // namespace KNetwork
945
946#endif
KNetwork::KResolverEntry
One resolution entry.
Definition: kresolver.h:67
KNetwork::KResolverResults
Name and service resolution results.
Definition: kresolver.h:198
KNetwork::KResolver
Name and service resolution class.
Definition: kresolver.h:296
KNetwork::KResolver::errorString
TQString errorString() const
Returns the textual representation of the error in this object.
Definition: kresolver.h:494
KNetwork::KResolver::setError
void setError(int errorcode, int systemerror=0)
Sets the error codes.
KNetwork::KResolver::SocketFamilies
SocketFamilies
Address family selection types.
Definition: kresolver.h:319
KNetwork::KResolver::finished
void finished(KResolverResults results)
This signal is emitted whenever the resolution is finished, one way or another (success or failure).
KNetwork::KResolver::Flags
Flags
Flags for the resolution.
Definition: kresolver.h:353
KNetwork::KResolver::ErrorCodes
ErrorCodes
Error codes.
Definition: kresolver.h:384
KNetwork::KResolver::StatusCodes
StatusCodes
Status codes.
Definition: kresolver.h:422
KNetwork::TDESocketAddress
A generic socket address.
Definition: tdesocketaddress.h:424
KNetwork
A namespace to store all networking-related (socket) classes.
Definition: kbufferedsocket.h:36

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.