Tizen Native API  7.0
Sticker Provider

The Sticker Provider API provides the functions to create/update/delete the sticker information.

Required Header

#include <sticker_provider.h>

Overview

The sticker provider application can manager sticker information using Sticker Provider APIs. However, the provider application can only update and delete their own stickers.

Functions

int sticker_provider_create (sticker_provider_h *provider_handle)
 Creates a sticker provider handle.
int sticker_provider_destroy (sticker_provider_h provider_handle)
 Destroys a sticker provider handle.
int sticker_provider_insert_data (sticker_provider_h provider_handle, sticker_data_h data_handle)
 Inserts a sticker data to the sticker database.
int sticker_provider_insert_data_by_json_file (sticker_provider_h provider_handle, const char *json_path, sticker_provider_insert_finished_cb callback, void *user_data)
 Inserts a sticker data using JSON file.
int sticker_provider_update_data (sticker_provider_h provider_handle, sticker_data_h data_handle)
 Updates a sticker data in the sticker database.
int sticker_provider_delete_data (sticker_provider_h provider_handle, sticker_data_h data_handle)
 Deletes a sticker data in the sticker database.
int sticker_provider_delete_data_by_uri (sticker_provider_h provider_handle, const char *uri)
 Deletes a sticker with the given uri from the sticker database.
int sticker_provider_get_sticker_count (sticker_provider_h provider_handle, int *count)
 Gets the count of stickers stored by the provider application.
int sticker_provider_data_foreach_all (sticker_provider_h provider_handle, int offset, int count, int *result, sticker_provider_data_foreach_cb callback, void *user_data)
 Retrieves all sticker data in the sticker database.
int sticker_provider_set_group_image (sticker_provider_h provider_handle, const char *group, sticker_data_uri_type_e type, const char *uri)
 Sets the image of the sticker group.

Typedefs

typedef struct sticker_provider_s * sticker_provider_h
 The sticker provider handle.
typedef void(* sticker_provider_data_foreach_cb )(sticker_data_h data_handle, void *user_data)
 Called to retrieve all sticker data in the sticker database.
typedef void(* sticker_provider_insert_finished_cb )(sticker_error_e error, void *user_data)
 Called when inserting sticker data is finished.

Typedef Documentation

typedef void(* sticker_provider_data_foreach_cb)(sticker_data_h data_handle, void *user_data)

Called to retrieve all sticker data in the sticker database.

The sticker_provider_data_foreach_all() must be called to invoke this callback function, synchronously.

Since :
5.5
Remarks:
data_handle should not be freed and can be used only in the callback. If you want to use it outside of the callback, you need to use a clone which can be obtained sticker_data_clone().
Parameters:
[in]data_handleThe sticker data handle
[in]user_dataThe user data passed from the foreach function
Precondition:
sticker_provider_data_foreach_all() will invoke this callback.
See also:
sticker_provider_data_foreach_all()
typedef struct sticker_provider_s* sticker_provider_h

The sticker provider handle.

Since :
5.5
typedef void(* sticker_provider_insert_finished_cb)(sticker_error_e error, void *user_data)

Called when inserting sticker data is finished.

The following error codes can be received:
STICKER_ERROR_NONE Successful
STICKER_ERROR_OPERATION_FAILED Operation failed

Since :
5.5
Parameters:
[in]errorThe sticker error code
[in]user_dataThe user data passed from the foreach function
Precondition:
sticker_provider_insert_data_by_json_file() will invoke this callback.
See also:
sticker_provider_insert_data_by_json_file()

Function Documentation

int sticker_provider_create ( sticker_provider_h provider_handle)

Creates a sticker provider handle.

Since :
5.5
Remarks:
If the function succeeds, provider_handle must be released with sticker_provider_destroy().
Parameters:
[out]provider_handleThe sticker provider handle
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OUT_OF_MEMORYOut of memory
STICKER_ERROR_OPERATION_FAILEDOperation failed
See also:
sticker_provider_destroy()
int sticker_provider_data_foreach_all ( sticker_provider_h  provider_handle,
int  offset,
int  count,
int *  result,
sticker_provider_data_foreach_cb  callback,
void *  user_data 
)

Retrieves all sticker data in the sticker database.

If you set the offset as 10 and count as 10, then only searched data from 10 to 19 will be invoked.

Since :
5.5
Remarks:
It is not an error if result is smaller than count.
Parameters:
[in]provider_handleThe sticker provider handle
[in]offsetThe start position (Starting from zero)
[in]countThe number of stickers to be searched with respect to the offset
[out]resultThe number of stickers retrieved (zero indicates that no data was found)
[in]callbackThe callback function to invoke
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OUT_OF_MEMORYOut of memory
STICKER_ERROR_OPERATION_FAILEDOperation failed
Postcondition:
This function invokes sticker_provider_data_foreach_cb() repeatedly for getting data.
See also:
sticker_provider_data_foreach_cb()
int sticker_provider_delete_data ( sticker_provider_h  provider_handle,
sticker_data_h  data_handle 
)

Deletes a sticker data in the sticker database.

