3553fd5e450731d2c27dfe9032e74c5615ca90fe
[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                         char* pPreloaded = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
347                         SysTryReturnResult(NID_SYS, pPreloaded != null, E_SYSTEM, "It is failed to get default ringtone.");
348
349                         String preloaded;
350                         preloaded.Append(pPreloaded);
351
352                         if(File::IsFileExist(preloaded) == true)
353                         {
354                                 value =  preloaded;
355                                 errorCode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, pPreloaded);
356                                 if(errorCode != SYSTEM_SETTINGS_ERROR_NONE)
357                                 {
358                                         SysLogException(NID_SYS, E_SYSTEM, "It is failed to set default ringtone.");
359                                 }
360
361                                 if(pPreloaded != null)
362                                 {
363                                         free(pPreloaded);
364                                 }
365                         }
366                         else
367                         {
368                                 if(pPreloaded != null)
369                                 {
370                                         free(pPreloaded);
371                                 }
372                                 return E_SYSTEM;
373                         }
374                 }
375         }
376         if(key == _SOUND_NOTIFICATION)
377         {
378                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone feature.");
379                 r = E_SUCCESS;
380                 char* pNotification = null;
381                 pNotification = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
382                 SysTryReturnResult(NID_SYS, pNotification != null, E_SYSTEM, "It is failed to get ringtone");
383                 value.Clear();
384                 value.Append(pNotification);
385                 free(pNotification);
386
387                 if(File::IsFileExist(value) == false)
388                 {
389                         char* pPreloaded = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
390                         SysTryReturnResult(NID_SYS, pPreloaded != null, E_SYSTEM, "It is failed to get default noti ringtone.");
391
392                         String preloaded;
393                         preloaded.Append(pPreloaded);
394                         if(File::IsFileExist(preloaded) == true)
395                         {
396                                 value =  preloaded;
397                                 errorCode = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, pPreloaded);
398                                 if(errorCode != 0)
399                                 {
400                                         SysLogException(NID_SYS, E_SYSTEM, "It is failed to set default noti ringtone.");
401                                 }
402
403                                 if(pPreloaded != null)
404                                 {
405                                         free(pPreloaded);
406                                 }
407                         }
408                         else
409                         {
410                                 if(pPreloaded != null)
411                                 {
412                                         free(pPreloaded);
413                                 }
414                                 return E_SYSTEM;
415                         }
416                 }
417         }
418         else if(key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
419         {
420                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notificaito sound feature.");
421                 r = E_SUCCESS;
422
423                 int current_value = 0;
424                 errorCode = vconf_get_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &current_value);
425                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get notification repeat count.");
426
427                 switch (current_value)
428                 {
429                 case SETTING_SOUND_REP_ONCE:
430                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE;
431                         break;
432                 case SETTING_SOUND_REP_EVERY_2_MIN:
433                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN;
434                         break;
435                 case SETTING_SOUND_REP_EVERY_5_MIN:
436                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN;
437                         break;
438                 case SETTING_SOUND_REP_EVERY_10_MIN:
439                         value = _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN;
440                         break;
441                 default:
442                         SysLogException(NID_SYS, E_SYSTEM, "Unsupported value[%d] is provided.", current_value);
443                         return E_SYSTEM;
444                 }
445         }
446
447         return r;
448 }
449
450 result
451 _SettingSoundProvider::SetValue(const String& key, const String value)
452 {
453         int errorCode = 0;
454         result r = E_OBJ_NOT_FOUND;
455
456         if(key == _SOUND_RINGTONE)
457         {
458                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support ringtone sound feature.");
459                 r = E_SUCCESS;
460
461                 char* pFilePath = null;
462                 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");
463                 pFilePath = _StringConverter::CopyToCharArrayN(value);
464
465                 SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "It is failed to convert type of filePath");
466
467                 errorCode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, const_cast<char*>(pFilePath));
468                 SysTryReturn(NID_SYS, errorCode == 0, E_SYSTEM, E_SYSTEM, "It is failed to set ringtone");
469
470                 delete [] pFilePath;
471         }
472         else if(key == _SOUND_NOTIFICATION)
473         {
474                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notification sound feature.");
475                 r = E_SUCCESS;
476
477                 char* pFilePath = null;
478                 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");
479                 pFilePath = _StringConverter::CopyToCharArrayN(value);
480
481                 SysTryReturn(NID_SYS, pFilePath != null, E_SYSTEM, E_SYSTEM, "It is failed to convert type of filePath");
482
483                 errorCode = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, const_cast<char*>(pFilePath));
484                 SysTryReturn(NID_SYS, errorCode == 0, E_SYSTEM, E_SYSTEM, "It is failed to set ringtone");
485
486                 delete [] pFilePath;
487         }
488         else if(key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
489         {
490                 SysTryReturnResult(NID_SYS, HasKey(key) == true, E_UNSUPPORTED_OPERATION, "Current device does not support notificaito sound feature.");
491                 r = E_SUCCESS;
492
493                 String requestValue(value);
494
495                 requestValue.ToLowerCase();
496
497                 int current_value = 0;
498
499                 if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_ONCE)
500                 {
501                         current_value = (int) SETTING_SOUND_REP_ONCE;
502                 }
503                 else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_2MIN)
504                 {
505                         current_value = (int) SETTING_SOUND_REP_EVERY_2_MIN;
506                 }
507                 else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_5MIN)
508                 {
509                         current_value = (int) SETTING_SOUND_REP_EVERY_5_MIN;
510                 }
511                 else if(requestValue == _SOUND_NOTIFICATION_REPEAT_PERIOD_10MIN)
512                 {
513                         current_value = (int) SETTING_SOUND_REP_EVERY_10_MIN;
514                 }
515                 else
516                 {
517                         SysLogException(NID_SYS, E_INVALID_ARG, "Requested value[%ls] is not supported.", value.GetPointer());
518                         return E_INVALID_ARG;
519                 }
520
521                 errorCode = vconf_set_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, current_value);
522                 SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to get notification repeat count.");
523         }
524
525
526         return r;
527 }
528
529 bool
530 _SettingSoundProvider::HasKey(const Tizen::Base::String& key)
531 {
532
533         if(key == _SOUND_MEDIA_VOLUME || key == _SOUND_NOTIFICATION_VOLUME
534                 || key == _SOUND_RINGTONE_VOLUME || key == _SOUND_SYSTEM_VOLUME)
535         {
536                 return true;
537         }
538         else if(key == _SOUND_RINGTONE)
539         {
540                 return true;
541         }
542         else if(key == _SOUND_SILENTMODE)
543         {
544                 return true;
545         }
546         else if(key == _SOUND_TOUCH || key == _SOUND_LOCK)
547         {
548                 return true;
549         }
550         else if(key == _SOUND_NOTIFICATION || key == _SOUND_NOTIFICATION_REPEAT_PERIOD)
551         {
552                 return true;
553         }
554
555         return false;
556 }
557
558 void
559 _SettingSoundProvider::SettingEventSoundManager(sound_type_e type, unsigned int volume, void* userData)
560 {
561         String settingKey;
562
563         switch (type)
564         {
565         case SOUND_TYPE_SYSTEM:
566                 settingKey.Append(_SOUND_SYSTEM_VOLUME);
567                 break;
568         case SOUND_TYPE_MEDIA:
569                 settingKey.Append(_SOUND_MEDIA_VOLUME);
570                 break;
571         case SOUND_TYPE_RINGTONE:
572                 settingKey.Append(_SOUND_RINGTONE_VOLUME);
573                 break;
574         case SOUND_TYPE_NOTIFICATION:
575                 settingKey.Append(_SOUND_NOTIFICATION_VOLUME);
576                 break;
577         default:
578                 SysLog(NID_SYS, "NOT IMPLEMENTED");
579                 return;
580         }
581
582         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
583         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
584
585         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
586         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
587 }
588
589 void
590 _SettingSoundProvider::SettingEventSettingInfo(system_settings_key_e key, void* userData)
591 {
592         String settingKey;
593
594         if(key == SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE)
595         {
596                 settingKey.Append(_SOUND_RINGTONE);
597         }
598         else
599         {
600                 return;
601         }
602         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
603         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
604
605         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
606         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
607 }
608
609 void
610 _SettingSoundProvider::SettingEventRuntimeInfo(runtime_info_key_e key, void* userData)
611 {
612         String settingKey;
613
614         if(key == RUNTIME_INFO_KEY_SILENT_MODE_ENABLED)
615         {
616                 settingKey.Append(_SOUND_SILENTMODE);
617         }
618         else
619         {
620                 return;
621         }
622         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
623         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
624
625         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
626         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
627 }
628 void
629 _SettingSoundProvider::SettingEventVConf(keynode_t* node, void* userData)
630 {
631         String settingKey;
632
633         if (strcmp(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, vconf_keynode_get_name(node)) == 0)
634         {
635                 settingKey.Append(_SOUND_TOUCH);
636         }
637         else if(strcmp(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, vconf_keynode_get_name(node)) == 0)
638         {
639                 settingKey.Append(_SOUND_LOCK);
640         }
641         else if(strcmp(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, vconf_keynode_get_name(node)) == 0)
642         {
643                 settingKey.Append(_SOUND_NOTIFICATION_REPEAT_PERIOD);
644         }
645         else if(strcmp(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_keynode_get_name(node)) == 0)
646         {
647                 settingKey.Append(_SOUND_NOTIFICATION);
648         }
649         else
650         {
651                 return;
652         }
653         _SettingInfo* pSettingInfo = _SettingInfo::GetInstance();
654         SysTryReturnVoidResult(NID_SYS, pSettingInfo != null, E_SYSTEM, "_SettingInfo is not ready.");
655
656         result r = pSettingInfo->AnnounceSettingEvent(settingKey);
657         SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send the event[%ls].", settingKey.GetPointer());
658 }
659
660 }}