#include "policy-client.h"
+#include <vconf.h>
+
+#define VCONFKEY_DPM_MODE_STATE "db/dpm/mode_state"
+
namespace {
const std::string SIGNAL_OBJECT_PATH = "/org/tizen/DevicePolicyManger/PIL";
const std::string POLICY_MANAGER_ADDRESS = "/tmp/.device-policy-manager.sock";
-int GetPolicyEnforceMode()
-{
- runtime::File policyManagerSocket(POLICY_MANAGER_ADDRESS);
-
- if (policyManagerSocket.exists()) {
- return 1;
- }
-
- return 0;
-}
-
} // namespace
DevicePolicyClient::DevicePolicyClient() noexcept :
- maintenanceMode(GetPolicyEnforceMode()), clientAddress(POLICY_MANAGER_ADDRESS)
+ clientAddress(POLICY_MANAGER_ADDRESS)
{
mainloop.reset(new ScopedGMainLoop);
}
const SignalHandler& handler,
void* data) noexcept
{
- if (!maintenanceMode)
+ if (!getMaintenanceMode())
return 0;
try {
int DevicePolicyClient::unsubscribeSignal(int id) noexcept
{
- if (!maintenanceMode)
+ if (!getMaintenanceMode())
return 0;
try {
return -1;
}
}
+
+int DevicePolicyClient::getMaintenanceMode()
+{
+ int value = 0;
+
+ ::vconf_get_bool(VCONFKEY_DPM_MODE_STATE, &value);
+
+ return value;
+}
const SignalHandler& handler,
void* data) noexcept;
int unsubscribeSignal(int subscriberId) noexcept;
+ int getMaintenanceMode();
template<typename Type, typename... Args>
Type methodCall(const std::string& method, Args&&... args)
{
- if (!maintenanceMode) {
+ if (!getMaintenanceMode()) {
errno = EPROTONOSUPPORT;
return Type();
}
}
private:
- int maintenanceMode;
std::string clientAddress;
std::unique_ptr<ScopedGMainLoop> mainloop;
};
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(vconf)
%description
Tizen Device Policy Client Library