4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include "MsgContact.h"
22 #include "MsgStorageTypes.h"
23 #include "MsgUtilStorage.h"
24 #include "MsgGconfWrapper.h"
25 #include "MsgNotificationWrapper.h"
29 #include <notification.h>
33 /*==================================================================================================
34 FUNCTION IMPLEMENTATION
35 ==================================================================================================*/
36 void MsgSmsClass0Noti(MSG_MESSAGE_INFO_S* pMsg, notification_h noti, bundle* args)
39 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
42 memset(tempId, 0x00, sizeof(tempId));
44 appsvc_set_appid(args, "org.tizen.msg-ui-class0");
46 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
47 if (noti_err != NOTIFICATION_ERROR_NONE) {
48 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
51 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
52 if (noti_err != NOTIFICATION_ERROR_NONE) {
53 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
56 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
58 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
60 if (pMsg->addressList[0].displayName[0] == '\0')
61 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
63 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
65 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
68 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
71 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
73 bundle_add(args, "type", "new_msg");
75 snprintf(tempId, 5, "%d", pMsg->msgId);
76 bundle_add(args, "msgId", tempId);
82 void MsgSmsMWINoti(MSG_MESSAGE_INFO_S* pMsg, notification_h noti, bundle* args)
86 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
88 appsvc_set_appid(args, "org.tizen.call");
90 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
91 if (noti_err != NOTIFICATION_ERROR_NONE) {
92 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
95 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
97 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New MWI Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
99 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
100 if (noti_err != NOTIFICATION_ERROR_NONE) {
101 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
104 if (pMsg->addressList[0].displayName[0] == '\0')
105 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
107 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
109 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
112 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
115 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
117 bundle_add(args, "launch-type", "MO");
118 bundle_add(args, "number", pMsg->addressList[0].addressVal);
124 void MsgSmsVoiceNoti(MSG_MESSAGE_INFO_S* pMsg)
129 notification_h noti = NULL;
130 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
133 args = bundle_create();
135 notiId = MsgSettingGetInt(VOICE_NOTI_ID_1);
138 noti = notification_load(NULL, notiId);
140 MSG_DEBUG("notification_load is failed.");
144 noti = notification_create(NOTIFICATION_TYPE_NOTI);
146 MSG_DEBUG("notification_new is failed.");
147 if (args != NULL) bundle_free(args);
154 appsvc_set_appid(args, "org.tizen.call");
156 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
157 if (noti_err != NOTIFICATION_ERROR_NONE) {
158 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
161 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
163 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Voicemail", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
165 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
166 if (noti_err != NOTIFICATION_ERROR_NONE) {
167 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
170 if (pMsg->addressList[0].displayName[0] == '\0')
171 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
173 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
175 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
178 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
181 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
183 bundle_add(args, "launch-type", "MO");
184 bundle_add(args, "number", pMsg->addressList[0].addressVal);
187 noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
188 if (noti_err != NOTIFICATION_ERROR_NONE) {
189 MSG_DEBUG("Fail to notification_set_execute_option : %d", noti_err);
194 noti_err = notification_update(noti);
195 if (noti_err != NOTIFICATION_ERROR_NONE) {
196 MSG_DEBUG("Fail to notification_update");
199 noti_err = notification_insert(noti, ¬iId);
200 if (noti_err != NOTIFICATION_ERROR_NONE) {
201 MSG_DEBUG("Fail to notification_insert");
204 if (MsgSettingSetInt(VOICE_NOTI_ID_1, notiId) == MSG_SUCCESS)
205 MSG_DEBUG("Insert VOICE_NOTI_ID_1 [%d]", notiId);
207 MSG_DEBUG("MsgSettingSetInt fail: VOICE_NOTI_ID_1");
210 noti_err = notification_free(noti);
211 if (noti_err != NOTIFICATION_ERROR_NONE) {
212 MSG_DEBUG("Fail to notification_free");
225 void MsgSmsReportNoti(MSG_MESSAGE_INFO_S* pMsg, notification_h noti, bundle* args)
229 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
231 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
232 if (noti_err != NOTIFICATION_ERROR_NONE) {
233 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
236 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
237 if(pMsg->networkStatus == MSG_NETWORK_DELIVER_SUCCESS)
238 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message Delivered", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
240 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Message delivery failed", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
242 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
243 if (noti_err != NOTIFICATION_ERROR_NONE) {
244 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
248 MSG_CONTACT_INFO_S contactInfo;
249 memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S));
250 MsgGetContactInfo(&(pMsg->addressList[0]), &contactInfo);
252 int order = MsgGetContactNameOrder();
255 if (contactInfo.firstName[0] != '\0') {
256 strncpy(pMsg->addressList[0].displayName, contactInfo.firstName, MAX_DISPLAY_NAME_LEN);
259 if (contactInfo.lastName[0] != '\0') {
260 strncat(pMsg->addressList[0].displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
261 strncat(pMsg->addressList[0].displayName, contactInfo.lastName, MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
263 } else if (order == 1) {
264 if (contactInfo.lastName[0] != '\0') {
265 strncpy(pMsg->addressList[0].displayName, contactInfo.lastName, MAX_DISPLAY_NAME_LEN);
266 strncat(pMsg->addressList[0].displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
269 if (contactInfo.firstName[0] != '\0') {
270 strncat(pMsg->addressList[0].displayName, contactInfo.firstName, MAX_DISPLAY_NAME_LEN-strlen(pMsg->addressList[0].displayName));
274 if (pMsg->addressList[0].displayName[0] == '\0')
275 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
277 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, pMsg->addressList[0].displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
279 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message delivered.", pMsg->msgText, NOTIFICATION_VARIABLE_TYPE_NONE);
282 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
285 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
288 noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
289 if (noti_err != NOTIFICATION_ERROR_NONE)
290 MSG_DEBUG("Fail to notification_set_display_applist");
296 msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
298 MSG_DEBUG("Start to Insert Notification.");
299 notification_h noti = NULL;
300 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
303 noti = notification_create(NOTIFICATION_TYPE_NOTI);
305 MSG_DEBUG("notification_create is failed.");
306 return MSG_ERR_UNKNOWN;
309 switch(pMsg->msgType.subType)
312 noti_err = notification_free(noti);
313 if (noti_err != NOTIFICATION_ERROR_NONE) {
314 MSG_DEBUG("Fail to notification_free");
316 MsgRefreshCBNoti(true);
319 case MSG_MWI_FAX_SMS :
320 case MSG_MWI_EMAIL_SMS :
321 case MSG_MWI_OTHER_SMS :
322 args = bundle_create();
323 MsgSmsMWINoti(pMsg, noti, args);
325 case MSG_MWI_VOICE_SMS :
326 noti_err = notification_free(noti);
327 if (noti_err != NOTIFICATION_ERROR_NONE) {
328 MSG_DEBUG("Fail to notification_free");
330 MsgSmsVoiceNoti(pMsg);
333 case MSG_STATUS_REPORT_SMS :
334 //args = bundle_create();
335 MsgSmsReportNoti(pMsg, noti, NULL);
337 case MSG_NORMAL_SMS :
338 if (pMsg->msgType.classType == MSG_CLASS_0) {
339 args = bundle_create();
340 MsgSmsClass0Noti(pMsg, noti, args);
342 } // Do not break here.
344 noti_err = notification_free(noti);
345 if (noti_err != NOTIFICATION_ERROR_NONE) {
346 MSG_DEBUG("Fail to notification_free");
348 MsgRefreshNoti(true);
354 // set execute option
355 noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
356 if (noti_err != NOTIFICATION_ERROR_NONE) {
357 MSG_DEBUG("Fail to notification_set_execute_option : %d", noti_err);
361 noti_err = notification_insert(noti, NULL);
362 if (noti_err != NOTIFICATION_ERROR_NONE) {
363 MSG_DEBUG("Fail to notification_insert");
366 noti_err = notification_free(noti);
367 if (noti_err != NOTIFICATION_ERROR_NONE) {
368 MSG_DEBUG("Fail to notification_free");
381 msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
384 notification_h noti = NULL;
385 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
387 char addressVal[MAX_ADDRESS_VAL_LEN+1];
388 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
389 char displayName[MAX_DISPLAY_NAME_LEN+1];
390 char sqlQuery[MAX_QUERY_LEN+1];
392 memset(addressVal, 0x00, sizeof(addressVal));
393 memset(firstName, 0x00, sizeof(firstName));
394 memset(lastName, 0x00, sizeof(lastName));
395 memset(displayName, 0x00, sizeof(displayName));
396 memset(sqlQuery, 0x00, sizeof(sqlQuery));
398 int report_status_type;
399 int report_status_value;
401 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
402 report_status_type = MSG_REPORT_TYPE_DELIVERY;
403 MSG_DEBUG("mms subtype is Delivery Report type");
404 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
405 report_status_type = MSG_REPORT_TYPE_READ;
406 MSG_DEBUG("mms subtype is Read Report type");
408 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
412 MSG_ADDRESS_INFO_S *address_info_s = &pMsg->addressList[0];
413 MSG_DEBUG("address info : %s, type : %d", address_info_s->addressVal, address_info_s->addressType);
415 if (address_info_s->addressType == MSG_ADDRESS_TYPE_PLMN) {
417 if (strlen(address_info_s->addressVal) > MAX_PRECONFIG_NUM) {
418 char newPhoneNum[MAX_PRECONFIG_NUM+1];
420 memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
422 MsgConvertNumber(address_info_s->addressVal, newPhoneNum);
424 snprintf(sqlQuery, sizeof(sqlQuery),
425 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
427 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%%%s' AND B.ADDRESS_VAL LIKE \'%%%s\';"
428 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, newPhoneNum, newPhoneNum);
431 snprintf(sqlQuery, sizeof(sqlQuery),
432 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
434 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%s' AND B.ADDRESS_VAL LIKE '%s';"
435 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal);
438 } else if (address_info_s->addressType == MSG_ADDRESS_TYPE_EMAIL) {//check full
439 snprintf(sqlQuery, sizeof(sqlQuery),
440 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
442 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL=\'%s\' AND B.ADDRESS_VAL LIKE \'%s\';"
443 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal);
445 snprintf(sqlQuery, sizeof(sqlQuery),
446 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
448 "WHERE B.MSG_ID=%d B.STATUS_TYPE=%d;"
449 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type);
452 MSG_DEBUG("sqlQuery = [%s]", sqlQuery);
454 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
455 return MSG_ERR_DB_PREPARE;
457 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
458 if (pDbHandle->columnText(0) != NULL) {
459 strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
460 MSG_DEBUG("addressVal is [%s]",addressVal);
462 MSG_DEBUG("address Val is Null");
465 char *pTempDisplayName = (char *)pDbHandle->columnText(1);
466 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
467 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
469 if (pDbHandle->columnText(2) != NULL)
470 strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
472 if (pDbHandle->columnText(3) != NULL)
473 strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
475 int order = MsgGetContactNameOrder();
478 if (firstName[0] != '\0') {
479 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
482 if (lastName[0] != '\0') {
483 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
484 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
486 } else if (order == 1) {
487 if (lastName[0] != '\0') {
488 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
489 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
492 if (firstName[0] != '\0') {
493 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
498 report_status_value = pDbHandle->columnInt(4);
499 MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
501 MSG_DEBUG("DB Query Result Fail");
502 pDbHandle->finalizeQuery();
503 return MSG_ERR_DB_STEP;
506 pDbHandle->finalizeQuery();
508 noti = notification_create(NOTIFICATION_TYPE_NOTI);
510 MSG_DEBUG("notification_create is failed.");
511 return MSG_ERR_UNKNOWN;
514 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
515 if (noti_err != NOTIFICATION_ERROR_NONE) {
516 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
519 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) { // MMS delivery report
521 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
522 if (noti_err != NOTIFICATION_ERROR_NONE) {
523 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
526 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
528 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Delivery Report", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
530 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) { // MMS read report
532 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
533 if (noti_err != NOTIFICATION_ERROR_NONE) {
534 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
537 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
539 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "Read Report", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
542 if (displayName[0] == '\0')
543 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
545 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
548 noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
549 if (noti_err != NOTIFICATION_ERROR_NONE)
550 MSG_DEBUG("Fail to notification_set_display_applist");
552 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
554 switch(report_status_value) {
555 case MSG_DELIVERY_REPORT_NONE:
556 noti_err = notification_free(noti);
557 if (noti_err != NOTIFICATION_ERROR_NONE) {
558 MSG_DEBUG("Fail to notification_free");
561 return MSG_ERR_UNKNOWN;
563 case MSG_DELIVERY_REPORT_EXPIRED:
564 MSG_DEBUG("Message expired.");
565 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message expired", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
566 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message expired", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
569 case MSG_DELIVERY_REPORT_REJECTED:
570 MSG_DEBUG("Message rejected.");
571 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message rejected", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
572 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message rejected", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
575 case MSG_DELIVERY_REPORT_DEFERRED:
576 MSG_DEBUG("Message deferred.");
577 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message deferred", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
578 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message deferred", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
581 case MSG_DELIVERY_REPORT_UNRECOGNISED:
582 MSG_DEBUG("Message unrecognised.");
583 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message unrecognised", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
584 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message unrecognised", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
587 case MSG_DELIVERY_REPORT_INDETERMINATE:
588 MSG_DEBUG("Message indeterminate.");
589 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message indeterminate", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
590 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message indeterminate", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
593 case MSG_DELIVERY_REPORT_FORWARDED:
594 MSG_DEBUG("Message forwarded.");
595 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message forwarded", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
596 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message forwarded", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
599 case MSG_DELIVERY_REPORT_UNREACHABLE:
600 MSG_DEBUG("Message unreachable.");
601 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message unreachable", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
602 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message unreachable", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
605 case MSG_DELIVERY_REPORT_ERROR:
606 MSG_DEBUG("Message error.");
607 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message error", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
608 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message error", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
612 MSG_DEBUG("Message delivered.");
613 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message delivered", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
614 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, "Message delivered", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
618 noti_err = notification_insert(noti, NULL);
619 if (noti_err != NOTIFICATION_ERROR_NONE)
620 MSG_DEBUG("Fail to notification_insert");
622 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
624 switch(report_status_value) {
625 case MSG_READ_REPORT_NONE:
626 noti_err = notification_free(noti);
627 if (noti_err != NOTIFICATION_ERROR_NONE)
628 MSG_DEBUG("Fail to notification_free");
630 return MSG_ERR_UNKNOWN;
632 case MSG_READ_REPORT_IS_DELETED:
633 MSG_DEBUG("Message deleted.");
634 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message deleted", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
638 MSG_DEBUG("Message read.");
639 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, "Message read", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
644 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
647 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
649 noti_err = notification_insert(noti, NULL);
650 if (noti_err != NOTIFICATION_ERROR_NONE) {
651 MSG_DEBUG("Fail to notification_insert");
654 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
656 noti_err = notification_free(noti);
657 if (noti_err != NOTIFICATION_ERROR_NONE) {
658 MSG_DEBUG("Fail to notification_free");
663 noti_err = notification_free(noti);
664 if (noti_err != NOTIFICATION_ERROR_NONE) {
665 MSG_DEBUG("Fail to notification_free");
672 msg_error_t MsgRefreshNoti(bool bWithTicker)
675 MsgDbHandler dbhandler;
676 MSG_MESSAGE_INFO_S msg = {0,};
678 int notiPrivId = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
680 notification_h noti = NULL;
681 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
683 bundle* reply = NULL;
686 msg_thread_id_t threadId = 0;
689 char addressVal[MAX_ADDRESS_VAL_LEN+1];
690 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
691 char displayName[MAX_DISPLAY_NAME_LEN+1];
692 char thumbPath[MAX_IMAGE_PATH_LEN+1];
693 char sqlQuery[MAX_QUERY_LEN+1];
695 memset(tempId, 0x00, sizeof(tempId));
696 memset(addressVal, 0x00, sizeof(addressVal));
697 memset(firstName, 0x00, sizeof(firstName));
698 memset(lastName, 0x00, sizeof(lastName));
699 memset(displayName, 0x00, sizeof(displayName));
700 memset(thumbPath, 0x00, sizeof(thumbPath));
701 memset(sqlQuery, 0x00, sizeof(sqlQuery));
703 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, "
704 "B.DISPLAY_TIME, A.CONTACT_ID, A.IMAGE_PATH, B.MSG_ID, B.MSG_TEXT, B.SUBJECT, B.MAIN_TYPE "
705 "FROM %s A, %s B WHERE A.CONV_ID=B.CONV_ID AND B.READ_STATUS=0 AND B.FOLDER_ID=%d AND "
706 "(B.STORAGE_ID = %d OR B.STORAGE_ID = %d) "
707 "ORDER BY B.DISPLAY_TIME DESC;",
708 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID, MSG_STORAGE_PHONE, MSG_STORAGE_SIM);
710 if (dbhandler.prepareQuery(sqlQuery) != MSG_SUCCESS)
711 return MSG_ERR_DB_PREPARE;
713 if (dbhandler.stepQuery() == MSG_ERR_DB_ROW) {
714 threadId = dbhandler.columnInt(0);
716 if (dbhandler.columnText(1) != NULL)
717 strncpy(addressVal, (char*)dbhandler.columnText(1), MAX_ADDRESS_VAL_LEN);
720 char *pTempDisplayName = (char *)dbhandler.columnText(2);
721 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
722 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
724 if (dbhandler.columnText(3) != NULL)
725 strncpy(firstName, (char*)dbhandler.columnText(3), MAX_DISPLAY_NAME_LEN);
727 if (dbhandler.columnText(4) != NULL)
728 strncpy(lastName, (char*)dbhandler.columnText(4), MAX_DISPLAY_NAME_LEN);
730 int order = MsgGetContactNameOrder();
733 if (firstName[0] != '\0') {
734 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
737 if (lastName[0] != '\0') {
738 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
739 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
741 } else if (order == 1) {
742 if (lastName[0] != '\0') {
743 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
744 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
747 if (firstName[0] != '\0') {
748 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
753 msgTime = (time_t)dbhandler.columnInt(5);
755 contactId = dbhandler.columnInt(6);
757 strncpy(thumbPath, (char*)dbhandler.columnText(7), MAX_IMAGE_PATH_LEN);
759 msg.msgId = dbhandler.columnInt(8);
761 strncpy(msg.msgText, (char*)dbhandler.columnText(9), MAX_MSG_TEXT_LEN);
763 strncpy(msg.subject, (char*)dbhandler.columnText(10), MAX_SUBJECT_LEN);
765 msg.msgType.mainType = dbhandler.columnInt(11);
767 MSG_DEBUG("unread message [%d].", msg.msgId);
770 MSG_DEBUG("No unread message.");
771 MSG_DEBUG("notiPrivId [%d]", notiPrivId);
773 dbhandler.finalizeQuery();
775 // No unread message.
776 if (notiPrivId > 0) {
777 noti_err = notification_delete_by_priv_id("8r4r5ddzzn.Messages", NOTIFICATION_TYPE_NOTI, notiPrivId);
778 if (noti_err != NOTIFICATION_ERROR_NONE) {
779 MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
785 if(MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId) != MSG_SUCCESS)
786 MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID");
788 return MSG_ERR_DB_STEP;
791 dbhandler.finalizeQuery();
793 int unreadMsgCnt = 0;
795 unreadMsgCnt = MsgStoGetUnreadCnt(&dbhandler, MSG_SMS_TYPE);
796 unreadMsgCnt += MsgStoGetUnreadCnt(&dbhandler, MSG_MMS_TYPE);
798 if (dbhandler.getTable(sqlQuery , &unreadMsgCnt) != MSG_SUCCESS) {
799 MSG_DEBUG("Fail to getTable");
800 dbhandler.freeTable();
801 return MSG_ERR_DB_GETTABLE;
804 dbhandler.freeTable();
807 MSG_DEBUG("notiPrivId [%d], unreadMsgCnt [%d]", notiPrivId, unreadMsgCnt);
809 if (notiPrivId > 0) {
810 noti = notification_load(NULL, notiPrivId);
812 MSG_DEBUG("notification_load is failed.");
816 noti = notification_create(NOTIFICATION_TYPE_NOTI);
818 MSG_DEBUG("notification_new is failed.");
819 return MSG_ERR_UNKNOWN;
826 noti_err = notification_set_pkgname(noti, "8r4r5ddzzn.Messages");
827 if (noti_err != NOTIFICATION_ERROR_NONE) {
828 MSG_DEBUG("Fail to notification_set_pkgname : %d", noti_err);
832 args = bundle_create();
834 appsvc_set_appid(args, "8r4r5ddzzn.Messages");
837 memset(&tempId, 0x00, sizeof(tempId));
838 bundle_add(args, "type", "new_msg");
839 snprintf(tempId, 5, "%d", msg.msgId);
840 bundle_add(args, "msgId", tempId);
842 if (unreadMsgCnt > 1) {
844 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
845 if (noti_err != NOTIFICATION_ERROR_NONE) {
846 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
849 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
850 if (noti_err != NOTIFICATION_ERROR_NONE) {
851 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
854 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
856 char unreadMsgCntStr[5] = {0,};
857 snprintf(unreadMsgCntStr, 5, "%d", unreadMsgCnt);
858 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
860 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Messages", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
862 // set execute option
863 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, args);
865 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL);
869 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
870 if (noti_err != NOTIFICATION_ERROR_NONE) {
871 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
874 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
875 if (noti_err != NOTIFICATION_ERROR_NONE) {
876 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
879 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, NORMAL_MSG_ICON_PATH);
880 if (noti_err != NOTIFICATION_ERROR_NONE) {
881 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
884 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, NORMAL_MSG_ICON_PATH);
885 if (noti_err != NOTIFICATION_ERROR_NONE) {
886 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
889 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
891 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
893 // set execute option
894 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
896 // Set responding option
897 reply = bundle_create();
898 appsvc_set_appid(reply, "8r4r5ddzzn.Messages");
900 bundle_add(reply, "type", "reply");
901 bundle_add(reply, "show_list", "list_show");
903 memset(&tempId, 0x00, sizeof(tempId));
904 snprintf(tempId, 5, "%d", msg.msgId);
905 bundle_add(reply, "msgId", tempId);
907 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply);
911 if (displayName[0] == '\0')
912 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
914 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
916 if (msg.msgType.mainType == MSG_SMS_TYPE)
917 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2,msg.msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
919 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msg.subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
922 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
925 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
927 notification_set_property(noti, NOTIFICATION_PROP_DISABLE_AUTO_DELETE);
930 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_ALL);
932 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER);
934 if (noti_err != NOTIFICATION_ERROR_NONE) {
935 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
938 if (notiPrivId > 0) {
939 noti_err = notification_update(noti);
940 if (noti_err != NOTIFICATION_ERROR_NONE) {
941 MSG_DEBUG("Fail to notification_update");
944 noti_err = notification_insert(noti, ¬iPrivId);
945 if (noti_err != NOTIFICATION_ERROR_NONE) {
946 MSG_DEBUG("Fail to notification_insert");
949 if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId) != MSG_SUCCESS)
950 MSG_DEBUG("MsgSettingSetInt fail: NOTIFICATION_PRIV_ID");
951 MSG_DEBUG("Insert notiPrivId [%d]", notiPrivId);
954 noti_err = notification_free(noti);
955 if (noti_err != NOTIFICATION_ERROR_NONE) {
956 MSG_DEBUG("Fail to notification_free");
971 msg_error_t MsgRefreshCBNoti(bool bWithTicker)
973 MsgDbHandler dbhandler;
975 int notiCbId = MsgSettingGetInt(CB_NOTI_PRIV_ID);
977 notification_h noti = NULL;
978 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
982 msg_thread_id_t threadId = 0;
983 msg_message_id_t msgId = 0;
986 char addressVal[MAX_ADDRESS_VAL_LEN+1];
987 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
988 char displayName[MAX_DISPLAY_NAME_LEN+1];
989 char thumbPath[MAX_IMAGE_PATH_LEN+1];
990 char msgText[MAX_MSG_TEXT_LEN+1];
991 char sqlQuery[MAX_QUERY_LEN+1];
993 memset(tempId, 0x00, sizeof(tempId));
994 memset(addressVal, 0x00, sizeof(addressVal));
995 memset(firstName, 0x00, sizeof(firstName));
996 memset(lastName, 0x00, sizeof(lastName));
997 memset(displayName, 0x00, sizeof(displayName));
998 memset(thumbPath, 0x00, sizeof(thumbPath));
999 memset(msgText, 0x00, sizeof(msgText));
1000 memset(sqlQuery, 0x00, sizeof(sqlQuery));
1002 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, "
1003 "B.DISPLAY_TIME, A.CONTACT_ID, A.IMAGE_PATH, B.MSG_ID, B.MSG_TEXT "
1004 "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 "
1005 "ORDER BY B.DISPLAY_TIME DESC;",
1006 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_CBMSGBOX_ID, MSG_STORAGE_PHONE);
1008 if (dbhandler.prepareQuery(sqlQuery) != MSG_SUCCESS)
1009 return MSG_ERR_DB_PREPARE;
1011 if (dbhandler.stepQuery() == MSG_ERR_DB_ROW) {
1012 threadId = dbhandler.columnInt(0);
1014 if (dbhandler.columnText(1) != NULL)
1015 strncpy(addressVal, (char*)dbhandler.columnText(1), MAX_ADDRESS_VAL_LEN);
1018 char *pTempDisplayName = (char *)dbhandler.columnText(2);
1019 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
1020 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
1022 if (dbhandler.columnText(3) != NULL)
1023 strncpy(firstName, (char*)dbhandler.columnText(3), MAX_DISPLAY_NAME_LEN);
1025 if (dbhandler.columnText(4) != NULL)
1026 strncpy(lastName, (char*)dbhandler.columnText(4), MAX_DISPLAY_NAME_LEN);
1028 int order = MsgGetContactNameOrder();
1031 if (firstName[0] != '\0') {
1032 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
1035 if (lastName[0] != '\0') {
1036 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
1037 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
1039 } else if (order == 1) {
1040 if (lastName[0] != '\0') {
1041 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
1042 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
1045 if (firstName[0] != '\0') {
1046 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
1051 msgTime = (time_t)dbhandler.columnInt(5);
1053 contactId = dbhandler.columnInt(6);
1055 strncpy(thumbPath, (char*)dbhandler.columnText(7), MAX_IMAGE_PATH_LEN);
1057 msgId = dbhandler.columnInt(8);
1059 strncpy(msgText, (char*)dbhandler.columnText(9), MAX_MSG_TEXT_LEN);
1061 MSG_DEBUG("unread CB message [%d].", msgId);
1064 MSG_DEBUG("No unread CB message.");
1065 MSG_DEBUG("notiCbId [%d]", notiCbId);
1067 dbhandler.finalizeQuery();
1069 // No unread message.
1071 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiCbId);
1072 if (noti_err != NOTIFICATION_ERROR_NONE) {
1073 MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1079 if(MsgSettingSetInt(CB_NOTI_PRIV_ID, notiCbId) != MSG_SUCCESS)
1080 MSG_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID");
1082 return MSG_ERR_DB_STEP;
1085 dbhandler.finalizeQuery();
1087 int unreadCbMsgCnt = 0;
1089 if (dbhandler.getTable(sqlQuery, &unreadCbMsgCnt) != MSG_SUCCESS) {
1090 MSG_DEBUG("getTable is failed");
1091 dbhandler.freeTable();
1092 return MSG_ERR_DB_GETTABLE;
1095 MSG_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", notiCbId, unreadCbMsgCnt);
1098 noti = notification_load(NULL, notiCbId);
1100 MSG_DEBUG("notification_load is failed.");
1104 noti = notification_create(NOTIFICATION_TYPE_NOTI);
1106 MSG_DEBUG("notification_new is failed.");
1107 return MSG_ERR_UNKNOWN;
1112 args = bundle_create();
1114 appsvc_set_appid(args, "8r4r5ddzzn.Messages");
1116 // Set bundle values
1117 memset(&tempId, 0x00, sizeof(tempId));
1118 bundle_add(args, "type", "new_msg");
1119 snprintf(tempId, 5, "%d", msgId);
1120 bundle_add(args, "msgId", tempId);
1122 if (unreadCbMsgCnt > 1) {
1123 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
1124 if (noti_err != NOTIFICATION_ERROR_NONE) {
1125 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
1128 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1130 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Messages", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1132 char unreadCbMsgCntStr[5] = {0,};
1133 snprintf(unreadCbMsgCntStr, 5, "%d", unreadCbMsgCnt);
1134 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadCbMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1136 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, args);
1138 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1139 if (noti_err != NOTIFICATION_ERROR_NONE) {
1140 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
1143 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1145 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1147 notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);
1151 if (displayName[0] == '\0')
1152 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1154 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1156 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1159 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
1162 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
1165 notification_set_led(noti, NOTIFICATION_LED_OP_ON, 0x00);
1168 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK);
1170 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR);
1172 if (noti_err != NOTIFICATION_ERROR_NONE) {
1173 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
1177 noti_err = notification_update(noti);
1178 if (noti_err != NOTIFICATION_ERROR_NONE) {
1179 MSG_DEBUG("Fail to notification_update");
1182 noti_err = notification_insert(noti, ¬iCbId);
1183 if (noti_err != NOTIFICATION_ERROR_NONE) {
1184 MSG_DEBUG("Fail to notification_insert");
1187 if (MsgSettingSetInt(CB_NOTI_PRIV_ID, notiCbId) != MSG_SUCCESS)
1188 MSG_DEBUG("MsgSettingSetInt fail: CB_NOTI_PRIV_ID");
1189 MSG_DEBUG("Insert notiCbId [%d]", notiCbId);
1192 noti_err = notification_free(noti);
1193 if (noti_err != NOTIFICATION_ERROR_NONE) {
1194 MSG_DEBUG("Fail to notification_free");
1205 msg_error_t MsgCleanAndResetNoti()
1207 msg_error_t err = MSG_SUCCESS;
1208 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1210 noti_err = notification_delete_all_by_type("8r4r5ddzzn.Messages", NOTIFICATION_TYPE_NOTI);
1211 if (noti_err != NOTIFICATION_ERROR_NONE) {
1212 MSG_DEBUG("Fail to notification_delete_all_by_type noti_err [%d]", noti_err);
1215 err = MsgRefreshNoti(false);
1216 if (err != MSG_SUCCESS) {
1217 MSG_DEBUG("Fail to MsgRefreshNoti : [err=%d]", err);
1220 err = MsgRefreshCBNoti(false);
1221 if (err != MSG_SUCCESS) {
1222 MSG_DEBUG("Fail to MsgRefreshCBNoti : [err=%d]", err);
1229 msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg)
1231 notification_h noti = NULL;
1232 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1234 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
1236 MSG_DEBUG("notification_new is failed.");
1237 return MSG_ERR_UNKNOWN;
1240 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
1241 if (noti_err != NOTIFICATION_ERROR_NONE) {
1242 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
1245 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
1246 if (noti_err != NOTIFICATION_ERROR_NONE) {
1247 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
1250 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
1251 if (noti_err != NOTIFICATION_ERROR_NONE) {
1252 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
1255 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER);
1256 if (noti_err != NOTIFICATION_ERROR_NONE) {
1257 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
1260 noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
1261 if (noti_err != NOTIFICATION_ERROR_NONE)
1262 MSG_DEBUG("Fail to notification_set_display_applist");
1264 noti_err = notification_insert(noti, NULL);
1265 if (noti_err != NOTIFICATION_ERROR_NONE) {
1266 MSG_DEBUG("Fail to notification_insert");
1269 noti_err = notification_free(noti);
1270 if (noti_err != NOTIFICATION_ERROR_NONE) {
1271 MSG_DEBUG("Fail to notification_free");
1278 msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)
1284 msg_error_t MsgClearVoiceNoti(MSG_SUB_TYPE_T subType)
1288 msg_error_t err = MSG_SUCCESS;
1290 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1292 if (subType == MSG_MWI_VOICE_SMS) {
1293 notiId = MsgSettingGetInt(VOICE_NOTI_ID_1);
1295 return MSG_ERR_UNKNOWN;
1299 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiId);
1300 if (noti_err != NOTIFICATION_ERROR_NONE) {
1301 MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1302 err = MSG_ERR_UNKNOWN;
1308 if (subType == MSG_MWI_VOICE_SMS) {
1309 if (MsgSettingSetInt(VOICE_NOTI_ID_1, notiId) == MSG_SUCCESS)
1310 MSG_DEBUG("Insert VOICE_NOTI_ID_1 [%d]", notiId);
1312 MSG_DEBUG("MsgSettingSetInt fail: VOICE_NOTI_ID_1");