Tizen(Headed) Native API  6.5
Policy Manager Interface

The policy client provides functions required to access the device policy APIs.

Required Header

#include <dpm/device-policy-manager.h>

Overview

The Policy Manager module provides Device Policy Manager handle which keeps track of state between the device admin client and the device policy manager. The device admin clients must create the handle by using dpm_manager_create() before attempting to use almost any of the device policy APIs, and the handle should be freed by using dpm_manager_destroy() when interaction with the device policy manager is no longer required.

Functions

device_policy_manager_h dpm_manager_create (void)
 Creates the device policy manager handle.
int dpm_manager_destroy (device_policy_manager_h handle)
 Releases the device policy manager handle.
int dpm_add_policy_changed_cb (device_policy_manager_h handle, const char *name, dpm_policy_changed_cb callback, void *user_data, int *id)
 Adds policy change callback to the device policy manager.
int dpm_remove_policy_changed_cb (device_policy_manager_h handle, int id)
 Removes policy change callback from the device policy manager.
int dpm_add_signal_cb (device_policy_manager_h handle, const char *signal, dpm_signal_cb callback, void *user_data, int *id)
 Adds signal callback.
int dpm_remove_signal_cb (device_policy_manager_h handle, int id)
 Removes signal callback.

Typedefs

typedef void(* dpm_policy_changed_cb )(const char *name, const char *state, void *user_data)
 Called when a policy is changed.
typedef void * device_policy_manager_h
 The device policy manager handle.
typedef void(* dpm_signal_cb )(const char *name, const char *object, void *user_data)
 Called when a zone raises a signal.

Typedef Documentation

typedef void* device_policy_manager_h

The device policy manager handle.

The device policy manager handle is an abstraction of the logical connection between the device policy manager and it's client. The device policy manager handle must be created by using dpm_manager_create() before attempting to use almost any of the device policy APIs, and it should be freed when interaction with the device policy manager is no longer required. To release the handle, use dpm_manager_destroy().

Since :
3.0
See also:
dpm_manager_create()
dpm_manager_destroy()
typedef void(* dpm_policy_changed_cb)(const char *name, const char *state, void *user_data)

Called when a policy is changed.

Since :
3.0
Parameters:
[in]nameThe name of the policy
[in]stateThe current state of the policy
[in]user_dataThe user data passed from dpm_add_policy_changed_cb
See also:
dpm_add_policy_changed_cb()
dpm_remove_policy_changed_cb()
typedef void(* dpm_signal_cb)(const char *name, const char *object, void *user_data)

Called when a zone raises a signal.

Since :
3.0
Parameters:
[in]nameThe zone name
[in]objectThe object name triggered the signal
[in]user_dataThe user data passed from dpm_add_signal_cb
See also:
dpm_add_signal_cb()
dpm_remove_signal_cb()

Enumeration Type Documentation

Enumeration of device policy API errors.

Since :
3.0
Enumerator:
DPM_ERROR_NONE 

The operation was successful

DPM_ERROR_INVALID_PARAMETER 

Invalid parameter

DPM_ERROR_CONNECTION_REFUSED 

Connection refused

DPM_ERROR_TIMED_OUT 

Time out

DPM_ERROR_PERMISSION_DENIED 

Access privilege is not sufficient

DPM_ERROR_NOT_PERMITTED 

Operation not permitted

DPM_ERROR_FILE_EXISTS 

File exists

DPM_ERROR_OUT_OF_MEMORY 

Out of memory

DPM_ERROR_NO_DATA 

No Data


Function Documentation

int dpm_add_policy_changed_cb ( device_policy_manager_h  handle,
const char *  name,
dpm_policy_changed_cb  callback,
void *  user_data,
int *  id 
)

Adds policy change callback to the device policy manager.

This API can be used to subscribe policy change callback. The callback specified to this API is asynchronously called when policy is changed on runtime.

