2 * Copyright (c) 2014 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.
19 #include "MsgCallStatusManager.h"
21 #include "MsgCppTypes.h"
22 #include "MsgGconfWrapper.h"
23 #include "MsgSettingTypes.h"
24 #include "MsgDrmWrapper.h"
25 #include "MsgSensorWrapper.h"
26 #include "MsgUtilFile.h"
27 #include "MsgStorageTypes.h"
28 #include "MsgContact.h"
30 #include "MsgNotificationWrapper.h"
31 #include "MsgSoundPlayer.h"
33 #ifndef MSG_WEARABLE_PROFILE
36 #include <sound_manager.h>
38 #include <feedback-internal.h>
40 /*==================================================================================================
42 ==================================================================================================*/
43 #define MAX_SOUND_FILE_LEN 1024
45 #define DEFAULT_ALERT_FILE "/opt/usr/share/settings/Alerts/Whistle.ogg"
47 #define HAPTIC_TEST_ITERATION 1
48 #define MSG_VIBRATION_INTERVAL 3000
49 #define MSG_SOUND_TIMEOUT 5500
52 /*==================================================================================================
54 ==================================================================================================*/
55 player_h g_PlayerHandle = NULL;
56 sound_stream_info_h g_stream_info = NULL;
58 pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER;
59 pthread_mutex_t muStream = PTHREAD_MUTEX_INITIALIZER;
61 #endif /* MSG_WEARABLE_PROFILE */
63 /*==================================================================================================
64 IMPLEMENTATION OF Functions
65 ==================================================================================================*/
66 void MsgSoundRepeatAlarmCB(int alarmId)
70 #ifndef MSG_WEARABLE_PROFILE
72 MsgSoundPlayer::instance()->MsgSoundInitRepeatAlarm();
74 #endif /* MSG_WEARABLE_PROFILE */
81 void MsgSensorCBStop()
85 #ifndef MSG_WEARABLE_PROFILE
88 MsgSoundPlayer::instance()->MsgSoundPlayStop();
90 MsgDeleteNotification(MSG_NOTI_TYPE_ALL, -1);
92 MsgRefreshNotification(MSG_NOTI_TYPE_ALL, false, MSG_ACTIVE_NOTI_TYPE_NONE);
94 #ifndef MSG_NOTI_INTEGRATION
95 MsgRefreshNotification(MSG_NOTI_TYPE_SIM, false, MSG_ACTIVE_NOTI_TYPE_NONE);
100 #endif /* MSG_WEARABLE_PROFILE */
106 static gboolean MsgSoundMelodyTimeout(gpointer data)
110 MsgSoundPlayer::instance()->MsgSoundPlayStop();
118 #ifndef MSG_WEARABLE_PROFILE
119 static void MsgSoundPlayeErrorCallback(int error_code, void *user_data)
121 MSG_DEBUG("MsgSoundPlayeErrorCallback called [%d]", error_code);
122 MsgSoundPlayer::instance()->MsgStreamStop();
123 MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT);
126 static void MsgSoundPlayeCompletedCallback(void *user_data)
128 MSG_DEBUG("MsgSoundPlayeCompletedCallback called");
129 MsgSoundPlayer::instance()->MsgSoundPlayStop();
132 static void MsgSoundPlayeInterruptedCallback(player_interrupted_code_e code, void *user_data)
134 MSG_DEBUG("MsgSoundPlayeInterruptedCallback called [%d]", code);
135 MsgSoundPlayer::instance()->MsgSoundPlayStop();
138 static void MsgStreamFocusCallback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
140 MSG_DEBUG("MsgStreamFocusCallback called, reason_for_change [%d], additional_info [%s]", reason_for_change, additional_info);
142 sound_stream_focus_state_e playback_focus_state = SOUND_STREAM_FOCUS_STATE_ACQUIRED;
144 sound_manager_get_focus_state(stream_info, &playback_focus_state, NULL);
145 if (playback_focus_state == SOUND_STREAM_FOCUS_STATE_RELEASED) {
146 MSG_DEBUG("sound stream focus released");
147 MsgSoundPlayer::instance()->MsgSoundPlayStop();
152 /*==================================================================================================
153 IMPLEMENTATION OF MsgSoundPlayer - Member Functions
154 ==================================================================================================*/
155 MsgSoundPlayer* MsgSoundPlayer::pInstance = NULL;
158 MsgSoundPlayer::MsgSoundPlayer()
160 #ifndef MSG_WEARABLE_PROFILE
163 bFeedbackInit = false;
166 defaultRingtonePath = NULL;
168 defaultRingtonePath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
170 if (defaultRingtonePath == NULL || MsgGetFileSize(defaultRingtonePath) < 1) {
171 defaultRingtonePath = (char *)DEFAULT_ALERT_FILE;
174 MSG_DEBUG("defaultRingtonePath [%s]", defaultRingtonePath);
176 if (MsgSensorConnect() == MSG_SUCCESS) {
177 if (MsgRegSensorCB(&MsgSensorCBStop) != MSG_SUCCESS) {
178 MSG_DEBUG("Fail to MsgRegSensorCB.");
179 MsgSensorDisconnect();
182 MSG_DEBUG("Fail to MsgSensorConnect.");
184 #endif /* MSG_WEARABLE_PROFILE */
188 MsgSoundPlayer::~MsgSoundPlayer()
193 MsgSoundPlayer* MsgSoundPlayer::instance()
196 MSG_DEBUG("pInstance is NULL. Now creating instance.");
197 pInstance = new MsgSoundPlayer();
204 void MsgSoundPlayer::MsgGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p)
206 #ifndef MSG_WEARABLE_PROFILE
207 MSG_RINGTONE_TYPE_T ringtoneType = (MSG_RINGTONE_TYPE_T)MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE);
209 MSG_DEBUG("Ringtone type = [%d]", ringtoneType);
211 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) {
212 *msg_tone_file_path_p = NULL;
216 char *tmpFilePath = NULL;
217 *msg_tone_file_path_p = new char[MSG_FILEPATH_LEN_MAX+1];
219 char *msg_tone_file_path = *msg_tone_file_path_p;
221 bool bUserRingtone = userRingtonePath && userRingtonePath[0] != '\0';
223 tmpFilePath = userRingtonePath;
225 if (ringtoneType == MSG_RINGTONE_TYPE_DEFAULT) {
226 tmpFilePath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
228 tmpFilePath = MsgSettingGetString(MSG_SETTING_RINGTONE_PATH);
232 memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1));
234 if ((tmpFilePath == NULL || MsgGetFileSize(tmpFilePath) < 1) || /* wrong ringtone file path */
235 (MsgDrmIsDrmFile(tmpFilePath) && !MsgDrmCheckRingtone(tmpFilePath))) { /* check DRM */
236 if (tmpFilePath && (strcmp(tmpFilePath, "silent") == 0)) {
237 MSG_DEBUG("Set ringtone to NONE(Silent)");
238 msg_tone_file_path = NULL;
240 MSG_DEBUG("Set ringtone to defaultRingtonePath.");
241 strncpy(msg_tone_file_path, defaultRingtonePath, MSG_FILEPATH_LEN_MAX);
244 MSG_DEBUG("Set ringtone to tmpFilePath.");
245 snprintf(msg_tone_file_path, MSG_FILEPATH_LEN_MAX, "%s", tmpFilePath);
248 if (tmpFilePath && !bUserRingtone) {
252 #endif /* MSG_WEARABLE_PROFILE */
255 #ifndef MSG_WEARABLE_PROFILE
256 void MsgSoundPlayer::MsgGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration)
260 /* samsung basic concept : feedback should follow profile setting.
261 * And if notification setting exist in msg app, then apply it prior to profile when profile either sound or vibration.
262 * But, Play sound when profile is vibration during call, if device does not support haptic */
263 if (bSound || bVibration) {
264 bool bHantic_device = false;
265 #ifdef FEATURE_HAPTIC_ENABLE
266 bHantic_device = true;
268 if (bHantic_device || (bOnCall == false)) {
271 MSG_DEBUG("Play sound.");
276 MSG_DEBUG("Play vibration.");
277 *bPlayVibration = true;
281 MSG_DEBUG("Play vibration.");
282 *bPlayVibration = true;
285 } else { /* during call */
286 if (bMsgSound || bMsgVibration) {
287 MSG_DEBUG("Play sound.");
293 #endif /* MSG_WEARABLE_PROFILE */
295 void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall)
299 #ifndef MSG_WEARABLE_PROFILE
301 if (!bPlaySound || !bPlayVibration || !bOnCall) {
302 MSG_DEBUG("IN parameter is NULL.");
307 *bPlayVibration = false;
311 bool bSoundOn = false; /* sound setting on notification panel */
312 bool bVibrationOn = false; /* vibration setting on notification panel */
314 MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn);
315 MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn);
318 #if 0 /* not used value */
319 bool bNotiVibrationOn = false; /* alert vibration */
320 MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, &bNotiVibrationOn);
323 bool bMsgSettingNoti = true; /* Alert for message notification */
324 bool bMsgSettingVibration = false; /* vibration for message notification */
326 MSG_RINGTONE_TYPE_T ringtoneType = MSG_RINGTONE_TYPE_DEFAULT; /*sound type for message notification */
327 bool bMsgSettingSound = true;
329 MsgSettingGetBool(MSG_SETTING_VIBRATION, &bMsgSettingVibration);
330 MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bMsgSettingNoti);
331 ringtoneType = (MSG_RINGTONE_TYPE_T)MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE);
332 if (ringtoneType == MSG_RINGTONE_TYPE_SILENT)
333 bMsgSettingSound = false;
335 MSG_SEC_DEBUG("Sound status : Sound mode[%d], Manner mode[%d]", bSoundOn, bVibrationOn);
336 MSG_SEC_DEBUG("Msg Setting : Noti Alert[%d], vibration[%d], sound[%d], ringtoneType[%d]", bMsgSettingNoti, bMsgSettingVibration, bMsgSettingSound, ringtoneType);
339 /* int alertOnCall = 0; */
341 callStatus = MsgGetCallStatus();
342 MSG_DEBUG("Call Status [%d]", callStatus);
344 /* Check call status */
345 if (callStatus > 0 && callStatus < 3) {
347 *bOnCall = true; /* set call status; */
349 /* 2. Call is not active */
351 MSG_DEBUG("Call is not active.");
352 int voiceRecording = MsgSettingGetInt(VCONFKEY_RECORDER_STATE);
354 if (bVoiceMail) { /* 2-1. Voice message */
355 if (bMsgSettingNoti) {
356 MsgGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration);
359 MSG_DEBUG("It doesn't play sound/vibration - voice message.");
361 } else { /* 2-1. Normal message */
362 if (bMsgSettingNoti) {
363 if (voiceRecording != VCONFKEY_RECORDER_STATE_RECORDING) {
364 MsgGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration);
366 MSG_DEBUG("It doesn't play sound/vibration.");
369 MSG_DEBUG("It doesn't play sound/vibration.");
374 #endif /* MSG_WEARABLE_PROFILE */
380 void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_SOUND_TYPE_T soundType)
383 #ifndef MSG_WEARABLE_PROFILE
385 MSG_DEBUG("soundType [%d]", soundType);
387 /* check camera state */
388 int cameraState = 0; /* camera recording state */
389 cameraState = MsgSettingGetInt(VCONFKEY_CAMERA_STATE);
390 MSG_SEC_DEBUG("Camera state [%d]", cameraState);
392 if (cameraState == VCONFKEY_CAMERA_STATE_RECORDING) {
397 /* contacts-service is not used for gear */
398 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
399 /* get contact information */
400 MSG_CONTACT_INFO_S contactInfo;
401 memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
404 /* Get Contact Info */
405 if (MsgGetContactInfo(pAddrInfo, &contactInfo) != MSG_SUCCESS) {
406 MSG_DEBUG("MsgGetContactInfo() fail.");
409 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
410 /* get ringtone file path */
411 char *msg_tone_file_path = NULL;
412 unique_ptr<char*, void(*)(char**)> buf(&msg_tone_file_path, unique_ptr_deleter);
414 if (soundType == MSG_SOUND_PLAY_EMERGENCY) {
415 msg_tone_file_path = new char[MAX_SOUND_FILE_LEN+1];
416 memset(msg_tone_file_path, 0x00, sizeof(char)*(MAX_SOUND_FILE_LEN+1));
417 } else if (soundType == MSG_SOUND_PLAY_DEFAULT) {
418 msg_tone_file_path = new char[MAX_SOUND_FILE_LEN+1];
419 memset(msg_tone_file_path, 0x00, sizeof(char)*(MAX_SOUND_FILE_LEN+1));
420 strncpy(msg_tone_file_path, DEFAULT_ALERT_FILE, MAX_SOUND_FILE_LEN);
422 /* contacts-service is not used for gear */
423 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
425 MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path);
427 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
428 MSG_SEC_DEBUG("soundType [%d], Sound File [%s]", soundType, msg_tone_file_path);
430 /* get sound play status */
431 bool bPlaySound = false;
432 bool bPlayVibration = false;
433 bool bVoiceMsg = (soundType == MSG_SOUND_PLAY_VOICEMAIL)?true:false;
434 bool bOnCall = false;
436 MsgGetPlayStatus(bVoiceMsg, &bPlaySound, &bPlayVibration, &bOnCall);
438 MSG_SEC_DEBUG("sound=[%d], vibration=[%d], voice_msg?[%d], on_call?[%d]",
439 bPlaySound, bPlayVibration, bVoiceMsg, bOnCall);
443 int err = MsgStreamStart(soundType);
445 if (err != SOUND_MANAGER_ERROR_NONE)
446 MSG_DEBUG("MsgStreamStart() Failed : %d", err);
448 MsgSoundPlayMelody(msg_tone_file_path);
451 /* contacts-service is not used for gear */
452 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
454 if (bPlayVibration) {
455 MsgSoundPlayVibration(contactInfo.vibrationPath);
457 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
459 /* For repeatition. */
460 /* MsgSoundSetRepeatAlarm(); */
462 #endif /* MSG_WEARABLE_PROFILE */
467 void MsgSoundPlayer::MsgSoundPlayStop()
470 #ifndef MSG_WEARABLE_PROFILE
473 pthread_mutex_lock(&muMmPlay);
475 if (bPlaying == true && g_PlayerHandle != NULL) {
476 MSG_DEBUG("stopping the player.");
477 /* Stop playing media contents */
478 err = player_stop(g_PlayerHandle);
480 if (err != PLAYER_ERROR_NONE)
481 MSG_DEBUG("stopping the player handle failed");
484 if (g_PlayerHandle != NULL) {
485 MSG_DEBUG("destroy the player.");
487 player_unset_error_cb(g_PlayerHandle);
488 player_unset_completed_cb(g_PlayerHandle);
489 player_unset_interrupted_cb(g_PlayerHandle);
490 player_unprepare(g_PlayerHandle);
491 player_destroy(g_PlayerHandle);
494 g_PlayerHandle = NULL;
497 pthread_mutex_unlock(&muMmPlay);
501 #endif /* MSG_WEARABLE_PROFILE */
506 int MsgSoundPlayer::MsgStreamStart(MSG_SOUND_TYPE_T soundType)
511 #ifndef MSG_WEARABLE_PROFILE
512 pthread_mutex_lock(&muStream);
514 if (g_stream_info != NULL) {
515 err = sound_manager_destroy_stream_information(g_stream_info);
516 if (err != SOUND_MANAGER_ERROR_NONE)
517 MSG_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err);
519 g_stream_info = NULL;
522 if (soundType == MSG_SOUND_PLAY_EMERGENCY)
523 err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_EMERGENCY, MsgStreamFocusCallback, NULL, &g_stream_info);
525 err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_NOTIFICATION, MsgStreamFocusCallback, NULL, &g_stream_info);
527 if (err != SOUND_MANAGER_ERROR_NONE) {
528 MSG_DEBUG("sound_manager_create_stream_information() Failed : %d", err);
529 pthread_mutex_unlock(&muStream);
533 err = sound_manager_acquire_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
534 pthread_mutex_unlock(&muStream);
536 #endif /* MSG_WEARABLE_PROFILE */
542 void MsgSoundPlayer::MsgStreamStop()
545 #ifndef MSG_WEARABLE_PROFILE
546 pthread_mutex_lock(&muStream);
548 if (g_stream_info != NULL) {
549 int err = sound_manager_release_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
550 if (err != SOUND_MANAGER_ERROR_NONE)
551 MSG_DEBUG("sound_manager_release_focus() Failed : %d", err);
553 err = sound_manager_destroy_stream_information(g_stream_info);
554 if (err != SOUND_MANAGER_ERROR_NONE)
555 MSG_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err);
557 g_stream_info = NULL;
559 pthread_mutex_unlock(&muStream);
561 #endif /* MSG_WEARABLE_PROFILE */
566 void MsgSoundPlayer::MsgSoundPlayMelody(char *pMsgToneFilePath)
568 #ifndef MSG_WEARABLE_PROFILE
569 int err = PLAYER_ERROR_NONE;
571 if (!pMsgToneFilePath) {
572 MSG_DEBUG("Ringtone path is NULL");
576 pthread_mutex_lock(&muMmPlay);
578 if (g_stream_info == NULL) {
579 MSG_DEBUG("g_stream_info is NULL");
583 if (g_PlayerHandle) {
584 player_unset_error_cb(g_PlayerHandle);
585 player_unset_completed_cb(g_PlayerHandle);
586 player_unset_interrupted_cb(g_PlayerHandle);
587 player_unprepare(g_PlayerHandle);
588 player_destroy(g_PlayerHandle);
591 err = player_create(&g_PlayerHandle);
593 pthread_mutex_unlock(&muMmPlay);
595 if (err != PLAYER_ERROR_NONE) {
596 MSG_DEBUG("creating the player handle failed");
600 /* Setting the call back function msg_callback */
601 player_set_error_cb(g_PlayerHandle, MsgSoundPlayeErrorCallback, NULL);
602 player_set_completed_cb(g_PlayerHandle, MsgSoundPlayeCompletedCallback, NULL);
603 player_set_interrupted_cb(g_PlayerHandle, MsgSoundPlayeInterruptedCallback, NULL);
605 player_set_audio_policy_info(g_PlayerHandle, g_stream_info);
608 err = player_set_uri(g_PlayerHandle, (const char *)pMsgToneFilePath);
609 if (err != PLAYER_ERROR_NONE)
610 MSG_DEBUG("player_set_uri() error : [%d]", err);
612 err = player_prepare(g_PlayerHandle);
613 if (err != PLAYER_ERROR_NONE) {
614 MSG_DEBUG("player_prepare() error : [%d]", err);
615 if (pMsgToneFilePath != defaultRingtonePath) {
616 pMsgToneFilePath = defaultRingtonePath;
621 } while (err != PLAYER_ERROR_NONE);
624 pthread_mutex_lock(&muMmPlay);
625 MSG_DEBUG("player_start with [%s]", pMsgToneFilePath);
626 err = player_start(g_PlayerHandle);
628 if (err != PLAYER_ERROR_NONE) {
629 MSG_DEBUG("player_start, FAIL [%x]", err);
631 /* Add Timer to stop playing after 5 sec. */
633 int g_contact_timer = -1;
634 g_contact_timer = g_timeout_add(MSG_SOUND_TIMEOUT, (GSourceFunc)MsgSoundMelodyTimeout, NULL);
639 pthread_mutex_unlock(&muMmPlay);
645 void MsgSoundPlayer::MsgSoundPlayVibration(char *vibrationPath)
649 #ifndef MSG_WEARABLE_PROFILE
653 if (!bFeedbackInit) {
654 int ret = feedback_initialize();
656 if (ret != FEEDBACK_ERROR_NONE) {
657 MSG_DEBUG("Fail to feedback_initialize : [%d]", ret);
658 bFeedbackInit = false;
661 MSG_DEBUG("Success to feedback_initialize.");
662 bFeedbackInit = true;
666 if (vibrationPath && strlen(vibrationPath)) {
667 MSG_DEBUG("vibrationPath: [%s]", vibrationPath);
668 ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, vibrationPath);
669 if (ret != FEEDBACK_ERROR_NONE)
670 MSG_DEBUG("Fail to feedback_set_resource_path");
671 ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE);
673 if (ret != FEEDBACK_ERROR_NONE)
674 MSG_DEBUG("Fail to feedback_play_type");
676 ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, NULL);
677 if (ret != FEEDBACK_ERROR_NONE)
678 MSG_DEBUG("Fail to feedback_set_resource_path");
680 ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE);
681 if (ret != FEEDBACK_ERROR_NONE)
682 MSG_DEBUG("Fail to feedback_play_type");
685 #endif /* MSG_WEARABLE_PROFILE */
691 void MsgSoundPlayer::MsgSoundSetRepeatAlarm()
693 #ifndef MSG_WEARABLE_PROFILE
695 int nRepeatValue = 0;
696 long nRepeatTime = 0;
698 nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE);
700 switch (nRepeatValue) {
701 case MSG_ALERT_TONE_ONCE:
705 case MSG_ALERT_TONE_2MINS:
709 case MSG_ALERT_TONE_5MINS:
713 case MSG_ALERT_TONE_10MINS:
718 MSG_DEBUG("Invalid Repetition time");
722 MSG_DEBUG("nRepeatTime = %d", nRepeatTime);
724 if (nRepeatTime > 0) {
726 if (MsgAlarmRemove(g_alarmId) != MSG_SUCCESS)
727 MSG_FATAL("MsgAlarmRemove fail.");
731 MsgSoundCreateRepeatAlarm(nRepeatTime);
734 #endif /* MSG_WEARABLE_PROFILE */
738 void MsgSoundPlayer::MsgSoundCreateRepeatAlarm(int RepeatTime)
742 #ifndef MSG_WEARABLE_PROFILE
750 tmp_time += (RepeatTime*60);
752 localtime_r(&tmp_time, &repeat_tm);
754 if (MsgAlarmRegistration(&repeat_tm, MsgSoundRepeatAlarmCB, &alarmId) != MSG_SUCCESS) {
755 MSG_DEBUG("MsgAlarmRegistration fail.");
760 MSG_DEBUG("Set g_alarmId to [%d]", alarmId);
764 #endif /* MSG_WEARABLE_PROFILE */
768 int MsgSoundPlayer::MsgSoundGetUnreadMsgCnt()
772 #ifndef MSG_WEARABLE_PROFILE
775 unreadCnt = MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE);
778 unreadCnt += MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE);
780 MSG_DEBUG("unread count : [%d]", unreadCnt);
782 #endif /* MSG_WEARABLE_PROFILE */
787 void MsgSoundPlayer::MsgSoundInitRepeatAlarm()
791 #ifndef MSG_WEARABLE_PROFILE
793 int nRepeatValue = 0;
794 long nRepeatTime = 0;
798 if (MsgSoundGetUnreadMsgCnt() <= 0) {
799 MSG_DEBUG("no unread msg");
803 nRepeatValue = MsgSettingGetInt(MSG_ALERT_REP_TYPE);
805 switch (nRepeatValue) {
806 case MSG_ALERT_TONE_ONCE:
810 case MSG_ALERT_TONE_2MINS:
814 case MSG_ALERT_TONE_5MINS:
818 case MSG_ALERT_TONE_10MINS:
823 MSG_DEBUG("Invalid Repetition time");
827 MSG_DEBUG("nRepeatTime = %d", nRepeatTime);
830 MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_USER);
832 #endif /* MSG_WEARABLE_PROFILE */