org.kde.koala

Class Job

public class Job extends QObject

The base class for all jobs. For all jobs created in an application, the code looks like
   KIO.Job  job = KIO.someoperation( some parameters );
   connect( job, SIGNAL("result( KIO.Job  )"),
            this, SLOT("slotResult( KIO.Job  )") );
 
(other connects, specific to the job) And slotResult is usually at least:
  if ( job.error() )
      job.showErrorDialog( this or null  );
 
See JobSignals for signals emitted by Job

See Also: Scheduler Slave

UNKNOWN: The base class for all jobs.

Constructor Summary
protected Job(Class dummy)
Job(boolean showProgressInfo)
Method Summary
voidaddMetaData(String key, String value)
Add key/value pair to the meta data that is sent to the slave.
protected voidaddSubjob(Job job, boolean inheritMetaData)
Add a job that has to be finished before a result is emitted.
protected voidaddSubjob(Job job)
StringclassName()
ArrayListdetailedErrorStrings(KURL reqUrl, int method)
Converts an error code and a non-i18n error message into i18n strings suitable for presentation in a detailed error message box.
ArrayListdetailedErrorStrings(KURL reqUrl)
ArrayListdetailedErrorStrings()
protected voidemitPercent(long processedSize, long totalSize)
Utility function for inherited jobs.
protected voidemitResult()
Utility function to emit the result signal, and suicide this job.
protected voidemitSpeed(long speed)
Utility function for inherited jobs.
interror()
Returns the error code, if there has been an error.
StringerrorString()
Converts an error code and a non-i18n error message into an error message in the current language.
StringerrorText()
Returns the error text if there has been an error.
protected intextraFlags()
longgetProcessedSize()
Returns the processed size for this job.
booleanisAutoErrorHandlingEnabled()
Returns whether automatic error handling is enabled or disabled.
booleanisAutoWarningHandlingEnabled()
Returns whether automatic warning handling is enabled or disabled.
booleanisInteractive()
Returns whether message display is enabled or disabled.
voidkill(boolean quietly)
Abort this job.
voidkill()
QMetaObjectmetaObject()
JobparentJob()
Returns the parent job, if there is one.
intprogressId()
Returns the progress id for this job.
StringqueryMetaData(String key)
Query meta data received from the slave.
protected voidremoveSubjob(Job job)
Mark a sub job as being done.
protected voidremoveSubjob(Job job, boolean mergeMetaData, boolean emitResultIfLast)
Overloaded version of removeSubjob
voidsetAutoErrorHandlingEnabled(boolean enable, QWidget parentWidget)
Enable or disable the automatic error handling.
voidsetAutoErrorHandlingEnabled(boolean enable)
voidsetAutoWarningHandlingEnabled(boolean enable)
Enable or disable the automatic warning handling.
voidsetInteractive(boolean enable)
Enable or disable the message display from the job.
voidsetParentJob(Job parentJob)
Set the parent Job.
protected voidsetProcessedSize(long size)
Set the processed size, does not emit processedSize
voidsetWindow(QWidget window)
Associate this job with a window given by window.
voidshowErrorDialog(QWidget parent)
Display a dialog box to inform the user of the error given by this job.
voidshowErrorDialog()
protected voidslotInfoMessage(Job job, String msg)
Forward signal from subjob.
protected voidslotResult(Job job)
Called whenever a subjob finishes.
protected voidslotSpeed(Job job, long speed)
Forward signal from subjob.
protected voidslotSpeedTimeout()
Remove speed information.
QWidgetwindow()
Returns the window this job is associated with.

Constructor Detail

Job

protected Job(Class dummy)

Job

public Job(boolean showProgressInfo)

Method Detail

addMetaData

public void addMetaData(String key, String value)
Add key/value pair to the meta data that is sent to the slave.

Parameters: key the key of the meta data value the value of the meta data

See Also: Job Job

UNKNOWN: Add key/value pair to the meta data that is sent to the slave.

addSubjob

protected void addSubjob(Job job, boolean inheritMetaData)
Add a job that has to be finished before a result is emitted. This has obviously to be called before the finish signal is emitted by the slave.

Parameters: job the subjob to add inheritMetaData if true, the subjob will inherit the meta data from this job.

UNKNOWN: Add a job that has to be finished before a result is emitted.

