handling project name on both of daemon and things lib
[apps/native/tizen-things-daemon.git] / daemon / src / ttd-app-data.c
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 #include <glib.h>
18 #include "ttd-log.h"
19 #include "ttd-app-data.h"
20
21 struct __ttd_app_data {
22         char *p_name;
23         char *data;
24 };
25
26 ttd_app_data *ttd_app_data_new(const char *project, const char *data)
27 {
28         ttd_app_data *app_data = NULL;
29
30         retv_if(!project, NULL);
31         retv_if(!data, NULL);
32
33         app_data = g_try_malloc0(sizeof(ttd_app_data));
34         retv_if(!app_data, NULL);
35
36         app_data->p_name = g_strdup(project);
37         app_data->data = g_strdup(data);
38
39         return app_data;
40 }
41
42 void ttd_app_data_free(ttd_app_data *app_data)
43 {
44         if (!app_data)
45                 return;
46
47         g_free(app_data->p_name);
48         g_free(app_data->data);
49         g_free(app_data);
50 }
51
52 const char *ttd_app_data_get_project_name(ttd_app_data *app_data)
53 {
54         retv_if(!app_data, NULL);
55         return app_data->p_name;
56 }
57
58 const char *ttd_app_data_get_data(ttd_app_data *app_data)
59 {
60         retv_if(!app_data, NULL);
61         return app_data->data;
62 }