Akonadi.AgentBase

KDE 4.5 PyKDE API Reference

- KDE's Python API

# AgentBase Class Reference

`from PyKDE4.akonadi import *`

Inherits: QObject
Subclasses: Akonadi.PreprocessorBase, Akonadi.ResourceBase
Namespace: Akonadi

## 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

Author:
  Till Adam <adam@kde.org>, Volker Krause <vkrause@kde.org>

## Enumerations
Status | { Idle, Running, Broken }
## Signals
| abortRequested ()
| agentNameChanged (QString name)
| configurationDialogAccepted ()
| configurationDialogRejected ()
| error (QString message)
| onlineChanged (bool online)
| percent (int progress)
| reloadConfiguration ()
| status (int status, QString message=QString())
| warning (QString message)
## Methods
| __init__ (self, QString id)
| aboutToQuit (self)
QString | agentName (self)
| changeProcessed (self)
Akonadi.ChangeRecorder | changeRecorder (self)
| cleanup (self)
| configure (self, int windowId)
| doSetOnline (self, bool online)
QString | identifier (self)
bool | isOnline (self)
int | progress (self)
QString | progressMessage (self)
| registerObserver (self, Akonadi.AgentBase.Observer observer)
| setAgentName (self, QString name)
| setNeedsNetwork (self, bool needsNetwork)
| setOnline (self, bool state)
int | status (self)
QString | statusMessage (self)
int | winIdForDialogs (self)

## Signal Documentation

abortRequested | ( |  | ) |

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

Signal syntax:
  `QObject.connect(source, SIGNAL("abortRequested()"), target_slot)`

agentNameChanged | ( | QString | name
| ) |  |  |

This signal is emitted whenever the name of the agent has changed.

Parameters:

  | name | The new name of the agent.

Since:
  4.3

Signal syntax:
  `QObject.connect(source, SIGNAL("agentNameChanged(const QString&)"), target_slot)`

configurationDialogAccepted | ( |  | ) |

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

Signal syntax:
  `QObject.connect(source, SIGNAL("configurationDialogAccepted()"), target_slot)`

configurationDialogRejected | ( |  | ) |

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

Signal syntax:
  `QObject.connect(source, SIGNAL("configurationDialogRejected()"), target_slot)`

error | ( | QString | message
| ) |  |  |

This signal shall be used to report errors.

Parameters:

  | message | The i18n'ed error message.

Signal syntax:
  `QObject.connect(source, SIGNAL("error(const QString&)"), target_slot)`

onlineChanged | ( | bool | online
| ) |  |  |

Emitted when the online state changed.

Parameters:

  | online | The online state.

Since:
  4.2

Signal syntax:
  `QObject.connect(source, SIGNAL("onlineChanged(bool)"), target_slot)`

percent | ( | int | progress
| ) |  |  |

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.

Signal syntax:
  `QObject.connect(source, SIGNAL("percent(int)"), target_slot)`

reloadConfiguration | ( |  | ) |

Emitted if another application has changed the agent's configuration remotely and called AgentInstance.reconfigure().

Since:
  4.2

Signal syntax:
  `QObject.connect(source, SIGNAL("reloadConfiguration()"), target_slot)`

status | ( | int | status,
|  | QString | message=QString()
| ) |  |  |

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.

Signal syntax:
  `QObject.connect(source, SIGNAL("status(int, const QString&)"), target_slot)`

warning | ( | QString | message
| ) |  |  |

This signal shall be used to report warnings.

Parameters:

  | message | The i18n'ed warning message.

Signal syntax:
  `QObject.connect(source, SIGNAL("warning(const QString&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QString | id
| ) |  |  |

Creates an agent base.

Parameters:

  | id | The instance id of the agent.

aboutToQuit | ( |  | self ) |

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).

QString agentName | ( |  | self ) |

Returns the name of the agent.

Since:
  4.3

changeProcessed | ( |  | self ) |

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.

Akonadi.ChangeRecorder changeRecorder | ( |  | self ) |

Returns the Akonadi.ChangeRecorder object used for monitoring. Use this to configure which parts you want to monitor.

cleanup | ( |  | self ) |

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.

configure | ( | self, |
|  | int | windowId
| ) |  |  |

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.

doSetOnline | ( | self, |
|  | bool | online
| ) |  |  |

This method is called whenever the online status has changed. Reimplement this method to react on online status changes.

QString identifier | ( |  | self ) |

Returns the instance identifier of this agent.

bool isOnline | ( |  | self ) |

Returns whether the agent is currently online.

int progress | ( |  | self ) |

This method returns the current progress of the agent in percentage.

QString progressMessage | ( |  | self ) |

This method returns an i18n'ed description of the current progress.

registerObserver | ( | self, |
|  | Akonadi.AgentBase.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

setAgentName | ( | self, |
|  | QString | name
| ) |  |  |

This method is used to set the name of the agent.

Since:
  4.3

setNeedsNetwork | ( | self, |
|  | bool | needsNetwork
| ) |  |  |

Sets whether the agent needs network or not.

Since:
  4.2

To do: use this in combination with Solid.Networking.Notifier to change the onLine status of the agent.

setOnline | ( | self, |
|  | bool | state
| ) |  |  |

Sets whether the agent shall be online or not.

int status | ( |  | self ) |

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.

QString statusMessage | ( |  | self ) |

This method returns an i18n'ed description of the current status code.

int winIdForDialogs | ( |  | self ) |

This method returns the windows id, which should be used for dialogs.

## Enumeration Documentation

Status

This enum describes the different states the agent can be in.

Enumerator:

  Idle = 0 |
  Running |
  Broken |