Askuser-popup for mobile profile
[profile/mobile/apps/native/askuser-popup.git] / common / src / common_utils.c
1 /**
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @file        common_utils.c
18  * @author      Yunjin Lee (yunjin-.lee@samsung.com)
19  * @version     1.0
20  * @brief
21  */
22
23 #include <efl_extension.h>
24
25 #include "common_utils.h"
26
27 privacy_data_s* new_privacy_data()
28 {
29         privacy_data_s* pd = (privacy_data_s*)malloc(sizeof(privacy_data_s));
30         if (!pd) {
31                 LOGE("failed to malloc privacy_data_s");
32                 return NULL;
33         }
34         pd->privacy = NULL;
35         pd->user_responsed = false;
36         pd->response = NULL;
37         return pd;
38 }
39
40 void __free_privacy_data(privacy_data_s* pd)
41 {
42         if (pd->privacy)
43                 free(pd->privacy);
44         if (pd->response)
45                 free(pd->response);
46 }
47
48 void free_privacy_data(gpointer pd)
49 {
50         __free_privacy_data((privacy_data_s*) pd);
51         free(pd);
52 }
53
54 void free_app_data(app_data_s* ad)
55 {
56         if (ad->caller_pkgid != NULL)
57                 free(ad->caller_pkgid);
58         if (ad->privacy_list != NULL)
59                 g_list_free_full(ad->privacy_list, free_privacy_data);
60         if (ad->launch_type != NULL)
61                 free(ad->launch_type);
62 }