nn::boss::RegisterTask Function

Syntax

nn::Result RegisterTask(
     Task * pTask,
     TaskPolicy * pPolicy,
     TaskAction * pAction,
     TaskOption * pOption = NULL,
     u8 taskStep = DEFAULT_STEP_ID
);

Arguments

Name Description
in pTask Specifies a task name. You can use a name of up to seven characters.
in pPolicy Specifies a task policy.
in pAction Specifies a task action.( For example, NsaDownloadAction.)
in pOption Specifies task options. (Optional)
in taskStep Specifies a task step ID. (May be omitted if there is only one task step to be executed)

Return Values

Returns the function's execution result. Returns one of the Result values listed below.
Value Description
ResultSuccess Registration successful.
ResultInvalidTaskId The task ID pointer is NULL or a zero-length string.
ResultInvalidPolicy The policy information pointer is NULL.
ResultInvalidAction The task action pointer is NULL.
ResultInvalidTaskPriolity The task priority specification is out-of-range. Confirm that it is in the range of TaskPriority.
ResultTaskPermissionOutOfRange The task permission information is out of range. Confirm that it is in the range of TaskPermission.
ResultSchedulingPolicyOutOfRange The scheduling policy is out of range. Confirm that it is in the range of SchedulingPolicy.
ResultInvalidTaskTargetDuration The task duration is invalid. (This is for future extensibility.)
ResultActionCodeOutOfRange The task action code is out of range. Confirm that it is in the range of Action.
ResultInvalidUrl The URL string pointer is NULL or a zero-length string.
ResultApInfoTypeOutOfRange The AP information type is out of range. Confirm that it is in the range of ApInfoType.
ResultInvalidFilePath The file path string pointer is NULL or a zero-length string.
ResultInvalidOption The task option pointer is NULL, or the option code is out of range. Confirm that it is in the range of ExecOption.
ResultStorageNotFound Storage has not been registered for the corresponding application ID.
ResultTaskIdAlreadyExist Another task of the same name is already registered.
ResultDatabaseFull Storage and tasks cannot be registered because the maximum number of registered application IDs and tasks has been reached.
ResultIpcNotSessionInitialized The session has not been initialized. This result is returned if this function is called before the Initialize function. Always call the Initialize function first thing when you use the BOSS library.
A value other than the above. Unexpected error (see boss_Result.h for error details).

Description

Registers a task to the library.

To register tasks, you must prepare the TaskPolicy class, a subclass of the TaskAction class (such as NsaDownloadAction), and the optional TaskOption class. See the topic for each class for more information on which attributes must be set. After you have finished registering a task, you can reuse each of these instances as necessary by calling the Initialize function. You can schedule and run a registered task by calling the Task class's Start function.

Common task registration errors

(1) An NSA download task is registered when no storage has been registered (ResultStorageNotFound).
Use the RegisterStorage function to register storage for the NSA download task.

(2) A task with the same name is already registered (ResultTaskIdAlreadyExist).
Either use the UnregisterTask function to delete one of the tasks in question or reuse the task that has already been registered.

(3) The task cannot be registered because the task database is full and no existing tasks can be deleted (ResultDatabaseFull).
When the task database is full, tasks with a remaining execution count of zero are automatically deleted so that new tasks can be registered successfully. However, if no tasks can be deleted because none of them have a remaining execution count of zero, this error occurs. If it is possible to delete any of the tasks registered by the application itself, you can resolve this issue by deleting one of those tasks by using the UnregisterTask function and then attempting to register the new task again.(The application can run the GetTaskIdList function to get a list of the task IDs for tasks it has registered.)
Alternatively, after some time elapses, it is possible that the execution count of some other task (maybe even some other application's task) will reach zero, allowing your task to be registered successfully.
You can therefore also resolve this problem by waiting awhile (until the next time the application starts, for example) and retrying task registration later.

Revision History

2010/09/16
Initial version.

CONFIDENTIAL