Since :
5.5
Remarks:
The data_handle must be the handle of the sticker stored in the sticker database.
Parameters:
[in]provider_handleThe sticker provider handle
[in]data_handleThe sticker data handle to be deleted
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OPERATION_FAILEDOperation failed
See also:
sticker_provider_insert_data()
sticker_provider_update_data()
int sticker_provider_delete_data_by_uri ( sticker_provider_h  provider_handle,
const char *  uri 
)

Deletes a sticker with the given uri from the sticker database.

If the database does not have a sticker that matches the given uri, the STICKER_ERROR_NO_SUCH_FILE error is returned.

Since :
5.5
Parameters:
[in]provider_handleThe sticker provider handle
[in]uriThe URI of the sticker data to be deleted
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OPERATION_FAILEDOperation failed
STICKER_ERROR_NO_SUCH_FILENo such file
See also:
sticker_provider_insert_data()
sticker_provider_delete_data()
int sticker_provider_destroy ( sticker_provider_h  provider_handle)

Destroys a sticker provider handle.

Since :
5.5
Parameters:
[in]provider_handleThe sticker provider handle
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OPERATION_FAILEDOperation failed
See also:
sticker_provider_create()
int sticker_provider_get_sticker_count ( sticker_provider_h  provider_handle,
int *  count 
)

Gets the count of stickers stored by the provider application.

Since :
5.5
Parameters:
[in]provider_handleThe sticker provider handle
[out]countThe number of stickers
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OPERATION_FAILEDOperation failed
int sticker_provider_insert_data ( sticker_provider_h  provider_handle,
sticker_data_h  data_handle 
)

Inserts a sticker data to the sticker database.

Since :
5.5
Remarks:
All data except thumbnail, description, and display_type must be set in the data_handle to insert the sticker data. If the URI type is STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory. It is recommended to delete your sticker file after inserting a sticker data.
Parameters:
[in]provider_handleThe sticker provider handle
[in]data_handleThe sticker data handle to be saved
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OPERATION_FAILEDOperation failed
STICKER_ERROR_FILE_EXISTSFile exists
STICKER_ERROR_NO_SUCH_FILENo such file
See also:
sticker_provider_update_data()
sticker_provider_delete_data()
int sticker_provider_insert_data_by_json_file ( sticker_provider_h  provider_handle,
const char *  json_path,
sticker_provider_insert_finished_cb  callback,
void *  user_data 
)

Inserts a sticker data using JSON file.

json_path must be a relative path like '/data/message_sticker.json'.

Since :
5.5
Remarks:
All data except thumbnail, description, and display_type must be set in the JSON file to insert the sticker data. json_path must have a non-null value and must be an existing file. If not, the error as invalid parameter will be returned. If the URI type is STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory. It is recommended to delete your sticker files after inserting a sticker data.
Parameters:
[in]provider_handleThe sticker provider handle
[in]json_pathThe path of JSON file containing sticker information to be saved
[in]callbackThe callback function to invoke
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OPERATION_FAILEDOperation failed
Postcondition:
This function invokes sticker_provider_insert_finished_cb().
See also:
sticker_provider_insert_finished_cb()
 //JSON file format
 {
    "sticker":
    [
        {
            "type" : 1,
            "uri" : "/res/face/heart_eyes.png",
            "keyword" : ["heart eyes", "love", "cute"],
            "group" : "face",
            "thumbnail" : "/res/face/thumbnail/heart_eyes.png",
            "description" : "Smiling face with heart eyes emoji.",
            "display_type" : 1
        },
        {
            "type" : 2,
            "uri" : "https://samsung.com/example/01/high_five.png",
            "keyword" : ["smile", "high five"],
            "group" : "face",
            "thumbnail" : "",
            "description" : "Smiling face with high five emoji.",
            "display_type" : null
        },
            .....
        {
            .....
        }
    ]
 }
int sticker_provider_set_group_image ( sticker_provider_h  provider_handle,
const char *  group,
sticker_data_uri_type_e  type,
const char *  uri 
)

Sets the image of the sticker group.

uri must be a relative path like '/res/smile.png' when type is STICKER_DATA_URI_LOCAL_PATH.

Since :
6.5
Parameters:
[in]provider_handleThe sticker provider handle
[in]groupThe group name for setting group image
[in]typeThe URI type of the image file
[in]uriThe URI of the image file
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter, e.g. group is NULL or the group name does not exist in the database
STICKER_ERROR_OPERATION_FAILEDOperation failed
STICKER_ERROR_NO_SUCH_FILENo such file, e.g. uri is NULL or the specified file does not exist
See also:
sticker_provider_insert_data()
int sticker_provider_update_data ( sticker_provider_h  provider_handle,
sticker_data_h  data_handle 
)

Updates a sticker data in the sticker database.

Since :
5.5
Parameters:
[in]provider_handleThe sticker provider handle
[in]data_handleThe sticker data handle to be updated
Returns:
0 on success, otherwise a negative error value
Return values:
STICKER_ERROR_NONESuccessful
STICKER_ERROR_NOT_SUPPORTEDNot supported
STICKER_ERROR_INVALID_PARAMETERInvalid parameter
STICKER_ERROR_OPERATION_FAILEDOperation failed
STICKER_ERROR_FILE_EXISTSFile exists
STICKER_ERROR_NO_SUCH_FILENo such file
See also:
sticker_provider_insert_data()
sticker_provider_delete_data()