Add block number check logic 43/146343/2
authorWootak Jung <wootak.jung@samsung.com>
Mon, 28 Aug 2017 07:30:13 +0000 (16:30 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 28 Aug 2017 07:30:13 +0000 (16:30 +0900)
Change-Id: I3c0cffd75b61440c8871daf51190bc6ed4824db0

common/CMakeLists.txt
common/include/callmgr-util.h
common/src/callmgr-util-ext.c
common/src/callmgr-util.c
packaging/call-manager.spec
service/src/callmgr-core.c

index cf3e1b340962c2a9ede03e48181118a52c6e5b55..6064402aff5b9e1da9bf0c70b2e48d4bd6cb847b 100644 (file)
@@ -22,6 +22,7 @@ pkg_check_modules(common_pkgs REQUIRED
        libsystemd-login
        libtzplatform-config
        capi-system-info
+       phonenumber-utils
 )
 
 FOREACH(flag ${common_pkgs_CFLAGS})
index e6179aa83cc6886b9309728b4bdfe9b35907c745..590697ce1baac79d1f3b45776d0cb81081348d8d 100644 (file)
@@ -146,6 +146,7 @@ int _callmgr_util_launch_ciss(const char* number, int sim_slot);
 int _callmgr_util_is_recording_progress(gboolean *is_recording);
 int _callmgr_util_is_video_recording_progress(gboolean *is_recording);
 
+int _callmgr_util_check_blocking_number(const char *number, gboolean *is_blocked);
 int _callmgr_util_check_disturbing_setting(const char *number, gboolean *is_do_not_disturb);
 
 gboolean _callmgr_util_check_access_control(cynara *p_cynara, GDBusMethodInvocation *invoc, const char *label, const char *perm);
index 630a7c3d948c338a93e8f0d84bc07b59fdb08911..03dba0303878d41f72c50eef2a34644b6aa93e2b 100644 (file)
@@ -50,6 +50,11 @@ int _callmgr_util_is_video_recording_progress(gboolean *is_recording)
        return 0;
 }
 
+/*
+ * Please consider to use _callmgr_util_check_blocking_number() instead of this function.
+ * Since tizen 4.0, phonenumber-utils provides this feature.
+ * http://mosaic.sec.samsung.net/club/club.menu.bbs.read.screen?p_club_id=1230&p_menu_id=62&p_group_id=58&message_id=6591434
+ */
 int _callmgr_util_check_block_mode_num(const char *str_num, gboolean *is_blocked)
 {
        int result = 0;
index ca68b093ddaa3a58187147b34524b6ccdf1fcc2b..702393ace8b565ea6043eeebda5b86ecb7816f9c 100644 (file)
@@ -35,6 +35,7 @@
 #include <systemd/sd-login.h>
 #include <tzplatform_config.h>
 #include <system_info.h>
+#include <phone_number.h>
 
 #include "callmgr-util.h"
 #include "callmgr-log.h"
@@ -867,6 +868,30 @@ int _callmgr_util_launch_ciss(const char* number, int sim_slot)
        return 0;
 }
 
+int _callmgr_util_check_blocking_number(const char *number, gboolean *is_blocked)
+{
+       int ret = 0;
+       phone_number_blocking_rule_h rule = NULL;
+
+       dbg("_callmgr_util_check_blocking_number");
+       if (!number || !is_blocked) {
+               err("Invalid parameter!!!");
+               return 0;
+       }
+
+       ret = phone_number_connect();
+       if (ret != PHONE_NUMBER_ERROR_NONE) {
+               err("phone_number_connect() failed!!! (%d,%s)", ret, get_error_message(ret));
+               return 0;
+       }
+
+       phone_number_check_blocking(number, is_blocked);
+       dbg("number[%s] is %s", number, *is_blocked ? "blocked" : "not blocked");
+
+       phone_number_disconnect();
+       return 0;
+}
+
 int _callmgr_util_check_disturbing_setting(const char *number, gboolean *is_do_not_disturb)
 {
        notification_system_setting_h system_setting = NULL;
index d92c93f4432a7bb3fef77f4bd06667c109eda778..6c304c4c3fabf1d7413847f928584d0d7619cff1 100644 (file)
@@ -1,6 +1,6 @@
 %define major 0
 %define minor 2
-%define patchlevel 26
+%define patchlevel 27
 %define ext_feature 0
 
 Name:           call-manager
@@ -55,6 +55,7 @@ BuildRequires: pkgconfig(cynara-creds-gdbus)
 BuildRequires: pkgconfig(cynara-session)
 BuildRequires: pkgconfig(msg-service)
 BuildRequires: pkgconfig(libsystemd)
+BuildRequires: pkgconfig(phonenumber-utils)
 
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
index c2969c99aa14e24e37d4ffd7ef58a9e554e2db86..1067c332fc637f2dba580501793dacf953674edb 100644 (file)
@@ -1213,12 +1213,12 @@ static void __callmgr_core_process_telephony_events(cm_telephony_event_type_e ev
                if (call) {
                        char *number = NULL;
                        _callmgr_telephony_get_call_number(call, &number);
-                       gboolean is_blocked_num = FALSE;
                        gboolean is_rec_blocked = FALSE;
                        gboolean is_bike_mode_enabled = FALSE;
                        gboolean is_low_battery = FALSE;
                        int call_cnt = -1;
                        gboolean is_do_not_disturb = FALSE;
+                       gboolean is_blocked = FALSE;
 
                        _callmgr_telephony_get_call_type(call, &call_type);
                        __callmgr_core_convert_tel_call_type(call_type, &cm_call_type);
@@ -1231,14 +1231,14 @@ static void __callmgr_core_process_telephony_events(cm_telephony_event_type_e ev
                                return;
                        }
 
-                       _callmgr_util_check_block_mode_num(number, &is_blocked_num);
+                       _callmgr_util_check_blocking_number(number, &is_blocked);
                        _callmgr_vconf_is_recording_reject_enabled(&is_rec_blocked);
                        _callmgr_vconf_is_bike_mode_enabled(&is_bike_mode_enabled);
                        _callmgr_vconf_is_low_battery(&is_low_battery);
 
                        _callmgr_util_check_disturbing_setting(number, &is_do_not_disturb);
                        _callmgr_telephony_get_call_count(core_data->telephony_handle, &call_cnt);
-                       if ((is_blocked_num == TRUE)
+                       if ((is_blocked == TRUE)
                                || (is_rec_blocked == TRUE)
                                || (is_do_not_disturb == TRUE)
                                || ((is_bike_mode_enabled == TRUE) && (call_cnt > 1))   // if 2nd incoming call