KNetwork::KResolverWorkerBase

KNetwork::KResolverWorkerBase Class Referenceabstract

#include <k3resolverworkerbase.h>

Classes

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!

Deprecated:
Use KSocketFactory or KLocalSocket instead

Definition at line 65 of file k3resolverworkerbase.h.

Member Function Documentation

void KResolverWorkerBase::acquireResolver ( )
protected

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 141 of file k3resolverworkerbase.cpp.

bool KResolverWorkerBase::checkResolver ( )
protected

Checks the resolver subsystem status.

Returns
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 135 of file k3resolverworkerbase.cpp.

bool KResolverWorkerBase::enqueue ( KResolver other)
protected

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.

Returns
true on successful queuing or false if a problem ocurred

Definition at line 115 of file k3resolverworkerbase.cpp.

bool KResolverWorkerBase::enqueue ( KResolverWorkerBase worker)
protected

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 121 of file k3resolverworkerbase.cpp.

int KResolverWorkerBase::familyMask ( ) const

gets the family mask

Definition at line 72 of file k3resolverworkerbase.cpp.

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 105 of file k3resolverworkerbase.cpp.

int KResolverWorkerBase::flags ( ) const

gets the flags

Definition at line 64 of file k3resolverworkerbase.cpp.

QString KResolverWorkerBase::nodeName ( ) const

This is the hostname to be looked for.

Definition at line 48 of file k3resolverworkerbase.cpp.

bool KResolverWorkerBase::postprocess ( )
protectedvirtual

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.

Returns
true on success

Definition at line 110 of file k3resolverworkerbase.cpp.

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.

Returns
true on success
int KResolverWorkerBase::protocol ( ) const

gets the protocol number

Definition at line 88 of file k3resolverworkerbase.cpp.

QByteArray KResolverWorkerBase::protocolName ( ) const

gets the protocol name, if applicable

Definition at line 96 of file k3resolverworkerbase.cpp.

void KResolverWorkerBase::releaseResolver ( )
protected

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

Definition at line 147 of file k3resolverworkerbase.cpp.

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!

Returns
true on success
QString KResolverWorkerBase::serviceName ( ) const

And this is the service name.

Definition at line 56 of file k3resolverworkerbase.cpp.

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

Sets the error.

Definition at line 231 of file k3resolverworkerbase.h.

int KResolverWorkerBase::socketType ( ) const

gets the socket type

Definition at line 80 of file k3resolverworkerbase.cpp.

Member Data Documentation

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-2020 The KDE developers.
Generated on Tue Jul 7 2020 22:56:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.