set new bundle key to tell if notification is report noti or not 44/87344/3
authorKyeonghun Lee <kh9090.lee@samsung.com>
Wed, 7 Sep 2016 11:41:20 +0000 (20:41 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 9 Sep 2016 00:50:50 +0000 (09:50 +0900)
Change-Id: I9bb38ad122abc6cc1eba79304b7cd1b1e0d015af
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
manager/src/msg-manager-notification.cpp

index c21f375..d4f2256 100644 (file)
@@ -139,8 +139,6 @@ void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
 
 void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback);
 
-bool isExistAddressInReportTable(const char *addr);
-
 /* Wrapper */
 void createServiceHandle(app_control_h *svc_h);
 void setServiceAppId(app_control_h svc_h, const char* app_id);
@@ -180,55 +178,6 @@ bool _is_valid_email(char *pAddress)
 }
 
 
-bool isExistAddressInReportTable(const char *addr)
-{
-       char sqlQuery[MAX_QUERY_LEN+1];
-       int rowCnt = 0, colCnt = 0;
-       char **db_res = NULL;
-       int msg_err = 0;
-
-       char *normal_addr = msg_mgr_normalize_number((char *)addr);
-
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr);
-
-       msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
-               return false;
-       }
-
-       msg_err = msg_db_free(msg_handle, db_res);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
-               return false;
-       }
-
-       if (rowCnt > 0)
-               return true;
-
-       memset(sqlQuery, 0x00, sizeof(sqlQuery));
-       snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr);
-
-       msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
-               return false;
-       }
-
-       msg_err = msg_db_free(msg_handle, db_res);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
-               return false;
-       }
-
-       if (rowCnt > 0)
-               return true;
-
-       return false;
-}
-
-
 void MsgMgrInitReportNotiList()
 {
        MSG_MGR_BEGIN();
@@ -256,6 +205,10 @@ void MsgMgrInitReportNotiList()
 
        while (noti_list != NULL) {
                noti = notification_list_get_data(noti_list);
+               if (noti == NULL) {
+                       MSG_MGR_DEBUG("notification_list_get_data() failed!!");
+                       break;
+               }
 
                char tempAddr[MAX_ADDRESS_VAL_LEN+1];
                memset(tempAddr, 0x00, sizeof(tempAddr));
@@ -266,11 +219,14 @@ void MsgMgrInitReportNotiList()
                        break;
                }
 
-               char *addr = NULL;
+               char *is_report_noti = NULL;
+
+               int ret = app_control_get_extra_data(app_control, "is_report_noti", &is_report_noti);
+               if (ret == APP_CONTROL_ERROR_NONE && is_report_noti != NULL && g_strcmp0(is_report_noti, "true") == 0) {
+                       char *addr = NULL;
 
-               int ret = app_control_get_extra_data(app_control, "address", &addr);
-               if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
-                       if (isExistAddressInReportTable(addr)) {
+                       ret = app_control_get_extra_data(app_control, "address", &addr);
+                       if (ret == APP_CONTROL_ERROR_NONE && addr != NULL) {
                                report_notification_s *info = new report_notification_s;
                                memset(info, 0x00, sizeof(report_notification_s));
 
@@ -279,12 +235,18 @@ void MsgMgrInitReportNotiList()
 
                                msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info);
                                MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal);
+
+                               g_free(addr);
+                               addr = NULL;
                        }
+               }
 
-                       g_free(addr);
-                       addr = NULL;
+               if (is_report_noti) {
+                       g_free(is_report_noti);
+                       is_report_noti = NULL;
                }
 
+
                noti_list = notification_list_get_next(noti_list);
        }
 
@@ -458,6 +420,7 @@ int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_M
                goto __END_OF_ADD_REPORT_NOTI;
        }
 
+       addServiceExtraData(noti_info.svc_h, "is_report_noti", "true");
        setNotification(noti_h, &noti_info, true);
 
        info->priv_id = noti_info.id;