static int _check_file_exist(const char *app_id, const char *path)
{
int ret = 0;
+ int path_len = 0;
package_info_h package_info = NULL;
char *app_path = NULL;
char *file_path = NULL;
goto cleanup;
}
- int path_len = strlen(app_path) + strlen(path) + 2;
+ path_len = strlen(app_path) + strlen(path) + 2;
file_path = (char *)calloc(path_len, sizeof(char));
if (!file_path) {
LOGE("Failed to alloc memory");
int arr_len = 0;
int keyword_arr_len = 0;
+ JsonNode *root = NULL;
+ JsonObject *root_obj = NULL;
+
*reply_body = g_variant_new("()");
if (*reply_body == NULL) {
LOGE("Failed to create reply_body");
goto cleanup;
}
- JsonNode *root = json_parser_get_root(parser);
+ root = json_parser_get_root(parser);
if (root == NULL) {
LOGE("failed to get root");
ret = STICKERD_SERVER_ERROR_OPERATION_FAILED;
goto cleanup;
}
- JsonObject *root_obj = json_node_get_object(root);
+ root_obj = json_node_get_object(root);
if (root_obj == NULL) {
LOGE("failed to get object");
ret = STICKERD_SERVER_ERROR_OPERATION_FAILED;
int stickerd_db_delete_sticker_info(int record_id)
{
int ret;
+ int uri_type = 0;
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
+ const unsigned char *uri = NULL;
+ const unsigned char *thumbnail = NULL;
db = _db_open();
if (!db)
goto cleanup;
}
- int uri_type = sqlite3_column_int(stmt, 0);
- const unsigned char *uri = sqlite3_column_text(stmt, 1);
- const unsigned char *thumbnail = sqlite3_column_text(stmt, 2);
+ uri_type = sqlite3_column_int(stmt, 0);
+ uri = sqlite3_column_text(stmt, 1);
+ thumbnail = sqlite3_column_text(stmt, 2);
if (uri_type == 1 && unlink((const char *)uri) == -1)
LOGE("fail to delete sticker file");
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
+ int uri_type = 0;
+ const unsigned char *thumbnail = NULL;
+
db = _db_open();
if (!db)
return STICKERD_SERVER_ERROR_DB_FAILED;
goto cleanup;
}
- int uri_type = sqlite3_column_int(stmt, 0);
- const unsigned char *thumbnail = sqlite3_column_text(stmt, 1);
+ uri_type = sqlite3_column_int(stmt, 0);
+ thumbnail = sqlite3_column_text(stmt, 1);
if (uri_type == 1 && unlink((const char *)uri) == -1)
LOGE("fail to delete sticker file");
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
+ const unsigned char *tmp_app_id = NULL;
+ const unsigned char *tmp_uri = NULL;
+ const unsigned char *tmp_thumbnail = NULL;
+ const unsigned char *tmp_description = NULL;
+ const unsigned char *tmp_group = NULL;
+ const unsigned char *tmp_date = NULL;
+
db = _db_open();
if (!db)
return STICKERD_SERVER_ERROR_DB_FAILED;
goto cleanup;
}
- const unsigned char *tmp_app_id = sqlite3_column_text(stmt, 1);
+ tmp_app_id = sqlite3_column_text(stmt, 1);
if (tmp_app_id) {
sticker_info->app_id = strdup((const char *)tmp_app_id);
} else {
sticker_info->type = sqlite3_column_int(stmt, 2);
- const unsigned char *tmp_uri = sqlite3_column_text(stmt, 3);
+ tmp_uri = sqlite3_column_text(stmt, 3);
if (tmp_uri)
sticker_info->uri = strdup((const char *)tmp_uri);
- const unsigned char *tmp_thumbnail = sqlite3_column_text(stmt, 4);
+ tmp_thumbnail = sqlite3_column_text(stmt, 4);
if (tmp_thumbnail)
sticker_info->thumbnail = strdup((const char *)tmp_thumbnail);
- const unsigned char *tmp_description = sqlite3_column_text(stmt, 5);
+ tmp_description = sqlite3_column_text(stmt, 5);
if (tmp_description)
sticker_info->description = strdup((const char *)tmp_description);
- const unsigned char *tmp_group = sqlite3_column_text(stmt, 6);
+ tmp_group = sqlite3_column_text(stmt, 6);
if (tmp_group)
sticker_info->group = strdup((const char *)tmp_group);
- const unsigned char *tmp_date = sqlite3_column_text(stmt, 7);
+ tmp_date = sqlite3_column_text(stmt, 7);
if (tmp_date)
sticker_info->date = strdup((const char *)tmp_date);
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
+ const unsigned char *tmp_app_id = NULL;
+ const unsigned char *tmp_uri = NULL;
+ const unsigned char *tmp_thumbnail = NULL;
+ const unsigned char *tmp_description = NULL;
+ const unsigned char *tmp_group = NULL;
+ const unsigned char *tmp_date = NULL;
+
db = _db_open();
if (!db)
return STICKERD_SERVER_ERROR_DB_FAILED;
sticker_info->record_id = sqlite3_column_int(stmt, 0);
- const unsigned char *tmp_app_id = sqlite3_column_text(stmt, 1);
+ tmp_app_id = sqlite3_column_text(stmt, 1);
if (tmp_app_id)
sticker_info->app_id = strdup((const char *)tmp_app_id);
sticker_info->type = sqlite3_column_int(stmt, 2);
- const unsigned char *tmp_uri = sqlite3_column_text(stmt, 3);
+ tmp_uri = sqlite3_column_text(stmt, 3);
if (tmp_uri)
sticker_info->uri = strdup((const char *)tmp_uri);
- const unsigned char *tmp_thumbnail = sqlite3_column_text(stmt, 4);
+ tmp_thumbnail = sqlite3_column_text(stmt, 4);
if (tmp_thumbnail)
sticker_info->thumbnail = strdup((const char *)tmp_thumbnail);
- const unsigned char *tmp_description = sqlite3_column_text(stmt, 5);
+ tmp_description = sqlite3_column_text(stmt, 5);
if (tmp_description)
sticker_info->description = strdup((const char *)tmp_description);
- const unsigned char *tmp_group = sqlite3_column_text(stmt, 6);
+ tmp_group = sqlite3_column_text(stmt, 6);
if (tmp_group)
sticker_info->group = strdup((const char *)tmp_group);
- const unsigned char *tmp_date = sqlite3_column_text(stmt, 7);
+ tmp_date = sqlite3_column_text(stmt, 7);
if (tmp_date)
sticker_info->date = strdup((const char *)tmp_date);
char *uri_path = NULL;
char *rel_thumbnail = NULL;
JsonArray *keyword_arr = NULL;
+ JsonArray *allowlist_arr = NULL;
+ JsonArray *sticker_arr = NULL;
int disp_type = 0;
int keyword_arr_len = 0;
+ JsonNode *root = NULL;
+ JsonObject *root_obj = NULL;
+
parser = json_parser_new();
json_parser_load_from_file(parser, file_path, &err_msg);
if (err_msg) {
goto cleanup;
}
- JsonNode *root = json_parser_get_root(parser);
+ root = json_parser_get_root(parser);
if (root == NULL) {
LOGE("failed to get root");
ret = 0;
goto cleanup;
}
- JsonObject *root_obj = json_node_get_object(root);
+ root_obj = json_node_get_object(root);
if (root_obj == NULL) {
LOGE("failed to get object");
ret = 0;
goto cleanup;
}
- JsonArray *allowlist_arr = json_object_get_array_member(root_obj, "whitelist");
+ allowlist_arr = json_object_get_array_member(root_obj, "whitelist");
if (allowlist_arr != NULL) {
for (int i = 0; i < json_array_get_length(allowlist_arr); i++) {
__insert_sticker_allowlist_info(appid, json_array_get_string_element(allowlist_arr, i));
}
}
- JsonArray *sticker_arr = json_object_get_array_member(root_obj, "sticker");
+ sticker_arr = json_object_get_array_member(root_obj, "sticker");
if (sticker_arr == NULL) {
LOGE("failed to get array member");
ret = 0;