3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
33 #include "MsgHelper.h"
35 #include "MsgGconfWrapper.h"
36 #include "MsgSettingTypes.h"
37 #include "MsgSoundPlayer.h"
42 /*==================================================================================================
44 ==================================================================================================*/
45 static bool g_bRepeat = false;
46 static alarm_id_t g_alarmId = 0;
49 /*==================================================================================================
50 FUNCTION IMPLEMENTATION
51 ==================================================================================================*/
54 void MsgSoundPlayStart()
64 MSG_DEBUG("Failed to fork");
69 MSG_DEBUG("Child Process - Run helper app for Sound");
71 execl("/usr/bin/msg-helper", MSG_SOUND_START, NULL);
73 MSG_DEBUG("Faild to run helper app for Sound");
77 else if (childpid != 0)
79 MSG_DEBUG("Parent Process - Mms Plugin Storage.");
82 if (g_bRepeat == false)
83 g_bRepeat = MsgSoundSetRepeatAlarm();
88 void MsgSoundPlayStop()
98 MSG_DEBUG("Failed to fork");
103 MSG_DEBUG("Child Process - Run helper app for Sound");
105 execl("/usr/bin/msg-helper", MSG_SOUND_STOP, NULL);
107 MSG_DEBUG("Faild to run helper app for Sound");
111 else if (childpid != 0)
113 MSG_DEBUG("Parent Process - Mms Plugin Storage.");
120 bool MsgSoundSetRepeatAlarm()
124 int nRepeatValue = 0;
125 long nRepeatTime = 0;
127 nRepeatValue = MsgSettingGetInt(MSG_ALERT_TONE);
129 switch (nRepeatValue)
131 case MSG_ALERT_TONE_ONCE:
135 case MSG_ALERT_TONE_2MINS:
139 case MSG_ALERT_TONE_5MINS:
143 case MSG_ALERT_TONE_10MINS:
148 MSG_DEBUG("Invalid Repetition time");
152 MSG_DEBUG("nRepeatTime = %d", nRepeatTime);
156 bRet = MsgSoundCreateRepeatAlarm(nRepeatTime);
163 bool MsgSoundCreateRepeatAlarm(int RepeatTime)
168 struct tm current_tm;
172 localtime_r(¤t_time, ¤t_tm);
176 retval = alarmmgr_init("msg-service-tools");
180 MSG_FATAL("alarmmgr_init() error [%d]", retval);
184 alarm_info_t* alarm_info;
185 alarm_date_t target_time;
187 alarm_info = alarmmgr_create_alarm();
189 target_time.year = 0;
190 target_time.month = 0;
193 if (current_tm.tm_min+RepeatTime < 60)
195 target_time.hour = current_tm.tm_hour;
196 target_time.min = current_tm.tm_min+RepeatTime;
200 if (current_tm.tm_hour < 12)
202 target_time.hour = current_tm.tm_hour+1;
206 target_time.hour = (current_tm.tm_hour+1)%12;
209 target_time.min = (current_tm.tm_min+RepeatTime)%60;
212 target_time.sec = current_tm.tm_sec;
214 alarmmgr_set_time(alarm_info, target_time);
215 alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
216 alarmmgr_set_type(alarm_info, ALARM_TYPE_VOLATILE);
217 alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &g_alarmId);
219 retval = alarmmgr_set_cb(MsgSoundRepeatAlarmCB, NULL);
223 MSG_DEBUG("alarmmgr_set_cb() error [%d]", retval);
227 MSG_DEBUG("Repeat Alarm Time : [%d-%d-%d %d:%d:%d]",
228 target_time.year,target_time.month,target_time.day,
229 target_time.hour, target_time.min, target_time.sec);
237 int MsgSoundRepeatAlarmCB(int TimerId, void *pUserParam)
243 if (MsgSoundGetUnreadMsgCnt() <= 0)
245 MSG_DEBUG("no unread msg");
258 int MsgSoundGetUnreadMsgCnt()
263 unreadCnt = MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE);
266 unreadCnt += MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE);
268 MSG_DEBUG("unread count : [%d]", unreadCnt);