From 192615255f0d08d72e2e68f5952859dd9f6723fa Mon Sep 17 00:00:00 2001 From: Jaemin Ryu Date: Tue, 14 Jun 2016 18:25:03 +0900 Subject: [PATCH] Add misc policies Change-Id: I4bd1057c55ce5eb804fbee3da6573d19993080d8 Signed-off-by: Jaemin Ryu --- libs/dpm/restriction.cpp | 73 +++++++++++++++++++++++++++++ libs/dpm/restriction.h | 101 +++++++++++++++++++++++++++++++++++++++++ libs/restriction.cpp | 54 ++++++++++++++++++++++ policy/restriction.hxx | 9 ++++ server/data/PolicyManifest.xml | 4 +- server/restriction.cpp | 39 ++++++++++++++++ 6 files changed, 278 insertions(+), 2 deletions(-) diff --git a/libs/dpm/restriction.cpp b/libs/dpm/restriction.cpp index 200f0a8..2bfbea2 100644 --- a/libs/dpm/restriction.cpp +++ b/libs/dpm/restriction.cpp @@ -376,3 +376,76 @@ int dpm_restriction_get_bluetooth_pairing_state(dpm_restriction_policy_h handle, return DPM_ERROR_NONE; } + +int dpm_restriction_set_popimap_email_state(dpm_restriction_policy_h handle, int enable) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyContext &client = GetDevicePolicyContext(handle); + RestrictionPolicy restriction = client.createPolicyInterface(); + return restriction.setPopImapEmailState(enable); +} + +int dpm_restriction_get_popimap_email_state(dpm_restriction_policy_h handle, int *state) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyContext &client = GetDevicePolicyContext(handle); + RestrictionPolicy restriction = client.createPolicyInterface(); + int ret = restriction.getPopImapEmailState(); + if (ret < 0) { + return -1; + } + *state = ret; + return DPM_ERROR_NONE; +} + +int dpm_restriction_set_messaging_state(dpm_restriction_policy_h handle, int enable) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyContext &client = GetDevicePolicyContext(handle); + RestrictionPolicy restriction = client.createPolicyInterface(); + return restriction.setMessagingState(enable); +} + +int dpm_restriction_get_messaging_state(dpm_restriction_policy_h handle, int *state) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyContext &client = GetDevicePolicyContext(handle); + RestrictionPolicy restriction = client.createPolicyInterface(); + int ret = restriction.getMessagingState(); + if (ret < 0) { + return -1; + } + *state = ret; + return DPM_ERROR_NONE; +} + +int dpm_restriction_set_browser_state(dpm_restriction_policy_h handle, int enable) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyContext &client = GetDevicePolicyContext(handle); + RestrictionPolicy restriction = client.createPolicyInterface(); + return restriction.setBrowserState(enable); +} + +int dpm_restriction_get_browser_state(dpm_restriction_policy_h handle, int *state) +{ + RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER); + RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER); + + DevicePolicyContext &client = GetDevicePolicyContext(handle); + RestrictionPolicy restriction = client.createPolicyInterface(); + int ret = restriction.getBrowserState(); + if (ret < 0) { + return -1; + } + *state = ret; + return DPM_ERROR_NONE; +} + diff --git a/libs/dpm/restriction.h b/libs/dpm/restriction.h index fc130dc..af44d41 100644 --- a/libs/dpm/restriction.h +++ b/libs/dpm/restriction.h @@ -613,6 +613,107 @@ DPM_API int dpm_restriction_set_bluetooth_pairing_state(dpm_restriction_policy_h DPM_API int dpm_restriction_get_bluetooth_pairing_state(dpm_restriction_policy_h handle, int *enable); /** +* @brief Specifies whether the device allows access to POP or IMAP e-mail +* @details An administrator can diable the email capability without any user interaction +* @since_tizen 3.0 +* @param[in] handle The restriction policy handle +* @param[in] enable TRUE to restrict POP or IMAP e-mail, else FALSE +* @return #DPM_ERROR_NONE on success, otherwise a negative value +* @retval #DPM_ERROR_NONE Successful +* @retval #DPM_ERROR_NOT_SUPPORTED Not supported +* @retval #DPM_ERROR_PERMISSION_DENIED The application does not have +* the privilege to call this API +* @pre handle must be created by dpm_context_acquire_restriction_policy() +* @see dpm_context_acquire_restriction_policy() +* @see dpm_context_release_restriction_policy() +* @see dpm_restriction_get_popimap_email_state() +*/ +DPM_API int dpm_restriction_set_popimap_email_state(dpm_restriction_policy_h handle, int enable); + +/** +* @brief Checks whether the device allows access to POP or IMAP e-mail +* @details An administrator can check the email capability without any user interaction +* @since_tizen 3.0 +* @param[in] handle The restriction policy handle +* @param[out] enable TRUE if the access to POP or IMAP e-mail is disallowed, FALSE if allowed +* @return #DPM_ERROR_NONE on success, otherwise a negative value +* @retval #DPM_ERROR_NONE Successful +* @retval #DPM_ERROR_NOT_SUPPORTED Not supported +* @pre handle must be created by dpm_context_acquire_restriction_policy() +* @see dpm_context_acquire_restriction_policy() +* @see dpm_context_release_restriction_policy() +* @see dpm_restriction_set_popimap_email_state() +*/ +DPM_API int dpm_restriction_get_popimap_email_state(dpm_restriction_policy_h handle, int *state); + +/** + * @brief Specifies whether the devce allows the use of SMS or text messaging. + * @details An administrator can disable the text messaging capability without any user interaction + * @since_tizen 3.0 + * @privlevel partner + * @privilege %http://tizen.org/privilege/dpm.message + * @param[in] handle The restriction policy handle + * @param[in] enable TRUE to restrict the use of SMS or text messaging, else FALSE + * @return #DPM_ERROR_NONE on success, otherwise a negative value + * @retval #DPM_ERROR_NONE Successful + * @retval #DPM_ERROR_NOT_SUPPORTED Not supported + * @retval #DPM_ERROR_PERMISSION_DENIED The application does not have + * the privilege to call this API + * @pre handle must be created by dpm_context_acquire_restriction_policy() + * @see dpm_context_acquire_restriction_policy() + * @see dpm_context_release_restriction_policy() + * @see dpm_restriction_get_messaging_state() + */ +DPM_API int dpm_restriction_set_messaging_state(dpm_restriction_policy_h handle, int enable); + +/** +* @brief Checks whether the text messaging capability is enabled or not +* @details An administrator can check whether text messaging capability is enabled or not. +* @since_tizen 3.0 +* @param[in] handle The restriction policy handle +* @param[out] enable TRUE if the use of SMS or text messging is disallowed, FALSE if allowed +* @return #DPM_ERROR_NONE on success, otherwise a negative value +* @retval #DPM_ERROR_NONE Successful +* @retval #DPM_ERROR_NOT_SUPPORTED Not supported +* @pre handle must be created by dpm_context_acquire_restriction_policy() +* @see dpm_context_acquire_restriction_policy() +* @see dpm_context_release_restriction_policy() +* @see dpm_restriction_set_messaging_state() +*/ +DPM_API int dpm_restriction_get_messaging_state(dpm_restriction_policy_h handle, int *state); + +/** + * @brief Checks whether the device allows access to POP or IMAP e-mail + * @details An administrator can check the email capability without any user interaction + * @since_tizen 3.0 + * @param[in] handle The restriction policy handle + * @param[out] enable TRUE if the access to POP or IMAP e-mail is disallowed, FALSE if allowed + * @return #DPM_ERROR_NONE on success, otherwise a negative value + * @retval #DPM_ERROR_NONE Successful + * @retval #DPM_ERROR_NOT_SUPPORTED Not supported + * @pre handle must be created by dpm_context_acquire_restriction_policy() + * @see dpm_context_acquire_restriction_policy() + * @see dpm_context_release_restriction_policy() + * @see dpm_restriction_set_popimap_email_state() + */ +DPM_API int dpm_restriction_set_browser_state(dpm_restriction_policy_h handle, int enable); + +/** + * @brief Checks whether the web browser capability is enabled or not + * @details An administrator can check whether web browser capability is enabled or not. + * @since_tizen 3.0 + * @param[in] handle The restriction policy handle + * @param[out] enable TRUE if the use of web browser is enabled, FALSE if allowed + * @return #DPM_ERROR_NONE on success, otherwise a negative value + * @retval #DPM_ERROR_NONE Successful + * @retval #DPM_ERROR_NOT_SUPPORTED Not supported + * @pre handle must be created by dpm_context_acquire_restriction_policy() + * @see dpm_context_acquire_restriction_policy() + * @see dpm_context_release_restriction_policy() + * @see dpm_restriction_set_browser_state() + */ +DPM_API int dpm_restriction_get_browser_state(dpm_restriction_policy_h handle, int *state); +/** * @} // end of DPM_RESTRICTION_POLICY */ diff --git a/libs/restriction.cpp b/libs/restriction.cpp index 12b01ca..38975cf 100644 --- a/libs/restriction.cpp +++ b/libs/restriction.cpp @@ -154,4 +154,58 @@ int RestrictionPolicy::getExternalStorageState() } } +int RestrictionPolicy::setPopImapEmailState(int enable) +{ + try { + return context->methodCall("RestrictionPolicy::setPopImapEmailState", enable); + } catch (runtime::Exception& e) { + return -1; + } +} + +int RestrictionPolicy::getPopImapEmailState() +{ + try { + return context->methodCall("RestrictionPolicy::getPopImapEmailState"); + } catch (runtime::Exception& e) { + return -1; + } +} + +int RestrictionPolicy::setMessagingState(int enable) +{ + try { + return context->methodCall("RestrictionPolicy::setMessagingState", enable); + } catch (runtime::Exception& e) { + return -1; + } +} + +int RestrictionPolicy::getMessagingState() +{ + try { + return context->methodCall("RestrictionPolicy::getMessagingState"); + } catch (runtime::Exception& e) { + return -1; + } +} + +int RestrictionPolicy::setBrowserState(int enable) +{ + try { + return context->methodCall("RestrictionPolicy::setBrowserState", enable); + } catch (runtime::Exception& e) { + return -1; + } +} + +int RestrictionPolicy::getBrowserState() +{ + try { + return context->methodCall("RestrictionPolicy::getBrowserState"); + } catch (runtime::Exception& e) { + return -1; + } +} + } //namespace DevicePolicyManager diff --git a/policy/restriction.hxx b/policy/restriction.hxx index bce7ecb..2dcbc9d 100644 --- a/policy/restriction.hxx +++ b/policy/restriction.hxx @@ -50,6 +50,15 @@ public: int setExternalStorageState(int enable); int getExternalStorageState(); + int setPopImapEmailState(int enable); + int getPopImapEmailState(); + + int setMessagingState(int enable); + int getMessagingState(); + + int setBrowserState(int enable); + int getBrowserState(); + private: PolicyControlContext& context; }; diff --git a/server/data/PolicyManifest.xml b/server/data/PolicyManifest.xml index 1b33598..04e7e4f 100644 --- a/server/data/PolicyManifest.xml +++ b/server/data/PolicyManifest.xml @@ -61,8 +61,8 @@ allowed allowed allowed - allowed - allowed + allowed + allowed allowed allowed allowed diff --git a/server/restriction.cpp b/server/restriction.cpp index 2b5b74f..5e33dc7 100644 --- a/server/restriction.cpp +++ b/server/restriction.cpp @@ -57,6 +57,12 @@ RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) : context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getUsbTetheringState)); context.registerParametricMethod(this, (int)(RestrictionPolicy::setExternalStorageState)(int)); context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getExternalStorageState)); + context.registerParametricMethod(this, (int)(RestrictionPolicy::setPopImapEmailState)(int)); + context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getPopImapEmailState)); + context.registerParametricMethod(this, (int)(RestrictionPolicy::setMessagingState)(int)); + context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getMessagingState)); + context.registerParametricMethod(this, (int)(RestrictionPolicy::setBrowserState)(int)); + context.registerNonparametricMethod(this, (int)(RestrictionPolicy::getBrowserState)); context.createNotification("camera"); context.createNotification("clipboard"); @@ -65,6 +71,9 @@ RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) : context.createNotification("settings-changes"); context.createNotification("usb-debugging"); context.createNotification("usb-tethering"); + context.createNotification("popimap-email"); + context.createNotification("messaging"); + context.createNotification("browser"); } RestrictionPolicy::~RestrictionPolicy() @@ -192,6 +201,36 @@ int RestrictionPolicy::getExternalStorageState() return IsPolicyAllowed(context, "external-storage"); } +int RestrictionPolicy::setPopImapEmailState(int enable) +{ + return SetPolicyAllowed(context, "popimap-email", enable); +} + +int RestrictionPolicy::getPopImapEmailState() +{ + return IsPolicyAllowed(context, "popimap-email"); +} + +int RestrictionPolicy::setMessagingState(int enable) +{ + return SetPolicyAllowed(context, "messaging", enable); +} + +int RestrictionPolicy::getMessagingState() +{ + return IsPolicyAllowed(context, "messaging"); +} + +int RestrictionPolicy::setBrowserState(int enable) +{ + return SetPolicyAllowed(context, "browser", enable); +} + +int RestrictionPolicy::getBrowserState() +{ + return IsPolicyAllowed(context, "browser"); +} + RestrictionPolicy restrictionPolicy(Server::instance()); } // namespace DevicePolicyManager -- 2.7.4