* limitations under the License.
*/
-#include <gio/gio.h>
#include <systemd/sd-login.h>
#include "MsgDebug.h"
#include "MsgGconfWrapper.h"
#include "MsgUtilFile.h"
#include "MsgUtilFunction.h"
+#include "MsgUtilStorage.h"
#include <system_info.h>
#include <libintl.h>
#include <ctype.h>
#include <aul.h>
#include <aul_svc.h>
+#include <dpm/restriction.h>
typedef struct _msg_launch_app_data {
char *app_id;
[FEATURE_INDEX_MMS] = false,
};
-int _dbus_owner_id = 0;
+static int dpm_policy_enable[] = {
+ [MSG_UNKNOWN_TYPE] = 0,
+ [MSG_SMS_TYPE] = 1,
+ [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
}
-void MsgDbusInit()
+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;
+
+ 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;
+ }
+}
+
+
+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()
{
- MSG_DEBUG();
+ 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;
+ }
- _dbus_owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
- "msg-service.dbus.service",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL,
- NULL, NULL);
+ return true;
+}
+
+void msg_init_dpm_policy()
+{
+ MSG_BEGIN();
- if (_dbus_owner_id == 0) {
- MSG_ERR("g_bus_own_name() error");
+ dpm_handle = dpm_manager_create();
+ if (dpm_handle == NULL) {
+ MSG_ERR("dpm_manager_create() failed");
+ return;
}
- MSG_DEBUG("owner_id = [%d]", _dbus_owner_id);
+ 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;
}
-void MsgDbusDeinit()
+bool msg_check_dpm_policy(int type)
{
- MSG_DEBUG();
- if (_dbus_owner_id)
- g_bus_unown_name(_dbus_owner_id);
+ if (is_dpm_init == false)
+ msg_init_dpm_policy();
- _dbus_owner_id = 0;
+ return dpm_policy_enable[MSG_SMS_TYPE];
+// return dpm_policy_enable[type];
}
+