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... | |
class | ObserverV2 |
BC extension of Observer with support for monitoring item and collection moves. More... | |
Public Types | |
enum | Status { Idle = 0, Running, Broken } |
Signals | |
void | abortRequested () |
void | agentNameChanged (const QString &name) |
void | configurationDialogAccepted () |
void | configurationDialogRejected () |
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 | |
AgentBase (const QString &id) | |
~AgentBase () | |
virtual void | aboutToQuit () |
void | changeProcessed () |
ChangeRecorder * | changeRecorder () const |
virtual void | doSetOnline (bool online) |
bool | isOnline () const |
void | setNeedsNetwork (bool needsNetwork) |
void | setOnline (bool state) |
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 277 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 Akonadi::AgentBase::abortRequested | ( | ) | [signal] |
Emitted when another application has remotely asked the agent to abort its current operation.
Connect to this signal if your agent supports abortion. After aborting and cleaning up, agents should return to Idle status.
- Since:
- 4.4
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 609 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 684 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 690 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.
- Note:
- If you reimplement this in a subclass make sure to call this base implementation at the end.
Definition at line 613 of file agentbase.cpp.
void Akonadi::AgentBase::configurationDialogAccepted | ( | ) | [signal] |
This signal is emitted whenever the user has accepted the configuration dialog.
- Note:
- Implementors of agents/resources are responsible to emit this signal if the agent/resource reimplements configure().
- Since:
- 4.4
void Akonadi::AgentBase::configurationDialogRejected | ( | ) | [signal] |
This signal is emitted whenever the user has rejected the configuration dialog.
- Note:
- Implementors of agents/resources are responsible to emit this signal if the agent/resource reimplements configure().
- Since:
- 4.4
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.
- Note:
- If the method is reimplemented it has to emit the configurationDialogAccepted() or configurationDialogRejected() signals depending on the users choice.
Definition at line 565 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 560 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 650 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 306 of file agentbase.h.
bool AgentBase::isOnline | ( | ) | const [protected] |
Returns whether the agent is currently online.
Definition at line 529 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 515 of file agentbase.cpp.
QString AgentBase::progressMessage | ( | ) | const [virtual] |
This method returns an i18n'ed description of the current progress.
Definition at line 522 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 645 of file agentbase.cpp.
void Akonadi::AgentBase::reloadConfiguration | ( | ) | [signal] |
Emitted if another application has changed the agent's 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 655 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 536 of file agentbase.cpp.
void AgentBase::setOnline | ( | bool | state | ) | [protected] |
Sets whether the agent shall be online or not.
Definition at line 551 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 501 of file agentbase.cpp.
QString AgentBase::statusMessage | ( | ) | const [virtual] |
This method returns an i18n'ed description of the current status code.
Definition at line 508 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 578 of file agentbase.cpp.
The documentation for this class was generated from the following files: