diff options
Diffstat (limited to 'src/agent/common/common_vconf.c')
-rwxr-xr-x | src/agent/common/common_vconf.c | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/src/agent/common/common_vconf.c b/src/agent/common/common_vconf.c new file mode 100755 index 0000000..e874d37 --- /dev/null +++ b/src/agent/common/common_vconf.c @@ -0,0 +1,191 @@ +/* + * oma-ds-agent + * Copyright (c) 2012 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @Common_Util.c + * @version 0.1 + * @brief This file is the source file of implementation of wrapping vconf function + */ + +#include <vconf.h> +#include <stdio.h> +#include <stdlib.h> +#include <glib.h> +#include <string.h> + +#include <sync_agent.h> + +#include "common/common_vconf.h" + +char *get_vconf_str(char *base_key, char *key) +{ + _EXTERN_FUNC_ENTER; + + char path[128]; + char *value = NULL; + + snprintf(path, sizeof(path), "%s%s", base_key, key); + value = vconf_get_str(path); + + if (value != NULL) { + if (strcmp(value, "") == 0) { + + if (value != NULL) + free(value); + + _EXTERN_FUNC_EXIT; + return NULL; + } else { + _EXTERN_FUNC_EXIT; + return value; + } + } else { + _EXTERN_FUNC_EXIT; + return NULL; + } + +} + +char *get_vconf_str_key(char *key) +{ + _EXTERN_FUNC_ENTER; + + char *value = NULL; + value = vconf_get_str(key); + + if (value != NULL) { + if (strcmp(value, "") == 0) { + + if (value != NULL) + free(value); + + _EXTERN_FUNC_EXIT; + return NULL; + } else { + _EXTERN_FUNC_EXIT; + return value; + } + } else { + _EXTERN_FUNC_EXIT; + return NULL; + } +} + +bool get_vconf_int(char *base_key, char *key, int *value) +{ + _EXTERN_FUNC_ENTER; + + char path[128]; + int temp = 0; + int result; + + snprintf(path, sizeof(path), "%s%s", base_key, key); + result = vconf_get_int(path, &temp); + + _EXTERN_FUNC_EXIT; + + if (result == 0) { + *value = temp; + return true; + } else + return false; +} + +bool get_vconf_int_key(char *key, int *value) +{ + _EXTERN_FUNC_ENTER; + + int temp = 0; + int result; + + result = vconf_get_int(key, &temp); + + _EXTERN_FUNC_EXIT; + + if (result == 0) { + *value = temp; + return true; + } else + return false; +} + +bool set_vconf_str(char *base_key, char *key, char *value) +{ + _EXTERN_FUNC_ENTER; + + char path[128]; + int result; + + snprintf(path, sizeof(path), "%s%s", base_key, key); + result = vconf_set_str(path, value); + + _EXTERN_FUNC_EXIT; + + if (result == 0) + return true; + else + return false; +} + +bool set_vconf_str_key(char *key, char *value) +{ + _EXTERN_FUNC_ENTER; + + int result; + result = vconf_set_str(key, value); + + _EXTERN_FUNC_EXIT; + + if (result == 0) + return true; + else + return false; +} + +bool set_vconf_int(char *base_key, char *key, int value) +{ + _EXTERN_FUNC_ENTER; + + char path[128]; + int result; + + snprintf(path, sizeof(path), "%s%s", base_key, key); + result = vconf_set_int(path, value); + + _EXTERN_FUNC_EXIT; + + if (result == 0) + return true; + else + return false; +} + +bool set_vconf_int_key(char *key, int value) +{ + _EXTERN_FUNC_ENTER; + + int result; + + result = vconf_set_int(key, value); + + _EXTERN_FUNC_EXIT; + + if (result == 0) + return true; + else + return false; +} |