akonadi
Akonadi::Job Class Reference
Base class for all actions in the Akonadi storage. More...
#include <job.h>

Public Types | |
enum | Error { ConnectionFailed = UserDefinedError, ProtocolVersionMismatch, UserCanceled, Unknown, UserError = UserDefinedError + 42 } |
typedef QList< Job * > | List |
Signals | |
void | aboutToStart (Akonadi::Job *job) |
void | writeFinished (Akonadi::Job *job) |
Public Member Functions | |
virtual QString | errorString () const |
Job (QObject *parent=0) | |
void | start () |
virtual | ~Job () |
Protected Slots | |
virtual void | slotResult (KJob *job) |
Protected Member Functions | |
virtual bool | addSubjob (KJob *job) |
virtual void | doHandleResponse (const QByteArray &tag, const QByteArray &data) |
virtual bool | doKill () |
virtual void | doStart ()=0 |
void | emitWriteFinished () |
virtual bool | removeSubjob (KJob *job) |
Detailed Description
Base class for all actions in the Akonadi storage.This class encapsulates a request to the pim storage service, the code looks like
Akonadi::Job *job = new Akonadi::SomeJob( some parameter ); connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotResult( KJob* ) ) );
The job is queued for execution as soon as the event loop is entered again.
And the slotResult is usually at least:
if ( job->error() ) { // handle error... }
With the synchronous interface the code looks like
Akonadi::SomeJob *job = new Akonadi::SomeJob( some parameter ); if ( !job->exec() ) { qDebug() << "Error:" << job->errorString(); } else { // do something }
- Warning:
- Using the synchronous method is error prone, use this only if the asynchronous access is not possible and none of the following known issues apply:
- exec() must not be called directly from a result slot of another job in the same Session. This will trigger a dead-lock since the program won't return from the result slot and thus will never complete the finishing of the current job, keeping it in the internal queue and blocking the execution of any following job.
- exec() must not be called from within another event-loop that might finish before the newly started inner sub-eventloop. This will crash!
Subclasses must reimplement doStart().
- Note:
- KJob-derived objects delete itself, it is thus not possible to create job objects on the stack!
Definition at line 94 of file job.h.
Member Typedef Documentation
typedef QList<Job*> Akonadi::Job::List |
Member Enumeration Documentation
enum Akonadi::Job::Error |
Describes the error codes that can be emitted by this class.
Subclasses can provide additional codes, starting from UserError onwards
Constructor & Destructor Documentation
Job::Job | ( | QObject * | parent = 0 |
) | [explicit] |
Member Function Documentation
void Akonadi::Job::aboutToStart | ( | Akonadi::Job * | job | ) | [signal] |
This signal is emitted directly before the job will be started.
- Parameters:
-
job The started job.
bool Job::addSubjob | ( | KJob * | job | ) | [protected, virtual] |
Adds the given job as a subjob to this job.
This method is automatically called if you construct a job using another job as parent object. The base implementation does the necessary setup to share the network connection with the backend.
- Parameters:
-
job The new subjob.
Reimplemented in Akonadi::TransactionSequence.
void Job::doHandleResponse | ( | const QByteArray & | tag, | |
const QByteArray & | data | |||
) | [protected, virtual] |
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
It will be called on received data from the backend. The default implementation does nothing.
- Parameters:
-
tag The tag of the corresponding command, empty if this is an untagged response. data The received data.
Reimplemented in Akonadi::CollectionCreateJob, Akonadi::CollectionFetchJob, Akonadi::CollectionStatisticsJob, Akonadi::ItemCreateJob, Akonadi::ItemFetchJob, and Akonadi::ItemModifyJob.
bool Job::doKill | ( | ) | [protected, virtual] |
virtual void Akonadi::Job::doStart | ( | ) | [protected, pure virtual] |
This method must be reimplemented in the concrete jobs.
It will be called after the job has been started and a connection to the Akonadi backend has been established.
Implemented in Akonadi::CollectionCopyJob, Akonadi::CollectionCreateJob, Akonadi::CollectionDeleteJob, Akonadi::CollectionFetchJob, Akonadi::CollectionModifyJob, Akonadi::CollectionMoveJob, Akonadi::CollectionStatisticsJob, Akonadi::ItemCopyJob, Akonadi::ItemCreateJob, Akonadi::ItemDeleteJob, Akonadi::ItemFetchJob, Akonadi::ItemModifyJob, Akonadi::ItemMoveJob, Akonadi::ItemSync, Akonadi::LinkJob, Akonadi::SearchCreateJob, Akonadi::TransactionBeginJob, Akonadi::TransactionRollbackJob, Akonadi::TransactionCommitJob, Akonadi::TransactionSequence, and Akonadi::UnlinkJob.
void Job::emitWriteFinished | ( | ) | [protected] |
Call this method to indicate that this job will not call writeData() again.
- See also:
- writeFinished()
QString Job::errorString | ( | ) | const [virtual] |
bool Job::removeSubjob | ( | KJob * | job | ) | [protected, virtual] |
void Job::start | ( | ) |
void Akonadi::Job::writeFinished | ( | Akonadi::Job * | job | ) | [signal] |
This signal is emitted if the job has finished all write operations, ie.
if this signal is emitted, the job guarantees to not call writeData() again. Do not emit this signal directly, call emitWriteFinished() instead.
- Parameters:
-
job This job.
- See also:
- emitWriteFinished()
The documentation for this class was generated from the following files: