2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
17 /*==================================================================================================
19 ==================================================================================================*/
21 #include "MsgStorageHandler.h"
22 #include "MsgUtilFunction.h"
23 #include "MsgDPMUtils.h"
25 #include <dpm/restriction.h>
27 device_policy_manager_h dpm_handle = NULL;
28 int dpm_sms_callback_id = 0;
29 int dpm_mms_callback_id = 0;
31 /*==================================================================================================
32 FUNCTION IMPLEMENTATION
33 ==================================================================================================*/
35 static void dpm_sms_policy_changed_callback(const char* name, const char* object, void *user_data)
37 MSG_INFO("dpm_sms_policy_changed_callback called. name [%s] object [%s]", name, object);
42 ret = dpm_restriction_get_messaging_state(dpm_handle, "sim1", &state);
43 if (ret != DPM_ERROR_NONE) {
44 MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
48 msg_set_dpm_policy(MSG_SMS_TYPE, state);
51 MsgStoUpdateDPMRestrictedStatus(MSG_SMS_TYPE);
53 MsgStoUpdateDPMRestrictedStatus(MSG_MMS_TYPE);
58 static void dpm_mms_policy_changed_callback(const char* name, const char* object, void *user_data)
60 MSG_INFO("dpm_mms_policy_changed_callback called. name [%s] object [%s]", name, object);
65 ret = dpm_restriction_get_messaging_state(dpm_handle, &dpm_policy_enable[MSG_MMS_TYPE]);
66 if (ret != DPM_ERROR_NONE) {
67 MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
71 msg_set_dpm_policy(MSG_MMS_TYPE, state);
74 MsgStoUpdateDPMRestrictedStatus(MSG_MMS_TYPE);
78 void __get_dpm_policy()
83 ret = dpm_restriction_get_messaging_state(dpm_handle, "sim1", &state);
84 if (ret != DPM_ERROR_NONE) {
85 MSG_ERR("dpm_restriction_get_messaging_state failed [%d]", ret);
89 MSG_DEBUG("sms policy [%d]", state);
90 msg_set_dpm_policy(MSG_SMS_TYPE, state);
91 // MSG_DEBUG("mms policy [%d]", dpm_policy_enable[MSG_MMS_TYPE]);
93 ret = dpm_add_policy_changed_cb(dpm_handle, "messaging", dpm_sms_policy_changed_callback, NULL, &dpm_sms_callback_id);
94 if (ret != DPM_ERROR_NONE) {
95 MSG_ERR("dpm_add_policy_changed_cb failed [%d]", ret);
100 void msg_init_dpm_policy()
106 dpm_handle = dpm_manager_create();
107 if (dpm_handle == NULL) {
108 MSG_ERR("dpm_manager_create() failed");
110 MSG_DEBUG("dpm_manager_create() success");
122 void msg_deinit_dpm_policy()
124 if (dpm_sms_callback_id)
125 dpm_remove_policy_changed_cb(dpm_handle, dpm_sms_callback_id);
127 if (dpm_mms_callback_id)
128 dpm_remove_policy_changed_cb(dpm_handle, dpm_mms_callback_id);
131 dpm_manager_destroy(dpm_handle);