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 "MsgNotificationWrapper.h"
24 #include <notification.h>
27 /*==================================================================================================
28 FUNCTION IMPLEMENTATION
29 ==================================================================================================*/
30 msg_error_t MsgInsertNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
32 notification_h noti = NULL;
33 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
37 msg_thread_id_t threadId = 0;
40 char addressVal[MAX_ADDRESS_VAL_LEN+1];
41 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
42 char displayName[MAX_DISPLAY_NAME_LEN+1];
43 char thumbPath[MAX_IMAGE_PATH_LEN+1];
44 char sqlQuery[MAX_QUERY_LEN+1];
46 memset(tempId, 0x00, sizeof(tempId));
47 memset(addressVal, 0x00, sizeof(addressVal));
48 memset(firstName, 0x00, sizeof(firstName));
49 memset(lastName, 0x00, sizeof(lastName));
50 memset(displayName, 0x00, sizeof(displayName));
51 memset(thumbPath, 0x00, sizeof(thumbPath));
52 memset(sqlQuery, 0x00, sizeof(sqlQuery));
54 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 \
55 FROM %s A, %s B WHERE B.MSG_ID=%d AND A.CONV_ID=B.CONV_ID;",
56 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, pMsg->msgId);
58 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
59 return MSG_ERR_DB_PREPARE;
61 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
62 threadId = pDbHandle->columnInt(0);
64 if (pDbHandle->columnText(1) != NULL)
65 strncpy(addressVal, (char*)pDbHandle->columnText(1), MAX_ADDRESS_VAL_LEN);
68 char *pTempDisplayName = (char *)pDbHandle->columnText(2);
69 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
70 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
72 if (pDbHandle->columnText(3) != NULL)
73 strncpy(firstName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
75 if (pDbHandle->columnText(4) != NULL)
76 strncpy(lastName, (char*)pDbHandle->columnText(4), MAX_DISPLAY_NAME_LEN);
78 int order = MsgGetContactNameOrder();
81 if (firstName[0] != '\0') {
82 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
85 if (lastName[0] != '\0') {
86 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
87 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
89 } else if (order == 1) {
90 if (lastName[0] != '\0') {
91 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
92 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
95 if (firstName[0] != '\0') {
96 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
101 msgTime = (time_t)pDbHandle->columnInt(5);
103 contactId = pDbHandle->columnInt(6);
105 strncpy(thumbPath, (char*)pDbHandle->columnText(7), MAX_IMAGE_PATH_LEN);
107 pDbHandle->finalizeQuery();
108 return MSG_ERR_DB_STEP;
111 pDbHandle->finalizeQuery();
114 args = bundle_create();
116 if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.subType == MSG_CB_SMS) {
118 noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, pMsg->msgId);
120 MSG_DEBUG("notification_new is failed.");
122 return MSG_ERR_UNKNOWN;
125 noti_err = notification_set_application(noti, "org.tizen.message");
126 if (noti_err != NOTIFICATION_ERROR_NONE) {
127 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
130 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, CB_MSG_ICON_PATH);
131 if (noti_err != NOTIFICATION_ERROR_NONE) {
132 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
135 memset(&tempId, 0x00, sizeof(tempId));
137 bundle_add(args, "type", "msg_id");
139 snprintf(tempId, 5, "%d", pMsg->msgId);
140 bundle_add(args, "msgId", tempId);
141 } else if (pMsg->msgType.mainType == MSG_SMS_TYPE && pMsg->msgType.classType == MSG_CLASS_0) {
143 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
145 MSG_DEBUG("notification_new is failed.");
147 return MSG_ERR_UNKNOWN;
150 noti_err = notification_set_application(noti, "org.tizen.msg-ui-class0");
151 if (noti_err != NOTIFICATION_ERROR_NONE) {
152 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
155 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
156 if (noti_err != NOTIFICATION_ERROR_NONE) {
157 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
160 bundle_add(args, "type", "msg_id");
162 snprintf(tempId, 5, "%d", pMsg->msgId);
163 bundle_add(args, "msgId", tempId);
164 } else if (pMsg->msgType.mainType == MSG_SMS_TYPE &&
165 (pMsg->msgType.subType >= MSG_MWI_VOICE_SMS && pMsg->msgType.subType <= MSG_MWI_OTHER_SMS)) {
167 noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, NOTIFICATION_PRIV_ID_NONE);
169 MSG_DEBUG("notification_new is failed.");
171 return MSG_ERR_UNKNOWN;
174 noti_err = notification_set_application(noti, "org.tizen.message");
175 if (noti_err != NOTIFICATION_ERROR_NONE) {
176 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
179 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, VOICE_MSG_ICON_PATH);
180 if (noti_err != NOTIFICATION_ERROR_NONE) {
181 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
184 memset(&tempId, 0x00, sizeof(tempId));
186 bundle_add(args, "launch-type", "MO");
187 bundle_add(args, "number", addressVal);
190 MSG_DEBUG("notification_new pMsg->msgId [%d]", pMsg->msgId);
191 noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, pMsg->msgId);
193 MSG_DEBUG("notification_new is failed.");
195 return MSG_ERR_UNKNOWN;
198 noti_err = notification_set_application(noti, "org.tizen.message");
199 if (noti_err != NOTIFICATION_ERROR_NONE) {
200 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
203 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
204 if (noti_err != NOTIFICATION_ERROR_NONE) {
205 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
208 memset(&tempId, 0x00, sizeof(tempId));
210 bundle_add(args, "type", "msg_id");
212 snprintf(tempId, 5, "%d", pMsg->msgId);
213 bundle_add(args, "msgId", tempId);
216 if (displayName[0] == '\0')
217 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
219 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
221 if (pMsg->msgType.mainType == MSG_SMS_TYPE)
222 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
224 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
228 noti_err = notification_set_args(noti, args, NULL);
229 if (noti_err != NOTIFICATION_ERROR_NONE) {
230 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
234 noti_err = notification_set_time(noti, msgTime);
235 if (noti_err != NOTIFICATION_ERROR_NONE) {
236 MSG_DEBUG("Fail to notification_set_time : %d", noti_err);
239 if (thumbPath[0] != '\0') {
240 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, thumbPath);
241 if (noti_err != NOTIFICATION_ERROR_NONE) {
242 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
245 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL_FOR_LOCK, thumbPath);
246 if (noti_err != NOTIFICATION_ERROR_NONE) {
247 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
251 noti_err = notification_insert(noti, NULL);
252 if (noti_err != NOTIFICATION_ERROR_NONE) {
253 MSG_DEBUG("Fail to notification_insert");
256 noti_err = notification_free(noti);
257 if (noti_err != NOTIFICATION_ERROR_NONE) {
258 MSG_DEBUG("Fail to notification_free");
266 msg_error_t MsgInsertNoti(MSG_MESSAGE_INFO_S* pMsg)
268 notification_h noti = NULL;
269 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
272 char addressVal[MAX_ADDRESS_VAL_LEN+1];
273 char displayName[MAX_DISPLAY_NAME_LEN+1];
275 memset(addressVal, 0x00, sizeof(addressVal));
276 memset(displayName, 0x00, sizeof(displayName));
278 snprintf(addressVal, sizeof(addressVal), "%s", pMsg->addressList[0].addressVal);
279 snprintf(displayName, sizeof(displayName), "%s", pMsg->addressList[0].displayName);
281 if (pMsg->msgType.mainType == MSG_SMS_TYPE &&
282 (pMsg->msgType.subType >= MSG_MWI_VOICE_SMS && pMsg->msgType.subType <= MSG_MWI_OTHER_SMS)) {
284 args = bundle_create();
286 noti = notification_new(NOTIFICATION_TYPE_NOTI, 1, NOTIFICATION_PRIV_ID_NONE);
288 MSG_DEBUG("notification_new is failed.");
290 return MSG_ERR_UNKNOWN;
293 noti_err = notification_set_application(noti, "com.samsung.call");
294 if (noti_err != NOTIFICATION_ERROR_NONE) {
295 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
298 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, VOICE_MSG_ICON_PATH);
299 if (noti_err != NOTIFICATION_ERROR_NONE) {
300 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
303 //FIXME :: Temp code for voice number, 2012.08.16 sangkoo.kim
304 bundle_add(args, "launch-type", "MO");
305 bundle_add(args, "number", pMsg->addressList[0].addressVal);
308 return MSG_ERR_INVALID_PARAMETER;
311 if (displayName[0] == '\0')
312 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
314 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
316 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg->msgText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
319 noti_err = notification_set_args(noti, args, NULL);
320 if (noti_err != NOTIFICATION_ERROR_NONE) {
321 MSG_DEBUG("Fail to notification_set_args : %d", noti_err);
325 noti_err = notification_set_time(noti, pMsg->displayTime);
326 if (noti_err != NOTIFICATION_ERROR_NONE) {
327 MSG_DEBUG("Fail to notification_set_time : %d", noti_err);
330 noti_err = notification_insert(noti, NULL);
331 if (noti_err != NOTIFICATION_ERROR_NONE) {
332 MSG_DEBUG("Fail to notification_insert");
335 noti_err = notification_free(noti);
336 if (noti_err != NOTIFICATION_ERROR_NONE) {
337 MSG_DEBUG("Fail to notification_free");
345 msg_error_t MsgInsertSmsReportToNoti(MsgDbHandler *pDbHandle, msg_message_id_t msgId, msg_delivery_report_status_t status)
347 notification_h noti = NULL;
348 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
350 char addressVal[MAX_ADDRESS_VAL_LEN+1];
351 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
352 char displayName[MAX_DISPLAY_NAME_LEN+1];
353 char contents[MAX_DISPLAY_NAME_LEN+1];
354 char sqlQuery[MAX_QUERY_LEN+1];
356 memset(addressVal, 0x00, sizeof(addressVal));
357 memset(firstName, 0x00, sizeof(firstName));
358 memset(lastName, 0x00, sizeof(lastName));
359 memset(displayName, 0x00, sizeof(displayName));
360 memset(contents, 0x00, sizeof(contents));
361 memset(sqlQuery, 0x00, sizeof(sqlQuery));
363 snprintf(sqlQuery, sizeof(sqlQuery), "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME \
364 FROM %s A, %s B WHERE B.MSG_ID = %d AND A.CONV_ID = B.CONV_ID;",
365 MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, msgId);
367 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
368 return MSG_ERR_DB_PREPARE;
370 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
371 if (pDbHandle->columnText(0) != NULL)
372 strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
374 if (pDbHandle->columnText(1) != NULL) {
375 strncpy(displayName, (char*)pDbHandle->columnText(1), MAX_DISPLAY_NAME_LEN);
377 if (pDbHandle->columnText(2) != NULL)
378 strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
380 if (pDbHandle->columnText(3) != NULL)
381 strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
383 int order = MsgGetContactNameOrder();
386 if (firstName[0] != '\0') {
387 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
390 if (lastName[0] != '\0') {
391 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
392 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
394 } else if (order == 1) {
395 if (lastName[0] != '\0') {
396 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
397 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
400 if (firstName[0] != '\0') {
401 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
406 MSG_DEBUG("query : %s", sqlQuery);
408 pDbHandle->finalizeQuery();
410 return MSG_ERR_DB_STEP;
413 pDbHandle->finalizeQuery();
416 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
418 MSG_DEBUG("notification_new is failed.");
419 return MSG_ERR_UNKNOWN;
422 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
423 if (noti_err != NOTIFICATION_ERROR_NONE) {
424 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
427 if (displayName[0] == '\0')
428 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
430 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
433 if (status == MSG_DELIVERY_REPORT_SUCCESS)
434 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
436 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deliver Failed.");
438 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
440 noti_err = notification_insert(noti, NULL);
441 if (noti_err != NOTIFICATION_ERROR_NONE) {
442 MSG_DEBUG("Fail to notification_insert");
445 noti_err = notification_free(noti);
446 if (noti_err != NOTIFICATION_ERROR_NONE) {
447 MSG_DEBUG("Fail to notification_free");
454 msg_error_t MsgInsertMmsReportToNoti(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S* pMsg)
456 notification_h noti = NULL;
457 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
459 char addressVal[MAX_ADDRESS_VAL_LEN+1];
460 char firstName[MAX_DISPLAY_NAME_LEN+1], lastName[MAX_DISPLAY_NAME_LEN+1];
461 char displayName[MAX_DISPLAY_NAME_LEN+1];
462 char contents[MAX_DISPLAY_NAME_LEN+1];
463 char sqlQuery[MAX_QUERY_LEN+1];
465 memset(addressVal, 0x00, sizeof(addressVal));
466 memset(firstName, 0x00, sizeof(firstName));
467 memset(lastName, 0x00, sizeof(lastName));
468 memset(displayName, 0x00, sizeof(displayName));
469 memset(contents, 0x00, sizeof(contents));
470 memset(sqlQuery, 0x00, sizeof(sqlQuery));
472 int report_status_type;
473 int report_status_value;
475 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
476 report_status_type = MSG_REPORT_TYPE_DELIVERY;
477 MSG_DEBUG("mms subtype is Delivery Report type");
478 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
479 report_status_type = MSG_REPORT_TYPE_READ;
480 MSG_DEBUG("mms subtype is Read Report type");
482 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
486 MSG_ADDRESS_INFO_S *address_info_s = &pMsg->addressList[0];
487 MSG_DEBUG("address info : %s, type : %d", address_info_s->addressVal, address_info_s->addressType);
489 if (address_info_s->addressType == MSG_ADDRESS_TYPE_PLMN) {//FIXME: compare 10 char of address
490 snprintf(sqlQuery, sizeof(sqlQuery),
491 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
493 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL LIKE \'%s\';"
494 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal);
495 } else if (address_info_s->addressType == MSG_ADDRESS_TYPE_EMAIL) {//check full
496 snprintf(sqlQuery, sizeof(sqlQuery),
497 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
499 "WHERE B.MSG_ID=%d AND B.STATUS_TYPE=%d AND A.ADDRESS_VAL=\'%s\';"
500 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type, address_info_s->addressVal);
502 snprintf(sqlQuery, sizeof(sqlQuery),
503 "SELECT A.ADDRESS_VAL, A.DISPLAY_NAME, A.FIRST_NAME, A.LAST_NAME, B.STATUS "
505 "WHERE B.MSG_ID=%d B.STATUS_TYPE=%d;"
506 , MSGFW_ADDRESS_TABLE_NAME, MSGFW_REPORT_TABLE_NAME, pMsg->msgId, report_status_type);
509 MSG_DEBUG("sqlQuery = [%s]", sqlQuery);
511 if (pDbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
512 return MSG_ERR_DB_PREPARE;
514 if (pDbHandle->stepQuery() == MSG_ERR_DB_ROW) {
515 if (pDbHandle->columnText(0) != NULL) {
516 strncpy(addressVal, (char*)pDbHandle->columnText(0), MAX_ADDRESS_VAL_LEN);
517 MSG_DEBUG("addressVal is [%s]",addressVal);
519 MSG_DEBUG("address Val is Null");
522 char *pTempDisplayName = (char *)pDbHandle->columnText(1);
523 if (pTempDisplayName != NULL && pTempDisplayName[0] != '\0') {
524 strncpy(displayName, pTempDisplayName, MAX_DISPLAY_NAME_LEN);
526 if (pDbHandle->columnText(2) != NULL)
527 strncpy(firstName, (char*)pDbHandle->columnText(2), MAX_DISPLAY_NAME_LEN);
529 if (pDbHandle->columnText(3) != NULL)
530 strncpy(lastName, (char*)pDbHandle->columnText(3), MAX_DISPLAY_NAME_LEN);
532 int order = MsgGetContactNameOrder();
535 if (firstName[0] != '\0') {
536 strncpy(displayName, firstName, MAX_DISPLAY_NAME_LEN);
539 if (lastName[0] != '\0') {
540 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
541 strncat(displayName, lastName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
543 } else if (order == 1) {
544 if (lastName[0] != '\0') {
545 strncpy(displayName, lastName, MAX_DISPLAY_NAME_LEN);
546 strncat(displayName, " ", MAX_DISPLAY_NAME_LEN-strlen(displayName));
549 if (firstName[0] != '\0') {
550 strncat(displayName, firstName, MAX_DISPLAY_NAME_LEN-strlen(displayName));
555 report_status_value = pDbHandle->columnInt(4);
558 MSG_DEBUG("DB Query Result Fail");
559 pDbHandle->finalizeQuery();
560 return MSG_ERR_DB_STEP;
563 pDbHandle->finalizeQuery();
565 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
567 MSG_DEBUG("notification_new is failed.");
568 return MSG_ERR_UNKNOWN;
571 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NOTI_MSG_ICON_PATH);
572 if (noti_err != NOTIFICATION_ERROR_NONE) {
573 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
576 if (displayName[0] == '\0')
577 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, addressVal, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
579 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, displayName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
581 if (pMsg->msgType.subType == MSG_DELIVERYIND_MMS) {
583 switch(report_status_value) {
584 case MSG_DELIVERY_REPORT_NONE:
585 noti_err = notification_free(noti);
586 if (noti_err != NOTIFICATION_ERROR_NONE) {
587 MSG_DEBUG("Fail to notification_free");
590 return MSG_ERR_UNKNOWN;
592 case MSG_DELIVERY_REPORT_EXPIRED:
593 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Expired.");
596 case MSG_DELIVERY_REPORT_REJECTED:
597 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Rejected.");
600 case MSG_DELIVERY_REPORT_DEFERRED:
601 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deferred.");
604 case MSG_DELIVERY_REPORT_UNRECOGNISED:
605 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Unrecognised.");
608 case MSG_DELIVERY_REPORT_INDETERMINATE:
609 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Indeterminate.");
612 case MSG_DELIVERY_REPORT_FORWARDED:
613 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Forwarded.");
616 case MSG_DELIVERY_REPORT_UNREACHABLE:
617 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Unreachable.");
620 case MSG_DELIVERY_REPORT_ERROR:
621 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Error.");
625 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Delivered.");
628 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
629 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
631 noti_err = notification_insert(noti, NULL);
632 if (noti_err != NOTIFICATION_ERROR_NONE)
633 MSG_DEBUG("Fail to notification_insert");
635 } else if (pMsg->msgType.subType == MSG_READORGIND_MMS) {
637 switch(report_status_value) {
638 case MSG_READ_REPORT_NONE:
639 noti_err = notification_free(noti);
640 if (noti_err != NOTIFICATION_ERROR_NONE)
641 MSG_DEBUG("Fail to notification_free");
643 return MSG_ERR_UNKNOWN;
645 case MSG_READ_REPORT_IS_DELETED:
646 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Deleted.");
650 snprintf(contents, MAX_DISPLAY_NAME_LEN, "Read.");
653 notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, contents, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
655 noti_err = notification_insert(noti, NULL);
656 if (noti_err != NOTIFICATION_ERROR_NONE) {
657 MSG_DEBUG("Fail to notification_insert");
660 MSG_DEBUG("No matching subtype. subtype [%d]", pMsg->msgType.subType);
662 noti_err = notification_free(noti);
663 if (noti_err != NOTIFICATION_ERROR_NONE) {
664 MSG_DEBUG("Fail to notification_free");
669 noti_err = notification_free(noti);
670 if (noti_err != NOTIFICATION_ERROR_NONE) {
671 MSG_DEBUG("Fail to notification_free");
678 msg_error_t MsgDeleteNotiByMsgId(msg_message_id_t msgId)
681 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
683 MSG_DEBUG("notification_delete_by_priv_id msgId [%d]", msgId);
685 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, msgId);
687 if (noti_err != NOTIFICATION_ERROR_NONE) {
688 MSG_DEBUG("Fail to notification_delete_by_priv_id noti_err [%d]", noti_err);
695 msg_error_t MsgDeleteNotiByThreadId(msg_thread_id_t ThreadId)
697 notification_delete_group_by_group_id(NULL, NOTIFICATION_TYPE_NOTI, ThreadId);
703 msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg)
706 MSG_DEBUG("pTickerMsg [%s]", pTickerMsg);
707 MSG_DEBUG("pLocaleTickerMsg [%s]", pLocaleTickerMsg);
709 notification_h noti = NULL;
710 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
712 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
714 MSG_DEBUG("notification_new is failed.");
715 return MSG_ERR_UNKNOWN;
718 noti_err = notification_set_application(noti, "org.tizen.message");
719 if (noti_err != NOTIFICATION_ERROR_NONE) {
720 MSG_DEBUG("Fail to notification_set_application : %d", noti_err);
723 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, NORMAL_MSG_ICON_PATH);
724 if (noti_err != NOTIFICATION_ERROR_NONE) {
725 MSG_DEBUG("Fail to notification_set_image : %d", noti_err);
728 noti_err = notification_set_text_domain(noti, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR);
729 if (noti_err != NOTIFICATION_ERROR_NONE) {
730 MSG_DEBUG("Fail to notification_set_text_domain.");
733 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
734 if (noti_err != NOTIFICATION_ERROR_NONE) {
735 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
738 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, pTickerMsg, pLocaleTickerMsg, NOTIFICATION_VARIABLE_TYPE_NONE);
739 if (noti_err != NOTIFICATION_ERROR_NONE) {
740 MSG_DEBUG("Fail to notification_set_text : %d", noti_err);
743 noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER);
744 if (noti_err != NOTIFICATION_ERROR_NONE) {
745 MSG_DEBUG("Fail to notification_set_display_applist : %d", noti_err);
748 noti_err = notification_insert(noti, NULL);
749 if (noti_err != NOTIFICATION_ERROR_NONE) {
750 MSG_DEBUG("Fail to notification_set_text_domain");
753 noti_err = notification_free(noti);
754 if (noti_err != NOTIFICATION_ERROR_NONE) {
755 MSG_DEBUG("Fail to notification_set_text_domain");