addSubjob

protected void addSubjob(Job job)

className

public String className()

detailedErrorStrings

public ArrayList detailedErrorStrings(KURL reqUrl, int method)
Converts an error code and a non-i18n error message into i18n strings suitable for presentation in a detailed error message box.

Parameters: reqUrl the request URL that generated this error message method the method that generated this error message (unimplemented)

Returns: the following strings: caption, error + description, causes+solutions

UNKNOWN: Converts an error code and a non-i18n error message into i18n strings suitable for presentation in a detailed error message box.

detailedErrorStrings

public ArrayList detailedErrorStrings(KURL reqUrl)

detailedErrorStrings

public ArrayList detailedErrorStrings()

emitPercent

protected void emitPercent(long processedSize, long totalSize)
Utility function for inherited jobs. Emits the percent signal if bigger than m_percent, after calculating it from the parameters.

Parameters: processedSize the processed size in bytes totalSize the total size in bytes

UNKNOWN: Utility function for inherited jobs.

emitResult

protected void emitResult()
Utility function to emit the result signal, and suicide this job. It first tells the observer to hide the progress dialog for this job.

UNKNOWN: Utility function to emit the result signal, and suicide this job.

emitSpeed

protected void emitSpeed(long speed)
Utility function for inherited jobs. Emits the speed signal and starts the timer for removing that info

Parameters: speed the speed in bytes/s

UNKNOWN: Utility function for inherited jobs.

error

public int error()
Returns the error code, if there has been an error. Only call this method from the slot connected to result().

Returns: the error code for this job, 0 if no error. Error codes are defined in KIO.Error.

UNKNOWN: Returns the error code, if there has been an error.

errorString

public String errorString()
Converts an error code and a non-i18n error message into an error message in the current language. The low level (non-i18n) error message (usually a url) is put into the translated error message using %1. Example for errid == ERR_CANNOT_OPEN_FOR_READING:
		   i18n( "Could not read\n%1" ).arg( errortext );
		 
Use this to display the error yourself, but for a dialog box use Job.showErrorDialog. Do not call it if error() is not 0.

Returns: the error message and if there is no error, a message telling the user that the app is broken, so check with error() whether there is an error

UNKNOWN: Converts an error code and a non-i18n error message into an error message in the current language.

errorText

public String errorText()
Returns the error text if there has been an error. Only call if error is not 0. This is really internal, better use errorString() or errorDialog().

Returns: a string to help understand the error, usually the url related to the error. Only valid if error() is not 0.

UNKNOWN: Returns the error text if there has been an error.

extraFlags

protected int extraFlags()

getProcessedSize

public long getProcessedSize()
Returns the processed size for this job.

See Also: Job

UNKNOWN: Returns the processed size for this job.

isAutoErrorHandlingEnabled

public boolean isAutoErrorHandlingEnabled()
Returns whether automatic error handling is enabled or disabled.

Returns: true if automatic error handling is enabled

See Also: Job

UNKNOWN: Returns whether automatic error handling is enabled or disabled.

isAutoWarningHandlingEnabled

public boolean isAutoWarningHandlingEnabled()
Returns whether automatic warning handling is enabled or disabled. See also setAutoWarningHandlingEnabled .

Returns: true if automatic warning handling is enabled

See Also: Job

UNKNOWN: Returns whether automatic warning handling is enabled or disabled.

isInteractive

public boolean isInteractive()
Returns whether message display is enabled or disabled.

Returns: true if message display is enabled

See Also: Job

UNKNOWN: Returns whether message display is enabled or disabled.

kill

public void kill(boolean quietly)
Abort this job. This kills all subjobs and deletes the job.

Parameters: quietly if false, Job will emit signal result and ask kio_uiserver to close the progress window. quietly is set to true for subjobs. Whether applications should call with true or false depends on whether they rely on result being emitted or not.

UNKNOWN: Abort this job.

kill

public void kill()

metaObject

public QMetaObject metaObject()

parentJob

public Job parentJob()
Returns the parent job, if there is one.

Returns: the parent job, or 0 if there is none

See Also: Job

UNKNOWN: Returns the parent job, if there is one.

progressId

public int progressId()
Returns the progress id for this job.

Returns: the progress id for this job, as returned by uiserver

UNKNOWN: Returns the progress id for this job.

