resolve TSAM-6816: update DB after DPM state changed 69/84569/1
authorKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 19 Aug 2016 09:11:49 +0000 (18:11 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 19 Aug 2016 09:11:49 +0000 (18:11 +0900)
Change-Id: If4984536dd8f79bb06d401f2716b0e5420adfc07
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/CMakeLists.txt
framework/MsgDPMUtils.cpp [new file with mode: 0644]
framework/main.cpp
framework/storage-handler/MsgStorageMessage.cpp
include/framework/MsgDPMUtils.h [new file with mode: 0644]
include/utils/MsgUtilFunction.h
plugin/mms_plugin/CMakeLists.txt
plugin/mms_plugin/MmsPluginInternal.cpp
utils/CMakeLists.txt
utils/MsgUtilFunction.cpp

index 1fc04c9def10b3b9a72b54a98f2258d6be53fae3..1405300b4db2b9ad2e6a367ea9f1ce9b983d0732 100755 (executable)
@@ -131,6 +131,7 @@ INSTALL(TARGETS ${TRANS-MANAGER-LIB} DESTINATION ${LIBDIR} COMPONENT RuntimeLibr
 
 SET(MAIN-SRCS
        ${CMAKE_SOURCE_DIR}/framework/main.cpp
+       ${CMAKE_SOURCE_DIR}/framework/MsgDPMUtils.cpp
 )
 
 INCLUDE_DIRECTORIES(
@@ -142,7 +143,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog vconf)
+pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog vconf dpm)
 
 FOREACH(flag ${main_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/framework/MsgDPMUtils.cpp b/framework/MsgDPMUtils.cpp
new file mode 100644 (file)
index 0000000..8441e73
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+#include "MsgDebug.h"
+#include "MsgStorageHandler.h"
+#include "MsgUtilFunction.h"
+#include "MsgDPMUtils.h"
+
+#include <dpm/restriction.h>
+
+device_policy_manager_h dpm_handle = NULL;
+int dpm_sms_callback_id = 0;
+int dpm_mms_callback_id = 0;
+
+/*==================================================================================================
+                                     FUNCTION IMPLEMENTATION
+==================================================================================================*/
+
+static void dpm_sms_policy_changed_callback(const char* name, const char* object, void *user_data)
+{
+       MSG_INFO("dpm_sms_policy_changed_callback called. name [%s] object [%s]", name, object);
+
+       int ret = 0;
+       int state = 0;
+
+       ret = dpm_restriction_get_messaging_state(dpm_handle, &state);
+       if (ret != DPM_ERROR_NONE) {
+               MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
+               return;
+       }
+
+       msg_set_dpm_policy(MSG_SMS_TYPE, state);
+
+       if (state == 1) {
+               MsgStoUpdateDPMRestrictedStatus(MSG_SMS_TYPE);
+               /* temporal */
+               MsgStoUpdateDPMRestrictedStatus(MSG_MMS_TYPE);
+       }
+}
+
+#if 0
+static void dpm_mms_policy_changed_callback(const char* name, const char* object, void *user_data)
+{
+       MSG_INFO("dpm_mms_policy_changed_callback called. name [%s] object [%s]", name, object);
+
+       int ret = 0;
+       int state = 0;
+
+       ret = dpm_restriction_get_messaging_state(dpm_handle, &dpm_policy_enable[MSG_MMS_TYPE]);
+       if (ret != DPM_ERROR_NONE) {
+               MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
+               return;
+       }
+
+       msg_set_dpm_policy(MSG_MMS_TYPE, state);
+
+       if (state == 1)
+               MsgStoUpdateDPMRestrictedStatus(MSG_MMS_TYPE);
+}
+#endif
+
+void __get_dpm_policy()
+{
+       int ret = 0;
+       int state = 0;
+
+       ret = dpm_restriction_get_messaging_state(dpm_handle, &state);
+       if (ret != DPM_ERROR_NONE) {
+               MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
+               return;
+       }
+
+       MSG_DEBUG("sms policy [%d]", state);
+       msg_set_dpm_policy(MSG_SMS_TYPE, state);
+//     MSG_DEBUG("mms policy [%d]", dpm_policy_enable[MSG_MMS_TYPE]);
+
+       ret = dpm_add_policy_changed_cb(dpm_handle, "messaging", dpm_sms_policy_changed_callback, NULL, &dpm_sms_callback_id);
+       if (ret != DPM_ERROR_NONE) {
+               MSG_ERR("dpm_add_policy_changed_cb failed [%d]", ret);
+               return;
+       }
+}
+
+void msg_init_dpm_policy()
+{
+       MSG_BEGIN();
+
+       int cnt = 5;
+       while (cnt--) {
+               dpm_handle = dpm_manager_create();
+               if (dpm_handle == NULL) {
+                       MSG_ERR("dpm_manager_create() failed");
+               } else {
+                       MSG_DEBUG("dpm_manager_create() success");
+                       __get_dpm_policy();
+                       break;
+               }
+
+               sleep(1);
+       }
+
+       MSG_END();
+}
+
+
+void msg_deinit_dpm_policy()
+{
+       if (dpm_handle)
+               dpm_manager_destroy(dpm_handle);
+
+       if (dpm_sms_callback_id)
+               dpm_remove_policy_changed_cb(dpm_handle, dpm_sms_callback_id);
+
+       if (dpm_mms_callback_id)
+               dpm_remove_policy_changed_cb(dpm_handle, dpm_mms_callback_id);
+}
+
index 73b634744a642010a07bfa36009f74044b8f612c..e33bec5e5f014384099fdf83a85ae6d2198ed8ea 100755 (executable)
@@ -18,6 +18,7 @@
                                          INCLUDE FILES
 ==================================================================================================*/
 #include "MsgCallStatusManager.h"
+#include "MsgDPMUtils.h"
 #include "MsgDebug.h"
 #include "MsgException.h"
 #include "MsgContact.h"
@@ -33,7 +34,6 @@
 #include "MsgStorageTypes.h"
 #include "MsgCmdHandler.h"
 #include "MsgUtilFile.h"
-#include "MsgUtilFunction.h"
 #include "MsgUtilStorage.h"
 #include "MsgNotificationWrapper.h"
 
index b1275f640e4ab9ff1d0f41ee45cd0aeb380b853d..f063392d9ddbf7dfe1adb6f27d00f7239dd9d135 100755 (executable)
@@ -3193,6 +3193,7 @@ msg_error_t MsgStoUpdateDPMRestrictedStatus(MSG_MAIN_TYPE_T msgType)
 
        err = dbHandle->execQuery(sqlQuery);
        if (err == MSG_SUCCESS) {
+               MsgStoUpdateAllAddress();
                MsgTransactionManager::instance()->broadcastStorageChangeCB(err, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
        }
 
diff --git a/include/framework/MsgDPMUtils.h b/include/framework/MsgDPMUtils.h
new file mode 100644 (file)
index 0000000..05eae28
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef MSG_DPM_UTILS_H
+#define MSG_DPM_UTILS_H
+
+/*==================================================================================================
+                                                                                               INCLUDE FILES
+==================================================================================================*/
+#include "MsgInternalTypes.h"
+
+
+/*==================================================================================================
+                                                                                               FUNCTION PROTOTYPES
+==================================================================================================*/
+
+void msg_init_dpm_policy();
+void msg_deinit_dpm_policy();
+
+#endif /* MSG_DPM_UTILS_H */
index a0086a0fac119f970c1234a4ac3dd6aefb0efb77..f5656f1d0c6951b5d3ea216773acda572b37067d 100755 (executable)
@@ -162,9 +162,7 @@ msg_error_t msg_aul_svc_set_operation(bundle *bundle_data, const char *operation
 
 msg_error_t msg_aul_svc_set_uri(bundle *bundle_data, char *uri);
 
-void msg_init_dpm_policy();
-
-void msg_deinit_dpm_policy();
+void msg_set_dpm_policy(int type, int state);
 
 bool msg_check_dpm_policy(int type);
 
index 2c48923a19ab13d5848e97cac6e7256437154a31..fb6b1adf34ea696c03b3bd733428d3d1d075dc72 100755 (executable)
@@ -34,7 +34,6 @@ SET(MMS-PLUGIN-SRCS
 
 INCLUDE_DIRECTORIES(
        ${CMAKE_SOURCE_DIR}/include/common
-       ${CMAKE_SOURCE_DIR}/include/framework
        ${CMAKE_SOURCE_DIR}/include/utils
        ${CMAKE_SOURCE_DIR}/include/externals
        ${CMAKE_SOURCE_DIR}/include/mapi
index ca89aafbd5b3ffa86b19c225f6d9ece568b8cbab..d6e00d8946014257d9a4ca77f90ed791396a3176 100755 (executable)
@@ -24,7 +24,6 @@
 #include "MsgSettingTypes.h"
 #include "MsgMmsMessage.h"
 #include "MsgGconfWrapper.h"
-#include "MsgStorageHandler.h"
 #include "MsgSerialize.h"
 #include "MsgSpamFilter.h"
 #include "MsgUtilMime.h"
index fa9fa468a50b386e59dade491b1e82c2339abf59..c20bbaa6e534a1bdfb06337e81505a9b92521b3f 100755 (executable)
@@ -39,14 +39,13 @@ SET(UTILS-SRCS
 INCLUDE_DIRECTORIES(
        ${CMAKE_SOURCE_DIR}/include/mapi
        ${CMAKE_SOURCE_DIR}/include/common
-       ${CMAKE_SOURCE_DIR}/include/framework
        ${CMAKE_SOURCE_DIR}/include/utils
        ${CMAKE_SOURCE_DIR}/vobject-engine/include
 )
 
 INCLUDE(FindPkgConfig)
 
-SET(PKG_MODULES glib-2.0 vconf dlog libxml-2.0 boost json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util aul sqlite3 capi-media-metadata-extractor icu-uc libsystemd-login libsmack csr dpm)
+SET(PKG_MODULES glib-2.0 vconf dlog libxml-2.0 boost json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util aul sqlite3 capi-media-metadata-extractor icu-uc libsystemd-login libsmack csr)
 pkg_check_modules(utils_pkgs REQUIRED ${PKG_MODULES})
 
 FOREACH(flag ${utils_pkgs_CFLAGS})
index 4df7ace60265407ef9ee139c9a65cd1365fab479..fc6fd6fb05eb56085fbccdaa6418af7b30506850 100755 (executable)
@@ -30,7 +30,6 @@
 #include <ctype.h>
 #include <aul.h>
 #include <aul_svc.h>
-#include <dpm/restriction.h>
 
 typedef struct _msg_launch_app_data {
        char *app_id;
@@ -56,11 +55,6 @@ static int dpm_policy_enable[] = {
                [MSG_MMS_TYPE] = 1,
 };
 
-device_policy_manager_h dpm_handle = NULL;
-bool is_dpm_init = false;
-int dpm_sms_callback_id = 0;
-int dpm_mms_callback_id = 0;
-
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
 static int phonenumberMinMatchDigit = -1;
 #endif
@@ -1311,91 +1305,14 @@ msg_error_t msg_aul_svc_set_uri(bundle *bundle_data, char *uri)
 }
 
 
-void dpm_sms_policy_changed_callback(const char* name, const char* object, void *user_data)
+void msg_set_dpm_policy(int type, int state)
 {
-       MSG_INFO("dpm_sms_policy_changed_callback called. name [%s] object [%s]", name, object);
-
-       int ret = 0;
-
-       ret = dpm_restriction_get_messaging_state(dpm_handle, &dpm_policy_enable[MSG_SMS_TYPE - 1]);
-       if (ret != DPM_ERROR_NONE) {
-               MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
-               return;
-       }
+       dpm_policy_enable[type] = state;
 }
 
 
-void dpm_mms_policy_changed_callback(const char* name, const char* object, void *user_data)
-{
-       MSG_INFO("dpm_mms_policy_changed_callback called. name [%s] object [%s]", name, object);
-
-       int ret = 0;
-
-       ret = dpm_restriction_get_messaging_state(dpm_handle, &dpm_policy_enable[MSG_MMS_TYPE - 1]);
-       if (ret != DPM_ERROR_NONE) {
-               MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
-               return;
-       }
-}
-
-
-static bool __get_dpm_policy()
-{
-       int ret = 0;
-
-       ret = dpm_restriction_get_messaging_state(dpm_handle, &dpm_policy_enable[MSG_SMS_TYPE]);
-       if (ret != DPM_ERROR_NONE) {
-               MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
-               return false;
-       }
-
-       MSG_DEBUG("sms policy [%d]", dpm_policy_enable[MSG_SMS_TYPE]);
-       MSG_DEBUG("mms policy [%d]", dpm_policy_enable[MSG_MMS_TYPE]);
-
-       ret = dpm_add_policy_changed_cb(dpm_handle, "messaging", dpm_sms_policy_changed_callback, NULL, &dpm_sms_callback_id);
-       if (ret != DPM_ERROR_NONE) {
-               MSG_ERR("dpm_add_policy_changed_cb failed [%d]", ret);
-               return false;
-       }
-
-       return true;
-}
-
-void msg_init_dpm_policy()
-{
-       MSG_BEGIN();
-
-       dpm_handle = dpm_manager_create();
-       if (dpm_handle == NULL) {
-               MSG_ERR("dpm_manager_create() failed");
-               return;
-       }
-
-       is_dpm_init = __get_dpm_policy();
-
-       MSG_END();
-}
-
-
-void msg_deinit_dpm_policy()
-{
-       if (dpm_handle)
-               dpm_manager_destroy(dpm_handle);
-
-       if (dpm_sms_callback_id)
-               dpm_remove_policy_changed_cb(dpm_handle, dpm_sms_callback_id);
-
-       if (dpm_mms_callback_id)
-               dpm_remove_policy_changed_cb(dpm_handle, dpm_mms_callback_id);
-
-       is_dpm_init = false;
-}
-
 bool msg_check_dpm_policy(int type)
 {
-       if (is_dpm_init == false)
-               msg_init_dpm_policy();
-
        return dpm_policy_enable[MSG_SMS_TYPE];
 //     return dpm_policy_enable[type];
 }