Add misc policies 63/74463/1
authorJaemin Ryu <jm77.ryu@samsung.com>
Tue, 14 Jun 2016 09:25:03 +0000 (18:25 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Tue, 14 Jun 2016 09:25:03 +0000 (18:25 +0900)
Change-Id: I4bd1057c55ce5eb804fbee3da6573d19993080d8
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
libs/dpm/restriction.cpp
libs/dpm/restriction.h
libs/restriction.cpp
policy/restriction.hxx
server/data/PolicyManifest.xml
server/restriction.cpp

index 200f0a8..2bfbea2 100644 (file)
@@ -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<RestrictionPolicy>();
+       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<RestrictionPolicy>();
+       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<RestrictionPolicy>();
+       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<RestrictionPolicy>();
+       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<RestrictionPolicy>();
+    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<RestrictionPolicy>();
+    int ret = restriction.getBrowserState();
+    if (ret < 0) {
+        return -1;
+    }
+    *state = ret;
+    return DPM_ERROR_NONE;
+}
+
index fc130dc..af44d41 100644 (file)
@@ -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
  */
 
index 12b01ca..38975cf 100644 (file)
@@ -154,4 +154,58 @@ int RestrictionPolicy::getExternalStorageState()
        }
 }
 
+int RestrictionPolicy::setPopImapEmailState(int enable)
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::setPopImapEmailState", enable);
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
+int RestrictionPolicy::getPopImapEmailState()
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::getPopImapEmailState");
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
+int RestrictionPolicy::setMessagingState(int enable)
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::setMessagingState", enable);
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
+int RestrictionPolicy::getMessagingState()
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::getMessagingState");
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
+int RestrictionPolicy::setBrowserState(int enable)
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::setBrowserState", enable);
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
+int RestrictionPolicy::getBrowserState()
+{
+    try {
+        return context->methodCall<int>("RestrictionPolicy::getBrowserState");
+    } catch (runtime::Exception& e) {
+        return -1;
+    }
+}
+
 } //namespace DevicePolicyManager
index bce7ecb..2dcbc9d 100644 (file)
@@ -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;
 };
index 1b33598..04e7e4f 100644 (file)
@@ -61,8 +61,8 @@
                <policy name="microphone">allowed</policy>
                <policy name="location">allowed</policy>
                <policy name="external-storage">allowed</policy>
-               <policy name="text-messaging">allowed</policy>
-               <policy name="pop-imap-email">allowed</policy>
+               <policy name="messaging">allowed</policy>
+               <policy name="popimap-email">allowed</policy>
                <policy name="browser">allowed</policy>
                <policy name="settings-changes">allowed</policy>
                <policy name="tethering">allowed</policy>
index 2b5b74f..5e33dc7 100644 (file)
@@ -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