2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #include "sticker_info.h"
17 #include <sticker_provider.h>
18 #include <app_common.h>
27 static sticker_provider_h sticker_provider = NULL;
28 static bool need_to_retrive = false;
31 set_sticker_data(sticker_data_uri_type_e type, const char* uri, const char* keyword,
32 int len, const char* group, const char* thumbnail, const char* description)
34 sticker_data_h sticker_data;
37 /* Creates a Sticker data handle */
38 ret = sticker_data_create(&sticker_data);
39 if (ret != STICKER_ERROR_NONE) {
41 LOGE("Failed to create sticker data");
44 /* Sets the URI and URI type of the sticker */
45 ret = sticker_data_set_uri(sticker_data, type, uri);
46 if (ret != STICKER_ERROR_NONE) {
48 LOGE("Failed to set uri");
51 //for (int i = 0; i < len; i++)
53 /* Adds a keyword of the sticker to the list */
54 ret = sticker_data_add_keyword(sticker_data, keyword);
55 if (ret != STICKER_ERROR_NONE) {
57 LOGE("Failed to add keyword");
61 /* Sets the group name of the sticker */
62 ret = sticker_data_set_group_name(sticker_data, group);
63 if (ret != STICKER_ERROR_NONE) {
65 LOGE("Failed to set group name");
68 /* Sets the thumbnail local path of the sticker */
70 ret = sticker_data_set_thumbnail(sticker_data, thumbnail);
71 if (ret != STICKER_ERROR_NONE) {
73 LOGE("Failed to set thumbnail");
77 /* Sets the description of the sticker */
78 ret = sticker_data_set_description(sticker_data, description);
79 if (ret != STICKER_ERROR_NONE) {
81 LOGE("Failed to set description");
88 insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc)
90 sticker_data_h data_handle;
93 data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, NULL, desc);
95 ret = sticker_provider_insert_data(sticker_provider, data_handle);
96 if (ret != STICKER_ERROR_NONE) {
97 LOGE("Failed to insert data. error code : %x. message : %s", ret, get_error_message(ret));
100 LOGI("Succeeded to insert data");
103 /* Destroys a sticker data handle */
104 ret = sticker_data_destroy(data_handle);
105 if (ret != STICKER_ERROR_NONE) {
107 LOGE("Failed to destroy sticker data");
111 int create_sticker_provider_handle(void)
114 ret = sticker_provider_create(&sticker_provider);
115 if (ret != STICKER_ERROR_NONE) {
117 LOGE("Failed to create sticker provider");
123 void destroy_sticker_provider_handle(void)
125 sticker_provider_destroy(sticker_provider);
126 sticker_provider = NULL;
129 void delete_sticker_data(const char *fileName)
132 ret = sticker_provider_delete_data_by_uri(sticker_provider, fileName);
133 if (ret != STICKER_ERROR_NONE)
134 LOGE("Failed to delete sticker. ret : %d", ret);