queryMetaData

public String queryMetaData(String key)
Query meta data received from the slave. (Valid when first data is received and/or slave is finished)

Parameters: key the key of the meta data to retrieve

Returns: the value of the meta data, or null if the key does not exist

UNKNOWN: Query meta data received from the slave.

removeSubjob

protected void removeSubjob(Job job)
Mark a sub job as being done. If it's the last to wait on the job will emit a result - jobs with two steps might want to override slotResult in order to avoid calling this method.

Parameters: job the subjob to add

UNKNOWN: Mark a sub job as being done.

removeSubjob

protected void removeSubjob(Job job, boolean mergeMetaData, boolean emitResultIfLast)
Overloaded version of removeSubjob

Parameters: job the subjob to remove mergeMetaData if set, the metadata received by the subjob is merged into this job. emitResultIfLast if this was the last subjob, emit result, i.e. terminate this job.

UNKNOWN: Overloaded version of removeSubjob

setAutoErrorHandlingEnabled

public void setAutoErrorHandlingEnabled(boolean enable, QWidget parentWidget)
Enable or disable the automatic error handling. When automatic error handling is enabled and an error occurs, then showErrorDialog() is called with the specified parentWidget (if supplied) , right before the emission of the result signal. The default is false.

Parameters: enable enable or disable automatic error handling parentWidget the parent widget, passed to showErrorDialog. Can be 0 for top-level

See Also: Job Job

UNKNOWN: Enable or disable the automatic error handling.

setAutoErrorHandlingEnabled

public void setAutoErrorHandlingEnabled(boolean enable)

setAutoWarningHandlingEnabled

public void setAutoWarningHandlingEnabled(boolean enable)
Enable or disable the automatic warning handling. When automatic warning handling is enabled and an error occurs, then a message box is displayed with the warning message The default is true. See also isAutoWarningHandlingEnabled , showErrorDialog

Parameters: enable enable or disable automatic warning handling

See Also: Job

UNKNOWN: Enable or disable the automatic warning handling.

setInteractive

public void setInteractive(boolean enable)
Enable or disable the message display from the job. The default is true.

Parameters: enable enable or disable message display

UNKNOWN: Enable or disable the message display from the job.

setParentJob

public void setParentJob(Job parentJob)
Set the parent Job. One example use of this is when FileCopyJob calls open_RenameDlg, it must pass the correct progress ID of the parent CopyJob (to hide the progress dialog). You can set the parent job only once. By default a job does not have a parent job.

Parameters: parentJob the new parent job

UNKNOWN: Set the parent Job.

setProcessedSize

protected void setProcessedSize(long size)
Set the processed size, does not emit processedSize

UNKNOWN: Set the processed size, does not emit processedSize

setWindow

public void setWindow(QWidget window)
Associate this job with a window given by window.

Parameters: window the window to associate to

See Also: Job

UNKNOWN: Associate this job with a window given by window.

showErrorDialog

public void showErrorDialog(QWidget parent)
Display a dialog box to inform the user of the error given by this job. Only call if error is not 0, and only in the slot connected to result.

Parameters: parent the parent widget for the dialog box, can be 0 for top-level

UNKNOWN: Display a dialog box to inform the user of the error given by this job.

showErrorDialog

public void showErrorDialog()

slotInfoMessage

protected void slotInfoMessage(Job job, String msg)
Forward signal from subjob.

Parameters: job the subjob msg the info message

See Also: Job

UNKNOWN: Forward signal from subjob.

slotResult

protected void slotResult(Job job)
Called whenever a subjob finishes. Default implementation checks for errors and propagates to parent job, then calls removeSubjob. Override if you don't want subjobs errors to be propagated.

Parameters: job the subjob

See Also: Job

UNKNOWN: Called whenever a subjob finishes.

slotSpeed

protected void slotSpeed(Job job, long speed)
Forward signal from subjob.

Parameters: job the subjob speed the speed in bytes/s

See Also: Job

UNKNOWN: Forward signal from subjob.

slotSpeedTimeout

protected void slotSpeedTimeout()
Remove speed information.

UNKNOWN: Remove speed information.

window

public QWidget window()
Returns the window this job is associated with.

Returns: the associated window

See Also: Job

UNKNOWN: Returns the window this job is associated with.