ToiOperationManager Interface Reference

Description

This is a generic interface that is used by other platform services that expose asynchronous operations and their results to applications.

Example of services that implement this interface can be found in ToiAssetManagerService::getAssetOperationManager() and ToiStorageService::getStorageOperationManager().

See also:
IToiOperationObserver

import "ToiOperationManager.idl";

List of all members.

Public Member Functions

TToiOperationId createOperation (in string userData) raises (TToiNotEnoughResourcesException)
void cancelOperation (in TToiOperationId operationId) raises (TToiInvalidArgumentException)
void releaseOperation (in TToiOperationId operationId) raises (TToiInvalidArgumentException)
ToiOperationManagerOperationInfo getOperationInfo (in TToiOperationId operationId) raises (TToiInvalidArgumentException)
void addEventListener (in long type, in ToiEventListener listener) raises (TToiInvalidArgumentException)
void removeEventListener (in long type, in ToiEventListener listener) raises (TToiInvalidArgumentException)

Public Attributes

Events
const long ON_OPERATION_RESULT = 2000
Operation error codes

Generic error codes defined for operations.

const TToiOperationError OP_ERROR_FAILED = -1
const TToiOperationError OP_ERROR_CANCELLED = -2
TToiOperationState
const TToiOperationState OPERATION_PENDING = 0
const TToiOperationState OPERATION_COMPLETED = 1
const TToiOperationState OPERATION_FAILED = 2
Operation results
const TToiOperationResult OP_RESULT_NONE = 0

Public Types

typedef long TToiOperationId
typedef long TToiOperationResult
typedef long TToiOperationError
typedef long TToiPropertyId
typedef string TToiPropertyValue
typedef sequence
< ToiOperationManagerProperty
TToiPropertySequence
typedef long TToiOperationState

Member Typedef Documentation

Type for operation errors.

Type for operation identifier.

Type for operation results.

State identifier used to identify the operation state.

Identifier for a metadata property. This with ToiOperationManager::TToiPropertyValue forms a key-value pair that is used by the ToiOperationManagerOperationInfo to provide additional information about operation informaiton .

Sequence of property tags.

Value for a metadata property. This with ToiOperationManager::TToiPropertyId forms a key-value pair that is used by the ToiOperationManagerOperationInfo toprovide additional information about operation informaiton .


Member Function Documentation

void ToiEventTarget::addEventListener ( in long  type,
in ToiEventListener  listener 
) raises (TToiInvalidArgumentException) [inherited]

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

Parameters:
typeThe event type of the event to subscribe to.
listenerThe JavaScript function that will receive events.
Exceptions:
TInvalidArgumentExceptionRaised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the application calls addEventListener with the same combination of type and listener twice.
void ToiOperationManager::cancelOperation ( in TToiOperationId  operationId) raises (TToiInvalidArgumentException)

Requests an operation to stop execution.

Parameters:
operationIdOperation identifier.
Exceptions:
TToiInvalidArgumentExceptionRaised if any of the parameters to the call are invalid.
TToiOperationId ToiOperationManager::createOperation ( in string  userData) raises (TToiNotEnoughResourcesException)

Creates a new operation. The operation identifier is used when starting a asynchronous request. When the operation is completed the operation shall either be released by calling ToiOperationManager::releaseOperation() or reused for another request.

Parameters:
userDataThe user defined data to be passed as parameter for identification in all operation callbacks.
Return values:
operationIdOperation identifier.
Exceptions:
TToiNotEnoughResourcesExceptionRaised if too many operations are active and the system cannot create another operation.
ToiOperationManagerOperationInfo ToiOperationManager::getOperationInfo ( in TToiOperationId  operationId) raises (TToiInvalidArgumentException)

Returns information about given operation. This method is normally not useful for an application that is listening to operation events since the same information is provided in the callback.

In some circumstances it may still be relevant to use this method and that is when the application is using a polled approach to handle operation results instead of callbacks. But also if the application do not handle an incoming callback directly and want to get the latest updated operation information.

Parameters:
operationIdOperation identifier.
Return values:
operationInfoThe current operation information.
Exceptions:
TToiInvalidArgumentExceptionRaised if any of the parameters to the call are invalid.
void ToiOperationManager::releaseOperation ( in TToiOperationId  operationId) raises (TToiInvalidArgumentException)

Releases any system resources associated with the operation and if needed cancels the operation as well. This method shall be called when the application is done with the operation and will use it no more.

Parameters:
operationIdOperation identifier.
Exceptions:
TToiInvalidArgumentExceptionRaised if any of the parameters to the call are invalid.
void ToiEventTarget::removeEventListener ( in long  type,
in ToiEventListener  listener 
) raises (TToiInvalidArgumentException) [inherited]

This method removes an event listener for a specific event.

Parameters:
typeThe event type of the event to remove the listener from.
listenerThe JavaScript function that was previously added as an event listener.
Exceptions:
TInvalidArgumentExceptionRaised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the listener had not previously been added.

Member Data Documentation

This is an Event identifier for ToiOperationOperationResultEvent.

This constant can also be accessed from toi.consts.ToiOperationManager.ON_OPERATION_RESULT.

Operation was canceled by user.

This constant can also be accessed from toi.consts.ToiOperationManager.OP_ERROR_CANCELLED.

Operation failed for unknown reason.

This constant can also be accessed from toi.consts.ToiOperationManager.OP_ERROR_FAILED.

The operation has no result. Can be used for operations that perform some action and only indicate progress, success and failure.

This constant can also be accessed from toi.consts.ToiOperationManager.OP_RESULT_NONE.

Asynchronous operation has finished and completed the request.

This constant can also be accessed from toi.consts.ToiOperationManager.OPERATION_COMPLETED.

Asynchronous operation has failed.

This constant can also be accessed from toi.consts.ToiOperationManager.OPERATION_FAILED.

Asynchronous operation is currently in progress.

This constant can also be accessed from toi.consts.ToiOperationManager.OPERATION_PENDING.