2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.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>
29 /*==================================================================================================
30 FUNCTION IMPLEMENTATION
31 ==================================================================================================*/
32 msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
35 int notiPrivId = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
37 notification_h noti = NULL;
38 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
42 msg_thread_id_t threadId = 0;
45 char addressVal[MAX_ADDRESS_VAL_LEN+1];
46 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
47 char displayName[MAX_DISPLAY_NAME_LEN+1];
48 char thumbPath[MAX_IMAGE_PATH_LEN+1];
49 char sqlQuery[MAX_QUERY_LEN+1];
51 memset(tempId, 0x00, sizeof(tempId));
52 memset(addressVal, 0x00, sizeof(addressVal));
53 memset(firstName, 0x00, sizeof(firstName));
54 memset(lastName, 0x00, sizeof(lastName));
55 memset(displayName, 0x00, sizeof(displayName));
56 memset(thumbPath, 0x00, sizeof(thumbPath));
57 memset(sqlQuery, 0x00, sizeof(sqlQuery));
59 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.DISPLAY_TIME, A.CONTACT_ID, A.IMAGE_PATH \
60 FROM %s A, %s B WHERE B.MSG_ID=%d AND A.CONV_ID=B.CONV_ID;",
61 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
63 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
64 return MSG_ERR_DB_PREPARE;
66 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
67 threadId = pDbHandle->columnInt(0);
69 if (pDbHandle->columnText(1) != NULL)
70 strncpy(addressVal, (char*)pDbHandle->columnText(1), MAX_ADDRESS_VAL_LEN);
73 char *pTempDisplayName = (char *)pDbHandle->columnText(2);
74 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
75 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
77 if (pDbHandle->columnText(3) != NULL)
78 strncpy(firstName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
80 if (pDbHandle->columnText(4) != NULL)
81 strncpy(lastName, (char*)pDbHandle->columnText(4), MAX_DISPLAY_NAME_LEN);
83 int order = MsgGetContactNameOrder();
86 if (firstName[0] != '\0') {
87 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
90 if (lastName[0] != '\0') {
91 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
92 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
94 } else if (order == 1) {
95 if (lastName[0] != '\0') {
96 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
97 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
100 if (firstName[0] != '\0') {
101 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
106 msgTime = (time_t)pDbHandle->columnInt(5);
108 contactId = pDbHandle->columnInt(6);
110 strncpy(thumbPath, (char*)pDbHandle->columnText(7), MAX_IMAGE_PATH_LEN);
112 pDbHandle->finalizeQuery();
113 return MSG_ERR_DB_STEP;
116 pDbHandle->finalizeQuery();
119 args = bundle_create();
121 if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_CB_SMS) {
123 noti = notification_create(NOTIFICATION_TYPE_NOTI);
125 MSG_DEBUG("notification_new is failed.");
127 return MSG_ERR_UNKNOWN;
130 noti_err = notification_set_application(noti, "org.tizen.message");
131 if (noti_err != NOTIFICATION_ERROR_NONE) {
132 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
134 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
135 if (noti_err != NOTIFICATION_ERROR_NONE) {
136 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
139 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, CB_MSG_ICON_PATH);
140 if (noti_err != NOTIFICATION_ERROR_NONE) {
141 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
144 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "CB Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
146 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New CB Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
148 if (displayName[0] == '\0')
149 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
151 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
153 if (pMsg->msgType.mainType == MSG_SMS_TYPE)
154 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
156 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
159 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
160 memset(&tempId, 0x00, sizeof(tempId));
162 bundle_add(args, "type", "msg_id");
164 snprintf(tempId, 5, "%d", pMsg->msgId);
165 bundle_add(args, "msgId", tempId);
169 noti_err = notification_set_args(noti, args, NULL);
170 if (noti_err != NOTIFICATION_ERROR_NONE) {
171 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
175 noti_err = notification_insert(noti, NULL);
176 if (noti_err != NOTIFICATION_ERROR_NONE) {
177 MSG_DEBUG("Fail to notification_insert");
180 noti_err = notification_free(noti);
181 if (noti_err != NOTIFICATION_ERROR_NONE) {
182 MSG_DEBUG("Fail to notification_free");
186 } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.classType == MSG_CLASS_0) {
188 noti = notification_create(NOTIFICATION_TYPE_NOTI);
190 MSG_DEBUG("notification_new is failed.");
192 return MSG_ERR_UNKNOWN;
195 noti_err = notification_set_application(noti, "org.tizen.msg-ui-class0");
196 if (noti_err != NOTIFICATION_ERROR_NONE) {
197 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
200 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
201 if (noti_err != NOTIFICATION_ERROR_NONE) {
202 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
205 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
207 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New CLASS 0 Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
209 if (displayName[0] == '\0')
210 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
212 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
214 if (pMsg->msgType.mainType == MSG_SMS_TYPE)
215 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
217 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
220 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
221 bundle_add(args, "type", "msg_id");
223 snprintf(tempId, 5, "%d", pMsg->msgId);
224 bundle_add(args, "msgId", tempId);
227 noti_err = notification_set_args(noti, args, NULL);
228 if (noti_err != NOTIFICATION_ERROR_NONE) {
229 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
233 noti_err = notification_insert(noti, NULL);
234 if (noti_err != NOTIFICATION_ERROR_NONE) {
235 MSG_DEBUG("Fail to notification_insert");
238 noti_err = notification_free(noti);
239 if (noti_err != NOTIFICATION_ERROR_NONE) {
240 MSG_DEBUG("Fail to notification_free");
243 } else if (pMsg->msgType.mainType == MSG_SMS_TYPE &&
244 (pMsg->msgType.subType >= MSG_MWI_VOICE_SMS && pMsg->msgType.subType <= MSG_MWI_OTHER_SMS)) {
246 noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, NOTIFICATION_PRIV_ID_NONE);
248 MSG_DEBUG("notification_new is failed.");
250 return MSG_ERR_UNKNOWN;
252 noti_err = notification_set_application(noti, "org.tizen.call");
253 if (noti_err != NOTIFICATION_ERROR_NONE) {
254 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
257 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
258 if (noti_err != NOTIFICATION_ERROR_NONE) {
259 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
262 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, VOICE_MSG_ICON_PATH);
263 if (noti_err != NOTIFICATION_ERROR_NONE) {
264 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
267 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
269 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
271 if (displayName[0] == '\0')
272 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
274 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
276 if (pMsg->msgType.mainType == MSG_SMS_TYPE)
277 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
279 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
282 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
283 memset(&tempId, 0x00, sizeof(tempId));
285 //FIXME :: Temp code for voice number, 2012.08.16 sangkoo.kim
286 bundle_add(args, "launch-type", "MO");
287 bundle_add(args, "number", addressVal);
291 noti_err = notification_set_args(noti, args, NULL);
292 if (noti_err != NOTIFICATION_ERROR_NONE) {
293 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
297 noti_err = notification_insert(noti, NULL);
298 if (noti_err != NOTIFICATION_ERROR_NONE) {
299 MSG_DEBUG("Fail to notification_insert");
302 noti_err = notification_free(noti);
303 if (noti_err != NOTIFICATION_ERROR_NONE) {
304 MSG_DEBUG("Fail to notification_free");
309 int unreadMsgCnt = MsgStoGetUnreadCnt(pDbHandle, MSG_SMS_TYPE);
310 unreadMsgCnt += MsgStoGetUnreadCnt(pDbHandle, MSG_MMS_TYPE);
312 MSG_DEBUG("notiPrivId [%d], unreadMsgCnt [%d]", notiPrivId, unreadMsgCnt);
314 if (notiPrivId > 0) {
315 noti = notification_load(NULL, notiPrivId);
317 MSG_DEBUG("notification_load is failed.");
321 noti = notification_create(NOTIFICATION_TYPE_NOTI);
323 MSG_DEBUG("notification_new is failed.");
325 return MSG_ERR_UNKNOWN;
331 noti_err = notification_set_application(noti, "org.tizen.message");
332 if (noti_err != NOTIFICATION_ERROR_NONE) {
333 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
336 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
337 if (noti_err != NOTIFICATION_ERROR_NONE) {
338 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
342 if (unreadMsgCnt > 1) {
344 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
345 if (noti_err != NOTIFICATION_ERROR_NONE) {
346 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
349 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
351 char unreadMsgCntStr[5] = {0,};
352 snprintf(unreadMsgCntStr, 5, "%d", unreadMsgCnt);
353 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
355 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
357 if (displayName[0] == '\0')
358 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
360 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
362 if (pMsg->msgType.mainType == MSG_SMS_TYPE)
363 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
365 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
368 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
372 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
373 if (noti_err != NOTIFICATION_ERROR_NONE) {
374 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
377 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
379 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
381 if (displayName[0] == '\0')
382 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
384 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
386 if (pMsg->msgType.mainType == MSG_SMS_TYPE)
387 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
389 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
392 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
395 memset(&tempId, 0x00, sizeof(tempId));
397 bundle_add(args, "type", "msg_id");
399 snprintf(tempId, 5, "%d", pMsg->msgId);
400 bundle_add(args, "msgId", tempId);
403 noti_err = notification_set_args(noti, args, NULL);
404 if (noti_err != NOTIFICATION_ERROR_NONE) {
405 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
409 if (notiPrivId > 0) {
410 noti_err = notification_update(noti);
411 if (noti_err != NOTIFICATION_ERROR_NONE) {
412 MSG_DEBUG("Fail to notification_update");
415 noti_err = notification_insert(noti, ¬iPrivId);
416 if (noti_err != NOTIFICATION_ERROR_NONE) {
417 MSG_DEBUG("Fail to notification_insert");
420 MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId);
421 MSG_DEBUG("Insert notiPrivId [%d]", notiPrivId);
424 noti_err = notification_free(noti);
425 if (noti_err != NOTIFICATION_ERROR_NONE) {
426 MSG_DEBUG("Fail to notification_free");
435 msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
438 notification_h noti = NULL;
439 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
442 char addressVal[MAX_ADDRESS_VAL_LEN+1];
443 char displayName[MAX_DISPLAY_NAME_LEN+1];
445 memset(addressVal, 0x00, sizeof(addressVal));
446 memset(displayName, 0x00, sizeof(displayName));
448 snprintf(addressVal, sizeof(addressVal), "%s", pMsg->addressList[0].addressVal);
449 snprintf(displayName, sizeof(displayName), "%s", pMsg->addressList[0].displayName);
451 noti = notification_create(NOTIFICATION_TYPE_NOTI);
453 MSG_DEBUG("notification_create is failed.");
454 return MSG_ERR_UNKNOWN;
457 if (pMsg->msgType.mainType == MSG_SMS_TYPE &&
458 (pMsg->msgType.subType >= MSG_MWI_VOICE_SMS && pMsg->msgType.subType <= MSG_MWI_OTHER_SMS)) {
460 args = bundle_create();
462 noti_err = notification_set_application(noti, "com.samsung.call");
463 if (noti_err != NOTIFICATION_ERROR_NONE) {
464 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
467 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
468 if (noti_err != NOTIFICATION_ERROR_NONE) {
469 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
472 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
474 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Voice Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
476 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, VOICE_MSG_ICON_PATH);
477 if (noti_err != NOTIFICATION_ERROR_NONE) {
478 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
481 //FIXME :: Temp code for voice number, 2012.08.16 sangkoo.kim
482 bundle_add(args, "launch-type", "MO");
483 bundle_add(args, "number", pMsg->addressList[0].addressVal);
485 } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_STATUS_REPORT_SMS) {
487 noti_err = notification_set_application(noti, "com.samsung.message");
488 if (noti_err != NOTIFICATION_ERROR_NONE) {
489 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
492 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
493 if (noti_err != NOTIFICATION_ERROR_NONE) {
494 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
497 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
499 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
501 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
502 if (noti_err != NOTIFICATION_ERROR_NONE) {
503 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
508 MSG_DEBUG("Message type does not match.");
510 noti_err = notification_free(noti);
511 if (noti_err != NOTIFICATION_ERROR_NONE) {
512 MSG_DEBUG("Fail to notification_free");
515 return MSG_ERR_INVALID_PARAMETER;
518 if (displayName[0] == '\0')
519 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
521 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
523 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
526 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, pMsg->displayTime);
529 noti_err = notification_set_args(noti, args, NULL);
530 if (noti_err != NOTIFICATION_ERROR_NONE) {
531 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
535 noti_err = notification_insert(noti, NULL);
536 if (noti_err != NOTIFICATION_ERROR_NONE) {
537 MSG_DEBUG("Fail to notification_insert");
540 noti_err = notification_free(noti);
541 if (noti_err != NOTIFICATION_ERROR_NONE) {
542 MSG_DEBUG("Fail to notification_free");
554 msg_error_t MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, msg_message_id_t msgId, msg_delivery_report_status_t status)
557 notification_h noti = NULL;
558 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
560 char addressVal[MAX_ADDRESS_VAL_LEN+1];
561 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
562 char displayName[MAX_DISPLAY_NAME_LEN+1];
563 char contents[MAX_DISPLAY_NAME_LEN+1];
564 char sqlQuery[MAX_QUERY_LEN+1];
566 memset(addressVal, 0x00, sizeof(addressVal));
567 memset(firstName, 0x00, sizeof(firstName));
568 memset(lastName, 0x00, sizeof(lastName));
569 memset(displayName, 0x00, sizeof(displayName));
570 memset(contents, 0x00, sizeof(contents));
571 memset(sqlQuery, 0x00, sizeof(sqlQuery));
573 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME \
574 FROM %s A, %s B WHERE B.MSG_ID = %d AND A.CONV_ID = B.CONV_ID;",
575 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId);
577 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
578 return MSG_ERR_DB_PREPARE;
580 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
581 if (pDbHandle->columnText(0) != NULL)
582 strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
584 if (pDbHandle->columnText(1) != NULL) {
585 strncpy(displayName, (char*)pDbHandle->columnText(1), MAX_DISPLAY_NAME_LEN);
587 if (pDbHandle->columnText(2) != NULL)
588 strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
590 if (pDbHandle->columnText(3) != NULL)
591 strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
593 int order = MsgGetContactNameOrder();
596 if (firstName[0] != '\0') {
597 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
600 if (lastName[0] != '\0') {
601 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
602 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
604 } else if (order == 1) {
605 if (lastName[0] != '\0') {
606 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
607 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
610 if (firstName[0] != '\0') {
611 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
616 MSG_DEBUG("query : %s", sqlQuery);
618 pDbHandle->finalizeQuery();
620 return MSG_ERR_DB_STEP;
623 pDbHandle->finalizeQuery();
626 noti = notification_create(NOTIFICATION_TYPE_NOTI);
628 MSG_DEBUG("notification_create is failed.");
629 return MSG_ERR_UNKNOWN;
631 noti_err = notification_set_application(noti, "org.tizen.call");
632 if (noti_err != NOTIFICATION_ERROR_NONE) {
633 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
635 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
636 if (noti_err != NOTIFICATION_ERROR_NONE) {
637 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
640 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
641 if (noti_err != NOTIFICATION_ERROR_NONE) {
642 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
645 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
647 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Delivery Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
649 if (displayName[0] == '\0')
650 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
652 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
654 if (status == MSG_DELIVERY_REPORT_SUCCESS)
655 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
657 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deliver Failed.");
659 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
661 noti_err = notification_insert(noti, NULL);
662 if (noti_err != NOTIFICATION_ERROR_NONE) {
663 MSG_DEBUG("Fail to notification_insert");
666 noti_err = notification_free(noti);
667 if (noti_err != NOTIFICATION_ERROR_NONE) {
668 MSG_DEBUG("Fail to notification_free");
675 msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
678 notification_h noti = NULL;
679 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
681 char addressVal[MAX_ADDRESS_VAL_LEN+1];
682 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
683 char displayName[MAX_DISPLAY_NAME_LEN+1];
684 char contents[MAX_DISPLAY_NAME_LEN+1];
685 char sqlQuery[MAX_QUERY_LEN+1];
687 memset(addressVal, 0x00, sizeof(addressVal));
688 memset(firstName, 0x00, sizeof(firstName));
689 memset(lastName, 0x00, sizeof(lastName));
690 memset(displayName, 0x00, sizeof(displayName));
691 memset(contents, 0x00, sizeof(contents));
692 memset(sqlQuery, 0x00, sizeof(sqlQuery));
694 int report_status_type;
695 int report_status_value;
697 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
698 report_status_type = MSG_REPORT_TYPE_DELIVERY;
699 MSG_DEBUG("mms subtype is Delivery Report type");
700 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
701 report_status_type = MSG_REPORT_TYPE_READ;
702 MSG_DEBUG("mms subtype is Read Report type");
704 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
708 MSG_ADDRESS_INFO_S *address_info_s = &pMsg->addressList[0];
709 MSG_DEBUG("address info : %s, type : %d", address_info_s->addressVal, address_info_s->addressType);
711 if (address_info_s->addressType == MSG_ADDRESS_TYPE_PLMN) {
713 if (strlen(address_info_s->addressVal) > MAX_PRECONFIG_NUM) {
714 char newPhoneNum[MAX_PRECONFIG_NUM+1];
716 memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
718 MsgConvertNumber(address_info_s->addressVal, newPhoneNum);
720 snprintf(sqlQuery, sizeof(sqlQuery),
721 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
723 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%%%s' AND B.ADDRESS_VAL LIKE \'%%%s\';"
724 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, newPhoneNum, newPhoneNum);
727 snprintf(sqlQuery, sizeof(sqlQuery),
728 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
730 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE '%s' AND B.ADDRESS_VAL LIKE '%s';"
731 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal);
734 } else if (address_info_s->addressType == MSG_ADDRESS_TYPE_EMAIL) {//check full
735 snprintf(sqlQuery, sizeof(sqlQuery),
736 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
738 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL=\'%s\' AND B.ADDRESS_VAL LIKE \'%s\';"
739 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal, address_info_s->addressVal);
741 snprintf(sqlQuery, sizeof(sqlQuery),
742 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
744 "WHERE B.MSG_ID=%d B.STATUS_TYPE=%d;"
745 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type);
748 MSG_DEBUG("sqlQuery = [%s]", sqlQuery);
750 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
751 return MSG_ERR_DB_PREPARE;
753 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
754 if (pDbHandle->columnText(0) != NULL) {
755 strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
756 MSG_DEBUG("addressVal is [%s]",addressVal);
758 MSG_DEBUG("address Val is Null");
761 char *pTempDisplayName = (char *)pDbHandle->columnText(1);
762 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
763 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
765 if (pDbHandle->columnText(2) != NULL)
766 strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
768 if (pDbHandle->columnText(3) != NULL)
769 strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
771 int order = MsgGetContactNameOrder();
774 if (firstName[0] != '\0') {
775 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
778 if (lastName[0] != '\0') {
779 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
780 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
782 } else if (order == 1) {
783 if (lastName[0] != '\0') {
784 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
785 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
788 if (firstName[0] != '\0') {
789 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
794 report_status_value = pDbHandle->columnInt(4);
795 MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value);
797 MSG_DEBUG("DB Query Result Fail");
798 pDbHandle->finalizeQuery();
799 return MSG_ERR_DB_STEP;
802 pDbHandle->finalizeQuery();
804 noti = notification_create(NOTIFICATION_TYPE_NOTI);
806 MSG_DEBUG("notification_create is failed.");
807 return MSG_ERR_UNKNOWN;
810 noti_err = notification_set_application(noti, "org.tizen.message");
811 if (noti_err != NOTIFICATION_ERROR_NONE) {
812 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
814 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
815 if (noti_err != NOTIFICATION_ERROR_NONE) {
816 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
819 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
820 if (noti_err != NOTIFICATION_ERROR_NONE) {
821 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
824 if (displayName[0] == '\0')
825 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
827 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
830 // notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
833 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
835 switch(report_status_value) {
836 case MSG_DELIVERY_REPORT_NONE:
837 noti_err = notification_free(noti);
838 if (noti_err != NOTIFICATION_ERROR_NONE) {
839 MSG_DEBUG("Fail to notification_free");
842 return MSG_ERR_UNKNOWN;
844 case MSG_DELIVERY_REPORT_EXPIRED:
845 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Expired.");
848 case MSG_DELIVERY_REPORT_REJECTED:
849 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Rejected.");
852 case MSG_DELIVERY_REPORT_DEFERRED:
853 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deferred.");
856 case MSG_DELIVERY_REPORT_UNRECOGNISED:
857 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Unrecognised.");
860 case MSG_DELIVERY_REPORT_INDETERMINATE:
861 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Indeterminate.");
864 case MSG_DELIVERY_REPORT_FORWARDED:
865 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Forwarded.");
868 case MSG_DELIVERY_REPORT_UNREACHABLE:
869 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Unreachable.");
872 case MSG_DELIVERY_REPORT_ERROR:
873 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Error.");
877 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
881 MSG_DEBUG("content text : %s", contents);
883 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
884 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
886 noti_err = notification_insert(noti, NULL);
887 if (noti_err != NOTIFICATION_ERROR_NONE)
888 MSG_DEBUG("Fail to notification_insert");
890 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
892 switch(report_status_value) {
893 case MSG_READ_REPORT_NONE:
894 noti_err = notification_free(noti);
895 if (noti_err != NOTIFICATION_ERROR_NONE)
896 MSG_DEBUG("Fail to notification_free");
898 return MSG_ERR_UNKNOWN;
900 case MSG_READ_REPORT_IS_DELETED:
901 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deleted.");
905 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Read.");
909 MSG_DEBUG("content text : %s", contents);
911 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
913 noti_err = notification_insert(noti, NULL);
914 if (noti_err != NOTIFICATION_ERROR_NONE) {
915 MSG_DEBUG("Fail to notification_insert");
918 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
920 noti_err = notification_free(noti);
921 if (noti_err != NOTIFICATION_ERROR_NONE) {
922 MSG_DEBUG("Fail to notification_free");
927 noti_err = notification_free(noti);
928 if (noti_err != NOTIFICATION_ERROR_NONE) {
929 MSG_DEBUG("Fail to notification_free");
936 msg_error_t MsgRefreshNoti()
939 MsgDbHandler dbhandler;
940 MSG_MESSAGE_INFO_S msg = {0,};
942 int notiPrivId = MsgSettingGetInt(NOTIFICATION_PRIV_ID);
944 notification_h noti = NULL;
945 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
949 msg_thread_id_t threadId = 0;
952 char addressVal[MAX_ADDRESS_VAL_LEN+1];
953 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
954 char displayName[MAX_DISPLAY_NAME_LEN+1];
955 char thumbPath[MAX_IMAGE_PATH_LEN+1];
956 char sqlQuery[MAX_QUERY_LEN+1];
958 memset(tempId, 0x00, sizeof(tempId));
959 memset(addressVal, 0x00, sizeof(addressVal));
960 memset(firstName, 0x00, sizeof(firstName));
961 memset(lastName, 0x00, sizeof(lastName));
962 memset(displayName, 0x00, sizeof(displayName));
963 memset(thumbPath, 0x00, sizeof(thumbPath));
964 memset(sqlQuery, 0x00, sizeof(sqlQuery));
966 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.CONV_ID, A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, \
967 B.DISPLAY_TIME, A.CONTACT_ID, A.IMAGE_PATH, B.MSG_ID, B.MSG_TEXT, B.SUBJECT, B.MAIN_TYPE \
968 FROM %s A, %s B WHERE A.CONV_ID=B.CONV_ID AND B.READ_STATUS=0 AND B.FOLDER_ID=%d ORDER BY B.DISPLAY_TIME, B.MSG_ID ASC;",
969 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, MSG_INBOX_ID);
971 if (dbhandler.prepareQuery(sqlQuery) != MSG_SUCCESS)
972 return MSG_ERR_DB_PREPARE;
974 if (dbhandler.stepQuery() == MSG_ERR_DB_ROW) {
975 threadId = dbhandler.columnInt(0);
977 if (dbhandler.columnText(1) != NULL)
978 strncpy(addressVal, (char*)dbhandler.columnText(1), MAX_ADDRESS_VAL_LEN);
981 char *pTempDisplayName = (char *)dbhandler.columnText(2);
982 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
983 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
985 if (dbhandler.columnText(3) != NULL)
986 strncpy(firstName, (char*)dbhandler.columnText(3), MAX_DISPLAY_NAME_LEN);
988 if (dbhandler.columnText(4) != NULL)
989 strncpy(lastName, (char*)dbhandler.columnText(4), MAX_DISPLAY_NAME_LEN);
991 int order = MsgGetContactNameOrder();
994 if (firstName[0] != '\0') {
995 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
998 if (lastName[0] != '\0') {
999 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
1000 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
1002 } else if (order == 1) {
1003 if (lastName[0] != '\0') {
1004 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
1005 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
1008 if (firstName[0] != '\0') {
1009 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
1014 msgTime = (time_t)dbhandler.columnInt(5);
1016 contactId = dbhandler.columnInt(6);
1018 strncpy(thumbPath, (char*)dbhandler.columnText(7), MAX_IMAGE_PATH_LEN);
1020 msg.msgId = dbhandler.columnInt(8);
1022 strncpy(msg.msgText, (char*)dbhandler.columnText(9), MAX_MSG_TEXT_LEN);
1024 strncpy(msg.subject, (char*)dbhandler.columnText(10), MAX_SUBJECT_LEN);
1026 msg.msgType.mainType = dbhandler.columnInt(11);
1028 MSG_DEBUG("unread message [%d].", msg.msgId);
1031 MSG_DEBUG("No unread message.");
1032 MSG_DEBUG("notiPrivId [%d]", notiPrivId);
1034 dbhandler.finalizeQuery();
1036 // No unread message.
1037 if (notiPrivId > 0) {
1038 notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, notiPrivId);
1039 if (noti_err != NOTIFICATION_ERROR_NONE) {
1040 MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err);
1046 MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId);
1048 return MSG_ERR_DB_STEP;
1051 dbhandler.finalizeQuery();
1054 args = bundle_create();
1056 int unreadMsgCnt = MsgStoGetUnreadCnt(&dbhandler, MSG_SMS_TYPE);
1057 unreadMsgCnt += MsgStoGetUnreadCnt(&dbhandler, MSG_MMS_TYPE);
1059 MSG_DEBUG("notiPrivId [%d], unreadMsgCnt [%d]", notiPrivId, unreadMsgCnt);
1061 if (notiPrivId > 0) {
1062 noti = notification_load(NULL, notiPrivId);
1064 MSG_DEBUG("notification_load is failed.");
1068 noti = notification_create(NOTIFICATION_TYPE_NOTI);
1070 MSG_DEBUG("notification_new is failed.");
1072 return MSG_ERR_UNKNOWN;
1077 noti_err = notification_set_application(noti, "org.tizen.message");
1078 if (noti_err != NOTIFICATION_ERROR_NONE) {
1079 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
1081 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
1082 if (noti_err != NOTIFICATION_ERROR_NONE) {
1083 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
1087 if (unreadMsgCnt > 1) {
1089 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
1090 if (noti_err != NOTIFICATION_ERROR_NONE) {
1091 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
1094 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1096 char unreadMsgCntStr[5] = {0,};
1097 snprintf(unreadMsgCntStr, 5, "%d", unreadMsgCnt);
1098 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1100 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1102 if (displayName[0] == '\0')
1103 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1105 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1107 if (msg.msgType.mainType == MSG_SMS_TYPE)
1108 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2,msg.msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1110 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msg.subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1113 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
1117 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
1118 if (noti_err != NOTIFICATION_ERROR_NONE) {
1119 MSG_DEBUG("Fail to notification_set_layout : %d", noti_err);
1122 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1124 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "New Message", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1126 if (displayName[0] == '\0')
1127 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1129 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1131 if (msg.msgType.mainType == MSG_SMS_TYPE)
1132 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2,msg.msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1134 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_2, msg.subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1137 notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, msgTime);
1140 memset(&tempId, 0x00, sizeof(tempId));
1142 bundle_add(args, "type", "msg_id");
1144 snprintf(tempId, 5, "%d", msg.msgId);
1145 bundle_add(args, "msgId", tempId);
1148 noti_err = notification_set_args(noti, args, NULL);
1149 if (noti_err != NOTIFICATION_ERROR_NONE) {
1150 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
1154 if (notiPrivId > 0) {
1155 noti_err = notification_update(noti);
1156 if (noti_err != NOTIFICATION_ERROR_NONE) {
1157 MSG_DEBUG("Fail to notification_update");
1160 noti_err = notification_insert(noti, ¬iPrivId);
1161 if (noti_err != NOTIFICATION_ERROR_NONE) {
1162 MSG_DEBUG("Fail to notification_insert");
1165 MsgSettingSetInt(NOTIFICATION_PRIV_ID, notiPrivId);
1166 MSG_DEBUG("Insert notiPrivId [%d]", notiPrivId);
1169 noti_err = notification_free(noti);
1170 if (noti_err != NOTIFICATION_ERROR_NONE) {
1171 MSG_DEBUG("Fail to notification_free");
1179 msg_error_t MsgCleanAndResetNoti()
1181 msg_error_t err = MSG_SUCCESS;
1182 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1184 noti_err = notification_delete_all_by_type("msg-server", NOTIFICATION_TYPE_NOTI);
1185 if (noti_err != NOTIFICATION_ERROR_NONE) {
1186 MSG_DEBUG("Fail to notification_delete_all_by_type noti_err [%d]", noti_err);
1187 return MSG_ERR_UNKNOWN;
1190 err = MsgRefreshNoti();
1191 if (err != MSG_SUCCESS) {
1192 MSG_DEBUG("Fail to MsgRefreshNoti");
1198 msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg)
1201 MSG_DEBUG("pTickerMsg [%s]", pTickerMsg);
1202 MSG_DEBUG("pLocaleTickerMsg [%s]", pLocaleTickerMsg);
1204 notification_h noti = NULL;
1205 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1207 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
1209 MSG_DEBUG("notification_new is failed.");
1210 return MSG_ERR_UNKNOWN;
1213 noti_err = notification_set_application(noti, "org.tizen.message");
1214 if (noti_err != NOTIFICATION_ERROR_NONE) {
1215 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
1218 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
1219 if (noti_err != NOTIFICATION_ERROR_NONE) {
1220 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
1223 noti_err = notification_set_text_domain(noti, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
1224 if (noti_err != NOTIFICATION_ERROR_NONE) {
1225 MSG_DEBUG("Fail to notification_set_text_domain.");
1228 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
1229 if (noti_err != NOTIFICATION_ERROR_NONE) {
1230 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
1233 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
1234 if (noti_err != NOTIFICATION_ERROR_NONE) {
1235 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
1238 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER);
1239 if (noti_err != NOTIFICATION_ERROR_NONE) {
1240 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
1243 noti_err = notification_insert(noti, NULL);
1244 if (noti_err != NOTIFICATION_ERROR_NONE) {
1245 MSG_DEBUG("Fail to notification_set_text_domain");
1248 noti_err = notification_free(noti);
1249 if (noti_err != NOTIFICATION_ERROR_NONE) {
1250 MSG_DEBUG("Fail to notification_set_text_domain");
1255 msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt)