KDECore
KNetwork::KResolverWorkerBase Class Reference
#include <kresolverworkerbase.h>
Classes | |
class | ResolverLocker |
Helper class for locking the resolver subsystem. More... | |
Public Member Functions | |
int | familyMask () const |
void | finished () |
int | flags () const |
KResolverWorkerBase () | |
QString | nodeName () const |
int | protocol () const |
QCString | protocolName () const |
QString | serviceName () const |
int | socketType () const |
virtual | ~KResolverWorkerBase () |
Public Attributes | |
KResolverResults | results |
Protected Member Functions | |
void | acquireResolver () |
bool | checkResolver () |
bool | enqueue (KResolverWorkerBase *worker) |
bool | enqueue (KResolver *other) |
virtual bool | postprocess () |
virtual bool | preprocess ()=0 |
void | releaseResolver () |
virtual bool | run ()=0 |
void | setError (int errorcode, int syserror=0) |
Detailed Description
For internal use only.
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!
Definition at line 60 of file kresolverworkerbase.h.
Constructor & Destructor Documentation
KResolverWorkerBase::KResolverWorkerBase | ( | ) |
Definition at line 39 of file kresolverworkerbase.cpp.
KResolverWorkerBase::~KResolverWorkerBase | ( | ) | [virtual] |
Definition at line 44 of file kresolverworkerbase.cpp.
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.
- Since:
- 3.4
Definition at line 134 of file kresolverworkerbase.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.
- Since:
- 3.4
Definition at line 128 of file kresolverworkerbase.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 114 of file kresolverworkerbase.cpp.
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 queueing or false if a problem ocurred
Definition at line 108 of file kresolverworkerbase.cpp.
int KResolverWorkerBase::familyMask | ( | ) | const |
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 98 of file kresolverworkerbase.cpp.
int KResolverWorkerBase::flags | ( | ) | const |
QString KResolverWorkerBase::nodeName | ( | ) | const |
bool KResolverWorkerBase::postprocess | ( | ) | [protected, virtual] |
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 103 of file kresolverworkerbase.cpp.
virtual bool KNetwork::KResolverWorkerBase::preprocess | ( | ) | [protected, pure 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 |
QCString KResolverWorkerBase::protocolName | ( | ) | const |
void KResolverWorkerBase::releaseResolver | ( | ) | [protected] |
This function is the counterpart for acquireResolver: the worker thread indicates that it's done with the resolver.
- Since:
- 3.4
Definition at line 140 of file kresolverworkerbase.cpp.
virtual bool KNetwork::KResolverWorkerBase::run | ( | ) | [protected, pure virtual] |
This is the function that should be overriden 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 |
void KNetwork::KResolverWorkerBase::setError | ( | int | errorcode, | |
int | syserror = 0 | |||
) | [inline, protected] |
int KResolverWorkerBase::socketType | ( | ) | const |
Member Data Documentation
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 125 of file kresolverworkerbase.h.
The documentation for this class was generated from the following files: