Job Class Reference
from PyKDE4.akonadi import *
Inherits: KCompositeJob → KJob → QObject
Subclasses: Akonadi.CollectionCopyJob, Akonadi.CollectionCreateJob, Akonadi.CollectionDeleteJob, Akonadi.CollectionFetchJob, Akonadi.CollectionModifyJob, Akonadi.CollectionStatisticsJob, KIO.CopyJob, KIO.DeleteJob, KIO.FileCopyJob, Akonadi.ItemCopyJob, Akonadi.ItemCreateJob, Akonadi.ItemDeleteJob, Akonadi.ItemFetchJob, Akonadi.ItemModifyJob, Akonadi.ItemMoveJob, Akonadi.ItemSync, Akonadi.SearchCreateJob, Akonadi.TransactionBeginJob, Akonadi.TransactionCommitJob, Akonadi.TransactionRollbackJob, Akonadi.TransactionSequence
Namespace: Akonadi
Detailed Description
- Abstract class:
- This class can be used as a base class for new classes, but can not be instantiated directly.
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!
Enumerations | |
Error | { ConnectionFailed, ProtocolVersionMismatch, UserCanceled, Unknown, UserError } |
Signals | |
aboutToStart (Akonadi.Job job) | |
writeFinished (Akonadi.Job job) | |
Methods | |
__init__ (self, QObject parent=0) | |
__init__ (self, JobPrivate dd, QObject parent) | |
aboutToStart (self, Akonadi.Job job) | |
bool | addSubjob (self, KJob job) |
doHandleResponse (self, QByteArray tag, QByteArray data) | |
bool | doKill (self) |
doStart (self) | |
emitWriteFinished (self) | |
QString | errorString (self) |
bool | removeSubjob (self, KJob job) |
slotResult (self, KJob job) | |
start (self) | |
writeFinished (self, Akonadi.Job job) |
Method Documentation
__init__ | ( | self, | ||
QObject | parent=0 | |||
) |
Creates a new job.
If the parent object is a Job object, the new job will be a subjob of parent. If the parent object is a Session object, it will be used for server communication instead of the default session.
- Parameters:
-
parent The parent object, job or session.
__init__ | ( | self, | ||
JobPrivate | dd, | |||
QObject | parent | |||
) |
aboutToStart | ( | self, | ||
Akonadi.Job | job | |||
) |
This signal is emitted directly before the job will be started.
- Parameters:
-
job The started job.
- Signal syntax:
QObject.connect(source, SIGNAL("aboutToStart(Job*)"), target_slot)
bool addSubjob | ( | self, | ||
KJob | job | |||
) |
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.
doHandleResponse | ( | self, | ||
QByteArray | tag, | |||
QByteArray | data | |||
) |
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.
bool doKill | ( | self ) |
Kills the execution of the job.
doStart | ( | self ) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
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.
emitWriteFinished | ( | self ) |
Call this method to indicate that this job will not call writeData() again.
- See also:
- writeFinished()
QString errorString | ( | self ) |
Returns the error string, if there has been an error, an empty string otherwise.
bool removeSubjob | ( | self, | ||
KJob | job | |||
) |
Removes the given subjob of this job.
- Parameters:
-
job The subjob to remove.
slotResult | ( | self, | ||
KJob | job | |||
) |
start | ( | self ) |
Jobs are started automatically once entering the event loop again, no need to explicitly call this.
writeFinished | ( | self, | ||
Akonadi.Job | job | |||
) |
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()
- Signal syntax:
QObject.connect(source, SIGNAL("writeFinished(Job*)"), target_slot)
Enumeration Documentation
Error |
Describes the error codes that can be emitted by this class. Subclasses can provide additional codes, starting from UserError onwards
- Enumerator:
-
ConnectionFailed = UserDefinedError ProtocolVersionMismatch UserCanceled Unknown UserError = UserDefinedError+42