4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * @file protocol-info.c
23 * @desc Network protocol entity: now it's only for
24 * datacall network interface type
26 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
30 #include <vconf/vconf.h>
33 #include "protocol-info.h"
34 #include "resourced.h"
37 static resourced_hw_net_protocol_type datacall_prot_t = RESOURCED_PROTOCOL_NONE;
39 static resourced_hw_net_protocol_type _convert_to_resourced_protocol(
43 case VCONFKEY_TELEPHONY_SVCTYPE_NOSVC:
44 return RESOURCED_PROTOCOL_DATACALL_NOSVC;
45 case VCONFKEY_TELEPHONY_SVCTYPE_EMERGENCY:
46 return RESOURCED_PROTOCOL_DATACALL_EMERGENCY;
47 case VCONFKEY_TELEPHONY_SVCTYPE_SEARCH:
48 return RESOURCED_PROTOCOL_DATACALL_SEARCH;
49 case VCONFKEY_TELEPHONY_SVCTYPE_2G:
50 return RESOURCED_PROTOCOL_DATACALL_2G;
51 case VCONFKEY_TELEPHONY_SVCTYPE_2_5G:
52 return RESOURCED_PROTOCOL_DATACALL_2_5G;
53 case VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE:
54 return RESOURCED_PROTOCOL_DATACALL_2_5G_EDGE;
55 case VCONFKEY_TELEPHONY_SVCTYPE_3G:
56 return RESOURCED_PROTOCOL_DATACALL_3G;
57 case VCONFKEY_TELEPHONY_SVCTYPE_HSDPA:
58 return RESOURCED_PROTOCOL_DATACALL_HSDPA;
59 case VCONFKEY_TELEPHONY_SVCTYPE_LTE:
60 return RESOURCED_PROTOCOL_DATACALL_LTE;
61 case VCONFKEY_TELEPHONY_SVCTYPE_NONE:
63 return RESOURCED_PROTOCOL_NONE;
67 static resourced_ret_c _get_protocol_type(
68 resourced_hw_net_protocol_type *prot_type)
72 ret = vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &status);
73 ret_value_msg_if(ret != 0, RESOURCED_ERROR_FAIL,
74 "vconf get failed(VCONFKEY_TELEPHONY_SVCTYPE)\n");
75 *prot_type = _convert_to_resourced_protocol(status);
76 return RESOURCED_ERROR_NONE;
79 static void _datacall_protocol_type_change_cb(keynode_t *key, void *data)
81 int val = vconf_keynode_get_int(key);
83 _D("key = %s, value = %d(int)\n", vconf_keynode_get_name(key), val);
84 datacall_prot_t = _convert_to_resourced_protocol(val);
87 void init_hw_net_protocol_type(void)
89 vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
90 _datacall_protocol_type_change_cb, NULL);
91 if (_get_protocol_type(&datacall_prot_t) != RESOURCED_ERROR_NONE)
92 _E("_get_protocol_type failed\n");
95 void finalize_hw_net_protocol_type(void)
97 vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVCTYPE,
98 _datacall_protocol_type_change_cb);
99 datacall_prot_t = RESOURCED_PROTOCOL_NONE;
102 resourced_hw_net_protocol_type get_hw_net_protocol_type(
103 const resourced_iface_type iftype)
105 if (iftype == RESOURCED_IFACE_DATACALL)
106 return datacall_prot_t;
108 return RESOURCED_PROTOCOL_NONE;