Add default Smack manifest for oma-ds-service.spec
[pkgs/o/oma-ds-service.git] / Common / Common_Vconf.c
1 /*
2  * oma-ds-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JuHak Park <juhaki.park@samsung.com>,
7  *          JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8  *          SunBong Ha <sunbong.ha@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24
25
26
27 /*
28  * For any sort of issue you concern as to this software,
29  * you may use following point of contact.
30  * All resources contributed on this software
31  * are orinigally written by S-Core Inc., a member of Samsung Group.
32  *
33  * SeongWon Shim <seongwon.shim@samsung.com>
34  */
35
36 /**
37  *   @Common_Util.c
38  *   @version                                                                   0.1
39  *   @brief                                                                             This file is the source file of implementation of wrapping vconf function
40  */
41
42 #include <vconf.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <glib.h>
46 #include <string.h>
47 #include "Common/Common_Vconf.h"
48
49
50 char *get_vconf_str(char *baseKey, char *key)
51 {
52         char path[128];
53         char *value = NULL;
54
55         sprintf(path, "%s%s", baseKey, key);
56         value = vconf_get_str(path);
57
58         if (value != NULL) {
59                 if (strcmp(value, "") == 0) {
60
61                         if (value != NULL)
62                                 free(value);
63
64                         return NULL;
65                 } else
66                         return value;
67         } else{
68                 return NULL;
69         }
70
71 }
72
73 char *get_vconf_str_key(char *key)
74 {
75         char *value = NULL;
76         value = vconf_get_str(key);
77
78         if (value != NULL) {
79                 if (strcmp(value, "") == 0) {
80
81                         if (value != NULL)
82                                 free(value);
83
84                         return NULL;
85                 } else
86                         return value;
87         } else{
88                 return NULL;
89         }
90 }
91
92 bool get_vconf_int(char *baseKey, char *key, int *value)
93 {
94         char path[128];
95         int temp = 0;
96         int result;
97
98         sprintf(path, "%s%s", baseKey, key);
99         result = vconf_get_int(path, &temp);
100
101         if (result == 0) {
102                 *value = temp;
103                 return true;
104         } else
105                 return false;
106 }
107
108 bool get_vconf_Int_key(char *key, int *value)
109 {
110         int temp = 0;
111         int result;
112
113         result = vconf_get_int(key, &temp);
114
115         if (result == 0) {
116                 *value = temp;
117                 return true;
118         } else
119                 return false;
120 }
121
122 bool set_vconf_str(char *baseKey, char *key, char *value)
123 {
124         char path[128];
125         int result;
126
127         sprintf(path, "%s%s", baseKey, key);
128         result = vconf_set_str(path, value);
129
130         if (result == 0)
131                 return true;
132         else
133                 return false;
134 }
135
136
137 bool set_vconf_str_key(char *key, char *value)
138 {
139         int result;
140         result = vconf_set_str(key, value);
141
142         if (result == 0)
143                 return true;
144         else
145                 return false;
146 }
147
148 bool set_vconf_int(char *baseKey, char *key, int value)
149 {
150         char path[128];
151         int result;
152
153         sprintf(path, "%s%s", baseKey, key);
154         result = vconf_set_int(path, value);
155
156         if (result == 0)
157                 return true;
158         else
159                 return false;
160 }
161
162 bool set_vconf_int_key(char *key, int value)
163 {
164         int result;
165
166         result = vconf_set_int(key, value);
167
168         if (result == 0)
169                 return true;
170         else
171                 return false;
172 }