Tizen Native API
5.0
|
To get the information of installed widgets.
#include <widget_service.h> #include <widget_errno.h>
This API is related with the following feature:
Tizen supports various kinds of APIs set for retrieving information of widgets. Every widgets are installed via package manager utilities. The information of installed widgets are stored in the system DB. In some cases, application developer needs to send update request to some widgets. To make it possible, this module provides related API set. But the API will only works if the widget and application are packaged in one.
To get the information for installed widgets.
To trigger the update event or send the updated content string to the widget.
Widget has predefined size types. 1x1 is a square so its pixel size of width and height must has to be same. 2x2, 4x4 also square. 2x1, 4x1, 4x2, 4x3 is a rectangle. so its pixel size of width & height should not be same. pixel size of width should be long than height. Pixel size can be differ between different devices. It depends on its screen resolution. So widget developer should care various kinds of devices (has different screen resolution).
Size Type | Size in pixels | Supported profile |
WIDGET_SIZE_TYPE_1x1 | - (SQUARE, depends on screen resolution) | No profile - This size type is not used. just defined for specifying a default cell size |
WIDGET_SIZE_TYPE_2x1 | - (RECTANGLE, depends on screen resolution) | Mobile |
WIDGET_SIZE_TYPE_2x2 | - (SQUARE, depends on screen resolution) | Mobile, Wearable (Default size) |
WIDGET_SIZE_TYPE_4x1 | - (RECTANGLE, depends on screen resolution) | Mobile |
WIDGET_SIZE_TYPE_4x2 | - (RECTANGLE, depends on screen resolution) | Mobile |
WIDGET_SIZE_TYPE_4x3 | - (RECTANGLE, depends on screen resolution) | Mobile |
WIDGET_SIZE_TYPE_4x4 | - (SQUARE, depends on screen resolution) | Mobile |
Widget also works for Easy Mode. For the Easy Mode, there are different size types. Called WIDGET_SIZE_TYPE_EASY_NxM
Size Type | Size in pixels | Supported profile |
WIDGET_SIZE_TYPE_EASY_1x1 | - (SQUARE, depends on screen resolution) | Mobile |
WIDGET_SIZE_TYPE_EASY_3x1 | - (RECTANGLE, depends on screen resolution) | Mobile |
WIDGET_SIZE_TYPE_EASY_3x3 | - (SQARE - depends on screen resolution) | Mobile |
However the Easy Mode is not a mandatory requirements for viewer application development. So you will not be able to create your widgets using Easy Mode size types. But if you are developing the homescreen(or application which is related with widgets displaying), You should care these types too.
Functions | |
int | widget_service_get_size (widget_size_type_e type, int *width, int *height) |
Gets the pixel size of given size type. | |
int | widget_service_get_size_type (int width, int height, widget_size_type_e *size_type) |
Gets the size type for given pixel size. | |
int | widget_service_get_need_of_mouse_event (const char *widget_id, widget_size_type_e size_type, bool *need_of_mouse_event) |
Gets the need of mouse event for the given widget. | |
int | widget_service_get_need_of_touch_effect (const char *widget_id, widget_size_type_e size_type, bool *need_of_touch_event) |
Gets the need of touch effect for the given widget. | |
int | widget_service_get_need_of_frame (const char *widget_id, widget_size_type_e size_type, bool *need_of_frame) |
Gets the need of decoration frame for the given widget. | |
int | widget_service_trigger_update (const char *widget_id, const char *instance_id, bundle *b, int force) |
Triggers the update event for given widget instance. | |
int | widget_service_change_period (const char *widget_id, const char *instance_id, double period) |
Changes the update period of the given widget instance. | |
int | widget_service_get_widget_list (widget_list_cb cb, void *data) |
Gets a list of all widgets. | |
char * | widget_service_get_main_app_id (const char *widget_id) |
Gets the MAIN application ID of given widget package ID. | |
int | widget_service_get_widget_list_by_pkgid (const char *pkgid, widget_list_by_pkgid_cb cb, void *data) |
Gets a list of widgets included in the given package ID. | |
char * | widget_service_get_widget_id (const char *id) |
Gets the ID of a widget by the given ID of package or UI app. If there are two or more widgets in the package, this function returns the ID of the primary widget. | |
char * | widget_service_get_app_id_of_setup_app (const char *widget_id) |
Gets the appId of setup app which is specified by the given widget ID's manifest. | |
char * | widget_service_get_package_id (const char *widget_id) |
Gets the package ID of the given widget. | |
char * | widget_service_get_name (const char *widget_id, const char *lang) |
Gets the name of the given widget. | |
char * | widget_service_get_preview_image_path (const char *widget_id, widget_size_type_e size_type) |
Gets the preview image path of given size type. | |
char * | widget_service_get_icon (const char *pkgid, const char *lang) |
Gets icon path of given widget package. | |
int | widget_service_get_nodisplay (const char *widget_id) |
Gets the "nodisplay" value. | |
int | widget_service_get_supported_sizes (const char *widget_id, int *cnt, int **w, int **h) |
Gets the supported size list. | |
int | widget_service_get_supported_size_types (const char *widgetid, int *cnt, int **types) |
Gets the supported size list of given widget ID. | |
int | widget_service_get_widget_instance_list (const char *widget_id, widget_instance_list_cb cb, void *data) |
Gets widget instances of given widget_id. | |
int | widget_service_set_lifecycle_event_cb (const char *widget_id, widget_lifecycle_event_cb cb, void *data) |
Registers event handler callback function for life cycle events of widgets. | |
int | widget_service_unset_lifecycle_event_cb (const char *widget_id, void **user_data) |
Unregisters event handler callback function for life cycle events of widgets. | |
int | widget_service_get_content_of_widget_instance (const char *widget_id, const char *widget_instance_id, bundle **b) |
Gets content of the widget instance. | |
Typedefs | |
typedef enum widget_error | widget_error_e |
Enumeration for the result status of widget operation. | |
typedef enum widget_size_type | widget_size_type_e |
Enumeration for list of supporting widget size types. | |
typedef enum widget_event_type | widget_event_type_e |
Enumeration for widget event type. | |
typedef int(* | widget_list_cb )(const char *pkgid, const char *widget_id, int is_prime, void *data) |
Callback function for getting result of widget_service_get_widget_list. | |
typedef int(* | widget_list_by_pkgid_cb )(const char *widget_id, int is_prime, void *data) |
Callback function for getting result of widget_service_get_widget_list_by_pkgid. | |
typedef int(* | widget_instance_list_cb )(const char *widget_id, const char *instance_id, void *data) |
Callback function for getting result of widget_service_get_widget_instance_list. | |
typedef enum widget_lifecycle_event | widget_lifecycle_event_e |
Enumeration for life cycle event of widgets. | |
typedef int(* | widget_lifecycle_event_cb )(const char *widget_id, widget_lifecycle_event_e lifecycle_event, const char *widget_instance_id, void *data) |
Called when a widget is created or destroyed. |
typedef enum widget_error widget_error_e |
Enumeration for the result status of widget operation.
typedef enum widget_event_type widget_event_type_e |
Enumeration for widget event type.
These events will be sent from the provider.
typedef int(* widget_instance_list_cb)(const char *widget_id, const char *instance_id, void *data) |
Callback function for getting result of widget_service_get_widget_instance_list.
[in] | widget_id | Widget appid |
[in] | widget_instance_id | widget instance ID |
[in] | data | user Data |
typedef int(* widget_lifecycle_event_cb)(const char *widget_id, widget_lifecycle_event_e lifecycle_event, const char *widget_instance_id, void *data) |
Called when a widget is created or destroyed.
[in] | widget_id | appid of widget application |
[in] | lifecycle_event | Type of event |
[in] | widget_instance_id | Widget instance ID |
[in] | data | user data |
0
on success, otherwise a negative error value typedef enum widget_lifecycle_event widget_lifecycle_event_e |
typedef int(* widget_list_by_pkgid_cb)(const char *widget_id, int is_prime, void *data) |
Callback function for getting result of widget_service_get_widget_list_by_pkgid.
[in] | widget_id | appid of widget application |
[in] | is_prime | will be sent as 1 if the widget is a default widget |
[in] | data | user Data |
typedef int(* widget_list_cb)(const char *pkgid, const char *widget_id, int is_prime, void *data) |
Callback function for getting result of widget_service_get_widget_list.
[in] | pkgid | package id |
[in] | widget_id | appid of widget application |
[in] | is_prime | will be sent as 1 if the widget is a default widget |
[in] | data | user Data |
typedef enum widget_size_type widget_size_type_e |
Enumeration for list of supporting widget size types.
enum widget_error |
Enumeration for the result status of widget operation.
enum widget_event_type |
Enumeration for widget event type.
These events will be sent from the provider.
enum widget_size_type |
Enumeration for list of supporting widget size types.
int widget_service_change_period | ( | const char * | widget_id, |
const char * | instance_id, | ||
double | period | ||
) |
Changes the update period of the given widget instance.
[in] | widget_id | appid of widget application |
[in] | instance_id | Widget instance ID |
[in] | period | New update period in sec |
0
on success, otherwise a negative error value WIDGET_ERROR_NONE | Successfully changed(requested) |
WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_FAULT | Failed to create a request packet |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
WIDGET_ERROR_OUT_OF_MEMORY | Not enough memory |
char* widget_service_get_app_id_of_setup_app | ( | const char * | widget_id | ) |
Gets the appId of setup app which is specified by the given widget ID's manifest.
This setup app should be launched before adding the widget to get the content_info.
This function should be called before adding a widget.
To determine the content information string.
[in] | widget_id | appid of widget application |
@c | NULL There is no setup application or error occurred, you can check it using get_last_result() |
appid | AppId if exists or NULL |
int widget_service_get_content_of_widget_instance | ( | const char * | widget_id, |
const char * | widget_instance_id, | ||
bundle ** | b | ||
) |
Gets content of the widget instance.
[in] | widget_id | appid of widget application |
[in] | widget_instance_id | Widget instance ID |
[out] | b | Bundle(content) data of the given widget instance, it should be released by caller. |
0
on success, otherwise a negative error value WIDGET_ERROR_IO_ERROR | Failed to access DB |
WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
char* widget_service_get_icon | ( | const char * | pkgid, |
const char * | lang | ||
) |
Gets icon path of given widget package.
The user should free the returned string with free().
[in] | pkgid | Package ID of widget application |
[in] | lang | Locale(en-us, ko-kr, ...), if it is NULL , function will use the system locale automatically |
name | Allocated heap address |
@c | NULL Fails to get path of an icon, get_last_result() will return reasons of failure if it fails |
char* widget_service_get_main_app_id | ( | const char * | widget_id | ) |
Gets the MAIN application ID of given widget package ID.
[in] | widget_id | appid of widget application |
@c | NULL if it fails to get main application Id (UI-APPID), get_last_result() will returns reason of failure |
appid | Main application Id |
char* widget_service_get_name | ( | const char * | widget_id, |
const char * | lang | ||
) |
Gets the name of the given widget.
[in] | widget_id | appid of widget application |
[in] | lang | Locale(en-us, ko-kr, ...), if it is NULL , function will use the system locale automatically |
name | If it fails to get name |
@c | NULL Allocated heap address, get_last_result() will return reasons of failure if it fails. |
int widget_service_get_need_of_frame | ( | const char * | widget_id, |
widget_size_type_e | size_type, | ||
bool * | need_of_frame | ||
) |
Gets the need of decoration frame for the given widget.
This API gets the need of decoration frame for the given widget from database.
The value of the need of touch effect means:
true : The viewer should make decoration frame outside of the widget. false : No need to make decoration frame.
[in] | widget_id | appid of widget application |
[in] | size_type | Size type |
[out] | need_of_frame | the need of decoration frame |
0
on success, otherwise a negative error value WIDGET_ERROR_INVALID_PARAMETER | Invalid parameter was given |
WIDGET_ERROR_IO_ERROR | Some error occurs on opening DB file |
int widget_service_get_need_of_mouse_event | ( | const char * | widget_id, |
widget_size_type_e | size_type, | ||
bool * | need_of_mouse_event | ||
) |
Gets the need of mouse event for the given widget.
This function gets need of mouse event for the given widget from database.
The value of mouse event requirement means:
true : The widget requires mouse event. A viewer must feed the mouse event to the widget instance.
false : The widget doesn't require mouse event.
[in] | widget_id | appid of widget application |
[in] | size_type | Widget size type |
[out] | need_of_mouse_event | The need of mouse event |
WIDGET_ERROR_INVALID_PARAMETER | Invalid parameter was given |
WIDGET_ERROR_IO_ERROR | Some error occurs on opening DB file |
int widget_service_get_need_of_touch_effect | ( | const char * | widget_id, |
widget_size_type_e | size_type, | ||
bool * | need_of_touch_event | ||
) |
Gets the need of touch effect for the given widget.
This API gets the need of touch effect for the given widget from database.
The value of the need of touch effect means:
true : A viewer is required to make the touch effect when a user clicks the widget, but it is just a recommendation.
false : A viewer is not required to make the touch effect, the box will make the touch effect itself.
[in] | widget_id | appid of widget application |
[in] | size_type | Size type |
[out] | need_of_touch_event | the need of touch effect |
0
on success, otherwise a negative error value WIDGET_ERROR_INVALID_PARAMETER | Invalid parameter was given |
WIDGET_ERROR_IO_ERROR | Some error occurs on opening DB file |
int widget_service_get_nodisplay | ( | const char * | widget_id | ) |
Gets the "nodisplay" value.
[in] | widget_id | appid of widget application |
1 | The box should not be listed by the widget list app |
0 | Box should be listed, get_last_result() will return reasons of failure if it fails |
char* widget_service_get_package_id | ( | const char * | widget_id | ) |
Gets the package ID of the given widget.
[in] | widget_id | appid of widget application |
appid | String which is allocated in the heap |
@c | NULL Invalid appid, get_last_result() will return reasons of failure if it fails |
char* widget_service_get_preview_image_path | ( | const char * | widget_id, |
widget_size_type_e | size_type | ||
) |
Gets the preview image path of given size type.
This function will return the preview image path.
[in] | widget_id | appid of widget application |
[in] | size_type | Widget size type |
path | Preview image path |
@c | NULL There is no preview image file, get_last_result() will returns reason of failure if it fails. |
int widget_service_get_size | ( | widget_size_type_e | type, |
int * | width, | ||
int * | height | ||
) |
Gets the pixel size of given size type.
Size types would be
WIDGET_SIZE_TYPE_1x1
WIDGET_SIZE_TYPE_2x1
WIDGET_SIZE_TYPE_2x2
WIDGET_SIZE_TYPE_4x1
WIDGET_SIZE_TYPE_4x2
WIDGET_SIZE_TYPE_4x3
WIDGET_SIZE_TYPE_4x4
WIDGET_SIZE_TYPE_4x5
WIDGET_SIZE_TYPE_4x6
WIDGET_SIZE_TYPE_FULL
WIDGET_SIZE_TYPE_EASY_1x1
WIDGET_SIZE_TYPE_EASY_3x1
WIDGET_SIZE_TYPE_EASY_3x3.
[in] | type | Size type |
[out] | width | Pixel size width |
[out] | height | Pixel size height |
0
on success, otherwise a negative error value WIDGET_ERROR_NONE | Successfully done |
int widget_service_get_size_type | ( | int | width, |
int | height, | ||
widget_size_type_e * | size_type | ||
) |
Gets the size type for given pixel size.
Returnable size types are
WIDGET_SIZE_TYPE_1x1
WIDGET_SIZE_TYPE_2x1
WIDGET_SIZE_TYPE_2x2
WIDGET_SIZE_TYPE_4x1
WIDGET_SIZE_TYPE_4x2
WIDGET_SIZE_TYPE_4x3
WIDGET_SIZE_TYPE_4x4
WIDGET_SIZE_TYPE_4x5
WIDGET_SIZE_TYPE_4x6
WIDGET_SIZE_TYPE_FULL
WIDGET_SIZE_TYPE_EASY_1x1
WIDGET_SIZE_TYPE_EASY_3x1
WIDGET_SIZE_TYPE_EASY_3x3
or
WIDGET_SIZE_TYPE_UNKNOWN for error.
[in] | width | Pixel size width |
[in] | height | Pixel size height |
[out] | size_type | Widget size type |
0
on success, otherwise a negative error value WIDGET_ERROR_INVALID_PARAMETER | Invalid parameter was given |
int widget_service_get_supported_size_types | ( | const char * | widgetid, |
int * | cnt, | ||
int ** | types | ||
) |
Gets the supported size list of given widget ID.
[in] | widgetid | appid of widget application |
[in] | cnt | Size of types array |
[in,out] | cnt | Result count of types array |
[out] | types | Array of types |
0
on success, otherwise a negative error value WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_IO_ERROR | Failed to access DB |
WIDGET_ERROR_NONE | Successfully done |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
int widget_service_get_supported_sizes | ( | const char * | widget_id, |
int * | cnt, | ||
int ** | w, | ||
int ** | h | ||
) |
Gets the supported size list.
[in] | widget_id | appid of widget application |
[in,out] | cnt | Count of array w and h |
[out] | w | Width array |
[out] | h | Height array |
0
on success, otherwise a negative error value WIDGET_ERROR_NONE | If succeed to get supported size list |
WIDGET_ERROR_IO_ERROR | Failed to access DB |
WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
char* widget_service_get_widget_id | ( | const char * | id | ) |
Gets the ID of a widget by the given ID of package or UI app. If there are two or more widgets in the package, this function returns the ID of the primary widget.
[in] | id | Package Id or UI App Id |
@c | NULL Failed to get primary widget id, get_last_result() will returns reason of failure |
widget_id | Primary widget Id. |
int widget_service_get_widget_instance_list | ( | const char * | widget_id, |
widget_instance_list_cb | cb, | ||
void * | data | ||
) |
Gets widget instances of given widget_id.
[in] | widget_id | appid of widget application |
[in] | cb | Callback function |
[in] | data | user Data for callback function |
0
on success, otherwise a negative error value WIDGET_ERROR_NOT_EXIST | Instance is not exist |
WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
WIDGET_ERROR_NOT_SUPPORTED | Not supported |
int widget_service_get_widget_list | ( | widget_list_cb | cb, |
void * | data | ||
) |
Gets a list of all widgets.
[in] | cb | Callback function |
[in] | data | user Data for callback function |
0
on success, otherwise a negative error value WIDGET_ERROR_IO_ERROR | Failed to access DB |
WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
count | Count of widget packages |
int widget_service_get_widget_list_by_pkgid | ( | const char * | pkgid, |
widget_list_by_pkgid_cb | cb, | ||
void * | data | ||
) |
Gets a list of widgets included in the given package ID.
[in] | pkgid | Package ID (Not the UI App ID) |
[in] | cb | Callback function |
[in] | data | Callback data |
0
on success, otherwise a negative error value int | Count of widget packages |
WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_IO_ERROR | Failed to access DB |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
int widget_service_set_lifecycle_event_cb | ( | const char * | widget_id, |
widget_lifecycle_event_cb | cb, | ||
void * | data | ||
) |
Registers event handler callback function for life cycle events of widgets.
[in] | widget_id | appid of widget application |
[in] | cb | Callback function |
[in] | data | user Data |
WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
int widget_service_trigger_update | ( | const char * | widget_id, |
const char * | instance_id, | ||
bundle * | b, | ||
int | force | ||
) |
Triggers the update event for given widget instance.
[in] | widget_id | appid of widget application |
[in] | instance_id | Set NULL if you don't know what the ID is. Then every instance of given pkgname will trigger its update event |
[in] | b | Bundle data will be passed to the widget application via widget_update handler, default is NULL |
[in] | force | 1 If you want to update your widget even if the provider is paused or 0. 0 is default |
0
on success, otherwise a negative error value WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_CANCELED | Provider is paused, so this update request is canceled.(ignored), if you want to make update forcely, use force=1 |
WIDGET_ERROR_OUT_OF_MEMORY | Memory is not enough to make request |
WIDGET_ERROR_FAULT | Failed to create a request packet |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
WIDGET_ERROR_NONE | Successfully requested |
int widget_service_unset_lifecycle_event_cb | ( | const char * | widget_id, |
void ** | user_data | ||
) |
Unregisters event handler callback function for life cycle events of widgets.
[in] | widget_id | appid of widget application |
[out] | user_data | User callback data |
0
on success, otherwise a negative error value WIDGET_ERROR_INVALID_PARAMETER | Invalid argument |
WIDGET_ERROR_PERMISSION_DENIED | Permission denied |
WIDGET_ERROR_NOT_EXIST | Event handler callback function does not exist |