akonadi
Akonadi::AgentBase Class Reference
The base class for all Akonadi agents and resources. More...
#include <agentbase.h>

Classes | |
class | Observer |
The interface for reacting on monitored or replayed changes. More... | |
Public Types | |
enum | Status { Idle = 0, Running, Broken } |
Signals | |
void | agentNameChanged (const QString &name) |
void | error (const QString &message) |
void | onlineChanged (bool b) |
void | percent (int progress) |
void | reloadConfiguration () |
void | status (int status, const QString &message=QString()) |
void | warning (const QString &message) |
Public Member Functions | |
QString | agentName () const |
virtual void | cleanup () |
virtual void | configure (WId windowId) |
QString | identifier () const |
virtual int | progress () const |
virtual QString | progressMessage () const |
void | registerObserver (Observer *observer) |
void | setAgentName (const QString &name) |
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 | setNeedsNetwork (bool needsNetwork) |
void | setOnline (bool state) |
~AgentBase () |
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.
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.
Akonadi::AgentBase::~AgentBase | ( | ) | [protected] |
Destroys the agent base.
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 504 of file agentbase.cpp.
QString AgentBase::agentName | ( | ) | const |
void Akonadi::AgentBase::agentNameChanged | ( | const QString & | name | ) | [signal] |
This signal is emitted whenever the name of the agent has changed.
- Parameters:
-
name The new name of the agent.
- Since:
- 4.3
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 580 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 586 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 508 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 462 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 457 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 |
Returns the instance identifier of this agent.
Definition at line 546 of file agentbase.cpp.
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] |
Returns whether the agent is currently online.
Definition at line 426 of file agentbase.cpp.
void Akonadi::AgentBase::onlineChanged | ( | bool | b | ) | [signal] |
Emitted when the online state changed.
- Parameters:
-
state The online state.
- Since:
- 4.2
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 412 of file agentbase.cpp.
QString AgentBase::progressMessage | ( | ) | const [virtual] |
This method returns an i18n'ed description of the current progress.
Definition at line 419 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 540 of file agentbase.cpp.
void Akonadi::AgentBase::reloadConfiguration | ( | ) | [signal] |
Emitted if another application has changed the agents configuration remotely and called AgentInstance::reconfigure().
- Since:
- 4.2
void AgentBase::setAgentName | ( | const QString & | name | ) |
This method is used to set the name of the agent.
- Since:
- 4.3
Definition at line 551 of file agentbase.cpp.
void AgentBase::setNeedsNetwork | ( | bool | needsNetwork | ) | [protected] |
Sets whether the agent needs network or not.
- Since:
- 4.2
- Todo:
- use this in combination with Solid::Networking::Notifier to change the onLine status of the agent.
Definition at line 433 of file agentbase.cpp.
void AgentBase::setOnline | ( | bool | state | ) | [protected] |
Sets whether the agent shall be online or not.
Definition at line 448 of file agentbase.cpp.
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 398 of file agentbase.cpp.
QString AgentBase::statusMessage | ( | ) | const [virtual] |
This method returns an i18n'ed description of the current status code.
Definition at line 405 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 474 of file agentbase.cpp.
The documentation for this class was generated from the following files: