use phone_number_check_blocking() to check blocked number 01/135101/2
authorKyeonghun Lee <kh9090.lee@samsung.com>
Wed, 21 Jun 2017 02:32:54 +0000 (11:32 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 23 Jun 2017 04:18:20 +0000 (13:18 +0900)
Change-Id: I1e776880ae60d1c7ff8c688fedc2c014ce6870f0
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
externals/CMakeLists.txt
externals/MsgSpamFilter.cpp
packaging/msg-service.spec

index f11b600..cedc0fd 100755 (executable)
@@ -31,7 +31,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(externals_pkgs REQUIRED glib-2.0 alarm-service lbs-dbus capi-system-device motion)
+pkg_check_modules(externals_pkgs REQUIRED glib-2.0 alarm-service lbs-dbus capi-system-device motion phonenumber-utils)
 
 FOREACH(flag ${externals_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index c0f543d..981f149 100755 (executable)
@@ -21,6 +21,8 @@
 #include "MsgGconfWrapper.h"
 #include "MsgSpamFilter.h"
 
+#include <phone_number.h>
+
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
 ==================================================================================================*/
@@ -86,13 +88,23 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
           Check Filter by Address
        ========================================================================*/
        int rowCnt = 0;
+       char sqlQuery[MAX_QUERY_LEN+1];
 
        MSG_SEC_DEBUG("pMsg->addressList[0].addressVal [%s]", pMsgInfo->addressList[0].addressVal);
+#if 0
+       bool is_blocking = false;
+       int ret = phone_number_check_blocking(pMsgInfo->addressList[0].addressVal, &is_blocking);
+       if (ret != PHONE_NUMBER_ERROR_NONE)
+               MSG_WARN("phone_number_check_blocking failed! [%d]", ret);
 
-       char sqlQuery[MAX_QUERY_LEN+1];
+       if (is_blocking == true) {
+               MSG_SEC_DEBUG("Msg is Filtered by Address : [%s]", pMsgInfo->addressList[0].addressVal);
+               pMsgInfo->folderId = MSG_SPAMBOX_ID;
+               return true;
+       }
 
+#else /* use phonenumber-utils API */
        memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
        snprintf(sqlQuery, sizeof(sqlQuery), "SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND '%s' LIKE (CASE WHEN LENGTH(FILTER_VALUE) > %d-1 THEN '%%' || SUBSTR(FILTER_VALUE, LENGTH(FILTER_VALUE)-%d+1) ELSE FILTER_VALUE END) AND FILTER_ACTIVE = 1 \
                        UNION SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND '%s' LIKE SUBSTR(FILTER_VALUE, 1) || '%%' AND FILTER_ACTIVE = 1 \
                        UNION SELECT FILTER_ID FROM %s WHERE FILTER_TYPE = %d AND '%s' LIKE '%%' || SUBSTR(FILTER_VALUE, 1) || '%%' AND FILTER_ACTIVE = 1 \
@@ -113,7 +125,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
                MSG_SEC_DEBUG("Msg is NOT Filtered by Address : [%s]", pMsgInfo->addressList[0].addressVal);
                pDbHandle->freeTable();
        }
-
+#endif
        /*========================================================================
           Check Filter by Subject
        ========================================================================*/
index 4536fd0..a052ce4 100755 (executable)
@@ -48,6 +48,7 @@ BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(libwbxml2)
 BuildRequires: pkgconfig(motion)
+BuildRequires: pkgconfig(phonenumber-utils)
 BuildRequires: pkgconfig(sqlite3)
 BuildRequires: pkgconfig(tapi)
 BuildRequires: pkgconfig(vconf)