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.
17 #include "sticker_info.h"
18 #include <sticker_provider.h>
19 #include <app_common.h>
25 static sticker_provider_h sticker_provider = NULL;
28 set_sticker_data(sticker_data_uri_type_e type, const char* uri, const char* keyword,
29 int len, const char* group, const char* thumbnail, const char* description)
31 sticker_data_h sticker_data;
34 /* Creates a Sticker data handle */
35 ret = sticker_data_create(&sticker_data);
36 if (ret != STICKER_ERROR_NONE) {
38 LOGE("Failed to create sticker data");
41 /* Sets the URI and URI type of the sticker */
42 ret = sticker_data_set_uri(sticker_data, type, uri);
43 if (ret != STICKER_ERROR_NONE) {
45 LOGE("Failed to set uri");
48 //for (int i = 0; i < len; i++)
50 /* Adds a keyword of the sticker to the list */
51 ret = sticker_data_add_keyword(sticker_data, keyword);
52 if (ret != STICKER_ERROR_NONE) {
54 LOGE("Failed to add keyword");
58 /* Sets the group name of the sticker */
59 ret = sticker_data_set_group_name(sticker_data, group);
60 if (ret != STICKER_ERROR_NONE) {
62 LOGE("Failed to set group name");
65 /* Sets the thumbnail local path of the sticker */
67 ret = sticker_data_set_thumbnail(sticker_data, thumbnail);
68 if (ret != STICKER_ERROR_NONE) {
70 LOGE("Failed to set thumbnail");
74 /* Sets the description of the sticker */
75 ret = sticker_data_set_description(sticker_data, description);
76 if (ret != STICKER_ERROR_NONE) {
78 LOGE("Failed to set description");
85 insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc)
87 sticker_data_h data_handle;
90 data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, NULL, desc);
92 ret = sticker_provider_insert_data(sticker_provider, data_handle);
93 if (ret != STICKER_ERROR_NONE) {
94 LOGE("Failed to insert data. error code : %x. message : %s", ret, get_error_message(ret));
97 LOGI("Succeeded to insert data");
100 /* Destroys a sticker data handle */
101 ret = sticker_data_destroy(data_handle);
102 if (ret != STICKER_ERROR_NONE) {
104 LOGE("Failed to destroy sticker data");
108 int create_sticker_provider_handle(void)
111 ret = sticker_provider_create(&sticker_provider);
112 if (ret != STICKER_ERROR_NONE) {
114 LOGE("Failed to create sticker provider");
120 void destroy_sticker_provider_handle(void)
122 sticker_provider_destroy(sticker_provider);
123 sticker_provider = NULL;
126 void delete_sticker_data(const char *fileName)
129 ret = sticker_provider_delete_data_by_uri(sticker_provider, fileName);
130 if (ret != STICKER_ERROR_NONE)
131 LOGE("Failed to delete sticker. ret : %d", ret);