1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*
* Contacts Service Helper
*
* Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Youngjae Shin <yj99.shin@samsung.com>
*
* 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.
*
*/
#include <malloc.h>
#include <contacts-svc.h>
#include <vconf.h>
#include <vconf-keys.h>
#include "cts-utils.h"
#include "internal.h"
#include "sim.h"
#include "sqlite.h"
#include "normalize.h"
#include "localize.h"
#include "utils.h"
static const char *HELPER_VCONF_TAPI_SIM_PB_INIT = VCONFKEY_TELEPHONY_SIM_PB_INIT;
static const char *HELPER_VCONF_SYSTEM_LANGUAGE = VCONFKEY_LANGSET;
static const char *HELPER_VCONF_DISPLAY_ORDER = VCONFKEY_CONTACTS_SVC_NAME_DISPLAY_ORDER;
static int default_language = -1;
static int system_language = -1;
static inline int helper_get_system_language(void)
{
return system_language;
}
inline int helper_set_default_language(int lang)
{
int ret = vconf_set_int(CTS_VCONF_DEFAULT_LANGUAGE, lang);
h_retvm_if(ret<0, CTS_ERR_VCONF_FAILED, "vconf_set_int() Failed(%d)", ret);
default_language = lang;
return CTS_SUCCESS;
}
static void helper_change_language_cb(keynode_t *key, void *data)
{
int ret = -1;
const char *langset;
langset = vconf_keynode_get_str(key);
if (!default_language) {
ret = vconf_get_int(CTS_VCONF_DEFAULT_LANGUAGE, &default_language);
h_retm_if(ret<0, "vconf_get_int() Failed(%d)", ret);
}
system_language = helper_get_language_type(langset);
if (system_language != default_language)
ret = helper_update_default_language(default_language, system_language);
}
static void helper_update_collation_cb(keynode_t *key, void *data)
{
helper_update_collation();
}
static void helper_tapi_sim_complete_cb(keynode_t *key, void *data)
{
int ret, init_stat;
init_stat = vconf_keynode_get_int(key);
if (VCONFKEY_TELEPHONY_SIM_PB_INIT_COMPLETED == init_stat) {
ret = helper_sim_read_SDN(NULL);
h_warn_if(CTS_SUCCESS != ret, "helper_sim_read_SDN() Failed(%d)", ret);
vconf_ignore_key_changed(HELPER_VCONF_TAPI_SIM_PB_INIT, helper_tapi_sim_complete_cb);
}
}
void helper_final_configuration(void)
{
int ret = -1;
ret = vconf_ignore_key_changed(HELPER_VCONF_SYSTEM_LANGUAGE, helper_change_language_cb);
h_retm_if(ret<0,"vconf_ignore_key_changed(%s) Failed(%d)",HELPER_VCONF_SYSTEM_LANGUAGE,ret);
ret = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, helper_update_collation_cb);
h_retm_if(ret<0,"vconf_ignore_key_changed(%s) Failed(%d)",VCONFKEY_REGIONFORMAT,ret);
ret = vconf_ignore_key_changed(HELPER_VCONF_DISPLAY_ORDER, helper_update_collation_cb);
h_retm_if(ret<0,"vconf_ignore_key_changed(%s) Failed(%d)",VCONFKEY_REGIONFORMAT,ret);
}
int helper_init_configuration(void)
{
int ret, sim_stat=-1;
const char *langset;
ret = vconf_get_int(CTS_VCONF_DEFAULT_LANGUAGE, &default_language);
if (ret < 0) {
ERR("vconf_get_int(%s) Failed(%d)",CTS_VCONF_DEFAULT_LANGUAGE ,ret);
default_language = 0;
}
ret = vconf_notify_key_changed(HELPER_VCONF_SYSTEM_LANGUAGE,
helper_change_language_cb, NULL);
h_retvm_if(ret<0, CTS_ERR_VCONF_FAILED, "vconf_notify_key_changed(%s) Failed(%d)",
HELPER_VCONF_SYSTEM_LANGUAGE, ret);
ret = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT,
helper_update_collation_cb, NULL);
h_retvm_if(ret<0, CTS_ERR_VCONF_FAILED, "vconf_notify_key_changed(%s) Failed(%d)",
VCONFKEY_REGIONFORMAT, ret);
ret = vconf_notify_key_changed(HELPER_VCONF_DISPLAY_ORDER,
helper_update_collation_cb, NULL);
h_retvm_if(ret<0, CTS_ERR_VCONF_FAILED, "vconf_notify_key_changed(%s) Failed(%d)",
HELPER_VCONF_DISPLAY_ORDER, ret);
langset = vconf_get_str(HELPER_VCONF_SYSTEM_LANGUAGE);
h_warn_if(NULL == langset, "vconf_get_str(%s) return NULL", HELPER_VCONF_SYSTEM_LANGUAGE);
system_language = helper_get_language_type(langset);
if (system_language != default_language) {
ERR("system lang(%s, %d), default lang(%d)", langset, system_language, default_language);
helper_update_default_language(default_language, system_language);
}
ret = vconf_get_int(HELPER_VCONF_TAPI_SIM_PB_INIT, &sim_stat);
if (VCONFKEY_TELEPHONY_SIM_PB_INIT_COMPLETED == sim_stat) {
ret = helper_sim_read_SDN(NULL);
h_warn_if(CTS_SUCCESS != ret, "helper_sim_read_SDN() Failed(%d)", ret);
} else {
ret = vconf_notify_key_changed(HELPER_VCONF_TAPI_SIM_PB_INIT,
helper_tapi_sim_complete_cb, NULL);
h_retvm_if(ret<0, CTS_ERR_VCONF_FAILED, "vconf_notify_key_changed(%s) Failed(%d)",
HELPER_VCONF_TAPI_SIM_PB_INIT, ret);
}
return CTS_SUCCESS;
}
void helper_trim_memory(void)
{
malloc_trim(0);
sqlite3_release_memory(-1);
}
|