Add Setting feature on system-server lib
[platform/framework/native/appfw.git] / src / system-server / setting / providers / FSys_SettingSoundProvider.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file        FSys_SettingSoundProvider.cpp
19  * @brief       This is the implementation for the _SettingSoundProvider class.
20  */
21
22 #include <FBase_StringConverter.h>
23
24 #include <FApp.h>
25 #include <FBase.h>
26 #include <FBaseSysLog.h>
27 #include <FIo.h>
28
29 #include "FSys_SettingInfo.h"
30 #include "FSys_SettingSoundProvider.h"
31
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Utility;
35 using namespace Tizen::Io;
36
37 namespace Tizen { namespace System
38 {
39 static const wchar_t* _SOUND_MEDIA_VOLUME = L"http://tizen.org/setting/sound.media.volume";
40 static const wchar_t* _SOUND_NOTIFICATION = L"http://tizen.org/setting/sound.notification";
41 static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD = L"http://tizen.org/setting/sound.notification.repetition_period";
42 static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE = L"once";
43 static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN = L"2min";
44 static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN = L"5min";
45 static const wchar_t* _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN = L"10min";
46 static const wchar_t* _SOUND_NOTIFICATION_VOLUME = L"http://tizen.org/setting/sound.notification.volume";
47 static const wchar_t* _SOUND_RINGTONE_VOLUME = L"http://tizen.org/setting/sound.ringtone.volume";
48 static const wchar_t* _SOUND_SYSTEM_VOLUME = L"http://tizen.org/setting/sound.system.volume";
49
50 static const wchar_t* _SOUND_RINGTONE = L"http://tizen.org/setting/sound.ringtone";
51 static const wchar_t* _SOUND_SILENTMODE = L"http://tizen.org/setting/sound.silent_mode";
52 static const wchar_t* _SOUND_TOUCH = L"http://tizen.org/setting/sound.touch";
53 static const wchar_t* _SOUND_LOCK = L"http://tizen.org/setting/sound.lock";
54
55 _SettingSoundProvider::_SettingSoundProvider()
56 {
57         int errorCode = sound_manager_set_volume_changed_cb(SettingEventSoundManager, null);
58         if(errorCode != 0)
59         {
60                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register volume event listener.");
61         }
62
63         errorCode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, SettingEventSettingInfo, null);
64         if(errorCode != 0)
65         {
66                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register ringtone event listener.");
67         }
68
69         errorCode = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, SettingEventRuntimeInfo, null);
70         if(errorCode != 0)
71         {
72                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register silent mode event listener.");
73         }
74
75         errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SettingEventVConf, null);
76         if(errorCode != 0)
77         {
78                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL event listener.");
79         }
80
81         errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SettingEventVConf, null);
82         if(errorCode != 0)
83         {
84                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT event listener.");
85         }
86
87         errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SettingEventVConf, null);
88         if(errorCode != 0)
89         {
90                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_SOUND_LOCK_BOOL event listener.");
91         }
92
93         errorCode = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SettingEventVConf, null);
94         if(errorCode != 0)
95         {
96                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to register VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT event listener.");
97         }
98 }
99
100
101 _SettingSoundProvider::~_SettingSoundProvider()
102 {
103         sound_manager_unset_volume_changed_cb();
104
105         int errorCode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE);
106         if(errorCode != 0)
107         {
108                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister ringtone event listener.");
109         }
110
111         errorCode = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED);
112         if(errorCode != 0)
113         {
114                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister silent mode event listener.");
115         }
116
117         errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SettingEventVConf);
118         if(errorCode != 0)
119         {
120                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL event listener.");
121         }
122
123         errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SettingEventVConf);
124         if(errorCode != 0)
125         {
126                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_SOUND_LOCK_BOOL event listener.");
127         }
128
129         errorCode = vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SettingEventVConf);
130         if(errorCode != 0)
131         {
132                 SysLogException(NID_SYS, E_SYSTEM, "It is failed to unregister VCONFKEY_SETAPPL_SOUND_LOCK_BOOL event listener.");
133         }
134 }
135
136 result
137 _SettingSoundProvider::GetValue(const String& key, bool& value)
138 {
139         int errorCode = 0;
140         result r = E_OBJ_NOT_FOUND;
141
142         if (key == _SOUND_SILENTMODE)
143         {
144                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
145                 r = E_SUCCESS;
146                 bool silentModeEnabled = false;
147                 errorCode = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, &silentModeEnabled);
148                 SysTryReturnResult(NID_SYS, errorCode == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get the RUNTIME_INFO_KEY_SILENT_MODE_ENABLED");
149                 value = !silentModeEnabled;
150         }
151         else if (key == _SOUND_TOUCH)
152         {
153                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound touch effect feature.");
154                 r = E_SUCCESS;
155                 int soundTouch = 0;
156                 errorCode = vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &soundTouch);
157                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL vconf");
158                 if(soundTouch == 0)
159                 {
160                         value = false;
161                 }
162                 else
163                 {
164                         value = true;
165                 }
166                 return r;
167         }
168         else if (key == _SOUND_LOCK)
169         {
170                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound touch effect feature.");
171                 r = E_SUCCESS;
172
173                 int soundLock = 0;
174                 errorCode = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &soundLock);
175                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_SOUND_LOCK_BOO vconf");
176                 if(soundLock == 0)
177                 {
178                         value = false;
179                 }
180                 else
181                 {
182                         value = true;
183                 }
184                 return r;
185         }
186         return r;
187 }
188
189 result
190 _SettingSoundProvider::SetValue(const String& key, const bool value)
191 {
192         int errorCode = 0;
193         result r = E_OBJ_NOT_FOUND;
194
195         if(key == _SOUND_SILENTMODE)
196         {
197                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
198                 r = E_SUCCESS;
199                 bool silentMode = !value;
200                 errorCode = vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, silentMode);
201                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to set on VCONFKEY_SETAPPL_SOUND_STATUS_BOOL vconf");
202         }
203         else if(key == _SOUND_TOUCH)
204         {
205                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound touch effect feature.");
206                 r = E_SUCCESS;
207                 errorCode = vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, value);
208                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL vconf");
209         }
210         else if(key == _SOUND_LOCK)
211         {
212                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound lock effect feature.");
213                 r = E_SUCCESS;
214                 errorCode = vconf_set_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, value);
215                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get on VCONFKEY_SETAPPL_SOUND_LOCK_BOOL vconf");
216         }
217         return r;
218 }
219
220 result
221 _SettingSoundProvider::GetValue(const String& key, int& value)
222 {
223         int volume = 0;
224         int maxVolume = 0;
225         int errorCode = 0;
226         result r = E_OBJ_NOT_FOUND;
227
228         if (key == _SOUND_MEDIA_VOLUME)
229         {
230                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
231                 r = E_SUCCESS;
232
233                 errorCode = sound_manager_get_max_volume(SOUND_TYPE_MEDIA, &maxVolume);
234                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
235
236                 errorCode = sound_manager_get_volume(SOUND_TYPE_MEDIA, &volume);
237                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
238
239                 value = volume;
240         }
241         else if (key == _SOUND_NOTIFICATION_VOLUME)
242         {
243                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
244                 r = E_SUCCESS;
245
246                 errorCode = sound_manager_get_max_volume(SOUND_TYPE_NOTIFICATION, &maxVolume);
247                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
248
249                 errorCode = sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &volume);
250                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
251
252                 value = volume;
253         }
254         else if (key == _SOUND_RINGTONE_VOLUME)
255         {
256                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
257                 r = E_SUCCESS;
258
259                 errorCode = sound_manager_get_max_volume(SOUND_TYPE_RINGTONE, &maxVolume);
260                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
261
262                 errorCode = sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
263                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
264
265                 value = volume;
266         }
267         else if (key == _SOUND_SYSTEM_VOLUME)
268         {
269                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
270                 r = E_SUCCESS;
271
272                 errorCode = sound_manager_get_max_volume(SOUND_TYPE_SYSTEM, &maxVolume);
273                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_max_volume It is failed");
274
275                 errorCode = sound_manager_get_volume(SOUND_TYPE_SYSTEM, &volume);
276                 SysTryReturnResult(NID_SYS, errorCode == SOUND_MANAGER_ERROR_NONE, E_SYSTEM, "sound_manager_get_volume It is failed");
277
278                 value = volume;
279         }
280         return r;
281 }
282
283 result
284 _SettingSoundProvider::SetValue(const String& key, const int value)
285 {
286         int errorCode = 0;
287         int maxVolume = 0;
288         result r = E_SUCCESS;
289         sound_type_e soundType;
290
291         if (key == _SOUND_MEDIA_VOLUME)
292         {
293                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
294                 soundType = SOUND_TYPE_MEDIA;
295         }
296         else if (key == _SOUND_NOTIFICATION_VOLUME)
297         {
298                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
299                 soundType = SOUND_TYPE_NOTIFICATION;
300         }
301         else if (key == _SOUND_RINGTONE_VOLUME)
302         {
303                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
304                 soundType = SOUND_TYPE_RINGTONE;
305         }
306         else if (key == _SOUND_SYSTEM_VOLUME)
307         {
308                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support sound feature.");
309                 soundType = SOUND_TYPE_SYSTEM;
310         }
311         else
312         {
313                 return E_OBJ_NOT_FOUND;
314         }
315
316         errorCode = sound_manager_get_max_volume(soundType, &maxVolume);
317         SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM,  "It is failed to get max volume.");
318         SysTryReturnResult(NID_SYS, maxVolume >= value && value >= 0, E_INVALID_ARG, "The specified value[%d] is outside the bounds of soundCategory.", value);
319
320         SysLog(NID_SYS, "Required Volume is %d, Value is %d", soundType, value);
321         errorCode = sound_manager_set_volume(soundType, value);
322         SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "A system error has occured.");
323
324         return r;
325 }
326
327 result
328 _SettingSoundProvider::GetValue(const String& key, String& value)
329 {
330         int errorCode = 0;
331         result r =E_OBJ_NOT_FOUND;
332
333         if(key == _SOUND_RINGTONE)
334         {
335                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone feature.");
336                 r = E_SUCCESS;
337                 char* pRingtone = null;
338                 errorCode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &pRingtone);
339                 SysTryReturnResult(NID_SYS, errorCode == SYSTEM_SETTINGS_ERROR_NONE, E_SYSTEM, "It is failed to get ringtone");
340
341                 value.Clear();
342                 value.Append(pRingtone);
343                 free(pRingtone);
344                 if(File::IsFileExist(value) == false)
345                 {
346                         if(File::IsFileExist(L"/opt/share/settings/Ringtones/ringtone_sdk.mp3") == true)
347                         {
348                                 value = L"/opt/share/settings/Ringtones/ringtone_sdk.mp3";
349                                 system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, "/opt/share/settings/Ringtones/ringtone_sdk.mp3");
350                         }
351                         else
352                         {
353                                 return E_SYSTEM;
354                         }
355                 }
356         }
357         if(key == _SOUND_NOTIFICATION)
358         {
359                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone feature.");
360                 r = E_SUCCESS;
361                 char* pNotification = null;
362                 pNotification = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
363                 SysTryReturnResult(NID_SYS, pNotification != null, E_SYSTEM, "It is failed to get ringtone");
364                 value.Clear();
365                 value.Append(pNotification);
366                 free(pNotification);
367
368                 if(File::IsFileExist(value) == false)
369                 {
370                         if(File::IsFileExist( L"/opt/share/settings/Alerts/General notification_sdk.wav") == true)
371                         {
372                                 value =  L"/opt/share/settings/Alerts/General notification_sdk.wav";
373                                 errorCode = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, "/opt/share/settings/Alerts/General notification_sdk.wav");
374                         }
375                         else
376                         {
377                                 return E_SYSTEM;
378                         }
379                 }
380         }
381         else if(key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
382         {
383                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notificaito sound feature.");
384                 r = E_SUCCESS;
385
386                 int current_value = 0;
387                 errorCode = vconf_get_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &current_value);
388                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get notification repeat count.");
389
390                 switch (current_value)
391                 {
392                 case SETTING_SOUND_REP_ONCE:
393                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE;
394                         break;
395                 case SETTING_SOUND_REP_EVERY_2_MIN:
396                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN;
397                         break;
398                 case SETTING_SOUND_REP_EVERY_5_MIN:
399                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN;
400                         break;
401                 case SETTING_SOUND_REP_EVERY_10_MIN:
402                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN;
403                         break;
404                 default:
405                         SysLogException(NID_SYS, E_SYSTEM, "Unsupported value[%d] is provided.", current_value);
406                         return E_SYSTEM;
407                 }
408         }
409
410         return r;
411 }
412
413 result
414 _SettingSoundProvider::SetValue(const String& key, const String value)
415 {
416         int errorCode = 0;
417         result r = E_OBJ_NOT_FOUND;
418
419         if(key == _SOUND_RINGTONE)
420         {
421                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone sound feature.");
422                 r = E_SUCCESS;
423
424                 char* pFilePath = null;
425                 SysTryReturn(NID_SYS, File::IsFileExist(value) == true, E_INVALID_ARG, E_INVALID_ARG, "The entry for the specified ringtone file or the file path cannot be found");
426                 pFilePath = _StringConverter::CopyToCharArrayN(value);
427
428                 SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "It is failed to convert type of filePath");
429
430                 errorCode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, const_cast<char*>(pFilePath));
431                 SysTryReturn(NID_SYS, errorCode == 0, E_SYSTEM, E_SYSTEM, "It is failed to set ringtone");
432
433                 delete [] pFilePath;
434         }
435         else if(key == _SOUND_NOTIFICATION)
436         {
437                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notification sound feature.");
438                 r = E_SUCCESS;
439
440                 char* pFilePath = null;
441                 SysTryReturn(NID_SYS, File::IsFileExist(value) == true, E_INVALID_ARG, E_INVALID_ARG, "The entry for the specified notification file or the file path cannot be found");
442                 pFilePath = _StringConverter::CopyToCharArrayN(value);
443
444                 SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "It is failed to convert type of filePath");
445
446                 errorCode = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, const_cast<char*>(pFilePath));
447                 SysTryReturn(NID_SYS, errorCode == 0, E_SYSTEM, E_SYSTEM, "It is failed to set ringtone");
448
449                 delete [] pFilePath;
450         }
451         else if(key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
452         {
453                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notificaito sound feature.");
454                 r = E_SUCCESS;
455
456                 String requestValue(value);
457
458                 requestValue.ToLowerCase();
459
460                 int current_value = 0;
461
462                 if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE)
463                 {
464                         current_value = (int) SETTING_SOUND_REP_ONCE;
465                 }
466                 else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN)
467                 {
468                         current_value = (int) SETTING_SOUND_REP_EVERY_2_MIN;
469                 }
470                 else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN)
471                 {
472                         current_value = (int) SETTING_SOUND_REP_EVERY_5_MIN;
473                 }
474                 else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN)
475                 {
476                         current_value = (int) SETTING_SOUND_REP_EVERY_10_MIN;
477                 }
478                 else
479                 {
480                         SysLogException(NID_SYS, E_INVALID_ARG, "Requested value[%ls] is not supported.", value.GetPointer());
481                         return E_INVALID_ARG;
482                 }
483
484                 errorCode = vconf_set_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, current_value);
485                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get notification repeat count.");
486         }
487
488
489         return r;
490 }
491
492 bool
493 _SettingSoundProvider::HasKey(const Tizen::Base::String& key)
494 {
495
496         if(key == _SOUND_MEDIA_VOLUME || key == _SOUND_NOTIFICATION_VOLUME
497                 || key == _SOUND_RINGTONE_VOLUME || key == _SOUND_SYSTEM_VOLUME)
498         {
499                 return true;
500         }
501         else if(key == _SOUND_RINGTONE)
502         {
503                 return true;
504         }
505         else if(key == _SOUND_SILENTMODE)
506         {
507                 return true;
508         }
509         else if(key == _SOUND_TOUCH || key == _SOUND_LOCK)
510         {
511                 return true;
512         }
513         else if(key == _SOUND_NOTIFICATION || key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
514         {
515                 return true;
516         }
517
518         return false;
519 }
520
521 void
522 _SettingSoundProvider::SettingEventSoundManager(sound_type_e type, unsigned int volume, void* userData)
523 {
524         String settingKey;
525
526         switch (type)
527         {
528         case SOUND_TYPE_SYSTEM:
529                 settingKey.Append(_SOUND_SYSTEM_VOLUME);
530                 break;
531         case SOUND_TYPE_MEDIA:
532                 settingKey.Append(_SOUND_MEDIA_VOLUME);
533                 break;
534         case SOUND_TYPE_RINGTONE:
535                 settingKey.Append(_SOUND_RINGTONE_VOLUME);
536                 break;
537         case SOUND_TYPE_NOTIFICATION:
538                 settingKey.Append(_SOUND_NOTIFICATION_VOLUME);
539                 break;
540         default:
541                 SysLog(NID_SYS, "NOT IMPLEMENTED");
542                 return;
543         }
544
545         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
546         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
547
548         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
549         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
550 }
551
552 void
553 _SettingSoundProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
554 {
555         String settingKey;
556
557         if(key == SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE)
558         {
559                 settingKey.Append(_SOUND_RINGTONE);
560         }
561         else
562         {
563                 return;
564         }
565         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
566         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
567
568         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
569         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
570 }
571
572 void
573 _SettingSoundProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
574 {
575         String settingKey;
576
577         if(key == RUNTIME_INFO_KEY_SILENT_MODE_ENABLED)
578         {
579                 settingKey.Append(_SOUND_SILENTMODE);
580         }
581         else
582         {
583                 return;
584         }
585         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
586         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
587
588         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
589         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
590 }
591 void
592 _SettingSoundProvider::SettingEventVConf(keynode_t* node, void* userData)
593 {
594         String settingKey;
595
596         if (strcmp(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, vconf_keynode_get_name(node)) == 0)
597         {
598                 settingKey.Append(_SOUND_TOUCH);
599         }
600         else if(strcmp(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, vconf_keynode_get_name(node)) == 0)
601         {
602                 settingKey.Append(_SOUND_LOCK);
603         }
604         else if(strcmp(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, vconf_keynode_get_name(node)) == 0)
605         {
606                 settingKey.Append(_SOUND_NOTIFICATION_REPEAT_PERIOD);
607         }
608         else if(strcmp(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_keynode_get_name(node)) == 0)
609         {
610                 settingKey.Append(_SOUND_NOTIFICATION);
611         }
612         else
613         {
614                 return;
615         }
616         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
617         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
618
619         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
620         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
621 }
622
623 }}