akonadi
Akonadi::AgentBase Class Reference
#include <agentbase.h>

Detailed Description
The base class for all Akonadi agents and resources.This class is a base class for all Akonadi agents, which covers the real agent processes and all resources.
It provides:
- lifetime management
- change monitoring and recording
- configuration interface
- problem reporting
Definition at line 58 of file agentbase.h.
Public Types | |
enum | Status { Idle = 0, Running, Broken } |
Signals | |
void | error (const QString &message) |
void | percent (int progress) |
void | status (int status, const QString &message=QString()) |
void | warning (const QString &message) |
Public Member Functions | |
virtual void | cleanup () |
virtual void | configure (WId windowId) |
QString | identifier () const |
virtual int | progress () const |
virtual QString | progressMessage () const |
void | registerObserver (Observer *observer) |
virtual int | status () const |
virtual QString | statusMessage () const |
WId | winIdForDialogs () const |
Static Public Member Functions | |
template<typename T> | |
static int | init (int argc, char **argv) |
Protected Member Functions | |
virtual void | aboutToQuit () |
AgentBase (const QString &id) | |
void | changeProcessed () |
ChangeRecorder * | changeRecorder () const |
virtual void | doSetOnline (bool online) |
bool | isOnline () const |
void | setOnline (bool state) |
~AgentBase () | |
Classes | |
class | Observer |
The interface for reacting on monitored or replayed changes. More... |
Member Enumeration Documentation
This enum describes the different states the agent can be in.
- Enumerator:
-
Idle The agent does currently nothing. Running The agent is working on something. Broken The agent encountered an error state.
Definition at line 214 of file agentbase.h.
Constructor & Destructor Documentation
Akonadi::AgentBase::AgentBase | ( | const QString & | id | ) | [protected] |
Creates an agent base.
- Parameters:
-
id The instance id of the agent.
AgentBase::~AgentBase | ( | ) | [protected] |
Member Function Documentation
void AgentBase::aboutToQuit | ( | ) | [protected, virtual] |
This method is called whenever the agent application is about to quit.
Reimplement this method to do session cleanup (e.g. disconnecting from groupware server).
Definition at line 433 of file agentbase.cpp.
void AgentBase::changeProcessed | ( | ) | [protected] |
Marks the current change as processes and replays the next change if change recording is enabled (noop otherwise).
This method is called from the default implementation of the change notification slots. While not required when not using change recording, it is nevertheless recommended to call this method when done with processing a change notification.
Definition at line 468 of file agentbase.cpp.
ChangeRecorder * AgentBase::changeRecorder | ( | ) | const [protected] |
Returns the Akonadi::ChangeRecorder object used for monitoring.
Use this to configure which parts you want to monitor.
Definition at line 474 of file agentbase.cpp.
void AgentBase::cleanup | ( | ) | [virtual] |
This method is called when the agent is removed from the system, so it can do some cleanup stuff.
Definition at line 437 of file agentbase.cpp.
void AgentBase::configure | ( | WId | windowId | ) | [virtual] |
This method is called whenever the agent shall show its configuration dialog to the user.
It will be automatically called when the agent is started for the first time.
- Parameters:
-
windowId The parent window id.
Definition at line 391 of file agentbase.cpp.
void AgentBase::doSetOnline | ( | bool | online | ) | [protected, virtual] |
This method is called whenever the online
status has changed.
Reimplement this method to react on online status changes.
Reimplemented in Akonadi::ResourceBase.
Definition at line 386 of file agentbase.cpp.
void Akonadi::AgentBase::error | ( | const QString & | message | ) | [signal] |
This signal shall be used to report errors.
- Parameters:
-
message The i18n'ed error message.
QString AgentBase::identifier | ( | ) | const |
static int Akonadi::AgentBase::init | ( | int | argc, | |
char ** | argv | |||
) | [inline, static] |
Use this method in the main function of your agent application to initialize your agent subclass.
This method also takes care of creating a KApplication object and parsing command line arguments.
- Note:
- In case the given class is also derived from AgentBase::Observer it gets registered as its own observer (see AgentBase::Observer), e.g.
agentInstance->registerObserver( agentInstance );
class MyAgent : public AgentBase { ... }; AKONADI_AGENT_MAIN( MyAgent )
Reimplemented in Akonadi::ResourceBase.
Definition at line 243 of file agentbase.h.
bool AgentBase::isOnline | ( | ) | const [protected] |
void Akonadi::AgentBase::percent | ( | int | progress | ) | [signal] |
This signal should be emitted whenever the progress of an action in the agent (e.g.
data transfer, connection establishment to remote server etc.) has changed.
- Parameters:
-
progress The progress of the action in percent.
int AgentBase::progress | ( | ) | const [virtual] |
This method returns the current progress of the agent in percentage.
Definition at line 357 of file agentbase.cpp.
QString AgentBase::progressMessage | ( | ) | const [virtual] |
This method returns an i18n'ed description of the current progress.
Definition at line 364 of file agentbase.cpp.
void AgentBase::registerObserver | ( | Observer * | observer | ) |
Registers the given observer for reacting on monitored or recorded changes.
- Parameters:
-
observer The change handler to register. No ownership transfer, i.e. the caller stays owner of the pointer and can reset the registration by calling this method with 0
Definition at line 457 of file agentbase.cpp.
void AgentBase::setOnline | ( | bool | state | ) | [protected] |
void Akonadi::AgentBase::status | ( | int | status, | |
const QString & | message = QString() | |||
) | [signal] |
This signal should be emitted whenever the status of the agent has been changed.
- Parameters:
-
status The new Status code. message A i18n'ed description of the new status.
int AgentBase::status | ( | ) | const [virtual] |
This method returns the current status code of the agent.
The following return values are possible:
- 0 - Idle
- 1 - Running
- 2 - Broken
Definition at line 343 of file agentbase.cpp.
QString AgentBase::statusMessage | ( | ) | const [virtual] |
This method returns an i18n'ed description of the current status code.
Definition at line 350 of file agentbase.cpp.
void Akonadi::AgentBase::warning | ( | const QString & | message | ) | [signal] |
This signal shall be used to report warnings.
- Parameters:
-
message The i18n'ed warning message.
WId AgentBase::winIdForDialogs | ( | ) | const |
This method returns the windows id, which should be used for dialogs.
Definition at line 403 of file agentbase.cpp.
The documentation for this class was generated from the following files: