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/log/log.h>
28 #include <dpl/singleton_impl.h>
29 IMPLEMENT_SINGLETON(SimpleRoamingAgent)
31 SimpleRoamingAgent::SimpleRoamingAgent()
33 if (vconf_notify_key_changed(
34 VCONFKEY_TELEPHONY_SVC_ROAM,
35 vConfChagedCallback, this) < 0)
37 LogError("Cannot add vconf callback [" <<
38 VCONFKEY_TELEPHONY_SVC_ROAM << "]");
39 Assert(false && "Cannot add vconf callback");
43 if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
44 LogError("Cannot get current roaming status");
45 Assert(false && "Cannot get current roaming status");
47 bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
48 m_networkType = type ? ROAMING : HOME;
49 LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));
54 SimpleRoamingAgent::~SimpleRoamingAgent()
56 if (vconf_ignore_key_changed(
57 VCONFKEY_TELEPHONY_SVC_ROAM,
58 vConfChagedCallback) < 0)
60 LogError("Cannot rm vconf callback [" <<
61 VCONFKEY_TELEPHONY_SVC_ROAM << "]");
62 //Assert(false && "Cannot remove vconf callback");
67 void SimpleRoamingAgent::vConfChagedCallback(keynode_t *keyNode, void *data)
69 LogInfo("SimpleRoamingAgent::vConfChagedCallback ");
70 char *key = vconf_keynode_get_name(keyNode);
73 LogWarning("vconf key is null.");
76 std::string keyString = key;
77 if (VCONFKEY_TELEPHONY_SVC_ROAM != keyString) {
78 LogError("Wrong key found");
79 Assert(false && "Wrong key found in vconf callback");
82 SimpleRoamingAgent *agent = static_cast<SimpleRoamingAgent *>(data);
84 LogError("Bad user arg from vconf lib");
85 Assert(false && "Bad user arg from vconf lib");
89 if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &result) != 0) {
90 LogError("Cannot get current roaming status");
91 Assert(false && "Cannot get current roaming status");
93 bool type = (result == VCONFKEY_TELEPHONY_SVC_ROAM_ON);
94 agent->m_networkType = type ? ROAMING : HOME;
95 LogInfo("Network type is " << (type ? "ROAMING" : "HOME"));