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 <vconf-keys.h>
18 #include <Filesystem/Path.h>
23 PLATFORM_VOLUME_LEVEL0 = 0,
24 PLATFORM_VOLUME_LEVEL1,
25 PLATFORM_VOLUME_LEVEL2,
26 PLATFORM_VOLUME_LEVEL3,
27 PLATFORM_VOLUME_LEVEL4,
28 PLATFORM_VOLUME_LEVEL5,
29 PLATFORM_VOLUME_LEVEL6,
30 PLATFORM_VOLUME_LEVEL7
34 namespace WrtDeviceApis {
36 Profile::Api::Volume Ringtone::getVolume() const
38 double step = Profile::Api::VOLUME_MAX /
39 static_cast<double>(PLATFORM_VOLUME_LEVEL7);
40 Haptics::Api::Feedback level = Profile::Api::NO_VOLUME +
41 (step * m_volumeKey.getInt());
42 if (level > Profile::Api::VOLUME_MAX) {
43 level = Profile::Api::VOLUME_MAX;
48 void Ringtone::setVolume(Profile::Api::Volume level)
50 if (level > Profile::Api::VOLUME_MAX) {
51 level = Profile::Api::VOLUME_MAX;
54 double step = Profile::Api::VOLUME_MAX /
55 static_cast<double>(PLATFORM_VOLUME_LEVEL7);
56 for (int i = PLATFORM_VOLUME_LEVEL0; i <= PLATFORM_VOLUME_LEVEL7; ++i) {
57 if (level <= (i * step)) {
58 m_volumeKey.setValue(i);
64 Filesystem::Api::IPathPtr Ringtone::getAudio() const
66 // TODO: probably not a full should be returned (maybe restricted to /mnt/ums)
67 return Filesystem::Api::IPath::create(m_audioKey.getString());
70 void Ringtone::setAudio(const Filesystem::Api::IPathPtr& path)
72 // TODO: it should probably be converted some way
73 m_audioKey.setValue(path->getFullPath());
76 Haptics::Api::Feedback Ringtone::getHaptics() const
78 double step = Haptics::Api::FEEDBACK_MAX /
79 static_cast<double>(SETTING_VIB_FEEDBACK_LEVEL5);
80 Haptics::Api::Feedback level = Haptics::Api::NO_FEEDBACK +
81 (step * m_hapticsKey.getInt());
82 if (level > Haptics::Api::FEEDBACK_MAX) {
83 level = Haptics::Api::FEEDBACK_MAX;
88 void Ringtone::setHaptics(Haptics::Api::Feedback level)
90 if (level > Haptics::Api::FEEDBACK_MAX) {
91 level = Haptics::Api::FEEDBACK_MAX;
94 double step = Haptics::Api::FEEDBACK_MAX /
95 static_cast<double>(SETTING_VIB_FEEDBACK_LEVEL5);
96 for (int i = SETTING_VIB_FEEDBACK_LEVEL0;
97 i <= SETTING_VIB_FEEDBACK_LEVEL5;
99 if (level <= (i * step)) {
100 m_hapticsKey.setValue(i);
106 Ringtone::Ringtone(Profile::Api::RingtoneScope scope) :
109 if (Profile::Api::RS_CALL == m_scope) {
110 m_volumeKey.reset(VCONFKEY_SETAPPL_PROFILE_CURRENT_CALL_VOLUME_INT);
111 m_hapticsKey.reset(VCONFKEY_SETAPPL_PROFILE_CURRENT_CALL_ALERT_VIB_INT);
112 m_audioKey.reset(VCONFKEY_SETAPPL_PROFILE_CURRENT_CALL_TONE_PATH_STR);
114 m_volumeKey.reset(VCONFKEY_SETAPPL_PROFILE_CURRENT_MSG_VOLUME_INT);
115 m_hapticsKey.reset(VCONFKEY_SETAPPL_PROFILE_CURRENT_MSG_ALERT_VIB_INT);
116 m_audioKey.reset(VCONFKEY_SETAPPL_PROFILE_CURRENT_MSG_TONE_PATH_STR);