Fix Sound alert and repetition.
authorKeeBum Kim <keebum.kim@samsung.com>
Fri, 24 Aug 2012 11:23:14 +0000 (20:23 +0900)
committerKeeBum Kim <keebum.kim@samsung.com>
Fri, 24 Aug 2012 11:23:14 +0000 (20:23 +0900)
framework/main.cpp
include/utils/MsgSoundPlayer.h
msg_helper/MsgSoundPlayer.cpp
utils/MsgSoundPlayer.cpp

index 943a7e6..0fd8b76 100755 (executable)
@@ -356,7 +356,8 @@ void* InitMsgServer(void*)
        // Register Callback to get the change of contact
        MsgInitContactSvc(&MsgContactChangedCallback);
 
-       MsgSoundPlayStart();
+       MsgSoundInitRepeatAlarm();
+
        return (void*)0;
 }
 
index 37eea6d..ce690e8 100755 (executable)
@@ -37,5 +37,6 @@ bool MsgSoundSetRepeatAlarm();
 bool MsgSoundCreateRepeatAlarm(int RepeatTime);
 int MsgSoundRepeatAlarmCB(int TimerId, void *pUserParam);
 int MsgSoundGetUnreadMsgCnt();
+void MsgSoundInitRepeatAlarm();
 
 #endif // MSG_SOUND_PLAYER_H
index d0a3ce6..10da84f 100755 (executable)
@@ -47,6 +47,25 @@ pthread_cond_t cvMmPlay = PTHREAD_COND_INITIALIZER;
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
+
+static gboolean MsgStopAndExit(void* data)
+{
+       MsgSoundPlayStop();
+       if(!bPlaying && !bVibrating)
+               worker_done();
+
+       return FALSE;
+}
+
+static gboolean MsgUninitAndExit(void* data)
+{
+       MsgSoundPlayUninit();
+       if(!bPlaying && !bVibrating)
+               worker_done();
+
+       return FALSE;
+}
+
 static gboolean MsgSoundMelodyTimeout(gpointer data)
 {
        MSG_BEGIN();
@@ -98,7 +117,7 @@ static int MsgSoundPlayCallback(int message, void *param, void *user_param)
        {
                case MM_MESSAGE_ERROR:
                        MSG_DEBUG("ERROR is happened.");
-                       MsgSoundPlayUninit();
+                       g_idle_add (MsgUninitAndExit, NULL);
                        break;
                case MM_MESSAGE_BEGIN_OF_STREAM:
                        MSG_DEBUG("Play is started.");
@@ -106,9 +125,7 @@ static int MsgSoundPlayCallback(int message, void *param, void *user_param)
                case MM_MESSAGE_END_OF_STREAM:
                case MM_MESSAGE_STATE_INTERRUPTED:
                        MSG_DEBUG("EOS or Interrupted.");
-                       MsgSoundPlayStop();
-                       if(!bPlaying && !bVibrating)
-                               worker_done();
+                       g_idle_add (MsgStopAndExit, NULL);
                        break;
                default:
                        MSG_DEBUG("message = %d", message);
index 2225961..15fd2f0 100755 (executable)
@@ -52,12 +52,8 @@ void MsgSoundPlayStart()
        if (childpid == 0)
        {
                MSG_DEBUG("Child Process - Run helper app for Sound");
-               int nRepeatValue = 0;
 
-               nRepeatValue = MsgSettingGetInt(MSG_ALERT_TONE);
-
-               if(nRepeatValue != MSG_ALERT_TONE_ONCE)
-                       execl("/usr/bin/msg-helper", MSG_SOUND_START, NULL);
+               execl("/usr/bin/msg-helper", MSG_SOUND_START, NULL);
 
                MSG_DEBUG("Faild to run helper app for Sound");
 
@@ -259,3 +255,49 @@ int MsgSoundGetUnreadMsgCnt()
        return unreadCnt;
 }
 
+void MsgSoundInitRepeatAlarm()
+{
+       MSG_BEGIN();
+
+       int nRepeatValue = 0;
+       long    nRepeatTime = 0;
+
+       g_bRepeat = false;
+
+       if (MsgSoundGetUnreadMsgCnt() <= 0) {
+               MSG_DEBUG("no unread msg");
+               return;
+       }
+
+       nRepeatValue = MsgSettingGetInt(MSG_ALERT_TONE);
+
+       switch (nRepeatValue)
+       {
+               case MSG_ALERT_TONE_ONCE:
+                       nRepeatTime = 0;
+               break;
+
+               case MSG_ALERT_TONE_2MINS:
+                       nRepeatTime = 2;
+               break;
+
+               case MSG_ALERT_TONE_5MINS:
+                       nRepeatTime = 5;
+               break;
+
+               case MSG_ALERT_TONE_10MINS:
+                       nRepeatTime = 10;
+               break;
+
+               default:
+                       MSG_DEBUG("Invalid Repetition time");
+               break;
+       }
+
+       MSG_DEBUG("nRepeatTime = %d", nRepeatTime);
+
+       if (nRepeatTime > 0)
+               MsgSoundPlayStart();
+
+       MSG_END();
+}