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 * @author Zbigniew Kostrzewa <z.kostrzewa@samsung.com>
21 #include <Commons/Exception.h>
23 namespace WrtDeviceApis {
25 bool Source::isConnected() const
27 return (m_serviceType.getInt() > VCONFKEY_TELEPHONY_SVCTYPE_SEARCH);
30 Api::SourceType Source::getType() const
33 switch (m_serviceType.getInt()) {
34 case VCONFKEY_TELEPHONY_SVCTYPE_2G:
35 case VCONFKEY_TELEPHONY_SVCTYPE_2_5G:
36 case VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE:
38 case VCONFKEY_TELEPHONY_SVCTYPE_3G:
39 case VCONFKEY_TELEPHONY_SVCTYPE_HSDPA:
42 return Api::ST_UNKNOWN;
45 Catch(Commons::ConversionException) {
46 ReThrow(Commons::PlatformException);
50 void Source::addOnTypeChange(
51 const Api::EventSourceTypeChangeEmitterPtr& emitter)
53 m_onSourceTypeChange.attach(emitter);
54 SourceTypeChangeEmitters::LockType lock = m_onSourceTypeChange.getLock();
55 if (m_onSourceTypeChange.size() == 1) {
56 m_serviceType.attachCallback(onTypeChange, this);
60 void Source::removeOnTypeChange(
61 Api::EventSourceTypeChangeEmitter::IdType id)
63 m_onSourceTypeChange.detach(id);
64 SourceTypeChangeEmitters::LockType lock = m_onSourceTypeChange.getLock();
65 if (m_onSourceTypeChange.size() == 0) {
66 m_serviceType.detachCallback();
71 m_serviceType(VCONFKEY_TELEPHONY_SVCTYPE)
75 void Source::onTypeChange(const VConf::Node* /* node */,
78 Source* this_ = static_cast<Source*>(data);
80 Api::EventSourceTypeChangePtr event(
81 new Api::EventSourceTypeChange());
83 event->setType(this_->getType());
85 Catch(Commons::PlatformException) {
86 event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
88 this_->m_onSourceTypeChange.emit(event);