2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file simple_roaming_agent.cpp
18 * @author Pawel Sikorski (p.sikorski@samsung.com)
19 * @author Lukasz Marek (l.marek@samsung.com)
20 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
22 * @brief roaming agent
25 #include "simple_roaming_agent.h"
27 #include <dpl/fast_delegate.h>
28 #include <dpl/log/log.h>
29 #include <dpl/singleton_impl.h>
30 IMPLEMENT_SINGLETON(SimpleRoamingAgent)
32 SimpleRoamingAgent::SimpleRoamingAgent()
34 if (vconf_notify_key_changed(
35 VCONFKEY_TELEPHONY_SVC_ROAM,
36 vConfChagedCallback, this) < 0)
38 LogError("Cannot add vconf callback [" <<
39 VCONFKEY_TELEPHONY_SVC_ROAM << "]");
40 Assert(false && "Cannot add vconf callback");
44 if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
45 LogError("Cannot get current roaming status");
46 Assert(false && "Cannot get current roaming status");
48 bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
49 m_networkType = type ? ROAMING : HOME;
50 LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));
55 SimpleRoamingAgent::~SimpleRoamingAgent()
57 if (vconf_ignore_key_changed(
58 VCONFKEY_TELEPHONY_SVC_ROAM,
59 vConfChagedCallback) < 0)
61 LogError("Cannot rm vconf callback [" <<
62 VCONFKEY_TELEPHONY_SVC_ROAM << "]");
63 Assert(false && "Cannot remove vconf callback");
68 void SimpleRoamingAgent::vConfChagedCallback(keynode_t *keyNode, void *data)
70 LogInfo("SimpleRoamingAgent::vConfChagedCallback ");
71 char *key = vconf_keynode_get_name(keyNode);
74 LogWarning("vconf key is null.");
77 SimpleRoamingAgent *agent = static_cast<SimpleRoamingAgent *>(data);
79 LogError("Bad user arg from vconf lib");
80 Assert(false && "Bad user arg from vconf lib");
84 if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
85 LogError("Cannot get current roaming status");
86 Assert(false && "Cannot get current roaming status");
88 bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
89 agent->m_networkType = type ? ROAMING : HOME;
90 LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));