2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
18 #include "MsgContact.h"
19 #include "MsgStorageTypes.h"
20 #include "MsgUtilStorage.h"
21 #include "MsgGconfWrapper.h"
22 #include "MsgNotificationWrapper.h"
26 #include <notification.h>
30 /*==================================================================================================
31 FUNCTION IMPLEMENTATION
32 ==================================================================================================*/
33 void MsgSmsClass0Noti(MSG_MESSAGE_INFO_S* pMsg, notification_h noti, bundle* args)
36 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
39 memset(tempId, 0x00, sizeof(tempId));
41 appsvc_set_appid(args, "org.tizen.msg-ui-class0");
43 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
44 if (noti_err != NOTIFICATION_ERROR_NONE) {
45 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
48 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
49 if (noti_err != NOTIFICATION_ERROR_NONE) {
50 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
53 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
55 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
57 if (pMsg->addressList[0].displayName[0] == '\0')
58 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
60 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
62 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
65 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
68 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
70 bundle_add(args, "type", "new_msg");
72 snprintf(tempId, 5, "%d", pMsg->msgId);
73 bundle_add(args, "msgId", tempId);
79 void MsgSmsMWINoti(MSG_MESSAGE_INFO_S* pMsg, notification_h noti, bundle* args)
83 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
85 appsvc_set_appid(args, "org.tizen.call");
87 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
88 if (noti_err != NOTIFICATION_ERROR_NONE) {
89 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
92 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
94 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New MWI Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
96 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
97 if (noti_err != NOTIFICATION_ERROR_NONE) {
98 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
101 if (pMsg->addressList[0].displayName[0] == '\0')
102 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
104 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
106 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
109 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
112 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
114 bundle_add(args, "launch-type", "MO");
115 bundle_add(args, "number", pMsg->addressList[0].addressVal);
121 void MsgSmsVoiceNoti(MSG_MESSAGE_INFO_S* pMsg)
126 notification_h noti = NULL;
127 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
130 args = bundle_create();
132 notiId = MsgSettingGetInt(VOICE_NOTI_ID_1);
135 noti = notification_load(NULL, notiId);
137 MSG_DEBUG("notification_load is failed.");
141 noti = notification_create(NOTIFICATION_TYPE_NOTI);
143 MSG_DEBUG("notification_new is failed.");
144 if (args != NULL) bundle_free(args);
151 appsvc_set_appid(args, "org.tizen.call");
153 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
154 if (noti_err != NOTIFICATION_ERROR_NONE) {
155 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
158 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
160 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Voicemail", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
162 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
163 if (noti_err != NOTIFICATION_ERROR_NONE) {
164 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
167 if (pMsg->addressList[0].displayName[0] == '\0')
168 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
170 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
172 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
175 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
178 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
180 bundle_add(args, "launch-type", "MO");
181 bundle_add(args, "number", pMsg->addressList[0].addressVal);
184 noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
185 if (noti_err != NOTIFICATION_ERROR_NONE) {
186 MSG_DEBUG("Fail to notification_set_execute_option : %d", noti_err);
191 noti_err = notification_update(noti);
192 if (noti_err != NOTIFICATION_ERROR_NONE) {
193 MSG_DEBUG("Fail to notification_update");
196 noti_err = notification_insert(noti, ¬iId);
197 if (noti_err != NOTIFICATION_ERROR_NONE) {
198 MSG_DEBUG("Fail to notification_insert");
201 if (MsgSettingSetInt(VOICE_NOTI_ID_1, notiId) == MSG_SUCCESS)
202 MSG_DEBUG("Insert VOICE_NOTI_ID_1 [%d]", notiId);
204 MSG_DEBUG("MsgSettingSetInt fail: VOICE_NOTI_ID_1");
207 noti_err = notification_free(noti);
208 if (noti_err != NOTIFICATION_ERROR_NONE) {
209 MSG_DEBUG("Fail to notification_free");
222 void MsgSmsReportNoti(MSG_MESSAGE_INFO_S* pMsg, notification_h noti, bundle* args)
226 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
228 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
229 if (noti_err != NOTIFICATION_ERROR_NONE) {
230 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
233 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
234 if(pMsg->networkStatus == MSG_NETWORK_DELIVER_SUCCESS)
235 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message Delivered", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
237 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivery failed", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
239 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
240 if (noti_err != NOTIFICATION_ERROR_NONE) {
241 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
245 MSG_CONTACT_INFO_S contactInfo;
246 memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
247 MsgGetContactInfo(&(pMsg->addressList[0]), &contactInfo);
249 int order = MsgGetContactNameOrder();
252 if (contactInfo.firstName[0] != '\0') {
253 strncpy(pMsg->addressList[0].displayName, contactInfo.firstName, MAX_DISPLAY_NAME_LEN);
256 if (contactInfo.lastName[0] != '\0') {
257 strncat(pMsg->addressList[0].displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
258 strncat(pMsg->addressList[0].displayName, contactInfo.lastName, MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
260 } else if (order == 1) {
261 if (contactInfo.lastName[0] != '\0') {
262 strncpy(pMsg->addressList[0].displayName, contactInfo.lastName, MAX_DISPLAY_NAME_LEN);
263 strncat(pMsg->addressList[0].displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
266 if (contactInfo.firstName[0] != '\0') {
267 strncat(pMsg->addressList[0].displayName, contactInfo.firstName, MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
271 if (pMsg->addressList[0].displayName[0] == '\0')
272 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
274 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
276 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message delivered.", pMsg->msgText, NOTIFICATION_VARIABLE_TYPE_NONE);
279 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
282 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
285 noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
286 if (noti_err != NOTIFICATION_ERROR_NONE)
287 MSG_DEBUG("Fail to notification_set_display_applist");
293 msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
295 MSG_DEBUG("Start to Insert Notification.");
296 notification_h noti = NULL;
297 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
300 noti = notification_create(NOTIFICATION_TYPE_NOTI);
302 MSG_DEBUG("notification_create is failed.");
303 return MSG_ERR_UNKNOWN;
306 switch(pMsg->msgType.subType)
309 noti_err = notification_free(noti);
310 if (noti_err != NOTIFICATION_ERROR_NONE) {
311 MSG_DEBUG("Fail to notification_free");
313 MsgRefreshCBNoti(true);
316 case MSG_MWI_FAX_SMS :
317 case MSG_MWI_EMAIL_SMS :
318 case MSG_MWI_OTHER_SMS :
319 args = bundle_create();
320 MsgSmsMWINoti(pMsg, noti, args);
322 case MSG_MWI_VOICE_SMS :
323 noti_err = notification_free(noti);
324 if (noti_err != NOTIFICATION_ERROR_NONE) {
325 MSG_DEBUG("Fail to notification_free");
327 MsgSmsVoiceNoti(pMsg);
330 case MSG_STATUS_REPORT_SMS :
331 //args = bundle_create();
332 MsgSmsReportNoti(pMsg, noti, NULL);
334 case MSG_NORMAL_SMS :
335 if (pMsg->msgType.classType == MSG_CLASS_0) {
336 args = bundle_create();
337 MsgSmsClass0Noti(pMsg, noti, args);
339 } // Do not break here.
341 noti_err = notification_free(noti);
342 if (noti_err != NOTIFICATION_ERROR_NONE) {
343 MSG_DEBUG("Fail to notification_free");
345 MsgRefreshNoti(true);
351 // set execute option
352 noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
353 if (noti_err != NOTIFICATION_ERROR_NONE) {
354 MSG_DEBUG("Fail to notification_set_execute_option : %d", noti_err);
358 noti_err = notification_insert(noti, NULL);
359 if (noti_err != NOTIFICATION_ERROR_NONE) {
360 MSG_DEBUG("Fail to notification_insert");
363 noti_err = notification_free(noti);
364 if (noti_err != NOTIFICATION_ERROR_NONE) {
365 MSG_DEBUG("Fail to notification_free");
378 msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
381 notification_h noti = NULL;
382 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
384 char addressVal[MAX_ADDRESS_VAL_LEN+1];
385 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
386 char displayName[MAX_DISPLAY_NAME_LEN+1];
387 char sqlQuery[MAX_QUERY_LEN+1];
389 memset(addressVal, 0x00, sizeof(addressVal));
390 memset(firstName, 0x00, sizeof(firstName));
391 memset(lastName, 0x00, sizeof(lastName));
392 memset(displayName, 0x00, sizeof(displayName));
393 memset(sqlQuery, 0x00, sizeof(sqlQuery));
395 int report_status_type;
396 int report_status_value;
398 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
399 report_status_type = MSG_REPORT_TYPE_DELIVERY;
400 MSG_DEBUG("mms subtype is Delivery Report type");
401 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
402 report_status_type = MSG_REPORT_TYPE_READ;
403 MSG_DEBUG("mms subtype is Read Report type");
405 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
409 MSG_ADDRESS_INFO_S *address_info_s = &pMsg->addressList[0];
410 MSG_DEBUG("address info : %s, type : %d", address_info_s->addressVal, address_info_s->addressType);
412 if (address_info_s->addressType == MSG_ADDRESS_TYPE_PLMN) {
414 if (strlen(address_info_s->addressVal) > MAX_PRECONFIG_NUM) {
415 char newPhoneNum[MAX_PRECONFIG_NUM+1];
417 memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
419 MsgConvertNumber(address_info_s->addressVal, newPhoneNum);
421 snprintf(sqlQuery, sizeof(sqlQuery),
422 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
424 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%%%s' AND B.ADDRESS_VAL LIKE \'%%%s\';"
425 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, newPhoneNum, newPhoneNum);
428 snprintf(sqlQuery, sizeof(sqlQuery),
429 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
431 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%s' AND B.ADDRESS_VAL LIKE '%s';"
432 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal);
435 } else if (address_info_s->addressType == MSG_ADDRESS_TYPE_EMAIL) {//check full
436 snprintf(sqlQuery, sizeof(sqlQuery),
437 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
439 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL=\'%s\' AND B.ADDRESS_VAL LIKE \'%s\';"
440 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal);
442 snprintf(sqlQuery, sizeof(sqlQuery),
443 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
445 "WHERE B.MSG_ID=%d B.STATUS_TYPE=%d;"
446 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type);
449 MSG_DEBUG("sqlQuery = [%s]", sqlQuery);
451 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
452 return MSG_ERR_DB_PREPARE;
454 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
455 if (pDbHandle->columnText(0) != NULL) {
456 strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
457 MSG_DEBUG("addressVal is [%s]",addressVal);
459 MSG_DEBUG("address Val is Null");
462 char *pTempDisplayName = (char *)pDbHandle->columnText(1);
463 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
464 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
466 if (pDbHandle->columnText(2) != NULL)
467 strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
469 if (pDbHandle->columnText(3) != NULL)
470 strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
472 int order = MsgGetContactNameOrder();
475 if (firstName[0] != '\0') {
476 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
479 if (lastName[0] != '\0') {
480 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
481 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
483 } else if (order == 1) {
484 if (lastName[0] != '\0') {
485 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
486 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
489 if (firstName[0] != '\0') {
490 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
495 report_status_value = pDbHandle->columnInt(4);
496 MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
498 MSG_DEBUG("DB Query Result Fail");
499 pDbHandle->finalizeQuery();
500 return MSG_ERR_DB_STEP;
503 pDbHandle->finalizeQuery();
505 noti = notification_create(NOTIFICATION_TYPE_NOTI);
507 MSG_DEBUG("notification_create is failed.");
508 return MSG_ERR_UNKNOWN;
511 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
512 if (noti_err != NOTIFICATION_ERROR_NONE) {
513 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
516 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) { // MMS delivery report
518 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
519 if (noti_err != NOTIFICATION_ERROR_NONE) {
520 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
523 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
525 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Delivery Report", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
527 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) { // MMS read report
529 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
530 if (noti_err != NOTIFICATION_ERROR_NONE) {
531 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
534 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
536 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Read Report", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
539 if (displayName[0] == '\0')
540 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
542 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
545 noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
546 if (noti_err != NOTIFICATION_ERROR_NONE)
547 MSG_DEBUG("Fail to notification_set_display_applist");
549 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
551 switch(report_status_value) {
552 case MSG_DELIVERY_REPORT_NONE:
553 noti_err = notification_free(noti);
554 if (noti_err != NOTIFICATION_ERROR_NONE) {
555 MSG_DEBUG("Fail to notification_free");
558 return MSG_ERR_UNKNOWN;
560 case MSG_DELIVERY_REPORT_EXPIRED:
561 MSG_DEBUG("Message expired.");
562 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message expired", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
563 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message expired", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
566 case MSG_DELIVERY_REPORT_REJECTED:
567 MSG_DEBUG("Message rejected.");
568 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message rejected", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
569 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message rejected", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
572 case MSG_DELIVERY_REPORT_DEFERRED:
573 MSG_DEBUG("Message deferred.");
574 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message deferred", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
575 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message deferred", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
578 case MSG_DELIVERY_REPORT_UNRECOGNISED:
579 MSG_DEBUG("Message unrecognised.");
580 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message unrecognised", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
581 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message unrecognised", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
584 case MSG_DELIVERY_REPORT_INDETERMINATE:
585 MSG_DEBUG("Message indeterminate.");
586 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message indeterminate", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
587 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message indeterminate", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
590 case MSG_DELIVERY_REPORT_FORWARDED:
591 MSG_DEBUG("Message forwarded.");
592 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message forwarded", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
593 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message forwarded", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
596 case MSG_DELIVERY_REPORT_UNREACHABLE:
597 MSG_DEBUG("Message unreachable.");
598 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message unreachable", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
599 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message unreachable", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
602 case MSG_DELIVERY_REPORT_ERROR:
603 MSG_DEBUG("Message error.");
604 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message error", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
605 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message error", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
609 MSG_DEBUG("Message delivered.");
610 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message delivered", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
611 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message delivered", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
615 noti_err = notification_insert(noti, NULL);
616 if (noti_err != NOTIFICATION_ERROR_NONE)
617 MSG_DEBUG("Fail to notification_insert");
619 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
621 switch(report_status_value) {
622 case MSG_READ_REPORT_NONE:
623 noti_err = notification_free(noti);
624 if (noti_err != NOTIFICATION_ERROR_NONE)
625 MSG_DEBUG("Fail to notification_free");
627 return MSG_ERR_UNKNOWN;
629 case MSG_READ_REPORT_IS_DELETED:
630 MSG_DEBUG("Message deleted.");
631 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message deleted", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
635 MSG_DEBUG("Message read.");
636 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message read", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
641 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
644 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
646 noti_err = notification_insert(noti, NULL);
647 if (noti_err != NOTIFICATION_ERROR_NONE) {
648 MSG_DEBUG("Fail to notification_insert");
651 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
653 noti_err = notification_free(noti);
654 if (noti_err != NOTIFICATION_ERROR_NONE) {
655 MSG_DEBUG("Fail to notification_free");
660 noti_err = notification_free(noti);
661 if (noti_err != NOTIFICATION_ERROR_NONE) {
662 MSG_DEBUG("Fail to notification_free");
669 msg_error_t MsgRefreshNoti(bool bWithTicker)
672 MsgDbHandler dbhandler;
673 MSG_MESSAGE_INFO_S msg = {0,};
675 int notiPrivId = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
677 notification_h noti = NULL;
678 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
680 bundle* reply = NULL;
683 msg_thread_id_t threadId = 0;
686 char addressVal[MAX_ADDRESS_VAL_LEN+1];
687 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
688 char displayName[MAX_DISPLAY_NAME_LEN+1];
689 char thumbPath[MAX_IMAGE_PATH_LEN+1];
690 char sqlQuery[MAX_QUERY_LEN+1];
692 memset(tempId, 0x00, sizeof(tempId));
693 memset(addressVal, 0x00, sizeof(addressVal));
694 memset(firstName, 0x00, sizeof(firstName));
695 memset(lastName, 0x00, sizeof(lastName));
696 memset(displayName, 0x00, sizeof(displayName));
697 memset(thumbPath, 0x00, sizeof(thumbPath));
698 memset(sqlQuery, 0x00, sizeof(sqlQuery));
700 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, "
701 "B.DISPLAY_TIME, A.CONTACT_ID, A.IMAGE_PATH, B.MSG_ID, B.MSG_TEXT, B.SUBJECT, B.MAIN_TYPE "
702 "FROM %s A, %s B WHERE A.CONV_ID=B.CONV_ID AND B.READ_STATUS=0 AND B.FOLDER_ID=%d AND "
703 "(B.STORAGE_ID = %d OR B.STORAGE_ID = %d) "
704 "ORDER BY B.DISPLAY_TIME DESC;",
705 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_STORAGE_PHONE, MSG_STORAGE_SIM);
707 if (dbhandler.prepareQuery(sqlQuery) != MSG_SUCCESS)
708 return MSG_ERR_DB_PREPARE;
710 if (dbhandler.stepQuery() == MSG_ERR_DB_ROW) {
711 threadId = dbhandler.columnInt(0);
713 if (dbhandler.columnText(1) != NULL)
714 strncpy(addressVal, (char*)dbhandler.columnText(1), MAX_ADDRESS_VAL_LEN);
717 char *pTempDisplayName = (char *)dbhandler.columnText(2);
718 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
719 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
721 if (dbhandler.columnText(3) != NULL)
722 strncpy(firstName, (char*)dbhandler.columnText(3), MAX_DISPLAY_NAME_LEN);
724 if (dbhandler.columnText(4) != NULL)
725 strncpy(lastName, (char*)dbhandler.columnText(4), MAX_DISPLAY_NAME_LEN);
727 int order = MsgGetContactNameOrder();
730 if (firstName[0] != '\0') {
731 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
734 if (lastName[0] != '\0') {
735 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
736 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
738 } else if (order == 1) {
739 if (lastName[0] != '\0') {
740 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
741 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
744 if (firstName[0] != '\0') {
745 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
750 msgTime = (time_t)dbhandler.columnInt(5);
752 contactId = dbhandler.columnInt(6);
754 strncpy(thumbPath, (char*)dbhandler.columnText(7), MAX_IMAGE_PATH_LEN);
756 msg.msgId = dbhandler.columnInt(8);
758 strncpy(msg.msgText, (char*)dbhandler.columnText(9), MAX_MSG_TEXT_LEN);
760 strncpy(msg.subject, (char*)dbhandler.columnText(10), MAX_SUBJECT_LEN);
762 msg.msgType.mainType = dbhandler.columnInt(11);
764 MSG_DEBUG("unread message [%d].", msg.msgId);
767 MSG_DEBUG("No unread message.");
768 MSG_DEBUG("notiPrivId [%d]", notiPrivId);
770 dbhandler.finalizeQuery();
772 // No unread message.
773 if (notiPrivId > 0) {
774 noti_err = notification_delete_by_priv_id("8r4r5ddzzn.Messages", NOTIFICATION_TYPE_NOTI, notiPrivId);
775 if (noti_err != NOTIFICATION_ERROR_NONE) {
776 MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
782 if(MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId) != MSG_SUCCESS)
783 MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID");
785 return MSG_ERR_DB_STEP;
788 dbhandler.finalizeQuery();
790 int unreadMsgCnt = 0;
792 unreadMsgCnt = MsgStoGetUnreadCnt(&dbhandler, MSG_SMS_TYPE);
793 unreadMsgCnt += MsgStoGetUnreadCnt(&dbhandler, MSG_MMS_TYPE);
795 if (dbhandler.getTable(sqlQuery , &unreadMsgCnt) != MSG_SUCCESS) {
796 MSG_DEBUG("Fail to getTable");
797 dbhandler.freeTable();
798 return MSG_ERR_DB_GETTABLE;
801 dbhandler.freeTable();
804 MSG_DEBUG("notiPrivId [%d], unreadMsgCnt [%d]", notiPrivId, unreadMsgCnt);
806 if (notiPrivId > 0) {
807 noti = notification_load(NULL, notiPrivId);
809 MSG_DEBUG("notification_load is failed.");
813 noti = notification_create(NOTIFICATION_TYPE_NOTI);
815 MSG_DEBUG("notification_new is failed.");
816 return MSG_ERR_UNKNOWN;
823 noti_err = notification_set_pkgname(noti, "8r4r5ddzzn.Messages");
824 if (noti_err != NOTIFICATION_ERROR_NONE) {
825 MSG_DEBUG("Fail to notification_set_pkgname : %d", noti_err);
829 args = bundle_create();
831 appsvc_set_appid(args, "8r4r5ddzzn.Messages");
834 memset(&tempId, 0x00, sizeof(tempId));
835 bundle_add(args, "type", "new_msg");
836 snprintf(tempId, 5, "%d", msg.msgId);
837 bundle_add(args, "msgId", tempId);
839 if (unreadMsgCnt > 1) {
841 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
842 if (noti_err != NOTIFICATION_ERROR_NONE) {
843 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
846 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
847 if (noti_err != NOTIFICATION_ERROR_NONE) {
848 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
851 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
853 char unreadMsgCntStr[5] = {0,};
854 snprintf(unreadMsgCntStr, 5, "%d", unreadMsgCnt);
855 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
857 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Messages", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
859 // set execute option
860 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, args);
862 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL);
866 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
867 if (noti_err != NOTIFICATION_ERROR_NONE) {
868 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
871 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
872 if (noti_err != NOTIFICATION_ERROR_NONE) {
873 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
876 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, NORMAL_MSG_ICON_PATH);
877 if (noti_err != NOTIFICATION_ERROR_NONE) {
878 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
881 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, NORMAL_MSG_ICON_PATH);
882 if (noti_err != NOTIFICATION_ERROR_NONE) {
883 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
886 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
888 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
890 // set execute option
891 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
893 // Set responding option
894 reply = bundle_create();
895 appsvc_set_appid(reply, "8r4r5ddzzn.Messages");
897 bundle_add(reply, "type", "reply");
898 bundle_add(reply, "show_list", "list_show");
900 memset(&tempId, 0x00, sizeof(tempId));
901 snprintf(tempId, 5, "%d", msg.msgId);
902 bundle_add(reply, "msgId", tempId);
904 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply);
908 if (displayName[0] == '\0')
909 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
911 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
913 if (msg.msgType.mainType == MSG_SMS_TYPE)
914 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2,msg.msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
916 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msg.subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
919 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
922 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
924 notification_set_property(noti, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
927 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_ALL);
929 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER);
931 if (noti_err != NOTIFICATION_ERROR_NONE) {
932 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
935 if (notiPrivId > 0) {
936 noti_err = notification_update(noti);
937 if (noti_err != NOTIFICATION_ERROR_NONE) {
938 MSG_DEBUG("Fail to notification_update");
941 noti_err = notification_insert(noti, ¬iPrivId);
942 if (noti_err != NOTIFICATION_ERROR_NONE) {
943 MSG_DEBUG("Fail to notification_insert");
946 if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId) != MSG_SUCCESS)
947 MSG_DEBUG("MsgSettingSetInt fail: NOTIFICATION_PRIV_ID");
948 MSG_DEBUG("Insert notiPrivId [%d]", notiPrivId);
951 noti_err = notification_free(noti);
952 if (noti_err != NOTIFICATION_ERROR_NONE) {
953 MSG_DEBUG("Fail to notification_free");
968 msg_error_t MsgRefreshCBNoti(bool bWithTicker)
970 MsgDbHandler dbhandler;
972 int notiCbId = MsgSettingGetInt(CB_NOTI_PRIV_ID);
974 notification_h noti = NULL;
975 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
979 msg_thread_id_t threadId = 0;
980 msg_message_id_t msgId = 0;
983 char addressVal[MAX_ADDRESS_VAL_LEN+1];
984 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
985 char displayName[MAX_DISPLAY_NAME_LEN+1];
986 char thumbPath[MAX_IMAGE_PATH_LEN+1];
987 char msgText[MAX_MSG_TEXT_LEN+1];
988 char sqlQuery[MAX_QUERY_LEN+1];
990 memset(tempId, 0x00, sizeof(tempId));
991 memset(addressVal, 0x00, sizeof(addressVal));
992 memset(firstName, 0x00, sizeof(firstName));
993 memset(lastName, 0x00, sizeof(lastName));
994 memset(displayName, 0x00, sizeof(displayName));
995 memset(thumbPath, 0x00, sizeof(thumbPath));
996 memset(msgText, 0x00, sizeof(msgText));
997 memset(sqlQuery, 0x00, sizeof(sqlQuery));
999 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, "
1000 "B.DISPLAY_TIME, A.CONTACT_ID, A.IMAGE_PATH, B.MSG_ID, B.MSG_TEXT "
1001 "FROM %s A, %s B WHERE A.CONV_ID=B.CONV_ID AND B.READ_STATUS=0 AND B.FOLDER_ID=%d AND B.STORAGE_ID = %d "
1002 "ORDER BY B.DISPLAY_TIME DESC;",
1003 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
1005 if (dbhandler.prepareQuery(sqlQuery) != MSG_SUCCESS)
1006 return MSG_ERR_DB_PREPARE;
1008 if (dbhandler.stepQuery() == MSG_ERR_DB_ROW) {
1009 threadId = dbhandler.columnInt(0);
1011 if (dbhandler.columnText(1) != NULL)
1012 strncpy(addressVal, (char*)dbhandler.columnText(1), MAX_ADDRESS_VAL_LEN);
1015 char *pTempDisplayName = (char *)dbhandler.columnText(2);
1016 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
1017 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
1019 if (dbhandler.columnText(3) != NULL)
1020 strncpy(firstName, (char*)dbhandler.columnText(3), MAX_DISPLAY_NAME_LEN);
1022 if (dbhandler.columnText(4) != NULL)
1023 strncpy(lastName, (char*)dbhandler.columnText(4), MAX_DISPLAY_NAME_LEN);
1025 int order = MsgGetContactNameOrder();
1028 if (firstName[0] != '\0') {
1029 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
1032 if (lastName[0] != '\0') {
1033 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
1034 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
1036 } else if (order == 1) {
1037 if (lastName[0] != '\0') {
1038 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
1039 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
1042 if (firstName[0] != '\0') {
1043 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
1048 msgTime = (time_t)dbhandler.columnInt(5);
1050 contactId = dbhandler.columnInt(6);
1052 strncpy(thumbPath, (char*)dbhandler.columnText(7), MAX_IMAGE_PATH_LEN);
1054 msgId = dbhandler.columnInt(8);
1056 strncpy(msgText, (char*)dbhandler.columnText(9), MAX_MSG_TEXT_LEN);
1058 MSG_DEBUG("unread CB message [%d].", msgId);
1061 MSG_DEBUG("No unread CB message.");
1062 MSG_DEBUG("notiCbId [%d]", notiCbId);
1064 dbhandler.finalizeQuery();
1066 // No unread message.
1068 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiCbId);
1069 if (noti_err != NOTIFICATION_ERROR_NONE) {
1070 MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1076 if(MsgSettingSetInt(CB_NOTI_PRIV_ID, notiCbId) != MSG_SUCCESS)
1077 MSG_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1079 return MSG_ERR_DB_STEP;
1082 dbhandler.finalizeQuery();
1084 int unreadCbMsgCnt = 0;
1086 if (dbhandler.getTable(sqlQuery, &unreadCbMsgCnt) != MSG_SUCCESS) {
1087 MSG_DEBUG("getTable is failed");
1088 dbhandler.freeTable();
1089 return MSG_ERR_DB_GETTABLE;
1092 MSG_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", notiCbId, unreadCbMsgCnt);
1095 noti = notification_load(NULL, notiCbId);
1097 MSG_DEBUG("notification_load is failed.");
1101 noti = notification_create(NOTIFICATION_TYPE_NOTI);
1103 MSG_DEBUG("notification_new is failed.");
1104 return MSG_ERR_UNKNOWN;
1109 args = bundle_create();
1111 appsvc_set_appid(args, "8r4r5ddzzn.Messages");
1113 // Set bundle values
1114 memset(&tempId, 0x00, sizeof(tempId));
1115 bundle_add(args, "type", "new_msg");
1116 snprintf(tempId, 5, "%d", msgId);
1117 bundle_add(args, "msgId", tempId);
1119 if (unreadCbMsgCnt > 1) {
1120 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
1121 if (noti_err != NOTIFICATION_ERROR_NONE) {
1122 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
1125 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1127 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Messages", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1129 char unreadCbMsgCntStr[5] = {0,};
1130 snprintf(unreadCbMsgCntStr, 5, "%d", unreadCbMsgCnt);
1131 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadCbMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1133 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, args);
1135 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1136 if (noti_err != NOTIFICATION_ERROR_NONE) {
1137 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
1140 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1142 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1144 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
1148 if (displayName[0] == '\0')
1149 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1151 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1153 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1156 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
1159 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
1162 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
1165 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK);
1167 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR);
1169 if (noti_err != NOTIFICATION_ERROR_NONE) {
1170 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
1174 noti_err = notification_update(noti);
1175 if (noti_err != NOTIFICATION_ERROR_NONE) {
1176 MSG_DEBUG("Fail to notification_update");
1179 noti_err = notification_insert(noti, ¬iCbId);
1180 if (noti_err != NOTIFICATION_ERROR_NONE) {
1181 MSG_DEBUG("Fail to notification_insert");
1184 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, notiCbId) != MSG_SUCCESS)
1185 MSG_DEBUG("MsgSettingSetInt fail: CB_NOTI_PRIV_ID");
1186 MSG_DEBUG("Insert notiCbId [%d]", notiCbId);
1189 noti_err = notification_free(noti);
1190 if (noti_err != NOTIFICATION_ERROR_NONE) {
1191 MSG_DEBUG("Fail to notification_free");
1202 msg_error_t MsgCleanAndResetNoti()
1204 msg_error_t err = MSG_SUCCESS;
1205 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1207 noti_err = notification_delete_all_by_type("8r4r5ddzzn.Messages", NOTIFICATION_TYPE_NOTI);
1208 if (noti_err != NOTIFICATION_ERROR_NONE) {
1209 MSG_DEBUG("Fail to notification_delete_all_by_type noti_err [%d]", noti_err);
1212 err = MsgRefreshNoti(false);
1213 if (err != MSG_SUCCESS) {
1214 MSG_DEBUG("Fail to MsgRefreshNoti : [err=%d]", err);
1217 err = MsgRefreshCBNoti(false);
1218 if (err != MSG_SUCCESS) {
1219 MSG_DEBUG("Fail to MsgRefreshCBNoti : [err=%d]", err);
1226 msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg)
1228 notification_h noti = NULL;
1229 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1231 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
1233 MSG_DEBUG("notification_new is failed.");
1234 return MSG_ERR_UNKNOWN;
1237 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
1238 if (noti_err != NOTIFICATION_ERROR_NONE) {
1239 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
1242 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
1243 if (noti_err != NOTIFICATION_ERROR_NONE) {
1244 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
1247 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
1248 if (noti_err != NOTIFICATION_ERROR_NONE) {
1249 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
1252 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER);
1253 if (noti_err != NOTIFICATION_ERROR_NONE) {
1254 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
1257 noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
1258 if (noti_err != NOTIFICATION_ERROR_NONE)
1259 MSG_DEBUG("Fail to notification_set_display_applist");
1261 noti_err = notification_insert(noti, NULL);
1262 if (noti_err != NOTIFICATION_ERROR_NONE) {
1263 MSG_DEBUG("Fail to notification_insert");
1266 noti_err = notification_free(noti);
1267 if (noti_err != NOTIFICATION_ERROR_NONE) {
1268 MSG_DEBUG("Fail to notification_free");
1275 msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)
1281 msg_error_t MsgClearVoiceNoti(MSG_SUB_TYPE_T subType)
1285 msg_error_t err = MSG_SUCCESS;
1287 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1289 if (subType == MSG_MWI_VOICE_SMS) {
1290 notiId = MsgSettingGetInt(VOICE_NOTI_ID_1);
1292 return MSG_ERR_UNKNOWN;
1296 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiId);
1297 if (noti_err != NOTIFICATION_ERROR_NONE) {
1298 MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1299 err = MSG_ERR_UNKNOWN;
1305 if (subType == MSG_MWI_VOICE_SMS) {
1306 if (MsgSettingSetInt(VOICE_NOTI_ID_1, notiId) == MSG_SUCCESS)
1307 MSG_DEBUG("Insert VOICE_NOTI_ID_1 [%d]", notiId);
1309 MSG_DEBUG("MsgSettingSetInt fail: VOICE_NOTI_ID_1");