Since :
3.0
Parameters:
[in]handleDevice policy manager handle
[in]namePolicy name to subscribe(see Policy List)
[in]callbackThe callback when policy is changed
[in]user_dataUser specified data passed to the callback
[out]idPolicy change callback identifier
Returns:
DPM_ERROR_NONE on success, otherwise a negative value
Return values:
DPM_ERROR_NONESuccessful
DPM_ERROR_INVALID_PARAMETERInvalid parameter
DPM_ERROR_TIMED_OUTTime out
Remarks:
See Policy List section for available policy name
Precondition:
The handle must be created by dpm_manager_create().
See also:
dpm_manager_create()
dpm_remove_policy_changed_cb()
int dpm_add_signal_cb ( device_policy_manager_h  handle,
const char *  signal,
dpm_signal_cb  callback,
void *  user_data,
int *  id 
)

Adds signal callback.

This API can be used to receive signals raised by the device policy manager. The callback specified to this function is automatically called when the device policy manager raises signal.

Since :
3.0
Parameters:
[in]handleDevice policy manager handle
[in]signalThe signal name to receive(see Signal List)
[in]callbackThe signal callback
[in]user_dataThe user data passed to the callback function
[out]idSignal identifier
Returns:
DPM_ERROR_NONE on success, otherwise a negative value
Return values:
DPM_ERROR_NONESuccessful
DPM_ERROR_INVALID_PARAMETERInvalid parameter
DPM_ERROR_TIMED_OUTTime out
Remarks:
See Signal List section for signals
Precondition:
The handle must be created by dpm_manager_create().
See also:
dpm_manager_create()
dpm_manager_destroy()
dpm_remove_signal_cb()

Creates the device policy manager handle.

This API creates device policy manager handle required to the device policy APIs. This API is also used to verify whether caller is authorized or not.

Since :
3.0
Returns:
Device policy manager handle on success, otherwise NULL
Remarks:
The specific error code can be obtained by using the get_last_result() method. Error codes are described in exception section. The returned handle should be released using dpm_manager_destroy().
Exceptions:
DPM_ERROR_NONENo error
DPM_ERROR_CONNECTION_REFUSEDConnection refused
DPM_ERROR_OUT_OF_MEMORYOut of memory
See also:
dpm_manager_destroy()
get_last_result()

Releases the device policy manager handle.

This API must be called if interaction with the device policy manager is no longer required.

Since :
3.0
Parameters:
[in]handleDevice policy manager handle
Returns:
DPM_ERROR_NONE on success, otherwise a negative value
Return values:
DPM_ERROR_NONESuccessful
DPM_ERROR_INVALID_PARAMETERInvalid parameter
Precondition:
The handle must be created by dpm_manager_create().
See also:
dpm_manager_create()

Removes policy change callback from the device policy manager.

This API should be called if policy change subscription is no longer required.

Since :
3.0
Parameters:
[in]handleDevice policy manager handle
[in]idPolicy change callback identifier
Returns:
DPM_ERROR_NONE on success, otherwise a negative value
Return values:
DPM_ERROR_NONESuccessful
DPM_ERROR_INVALID_PARAMETERInvalid parameter
DPM_ERROR_TIMED_OUTTime out
Precondition:
The handle must be created by dpm_manager_create().
The callback identifier must be created by dpm_add_policy_changed_cb().
See also:
dpm_manager_create()
dpm_add_policy_changed_cb()
int dpm_remove_signal_cb ( device_policy_manager_h  handle,
int  id 
)

Removes signal callback.

This API removes signal callback.

Since :
3.0
Parameters:
[in]handleDevice policy manager handle
[in]idSignal identifier
Returns:
DPM_ERROR_NONE on success, otherwise a negative value
Return values:
DPM_ERROR_NONESuccessful
DPM_ERROR_INVALID_PARAMETERInvalid parameter
DPM_ERROR_TIMED_OUTTime out
Precondition:
The context must be created by dpm_manager_create().
See also:
dpm_manager_create()
dpm_manager_destroy()
dpm_add_signal_cb()