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 #include <Commons/Exception.h>
18 #include <vconf-keys.h>
22 #define __TEMP_OPTION_FOR_GET_CURRENT_VOLUME__ // We can't get current volume by VCONF. This option is temporary till VCONF is woring correctly.
23 #if defined (__TEMP_OPTION_FOR_GET_CURRENT_VOLUME__)
25 #include <mm_player.h>
31 const std::size_t NUMBER_OF_AVAILABLE_DESKTOPS = 1;
32 const std::size_t DEFAULT_DESKTOP_INDEX = 1;
34 const WrtDeviceApis::Profile::Api::IManager::ProfileType profileMap[] = {
35 WrtDeviceApis::Profile::Api::IManager::NORMAL,
36 WrtDeviceApis::Profile::Api::IManager::SILENT,
37 WrtDeviceApis::Profile::Api::IManager::DRIVING,
38 WrtDeviceApis::Profile::Api::IManager::MEETING,
39 WrtDeviceApis::Profile::Api::IManager::OUTDOOR,
40 WrtDeviceApis::Profile::Api::IManager::FLIGHT
42 const size_t PROFILE_MAP_SIZE = sizeof(profileMap) / sizeof(profileMap[0]);
45 namespace WrtDeviceApis {
47 Manager& Manager::getInstance()
49 static Manager instance;
57 void Manager::Release() const
60 Ringtones::iterator it1 = m_ringtones.begin();
61 for (; it1 != m_ringtones.end(); ++it1) {
64 if (m_ringtones.size() > 0) {
68 Desktops::iterator it2 = m_desktops.begin();
69 for (; it2 != m_desktops.end(); ++it2) {
74 if (m_desktops.size() > 0) {
79 Profile::Api::IDesktopPtr Manager::getDesktop(std::size_t index) const
81 if (index == Profile::Api::IDesktop::DEFAULT) {
82 index = DEFAULT_DESKTOP_INDEX;
85 if (index > NUMBER_OF_AVAILABLE_DESKTOPS) {
86 Throw(Commons::OutOfRangeException);
89 Desktops::const_iterator it = m_desktops.find(index);
90 if (it != m_desktops.end()) {
93 return (m_desktops[index] = Profile::Api::IDesktopPtr(new Desktop()));
96 std::size_t Manager::getDesktopCount() const
98 return NUMBER_OF_AVAILABLE_DESKTOPS;
101 Profile::Api::IRingtone* Manager::getRingtone(Profile::Api::RingtoneScope scope)
105 case Profile::Api::RS_CALL:
106 return getRingtone_(Profile::Api::RS_CALL);
107 case Profile::Api::RS_SMS:
108 case Profile::Api::RS_MMS:
109 case Profile::Api::RS_EMAIL:
110 return getRingtone_(Profile::Api::RS_SMS);
112 Throw(Commons::UnsupportedException);
117 m_profileKey(VCONFKEY_SETAPPL_CUR_PROFILE_INT),
118 m_volumeKey(VCONFKEY_SETAPPL_PROFILE_CURRENT_CALL_VOLUME_INT),
119 m_vibrationKey(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL)
123 Profile::Api::IRingtone* Manager::getRingtone_(
124 Profile::Api::RingtoneScope scope) const
126 Ringtones::const_iterator it = m_ringtones.find(scope);
127 if (it != m_ringtones.end()) {
130 return (m_ringtones[scope] = new Ringtone(scope));
133 Profile::Api::IManager::ProfileType Manager::getProfileType() const
135 int profile = m_profileKey.getInt();
136 if (profile < 0 || profile >= static_cast<int>(PROFILE_MAP_SIZE)) {
137 Throw(Commons::OutOfRangeException);
140 return profileMap[profile];
143 int Manager::getSystemVolume() const
145 #if defined (__TEMP_OPTION_FOR_GET_CURRENT_VOLUME__)
146 unsigned int volume = 0;
147 int err = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &volume);
148 if (MM_ERROR_NONE != err) {
149 LogError("Can't get volume level. Error code: " << std::hex << err);
154 return m_volumeKey.getInt();
158 int Manager::getVibrateType() const
160 return m_vibrationKey.getBool();