Search for usage in LXR

KNetwork::KResolverWorkerBase Class Referenceabstract

#include <k3resolverworkerbase.h>


class  ResolverLocker

Public Member Functions

int familyMask () const
void finished ()
int flags () const
QString nodeName () const
int protocol () const
QByteArray protocolName () const
QString serviceName () const
int socketType () const

Public Attributes

KResolverResults results

Protected Member Functions

void acquireResolver ()
bool checkResolver ()
bool enqueue (KResolver *other)
bool enqueue (KResolverWorkerBase *worker)
virtual bool postprocess ()
virtual bool preprocess ()=0
void releaseResolver ()
virtual bool run ()=0
void setError (int errorcode, int syserror=0)

Detailed Description

This class is the base functionality for a resolver worker. That is, the class that does the actual work.

In the future, this class might be exposed to allow plug-ins. So, try and make it binary compatible.

Note that hostnames are still encoded in Unicode at this point. It's up to the worker class to decide which encoding to use. In the case of DNS, an ASCII Compatible Encoding (ACE) must be used. See KResolver::domainToAscii().

Also specially note that the run method in this class is called in a thread that is not the program's main thread. So do not do anything there that you shouldn't!

Use KSocketFactory or KLocalSocket instead

Definition at line 65 of file k3resolverworkerbase.h.

Member Function Documentation

◆ acquireResolver()

void KResolverWorkerBase::acquireResolver ( )

This function has to be called from the resolver workers that require use of the DNS resolver code (i.e., res_* functions, generally in libresolv).

It indicates that the function is starting a resolution and that the resolver backend shouldn't change asynchronously.

If any pending res_init's are required, they will be performed before this function returns.

Definition at line 140 of file k3resolverworkerbase.cpp.

◆ checkResolver()

bool KResolverWorkerBase::checkResolver ( )

Checks the resolver subsystem status.

true if the resolver subsystem changed, false otherwise. If this function returns true, it might be necessary to restart the resolution altogether.

Definition at line 134 of file k3resolverworkerbase.cpp.

◆ enqueue() [1/2]

bool KResolverWorkerBase::enqueue ( KResolver other)

Enqueue the given resolver for post-processing.

Use this function to make the manager call for another resolution. This is suitable for workers that do post-processing.

The manager will make sure that any requests enqueued by this function are done before calling the postprocessing function, which you should override.

Important: do use KResolver's own enqueueing functions (i.e., KResolver::start()). Instead, use this function.

true on successful queuing or false if a problem ocurred

Definition at line 114 of file k3resolverworkerbase.cpp.

◆ enqueue() [2/2]

bool KResolverWorkerBase::enqueue ( KResolverWorkerBase worker)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 120 of file k3resolverworkerbase.cpp.

◆ familyMask()

int KResolverWorkerBase::familyMask ( ) const

gets the family mask

Definition at line 71 of file k3resolverworkerbase.cpp.

◆ finished()

void KResolverWorkerBase::finished ( )

Call this function to indicate that processing has finished.

This is useful in the preprocessing stage, to indicate that run() doesn't have to be called.

Definition at line 104 of file k3resolverworkerbase.cpp.

◆ flags()

int KResolverWorkerBase::flags ( ) const

gets the flags

Definition at line 63 of file k3resolverworkerbase.cpp.

◆ nodeName()

QString KResolverWorkerBase::nodeName ( ) const

This is the hostname to be looked for.

Definition at line 47 of file k3resolverworkerbase.cpp.

◆ postprocess()

bool KResolverWorkerBase::postprocess ( )

This function gets called during post processing for this class.

Important: this function gets called in the main event thread. And it MUST NOT block.

true on success

Definition at line 109 of file k3resolverworkerbase.cpp.

◆ preprocess()

virtual bool KNetwork::KResolverWorkerBase::preprocess ( )
protectedpure virtual

This function gets called during pre processing for this class and you must override it.

Important: this function gets called in the main event thread. And it MUST NOT block.

This function can be used for an object to determine if it will be able to resolve the given data or not even before launching into a blocking operation. This function should return true if the object is capable of handling this kind of data; false otherwise. Note that the return value of 'true' means that the object's blocking answer will be considered authoritative.

This function MUST NOT queue further requests. Leave that to run().

This function is pure virtual; you must override it.

true on success

◆ protocol()

int KResolverWorkerBase::protocol ( ) const

gets the protocol number

Definition at line 87 of file k3resolverworkerbase.cpp.

◆ protocolName()

QByteArray KResolverWorkerBase::protocolName ( ) const

gets the protocol name, if applicable

Definition at line 95 of file k3resolverworkerbase.cpp.

◆ releaseResolver()

void KResolverWorkerBase::releaseResolver ( )

This function is the counterpart for acquireResolver() - the worker thread indicates that it's done with the resolver.

Definition at line 146 of file k3resolverworkerbase.cpp.

◆ run()

virtual bool KNetwork::KResolverWorkerBase::run ( )
protectedpure virtual

This is the function that should be overridden in derived classes.

Derived classes will do their blocking job in this function and return either success or failure to work (not the lookup). That is, whether the lookup result was a domain found or not, if we got our answer, we should indicate success. The error itself must be set with setError().

Important: this function gets called in a separate thread!

true on success

◆ serviceName()

QString KResolverWorkerBase::serviceName ( ) const

And this is the service name.

Definition at line 55 of file k3resolverworkerbase.cpp.

◆ setError()

void KNetwork::KResolverWorkerBase::setError ( int  errorcode,
int  syserror = 0 

Sets the error.

Definition at line 231 of file k3resolverworkerbase.h.

◆ socketType()

int KResolverWorkerBase::socketType ( ) const

gets the socket type

Definition at line 79 of file k3resolverworkerbase.cpp.

Member Data Documentation

◆ results

KResolverResults KNetwork::KResolverWorkerBase::results

Derived classes will put their resolved data in this list, or will leave it empty in case of error.

Status and error codes should also be stored in this object (the setError() function does that).

Definition at line 129 of file k3resolverworkerbase.h.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Jan 30 2023 04:01:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.