Change indentation: spaces to tabs 10/78810/3
authorJaemin Ryu <jm77.ryu@samsung.com>
Thu, 7 Jul 2016 02:37:01 +0000 (11:37 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Thu, 7 Jul 2016 03:53:18 +0000 (12:53 +0900)
Change-Id: I9302db650601b6b5c8e940c5d847029b5d273601
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
212 files changed:
common/CMakeLists.txt
common/array.h
common/audit/console-sink.cpp
common/audit/console-sink.h
common/audit/logger.cpp
common/audit/logger.h
common/audit/logsink.h
common/audit/null-sink.h
common/auth/group.cpp
common/auth/group.h
common/auth/user.cpp
common/auth/user.h
common/data-type.h
common/db/column.cpp
common/db/column.h
common/db/connection.cpp
common/db/connection.h
common/db/statement.cpp
common/db/statement.h
common/dbus/connection.cpp
common/dbus/connection.h
common/dbus/error.cpp
common/dbus/error.h
common/dbus/variant.cpp
common/dbus/variant.h
common/error.cpp
common/error.h
common/eventfd.cpp
common/eventfd.h
common/exception.h
common/file-descriptor.h
common/filesystem.cpp
common/filesystem.h
common/mainloop.cpp
common/mainloop.h
common/pam.cpp
common/pam.h
common/process.cpp
common/process.h
common/reflection.h
common/rmi/callback-holder.h
common/rmi/client.cpp
common/rmi/client.h
common/rmi/connection.cpp
common/rmi/connection.h
common/rmi/message-composer.cpp
common/rmi/message-composer.h
common/rmi/message.cpp
common/rmi/message.h
common/rmi/notification.cpp
common/rmi/notification.h
common/rmi/service.cpp
common/rmi/service.h
common/rmi/socket.cpp
common/rmi/socket.h
common/serialize.h
common/thread-pool.cpp
common/thread-pool.h
common/xml/document.cpp
common/xml/document.h
common/xml/keepblanks.cpp
common/xml/keepblanks.h
common/xml/node.cpp
common/xml/node.h
common/xml/parser.cpp
common/xml/parser.h
libs/CMakeLists.txt
libs/administration.cpp
libs/application.cpp
libs/bluetooth.cpp
libs/common.cmake
libs/dpm/administration.cpp
libs/dpm/application.cpp
libs/dpm/application.h
libs/dpm/bluetooth.cpp
libs/dpm/client-handle.cpp
libs/dpm/context.h
libs/dpm/debug.h
libs/dpm/device-policy-manager.h
libs/dpm/password.cpp
libs/dpm/password.h
libs/dpm/restriction.cpp
libs/dpm/security.cpp
libs/dpm/storage.cpp
libs/dpm/storage.h
libs/dpm/wifi.cpp
libs/dpm/zone.cpp
libs/dpm/zone.h
libs/ivi.cmake
libs/location.cpp
libs/mobile.cmake
libs/password.cpp
libs/policy-client.cpp
libs/policy-client.h
libs/restriction.cpp
libs/security.cpp
libs/storage.cpp
libs/wearable.cmake
libs/wifi.cpp
libs/zone.cpp
policy/administration.hxx
policy/application.hxx
policy/bluetooth.hxx
policy/password.hxx
policy/restriction.hxx
policy/security.hxx
policy/storage.hxx
policy/wifi.hxx
policy/zone.hxx
policy/zone/app-proxy.hxx
policy/zone/package-proxy.hxx
policy/zone/zone.hxx
server/CMakeLists.txt
server/administration.cpp
server/app-bundle.cpp
server/app-bundle.h
server/application.cpp
server/bluetooth.cpp
server/client-manager.cpp
server/client-manager.h
server/common.cmake
server/ivi.cmake
server/launchpad.cpp
server/launchpad.h
server/location.cpp
server/main.cpp
server/mobile.cmake
server/packman.cpp
server/packman.h
server/password.cpp
server/policy-storage.cpp
server/policy-storage.h
server/policy.cpp
server/policy.h
server/restriction.cpp
server/security.cpp
server/server.cpp
server/server.h
server/storage.cpp
server/wearable.cmake
server/wifi.cpp
server/zone.cpp
server/zone/app-proxy.cpp
server/zone/package-proxy.cpp
server/zone/zone.cpp
tests/api/CMakeLists.txt
tests/api/admin.c
tests/api/application.c
tests/api/bluetooth.c
tests/api/common.cmake
tests/api/context.c
tests/api/ivi.cmake
tests/api/main.c
tests/api/manager.c
tests/api/mobile.cmake
tests/api/password.c
tests/api/restriction.c
tests/api/security.c
tests/api/testbench.c
tests/api/testbench.h
tests/api/wearable.cmake
tests/api/wifi.c
tests/api/zone.c
tests/testbench/testbench.cpp
tests/testbench/testbench.h
tests/unit/database.cpp
tests/unit/filesystem.cpp
tests/unit/main.cpp
tests/unit/proc.cpp
tests/unit/rmi.cpp
tests/unit/shadow.cpp
tests/unit/xml.cpp
tools/CMakeLists.txt
tools/ode/include/ode-app-widget.h
tools/ode/include/ode-app.h
tools/ode/res/edc_resource/encryption_device.edc
tools/ode/res/org.tizen.ode.edc
tools/ode/src/ode-app-main.c
tools/syspopup/CMakeLists.txt
tools/syspopup/include/dpm-syspopup.h
tools/syspopup/src/main.c
tools/syspopup/src/popup-list.c
tools/syspopup/src/ui.c
zone/CMakeLists.txt
zone/cli/CMakeLists.txt
zone/cli/zone-admin-cli.cpp
zone/libs/CMakeLists.txt
zone/libs/app-proxy.cpp
zone/libs/package-proxy.cpp
zone/libs/zone.cpp
zone/libs/zone/app-info-internal.h
zone/libs/zone/app-proxy.cpp
zone/libs/zone/debug.h
zone/libs/zone/package-info-internal.h
zone/libs/zone/package-proxy.cpp
zone/libs/zone/zone.cpp
zone/libs/zone/zone.h
zone/module/CMakeLists.txt
zone/module/session.cpp
zone/module/zone-builder.cpp
zone/module/zone-builder.h
zone/module/zone-guard.h
zone/module/zone.cpp
zone/volume/CMakeLists.txt
zone/volume/ecryptfs.h
zone/volume/kernel-keyring.cpp
zone/volume/kernel-keyring.h
zone/volume/key-generator.cpp
zone/volume/key-generator.h
zone/volume/key-manager.cpp
zone/volume/key-manager.h
zone/volume/main.cpp

index f5d4a29..364441f 100755 (executable)
 PROJECT(dpm-common)
 
 SET (COMMON_SOURCES     ${DPM_COMMON}/error.cpp
-                        ${DPM_COMMON}/process.cpp
-                        ${DPM_COMMON}/eventfd.cpp
-                        ${DPM_COMMON}/mainloop.cpp
-                        ${DPM_COMMON}/filesystem.cpp
-                        ${DPM_COMMON}/thread-pool.cpp
-                        ${DPM_COMMON}/rmi/socket.cpp
-                        ${DPM_COMMON}/rmi/client.cpp
-                        ${DPM_COMMON}/rmi/message.cpp
-                        ${DPM_COMMON}/rmi/message-composer.cpp
-                        ${DPM_COMMON}/rmi/service.cpp
-                        ${DPM_COMMON}/rmi/connection.cpp
-                        ${DPM_COMMON}/rmi/notification.cpp
-                        ${DPM_COMMON}/audit/logger.cpp
-                        ${DPM_COMMON}/audit/null-sink.cpp
-                        ${DPM_COMMON}/audit/console-sink.cpp
-                        ${DPM_COMMON}/xml/node.cpp
-                        ${DPM_COMMON}/xml/parser.cpp
-                        ${DPM_COMMON}/xml/document.cpp
-                        ${DPM_COMMON}/xml/keepblanks.cpp
-                        ${DPM_COMMON}/db/column.cpp
-                        ${DPM_COMMON}/db/statement.cpp
-                        ${DPM_COMMON}/db/connection.cpp
-                        ${DPM_COMMON}/auth/user.cpp
-                        ${DPM_COMMON}/auth/group.cpp
-                        ${DPM_COMMON}/dbus/error.cpp
-                        ${DPM_COMMON}/dbus/variant.cpp
-                        ${DPM_COMMON}/dbus/connection.cpp
+                                               ${DPM_COMMON}/process.cpp
+                                               ${DPM_COMMON}/eventfd.cpp
+                                               ${DPM_COMMON}/mainloop.cpp
+                                               ${DPM_COMMON}/filesystem.cpp
+                                               ${DPM_COMMON}/thread-pool.cpp
+                                               ${DPM_COMMON}/rmi/socket.cpp
+                                               ${DPM_COMMON}/rmi/client.cpp
+                                               ${DPM_COMMON}/rmi/message.cpp
+                                               ${DPM_COMMON}/rmi/message-composer.cpp
+                                               ${DPM_COMMON}/rmi/service.cpp
+                                               ${DPM_COMMON}/rmi/connection.cpp
+                                               ${DPM_COMMON}/rmi/notification.cpp
+                                               ${DPM_COMMON}/audit/logger.cpp
+                                               ${DPM_COMMON}/audit/null-sink.cpp
+                                               ${DPM_COMMON}/audit/console-sink.cpp
+                                               ${DPM_COMMON}/xml/node.cpp
+                                               ${DPM_COMMON}/xml/parser.cpp
+                                               ${DPM_COMMON}/xml/document.cpp
+                                               ${DPM_COMMON}/xml/keepblanks.cpp
+                                               ${DPM_COMMON}/db/column.cpp
+                                               ${DPM_COMMON}/db/statement.cpp
+                                               ${DPM_COMMON}/db/connection.cpp
+                                               ${DPM_COMMON}/auth/user.cpp
+                                               ${DPM_COMMON}/auth/group.cpp
+                                               ${DPM_COMMON}/dbus/error.cpp
+                                               ${DPM_COMMON}/dbus/variant.cpp
+                                               ${DPM_COMMON}/dbus/connection.cpp
 )
 
 SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
@@ -51,12 +51,12 @@ SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack"
 ADD_LIBRARY(${PROJECT_NAME} STATIC ${COMMON_SOURCES})
 
 PKG_CHECK_MODULES(COMMON_DEPS REQUIRED  libxml-2.0
-                                        sqlite3
-                                        gio-2.0
+                                                                               sqlite3
+                                                                               gio-2.0
 )
 
 INCLUDE_DIRECTORIES(SYSTEM  ${DPM_COMMON}
-                            ${COMMON_DEPS_INCLUDE_DIRS}
+                                                       ${COMMON_DEPS_INCLUDE_DIRS}
 )
 
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${COMMON_DEPS_LIBRARIES})
index ce8ddff..77ac2a3 100644 (file)
@@ -25,32 +25,33 @@ namespace runtime {
 template <typename T>
 class Array final {
 public:
-    Array() = delete;
-    Array(std::vector<T> &&list) :
-        list(std::move(list)), it(this->list.begin())
-    {
-    };
-    Array(const std::vector<T> &list) :
-        list(list), it(this->list.begin())
-    {
-    };
-
-    T *next()
-    {
-        if (it != list.end()) {
-            return &(*it++);
-        }
-        return NULL;
-    }
-
-    bool isEnd()
-    {
-        return it == list.end();
-    }
+       Array() = delete;
+       Array(std::vector<T> &&list) :
+               list(std::move(list)), it(this->list.begin())
+       {
+       }
+
+       Array(const std::vector<T> &list) :
+               list(list), it(this->list.begin())
+       {
+       }
+
+       T *next()
+       {
+               if (it != list.end()) {
+                       return &(*it++);
+               }
+               return NULL;
+       }
+
+       bool isEnd()
+       {
+               return it == list.end();
+       }
 
 private:
-    std::vector<T> list;
-    typename std::vector<T>::iterator it;
+       std::vector<T> list;
+       typename std::vector<T>::iterator it;
 };
 
 } // namespace runtime
index 260c78a..b3e4d94 100644 (file)
@@ -22,7 +22,7 @@ namespace audit {
 
 void ConsoleLogSink::sink(const std::string& message)
 {
-    std::cout << message;
+       std::cout << message;
 }
 
 } // namespace audit
index ea1ce06..85dbe27 100644 (file)
@@ -25,7 +25,7 @@ namespace audit {
 
 class ConsoleLogSink : public LogSink {
 public:
-    void sink(const std::string& message) override;
+       void sink(const std::string& message) override;
 };
 
 } // namespace audit
index 2f60345..3c547f8 100644 (file)
@@ -31,47 +31,47 @@ std::unique_ptr<LogSink> Logger::backend(new ConsoleLogSink());
 
 std::string LogLevelToString(const LogLevel level)
 {
-    switch (level) {
-    case LogLevel::Error:
-        return "ERROR";
-    case LogLevel::Warning:
-        return "WARN";
-    case LogLevel::Debug:
-        return "DEBUG";
-    case LogLevel::Info:
-        return "INFO";
-    case LogLevel::Trace:
-        return "TRACE";
-    default:
-        return "UNKNOWN";
-    }
+       switch (level) {
+       case LogLevel::Error:
+               return "ERROR";
+       case LogLevel::Warning:
+               return "WARN";
+       case LogLevel::Debug:
+               return "DEBUG";
+       case LogLevel::Info:
+               return "INFO";
+       case LogLevel::Trace:
+               return "TRACE";
+       default:
+               return "UNKNOWN";
+       }
 }
 
 void Logger::setLogLevel(const LogLevel level)
 {
-    Logger::logLevel = level;
+       Logger::logLevel = level;
 }
 
 LogLevel Logger::getLogLevel(void)
 {
-    return Logger::logLevel;
+       return Logger::logLevel;
 }
 
 void Logger::log(LogLevel severity,
-                 const std::string& file,
-                 const unsigned int line,
-                 const std::string& func,
-                 const std::string& message)
+                                const std::string& file,
+                                const unsigned int line,
+                                const std::string& func,
+                                const std::string& message)
 {
-    std::ostringstream buffer;
+       std::ostringstream buffer;
 
-    buffer << LogLevelToString(severity)
-           << "<" << ::getpid() << ">:"
-           << file << ":" << line
-           << " " << func << " " << message
-           << std::endl;
+       buffer << LogLevelToString(severity)
+                  << "<" << ::getpid() << ">:"
+                  << file << ":" << line
+                  << " " << func << " " << message
+                  << std::endl;
 
-    Logger::backend->sink(buffer.str());
+       Logger::backend->sink(buffer.str());
 }
 
 } // namespace audit
index 1b50dc0..70cd155 100644 (file)
 namespace audit {
 
 enum class LogLevel : int {
-    Error,
-    Warning,
-    Debug,
-    Info,
-    Trace
+       Error,
+       Warning,
+       Debug,
+       Info,
+       Trace
 };
 
 class Logger {
 public:
-    static void setLogLevel(const LogLevel level);
-    static LogLevel getLogLevel(void);
-    static void log(LogLevel severity,
-                    const std::string& file,
-                    const unsigned int line,
-                    const std::string& func,
-                    const std::string& message);
+       static void setLogLevel(const LogLevel level);
+       static LogLevel getLogLevel(void);
+       static void log(LogLevel severity,
+                                       const std::string& file,
+                                       const unsigned int line,
+                                       const std::string& func,
+                                       const std::string& message);
 
 private:
-    static LogLevel logLevel;
-    static std::unique_ptr<LogSink> backend;
+       static LogLevel logLevel;
+       static std::unique_ptr<LogSink> backend;
 };
 
 #ifndef __FILENAME__
@@ -57,10 +57,10 @@ private:
 
 #define LOG(SEVERITY, MESSAGE)                                         \
 do {                                                                   \
-    if (audit::LogLevel::SEVERITY <= audit::Logger::getLogLevel()) {   \
-        audit::Logger::log(audit::LogLevel::SEVERITY,                  \
-                           __FILENAME__, __LINE__, __func__, MESSAGE); \
-    }                                                                  \
+       if (audit::LogLevel::SEVERITY <= audit::Logger::getLogLevel()) {   \
+               audit::Logger::log(audit::LogLevel::SEVERITY,                  \
+                                                  __FILENAME__, __LINE__, __func__, MESSAGE); \
+       }                                                                  \
 } while (0)
 
 #define ERROR(MESSAGE) LOG(Error, MESSAGE)
index 625281a..f1949df 100644 (file)
@@ -23,9 +23,9 @@ namespace audit {
 
 class LogSink {
 public:
-    LogSink() {}
-    virtual ~LogSink() {}
-    virtual void sink(const std::string& message) = 0;
+       LogSink() {}
+       virtual ~LogSink() {}
+       virtual void sink(const std::string& message) = 0;
 };
 
 } // namespace audit
index 9443969..cd5d9dc 100644 (file)
@@ -25,7 +25,7 @@ namespace audit {
 
 class NullLogSink : public LogSink {
 public:
-    void sink(const std::string& message) override;
+       void sink(const std::string& message) override;
 };
 
 } // namespace audit
index 7bb8497..89e1ceb 100644 (file)
  *  limitations under the License
  */
 
-
-#include <regex>
-#include <memory>
-
 #include <grp.h>
 #include <gshadow.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include <regex>
+#include <memory>
+
 #include "group.h"
 #include "shadow.h"
 #include "exception.h"
 namespace runtime {
 
 Group::Group(const Group& group) :
-    name(group.name), gid(group.gid)
+       name(group.name), gid(group.gid)
 {
 }
 
 Group::Group(const std::string& group)
 {
-    struct group grp, *result;
-    int bufsize;
+       struct group grp, *result;
+       int bufsize;
 
-    bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
-    if (bufsize == -1)
-        bufsize = 16384;
+       bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
+       if (bufsize == -1)
+               bufsize = 16384;
 
-    std::unique_ptr<char[]> buf(new char[bufsize]);
+       std::unique_ptr<char[]> buf(new char[bufsize]);
 
-    ::getgrnam_r(group.c_str(), &grp, buf.get(), bufsize, &result);
-    if (result == NULL) {
-        throw runtime::Exception("Group doesn't exist");
-    }
+       ::getgrnam_r(group.c_str(), &grp, buf.get(), bufsize, &result);
+       if (result == NULL) {
+               throw runtime::Exception("Group doesn't exist");
+       }
 
-    name = result->gr_name;
-    gid = result->gr_gid;
+       name = result->gr_name;
+       gid = result->gr_gid;
 }
 
 Group::Group(const gid_t group)
 {
-    struct group grp, *result;
-    int bufsize;
+       struct group grp, *result;
+       int bufsize;
 
-    bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
-    if (bufsize == -1)
-        bufsize = 16384;
+       bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
+       if (bufsize == -1)
+               bufsize = 16384;
 
-    std::unique_ptr<char[]> buf(new char[bufsize]);
+       std::unique_ptr<char[]> buf(new char[bufsize]);
 
-    ::getgrgid_r(group, &grp, buf.get(), bufsize, &result);
-    if (result == NULL) {
-        throw runtime::Exception("Group doesn't exist");
-    }
+       ::getgrgid_r(group, &grp, buf.get(), bufsize, &result);
+       if (result == NULL) {
+               throw runtime::Exception("Group doesn't exist");
+       }
 
-    name = result->gr_name;
-    gid = result->gr_gid;
+       name = result->gr_name;
+       gid = result->gr_gid;
 }
 
 Group::Group() :
-    Group(::getgid())
+       Group(::getgid())
 {
 }
 
index 544dbca..5c0b583 100644 (file)
 #ifndef __RUNTIME_GROUP_H__
 #define __RUNTIME_GROUP_H__
 
-#include <string>
 #include <limits.h>
 #include <sys/types.h>
 
+#include <string>
+
 #ifndef INVALID_GID
 #define INVALID_GID             UINT_MAX
 #endif
@@ -29,24 +30,24 @@ namespace runtime {
 
 class Group final {
 public:
-    Group(const std::string& name);
-    Group(const gid_t group);
-    Group(const Group& group);
-    Group();
+       Group(const std::string& name);
+       Group(const gid_t group);
+       Group(const Group& group);
+       Group();
 
-    const std::string& getName() const
-    {
-        return name;
-    }
+       const std::string& getName() const
+       {
+               return name;
+       }
 
-    const gid_t getGid() const
-    {
-        return gid;
-    }
+       const gid_t getGid() const
+       {
+               return gid;
+       }
 
 private:
-    std::string name;
-    gid_t gid;
+       std::string name;
+       gid_t gid;
 };
 
 } // namespace runtime
index c1a8e01..0848a5e 100644 (file)
@@ -13,8 +13,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  */
-#include <regex>
-#include <memory>
 
 #include <pwd.h>
 #include <shadow.h>
@@ -22,6 +20,9 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include <regex>
+#include <memory>
+
 #include "user.h"
 #include "group.h"
 #include "shadow.h"
 namespace runtime {
 
 User::User(const User& user) :
-    name(user.name), uid(user.uid), gid(user.gid)
+       name(user.name), uid(user.uid), gid(user.gid)
 {
 }
 
 User::User(const std::string& user)
 {
-    struct passwd pwd, *result;
-    int bufsize;
+       struct passwd pwd, *result;
+       int bufsize;
 
-    bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
-    if (bufsize == -1)
-        bufsize = 16384;
+       bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
+       if (bufsize == -1)
+               bufsize = 16384;
 
-    std::unique_ptr<char[]> buf(new char[bufsize]);
+       std::unique_ptr<char[]> buf(new char[bufsize]);
 
-    ::getpwnam_r(user.c_str(), &pwd, buf.get(), bufsize, &result);
-    if (result == NULL) {
-        throw runtime::Exception("User " + user + " doesn't exist");
-    }
+       ::getpwnam_r(user.c_str(), &pwd, buf.get(), bufsize, &result);
+       if (result == NULL) {
+               throw runtime::Exception("User " + user + " doesn't exist");
+       }
 
-    name = result->pw_name;
-    uid = result->pw_uid;
-    gid = result->pw_gid;
+       name = result->pw_name;
+       uid = result->pw_uid;
+       gid = result->pw_gid;
 }
 
 User::User(const uid_t user)
 {
-    struct passwd pwd, *result;
-    int bufsize;
-
-    bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
-    if (bufsize == -1)
-        bufsize = 16384;
-
-    std::unique_ptr<char[]> buf(new char[bufsize]);
-    ::getpwuid_r(user, &pwd, buf.get(), bufsize, &result);
-    if (result == NULL) {
-        throw runtime::Exception("User " + std::to_string(user) + "doesn't exist");
-    }
-
-    name = result->pw_name;
-    uid = result->pw_uid;
-    gid = result->pw_gid;
+       struct passwd pwd, *result;
+       int bufsize;
+
+       bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
+       if (bufsize == -1)
+               bufsize = 16384;
+
+       std::unique_ptr<char[]> buf(new char[bufsize]);
+       ::getpwuid_r(user, &pwd, buf.get(), bufsize, &result);
+       if (result == NULL) {
+               throw runtime::Exception("User " + std::to_string(user) + "doesn't exist");
+       }
+
+       name = result->pw_name;
+       uid = result->pw_uid;
+       gid = result->pw_gid;
 }
 
 User::User() :
-    User(::getuid())
+       User(::getuid())
 {
 }
 
index 09e12ba..88aa5b0 100644 (file)
 #ifndef __RUNTIME_USER_H__
 #define __RUNTIME_USER_H__
 
-#include <string>
 #include <limits.h>
 #include <sys/types.h>
 
+#include <string>
+
 #ifndef INVALID_UID
 #define INVALID_UID             UINT_MAX
 #endif
@@ -29,30 +30,30 @@ namespace runtime  {
 
 class User final {
 public:
-    User(const std::string& name);
-    User(const uid_t user);
-    User(const User& user);
-    User();
-
-    const std::string& getName() const
-    {
-        return name;
-    }
-
-    uid_t getUid() const
-    {
-        return uid;
-    }
-
-    gid_t getGid() const
-    {
-        return gid;
-    }
+       User(const std::string& name);
+       User(const uid_t user);
+       User(const User& user);
+       User();
+
+       const std::string& getName() const
+       {
+               return name;
+       }
+
+       uid_t getUid() const
+       {
+               return uid;
+       }
+
+       gid_t getGid() const
+       {
+               return gid;
+       }
 
 private:
-    std::string name;
-    uid_t uid;
-    gid_t gid;
+       std::string name;
+       uid_t uid;
+       gid_t gid;
 };
 
 } // namespace runtime
index 9c44075..b5b232c 100644 (file)
 #include "reflection.h"
 
 struct Void {
-    NO_REFLECTABLE_PROPERTY
+       NO_REFLECTABLE_PROPERTY
 };
 
 struct String {
-    String() = default;
-    String(const String& str) : value(str.value) {}
-    String(String&& str) : value(std::move(str.value)) {}
+       String() = default;
+       String(const String& str) : value(str.value) {}
+       String(String&& str) : value(std::move(str.value)) {}
 
-    String(const char* str) : value(str) {}
-    String(const std::string& str) : value(str) {}
+       String(const char* str) : value(str) {}
+       String(const std::string& str) : value(str) {}
 
-    String& operator=(const String& str)
-    {
-        if (this != &str) {
-            value = str.value;
-        }
+       String& operator=(const String& str)
+       {
+               if (this != &str) {
+                       value = str.value;
+               }
 
-        return *this;
-    }
+               return *this;
+       }
 
-    String& operator=(String&& str)
-    {
-        if (this != &str) {
-            value = std::move(str.value);
-        }
-        return *this;
-    }
+       String& operator=(String&& str)
+       {
+               if (this != &str) {
+                       value = std::move(str.value);
+               }
+               return *this;
+       }
 
-    std::string value;
-    REFLECTABLE(value)
+       std::string value;
+       REFLECTABLE(value)
 };
 
 struct StringPair {
-    std::string first;
-    std::string second;
-    REFLECTABLE(first, second)
+       std::string first;
+       std::string second;
+       REFLECTABLE(first, second)
 };
 
 struct Status {
-    Status() : code(0) {}
-    Status(int v) : code(v) {}
+       Status() : code(0) {}
+       Status(int v) : code(v) {}
 
-    operator int() const
-    {
-        return code;
-    }
+       operator int() const
+       {
+               return code;
+       }
 
-    int code;
-    REFLECTABLE(code)
+       int code;
+       REFLECTABLE(code)
 };
 
 template<typename T>
 struct Vector {
-    std::vector<T> value;
-    REFLECTABLE(value)
+       std::vector<T> value;
+       REFLECTABLE(value)
 };
 
 #endif //!__RUNTIME_DATA_TYPE_H__
index 326610f..3a57600 100644 (file)
@@ -21,8 +21,8 @@
 namespace database {
 
 Column::Column(const Statement& stmt, int idx) :
-    statement(stmt.get()),
-    index(idx)
+       statement(stmt.get()),
+       index(idx)
 {
 }
 
@@ -32,42 +32,42 @@ Column::~Column() noexcept
 
 std::string Column::getName() const
 {
-    return sqlite3_column_name(statement, index);
+       return sqlite3_column_name(statement, index);
 }
 
 int Column::getInt() const
 {
-    return sqlite3_column_int(statement, index);
+       return sqlite3_column_int(statement, index);
 }
 
 sqlite3_int64 Column::getInt64() const
 {
-    return sqlite3_column_int64(statement, index);
+       return sqlite3_column_int64(statement, index);
 }
 
 double Column::getDouble() const
 {
-    return sqlite3_column_double(statement, index);
+       return sqlite3_column_double(statement, index);
 }
 
 const char* Column::getText() const
 {
-    return reinterpret_cast<const char *>(sqlite3_column_text(statement, index));
+       return reinterpret_cast<const char *>(sqlite3_column_text(statement, index));
 }
 
 const void* Column::getBlob() const
 {
-    return sqlite3_column_blob(statement, index);
+       return sqlite3_column_blob(statement, index);
 }
 
 int Column::getType() const
 {
-    return sqlite3_column_type(statement, index);
+       return sqlite3_column_type(statement, index);
 }
 
 int Column::getBytes() const
 {
-    return sqlite3_column_bytes(statement, index);
+       return sqlite3_column_bytes(statement, index);
 }
 
 } // namespace database
index 71afb31..1dc9965 100644 (file)
@@ -27,51 +27,51 @@ namespace database {
 
 class Column {
 public:
-    Column(const Statement& stmt, int idx);
-    virtual ~Column() noexcept;
-
-    std::string getName() const;
-    sqlite3_int64 getInt64() const;
-    const char* getText() const;
-    double getDouble() const;
-    const void* getBlob() const;
-    int getInt() const;
-    int getType() const;
-    int getBytes() const;
-
-    inline int size() const
-    {
-        return getBytes();
-    }
-
-    inline operator int() const
-    {
-        return getInt();
-    }
-
-    inline operator sqlite3_int64() const
-    {
-        return getInt64();
-    }
-
-    inline operator double() const
-    {
-        return getDouble();
-    }
-
-    inline operator const char*() const
-    {
-        return getText();
-    }
-
-    inline operator const void*() const
-    {
-        return getBlob();
-    }
+       Column(const Statement& stmt, int idx);
+       virtual ~Column() noexcept;
+
+       std::string getName() const;
+       sqlite3_int64 getInt64() const;
+       const char* getText() const;
+       double getDouble() const;
+       const void* getBlob() const;
+       int getInt() const;
+       int getType() const;
+       int getBytes() const;
+
+       inline int size() const
+       {
+               return getBytes();
+       }
+
+       inline operator int() const
+       {
+               return getInt();
+       }
+
+       inline operator sqlite3_int64() const
+       {
+               return getInt64();
+       }
+
+       inline operator double() const
+       {
+               return getDouble();
+       }
+
+       inline operator const char*() const
+       {
+               return getText();
+       }
+
+       inline operator const void*() const
+       {
+               return getBlob();
+       }
 
 private:
-    sqlite3_stmt* statement;
-    int index;
+       sqlite3_stmt* statement;
+       int index;
 };
 
 } // namespace database
index 8cba6c6..5ea016e 100644 (file)
 namespace database {
 
 Connection::Connection(const std::string& name, const int flags) :
-    handle(nullptr),
-    filename(name)
+       handle(nullptr), filename(name)
 {
-    if (::sqlite3_open_v2(filename.c_str(), &handle, flags, NULL)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (::sqlite3_open_v2(filename.c_str(), &handle, flags, NULL)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 Connection::~Connection()
 {
-    ::sqlite3_close(handle);
+       ::sqlite3_close(handle);
 }
 
 int Connection::exec(const std::string& query)
 {
-    if (::sqlite3_exec(handle, query.c_str(), NULL, NULL, NULL) != SQLITE_OK) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (::sqlite3_exec(handle, query.c_str(), NULL, NULL, NULL) != SQLITE_OK) {
+               throw runtime::Exception(getErrorMessage());
+       }
 
-    return ::sqlite3_changes(handle);
+       return ::sqlite3_changes(handle);
 }
 
 } // namespace database
index 9bf2e87..1465533 100644 (file)
@@ -25,50 +25,50 @@ namespace database {
 
 class Connection {
 public:
-    enum Mode {
-        Create = SQLITE_OPEN_CREATE,
-        ReadWrite = SQLITE_OPEN_READWRITE
-    };
+       enum Mode {
+               Create = SQLITE_OPEN_CREATE,
+               ReadWrite = SQLITE_OPEN_READWRITE
+       };
 
-    Connection(const std::string& name, const int flags);
-    virtual ~Connection();
+       Connection(const std::string& name, const int flags);
+       ~Connection();
 
-    int exec(const std::string& query);
-    bool isTableExists(const std::string& tableName);
+       int exec(const std::string& query);
+       bool isTableExists(const std::string& tableName);
 
-    inline long long getLastInsertRowId() const noexcept
-    {
-        return sqlite3_last_insert_rowid(handle);
-    }
+       inline long long getLastInsertRowId() const noexcept
+       {
+               return sqlite3_last_insert_rowid(handle);
+       }
 
-    inline const std::string& getName() const noexcept
-    {
-        return filename;
-    }
+       inline const std::string& getName() const noexcept
+       {
+               return filename;
+       }
 
-    inline int getErrorCode() const
-    {
-        return sqlite3_errcode(handle);
-    }
+       inline int getErrorCode() const
+       {
+               return sqlite3_errcode(handle);
+       }
 
-    inline int getExtendedErrorCode() const
-    {
-        return sqlite3_extended_errcode(handle);
-    }
+       inline int getExtendedErrorCode() const
+       {
+               return sqlite3_extended_errcode(handle);
+       }
 
-    inline std::string getErrorMessage() const
-    {
-        return sqlite3_errmsg(handle);
-    }
+       inline std::string getErrorMessage() const
+       {
+               return sqlite3_errmsg(handle);
+       }
 
-    inline sqlite3* get() const noexcept
-    {
-        return handle;
-    }
+       inline sqlite3* get() const noexcept
+       {
+               return handle;
+       }
 
 private:
-    sqlite3* handle;
-    std::string filename;
+       sqlite3* handle;
+       std::string filename;
 };
 
 } // namespace database
index f45b062..22d2243 100644 (file)
 namespace database {
 
 Statement::Statement(const Connection& db, const std::string& query) :
-    statement(nullptr),
-    columnCount(0),
-    validRow(false)
+       statement(nullptr),
+       columnCount(0),
+       validRow(false)
 {
-    if (SQLITE_OK != ::sqlite3_prepare_v2(db.get(),
-                                          query.c_str(),
-                                          query.size(),
-                                          &statement,
-                                          NULL)) {
-        throw runtime::Exception(db.getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_prepare_v2(db.get(),
+                                                                                 query.c_str(),
+                                                                                 query.size(),
+                                                                                 &statement,
+                                                                                 NULL)) {
+               throw runtime::Exception(db.getErrorMessage());
+       }
 
-    columnCount = sqlite3_column_count(statement);
+       columnCount = sqlite3_column_count(statement);
 }
 
 Statement::~Statement()
 {
-    ::sqlite3_finalize(statement);
+       ::sqlite3_finalize(statement);
 }
 
 void Statement::reset()
 {
-    if (::sqlite3_reset(statement) != SQLITE_OK) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (::sqlite3_reset(statement) != SQLITE_OK) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::clearBindings()
 {
-    if (::sqlite3_clear_bindings(statement) != SQLITE_OK) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (::sqlite3_clear_bindings(statement) != SQLITE_OK) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 std::string Statement::getErrorMessage() const
 {
-    return ::sqlite3_errmsg(::sqlite3_db_handle(statement));
+       return ::sqlite3_errmsg(::sqlite3_db_handle(statement));
 }
 
 std::string Statement::getErrorMessage(int errorCode) const
 {
-    return ::sqlite3_errstr(errorCode);
+       return ::sqlite3_errstr(errorCode);
 }
 
 bool Statement::step()
 {
-    if (SQLITE_ROW == ::sqlite3_step(statement)) {
-        return (validRow = true);
-    }
+       if (SQLITE_ROW == ::sqlite3_step(statement)) {
+               return (validRow = true);
+       }
 
-    return (validRow = false);
+       return (validRow = false);
 }
 
 int Statement::exec()
 {
-    if (SQLITE_DONE == ::sqlite3_step(statement)) {
-        validRow = false;
-    }
+       if (SQLITE_DONE == ::sqlite3_step(statement)) {
+               validRow = false;
+       }
 
-    return sqlite3_changes(sqlite3_db_handle(statement));
+       return sqlite3_changes(sqlite3_db_handle(statement));
 }
 
 Column Statement::getColumn(const int index)
 {
-    if (!validRow || (index >= columnCount)) {
-        throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
-    }
+       if (!validRow || (index >= columnCount)) {
+               throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
+       }
 
-    return Column(*this, index);
+       return Column(*this, index);
 }
 
 bool Statement::isNullColumn(const int index) const
 {
-    if (!validRow || (index >= columnCount)) {
-        throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
-    }
+       if (!validRow || (index >= columnCount)) {
+               throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
+       }
 
-    return (SQLITE_NULL == sqlite3_column_type(statement, index));
+       return (SQLITE_NULL == sqlite3_column_type(statement, index));
 }
 
 std::string Statement::getColumnName(const int index) const
 {
-    if (index >= columnCount) {
-        throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
-    }
+       if (index >= columnCount) {
+               throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
+       }
 
-    return sqlite3_column_name(statement, index);
+       return sqlite3_column_name(statement, index);
 }
 
 
 void Statement::bind(const int index, const int& value)
 {
-    if (SQLITE_OK != ::sqlite3_bind_int(statement, index, value)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_bind_int(statement, index, value)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const int index, const sqlite3_int64& value)
 {
-    if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const int index, const double& value)
 {
-    if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const int index, const char* value)
 {
-    if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const int index, const std::string& value)
 {
-    if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(),
-                                         static_cast<int>(value.size()), SQLITE_TRANSIENT)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(),
+                                                                                static_cast<int>(value.size()), SQLITE_TRANSIENT)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const int index, const void* value, const int size)
 {
-    if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const int index)
 {
-    if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const std::string& name, const int& value)
 {
-    int index = sqlite3_bind_parameter_index(statement, name.c_str());
-    if (SQLITE_OK != sqlite3_bind_int(statement, index, value)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       int index = sqlite3_bind_parameter_index(statement, name.c_str());
+       if (SQLITE_OK != sqlite3_bind_int(statement, index, value)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const std::string& name, const sqlite3_int64& value)
 {
-    int index = sqlite3_bind_parameter_index(statement, name.c_str());
-    if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       int index = sqlite3_bind_parameter_index(statement, name.c_str());
+       if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const std::string& name, const double& value)
 {
-    int index = sqlite3_bind_parameter_index(statement, name.c_str());
-    if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       int index = sqlite3_bind_parameter_index(statement, name.c_str());
+       if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const std::string& name, const std::string& value)
 {
-    int index = sqlite3_bind_parameter_index(statement, name.c_str());
-    if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(),
-                                         static_cast<int>(value.size()), SQLITE_TRANSIENT)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       int index = sqlite3_bind_parameter_index(statement, name.c_str());
+       if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(),
+                                                                                static_cast<int>(value.size()), SQLITE_TRANSIENT)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const std::string& name, const char* value)
 {
-    int index = sqlite3_bind_parameter_index(statement, name.c_str());
-    if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       int index = sqlite3_bind_parameter_index(statement, name.c_str());
+       if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const std::string& name, const void* value, const int size)
 {
-    int index = sqlite3_bind_parameter_index(statement, name.c_str());
-    if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       int index = sqlite3_bind_parameter_index(statement, name.c_str());
+       if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 void Statement::bind(const std::string& name)
 {
-    int index = sqlite3_bind_parameter_index(statement, name.c_str());
-    if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) {
-        throw runtime::Exception(getErrorMessage());
-    }
+       int index = sqlite3_bind_parameter_index(statement, name.c_str());
+       if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) {
+               throw runtime::Exception(getErrorMessage());
+       }
 }
 
 } // namespace database
index 4c7313a..c834303 100644 (file)
@@ -29,54 +29,54 @@ class Connection;
 
 class Statement {
 public:
-    Statement(const Connection& db, const std::string& query);
-    virtual ~Statement();
-
-    int exec();
-    bool step();
-
-    void reset();
-    void clearBindings();
-    std::string getErrorMessage() const;
-    std::string getErrorMessage(int errorCode) const;
-
-    Column getColumn(const int index);
-    std::string getColumnName(const int index) const;
-    bool isNullColumn(const int index) const;
-
-    void bind(const int index, const int& value);
-    void bind(const int index, const sqlite3_int64& value);
-    void bind(const int index, const double& value);
-    void bind(const int index, const std::string& value);
-    void bind(const int index, const char* value);
-    void bind(const int index, const void* value, const int size);
-    void bind(const int index);
-
-    void bind(const std::string& name, const int& value);
-    void bind(const std::string& name, const sqlite3_int64& value);
-    void bind(const std::string& name, const double& value);
-    void bind(const std::string& name, const std::string& value);
-    void bind(const std::string& name, const char* value);
-    void bind(const std::string& name, const void* value, const int size);
-    void bind(const std::string& name);
-
-    inline int getColumnCount() const
-    {
-        return columnCount;
-    }
-
-    inline sqlite3_stmt* get() const noexcept
-    {
-        return statement;
-    }
+       Statement(const Connection& db, const std::string& query);
+       virtual ~Statement();
+
+       int exec();
+       bool step();
+
+       void reset();
+       void clearBindings();
+       std::string getErrorMessage() const;
+       std::string getErrorMessage(int errorCode) const;
+
+       Column getColumn(const int index);
+       std::string getColumnName(const int index) const;
+       bool isNullColumn(const int index) const;
+
+       void bind(const int index, const int& value);
+       void bind(const int index, const sqlite3_int64& value);
+       void bind(const int index, const double& value);
+       void bind(const int index, const std::string& value);
+       void bind(const int index, const char* value);
+       void bind(const int index, const void* value, const int size);
+       void bind(const int index);
+
+       void bind(const std::string& name, const int& value);
+       void bind(const std::string& name, const sqlite3_int64& value);
+       void bind(const std::string& name, const double& value);
+       void bind(const std::string& name, const std::string& value);
+       void bind(const std::string& name, const char* value);
+       void bind(const std::string& name, const void* value, const int size);
+       void bind(const std::string& name);
+
+       inline int getColumnCount() const
+       {
+               return columnCount;
+       }
+
+       inline sqlite3_stmt* get() const noexcept
+       {
+               return statement;
+       }
 
 private:
-    typedef std::map<std::string, int> ColumnMap;
+       typedef std::map<std::string, int> ColumnMap;
 
-    sqlite3_stmt* statement;
-    int columnCount;
-    int validRow;
-    ColumnMap columnNames;
+       sqlite3_stmt* statement;
+       int columnCount;
+       int validRow;
+       ColumnMap columnNames;
 };
 
 } // namespace database
index f609260..68c063e 100644 (file)
@@ -29,141 +29,141 @@ namespace {
 const std::string DBUS_SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket";
 
 void defaultCallback(GDBusConnection* connection,
-                     const gchar *sender_name,
-                     const gchar *object_path,
-                     const gchar *interface_name,
-                     const gchar *signal_name,
-                     GVariant *parameters,
-                     gpointer user_data) {
-    Connection::signalCallback* func = reinterpret_cast<Connection::signalCallback*> (user_data);
-    (*func)(Variant(parameters));
-    delete func;
+                                        const gchar *sender_name,
+                                        const gchar *object_path,
+                                        const gchar *interface_name,
+                                        const gchar *signal_name,
+                                        GVariant *parameters,
+                                        gpointer user_data) {
+       Connection::signalCallback* func = reinterpret_cast<Connection::signalCallback*> (user_data);
+       (*func)(Variant(parameters));
+       delete func;
 }
 
 } // namespace
 
 Connection::Connection(const std::string& address) :
-     connection(nullptr)
+        connection(nullptr)
 {
-    Error error;
-    const GDBusConnectionFlags flags = static_cast<GDBusConnectionFlags>
-        (G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION);
-
-    connection = g_dbus_connection_new_for_address_sync(address.c_str(), flags, NULL, NULL, &error);
-    if (error) {
-        ERROR(error->message);
-        throw runtime::Exception(error->message);
-    }
+       Error error;
+       const GDBusConnectionFlags flags = static_cast<GDBusConnectionFlags>
+               (G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION);
+
+       connection = g_dbus_connection_new_for_address_sync(address.c_str(), flags, NULL, NULL, &error);
+       if (error) {
+               ERROR(error->message);
+               throw runtime::Exception(error->message);
+       }
 }
 
 Connection::Connection(Connection&& other) :
-    connection(other.connection)
+       connection(other.connection)
 {
-    other.connection = nullptr;
+       other.connection = nullptr;
 }
 
 Connection::~Connection()
 {
-    if (connection) {
-        g_dbus_connection_close_sync(connection, NULL, NULL);
-        g_object_unref(connection);
-    }
+       if (connection) {
+               g_dbus_connection_close_sync(connection, NULL, NULL);
+               g_object_unref(connection);
+       }
 }
 
 Connection& Connection::getSystem()
 {
-    static Connection __instance__(DBUS_SYSTEM_BUS_ADDRESS);
-    return __instance__;
+       static Connection __instance__(DBUS_SYSTEM_BUS_ADDRESS);
+       return __instance__;
 }
 
 void Connection::emitSignal(const std::string& busName,
-                            const std::string& object,
-                            const std::string& interface,
-                            const std::string& name,
-                            const std::string& paramType,
-                            ...)
+                                                       const std::string& object,
+                                                       const std::string& interface,
+                                                       const std::string& name,
+                                                       const std::string& paramType,
+                                                       ...)
 {
-    Error error;
-    va_list ap;
-
-    va_start(ap, paramType);
-    g_dbus_connection_emit_signal(connection,
-                                  busName.empty() ? NULL : busName.c_str(),
-                                  object.c_str(),
-                                  interface.c_str(),
-                                  name.c_str(),
-                                  paramType.empty() ? NULL :
-                                      g_variant_new(paramType.c_str(), NULL, &ap),
-                                  &error);
-    va_end(ap);
-
-    if (error) {
-        ERROR(error->message);
-        throw runtime::Exception(error->message);
-    }
+       Error error;
+       va_list ap;
+
+       va_start(ap, paramType);
+       g_dbus_connection_emit_signal(connection,
+                                                                 busName.empty() ? NULL : busName.c_str(),
+                                                                 object.c_str(),
+                                                                 interface.c_str(),
+                                                                 name.c_str(),
+                                                                 paramType.empty() ? NULL :
+                                                                 g_variant_new(paramType.c_str(), NULL, &ap),
+                                                                 &error);
+       va_end(ap);
+
+       if (error) {
+               ERROR(error->message);
+               throw runtime::Exception(error->message);
+       }
 }
 
 Connection::subscriptionId Connection::subscribeSignal(const std::string& sender,
-                                                       const std::string& interface,
-                                                       const std::string& object,
-                                                       const std::string& member,
-                                                       const signalCallback callback)
+                                                                                                          const std::string& interface,
+                                                                                                          const std::string& object,
+                                                                                                          const std::string& member,
+                                                                                                          const signalCallback callback)
 {
-    subscriptionId id;
-    id = g_dbus_connection_signal_subscribe(connection,
-                                            sender.empty()    ? NULL : sender.c_str(),
-                                            interface.empty() ? NULL : interface.c_str(),
-                                            object.empty()    ? NULL : object.c_str(),
-                                            member.empty()    ? NULL : member.c_str(),
-                                            NULL,
-                                            G_DBUS_SIGNAL_FLAGS_NONE,
-                                            defaultCallback,
-                                            new signalCallback(callback),
-                                            NULL);
-    return id;
+       subscriptionId id;
+       id = g_dbus_connection_signal_subscribe(connection,
+                                                                                       sender.empty()    ? NULL : sender.c_str(),
+                                                                                       interface.empty() ? NULL : interface.c_str(),
+                                                                                       object.empty()    ? NULL : object.c_str(),
+                                                                                       member.empty()    ? NULL : member.c_str(),
+                                                                                       NULL,
+                                                                                       G_DBUS_SIGNAL_FLAGS_NONE,
+                                                                                       defaultCallback,
+                                                                                       new signalCallback(callback),
+                                                                                       NULL);
+       return id;
 }
 
 void Connection::unsubscribeSignal(Connection::subscriptionId id)
 {
-    g_dbus_connection_signal_unsubscribe(connection, id);
+       g_dbus_connection_signal_unsubscribe(connection, id);
 }
 
 const Variant Connection::methodcall(const std::string& busName,
-                                     const std::string& object,
-                                     const std::string& interface,
-                                     const std::string& method,
-                                     int timeout,
-                                     const std::string& replyType,
-                                     const std::string& paramType,
-                                     ...)
+                                                                        const std::string& object,
+                                                                        const std::string& interface,
+                                                                        const std::string& method,
+                                                                        int timeout,
+                                                                        const std::string& replyType,
+                                                                        const std::string& paramType,
+                                                                        ...)
 {
-    Variant result;
-    Error error;
-    va_list ap;
-
-    va_start(ap, paramType);
-    result = g_dbus_connection_call_sync(connection,
-                                         busName.empty() ? NULL :
-                                             busName.c_str(),
-                                         object.c_str(),
-                                         interface.c_str(),
-                                         method.c_str(),
-                                         paramType.empty() ? NULL :
-                                             g_variant_new_va(paramType.c_str(), NULL, &ap),
-                                         replyType.empty() ? NULL :
-                                             G_VARIANT_TYPE(replyType.c_str()),
-                                         G_DBUS_CALL_FLAGS_NONE,
-                                         timeout,
-                                         NULL,
-                                         &error);
-    va_end(ap);
-
-    if (error) {
-        ERROR(error->message);
-        throw runtime::Exception(error->message);
-    }
-
-    return result;
+       Variant result;
+       Error error;
+       va_list ap;
+
+       va_start(ap, paramType);
+       result = g_dbus_connection_call_sync(connection,
+                                                                                busName.empty() ? NULL :
+                                                                                busName.c_str(),
+                                                                                object.c_str(),
+                                                                                interface.c_str(),
+                                                                                method.c_str(),
+                                                                                paramType.empty() ? NULL :
+                                                                                g_variant_new_va(paramType.c_str(), NULL, &ap),
+                                                                                replyType.empty() ? NULL :
+                                                                                G_VARIANT_TYPE(replyType.c_str()),
+                                                                                G_DBUS_CALL_FLAGS_NONE,
+                                                                                timeout,
+                                                                                NULL,
+                                                                                &error);
+       va_end(ap);
+
+       if (error) {
+               ERROR(error->message);
+               throw runtime::Exception(error->message);
+       }
+
+       return result;
 }
 
 } // namespace dbus
index 89b02ff..2fa82d7 100644 (file)
@@ -28,47 +28,47 @@ namespace dbus {
 
 class Connection {
 public:
-    typedef unsigned int subscriptionId;
-    typedef std::function<void(Variant)> signalCallback;
+       typedef unsigned int subscriptionId;
+       typedef std::function<void(Variant)> signalCallback;
 
-    Connection() = delete;
-    Connection(const Connection&) = delete;
-    Connection(Connection&&);
-    ~Connection();
+       Connection() = delete;
+       Connection(const Connection&) = delete;
+       Connection(Connection&&);
+       ~Connection();
 
-    Connection& operator=(const Connection&) = delete;
+       Connection& operator=(const Connection&) = delete;
 
-    static Connection& getSystem();
+       static Connection& getSystem();
 
-    void emitSignal(const std::string& busName,
-                    const std::string& object,
-                    const std::string& interface,
-                    const std::string& name,
-                    const std::string& paramType,
-                    ...);
+       void emitSignal(const std::string& busName,
+                                       const std::string& object,
+                                       const std::string& interface,
+                                       const std::string& name,
+                                       const std::string& paramType,
+                                       ...);
 
-    subscriptionId subscribeSignal(const std::string& sender,
-                                   const std::string& interface,
-                                   const std::string& object,
-                                   const std::string& member,
-                                   const signalCallback callback);
+       subscriptionId subscribeSignal(const std::string& sender,
+                                                                  const std::string& interface,
+                                                                  const std::string& object,
+                                                                  const std::string& member,
+                                                                  const signalCallback callback);
 
 
-    void unsubscribeSignal(subscriptionId id);
+       void unsubscribeSignal(subscriptionId id);
 
-    const Variant methodcall(const std::string& busName,
-                             const std::string& object,
-                             const std::string& interface,
-                             const std::string& method,
-                             int timeout,
-                             const std::string& replyType,
-                             const std::string& paramType,
-                             ...);
+       const Variant methodcall(const std::string& busName,
+                                                        const std::string& object,
+                                                        const std::string& interface,
+                                                        const std::string& method,
+                                                        int timeout,
+                                                        const std::string& replyType,
+                                                        const std::string& paramType,
+                                                        ...);
 
 private:
-    Connection(const std::string& address);
+       Connection(const std::string& address);
 
-    GDBusConnection* connection;
+       GDBusConnection* connection;
 };
 
 } // namespace dbus
index 8a5b2f2..87a4a1d 100644 (file)
 namespace dbus {
 
 Error::Error() :
-    error(nullptr)
+       error(nullptr)
 {
 }
 
 Error::~Error()
 {
-    if (error) {
-        g_error_free(error);
-    }
+       if (error) {
+               g_error_free(error);
+       }
 }
 
 GError** Error::operator& ()
 {
-    return &error;
+       return &error;
 }
 
 const GError* Error::operator-> () const
 {
-        return error;
+       return error;
 }
 
 Error::operator bool () const
 {
-    return error != nullptr;
+       return error != nullptr;
 }
 
 std::ostream& operator<<(std::ostream& os, const Error& e)
 {
-    return os << e->message;
+       return os << e->message;
 }
 
 } // namespace dbus
index e6c7a1e..b57ab32 100644 (file)
@@ -24,17 +24,17 @@ namespace dbus {
 
 class Error {
 public:
-    Error();
-    ~Error();
+       Error();
+       ~Error();
 
-    GError** operator& ();
-    const GError* operator-> () const;
-    operator bool () const;
+       GError** operator& ();
+       const GError* operator-> () const;
+       operator bool () const;
 
-    friend std::ostream& operator<<(std::ostream& os, const Error& e);
+       friend std::ostream& operator<<(std::ostream& os, const Error& e);
 
 private:
-    GError* error;
+       GError* error;
 };
 
 } // namespace dbus
index 579ed6c..524a25f 100644 (file)
 namespace dbus {
 
 Variant::Variant(GVariant* var) :
-    variant(var)
+       variant(var)
 {
 }
 
 Variant::Variant(Variant&& var) :
-    variant(var.variant)
+       variant(var.variant)
 {
-    var.variant = nullptr;
+       var.variant = nullptr;
 }
 
 Variant::Variant() :
-    variant(nullptr)
+       variant(nullptr)
 {
 }
 
 Variant::~Variant()
 {
-    if (variant) {
-        g_variant_unref(variant);
-    }
+       if (variant) {
+               g_variant_unref(variant);
+       }
 }
 
 Variant& Variant::operator=(GVariant* var)
 {
-    variant = var;
-    return *this;
+       variant = var;
+       return *this;
 }
 
 Variant::operator bool () const
 {
-    return variant != nullptr;
+       return variant != nullptr;
 }
 
 void Variant::get(const std::string& format, ...) const
 {
-    va_list ap;
+       va_list ap;
 
-    va_start(ap, format);
-    g_variant_get_va(variant, format.c_str(), NULL, &ap);
-    va_end(ap);
+       va_start(ap, format);
+       g_variant_get_va(variant, format.c_str(), NULL, &ap);
+       va_end(ap);
 }
 
 
 VariantIterator::VariantIterator(GVariantIter* it) :
-    iterator(it)
+       iterator(it)
 {
 }
 
 VariantIterator::VariantIterator(VariantIterator&& it) :
-    iterator(it.iterator)
+       iterator(it.iterator)
 {
-    it.iterator = nullptr;
+       it.iterator = nullptr;
 }
 
 VariantIterator::VariantIterator() :
-    iterator(nullptr)
+       iterator(nullptr)
 {
 }
 
 VariantIterator::~VariantIterator()
 {
-    if (iterator) {
-        g_variant_iter_free(iterator);
-    }
+       if (iterator) {
+               g_variant_iter_free(iterator);
+       }
 }
 
 VariantIterator& VariantIterator::operator=(GVariantIter* it)
 {
-    iterator = it;
-    return *this;
+       iterator = it;
+       return *this;
 }
 
 VariantIterator::operator bool () const
 {
-    return iterator != nullptr;
+       return iterator != nullptr;
 }
 
 GVariantIter** VariantIterator::operator & ()
 {
-    return &iterator;
+       return &iterator;
 }
 
 bool VariantIterator::get(const std::string& format, ...) const
 {
-    GVariant *var;
-    va_list ap;
-    var = g_variant_iter_next_value(iterator);
-    if (var == NULL) {
-        return false;
-    }
+       GVariant *var;
+       va_list ap;
+       var = g_variant_iter_next_value(iterator);
+       if (var == NULL) {
+               return false;
+       }
 
-    va_start(ap, format);
-    g_variant_get_va(var, format.c_str(), NULL, &ap);
-    va_end(ap);
+       va_start(ap, format);
+       g_variant_get_va(var, format.c_str(), NULL, &ap);
+       va_end(ap);
 
-    g_variant_unref(var);
+       g_variant_unref(var);
 
-    return true;
+       return true;
 }
 
 } // namespace dbus
index 832fe8c..9b4348b 100644 (file)
@@ -24,34 +24,34 @@ namespace dbus {
 
 class Variant {
 public:
-    Variant(GVariant* var);
-    Variant(Variant&& var);
-    Variant();
-    ~Variant();
+       Variant(GVariant* var);
+       Variant(Variant&& var);
+       Variant();
+       ~Variant();
 
-    Variant& operator=(GVariant* var);
-    operator bool () const;
-    GVariant* operator & ();
+       Variant& operator=(GVariant* var);
+       operator bool () const;
+       GVariant* operator & ();
 
-    void get(const std::string& format, ...) const;
+       void get(const std::string& format, ...) const;
 private:
-    GVariant* variant;
+       GVariant* variant;
 };
 
 class VariantIterator {
 public:
-    VariantIterator(GVariantIter* it);
-    VariantIterator(VariantIterator&& it);
-    VariantIterator();
-    ~VariantIterator();
+       VariantIterator(GVariantIter* it);
+       VariantIterator(VariantIterator&& it);
+       VariantIterator();
+       ~VariantIterator();
 
-    VariantIterator& operator=(GVariantIter* it);
-    operator bool () const;
-    GVariantIter** operator & ();
+       VariantIterator& operator=(GVariantIter* it);
+       operator bool () const;
+       GVariantIter** operator & ();
 
-    bool get(const std::string& format, ...) const;
+       bool get(const std::string& format, ...) const;
 private:
-    GVariantIter* iterator;
+       GVariantIter* iterator;
 };
 
 
index f4c6a89..839d3ca 100644 (file)
@@ -24,28 +24,28 @@ namespace runtime {
 
 int Error::lastErrorCode()
 {
-    return errno;
+       return errno;
 }
 
 std::string Error::message(int errorCode)
 {
-    char errmsg[256];
-    return ::strerror_r(errorCode, errmsg, sizeof(errmsg));
+       char errmsg[256];
+       return ::strerror_r(errorCode, errmsg, sizeof(errmsg));
 }
 
 std::string Error::message()
 {
-    return message(lastErrorCode());
+       return message(lastErrorCode());
 }
 
 std::string GetSystemErrorMessage(int errorCode)
 {
-    return Error::message(errorCode);
+       return Error::message(errorCode);
 }
 
 std::string GetSystemErrorMessage()
 {
-    return Error::message();
+       return Error::message();
 }
 
 } // namespace runtime
index af42719..f746c38 100644 (file)
@@ -23,9 +23,9 @@ namespace runtime {
 
 class Error {
 public:
-    static std::string message();
-    static std::string message(int errorCode);
-    static int lastErrorCode();
+       static std::string message();
+       static std::string message(int errorCode);
+       static int lastErrorCode();
 };
 
 std::string GetSystemErrorMessage();
index 0ecc9f4..c9891db 100644 (file)
@@ -27,33 +27,33 @@ namespace runtime {
 
 EventFD::EventFD(unsigned int initval, int flags)
 {
-    fd = ::eventfd(initval, flags);
-    if (fd == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       fd = ::eventfd(initval, flags);
+       if (fd == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 }
 
 EventFD::~EventFD()
 {
-    if (fd != -1) {
-        ::close(fd);
-    }
+       if (fd != -1) {
+               ::close(fd);
+       }
 }
 
 void EventFD::send()
 {
-    const std::uint64_t val = 1;
-    if (::write(fd, &val, sizeof(val)) == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       const std::uint64_t val = 1;
+       if (::write(fd, &val, sizeof(val)) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 }
 
 void EventFD::receive()
 {
-    std::uint64_t val;
-    if (::read(fd, &val, sizeof(val)) == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       std::uint64_t val;
+       if (::read(fd, &val, sizeof(val)) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 }
 
 } // namespace runtime
index c645227..98c4119 100644 (file)
@@ -23,25 +23,24 @@ namespace runtime {
 
 class EventFD {
 public:
-    EventFD(unsigned int initval = 0, int flags = EFD_SEMAPHORE | EFD_CLOEXEC);
-    ~EventFD();
+       EventFD(unsigned int initval = 0, int flags = EFD_SEMAPHORE | EFD_CLOEXEC);
+       ~EventFD();
 
-    EventFD(const EventFD&) = delete;
-    EventFD& operator=(const EventFD&) = delete;
+       EventFD(const EventFD&) = delete;
+       EventFD& operator=(const EventFD&) = delete;
 
-    void send();
-    void receive();
+       void send();
+       void receive();
 
-    int getFd() const
-    {
-        return fd;
-    }
+       int getFd() const
+       {
+               return fd;
+       }
 
 private:
-    int fd;
+       int fd;
 };
 
 } // namespace runtime
 
 #endif //__RUNTIME_EVENTFD_H__
-
index efa4ecd..734019a 100644 (file)
@@ -24,10 +24,10 @@ namespace runtime {
 
 class Exception: public std::runtime_error {
 public:
-    Exception(const std::string& error) :
-        std::runtime_error(error)
-    {
-    }
+       Exception(const std::string& error) :
+               std::runtime_error(error)
+       {
+       }
 };
 } // namespace runtime
 #endif //__RUNTIME_EXCEPTION_H__
index bfbcadf..d032c05 100644 (file)
 #include <iostream>
 
 struct FileDescriptor {
-    FileDescriptor(int fd = -1, bool autoclose = false) :
-        fileDescriptor(fd),
-        autoClose(autoclose)
-    {
-    }
+       FileDescriptor(int fd = -1, bool autoclose = false) :
+               fileDescriptor(fd), autoClose(autoclose)
+       {
+       }
 
-    FileDescriptor(const FileDescriptor&) = delete;
-    FileDescriptor(FileDescriptor&& rhs) :
-        fileDescriptor(rhs.fileDescriptor),
-        autoClose(rhs.autoClose)
-    {
-        rhs.fileDescriptor = -1;
-    }
+       FileDescriptor(const FileDescriptor&) = delete;
+       FileDescriptor(FileDescriptor&& rhs) :
+               fileDescriptor(rhs.fileDescriptor),
+               autoClose(rhs.autoClose)
+       {
+               rhs.fileDescriptor = -1;
+       }
 
-    ~FileDescriptor() {
-        if ((fileDescriptor != -1) && (autoClose == true)) {
-            ::close(fileDescriptor);
-        }
-    }
+       ~FileDescriptor() {
+               if ((fileDescriptor != -1) && (autoClose == true)) {
+                       ::close(fileDescriptor);
+               }
+       }
 
-    FileDescriptor& operator=(const int fd) {
-        fileDescriptor = fd;
-        autoClose = false;
-        return *this;
-    }
+       FileDescriptor& operator=(const int fd) {
+               fileDescriptor = fd;
+               autoClose = false;
+               return *this;
+       }
 
-    FileDescriptor& operator=(FileDescriptor&& rhs) {
-        if (this != &rhs) {
-            fileDescriptor = rhs.fileDescriptor;
-            autoClose = rhs.autoClose;
-            rhs.fileDescriptor = -1;
-        }
+       FileDescriptor& operator=(FileDescriptor&& rhs) {
+               if (this != &rhs) {
+                       fileDescriptor = rhs.fileDescriptor;
+                       autoClose = rhs.autoClose;
+                       rhs.fileDescriptor = -1;
+               }
 
-        return *this;
-    }
+               return *this;
+       }
 
-    int fileDescriptor;
-    bool autoClose;
+       int fileDescriptor;
+       bool autoClose;
 };
 
 #endif //__RUNTIME_FILE_DESCRIPTOR_H__
index d563f18..b6a57f3 100755 (executable)
 
 namespace runtime {
 
-File::File()
-    : descriptor(-1)
+File::File() :
+       descriptor(-1)
 {
 }
 
-File::File(const char* pathname)
-    : descriptor(-1), path(pathname)
+File::File(const char* pathname) :
+       descriptor(-1), path(pathname)
 {
 }
 
-File::File(const std::string& pathname)
-    : descriptor(-1), path(pathname)
+File::File(const std::string& pathname) :
+       descriptor(-1), path(pathname)
 {
 }
 
-File::File(const File& file)
-    : File(file.getPath())
+File::File(const File& file) :
+       File(file.getPath())
 {
 }
 
-File::File(const std::string& pathname, int flags)
-    : File(pathname)
+File::File(const std::string& pathname, int flags) :
+       File(pathname)
 {
-    open(flags);
+       open(flags);
 }
 
 File::~File()
 {
-    close();
+       close();
 }
 
 bool File::exists() const
 {
-    struct stat st;
-    return (::stat(path.c_str(), &st) == 0);
+       struct stat st;
+       return (::stat(path.c_str(), &st) == 0);
 }
 
 bool File::canRead() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    if (st.st_uid == geteuid()) {
-        return ((st.st_mode & S_IRUSR) != 0);
-    } else if (st.st_gid == getegid()) {
-        return ((st.st_mode & S_IRGRP) != 0);
-    }
+       if (st.st_uid == geteuid()) {
+               return ((st.st_mode & S_IRUSR) != 0);
+       } else if (st.st_gid == getegid()) {
+               return ((st.st_mode & S_IRGRP) != 0);
+       }
 
-    return (((st.st_mode & S_IROTH) != 0) || (geteuid() == 0));
+       return (((st.st_mode & S_IROTH) != 0) || (geteuid() == 0));
 }
 
 bool File::canWrite() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    if (st.st_uid == geteuid()) {
-        return ((st.st_mode & S_IWUSR) != 0);
-    } else if (st.st_gid == getegid()) {
-        return ((st.st_mode & S_IWGRP) != 0);
-    }
+       if (st.st_uid == geteuid()) {
+               return ((st.st_mode & S_IWUSR) != 0);
+       } else if (st.st_gid == getegid()) {
+               return ((st.st_mode & S_IWGRP) != 0);
+       }
 
-    return (((st.st_mode & S_IWOTH) != 0) || (geteuid() == 0));
+       return (((st.st_mode & S_IWOTH) != 0) || (geteuid() == 0));
 }
 
 bool File::canExecute() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    if (st.st_uid == geteuid()) {
-        return ((st.st_mode & S_IXUSR) != 0);
-    } else if (st.st_gid == getegid()) {
-        return ((st.st_mode & S_IXGRP) != 0);
-    }
+       if (st.st_uid == geteuid()) {
+               return ((st.st_mode & S_IXUSR) != 0);
+       } else if (st.st_gid == getegid()) {
+               return ((st.st_mode & S_IXGRP) != 0);
+       }
 
-    return ((st.st_mode & S_IXOTH) != 0);
+       return ((st.st_mode & S_IXOTH) != 0);
 }
 
 bool File::isLink() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return S_ISLNK(st.st_mode);
+       return S_ISLNK(st.st_mode);
 }
 
 bool File::isFile() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return S_ISREG(st.st_mode);
+       return S_ISREG(st.st_mode);
 }
 
 bool File::isDirectory() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return S_ISDIR(st.st_mode);
+       return S_ISDIR(st.st_mode);
 }
 
 bool File::isDevice() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode));
+       return (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode));
 }
 
 mode_t File::getMode() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return st.st_mode;
+       return st.st_mode;
 }
 
 uid_t File::getUid() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return st.st_uid;
+       return st.st_uid;
 }
 
 gid_t File::getGid() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return st.st_gid;
+       return st.st_gid;
 }
 
 size_t File::size() const
 {
-    struct stat st;
-    if (::stat(path.c_str(), &st) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       struct stat st;
+       if (::stat(path.c_str(), &st) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    return st.st_size;
+       return st.st_size;
 }
 
 void File::create(mode_t mode)
 {
-    while (1) {
-        descriptor = ::creat(path.c_str(), mode);
-        if (descriptor == -1) {
-            if (errno != EINTR) {
-                continue;
-            }
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-        return;
-    }
+       while (1) {
+               descriptor = ::creat(path.c_str(), mode);
+               if (descriptor == -1) {
+                       if (errno != EINTR) {
+                               continue;
+                       }
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+               return;
+       }
 }
 
 void File::open(int flags)
 {
-    while (1) {
-        descriptor = ::open(path.c_str(), flags);
-        if (descriptor == -1) {
-            if (errno != EINTR) {
-                continue;
-            }
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-        return;
-    }
+       while (1) {
+               descriptor = ::open(path.c_str(), flags);
+               if (descriptor == -1) {
+                       if (errno != EINTR) {
+                               continue;
+                       }
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+               return;
+       }
 }
 
 void File::close()
 {
-    if (descriptor == -1) {
-        return;
-    }
+       if (descriptor == -1) {
+               return;
+       }
 
-    while (1) {
-        if (::close(descriptor) == -1) {
-            if (errno == EINTR) {
-                continue;
-            }
-        }
-        break;
-    }
+       while (1) {
+               if (::close(descriptor) == -1) {
+                       if (errno == EINTR) {
+                               continue;
+                       }
+               }
+               break;
+       }
 
-    descriptor = -1;
+       descriptor = -1;
 }
 
 void File::read(void *buffer, const size_t size) const
 {
-    size_t total = 0;
+       size_t total = 0;
 
-    while (total < size) {
-        int bytes = ::read(descriptor, reinterpret_cast<char*>(buffer) + total, size - total);
-        if (bytes >= 0) {
-            total += bytes;
-        } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
-            continue;
-        } else {
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-    }
+       while (total < size) {
+               int bytes = ::read(descriptor, reinterpret_cast<char*>(buffer) + total, size - total);
+               if (bytes >= 0) {
+                       total += bytes;
+               } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
+                       continue;
+               } else {
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 void File::write(const void *buffer, const size_t size) const
 {
-    size_t written = 0;
+       size_t written = 0;
 
-    while (written < size) {
-        int bytes = ::write(descriptor, reinterpret_cast<const char*>(buffer) + written, size - written);
-        if (bytes >= 0) {
-            written += bytes;
-        } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
-            continue;
-        } else {
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-    }
+       while (written < size) {
+               int bytes = ::write(descriptor, reinterpret_cast<const char*>(buffer) + written, size - written);
+               if (bytes >= 0) {
+                       written += bytes;
+               } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
+                       continue;
+               } else {
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 File File::copyTo(const std::string& destDir)
 {
-    const std::string& filename = getPath();
-    File destFile(destDir);
-    if (destFile.exists()) {
-        destFile = destDir + "/" + getName();
-    }
+       const std::string& filename = getPath();
+       File destFile(destDir);
+       if (destFile.exists()) {
+               destFile = destDir + "/" + getName();
+       }
 
-    if (isDirectory()) {
-        DirectoryIterator iter(filename), end;
-        destFile.makeDirectory(false, getUid(), getGid());
+       if (isDirectory()) {
+               DirectoryIterator iter(filename), end;
+               destFile.makeDirectory(false, getUid(), getGid());
 
-        while (iter != end) {
-            iter->copyTo(destFile.getPath());
-            ++iter;
-        }
-    } else {
-        open(O_RDONLY);
-        destFile.create(getMode());
-        ::sendfile(destFile.descriptor, descriptor, 0, size());
-        destFile.close();
-        close();
-    }
+               while (iter != end) {
+                       iter->copyTo(destFile.getPath());
+                       ++iter;
+               }
+       } else {
+               open(O_RDONLY);
+               destFile.create(getMode());
+               ::sendfile(destFile.descriptor, descriptor, 0, size());
+               destFile.close();
+               close();
+       }
 
-    return destFile;
+       return destFile;
 }
 
 void File::remove(bool recursive)
 {
-    if (isDirectory()) {
-        if (recursive) {
-            DirectoryIterator iter(path), end;
-            while (iter != end) {
-                iter->remove(true);
-                ++iter;
-            }
-        }
-        if (::rmdir(path.c_str()) != 0) {
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-    } else {
-        if (::unlink(path.c_str()) != 0) {
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-    }
+       if (isDirectory()) {
+               if (recursive) {
+                       DirectoryIterator iter(path), end;
+                       while (iter != end) {
+                               iter->remove(true);
+                               ++iter;
+                       }
+               }
+               if (::rmdir(path.c_str()) != 0) {
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+       } else {
+               if (::unlink(path.c_str()) != 0) {
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 void File::makeBaseDirectory(uid_t uid, gid_t gid)
 {
-    std::string::size_type i = path[0] != '/' ? -1 : 0;
-    const std::string& pathStr = path;
-    while ((i = pathStr.find('/', i + 1)) != std::string::npos) {
-        std::string substr = pathStr.substr(0, i);
-        int ret = ::mkdir(substr.c_str(), 0777);
-        if ((ret == -1) && (errno == EEXIST)) {
-            continue;
-        } else if (ret == 0) {
-            if ((uid | gid) != 0) {
-                if (::chown(substr.c_str(), uid, gid) == -1) {
-                    throw runtime::Exception(runtime::GetSystemErrorMessage());
-                }
-            }
-        } else {
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-    }
+       std::string::size_type i = path[0] != '/' ? -1 : 0;
+       const std::string& pathStr = path;
+       while ((i = pathStr.find('/', i + 1)) != std::string::npos) {
+               std::string substr = pathStr.substr(0, i);
+               int ret = ::mkdir(substr.c_str(), 0777);
+               if ((ret == -1) && (errno == EEXIST)) {
+                       continue;
+               } else if (ret == 0) {
+                       if ((uid | gid) != 0) {
+                               if (::chown(substr.c_str(), uid, gid) == -1) {
+                                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                               }
+                       }
+               } else {
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 void File::makeDirectory(bool recursive, uid_t uid, gid_t gid)
 {
-    if (recursive) {
-        makeBaseDirectory(uid, gid);
-    }
+       if (recursive) {
+               makeBaseDirectory(uid, gid);
+       }
 
-    if (::mkdir(path.c_str(), 0777) == -1) {
-        throw runtime::Exception("mkdir failed in makeDirectory: " + path);
-    }
+       if (::mkdir(path.c_str(), 0777) == -1) {
+               throw runtime::Exception("mkdir failed in makeDirectory: " + path);
+       }
 
-    if ((uid | gid) != 0) {
-        chown(uid, gid);
-    }
+       if ((uid | gid) != 0) {
+               chown(uid, gid);
+       }
 }
 
 void File::chown(uid_t uid, gid_t gid, bool recursive)
 {
-    if (::chown(path.c_str(), uid, gid) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       if (::chown(path.c_str(), uid, gid) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    if (recursive && isDirectory()) {
-        DirectoryIterator iter(path), end;
-        while (iter != end) {
-            iter->chown(uid, gid, true);
-            ++iter;
-        }
-    }
+       if (recursive && isDirectory()) {
+               DirectoryIterator iter(path), end;
+               while (iter != end) {
+                       iter->chown(uid, gid, true);
+                       ++iter;
+               }
+       }
 }
 
 void File::chmod(mode_t mode, bool recursive)
 {
-    if (::chmod(path.c_str(), mode) != 0) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       if (::chmod(path.c_str(), mode) != 0) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    if (recursive && isDirectory()) {
-        DirectoryIterator iter(path), end;
-        while (iter != end) {
-            iter->chmod(mode, true);
-            ++iter;
-        }
-    }
+       if (recursive && isDirectory()) {
+               DirectoryIterator iter(path), end;
+               while (iter != end) {
+                       iter->chmod(mode, true);
+                       ++iter;
+               }
+       }
 }
 
 void File::lock() const
 {
-    if (::flock(descriptor, LOCK_EX) == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       if (::flock(descriptor, LOCK_EX) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 }
 
 void File::unlock() const
 {
-    if (::flock(descriptor, LOCK_UN) == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       if (::flock(descriptor, LOCK_UN) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 }
 
 DirectoryIterator::DirectoryIterator()
-    : directoryHandle(nullptr)
+       : directoryHandle(nullptr)
 {
 }
 
 DirectoryIterator::DirectoryIterator(const std::string& dir)
-    : directoryHandle(nullptr)
+       : directoryHandle(nullptr)
 {
-    reset(dir);
+       reset(dir);
 }
 
 DirectoryIterator::~DirectoryIterator()
 {
-    if (directoryHandle != nullptr) {
-        ::closedir(directoryHandle);
-    }
+       if (directoryHandle != nullptr) {
+               ::closedir(directoryHandle);
+       }
 }
 
 void DirectoryIterator::reset(const std::string& dir)
 {
-    if (directoryHandle != nullptr) {
-        ::closedir(directoryHandle);
-        directoryHandle = nullptr;
-    }
+       if (directoryHandle != nullptr) {
+               ::closedir(directoryHandle);
+               directoryHandle = nullptr;
+       }
 
-    basename = dir;
-    directoryHandle = ::opendir(basename.c_str());
-    if (directoryHandle == nullptr) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       basename = dir;
+       directoryHandle = ::opendir(basename.c_str());
+       if (directoryHandle == nullptr) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    next();
+       next();
 }
 
 void DirectoryIterator::next()
 {
-    std::string name;
-    struct dirent entry, *ent;
+       std::string name;
+       struct dirent entry, *ent;
 
-    while (1) {
-        if (readdir_r(directoryHandle, &entry, &ent) != 0) {
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
+       while (1) {
+               if (readdir_r(directoryHandle, &entry, &ent) != 0) {
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
 
-        if (ent == NULL)
-            break;
+               if (ent == NULL)
+                       break;
 
-        if (ent->d_name[0] == '.' && ent->d_name[1] == '\0') {
-            continue;
-        }
+               if (ent->d_name[0] == '.' && ent->d_name[1] == '\0') {
+                       continue;
+               }
 
-        if (ent->d_name[0] == '.' &&
-                ent->d_name[1] == '.' && ent->d_name[2] == '\0') {
-            continue;
-        }
+               if (ent->d_name[0] == '.' &&
+                               ent->d_name[1] == '.' && ent->d_name[2] == '\0') {
+                       continue;
+               }
 
-        name = basename + "/" + std::string(ent->d_name);
-        break;
-    }
+               name = basename + "/" + std::string(ent->d_name);
+               break;
+       }
 
-    current = name;
+       current = name;
 }
 
 DirectoryIterator& DirectoryIterator::operator=(const std::string& dir)
 {
-    reset(dir);
-    return *this;
+       reset(dir);
+       return *this;
 }
 
 DirectoryIterator& DirectoryIterator::operator++()
 {
-    next();
-    return *this;
+       next();
+       return *this;
 }
 
 static const struct mountOption {
-    const char* name;
-    int clear;
-    int flag;
+       const char* name;
+       int clear;
+       int flag;
 } mountOptions[] = {
-    { "defaults",      0, 0                },
-    { "ro",            0, MS_RDONLY        },
-    { "rw",            1, MS_RDONLY        },
-    { "suid",          1, MS_NOSUID        },
-    { "nosuid",        0, MS_NOSUID        },
-    { "dev",           1, MS_NODEV         },
-    { "nodev",         0, MS_NODEV         },
-    { "exec",          1, MS_NOEXEC        },
-    { "noexec",        0, MS_NOEXEC        },
-    { "sync",          0, MS_SYNCHRONOUS   },
-    { "async",         1, MS_SYNCHRONOUS   },
-    { "dirsync",       0, MS_DIRSYNC       },
-    { "remount",       0, MS_REMOUNT       },
-    { "mand",          0, MS_MANDLOCK      },
-    { "nomand",        1, MS_MANDLOCK      },
-    { "atime",         1, MS_NOATIME       },
-    { "noatime",       0, MS_NOATIME       },
-    { "diratime",      1, MS_NODIRATIME    },
-    { "nodiratime",    0, MS_NODIRATIME    },
-    { "bind",          0, MS_BIND          },
-    { "rbind",         0, MS_BIND | MS_REC },
-    { "relatime",      0, MS_RELATIME      },
-    { "norelatime",    1, MS_RELATIME      },
-    { "strictatime",   0, MS_STRICTATIME   },
-    { "nostrictatime", 1, MS_STRICTATIME   },
-    { NULL,            0, 0                },
+       { "defaults",      0, 0                },
+       { "ro",            0, MS_RDONLY        },
+       { "rw",            1, MS_RDONLY        },
+       { "suid",          1, MS_NOSUID        },
+       { "nosuid",        0, MS_NOSUID        },
+       { "dev",           1, MS_NODEV         },
+       { "nodev",         0, MS_NODEV         },
+       { "exec",          1, MS_NOEXEC        },
+       { "noexec",        0, MS_NOEXEC        },
+       { "sync",          0, MS_SYNCHRONOUS   },
+       { "async",         1, MS_SYNCHRONOUS   },
+       { "dirsync",       0, MS_DIRSYNC       },
+       { "remount",       0, MS_REMOUNT       },
+       { "mand",          0, MS_MANDLOCK      },
+       { "nomand",        1, MS_MANDLOCK      },
+       { "atime",         1, MS_NOATIME       },
+       { "noatime",       0, MS_NOATIME       },
+       { "diratime",      1, MS_NODIRATIME    },
+       { "nodiratime",    0, MS_NODIRATIME    },
+       { "bind",          0, MS_BIND          },
+       { "rbind",         0, MS_BIND | MS_REC },
+       { "relatime",      0, MS_RELATIME      },
+       { "norelatime",    1, MS_RELATIME      },
+       { "strictatime",   0, MS_STRICTATIME   },
+       { "nostrictatime", 1, MS_STRICTATIME   },
+       { NULL,            0, 0                },
 };
 
 static unsigned long parseMountOptions(const std::string& opts, std::string& mntdata)
 {
-    std::stringstream optsSstream(opts);
-    const struct mountOption* mo;
-    unsigned long mntflags = 0L;
-    std::string opt;
-
-    while (std::getline(optsSstream, opt, ',')) {
-        for (mo = mountOptions; mo->name != NULL; mo++) {
-            if (opt == mo->name) {
-                if (mo->clear) {
-                    mntflags &= ~mo->flag;
-                } else {
-                    mntflags |= mo->flag;
-                }
-                break;
-            }
-            if (mo->name != NULL) {
-                continue;
-            }
-            if (!mntdata.empty()) {
-                mntdata += ",";
-            }
-            mntdata += opt;
-        }
-    }
-
-    return mntflags;
+       std::stringstream optsSstream(opts);
+       const struct mountOption* mo;
+       unsigned long mntflags = 0L;
+       std::string opt;
+
+       while (std::getline(optsSstream, opt, ',')) {
+               for (mo = mountOptions; mo->name != NULL; mo++) {
+                       if (opt == mo->name) {
+                               if (mo->clear) {
+                                       mntflags &= ~mo->flag;
+                               } else {
+                                       mntflags |= mo->flag;
+                               }
+                               break;
+                       }
+                       if (mo->name != NULL) {
+                               continue;
+                       }
+                       if (!mntdata.empty()) {
+                               mntdata += ",";
+                       }
+                       mntdata += opt;
+               }
+       }
+
+       return mntflags;
 }
 
 void Mount::mountEntry(const std::string& src, const std::string& dest, const std::string& type, const std::string& opts)
 {
-    int ret;
-    unsigned long mntflags;
-    std::string mntdata;
-
-    mntflags = parseMountOptions(opts, mntdata);
-
-    ret = ::mount(src.c_str(),
-                  dest.c_str(),
-                  type.c_str(),
-                  mntflags & ~MS_REMOUNT,
-                  mntdata.c_str());
-
-    if (ret) {
-        if ((mntflags & MS_REMOUNT) || (mntflags & MS_BIND)) {
-            ret = ::mount(src.c_str(),
-                          dest.c_str(),
-                          type.c_str(),
-                          mntflags | MS_REMOUNT,
-                          mntdata.c_str());
-        }
-
-        if (ret) {
-            throw runtime::Exception("failed to mount " + src + " on " + dest);
-        }
-    }
+       int ret;
+       unsigned long mntflags;
+       std::string mntdata;
+
+       mntflags = parseMountOptions(opts, mntdata);
+
+       ret = ::mount(src.c_str(),
+                                 dest.c_str(),
+                                 type.c_str(),
+                                 mntflags & ~MS_REMOUNT,
+                                 mntdata.c_str());
+
+       if (ret) {
+               if ((mntflags & MS_REMOUNT) || (mntflags & MS_BIND)) {
+                       ret = ::mount(src.c_str(),
+                                                 dest.c_str(),
+                                                 type.c_str(),
+                                                 mntflags | MS_REMOUNT,
+                                                 mntdata.c_str());
+               }
+
+               if (ret) {
+                       throw runtime::Exception("failed to mount " + src + " on " + dest);
+               }
+       }
 }
 
 } // namespace runtime
index ceb3ec5..20b8a6e 100644 (file)
@@ -26,143 +26,143 @@ namespace runtime {
 
 class File {
 public:
-    File();
-    File(const char* pathname);
-    File(const std::string& pathname);
-    File(const File& file);
-    File(const std::string& path, int flags);
-
-    ~File();
-
-    File& operator=(const std::string& pathname)
-    {
-        path = pathname;
-        return *this;
-    }
-
-    File& operator=(const File& file)
-    {
-        path = file.path;
-        return *this;
-    }
-
-    bool operator<(const File& file) const;
-    bool operator>(const File& file) const;
-    bool operator<=(const File& file) const;
-    bool operator>=(const File& file) const;
-
-    bool operator==(const File& file) const
-    {
-        return (path == file.path);
-    }
-
-    bool operator!=(const File& file) const
-    {
-        return !(path == file.path);
-    }
-
-    bool exists() const;
-    bool canRead() const;
-    bool canWrite() const;
-    bool canExecute() const;
-
-    bool isLink() const;
-    bool isFile() const;
-    bool isDirectory() const;
-    bool isDevice() const;
-
-    mode_t getMode() const;
-    uid_t getUid() const;
-    gid_t getGid() const;
-
-    size_t size() const;
-
-    void create(mode_t mode);
-    void open(int flags);
-    void read(void *buffer, const size_t size) const;
-    void write(const void *buffer, const size_t size) const;
-    void close();
-    File copyTo(const std::string& pathname);
-    void remove(bool recursive = false);
-    void makeBaseDirectory(uid_t uid = 0, gid_t gid = 0);
-    void makeDirectory(bool recursive = false, uid_t uid = 0, gid_t gid = 0);
-
-    void lock() const;
-    void unlock() const;
-
-    void chown(uid_t uid, gid_t gid, bool recursive = false);
-    void chmod(mode_t mode, bool recursive = false);
-
-    const std::string& getPath() const
-    {
-        return path;
-    }
-
-    const std::string getName() const
-    {
-        return path.substr(path.rfind('/') + 1);
-    }
+       File();
+       File(const char* pathname);
+       File(const std::string& pathname);
+       File(const File& file);
+       File(const std::string& path, int flags);
+
+       ~File();
+
+       File& operator=(const std::string& pathname)
+       {
+               path = pathname;
+               return *this;
+       }
+
+       File& operator=(const File& file)
+       {
+               path = file.path;
+               return *this;
+       }
+
+       bool operator<(const File& file) const;
+       bool operator>(const File& file) const;
+       bool operator<=(const File& file) const;
+       bool operator>=(const File& file) const;
+
+       bool operator==(const File& file) const
+       {
+               return (path == file.path);
+       }
+
+       bool operator!=(const File& file) const
+       {
+               return !(path == file.path);
+       }
+
+       bool exists() const;
+       bool canRead() const;
+       bool canWrite() const;
+       bool canExecute() const;
+
+       bool isLink() const;
+       bool isFile() const;
+       bool isDirectory() const;
+       bool isDevice() const;
+
+       mode_t getMode() const;
+       uid_t getUid() const;
+       gid_t getGid() const;
+
+       size_t size() const;
+
+       void create(mode_t mode);
+       void open(int flags);
+       void read(void *buffer, const size_t size) const;
+       void write(const void *buffer, const size_t size) const;
+       void close();
+       File copyTo(const std::string& pathname);
+       void remove(bool recursive = false);
+       void makeBaseDirectory(uid_t uid = 0, gid_t gid = 0);
+       void makeDirectory(bool recursive = false, uid_t uid = 0, gid_t gid = 0);
+
+       void lock() const;
+       void unlock() const;
+
+       void chown(uid_t uid, gid_t gid, bool recursive = false);
+       void chmod(mode_t mode, bool recursive = false);
+
+       const std::string& getPath() const
+       {
+               return path;
+       }
+
+       const std::string getName() const
+       {
+               return path.substr(path.rfind('/') + 1);
+       }
 
 private:
-    int descriptor;
-    std::string path;
+       int descriptor;
+       std::string path;
 };
 
 class DirectoryIterator {
 public:
-    DirectoryIterator();
-    DirectoryIterator(const std::string& dir);
+       DirectoryIterator();
+       DirectoryIterator(const std::string& dir);
 
-    ~DirectoryIterator();
+       ~DirectoryIterator();
 
-    DirectoryIterator& operator=(const std::string& dir);
-    DirectoryIterator& operator++();
+       DirectoryIterator& operator=(const std::string& dir);
+       DirectoryIterator& operator++();
 
-    bool operator==(const DirectoryIterator& iterator) const
-    {
-        return (current == iterator.current);
-    }
+       bool operator==(const DirectoryIterator& iterator) const
+       {
+               return (current == iterator.current);
+       }
 
-    bool operator!=(const DirectoryIterator& iterator) const
-    {
-        return !(current == iterator.current);
-    }
+       bool operator!=(const DirectoryIterator& iterator) const
+       {
+               return !(current == iterator.current);
+       }
 
-    const File& operator*() const
-    {
-        return current;
-    }
+       const File& operator*() const
+       {
+               return current;
+       }
 
-    File& operator*()
-    {
-        return current;
-    }
+       File& operator*()
+       {
+               return current;
+       }
 
-    const File* operator->() const
-    {
-        return &current;
-    }
+       const File* operator->() const
+       {
+               return &current;
+       }
 
-    File* operator->()
-    {
-        return &current;
-    }
+       File* operator->()
+       {
+               return &current;
+       }
 
 private:
-    void next();
-    void reset(const std::string& dir);
+       void next();
+       void reset(const std::string& dir);
 
-    File current;
-    DIR* directoryHandle;
-    std::string basename;
+       File current;
+       DIR* directoryHandle;
+       std::string basename;
 };
 
 class Mount final {
 public:
-    Mount() = delete;
+       Mount() = delete;
 
-    static void mountEntry(const std::string& src, const std::string& dest,
-                           const std::string& type, const std::string& opts);
+       static void mountEntry(const std::string& src, const std::string& dest,
+                                                  const std::string& type, const std::string& opts);
 };
 
 int Open(const std::string& path, int flags, mode_t mode);
index 1a921b2..dcb1d0e 100644 (file)
  *  limitations under the License
  */
 
-#include <cstring>
-#include <iostream>
 #include <unistd.h>
 #include <assert.h>
-#include <gio/gio.h>
 #include <sys/epoll.h>
 
+#include <cstring>
+#include <iostream>
+
+#include <gio/gio.h>
+
 #include "error.h"
 #include "exception.h"
 #include "mainloop.h"
@@ -33,140 +35,140 @@ namespace {
 
 gboolean GIOCallback(GIOChannel* channel, GIOCondition condition, void *data)
 {
-    Mainloop* mainloop = reinterpret_cast<Mainloop*>(data);
-    mainloop->dispatch(-1);
-    return TRUE;
+       Mainloop* mainloop = reinterpret_cast<Mainloop*>(data);
+       mainloop->dispatch(-1);
+       return TRUE;
 }
 
 } // namespace
 
 Mainloop::Mainloop() :
-    pollFd(::epoll_create1(EPOLL_CLOEXEC)),
-    stopped(false)
+       pollFd(::epoll_create1(EPOLL_CLOEXEC)),
+       stopped(false)
 {
-    if (pollFd == -1) {
-        throw Exception(GetSystemErrorMessage());
-    }
+       if (pollFd == -1) {
+               throw Exception(GetSystemErrorMessage());
+       }
 }
 
 Mainloop::~Mainloop()
 {
-    if (!callbacks.empty()) {
-        //assert(0 && "callback list is not empty");
-    }
+       if (!callbacks.empty()) {
+               //assert(0 && "callback list is not empty");
+       }
 
-    ::close(pollFd);
+       ::close(pollFd);
 }
 
 void Mainloop::addEventSource(const int fd, const Event events, Callback&& callback)
 {
-    epoll_event event;
-    std::lock_guard<Mutex> lock(mutex);
+       epoll_event event;
+       std::lock_guard<Mutex> lock(mutex);
 
-    if (callbacks.find(fd) != callbacks.end()) {
-        throw Exception("Event source already registered");
-    }
+       if (callbacks.find(fd) != callbacks.end()) {
+               throw Exception("Event source already registered");
+       }
 
-    ::memset(&event, 0, sizeof(epoll_event));
+       ::memset(&event, 0, sizeof(epoll_event));
 
-    event.events = events;
-    event.data.fd = fd;
+       event.events = events;
+       event.data.fd = fd;
 
-    if (::epoll_ctl(pollFd, EPOLL_CTL_ADD, fd, &event) == -1) {
-        throw Exception(GetSystemErrorMessage());
-    }
+       if (::epoll_ctl(pollFd, EPOLL_CTL_ADD, fd, &event) == -1) {
+               throw Exception(GetSystemErrorMessage());
+       }
 
-    callbacks.insert({fd, std::make_shared<Callback>(std::move(callback))});
+       callbacks.insert({fd, std::make_shared<Callback>(std::move(callback))});
 }
 
 void Mainloop::removeEventSource(const int fd)
 {
-    std::lock_guard<Mutex> lock(mutex);
+       std::lock_guard<Mutex> lock(mutex);
 
-    auto iter = callbacks.find(fd);
-    if (iter == callbacks.end()) {
-        return;
-    }
+       auto iter = callbacks.find(fd);
+       if (iter == callbacks.end()) {
+               return;
+       }
 
-    callbacks.erase(iter);
+       callbacks.erase(iter);
 
-    ::epoll_ctl(pollFd, EPOLL_CTL_DEL, fd, NULL);
+       ::epoll_ctl(pollFd, EPOLL_CTL_DEL, fd, NULL);
 }
 
 bool Mainloop::dispatch(const int timeout)
 {
-    int nfds;
-    epoll_event event[MAX_EPOLL_EVENTS];
-
-    do {
-        nfds = ::epoll_wait(pollFd, event, MAX_EPOLL_EVENTS, timeout);
-    } while ((nfds == -1) && (errno == EINTR));
-
-    if (nfds < 0) {
-        throw Exception(GetSystemErrorMessage());
-    }
-
-    for (int i = 0; i < nfds; i++) {
-        std::lock_guard<Mutex> lock(mutex);
-
-        auto iter = callbacks.find(event[i].data.fd);
-        if (iter == callbacks.end()) {
-            continue;
-        }
-
-        std::shared_ptr<Callback> callback(iter->second);
-        try {
-            if ((event[i].events & (EPOLLHUP | EPOLLRDHUP))) {
-                event[i].events &= ~EPOLLIN;
-            }
-
-            (*callback)(event[i].data.fd, event[i].events);
-        } catch (std::exception& e) {
-            std::cout << "EXCEPTION ON MAINLOOP" << std::endl;
-        }
-    }
-
-    return true;
+       int nfds;
+       epoll_event event[MAX_EPOLL_EVENTS];
+
+       do {
+               nfds = ::epoll_wait(pollFd, event, MAX_EPOLL_EVENTS, timeout);
+       } while ((nfds == -1) && (errno == EINTR));
+
+       if (nfds < 0) {
+               throw Exception(GetSystemErrorMessage());
+       }
+
+       for (int i = 0; i < nfds; i++) {
+               std::lock_guard<Mutex> lock(mutex);
+
+               auto iter = callbacks.find(event[i].data.fd);
+               if (iter == callbacks.end()) {
+                       continue;
+               }
+
+               std::shared_ptr<Callback> callback(iter->second);
+               try {
+                       if ((event[i].events & (EPOLLHUP | EPOLLRDHUP))) {
+                               event[i].events &= ~EPOLLIN;
+                       }
+
+                       (*callback)(event[i].data.fd, event[i].events);
+               } catch (std::exception& e) {
+                       std::cout << "EXCEPTION ON MAINLOOP" << std::endl;
+               }
+       }
+
+       return true;
 }
 
 void Mainloop::stop()
 {
-    wakeupSignal.send();
+       wakeupSignal.send();
 }
 
 void Mainloop::prepare()
 {
-    auto wakeupMainloop = [this](int fd, Mainloop::Event event) {
-        wakeupSignal.receive();
-        removeEventSource(wakeupSignal.getFd());
-        stopped = true;
-    };
+       auto wakeupMainloop = [this](int fd, Mainloop::Event event) {
+               wakeupSignal.receive();
+               removeEventSource(wakeupSignal.getFd());
+               stopped = true;
+       };
 
-    addEventSource(wakeupSignal.getFd(), EPOLLIN, wakeupMainloop);
+       addEventSource(wakeupSignal.getFd(), EPOLLIN, wakeupMainloop);
 }
 
 void Mainloop::run(bool useGMainloop)
 {
-    prepare();
-
-    if (useGMainloop) {
-        GIOChannel* channel;
-        channel = g_io_channel_unix_new(pollFd);
-        if (channel == NULL) {
-            std::cout << "GMAINLOOP CHANNEL ALLOC FAILED" << std::endl;
-            return;
-        }
-        g_io_add_watch(channel, (GIOCondition)(G_IO_IN|G_IO_HUP), GIOCallback, this);
-        g_io_channel_unref(channel);
-
-        while (!stopped) {
-            g_main_iteration(TRUE);
-        }
-    } else {
-        while (!stopped) {
-            dispatch(-1);
-        }
-    }
+       prepare();
+
+       if (useGMainloop) {
+               GIOChannel* channel;
+               channel = g_io_channel_unix_new(pollFd);
+               if (channel == NULL) {
+                       std::cout << "GMAINLOOP CHANNEL ALLOC FAILED" << std::endl;
+                       return;
+               }
+               g_io_add_watch(channel, (GIOCondition)(G_IO_IN|G_IO_HUP), GIOCallback, this);
+               g_io_channel_unref(channel);
+
+               while (!stopped) {
+                       g_main_iteration(TRUE);
+               }
+       } else {
+               while (!stopped) {
+                       dispatch(-1);
+               }
+       }
 }
 
 } // namespace runtime
index 781578b..4b55729 100644 (file)
@@ -32,28 +32,28 @@ namespace runtime {
 
 class Mainloop {
 public:
-    typedef unsigned int Event;
-    typedef std::function<void(int fd, Event event)> Callback;
+       typedef unsigned int Event;
+       typedef std::function<void(int fd, Event event)> Callback;
 
-    Mainloop();
-    ~Mainloop();
+       Mainloop();
+       ~Mainloop();
 
-    void addEventSource(const int fd, const Event events, Callback&& callback);
-    void removeEventSource(const int fd);
-    bool dispatch(const int timeout);
-    void run(bool useGMainloop = false);
-    void stop();
+       void addEventSource(const int fd, const Event events, Callback&& callback);
+       void removeEventSource(const int fd);
+       bool dispatch(const int timeout);
+       void run(bool useGMainloop = false);
+       void stop();
 
 private:
-    typedef std::recursive_mutex Mutex;
+       typedef std::recursive_mutex Mutex;
 
-    std::unordered_map<int, std::shared_ptr<Callback>> callbacks;
-    Mutex mutex;
-    int pollFd;
-    std::atomic<bool> stopped;
-    runtime::EventFD wakeupSignal;
+       std::unordered_map<int, std::shared_ptr<Callback>> callbacks;
+       Mutex mutex;
+       int pollFd;
+       std::atomic<bool> stopped;
+       runtime::EventFD wakeupSignal;
 
-    void prepare();
+       void prepare();
 };
 
 } // namespace runtime
index 0bf3d47..4759cd5 100644 (file)
@@ -28,138 +28,138 @@ namespace runtime {
 
 PAM::PAM(const std::string& service, const std::string& user)
 {
-    struct pam_conv pamc;
+       struct pam_conv pamc;
 
-    int error = ::pam_start(service.c_str(), user.c_str(), &pamc, &pamh);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
+       int error = ::pam_start(service.c_str(), user.c_str(), &pamc, &pamh);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
 }
 
 PAM::~PAM()
 {
-    int error = ::pam_end(pamh, PAM_SUCCESS);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
+       int error = ::pam_end(pamh, PAM_SUCCESS);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
 }
 
 void PAM::setData(const std::string &name, void* data, void (*cleanup)(pam_handle_t* pamh, void* data, int error))
 {
-    int error = ::pam_set_data(pamh, name.c_str(), data, cleanup);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
+       int error = ::pam_set_data(pamh, name.c_str(), data, cleanup);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
 }
 
 const void* PAM::getData(const std::string &name) const
 {
-    const void* ret;
-    int error = ::pam_get_data(pamh, name.c_str(), &ret);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
-    return ret;
+       const void* ret;
+       int error = ::pam_get_data(pamh, name.c_str(), &ret);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
+       return ret;
 }
 
 void PAM::setItem(int item, void* data)
 {
-    int error = ::pam_set_item(pamh, item, data);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
+       int error = ::pam_set_item(pamh, item, data);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
 }
 
 const void* PAM::getItem(int item) const
 {
-    const void* ret;
-    int error = ::pam_get_item(pamh, item, &ret);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
-    return ret;
+       const void* ret;
+       int error = ::pam_get_item(pamh, item, &ret);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
+       return ret;
 }
 
 const std::string PAM::getUser(const std::string &prompt) const
 {
-    const char* user;
-    int error = ::pam_get_user(pamh, &user, prompt.c_str());
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
-    return std::string(user);
+       const char* user;
+       int error = ::pam_get_user(pamh, &user, prompt.c_str());
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
+       return std::string(user);
 }
 
 void PAM::putEnv(const std::string &name_value)
 {
-    int error = ::pam_putenv(pamh, name_value.c_str());
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
+       int error = ::pam_putenv(pamh, name_value.c_str());
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
 }
 
 const std::string PAM::getEnv(const std::string &name) const
 {
-    const char* value = ::pam_getenv(pamh, name.c_str());
-    if (value == NULL) {
-        throw runtime::Exception("PAM Error");
-    }
-    return value;
+       const char* value = ::pam_getenv(pamh, name.c_str());
+       if (value == NULL) {
+               throw runtime::Exception("PAM Error");
+       }
+       return value;
 }
 
 const std::vector<std::string> PAM::getEnvList() const
 {
-    std::vector<std::string> ret;
-    char** array = ::pam_getenvlist(pamh);
-    if (array == NULL) {
-        throw runtime::Exception("PAM Error");
-    }
-    for (int i = 0; array[i] != NULL; i++) {
-        ret.push_back(array[i]);
-    }
-    return ret;
+       std::vector<std::string> ret;
+       char** array = ::pam_getenvlist(pamh);
+       if (array == NULL) {
+               throw runtime::Exception("PAM Error");
+       }
+       for (int i = 0; array[i] != NULL; i++) {
+               ret.push_back(array[i]);
+       }
+       return ret;
 }
 
 void PAM::syslog(const std::string &log, int priority)
 {
-    ::pam_syslog(pamh, priority, "%s", log.c_str());
+       ::pam_syslog(pamh, priority, "%s", log.c_str());
 }
 
 
 int PAM::authenticate(int flags)
 {
-    return ::pam_authenticate(pamh, flags);
+       return ::pam_authenticate(pamh, flags);
 }
 
 int PAM::setCredential(int flags)
 {
-    return ::pam_setcred(pamh, flags);
+       return ::pam_setcred(pamh, flags);
 }
 
 int PAM::accountManagement(int flags)
 {
-    return ::pam_acct_mgmt(pamh, flags);
+       return ::pam_acct_mgmt(pamh, flags);
 }
 
 int PAM::changeAuthenticationToken(int flags)
 {
-    return ::pam_chauthtok(pamh, flags);
+       return ::pam_chauthtok(pamh, flags);
 }
 
 void PAM::openSession(int flags)
 {
-    int error = ::pam_open_session(pamh, flags);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
+       int error = ::pam_open_session(pamh, flags);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
 }
 
 void PAM::closeSession(int flags)
 {
-    int error = ::pam_close_session(pamh, flags);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("PAM Error");
-    }
+       int error = ::pam_close_session(pamh, flags);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("PAM Error");
+       }
 }
 
 } // namespace runtime
index b6b6a33..93e1b05 100644 (file)
@@ -28,37 +28,37 @@ namespace runtime {
 
 class PAM final {
 public:
-    PAM(PAM&&) = delete;
-    PAM(const PAM&) = delete;
-    PAM(const std::string& service, const std::string& user);
-    ~PAM();
+       PAM(PAM&&) = delete;
+       PAM(const PAM&) = delete;
+       PAM(const std::string& service, const std::string& user);
+       ~PAM();
 
-    PAM& operator=(const PAM&) = delete;
-    PAM& operator=(PAM &&) = delete;
+       PAM& operator=(const PAM&) = delete;
+       PAM& operator=(PAM &&) = delete;
 
-    void setData(const std::string &name, void* data, void (*cleanup)(pam_handle_t* pamh, void* data, int error));
-    const void* getData(const std::string &name) const;
+       void setData(const std::string &name, void* data, void (*cleanup)(pam_handle_t* pamh, void* data, int error));
+       const void* getData(const std::string &name) const;
 
-    void setItem(int item, void* data);
-    const void* getItem(int item) const;
+       void setItem(int item, void* data);
+       const void* getItem(int item) const;
 
-    const std::string getUser(const std::string &prompt = "") const;
+       const std::string getUser(const std::string &prompt = "") const;
 
-    void putEnv(const std::string &name_value);
-    const std::string getEnv(const std::string &name) const;
-    const std::vector<std::string> getEnvList() const;
+       void putEnv(const std::string &name_value);
+       const std::string getEnv(const std::string &name) const;
+       const std::vector<std::string> getEnvList() const;
 
-    void syslog(const std::string &log, int priority = LOG_ERR);
+       void syslog(const std::string &log, int priority = LOG_ERR);
 
-    int authenticate(int flags);
-    int setCredential(int flags);
-    int accountManagement(int flags);
-    int changeAuthenticationToken(int flags);
-    void openSession(int flags);
-    void closeSession(int flags);
+       int authenticate(int flags);
+       int setCredential(int flags);
+       int accountManagement(int flags);
+       int changeAuthenticationToken(int flags);
+       void openSession(int flags);
+       void closeSession(int flags);
 
 private:
-    pam_handle_t* pamh;
+       pam_handle_t* pamh;
 };
 
 } // namespace runtime
index 327e728..d6284f0 100644 (file)
 namespace runtime {
 
 Process::Process(const std::string& prog) :
-    status(-1), pid(-1), program(prog)
+       status(-1), pid(-1), program(prog)
 {
-    args.push_back(prog);
+       args.push_back(prog);
 }
 
 Process::Process(const std::string& prog, const std::vector<std::string>& args) :
-    status(-1), pid(-1), program(prog), args(args)
+       status(-1), pid(-1), program(prog), args(args)
 {
 }
 
@@ -42,59 +42,59 @@ Process::~Process()
 
 int Process::execute()
 {
-    pid = ::fork();
-    if (pid == -1) {
-        return -1;
-    }
+       pid = ::fork();
+       if (pid == -1) {
+               return -1;
+       }
 
-    if (pid == 0) {
-        const char** argv = new const char *[args.size() + 1];
+       if (pid == 0) {
+               const char** argv = new const char *[args.size() + 1];
 
-        int i = 0;
-        for (std::string & arg : args) {
-            argv[i++] = arg.c_str();
-        }
-        argv[i] = NULL;
+               int i = 0;
+               for (std::string & arg : args) {
+                       argv[i++] = arg.c_str();
+               }
+               argv[i] = NULL;
 
-        ::execv(program.c_str(), const_cast<char* const*>(argv));
-        std::quick_exit(EXIT_FAILURE);
-    }
+               ::execv(program.c_str(), const_cast<char* const*>(argv));
+               std::quick_exit(EXIT_FAILURE);
+       }
 
-    return waitForFinished();
+       return waitForFinished();
 }
 
 int Process::waitForFinished()
 {
-    while (::waitpid(pid, &status, 0) == -1) {
-        if (errno != EINTR) {
-            return -1;
-        }
-    }
+       while (::waitpid(pid, &status, 0) == -1) {
+               if (errno != EINTR) {
+                       return -1;
+               }
+       }
 
-    return status;
+       return status;
 }
 
 bool Process::isRunning() const
 {
-    if (::kill(pid, 0) == 0) {
-        return true;
-    }
+       if (::kill(pid, 0) == 0) {
+               return true;
+       }
 
-    return false;
+       return false;
 }
 
 void Process::kill()
 {
-    if (::kill(pid, SIGKILL) == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       if (::kill(pid, SIGKILL) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 }
 
 void Process::terminate()
 {
-    if (::kill(pid, SIGINT) == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       if (::kill(pid, SIGINT) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 }
 
 } // namespace runtime
index 9a90cbb..9b629a2 100644 (file)
@@ -24,30 +24,30 @@ namespace runtime {
 
 class Process {
 public:
-    typedef pid_t Pid;
+       typedef pid_t Pid;
 
-    Process(const std::string& prog);
-    Process(const std::string& prog, const std::vector<std::string>& args);
-    Process(const Process& proc) = delete;
+       Process(const std::string& prog);
+       Process(const std::string& prog, const std::vector<std::string>& args);
+       Process(const Process& proc) = delete;
 
-    ~Process();
+       ~Process();
 
-    Process& operator=(const Process& proc) = delete;
+       Process& operator=(const Process& proc) = delete;
 
-    int execute();
-    int start();
-    int waitForFinished();
-    int waitForStarted();
-    void terminate();
-    void kill();
+       int execute();
+       int start();
+       int waitForFinished();
+       int waitForStarted();
+       void terminate();
+       void kill();
 
-    bool isRunning() const;
+       bool isRunning() const;
 
 private:
-    int status;
-    Pid pid;
-    std::string program;
-    std::vector<std::string> args;
+       int status;
+       Pid pid;
+       std::string program;
+       std::vector<std::string> args;
 };
 
 } // namespace runtime
index 26c6eeb..7f6bfde 100644 (file)
 
 #define VISIT_ELEMENT(elem) v.visit(#elem, elem)
 
-#define REFLECTABLE(...)                               \
-template<typename V>                                   \
-void accept(V v)                                       \
-{                                                      \
-       FOR_EACH_VAR_ARGS(VISIT_ELEMENT, __VA_ARGS__);  \
-}                                                      \
-template<typename V>                                   \
-void accept(V v) const                                 \
-{                                                      \
-       FOR_EACH_VAR_ARGS(VISIT_ELEMENT, __VA_ARGS__);  \
+#define REFLECTABLE(...)                            \
+template<typename V>                                \
+void accept(V v)                                    \
+{                                                   \
+       FOR_EACH_VAR_ARGS(VISIT_ELEMENT, __VA_ARGS__);  \
+}                                                   \
+template<typename V>                                \
+void accept(V v) const                              \
+{                                                   \
+       FOR_EACH_VAR_ARGS(VISIT_ELEMENT, __VA_ARGS__);  \
 }
 
-#define NO_REFLECTABLE_PROPERTY                                \
-       template<typename V>                            \
+#define NO_REFLECTABLE_PROPERTY \
+       template<typename V>        \
        static void accept(V) {}
 
 template<typename T>
 struct ReflectionTraitChecker {
-    struct Visitor {};
+       struct Visitor {};
 
-    template <typename C> static std::true_type
-    test(decltype(std::declval<C>().template accept(Visitor()))*);
+       template <typename C> static std::true_type
+       test(decltype(std::declval<C>().template accept(Visitor()))*);
 
-    template <typename C> static std::false_type
-    test(...);
+       template <typename C> static std::false_type
+       test(...);
 
-    static constexpr bool value = std::is_same<decltype(test<T>(0)), std::true_type>::value;
+       static constexpr bool value = std::is_same<decltype(test<T>(0)), std::true_type>::value;
 };
 
 template<typename T>
index f8def62..fc22950 100644 (file)
@@ -26,48 +26,48 @@ namespace rmi {
 
 template<typename Type, typename... Args>
 struct MethodHandler {
-    typedef std::function<Type(Args&...)> type;
+       typedef std::function<Type(Args&...)> type;
 };
 // using MethodHandler = std::function<Type(Args&...)>;
 
 template<typename Type, typename... Args>
 struct CallbackHolder {
-    template<int...>
-    struct Sequence {};
+       template<int...>
+       struct Sequence {};
 
-    template<int N, int... S>
-    struct SequenceExpansion : SequenceExpansion<N-1, N-1, S...> {};
+       template<int N, int... S>
+       struct SequenceExpansion : SequenceExpansion<N-1, N-1, S...> {};
 
-    template<int... S>
-    struct SequenceExpansion<0, S...> {
-        typedef Sequence<S...> type;
-    };
+       template<int... S>
+       struct SequenceExpansion<0, S...> {
+               typedef Sequence<S...> type;
+       };
 
-    std::tuple<Args...> parameters;
-    const typename MethodHandler<Type, Args...>::type& callback;
+       std::tuple<Args...> parameters;
+       const typename MethodHandler<Type, Args...>::type& callback;
 
-    CallbackHolder(const typename MethodHandler<Type, Args...>::type& m) :
-        callback(m)
-    {
-    }
+       CallbackHolder(const typename MethodHandler<Type, Args...>::type& m) :
+               callback(m)
+       {
+       }
 
-    Type dispatch(Message& message)
-    {
-        return callCallback(message, typename SequenceExpansion<sizeof...(Args)>::type());
-    }
+       Type dispatch(Message& message)
+       {
+               return callCallback(message, typename SequenceExpansion<sizeof...(Args)>::type());
+       }
 
-    template<typename...R>
-    Type callCallback(Message& message, R&... args)
-    {
-        message.unpackParameters(args...);
-        return callback(args...);
-    }
+       template<typename...R>
+       Type callCallback(Message& message, R&... args)
+       {
+               message.unpackParameters(args...);
+               return callback(args...);
+       }
 
-    template<int... S>
-    Type callCallback(Message& message, Sequence<S...>)
-    {
-        return callCallback(message, std::get<S>(parameters)...);
-    }
+       template<int... S>
+       Type callCallback(Message& message, Sequence<S...>)
+       {
+               return callCallback(message, std::get<S>(parameters)...);
+       }
 };
 
 } // namespace rmi
index de85d85..a913446 100644 (file)
 namespace rmi {
 
 Client::Client(const std::string& path) :
-    address(path)
+       address(path)
 {
 }
 
 Client::~Client()
 {
-    disconnect();
+       disconnect();
 }
 
 void Client::connect()
 {
-    connection = std::make_shared<Connection>(Socket::connect(address));
+       connection = std::make_shared<Connection>(Socket::connect(address));
 
-    dispatcher = std::thread([this] { mainloop.run(); });
+       dispatcher = std::thread([this] { mainloop.run(); });
 }
 
 int Client::unsubscribe(const std::string& provider, int id)
 {
-    // file descriptor(id) is automatically closed when mainloop callback is destroyed.
-    mainloop.removeEventSource(id);
-    return 0;
+       // file descriptor(id) is automatically closed when mainloop callback is destroyed.
+       mainloop.removeEventSource(id);
+       return 0;
 }
 
 int Client::subscribe(const std::string& provider, const std::string& name)
 {
-    Message request = connection->createMessage(Message::MethodCall, provider);
-    request.packParameters(name);
-    connection->send(request);
+       Message request = connection->createMessage(Message::MethodCall, provider);
+       request.packParameters(name);
+       connection->send(request);
 
-    FileDescriptor response;
-    Message reply = connection->dispatch();
-    reply.disclose(response);
+       FileDescriptor response;
+       Message reply = connection->dispatch();
+       reply.disclose(response);
 
-    return response.fileDescriptor;
+       return response.fileDescriptor;
 }
 
 void Client::disconnect()
 {
-    mainloop.stop();
-    if (dispatcher.joinable()) {
-        dispatcher.join();
-    }
+       mainloop.stop();
+       if (dispatcher.joinable()) {
+               dispatcher.join();
+       }
 }
 
 } // namespace rmi
index 0d3761a..53fe5b1 100644 (file)
@@ -31,78 +31,78 @@ namespace rmi {
 
 class Client {
 public:
-    Client(const std::string& address);
-    ~Client();
+       Client(const std::string& address);
+       ~Client();
 
-    Client(const Client&) = delete;
-    Client& operator=(const Client&) = delete;
+       Client(const Client&) = delete;
+       Client& operator=(const Client&) = delete;
 
-    void connect();
-    void disconnect();
+       void connect();
+       void disconnect();
 
-    int subscribe(const std::string& provider, const std::string& name);
+       int subscribe(const std::string& provider, const std::string& name);
 
-    template<typename... Args>
-    int subscribe(const std::string& provider, const std::string& name,
-                  const typename MethodHandler<void, Args...>::type& handler);
+       template<typename... Args>
+       int subscribe(const std::string& provider, const std::string& name,
+                                 const typename MethodHandler<void, Args...>::type& handler);
 
-    int unsubscribe(const std::string& provider, int handle);
+       int unsubscribe(const std::string& provider, int handle);
 
-    template<typename Type, typename... Args>
-    Type methodCall(const std::string& method, Args&&... args);
+       template<typename Type, typename... Args>
+       Type methodCall(const std::string& method, Args&&... args);
 
 private:
-    std::string address;
-    std::shared_ptr<Connection> connection;
-    runtime::Mainloop mainloop;
-    std::thread dispatcher;
+       std::string address;
+       std::shared_ptr<Connection> connection;
+       runtime::Mainloop mainloop;
+       std::thread dispatcher;
 };
 
 template<typename... Args>
 int Client::subscribe(const std::string& provider, const std::string& name,
-                      const typename MethodHandler<void, Args...>::type& handler)
+                                         const typename MethodHandler<void, Args...>::type& handler)
 {
-    int id = subscribe(provider, name);
-    if (id < 0) {
-        return -1;
-    }
+       int id = subscribe(provider, name);
+       if (id < 0) {
+               return -1;
+       }
 
-    std::shared_ptr<Socket> transport = std::make_shared<Socket>(id);
+       std::shared_ptr<Socket> transport = std::make_shared<Socket>(id);
 
-    auto callback = [handler, transport, this](int fd, runtime::Mainloop::Event event) {
-        if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) {
-            mainloop.removeEventSource(fd);
-            return;
-        }
+       auto callback = [handler, transport, this](int fd, runtime::Mainloop::Event event) {
+               if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) {
+                       mainloop.removeEventSource(fd);
+                       return;
+               }
 
-        try {
-            Message msg;
-            msg.decode(*transport);
+               try {
+                       Message msg;
+                       msg.decode(*transport);
 
-            CallbackHolder<void, Args...> callback(handler);
-            callback.dispatch(msg);
-        } catch (std::exception& e) {
-            std::cout << e.what() << std::endl;
-        }
-    };
+                       CallbackHolder<void, Args...> callback(handler);
+                       callback.dispatch(msg);
+               } catch (std::exception& e) {
+                       std::cout << e.what() << std::endl;
+               }
+       };
 
-    mainloop.addEventSource(id, EPOLLIN | EPOLLHUP | EPOLLRDHUP, callback);
+       mainloop.addEventSource(id, EPOLLIN | EPOLLHUP | EPOLLRDHUP, callback);
 
-    return id;
+       return id;
 }
 
 template<typename Type, typename... Args>
 Type Client::methodCall(const std::string& method, Args&&... args)
 {
-    Message request = connection->createMessage(Message::MethodCall, method);
-    request.packParameters(std::forward<Args>(args)...);
-    connection->send(request);
+       Message request = connection->createMessage(Message::MethodCall, method);
+       request.packParameters(std::forward<Args>(args)...);
+       connection->send(request);
 
-    Type response;
-    Message reply = connection->dispatch();
-    reply.disclose<Type>(response);
+       Type response;
+       Message reply = connection->dispatch();
+       reply.disclose<Type>(response);
 
-    return response;
+       return response;
 }
 
 } // namespace rmi
index f16a529..9153a81 100644 (file)
@@ -21,7 +21,7 @@
 namespace rmi {
 
 Connection::Connection(Socket&& sock) :
-    socket(std::move(sock))
+       socket(std::move(sock))
 {
 }
 
@@ -31,29 +31,29 @@ Connection::~Connection() noexcept
 
 Message Connection::createMessage(unsigned int type, const std::string& target)
 {
-    return Message(type, target);
+       return Message(type, target);
 }
 
 void Connection::send(const Message& message) const
 {
-    std::lock_guard<std::mutex> lock(transmitMutex);
-    message.encode(socket);
+       std::lock_guard<std::mutex> lock(transmitMutex);
+       message.encode(socket);
 }
 
 Message Connection::dispatch() const
 {
-    Message message;
-    std::lock_guard<std::mutex> lock(receiveMutex);
+       Message message;
+       std::lock_guard<std::mutex> lock(receiveMutex);
 
-    message.decode(socket);
-    if (message.isError()) {
-        std::string exception;
-        message.disclose(exception);
+       message.decode(socket);
+       if (message.isError()) {
+               std::string exception;
+               message.disclose(exception);
 
-        throw runtime::Exception(exception);
-    }
+               throw runtime::Exception(exception);
+       }
 
-    return message;
+       return message;
 }
 
 } // namespace rmi
index 5728f5f..0b943e2 100644 (file)
@@ -28,32 +28,32 @@ namespace rmi {
 
 class Connection {
 public:
-    Connection(Socket&& sock);
-    Connection(const Connection&) = delete;
-    ~Connection() noexcept;
+       Connection(Socket&& sock);
+       Connection(const Connection&) = delete;
+       ~Connection() noexcept;
 
-    Connection& operator=(const Connection&) = delete;
-    Connection& operator=(Connection&) = delete;
+       Connection& operator=(const Connection&) = delete;
+       Connection& operator=(Connection&) = delete;
 
-    Message createMessage(unsigned int type, const std::string& target);
+       Message createMessage(unsigned int type, const std::string& target);
 
-    void send(const Message& message) const;
-    Message dispatch() const;
+       void send(const Message& message) const;
+       Message dispatch() const;
 
-    int getFd() const
-    {
-        return socket.getFd();
-    }
+       int getFd() const
+       {
+               return socket.getFd();
+       }
 
-    Credentials getPeerCredentials() const
-    {
-        return socket.getPeerCredentials();
-    }
+       Credentials getPeerCredentials() const
+       {
+               return socket.getPeerCredentials();
+       }
 
 private:
-    Socket socket;
-    mutable std::mutex receiveMutex;
-    mutable std::mutex transmitMutex;
+       Socket socket;
+       mutable std::mutex receiveMutex;
+       mutable std::mutex transmitMutex;
 };
 
 } // namespace rmi
index 51331b6..cdb29aa 100644 (file)
 namespace rmi {
 
 MessageComposer::MessageComposer(size_t caps) :
-    capacity(caps),
-    produce(0),
-    consume(0),
-    buffer(new char[caps])
+       capacity(caps),
+       produce(0),
+       consume(0),
+       buffer(new char[caps])
 {
 }
 
 MessageComposer::MessageComposer(const MessageComposer& rhs) :
-    capacity(rhs.capacity),
-    produce(rhs.produce),
-    consume(rhs.consume),
-    buffer(new char[rhs.capacity])
+       capacity(rhs.capacity),
+       produce(rhs.produce),
+       consume(rhs.consume),
+       buffer(new char[rhs.capacity])
 {
-    std::copy(rhs.buffer + consume, rhs.buffer + produce, buffer + consume);
+       std::copy(rhs.buffer + consume, rhs.buffer + produce, buffer + consume);
 }
 
 MessageComposer::MessageComposer(MessageComposer&& rhs) :
-    capacity(0),
-    produce(0),
-    consume(0),
-    buffer(nullptr)
+       capacity(0),
+       produce(0),
+       consume(0),
+       buffer(nullptr)
 {
-    buffer = rhs.buffer;
-    capacity = rhs.capacity;
-    produce = rhs.produce;
-    consume = rhs.consume;
+       buffer = rhs.buffer;
+       capacity = rhs.capacity;
+       produce = rhs.produce;
+       consume = rhs.consume;
 
-    // Release buffer pointer from the source object so that
-    // the destructor does not free the memory multiple times.
+       // Release buffer pointer from the source object so that
+       // the destructor does not free the memory multiple times.
 
-    rhs.buffer = nullptr;
-    rhs.produce = 0;
-    rhs.consume = 0;
+       rhs.buffer = nullptr;
+       rhs.produce = 0;
+       rhs.consume = 0;
 }
 
 MessageComposer::~MessageComposer()
 {
-    if (buffer != nullptr) {
-        delete[] buffer;
-    }
+       if (buffer != nullptr) {
+               delete[] buffer;
+       }
 }
 
 MessageComposer& MessageComposer::operator=(const MessageComposer& rhs)
 {
-    if (this != &rhs) {
-        delete[] buffer;
+       if (this != &rhs) {
+               delete[] buffer;
 
-        capacity = rhs.capacity;
-        produce = rhs.produce;
-        consume = rhs.consume;
-        buffer = new char[capacity];
-        std::copy(rhs.buffer + consume, rhs.buffer + produce, buffer + consume);
-    }
+               capacity = rhs.capacity;
+               produce = rhs.produce;
+               consume = rhs.consume;
+               buffer = new char[capacity];
+               std::copy(rhs.buffer + consume, rhs.buffer + produce, buffer + consume);
+       }
 
-    return *this;
+       return *this;
 }
 
 MessageComposer& MessageComposer::operator=(MessageComposer&& rhs)
 {
-    if (this != &rhs) {
-        // Free existing buffer
-        delete[] buffer;
-
-        // Copy the buffer pointer and its attributes from the
-        // source object.
-        buffer = rhs.buffer;
-        produce = rhs.produce;
-        consume = rhs.consume;
-        capacity = rhs.capacity;
-
-        // Release buffer pointer from the source object so that
-        // the destructor does not free the memory multiple times.
-        rhs.buffer = nullptr;
-        rhs.produce = 0;
-        rhs.consume = 0;
-        rhs.capacity = 0;
-    }
-
-    return *this;
+       if (this != &rhs) {
+               // Free existing buffer
+               delete[] buffer;
+
+               // Copy the buffer pointer and its attributes from the
+               // source object.
+               buffer = rhs.buffer;
+               produce = rhs.produce;
+               consume = rhs.consume;
+               capacity = rhs.capacity;
+
+               // Release buffer pointer from the source object so that
+               // the destructor does not free the memory multiple times.
+               rhs.buffer = nullptr;
+               rhs.produce = 0;
+               rhs.consume = 0;
+               rhs.capacity = 0;
+       }
+
+       return *this;
 }
 
 void MessageComposer::write(const void* ptr, const size_t sz)
 {
-    size_t bytes = sz;
-    if ((produce + bytes) > capacity) {
-        bytes = capacity - produce;
-    }
+       size_t bytes = sz;
+       if ((produce + bytes) > capacity) {
+               bytes = capacity - produce;
+       }
 
-    ::memcpy(reinterpret_cast<char *>(buffer + produce), ptr, bytes);
-    produce += bytes;
+       ::memcpy(reinterpret_cast<char *>(buffer + produce), ptr, bytes);
+       produce += bytes;
 }
 
 void MessageComposer::read(void* ptr, const size_t sz)
 {
-    size_t bytes = sz;
-    if ((consume + bytes) > produce) {
-        bytes = produce - consume;
-    }
-
-    ::memcpy(ptr, reinterpret_cast<char *>(buffer) + consume, bytes);
-    consume += bytes;
-
-    // Reset cursors if there is no data
-    if (consume == produce) {
-        consume = produce = 0;
-    }
+       size_t bytes = sz;
+       if ((consume + bytes) > produce) {
+               bytes = produce - consume;
+       }
+
+       ::memcpy(ptr, reinterpret_cast<char *>(buffer) + consume, bytes);
+       consume += bytes;
+
+       // Reset cursors if there is no data
+       if (consume == produce) {
+               consume = produce = 0;
+       }
 }
 
 } // namespae rmi
index ce4838a..377b817 100644 (file)
@@ -26,48 +26,48 @@ namespace rmi {
 
 class MessageComposer {
 public:
-    MessageComposer(size_t caps = 4096);
-    MessageComposer(const MessageComposer& rhs);
-    MessageComposer(MessageComposer&& rhs);
+       MessageComposer(size_t caps = 4096);
+       MessageComposer(const MessageComposer& rhs);
+       MessageComposer(MessageComposer&& rhs);
 
-    ~MessageComposer();
+       ~MessageComposer();
 
-    MessageComposer& operator=(const MessageComposer& rhs);
-    MessageComposer& operator=(MessageComposer&& rhs);
+       MessageComposer& operator=(const MessageComposer& rhs);
+       MessageComposer& operator=(MessageComposer&& rhs);
 
-    void write(const void* ptr, const size_t sz);
-    void read(void* ptr, const size_t sz);
+       void write(const void* ptr, const size_t sz);
+       void read(void* ptr, const size_t sz);
 
-    void reserve(size_t size)
-    {
-        produce = size;
-    }
+       void reserve(size_t size)
+       {
+               produce = size;
+       }
 
-    void reset()
-    {
-        produce = consume = 0;
-    }
+       void reset()
+       {
+               produce = consume = 0;
+       }
 
-    char* begin() const
-    {
-        return buffer + consume;
-    }
+       char* begin() const
+       {
+               return buffer + consume;
+       }
 
-    char* end() const
-    {
-        return buffer + produce;
-    }
+       char* end() const
+       {
+               return buffer + produce;
+       }
 
-    size_t size() const
-    {
-        return (end() - begin());
-    }
+       size_t size() const
+       {
+               return (end() - begin());
+       }
 
 private:
-    size_t capacity;
-    size_t produce;
-    size_t consume;
-    char *buffer;
+       size_t capacity;
+       size_t produce;
+       size_t consume;
+       char *buffer;
 };
 
 } // namespae rmi
index 3a9e0f5..3c5efca 100644 (file)
@@ -21,26 +21,26 @@ namespace rmi {
 std::atomic<unsigned int> Message::sequence(0);
 
 Message::Message() :
-    signature({sequence++, Invalid, ""})
+       signature({sequence++, Invalid, ""})
 {
 }
 
 Message::Message(unsigned int id, unsigned int type, const std::string& target) :
-    signature({id, type, target})
+       signature({id, type, target})
 {
-    enclose(signature);
+       enclose(signature);
 }
 
 Message::Message(unsigned int type, const std::string& target) :
-    signature({sequence++, type, target})
+       signature({sequence++, type, target})
 {
-    enclose(signature);
+       enclose(signature);
 }
 
 Message::Message(Message&& rhs)
-    : signature(std::move(rhs.signature)),
-      buffer(std::move(rhs.buffer)),
-      fileDescriptors(std::move(rhs.fileDescriptors))
+       : signature(std::move(rhs.signature)),
+         buffer(std::move(rhs.buffer)),
+         fileDescriptors(std::move(rhs.fileDescriptors))
 {
 }
 
@@ -49,57 +49,57 @@ Message::~Message()
 }
 
 Message::Message(const Message& rhs) :
-    signature(rhs.signature),
-    buffer(rhs.buffer)
+       signature(rhs.signature),
+       buffer(rhs.buffer)
 {
-    enclose(signature);
+       enclose(signature);
 }
 
 Message& Message::operator=(const Message& rhs)
 {
-    if (this != &rhs) {
-        buffer = rhs.buffer;
-        signature = rhs.signature;
-    }
+       if (this != &rhs) {
+               buffer = rhs.buffer;
+               signature = rhs.signature;
+       }
 
-    return *this;
+       return *this;
 }
 
 Message& Message::operator=(Message&& rhs)
 {
-    if (this != &rhs) {
-        buffer = std::move(rhs.buffer);
-        signature = std::move(rhs.signature);
-        fileDescriptors = std::move(rhs.fileDescriptors);
-    }
+       if (this != &rhs) {
+               buffer = std::move(rhs.buffer);
+               signature = std::move(rhs.signature);
+               fileDescriptors = std::move(rhs.fileDescriptors);
+       }
 
-    return *this;
+       return *this;
 }
 
 Message Message::createReplyMessage() const
 {
-    return Message(id(), Reply, target());
+       return Message(id(), Reply, target());
 }
 
 Message Message::createErrorMessage(const std::string& message) const
 {
-    Message error(id(), Error, target());
-    error.enclose(message);
+       Message error(id(), Error, target());
+       error.enclose(message);
 
-    return error;
+       return error;
 }
 
 template<> void Message::enclose(FileDescriptor&& fd)
 {
-    fileDescriptors.push_back(std::move(fd));
+       fileDescriptors.push_back(std::move(fd));
 }
 
 template<> void Message::disclose(FileDescriptor& fd)
 {
-    if (!fileDescriptors.empty()) {
-        fd.fileDescriptor = std::move(fileDescriptors.front()).fileDescriptor;
-        fileDescriptors.pop_front();
-    }
+       if (!fileDescriptors.empty()) {
+               fd.fileDescriptor = std::move(fileDescriptors.front()).fileDescriptor;
+               fileDescriptors.pop_front();
+       }
 }
 
 } // namespace rmi
index 8a00fba..a54f360 100644 (file)
@@ -34,207 +34,207 @@ namespace rmi {
 
 class Message {
 public:
-    enum Type {
-        Invalid,
-        MethodCall,
-        Reply,
-        Error,
-        Signal
-    };
+       enum Type {
+               Invalid,
+               MethodCall,
+               Reply,
+               Error,
+               Signal
+       };
 
-    Message();
-    Message(unsigned int id, unsigned int type, const std::string&);
-    Message(unsigned int type, const std::string&);
-    Message(const Message& rhs);
-    Message(Message&& rhs);
+       Message();
+       Message(unsigned int id, unsigned int type, const std::string&);
+       Message(unsigned int type, const std::string&);
+       Message(const Message& rhs);
+       Message(Message&& rhs);
 
-    ~Message();
+       ~Message();
 
-    Message& operator=(const Message& rhs);
-    Message& operator=(Message&& rhs);
+       Message& operator=(const Message& rhs);
+       Message& operator=(Message&& rhs);
 
-    // [TBD] Take arguments
-    Message createReplyMessage() const;
-    Message createErrorMessage(const std::string& message) const;
+       // [TBD] Take arguments
+       Message createReplyMessage() const;
+       Message createErrorMessage(const std::string& message) const;
 
-    unsigned int id() const
-    {
-        return signature.id;
-    }
+       unsigned int id() const
+       {
+               return signature.id;
+       }
 
-    unsigned int type() const
-    {
-        return signature.type;
-    }
+       unsigned int type() const
+       {
+               return signature.type;
+       }
 
-    const std::string& target() const
-    {
-        return signature.target;
-    }
+       const std::string& target() const
+       {
+               return signature.target;
+       }
 
-    bool isInvalid() const
-    {
-        return type() == Invalid;
-    }
+       bool isInvalid() const
+       {
+               return type() == Invalid;
+       }
 
-    bool isError() const
-    {
-        return type() == Error;
-    }
+       bool isError() const
+       {
+               return type() == Error;
+       }
 
-    bool isMethodCall() const
-    {
-        return type() == MethodCall;
-    }
+       bool isMethodCall() const
+       {
+               return type() == MethodCall;
+       }
 
-    bool isSignal() const
-    {
-        return type() == Signal;
-    }
+       bool isSignal() const
+       {
+               return type() == Signal;
+       }
 
-    bool isReply() const
-    {
-        return type() == Reply;
-    }
+       bool isReply() const
+       {
+               return type() == Reply;
+       }
 
-    template<typename T>
-    void encode(const T& device) const;
+       template<typename T>
+       void encode(const T& device) const;
 
-    template<typename T>
-    void decode(const T& device);
+       template<typename T>
+       void decode(const T& device);
 
-    void packParameters()
-    {
-    }
+       void packParameters()
+       {
+       }
 
-    template<typename F>
-    void packParameters(F&& arg);
+       template<typename F>
+       void packParameters(F&& arg);
 
-    template<typename F, typename...R>
-    void packParameters(F&& first, R&&... rest);
+       template<typename F, typename...R>
+       void packParameters(F&& first, R&&... rest);
 
-    void unpackParameters()
-    {
-    }
+       void unpackParameters()
+       {
+       }
 
-    template<typename F>
-    void unpackParameters(F& arg);
+       template<typename F>
+       void unpackParameters(F& arg);
 
-    template<typename F, typename... R>
-    void unpackParameters(F& first, R&... rest);
+       template<typename F, typename... R>
+       void unpackParameters(F& first, R&... rest);
 
-    template<typename DataType>
-    void enclose(DataType&& data);
+       template<typename DataType>
+       void enclose(DataType&& data);
 
-    template<typename DataType>
-    void disclose(DataType& data);
+       template<typename DataType>
+       void disclose(DataType& data);
 
 private:
-    struct MessageHeader {
-        unsigned int id;    // Unique message id
-        unsigned int type;  // Mesage type
-        size_t length;// Total message length except MessageHeader itself
-        size_t ancillary;
-    };
-
-    struct MessageSignature {
-        unsigned int id;
-        unsigned int type;
-        std::string target;
-
-        REFLECTABLE(
-            id,
-            type,
-            target
-        )
-    };
-
-    MessageSignature signature;
-    MessageComposer buffer;
-    std::deque<FileDescriptor> fileDescriptors;
-
-    static std::atomic<unsigned int> sequence;
+       struct MessageHeader {
+               unsigned int id;    // Unique message id
+               unsigned int type;  // Mesage type
+               size_t length;// Total message length except MessageHeader itself
+               size_t ancillary;
+       };
+
+       struct MessageSignature {
+               unsigned int id;
+               unsigned int type;
+               std::string target;
+
+               REFLECTABLE(
+                       id,
+                       type,
+                       target
+               )
+       };
+
+       MessageSignature signature;
+       MessageComposer buffer;
+       std::deque<FileDescriptor> fileDescriptors;
+
+       static std::atomic<unsigned int> sequence;
 };
 
 template<typename F>
 void Message::packParameters(F&& arg)
 {
-    enclose<F>(std::forward<F>(arg));
+       enclose<F>(std::forward<F>(arg));
 }
 
 template<typename F, typename...R>
 void Message::packParameters(F&& first, R&&... rest)
 {
-    packParameters(std::forward<F>(first));
-    packParameters(std::forward<R>(rest)...);
+       packParameters(std::forward<F>(first));
+       packParameters(std::forward<R>(rest)...);
 }
 
 template<typename F>
 void Message::unpackParameters(F& arg)
 {
-    disclose<F>(arg);
+       disclose<F>(arg);
 }
 
 template<typename F, typename... R>
 void Message::unpackParameters(F& first, R&... rest)
 {
-    unpackParameters(first);
-    unpackParameters(rest...);
+       unpackParameters(first);
+       unpackParameters(rest...);
 }
 
 template<typename DataType>
 void Message::enclose(DataType&& data)
 {
-    runtime::Serializer<MessageComposer> serializer(buffer);
-    runtime::SerializableArgument<DataType> arg(std::forward<DataType>(data));
-    arg.accept(serializer);
+       runtime::Serializer<MessageComposer> serializer(buffer);
+       runtime::SerializableArgument<DataType> arg(std::forward<DataType>(data));
+       arg.accept(serializer);
 }
 
 template<typename DataType>
 void Message::disclose(DataType& data)
 {
-    runtime::Deserializer<MessageComposer> deserializer(buffer);
-    runtime::DeserializableArgument<DataType> arg(data);
-    arg.accept(deserializer);
+       runtime::Deserializer<MessageComposer> deserializer(buffer);
+       runtime::DeserializableArgument<DataType> arg(data);
+       arg.accept(deserializer);
 }
 
 template<typename T>
 void Message::encode(const T& device) const
 {
-    MessageHeader header = {
-        signature.id,
-        signature.type,
-        buffer.size(),
-        fileDescriptors.size()
-    };
-
-    device.write(&header, sizeof(header));
-    device.write(buffer.begin(), header.length);
-
-    int i = 0, fds[fileDescriptors.size()];
-    for (const FileDescriptor& fd : fileDescriptors) {
-        fds[i++] = fd.fileDescriptor;
-    }
-
-    device.sendFileDescriptors(fds, fileDescriptors.size());
+       MessageHeader header = {
+               signature.id,
+               signature.type,
+               buffer.size(),
+               fileDescriptors.size()
+       };
+
+       device.write(&header, sizeof(header));
+       device.write(buffer.begin(), header.length);
+
+       int i = 0, fds[fileDescriptors.size()];
+       for (const FileDescriptor& fd : fileDescriptors) {
+               fds[i++] = fd.fileDescriptor;
+       }
+
+       device.sendFileDescriptors(fds, fileDescriptors.size());
 }
 
 template<typename T>
 void Message::decode(const T& device)
 {
-    MessageHeader header;
-    device.read(&header, sizeof(header));
-    device.read(buffer.begin(), header.length);
-    buffer.reserve(header.length);
+       MessageHeader header;
+       device.read(&header, sizeof(header));
+       device.read(buffer.begin(), header.length);
+       buffer.reserve(header.length);
 
-    int fds[header.ancillary];
+       int fds[header.ancillary];
 
-    device.receiveFileDescriptors(fds, header.ancillary);
-    for (unsigned int i = 0; i < header.ancillary; i++) {
-        fileDescriptors.emplace_back(FileDescriptor(fds[i]));
-    }
+       device.receiveFileDescriptors(fds, header.ancillary);
+       for (unsigned int i = 0; i < header.ancillary; i++) {
+               fileDescriptors.emplace_back(FileDescriptor(fds[i]));
+       }
 
-    disclose(signature);
+       disclose(signature);
 }
 
 template<> void Message::enclose(FileDescriptor&& fd);
index d2b2f4e..1e1dfd9 100644 (file)
@@ -29,44 +29,44 @@ Notification::Notification()
 }
 
 Notification::Notification(const std::string& name) :
-    signalName(name)
+       signalName(name)
 {
 }
 
 Notification::Notification(Notification&& rhs) :
-    signalName(std::move(rhs.signalName)),
-    subscribers(std::move(rhs.subscribers))
+       signalName(std::move(rhs.signalName)),
+       subscribers(std::move(rhs.subscribers))
 {
 }
 
 SubscriptionId Notification::createSubscriber()
 {
-    int fds[2] = {-1, -1};
-    if (::socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
-        throw runtime::Exception("Failed to create socket pair");
-    }
+       int fds[2] = {-1, -1};
+       if (::socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
+               throw runtime::Exception("Failed to create socket pair");
+       }
 
-    std::lock_guard<std::mutex> lock(subscriberLock);
+       std::lock_guard<std::mutex> lock(subscriberLock);
        subscribers.push_back(std::make_shared<Socket>(fds[0]));
 
-    return SubscriptionId(fds[0], fds[1]);
+       return SubscriptionId(fds[0], fds[1]);
 }
 
 int Notification::removeSubscriber(const int id)
 {
-    std::lock_guard<std::mutex> lock(subscriberLock);
+       std::lock_guard<std::mutex> lock(subscriberLock);
 
-    std::list<std::shared_ptr<Socket>>::iterator it = subscribers.begin();
+       std::list<std::shared_ptr<Socket>>::iterator it = subscribers.begin();
 
-    while (it != subscribers.end()) {
-       if ((*it)->getFd() == id) {
-            subscribers.erase(it);
-            return 0;
-       }
-       ++it;
-    }
+       while (it != subscribers.end()) {
+          if ((*it)->getFd() == id) {
+                       subscribers.erase(it);
+                       return 0;
+          }
+          ++it;
+       }
 
-    return -1;
+       return -1;
 }
 
 } // namespace rmi
index 7da9e51..22d802e 100644 (file)
@@ -35,13 +35,13 @@ typedef std::pair<int, int> SubscriptionId;
 
 class Notification {
 public:
-    Notification();
+       Notification();
        Notification(const std::string& name);
-    Notification(const Notification&) = default;
-    Notification(Notification&&);
+       Notification(const Notification&) = default;
+       Notification(Notification&&);
 
-    SubscriptionId createSubscriber();
-    int removeSubscriber(const int id);
+       SubscriptionId createSubscriber();
+       int removeSubscriber(const int id);
 
        template<typename... Args>
        void notify(Args&&... args);
@@ -49,7 +49,7 @@ public:
 private:
        std::string signalName;
        std::list<std::shared_ptr<Socket>> subscribers;
-    std::mutex subscriberLock;
+       std::mutex subscriberLock;
 };
 
 template<typename... Args>
@@ -58,15 +58,15 @@ void Notification::notify(Args&&... args)
        Message msg(Message::Signal, signalName);
        msg.packParameters(std::forward<Args>(args)...);
 
-    std::lock_guard<std::mutex> lock(subscriberLock);
+       std::lock_guard<std::mutex> lock(subscriberLock);
 
-    for (const std::shared_ptr<Socket>& subscriber : subscribers) {
-        try {
-            msg.encode(*subscriber);
-        } catch (runtime::Exception& e) {
-            ERROR(e.what());
-        }
-    }
+       for (const std::shared_ptr<Socket>& subscriber : subscribers) {
+               try {
+                       msg.encode(*subscriber);
+               } catch (runtime::Exception& e) {
+                       ERROR(e.what());
+               }
+       }
 }
 
 } // namespae rmi
index 317b427..0c3effb 100644 (file)
@@ -29,11 +29,10 @@ namespace rmi {
 thread_local Service::ProcessingContext Service::processingContext;
 
 Service::Service(const std::string& path) :
-    address(path),
-    workqueue(5)
+       address(path), workqueue(5)
 {
-    setNewConnectionCallback(nullptr);
-    setCloseConnectionCallback(nullptr);
+       setNewConnectionCallback(nullptr);
+       setCloseConnectionCallback(nullptr);
 }
 
 Service::~Service()
@@ -42,17 +41,17 @@ Service::~Service()
 
 void Service::start(bool useGMainloop)
 {
-    Socket socket(Socket::create(address));
+       Socket socket(Socket::create(address));
 
-    auto accept = [&](int fd, runtime::Mainloop::Event event) {
-        onNewConnection(std::make_shared<Connection>(socket.accept()));
-    };
+       auto accept = [&](int fd, runtime::Mainloop::Event event) {
+               onNewConnection(std::make_shared<Connection>(socket.accept()));
+       };
 
-    mainloop.addEventSource(socket.getFd(),
-                            EPOLLIN | EPOLLHUP | EPOLLRDHUP,
-                            accept);
+       mainloop.addEventSource(socket.getFd(),
+                                                       EPOLLIN | EPOLLHUP | EPOLLRDHUP,
+                                                       accept);
 
-    mainloop.run(useGMainloop);
+       mainloop.run(useGMainloop);
 }
 
 void Service::stop()
@@ -61,159 +60,159 @@ void Service::stop()
 
 Service::ConnectionRegistry::iterator Service::getConnectionIterator(const int id)
 {
-    return std::find_if(connectionRegistry.begin(), connectionRegistry.end(),
-                        [id](const std::shared_ptr<Connection>& connection) {
-        return id == connection->getFd();
-    });
+       return std::find_if(connectionRegistry.begin(), connectionRegistry.end(),
+                                               [id](const std::shared_ptr<Connection>& connection) {
+               return id == connection->getFd();
+       });
 }
 
 void Service::setPrivilegeChecker(const PrivilegeChecker& checker)
 {
-    auto check = [checker, this](const Credentials& cred, const std::string& privilege) {
-        return checker(cred, privilege);
-    };
+       auto check = [checker, this](const Credentials& cred, const std::string& privilege) {
+               return checker(cred, privilege);
+       };
 
-    onMethodCall = std::move(checker);
+       onMethodCall = std::move(checker);
 }
 
 void Service::setNewConnectionCallback(const ConnectionCallback& connectionCallback)
 {
-    auto callback = [connectionCallback, this](const std::shared_ptr<Connection>& connection) {
-        auto handle = [&](int fd, runtime::Mainloop::Event event) {
-            std::lock_guard<std::mutex> lock(stateLock);
-
-            auto iter = getConnectionIterator(fd);
-            if (iter == connectionRegistry.end()) {
-                return;
-            }
-
-            if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) {
-                onCloseConnection(*iter);
-                connectionRegistry.erase(iter);
-                return;
-            }
-
-            onMessageProcess(*iter);
-        };
-
-        if ((connectionCallback == nullptr) ||
-            (connectionCallback(*connection) == true)) {
-            mainloop.addEventSource(connection->getFd(),
-                                    EPOLLIN | EPOLLHUP | EPOLLRDHUP,
-                                    handle);
-            std::lock_guard<std::mutex> lock(stateLock);
-            connectionRegistry.push_back(connection);
-        }
-    };
-
-    std::lock_guard<std::mutex> lock(stateLock);
-    onNewConnection = std::move(callback);
+       auto callback = [connectionCallback, this](const std::shared_ptr<Connection>& connection) {
+               auto handle = [&](int fd, runtime::Mainloop::Event event) {
+                       std::lock_guard<std::mutex> lock(stateLock);
+
+                       auto iter = getConnectionIterator(fd);
+                       if (iter == connectionRegistry.end()) {
+                               return;
+                       }
+
+                       if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) {
+                               onCloseConnection(*iter);
+                               connectionRegistry.erase(iter);
+                               return;
+                       }
+
+                       onMessageProcess(*iter);
+               };
+
+               if ((connectionCallback == nullptr) ||
+                       (connectionCallback(*connection) == true)) {
+                       mainloop.addEventSource(connection->getFd(),
+                                                                       EPOLLIN | EPOLLHUP | EPOLLRDHUP,
+                                                                       handle);
+                       std::lock_guard<std::mutex> lock(stateLock);
+                       connectionRegistry.push_back(connection);
+               }
+       };
+
+       std::lock_guard<std::mutex> lock(stateLock);
+       onNewConnection = std::move(callback);
 }
 
 void Service::setCloseConnectionCallback(const ConnectionCallback& closeCallback)
 {
-    auto callback = [closeCallback, this](const std::shared_ptr<Connection>& connection) {
-        mainloop.removeEventSource(connection->getFd());
-        if (closeCallback) {
-            closeCallback(*connection);
-        }
-    };
-
-    std::lock_guard<std::mutex> lock(stateLock);
-    onCloseConnection = std::move(callback);
+       auto callback = [closeCallback, this](const std::shared_ptr<Connection>& connection) {
+               mainloop.removeEventSource(connection->getFd());
+               if (closeCallback) {
+                       closeCallback(*connection);
+               }
+       };
+
+       std::lock_guard<std::mutex> lock(stateLock);
+       onCloseConnection = std::move(callback);
 }
 
 void Service::createNotification(const std::string& name)
 {
-    std::lock_guard<std::mutex> lock(notificationLock);
+       std::lock_guard<std::mutex> lock(notificationLock);
 
-    if (notificationRegistry.count(name)) {
-        throw runtime::Exception("Notification already registered");
-    }
+       if (notificationRegistry.count(name)) {
+               throw runtime::Exception("Notification already registered");
+       }
 
-    notificationRegistry.emplace(name, Notification(name));
+       notificationRegistry.emplace(name, Notification(name));
 }
 
 int Service::subscribeNotification(const std::string& name)
 {
-    auto closeHandler = [&, name, this](int fd, runtime::Mainloop::Event event) {
-        if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) {
-            unsubscribeNotification(name, fd);
-            return;
-        }
-    };
-
-    notificationLock.lock();
-    if (!notificationRegistry.count(name)) {
-        notificationLock.unlock();
-        return -1;
-    }
-
-    Notification& notification = notificationRegistry[name];
-    notificationLock.unlock();
-
-    try {
-        SubscriptionId slot = notification.createSubscriber();
-        mainloop.addEventSource(slot.first, EPOLLHUP | EPOLLRDHUP, closeHandler);
-        return slot.second;
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
-
-    return -1;
+       auto closeHandler = [&, name, this](int fd, runtime::Mainloop::Event event) {
+               if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) {
+                       unsubscribeNotification(name, fd);
+                       return;
+               }
+       };
+
+       notificationLock.lock();
+       if (!notificationRegistry.count(name)) {
+               notificationLock.unlock();
+               return -1;
+       }
+
+       Notification& notification = notificationRegistry[name];
+       notificationLock.unlock();
+
+       try {
+               SubscriptionId slot = notification.createSubscriber();
+               mainloop.addEventSource(slot.first, EPOLLHUP | EPOLLRDHUP, closeHandler);
+               return slot.second;
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return -1;
 }
 
 int Service::unsubscribeNotification(const std::string& name, const int id)
 {
-    notificationLock.lock();
+       notificationLock.lock();
 
-    if (!notificationRegistry.count(name)) {
-        notificationLock.unlock();
-        return -1;
-    }
+       if (!notificationRegistry.count(name)) {
+               notificationLock.unlock();
+               return -1;
+       }
 
-    Notification& notification = notificationRegistry[name];
-    notificationLock.unlock();
+       Notification& notification = notificationRegistry[name];
+       notificationLock.unlock();
 
-    mainloop.removeEventSource(id);
+       mainloop.removeEventSource(id);
 
-    notification.removeSubscriber(id);
+       notification.removeSubscriber(id);
 
-    return 0;
+       return 0;
 }
 
 void Service::onMessageProcess(const std::shared_ptr<Connection>& connection)
 {
-    // The connection object can be destroyed in main-thread when peer is closed.
-    // To make sure that the connection object is valid on that situation,
-    // we should increase the reference count of the shared_ptr by capturing it as value
-    auto process = [&, connection](Message& request) {
-        try {
-            std::shared_ptr<MethodContext> methodContext = methodRegistry.at(request.target());
-
-            processingContext = ProcessingContext(connection);
-            if (onMethodCall(processingContext.credentials, methodContext->privilege) != true) {
-                throw runtime::Exception("Permission denied");
-            }
-
-            connection->send(methodContext->dispatcher(request));
-        } catch (std::exception& e) {
-            try {
-                // Forward the exception to the peer
-                connection->send(request.createErrorMessage(e.what()));
-            } catch (std::exception& ex) {
-                // The connection is abnormally closed by the peer.
-                ERROR(ex.what());
-            }
-        }
-    };
-
-    try {
-        workqueue.submit(std::bind(process, connection->dispatch()));
-    } catch (std::exception& e) {
-        ERROR(e.what());
-    }
+       // The connection object can be destroyed in main-thread when peer is closed.
+       // To make sure that the connection object is valid on that situation,
+       // we should increase the reference count of the shared_ptr by capturing it as value
+       auto process = [&, connection](Message& request) {
+               try {
+                       std::shared_ptr<MethodContext> methodContext = methodRegistry.at(request.target());
+
+                       processingContext = ProcessingContext(connection);
+                       if (onMethodCall(processingContext.credentials, methodContext->privilege) != true) {
+                               throw runtime::Exception("Permission denied");
+                       }
+
+                       connection->send(methodContext->dispatcher(request));
+               } catch (std::exception& e) {
+                       try {
+                               // Forward the exception to the peer
+                               connection->send(request.createErrorMessage(e.what()));
+                       } catch (std::exception& ex) {
+                               // The connection is abnormally closed by the peer.
+                               ERROR(ex.what());
+                       }
+               }
+       };
+
+       try {
+               workqueue.submit(std::bind(process, connection->dispatch()));
+       } catch (std::exception& e) {
+               ERROR(e.what());
+       }
 }
 
 } // namespace rmi
index 0089d9b..0dee955 100644 (file)
 
 #define registerMethod(T, P, M, ...)                                          \
 setMethodHandler<TYPEOF(M), TYPEOF(STRIP(STRIP(M)))>                          \
-                (P, STRINGIFY(TYPEOF(STRIP(M))), std::bind(&TYPEOF(STRIP(M)), T, \
-                PROTOTYPE(TYPEOF(STRIP(STRIP(M))))))
+                               (P, STRINGIFY(TYPEOF(STRIP(M))), std::bind(&TYPEOF(STRIP(M)), T, \
+                               PROTOTYPE(TYPEOF(STRIP(STRIP(M))))))
 
 #define registerParametricMethod(T, P, M, ...)                                \
 setMethodHandler<TYPEOF(M), TYPEOF(STRIP(STRIP(M)))>                          \
-                (P, STRINGIFY(TYPEOF(STRIP(M))), std::bind(&TYPEOF(STRIP(M)), T, \
-                PROTOTYPE(TYPEOF(STRIP(STRIP(M))))))
+                               (P, STRINGIFY(TYPEOF(STRIP(M))), std::bind(&TYPEOF(STRIP(M)), T, \
+                               PROTOTYPE(TYPEOF(STRIP(STRIP(M))))))
 
 #define registerNonparametricMethod(T, P, M, ...)                             \
 setMethodHandler<TYPEOF(M)>                                                   \
-                (P, STRINGIFY(TYPEOF(STRIP(M))), std::bind(&TYPEOF(STRIP(M)), T))
+                               (P, STRINGIFY(TYPEOF(STRIP(M))), std::bind(&TYPEOF(STRIP(M)), T))
 
 namespace rmi {
 
@@ -69,125 +69,125 @@ typedef std::function<bool(const Credentials& cred, const std::string& privilege
 
 class Service {
 public:
-    Service(const std::string& address);
-    ~Service();
+       Service(const std::string& address);
+       ~Service();
 
-    Service(const Service&) = delete;
-    Service& operator=(const Service&) = delete;
+       Service(const Service&) = delete;
+       Service& operator=(const Service&) = delete;
 
-    void start(bool useGMainloop = false);
-    void stop();
+       void start(bool useGMainloop = false);
+       void stop();
 
-    void setPrivilegeChecker(const PrivilegeChecker& checker);
-    void setNewConnectionCallback(const ConnectionCallback& callback);
-    void setCloseConnectionCallback(const ConnectionCallback& callback);
+       void setPrivilegeChecker(const PrivilegeChecker& checker);
+       void setNewConnectionCallback(const ConnectionCallback& callback);
+       void setCloseConnectionCallback(const ConnectionCallback& callback);
 
-    template<typename Type, typename... Args>
-    void setMethodHandler(const std::string& privilege, const std::string& method,
-                          const typename MethodHandler<Type, Args...>::type& handler);
+       template<typename Type, typename... Args>
+       void setMethodHandler(const std::string& privilege, const std::string& method,
+                                                 const typename MethodHandler<Type, Args...>::type& handler);
 
-    void createNotification(const std::string& name);
-    int subscribeNotification(const std::string& name);
-    int unsubscribeNotification(const std::string& name, const int id);
+       void createNotification(const std::string& name);
+       int subscribeNotification(const std::string& name);
+       int unsubscribeNotification(const std::string& name, const int id);
 
        template <typename... Args>
        void notify(const std::string& name, Args&&... args);
 
-    pid_t getPeerPid() const
-    {
-        return processingContext.credentials.pid;
-    }
+       pid_t getPeerPid() const
+       {
+               return processingContext.credentials.pid;
+       }
 
-    uid_t getPeerUid() const
-    {
-        return processingContext.credentials.uid;
-    }
+       uid_t getPeerUid() const
+       {
+               return processingContext.credentials.uid;
+       }
 
-    gid_t getPeerGid() const
-    {
-        return processingContext.credentials.gid;
-    }
+       gid_t getPeerGid() const
+       {
+               return processingContext.credentials.gid;
+       }
 
 private:
-    struct ProcessingContext {
-        ProcessingContext() = default;
-        ProcessingContext(const std::shared_ptr<Connection>& connection) :
-            credentials(connection->getPeerCredentials())
-        {
-        }
+       struct ProcessingContext {
+               ProcessingContext() = default;
+               ProcessingContext(const std::shared_ptr<Connection>& connection) :
+                       credentials(connection->getPeerCredentials())
+               {
+               }
 
-        Credentials credentials;
-    };
+               Credentials credentials;
+       };
 
-    typedef std::list<std::shared_ptr<Connection>> ConnectionRegistry;
-    typedef std::function<void(const std::shared_ptr<Connection>& connection)> CallbackDispatcher;
+       typedef std::list<std::shared_ptr<Connection>> ConnectionRegistry;
+       typedef std::function<void(const std::shared_ptr<Connection>& connection)> CallbackDispatcher;
 
-    typedef std::function<Message(Message& message)> MethodDispatcher;
+       typedef std::function<Message(Message& message)> MethodDispatcher;
 
-    struct MethodContext {
-        MethodContext(const std::string& priv, MethodDispatcher&& disp) :
-            privilege(priv), dispatcher(std::move(disp))
-        {
-        }
+       struct MethodContext {
+               MethodContext(const std::string& priv, MethodDispatcher&& disp) :
+                       privilege(priv), dispatcher(std::move(disp))
+               {
+               }
 
-        std::string privilege;
-        MethodDispatcher dispatcher;
-    };
+               std::string privilege;
+               MethodDispatcher dispatcher;
+       };
 
-    typedef std::unordered_map<std::string, std::shared_ptr<MethodContext>> MethodRegistry;
-    typedef std::unordered_map<std::string, Notification> NotificationRegistry;
+       typedef std::unordered_map<std::string, std::shared_ptr<MethodContext>> MethodRegistry;
+       typedef std::unordered_map<std::string, Notification> NotificationRegistry;
 
-    void onMessageProcess(const std::shared_ptr<Connection>& connection);
+       void onMessageProcess(const std::shared_ptr<Connection>& connection);
 
-    ConnectionRegistry::iterator getConnectionIterator(const int id);
+       ConnectionRegistry::iterator getConnectionIterator(const int id);
 
-    CallbackDispatcher onNewConnection;
-    CallbackDispatcher onCloseConnection;
-    PrivilegeChecker onMethodCall;
+       CallbackDispatcher onNewConnection;
+       CallbackDispatcher onCloseConnection;
+       PrivilegeChecker onMethodCall;
 
-    MethodRegistry methodRegistry;
-    NotificationRegistry notificationRegistry;
-    ConnectionRegistry connectionRegistry;
+       MethodRegistry methodRegistry;
+       NotificationRegistry notificationRegistry;
+       ConnectionRegistry connectionRegistry;
 
-    runtime::Mainloop mainloop;
-    std::string address;
+       runtime::Mainloop mainloop;
+       std::string address;
 
-    runtime::ThreadPool workqueue;
-    std::mutex stateLock;
-    std::mutex notificationLock;
-    std::mutex methodRegistryLock;
+       runtime::ThreadPool workqueue;
+       std::mutex stateLock;
+       std::mutex notificationLock;
+       std::mutex methodRegistryLock;
 
-    static thread_local ProcessingContext processingContext;
+       static thread_local ProcessingContext processingContext;
 };
 
 template<typename Type, typename... Args>
 void Service::setMethodHandler(const std::string& privilege, const std::string& method,
-                               const typename MethodHandler<Type, Args...>::type& handler)
+                                                          const typename MethodHandler<Type, Args...>::type& handler)
 {
-    auto dispatchMethod = [handler](Message& message) {
-        CallbackHolder<Type, Args...> callback(handler);
-        Message reply = message.createReplyMessage();
-        reply.packParameters<Type>(callback.dispatch(message));
+       auto dispatchMethod = [handler](Message& message) {
+               CallbackHolder<Type, Args...> callback(handler);
+               Message reply = message.createReplyMessage();
+               reply.packParameters<Type>(callback.dispatch(message));
 
-        return reply;
-    };
+               return reply;
+       };
 
-    std::lock_guard<std::mutex> lock(methodRegistryLock);
+       std::lock_guard<std::mutex> lock(methodRegistryLock);
 
-    if (methodRegistry.count(method)) {
-        throw runtime::Exception("Method handler already registered");
-    }
+       if (methodRegistry.count(method)) {
+               throw runtime::Exception("Method handler already registered");
+       }
 
-    methodRegistry[method] = std::make_shared<MethodContext>(privilege, dispatchMethod);
+       methodRegistry[method] = std::make_shared<MethodContext>(privilege, dispatchMethod);
 }
 
 template <typename... Args>
 void Service::notify(const std::string& name, Args&&... args)
 {
-    std::lock_guard<std::mutex> lock(notificationLock);
+       std::lock_guard<std::mutex> lock(notificationLock);
 
-    Notification& slot = notificationRegistry.at(name);
-    slot.notify(name, std::forward<Args>(args)...);
+       Notification& slot = notificationRegistry.at(name);
+       slot.notify(name, std::forward<Args>(args)...);
 }
 
 } // namespace rmi
index 9a67556..3df11ce 100644 (file)
@@ -37,293 +37,292 @@ const int MAX_BACKLOG_SIZE = 100;
 
 void setCloseOnExec(int fd)
 {
-    if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
+       if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
 }
 
 Credentials getCredentials(int fd)
 {
-    socklen_t length = 256;
-    char buf[256];
-    struct ucred cred;
-    socklen_t credsz = sizeof(cred);
-    if (::getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &credsz)) {
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
-
-    if (::getsockopt(fd, SOL_SOCKET, SO_PEERSEC, buf, &length)) {
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
-
-    return {cred.pid, cred.uid, cred.gid, buf};
+       socklen_t length = 256;
+       char buf[256];
+       struct ucred cred;
+       socklen_t credsz = sizeof(cred);
+       if (::getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &credsz)) {
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
+
+       if (::getsockopt(fd, SOL_SOCKET, SO_PEERSEC, buf, &length)) {
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
+
+       return {cred.pid, cred.uid, cred.gid, buf};
 }
 
 } // namespace
 
 Socket::Socket(int fd, bool autoclose) :
-    socketFd(fd),
-    autoClose(autoclose)
+       socketFd(fd), autoClose(autoclose)
 {
 }
 
 Socket::Socket(Socket&& socket) noexcept :
-    socketFd(socket.socketFd),
-    autoClose(socket.autoClose)
+       socketFd(socket.socketFd),
+       autoClose(socket.autoClose)
 {
-    socket.socketFd = -1;
+       socket.socketFd = -1;
 }
 
 Socket::~Socket() noexcept
 {
-    if ((socketFd != -1) && (autoClose)) {
-        ::close(socketFd);
-    }
+       if ((socketFd != -1) && (autoClose)) {
+               ::close(socketFd);
+       }
 }
 
 Socket Socket::accept()
 {
-    int sockfd = ::accept(socketFd, nullptr, nullptr);
-    if (sockfd == -1) {
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
+       int sockfd = ::accept(socketFd, nullptr, nullptr);
+       if (sockfd == -1) {
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
 
-    setCloseOnExec(sockfd);
+       setCloseOnExec(sockfd);
 
-    return Socket(sockfd);
+       return Socket(sockfd);
 }
 
 int Socket::getFd() const
 {
-    return socketFd;
+       return socketFd;
 }
 
 Credentials Socket::getPeerCredentials() const
 {
-    return getCredentials(socketFd);
+       return getCredentials(socketFd);
 }
 
 void Socket::read(void *buffer, const size_t size) const
 {
-    size_t total = 0;
-
-    while (total < size) {
-        int bytes = ::read(socketFd, reinterpret_cast<char*>(buffer) + total, size - total);
-        if (bytes >= 0) {
-            total += bytes;
-        } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
-            continue;
-        } else {
-            throw SocketException(runtime::GetSystemErrorMessage());
-        }
-    }
+       size_t total = 0;
+
+       while (total < size) {
+               int bytes = ::read(socketFd, reinterpret_cast<char*>(buffer) + total, size - total);
+               if (bytes >= 0) {
+                       total += bytes;
+               } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
+                       continue;
+               } else {
+                       throw SocketException(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 void Socket::write(const void *buffer, const size_t size) const
 {
-    size_t written = 0;
-
-    while (written < size) {
-        int bytes = ::write(socketFd, reinterpret_cast<const char*>(buffer) + written, size - written);
-        if (bytes >= 0) {
-            written += bytes;
-        } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
-            continue;
-        } else {
-            throw SocketException(runtime::GetSystemErrorMessage());
-        }
-    }
+       size_t written = 0;
+
+       while (written < size) {
+               int bytes = ::write(socketFd, reinterpret_cast<const char*>(buffer) + written, size - written);
+               if (bytes >= 0) {
+                       written += bytes;
+               } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
+                       continue;
+               } else {
+                       throw SocketException(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 void Socket::sendFileDescriptors(const int* fds, const size_t nr) const
 {
-    if (nr == 0) return;
-
-    int buf;
-    struct iovec iov = {
-        .iov_base = &buf,
-        .iov_len = sizeof(char)
-    };
-
-    char buffer[CMSG_SPACE(sizeof(int) * nr)];
-    ::memset(buffer, 0, sizeof(buffer));
-
-    struct msghdr msgh;
-    ::memset(&msgh, 0, sizeof(msgh));
-
-    msgh.msg_iov = &iov;
-    msgh.msg_iovlen = 1;
-    msgh.msg_control = buffer;
-    msgh.msg_controllen = sizeof(buffer);
-
-    struct cmsghdr *cmhp;
-    cmhp = CMSG_FIRSTHDR(&msgh);
-    cmhp->cmsg_level = SOL_SOCKET;
-    cmhp->cmsg_type = SCM_RIGHTS;
-    cmhp->cmsg_len = CMSG_LEN(sizeof(int) * nr);
-
-    ::memcpy(CMSG_DATA(cmhp), fds, sizeof(int) * nr);
-
-    int written = 0;
-    while (written < 1) {
-        ssize_t ret = ::sendmsg(socketFd, &msgh, MSG_NOSIGNAL);
-        if (ret >= 0) {
-            written += ret;
-        } else if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) {
-            throw SocketException(runtime::GetSystemErrorMessage());
-        }
-    }
+       if (nr == 0) return;
+
+       int buf;
+       struct iovec iov = {
+               .iov_base = &buf,
+               .iov_len = sizeof(char)
+       };
+
+       char buffer[CMSG_SPACE(sizeof(int) * nr)];
+       ::memset(buffer, 0, sizeof(buffer));
+
+       struct msghdr msgh;
+       ::memset(&msgh, 0, sizeof(msgh));
+
+       msgh.msg_iov = &iov;
+       msgh.msg_iovlen = 1;
+       msgh.msg_control = buffer;
+       msgh.msg_controllen = sizeof(buffer);
+
+       struct cmsghdr *cmhp;
+       cmhp = CMSG_FIRSTHDR(&msgh);
+       cmhp->cmsg_level = SOL_SOCKET;
+       cmhp->cmsg_type = SCM_RIGHTS;
+       cmhp->cmsg_len = CMSG_LEN(sizeof(int) * nr);
+
+       ::memcpy(CMSG_DATA(cmhp), fds, sizeof(int) * nr);
+
+       int written = 0;
+       while (written < 1) {
+               ssize_t ret = ::sendmsg(socketFd, &msgh, MSG_NOSIGNAL);
+               if (ret >= 0) {
+                       written += ret;
+               } else if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) {
+                       throw SocketException(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 void Socket::receiveFileDescriptors(int* fds, const size_t nr) const
 {
-    if (nr == 0) return;
-
-    char buf = '!';
-    struct iovec iov = {
-        .iov_base = &buf,
-        .iov_len = sizeof(char)
-    };
-
-    char buffer[CMSG_SPACE(sizeof(int) * nr) + CMSG_SPACE(sizeof(struct ucred))];
-    ::memset(buffer, 0, sizeof(buffer));
-
-    struct msghdr msgh;
-    ::memset(&msgh, 0, sizeof(msgh));
-
-    msgh.msg_iov = &iov;
-    msgh.msg_iovlen = 1;
-    msgh.msg_control = buffer;
-    msgh.msg_controllen = sizeof(buffer);
-
-    ssize_t bytes = 0;
-    while (bytes < 1) {
-        ssize_t ret = ::recvmsg(socketFd, &msgh, MSG_WAITALL);
-        if (ret >= 0) {
-            bytes += ret;
-        } else {
-            if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) {
-                throw SocketException(runtime::GetSystemErrorMessage());
-            }
-        }
-    }
-
-    int i = 0;
-    for (struct cmsghdr *cmhp = CMSG_FIRSTHDR(&msgh); cmhp != NULL; cmhp = CMSG_NXTHDR(&msgh, cmhp)) {
-        if ((cmhp->cmsg_level == SOL_SOCKET) && (cmhp->cmsg_type == SCM_RIGHTS)) {
-            if (cmhp->cmsg_len != CMSG_LEN(sizeof(int) * nr)) {
-                std::cout << "Invalid File Descriptor Table" << std::endl;
-            }
-
-            fds[i++] = *(reinterpret_cast<int*>(CMSG_DATA(cmhp)));
-        }
-    }
+       if (nr == 0) return;
+
+       char buf = '!';
+       struct iovec iov = {
+               .iov_base = &buf,
+               .iov_len = sizeof(char)
+       };
+
+       char buffer[CMSG_SPACE(sizeof(int) * nr) + CMSG_SPACE(sizeof(struct ucred))];
+       ::memset(buffer, 0, sizeof(buffer));
+
+       struct msghdr msgh;
+       ::memset(&msgh, 0, sizeof(msgh));
+
+       msgh.msg_iov = &iov;
+       msgh.msg_iovlen = 1;
+       msgh.msg_control = buffer;
+       msgh.msg_controllen = sizeof(buffer);
+
+       ssize_t bytes = 0;
+       while (bytes < 1) {
+               ssize_t ret = ::recvmsg(socketFd, &msgh, MSG_WAITALL);
+               if (ret >= 0) {
+                       bytes += ret;
+               } else {
+                       if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) {
+                               throw SocketException(runtime::GetSystemErrorMessage());
+                       }
+               }
+       }
+
+       int i = 0;
+       for (struct cmsghdr *cmhp = CMSG_FIRSTHDR(&msgh); cmhp != NULL; cmhp = CMSG_NXTHDR(&msgh, cmhp)) {
+               if ((cmhp->cmsg_level == SOL_SOCKET) && (cmhp->cmsg_type == SCM_RIGHTS)) {
+                       if (cmhp->cmsg_len != CMSG_LEN(sizeof(int) * nr)) {
+                               std::cout << "Invalid File Descriptor Table" << std::endl;
+                       }
+
+                       fds[i++] = *(reinterpret_cast<int*>(CMSG_DATA(cmhp)));
+               }
+       }
 }
 
 #ifdef USE_SYSTEMD_SOCKET_ACTIVATION
 int Socket::createSystemdSocket(const std::string& path)
 {
-    int n = ::sd_listen_fds(-1);
-    if (n < 0) {
-        throw SocketException("sd_listen_fds faield");
-    }
-
-    for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; ++fd) {
-        if (::sd_is_socket_unix(fd, SOCK_STREAM, 1, path.c_str(), 0) > 0) {
-            setCloseOnExec(fd);
-            return fd;
-        }
-    }
-
-    return -1;
+       int n = ::sd_listen_fds(-1);
+       if (n < 0) {
+               throw SocketException("sd_listen_fds faield");
+       }
+
+       for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; ++fd) {
+               if (::sd_is_socket_unix(fd, SOCK_STREAM, 1, path.c_str(), 0) > 0) {
+                       setCloseOnExec(fd);
+                       return fd;
+               }
+       }
+
+       return -1;
 }
 #endif
 
 int Socket::createRegularSocket(const std::string& path)
 {
-    if (path.size() >= sizeof(sockaddr_un::sun_path)) {
-        throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG));
-    }
-
-    int sockfd = ::socket(AF_UNIX, SOCK_STREAM, 0);
-    if (sockfd == -1) {
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
-
-    setCloseOnExec(sockfd);
-
-    ::sockaddr_un addr;
-    addr.sun_family = AF_UNIX;
-    ::strncpy(addr.sun_path, path.c_str(), sizeof(sockaddr_un::sun_path));
-
-    if (addr.sun_path[0] == '@') {
-        addr.sun_path[0] = '\0';
-    } else {
-        unlink(path.c_str());
-    }
-
-    if (::bind(sockfd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_un)) == -1) {
-        ::close(sockfd);
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
-
-    int optval = 1;
-    if (::setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof(optval)) == -1) {
-        ::close(sockfd);
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
-
-    if (::listen(sockfd, MAX_BACKLOG_SIZE) == -1) {
-        ::close(sockfd);
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
-
-    return sockfd;
+       if (path.size() >= sizeof(sockaddr_un::sun_path)) {
+               throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG));
+       }
+
+       int sockfd = ::socket(AF_UNIX, SOCK_STREAM, 0);
+       if (sockfd == -1) {
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
+
+       setCloseOnExec(sockfd);
+
+       ::sockaddr_un addr;
+       addr.sun_family = AF_UNIX;
+       ::strncpy(addr.sun_path, path.c_str(), sizeof(sockaddr_un::sun_path));
+
+       if (addr.sun_path[0] == '@') {
+               addr.sun_path[0] = '\0';
+       } else {
+               unlink(path.c_str());
+       }
+
+       if (::bind(sockfd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_un)) == -1) {
+               ::close(sockfd);
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
+
+       int optval = 1;
+       if (::setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof(optval)) == -1) {
+               ::close(sockfd);
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
+
+       if (::listen(sockfd, MAX_BACKLOG_SIZE) == -1) {
+               ::close(sockfd);
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
+
+       return sockfd;
 }
 
 Socket Socket::create(const std::string& path)
 {
-    int fd;
+       int fd;
 
 #ifdef USE_SYSTEMD_SOCKET_ACTIVATION
-    fd = createSystemdSocket(path);
-    if (fd == -1) {
-        fd = createRegularSocket(path);
-    }
+       fd = createSystemdSocket(path);
+       if (fd == -1) {
+               fd = createRegularSocket(path);
+       }
 #else
-    fd = createRegularSocket(path);
+       fd = createRegularSocket(path);
 #endif
 
-    return Socket(fd);
+       return Socket(fd);
 }
 
 Socket Socket::connect(const std::string& path)
 {
-    if (path.size() >= sizeof(sockaddr_un::sun_path)) {
-        throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG));
-    }
+       if (path.size() >= sizeof(sockaddr_un::sun_path)) {
+               throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG));
+       }
 
-    int fd = ::socket(AF_UNIX, SOCK_STREAM, 0);
-    if (fd == -1) {
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
+       int fd = ::socket(AF_UNIX, SOCK_STREAM, 0);
+       if (fd == -1) {
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
 
-    setCloseOnExec(fd);
+       setCloseOnExec(fd);
 
-    sockaddr_un addr;
-    addr.sun_family = AF_UNIX;
-    ::strncpy(addr.sun_path, path.c_str(), sizeof(sockaddr_un::sun_path));
+       sockaddr_un addr;
+       addr.sun_family = AF_UNIX;
+       ::strncpy(addr.sun_path, path.c_str(), sizeof(sockaddr_un::sun_path));
 
-    if (addr.sun_path[0] == '@') {
-        addr.sun_path[0] = '\0';
-    }
+       if (addr.sun_path[0] == '@') {
+               addr.sun_path[0] = '\0';
+       }
 
-    if (::connect(fd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_un)) == -1) {
-        ::close(fd);
-        throw SocketException(runtime::GetSystemErrorMessage());
-    }
+       if (::connect(fd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_un)) == -1) {
+               ::close(fd);
+               throw SocketException(runtime::GetSystemErrorMessage());
+       }
 
-    return Socket(fd);
+       return Socket(fd);
 }
 
 } // namespace Ipc
index 19a8c6f..09a61bf 100644 (file)
@@ -23,49 +23,49 @@ namespace rmi {
 
 class SocketException: public runtime::Exception {
 public:
-    SocketException(const std::string& msg) : runtime::Exception(msg) {}
+       SocketException(const std::string& msg) : runtime::Exception(msg) {}
 };
 
 struct Credentials {
-    pid_t pid;
-    uid_t uid;
-    gid_t gid;
-    std::string security;
+       pid_t pid;
+       uid_t uid;
+       gid_t gid;
+       std::string security;
 };
 
 class Socket {
 public:
-    explicit Socket(int socketFd = -1, bool autoclose = true);
-    Socket(Socket&& socket) noexcept;
-    ~Socket() noexcept;
+       explicit Socket(int socketFd = -1, bool autoclose = true);
+       Socket(Socket&& socket) noexcept;
+       ~Socket() noexcept;
 
-    Socket(const Socket&) = delete;
-    Socket& operator=(const Socket&) = delete;
-    Socket& operator=(Socket&) = delete;
+       Socket(const Socket&) = delete;
+       Socket& operator=(const Socket&) = delete;
+       Socket& operator=(Socket&) = delete;
 
-    Socket accept();
-    int getFd() const;
-    Credentials getPeerCredentials() const;
+       Socket accept();
+       int getFd() const;
+       Credentials getPeerCredentials() const;
 
-    void write(const void* buffer, const size_t size) const;
-    void read(void* buffer, const size_t size) const;
+       void write(const void* buffer, const size_t size) const;
+       void read(void* buffer, const size_t size) const;
 
-    void sendFileDescriptors(const int* fds, const size_t nr) const;
-    void receiveFileDescriptors(int* fds, const size_t nr) const;
+       void sendFileDescriptors(const int* fds, const size_t nr) const;
+       void receiveFileDescriptors(int* fds, const size_t nr) const;
 
-    static Socket create(const std::string& path);
-    static Socket connect(const std::string& path);
+       static Socket create(const std::string& path);
+       static Socket connect(const std::string& path);
 
 private:
-    static int createRegularSocket(const std::string& path);
+       static int createRegularSocket(const std::string& path);
 
 #ifdef USE_SYSTEMD_SOCKET_ACTIVATION
-    static int createSystemdSocket(const std::string& path);
+       static int createSystemdSocket(const std::string& path);
 #endif
 
 private:
-    int socketFd;
-    bool autoClose;
+       int socketFd;
+       bool autoClose;
 };
 
 } // namespace rmi
index 21aaae9..f98dd31 100644 (file)
@@ -27,115 +27,121 @@ namespace runtime {
 
 template<typename T>
 struct SerializableArgument {
-    SerializableArgument(const T& arg) : value(arg) {}
+       SerializableArgument(const T& arg) :
+               value(arg)
+       {
+       }
 
-    const T& value;
-    REFLECTABLE(value)
+       const T& value;
+       REFLECTABLE(value)
 };
 
 template<typename T>
 struct DeserializableArgument {
-    DeserializableArgument(T& arg) : value(arg) {}
+       DeserializableArgument(T& arg) :
+               value(arg)
+       {
+       }
 
-    T& value;
-    REFLECTABLE(value)
+       T& value;
+       REFLECTABLE(value)
 };
 
 template<class StorageType>
 class Serializer {
 public:
-    Serializer(StorageType& source) :
-        storage(source)
-    {
-    }
+       Serializer(StorageType& source) :
+               storage(source)
+       {
+       }
 
-    template<typename DataType>
-    void visit(const std::string&, const DataType& value)
-    {
-        visitInternal(value);
-    }
+       template<typename DataType>
+       void visit(const std::string&, const DataType& value)
+       {
+               visitInternal(value);
+       }
 
 private:
-    void visitInternal(const std::string& value)
-    {
-        visitInternal(value.size());
-        storage.write(value.c_str(), value.size());
-    }
-
-    template<typename DataType, typename std::enable_if<std::is_arithmetic<DataType>::value, int>::type = 0>
-    void visitInternal(const DataType& value)
-    {
-        storage.write(&value, sizeof(DataType));
-    }
-
-    template<typename DataType, typename std::enable_if<::IsReflectable<DataType>::value, int>::type = 0>
-    void visitInternal(DataType& value)
-    {
-        value.accept(*this);
-    }
-
-    template<typename DataType>
-    void visitInternal(const std::vector<DataType>& values)
-    {
-        visitInternal(values.size());
-        for (const DataType& value : values) {
-            visitInternal(value);
-        }
-    }
+       void visitInternal(const std::string& value)
+       {
+               visitInternal(value.size());
+               storage.write(value.c_str(), value.size());
+       }
+
+       template<typename DataType, typename std::enable_if<std::is_arithmetic<DataType>::value, int>::type = 0>
+       void visitInternal(const DataType& value)
+       {
+               storage.write(&value, sizeof(DataType));
+       }
+
+       template<typename DataType, typename std::enable_if<::IsReflectable<DataType>::value, int>::type = 0>
+       void visitInternal(DataType& value)
+       {
+               value.accept(*this);
+       }
+
+       template<typename DataType>
+       void visitInternal(const std::vector<DataType>& values)
+       {
+               visitInternal(values.size());
+               for (const DataType& value : values) {
+                       visitInternal(value);
+               }
+       }
 
 private:
-    StorageType& storage;
+       StorageType& storage;
 };
 
 template<class StorageType>
 class Deserializer {
 public:
-    Deserializer(StorageType& source) :
-        storage(source)
-    {
-    }
+       Deserializer(StorageType& source) :
+               storage(source)
+       {
+       }
 
-    template<typename DataType>
-    void visit(const std::string&, DataType& value)
-    {
-        visitInternal(value);
-    }
+       template<typename DataType>
+       void visit(const std::string&, DataType& value)
+       {
+               visitInternal(value);
+       }
 
 private:
-    void visitInternal(std::string& value)
-    {
-        size_t size;
-        visitInternal(size);
-        value.resize(size);
-        storage.read(&value.front(), size);
-    }
-
-    template<typename DataType, typename std::enable_if<std::is_arithmetic<DataType>::value, int>::type = 0>
-    void visitInternal(DataType& value)
-    {
-        storage.read(&value, sizeof(DataType));
-    }
-
-    template<typename T, typename std::enable_if<::IsReflectable<T>::value, int>::type = 0>
-    void visitInternal(T& value)
-    {
-        value.accept(*this);
-    }
-
-    template<typename DataType>
-    void visitInternal(std::vector<DataType>& values)
-    {
-        size_t size;
-        visitInternal(size);
-        values.resize(size);
-
-        for (DataType& value : values) {
-            visitInternal(value);
-        }
-    }
+       void visitInternal(std::string& value)
+       {
+               size_t size;
+               visitInternal(size);
+               value.resize(size);
+               storage.read(&value.front(), size);
+       }
+
+       template<typename DataType, typename std::enable_if<std::is_arithmetic<DataType>::value, int>::type = 0>
+       void visitInternal(DataType& value)
+       {
+               storage.read(&value, sizeof(DataType));
+       }
+
+       template<typename T, typename std::enable_if<::IsReflectable<T>::value, int>::type = 0>
+       void visitInternal(T& value)
+       {
+               value.accept(*this);
+       }
+
+       template<typename DataType>
+       void visitInternal(std::vector<DataType>& values)
+       {
+               size_t size;
+               visitInternal(size);
+               values.resize(size);
+
+               for (DataType& value : values) {
+                       visitInternal(value);
+               }
+       }
 
 private:
-    StorageType& storage;
+       StorageType& storage;
 };
 
 } // namespace runtime
index 20f0a15..bd1e496 100644 (file)
 namespace runtime {
 
 ThreadPool::ThreadPool(size_t threads)
-    : stop(false)
+       : stop(false)
 {
-    for (size_t i = 0; i < threads; i++) {
-       workers.emplace_back([this] {
-            while (true) {
-                std::function<void()> task;
+       for (size_t i = 0; i < threads; i++) {
+          workers.emplace_back([this] {
+                       while (true) {
+                               std::function<void()> task;
 
-                __BEGIN_CRITICAL__
-                condition.wait(lock, [this]{ return stop || !tasks.empty();});
-                if (stop && tasks.empty()) {
-                    return;
-                }
+                               __BEGIN_CRITICAL__
+                               condition.wait(lock, [this]{ return stop || !tasks.empty();});
+                               if (stop && tasks.empty()) {
+                                       return;
+                               }
 
-                task = std::move(tasks.front());
-                tasks.pop_front();
-                __END_CRITICAL__
+                               task = std::move(tasks.front());
+                               tasks.pop_front();
+                               __END_CRITICAL__
 
-                task();
-            }
-        });
-    }
+                               task();
+                       }
+               });
+       }
 }
 
 ThreadPool::~ThreadPool()
 {
-    __BEGIN_CRITICAL__
-    stop = true;
-    __END_CRITICAL__
+       __BEGIN_CRITICAL__
+       stop = true;
+       __END_CRITICAL__
 
-    condition.notify_all();
+       condition.notify_all();
 
-    for (std::thread &worker: workers) {
-        if (worker.joinable()) {
-            worker.join();
-        }
-    }
+       for (std::thread &worker: workers) {
+               if (worker.joinable()) {
+                       worker.join();
+               }
+       }
 }
 
 void ThreadPool::submit(std::function<void()>&& task)
 {
-    __BEGIN_CRITICAL__
-    if (!stop) {
-        tasks.push_back(std::move(task));
-    }
-    __END_CRITICAL__
+       __BEGIN_CRITICAL__
+       if (!stop) {
+               tasks.push_back(std::move(task));
+       }
+       __END_CRITICAL__
 
-    condition.notify_one();
+       condition.notify_one();
 }
 
 } // namespace runtime
index 4677f61..e00e4cf 100644 (file)
@@ -28,21 +28,20 @@ namespace runtime {
 
 class ThreadPool {
 public:
-    ThreadPool(size_t threads);
-    ~ThreadPool();
+       ThreadPool(size_t threads);
+       ~ThreadPool();
 
-    void submit(std::function<void()>&& task);
+       void submit(std::function<void()>&& task);
 
 private:
-    std::vector<std::thread> workers;
-    std::deque<std::function<void()>> tasks;
+       std::vector<std::thread> workers;
+       std::deque<std::function<void()>> tasks;
 
-    std::mutex queueMutex;
-    std::condition_variable condition;
-    bool stop;
+       std::mutex queueMutex;
+       std::condition_variable condition;
+       bool stop;
 };
 
 } // namespace runtime
 
 #endif //__RUNTIME_THREAD_POOL_H__
-
index 364558a..f83fd2f 100644 (file)
 namespace xml {
 
 Document::Document(const std::string& root, const std::string& version) :
-    implementation(xmlNewDoc((const xmlChar*)version.c_str()))
+       implementation(xmlNewDoc((const xmlChar*)version.c_str()))
 {
-    if (implementation == nullptr) {
-        throw runtime::Exception("Failed to create document");
-    }
+       if (implementation == nullptr) {
+               throw runtime::Exception("Failed to create document");
+       }
 
-    implementation->_private = this;
+       implementation->_private = this;
 
-    xmlNode* rootPtr = xmlNewNode(NULL, xmlStrdup((const xmlChar*)root.c_str()));
-    xmlDocSetRootElement(implementation, rootPtr);
+       xmlNode* rootPtr = xmlNewNode(NULL, xmlStrdup((const xmlChar*)root.c_str()));
+       xmlDocSetRootElement(implementation, rootPtr);
 
-    rootNode = new Node(rootPtr);
+       rootNode = new Node(rootPtr);
 }
 
 Document::Document(xmlDoc* doc)
-    : implementation(doc)
+       : implementation(doc)
 {
-    implementation->_private = this;
+       implementation->_private = this;
 
-    rootNode = new Node(xmlDocGetRootElement(implementation));
+       rootNode = new Node(xmlDocGetRootElement(implementation));
 }
 
 Document::~Document()
 {
-    if (rootNode != nullptr) {
-        delete rootNode;
-    }
+       if (rootNode != nullptr) {
+               delete rootNode;
+       }
 
-    xmlFreeDoc(implementation);
+       xmlFreeDoc(implementation);
 }
 
 Node& Document::getRootNode()
 {
-    if (rootNode == nullptr) {
-        throw runtime::Exception("Empty document");
-    }
+       if (rootNode == nullptr) {
+               throw runtime::Exception("Empty document");
+       }
 
-    return *rootNode;
+       return *rootNode;
 }
 
 Node::NodeList Document::evaluate(const std::string& xpath)
 {
-    auto ctxt = xmlXPathNewContext(implementation);
-    if (ctxt == nullptr) {
-        throw runtime::Exception("Failed to create XPath context for " + xpath);
-    }
+       auto ctxt = xmlXPathNewContext(implementation);
+       if (ctxt == nullptr) {
+               throw runtime::Exception("Failed to create XPath context for " + xpath);
+       }
 
-    auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt);
-    if (result == nullptr) {
-        xmlXPathFreeContext(ctxt);
-        throw runtime::Exception("Invalid XPath: " + xpath);
-    }
+       auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt);
+       if (result == nullptr) {
+               xmlXPathFreeContext(ctxt);
+               throw runtime::Exception("Invalid XPath: " + xpath);
+       }
 
-    if (result ->type != XPATH_NODESET) {
-        xmlXPathFreeObject(result);
-        xmlXPathFreeContext(ctxt);
+       if (result ->type != XPATH_NODESET) {
+               xmlXPathFreeObject(result);
+               xmlXPathFreeContext(ctxt);
 
-        throw runtime::Exception("Only nodeset result types are supported");
-    }
+               throw runtime::Exception("Only nodeset result types are supported");
+       }
 
-    auto nodeset = result->nodesetval;
+       auto nodeset = result->nodesetval;
 
-    Node::NodeList nodes;
-    if ((nodeset == nullptr) || (xmlXPathNodeSetIsEmpty(nodeset))) {
-        xmlXPathFreeContext(ctxt);
-        return nodes;
-    }
+       Node::NodeList nodes;
+       if ((nodeset == nullptr) || (xmlXPathNodeSetIsEmpty(nodeset))) {
+               xmlXPathFreeContext(ctxt);
+               return nodes;
+       }
 
-    const int count = xmlXPathNodeSetGetLength(nodeset);
+       const int count = xmlXPathNodeSetGetLength(nodeset);
 
-    nodes.reserve(count);
-    for (int i = 0; i != count; i++) {
-        auto cnode = xmlXPathNodeSetItem(nodeset, i);
-        if (!cnode) {
-            continue;
-        }
+       nodes.reserve(count);
+       for (int i = 0; i != count; i++) {
+               auto cnode = xmlXPathNodeSetItem(nodeset, i);
+               if (!cnode) {
+                       continue;
+               }
 
-        if (cnode->type == XML_NAMESPACE_DECL) {
-            continue;
-        }
+               if (cnode->type == XML_NAMESPACE_DECL) {
+                       continue;
+               }
 
-        nodes.emplace_back(cnode);
-    }
+               nodes.emplace_back(cnode);
+       }
 
-    xmlXPathFreeObject(result);
-    xmlXPathFreeContext(ctxt);
+       xmlXPathFreeObject(result);
+       xmlXPathFreeContext(ctxt);
 
-    return nodes;
+       return nodes;
 }
 
 void Document::write(const std::string& filename, const std::string& encoding, bool formatted)
 {
-    KeepBlanks keepBlanks(KeepBlanks::Default);
-    xmlIndentTreeOutput = formatted;
-
-    xmlResetLastError();
-
-    const int result = xmlSaveFormatFileEnc(filename.c_str(),
-                                            implementation,
-                                            encoding.c_str(),
-                                            formatted);
-    if (result == 0) {
-        throw runtime::Exception("Failed to write XML document");
-    }
+       KeepBlanks keepBlanks(KeepBlanks::Default);
+       xmlIndentTreeOutput = formatted;
+
+       xmlResetLastError();
+
+       const int result = xmlSaveFormatFileEnc(filename.c_str(),
+                                                                                       implementation,
+                                                                                       encoding.c_str(),
+                                                                                       formatted);
+       if (result == 0) {
+               throw runtime::Exception("Failed to write XML document");
+       }
 }
 
 } // namespace xml
index f63df8d..a5bdc93 100644 (file)
@@ -30,19 +30,19 @@ namespace xml {
 
 class Document {
 public:
-    Document(const std::string& root, const std::string& version = XML_DEFAULT_VERSION);
-    Document(xmlDoc* doc);
+       Document(const std::string& root, const std::string& version = XML_DEFAULT_VERSION);
+       Document(xmlDoc* doc);
 
-    ~Document();
+       ~Document();
 
-    Node& getRootNode();
+       Node& getRootNode();
 
-    Node::NodeList evaluate(const std::string& xpath);
-    void write(const std::string& filename, const std::string& encoding, bool formatted);
+       Node::NodeList evaluate(const std::string& xpath);
+       void write(const std::string& filename, const std::string& encoding, bool formatted);
 
 private:
-    Node* rootNode;
-    xmlDoc* implementation;
+       Node* rootNode;
+       xmlDoc* implementation;
 };
 
 } // namespace xml
index a712838..3c38e0a 100644 (file)
@@ -20,14 +20,14 @@ namespace xml {
 
 KeepBlanks::KeepBlanks(bool value)
 {
-    preservedIndentTreeOutput = xmlIndentTreeOutput;
-    preservedKeepBlanksDefault = xmlKeepBlanksDefault(value ? 1 : 0);
+       preservedIndentTreeOutput = xmlIndentTreeOutput;
+       preservedKeepBlanksDefault = xmlKeepBlanksDefault(value ? 1 : 0);
 }
 
 KeepBlanks::~KeepBlanks()
 {
-    xmlKeepBlanksDefault(preservedKeepBlanksDefault);
-    xmlIndentTreeOutput = preservedIndentTreeOutput;
+       xmlKeepBlanksDefault(preservedKeepBlanksDefault);
+       xmlIndentTreeOutput = preservedIndentTreeOutput;
 }
 
 } // namespace xml
index 4dbbb46..7d5c2f4 100644 (file)
@@ -23,14 +23,14 @@ namespace xml {
 
 class KeepBlanks {
 public:
-    KeepBlanks(bool value);
-    ~KeepBlanks();
+       KeepBlanks(bool value);
+       ~KeepBlanks();
 
-    static const bool Default = true;
+       static const bool Default = true;
 
 private:
-    int preservedKeepBlanksDefault;
-    int preservedIndentTreeOutput;
+       int preservedKeepBlanksDefault;
+       int preservedIndentTreeOutput;
 };
 
 } // namespace xml
index 7899956..0d0c255 100644 (file)
 namespace xml {
 
 Node::Node(xmlNode* node) :
-    implementation(node)
+       implementation(node)
 {
 }
 
 Node::Node(Node&& node) :
-    implementation(node.implementation)
+       implementation(node.implementation)
 {
 }
 
@@ -36,82 +36,82 @@ Node::~Node()
 
 Node::NodeList Node::getChildren() const
 {
-    NodeList nodeList;
+       NodeList nodeList;
 
-    auto child = implementation->xmlChildrenNode;
-    while (child != nullptr) {
-        nodeList.emplace_back(child);
-        child = child->next;
-    }
+       auto child = implementation->xmlChildrenNode;
+       while (child != nullptr) {
+               nodeList.emplace_back(child);
+               child = child->next;
+       }
 
-    return nodeList;
+       return nodeList;
 }
 
 Node Node::addNewChild(const std::string& name)
 {
-    xmlNode* nodePtr = xmlNewNode(NULL, xmlStrdup((const xmlChar*)name.c_str()));
-    if (nodePtr == nullptr) {
-        throw runtime::Exception("Can not create a new node");
-    }
-    xmlAddChild(implementation, nodePtr);
+       xmlNode* nodePtr = xmlNewNode(NULL, xmlStrdup((const xmlChar*)name.c_str()));
+       if (nodePtr == nullptr) {
+               throw runtime::Exception("Can not create a new node");
+       }
+       xmlAddChild(implementation, nodePtr);
 
-    return Node(nodePtr);
+       return Node(nodePtr);
 }
 
 std::string Node::getName() const
 {
-    return implementation->name ? (const char*)implementation->name : "";
+       return implementation->name ? (const char*)implementation->name : "";
 }
 
 void Node::setName(const std::string& name)
 {
-    xmlNodeSetName(implementation, (const xmlChar*)name.c_str());
+       xmlNodeSetName(implementation, (const xmlChar*)name.c_str());
 }
 
 std::string Node::getContent() const
 {
-    xmlChar* content = xmlNodeGetContent(implementation);
-    if (content == NULL) {
-        return "";
-    }
-    std::string ret((const char*)content);
-    xmlFree(content);
-    return ret;
+       xmlChar* content = xmlNodeGetContent(implementation);
+       if (content == NULL) {
+               return "";
+       }
+       std::string ret((const char*)content);
+       xmlFree(content);
+       return ret;
 }
 
 void Node::setContent(const std::string& content)
 {
-    xmlNodeSetContent(implementation, (xmlChar*)content.c_str());
+       xmlNodeSetContent(implementation, (xmlChar*)content.c_str());
 }
 
 std::string Node::getProp(const std::string& name) const
 {
-    if (implementation->type != XML_ELEMENT_NODE) {
-        throw runtime::Exception("This node type does not have properties");
-    }
-
-    xmlChar* prop = xmlGetProp(implementation, (xmlChar*)name.c_str());
-    if (prop) {
-        std::string ret((const char*)prop);
-        xmlFree(prop);
-        return ret;
-    }
-
-    return "";
+       if (implementation->type != XML_ELEMENT_NODE) {
+               throw runtime::Exception("This node type does not have properties");
+       }
+
+       xmlChar* prop = xmlGetProp(implementation, (xmlChar*)name.c_str());
+       if (prop) {
+               std::string ret((const char*)prop);
+               xmlFree(prop);
+               return ret;
+       }
+
+       return "";
 }
 
 void Node::setProp(const std::string& name, const std::string& val)
 {
-    if (implementation->type != XML_ELEMENT_NODE) {
-        throw runtime::Exception("Can not set properties for this node type");
-    }
+       if (implementation->type != XML_ELEMENT_NODE) {
+               throw runtime::Exception("Can not set properties for this node type");
+       }
 
-    xmlSetProp(implementation, (xmlChar*)name.c_str(), (xmlChar*)val.c_str());
+       xmlSetProp(implementation, (xmlChar*)name.c_str(), (xmlChar*)val.c_str());
 }
 
 bool Node::isBlank() const
 {
-    return xmlIsBlankNode(const_cast<xmlNode*>(implementation));
+       return xmlIsBlankNode(const_cast<xmlNode*>(implementation));
 }
 
 } // namespace xml
index f021b8c..755d170 100644 (file)
@@ -29,32 +29,32 @@ namespace xml {
 
 class Node {
 public:
-    typedef std::vector<Node> NodeList;
+       typedef std::vector<Node> NodeList;
 
-    explicit Node(xmlNode* node);
-    Node(Node&&);
-    Node(const Node&) = delete;
+       explicit Node(xmlNode* node);
+       Node(Node&&);
+       Node(const Node&) = delete;
 
-    ~Node();
+       ~Node();
 
-    Node& operator=(const Node&) = delete;
+       Node& operator=(const Node&) = delete;
 
-    NodeList getChildren() const;
-    Node addNewChild(const std::string& name);
+       NodeList getChildren() const;
+       Node addNewChild(const std::string& name);
 
-    std::string getName() const;
-    void setName(const std::string& name);
+       std::string getName() const;
+       void setName(const std::string& name);
 
-    std::string getContent() const;
-    void setContent(const std::string& content);
+       std::string getContent() const;
+       void setContent(const std::string& content);
 
-    std::string getProp(const std::string& name) const;
-    void setProp(const std::string& name, const std::string& val);
+       std::string getProp(const std::string& name) const;
+       void setProp(const std::string& name, const std::string& val);
 
-    bool isBlank() const;
+       bool isBlank() const;
 
 private:
-    xmlNode* implementation;
+       xmlNode* implementation;
 };
 
 } // namespace xml
index 3314a5f..91c8d42 100644 (file)
@@ -27,60 +27,60 @@ namespace xml {
 
 Document* Parser::parseContext(xmlParserCtxt* context, bool validate)
 {
-    if (context == nullptr) {
-        throw runtime::Exception("Could not create parser context");
-    }
+       if (context == nullptr) {
+               throw runtime::Exception("Could not create parser context");
+       }
 
-    KeepBlanks(false);
+       KeepBlanks(false);
 
-    int options = 0;
+       int options = 0;
 
-    if (validate) {
-        options |= XML_PARSE_DTDVALID;
-    } else {
-        options &= ~XML_PARSE_DTDVALID;
-    }
+       if (validate) {
+               options |= XML_PARSE_DTDVALID;
+       } else {
+               options &= ~XML_PARSE_DTDVALID;
+       }
 
-    xmlCtxtUseOptions(context, options);
+       xmlCtxtUseOptions(context, options);
 
-    if (xmlParseDocument(context) < 0) {
-        xmlFreeParserCtxt(context);
-        throw runtime::Exception("Parsing failed");
-    }
+       if (xmlParseDocument(context) < 0) {
+               xmlFreeParserCtxt(context);
+               throw runtime::Exception("Parsing failed");
+       }
 
-    xmlDoc* document = context->myDoc;
+       xmlDoc* document = context->myDoc;
 
-    // We took the ownership on the doc
-    context->myDoc = nullptr;
+       // We took the ownership on the doc
+       context->myDoc = nullptr;
 
-    xmlFreeParserCtxt(context);
+       xmlFreeParserCtxt(context);
 
-    return new Document(document);
+       return new Document(document);
 }
 
 Document* Parser::parseFile(const std::string& filename, bool validate)
 {
-    xmlParserCtxt* context = xmlCreateFileParserCtxt(filename.c_str());
-    if (context == nullptr) {
-        throw runtime::Exception("Could not create parser context");
-    }
+       xmlParserCtxt* context = xmlCreateFileParserCtxt(filename.c_str());
+       if (context == nullptr) {
+               throw runtime::Exception("Could not create parser context");
+       }
 
-    if (context->directory == nullptr) {
-        context->directory = xmlParserGetDirectory(filename.c_str());
-    }
+       if (context->directory == nullptr) {
+               context->directory = xmlParserGetDirectory(filename.c_str());
+       }
 
-    return parseContext(context, validate);
+       return parseContext(context, validate);
 }
 
 Document* Parser::parseString(const std::string& xml, bool validate)
 {
-    xmlParserCtxt* context = xmlCreateMemoryParserCtxt(xml.c_str(), xml.size() + 1);
+       xmlParserCtxt* context = xmlCreateMemoryParserCtxt(xml.c_str(), xml.size() + 1);
 
-    if (context == nullptr) {
-        throw runtime::Exception("Could not create parser context");
-    }
+       if (context == nullptr) {
+               throw runtime::Exception("Could not create parser context");
+       }
 
-    return parseContext(context, validate);
+       return parseContext(context, validate);
 }
 
 } // namespace xml
index 85706f4..87b76dc 100644 (file)
@@ -28,11 +28,11 @@ namespace xml {
 
 class Parser {
 public:
-    static Document* parseFile(const std::string& filename, bool validate = false);
-    static Document* parseString(const std::string& xml, bool validate = false);
+       static Document* parseFile(const std::string& filename, bool validate = false);
+       static Document* parseString(const std::string& xml, bool validate = false);
 
 private:
-    static Document* parseContext(xmlParserCtxt* context, bool validate = false);
+       static Document* parseContext(xmlParserCtxt* context, bool validate = false);
 };
 
 } // namespace xml
index 58aba6d..28c3602 100755 (executable)
@@ -21,23 +21,23 @@ SET(LIB_SOVERSION "0")
 SET(PC_FILE "${PROJECT_NAME}.pc")
 
 SET(FOUNDATION          policy-client.cpp
-                        dpm/client-handle.cpp
+                                               dpm/client-handle.cpp
 )
 
 SET(POLICY              administration.cpp
-                        application.cpp
-                        bluetooth.cpp
-                        location.cpp
-                        restriction.cpp
-                        security.cpp
-                        storage.cpp
-                        wifi.cpp
-                        dpm/administration.cpp
-                        dpm/application.cpp
-                        dpm/bluetooth.cpp
-                        dpm/restriction.cpp
-                        dpm/security.cpp
-                        dpm/wifi.cpp
+                                               application.cpp
+                                               bluetooth.cpp
+                                               location.cpp
+                                               restriction.cpp
+                                               security.cpp
+                                               storage.cpp
+                                               wifi.cpp
+                                               dpm/administration.cpp
+                                               dpm/application.cpp
+                                               dpm/bluetooth.cpp
+                                               dpm/restriction.cpp
+                                               dpm/security.cpp
+                                               dpm/wifi.cpp
 )
 
 SET(CAPI                dpm/device-policy-manager.h
index 5358b65..49ae0e4 100644 (file)
@@ -21,7 +21,7 @@
 namespace DevicePolicyManager {
 
 AdministrationPolicy::AdministrationPolicy(PolicyControlContext& ctx) :
-    context(ctx)
+       context(ctx)
 {
 }
 
@@ -31,20 +31,20 @@ AdministrationPolicy::~AdministrationPolicy()
 
 int AdministrationPolicy::registerPolicyClient(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("AdministrationPolicy::registerPolicyClient", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("AdministrationPolicy::registerPolicyClient", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int AdministrationPolicy::deregisterPolicyClient(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("AdministrationPolicy::deregisterPolicyClient", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("AdministrationPolicy::deregisterPolicyClient", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } // namespace DevicePolicyManager
index ca60333..97581eb 100644 (file)
@@ -21,7 +21,7 @@
 namespace DevicePolicyManager {
 
 ApplicationPolicy::ApplicationPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
 }
 
@@ -31,73 +31,73 @@ ApplicationPolicy::~ApplicationPolicy()
 
 int ApplicationPolicy::installPackage(const std::string& pkgpath)
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::installPackage", pkgpath);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::installPackage", pkgpath);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ApplicationPolicy::uninstallPackage(const std::string& pkgid)
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::uninstallPackage", pkgid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::uninstallPackage", pkgid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ApplicationPolicy::setModeRestriction(int mode)
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::setModeRestriction", mode);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::setModeRestriction", mode);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ApplicationPolicy::unsetModeRestriction(int mode)
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::unsetModeRestriction", mode);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::unsetModeRestriction", mode);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ApplicationPolicy::getModeRestriction()
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::getModeRestriction");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::getModeRestriction");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ApplicationPolicy::addPrivilegeToBlacklist(int type, const std::string& privilege)
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::addPrivilegeToBlacklist", type, privilege);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::addPrivilegeToBlacklist", type, privilege);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ApplicationPolicy::removePrivilegeFromBlacklist(int type, const std::string& privilege)
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::removePrivilegeFromBlacklist", type, privilege);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::removePrivilegeFromBlacklist", type, privilege);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ApplicationPolicy::checkPrivilegeIsBlacklisted(int type, const std::string& privilege)
 {
-    try {
-        return context->methodCall<int>("ApplicationPolicy::checkPrivilegeIsBlacklisted", type, privilege);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ApplicationPolicy::checkPrivilegeIsBlacklisted", type, privilege);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 } // namespace DevicePolicyManager
index 72efe06..b9b6c52 100644 (file)
@@ -20,7 +20,7 @@
 namespace DevicePolicyManager {
 
 BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
 }
 
@@ -31,148 +31,148 @@ BluetoothPolicy::~BluetoothPolicy()
 // for restriction CPIs
 int BluetoothPolicy::setModeChangeState(const bool enable)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::setModeChangeState", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::setModeChangeState", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool BluetoothPolicy::getModeChangeState()
 {
-    try {
-        return context->methodCall<bool>("BluetoothPolicy::getModeChangeState");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("BluetoothPolicy::getModeChangeState");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::setDesktopConnectivityState(const bool enable)
 {
-    try {
-        return context->methodCall<bool>("BluetoothPolicy::setDesktopConnectivityState", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("BluetoothPolicy::setDesktopConnectivityState", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool BluetoothPolicy::getDesktopConnectivityState()
 {
-    try {
-        return context->methodCall<bool>("BluetoothPolicy::getDesktopConnectivityState");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("BluetoothPolicy::getDesktopConnectivityState");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::setTetheringState(bool enable)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::setTetheringState", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::setTetheringState", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool BluetoothPolicy::getTetheringState()
 {
-    try {
-        return context->methodCall<bool>("BluetoothPolicy::getTetheringState");
-    } catch (runtime::Exception &e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("BluetoothPolicy::getTetheringState");
+       } catch (runtime::Exception &e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::setPairingState(const bool enable)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::setPairingState", enable);
-    } catch (runtime::Exception &e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::setPairingState", enable);
+       } catch (runtime::Exception &e) {
+               return -1;
+       }
 }
 
 bool BluetoothPolicy::getPairingState()
 {
-    try {
-        return context->methodCall<bool>("BluetoothPolicy::getPairingState");
-    } catch (runtime::Exception &e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("BluetoothPolicy::getPairingState");
+       } catch (runtime::Exception &e) {
+               return -1;
+       }
 }
 
 
 // for bluetooth CAPIs
 int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::addDeviceToBlacklist", mac);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::addDeviceToBlacklist", mac);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::removeDeviceFromBlacklist(const std::string& mac)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::removeDeviceFromBlacklist", mac);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::removeDeviceFromBlacklist", mac);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::setDeviceRestriction(const bool enable)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::setDeviceRestriction", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::setDeviceRestriction", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool BluetoothPolicy::isDeviceRestricted()
 {
-    try {
-        return context->methodCall<bool>("BluetoothPolicy::isDeviceRestricted");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("BluetoothPolicy::isDeviceRestricted");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::addUuidToBlacklist(const std::string& uuid)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::addUuidToBlacklist", uuid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::addUuidToBlacklist", uuid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::removeUuidFromBlacklist(const std::string& uuid)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::removeUuidFromBlacklist", uuid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::removeUuidFromBlacklist", uuid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int BluetoothPolicy::setUuidRestriction(const bool enable)
 {
-    try {
-        return context->methodCall<int>("BluetoothPolicy::setUuidRestriction", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("BluetoothPolicy::setUuidRestriction", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool BluetoothPolicy::isUuidRestricted()
 {
-    try {
-        return context->methodCall<bool>("BluetoothPolicy::isUuidRestricted");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("BluetoothPolicy::isUuidRestricted");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } // namespace DevicePolicyManager
index 8d9f027..3070ec0 100644 (file)
 #
 
 SET(POLICY      ${POLICY}
-                password.cpp
-                dpm/password.cpp
+                               password.cpp
+                               dpm/password.cpp
 )
 
 SET(CAPI        ${CAPI}
-                dpm/password.h
+                               dpm/password.h
 )
index 248a7bf..6d1b226 100644 (file)
@@ -27,14 +27,14 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_admin_register_client(device_policy_manager_h handle, const char* name)
 {
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
        AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
-    return admin.registerPolicyClient(name);
+       return admin.registerPolicyClient(name);
 }
 
 EXPORT_API int dpm_admin_deregister_client(device_policy_manager_h handle, const char* name)
 {
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
        AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
-    return admin.deregisterPolicyClient(name);
+       return admin.deregisterPolicyClient(name);
 }
index ae12903..4c30cdc 100644 (file)
@@ -24,37 +24,37 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_application_set_mode_restriction(device_policy_manager_h handle, int mode)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext& client = GetDevicePolicyContext(handle);
-    ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
-    return application.setModeRestriction(mode);
+       DevicePolicyContext& client = GetDevicePolicyContext(handle);
+       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       return application.setModeRestriction(mode);
 }
 
 EXPORT_API int dpm_application_unset_mode_restriction(device_policy_manager_h handle, int mode)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext& client = GetDevicePolicyContext(handle);
-    ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
-    return application.unsetModeRestriction(mode);
+       DevicePolicyContext& client = GetDevicePolicyContext(handle);
+       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       return application.unsetModeRestriction(mode);
 }
 
 EXPORT_API int dpm_application_get_mode_restriction(device_policy_manager_h handle, int *mode)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext& client = GetDevicePolicyContext(handle);
-    ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
-    int ret = application.getModeRestriction();
-    if (ret < 0) {
-        return -1;
-    }
-    *mode = ret;
-    return DPM_ERROR_NONE;
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext& client = GetDevicePolicyContext(handle);
+       ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+       int ret = application.getModeRestriction();
+       if (ret < 0) {
+               return -1;
+       }
+       *mode = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_application_add_privilege_to_blacklist(device_policy_manager_h handle, int type, const char* privilege)
index 52fc1d2..09a0e2e 100644 (file)
@@ -39,11 +39,11 @@ extern "C" {
  * @since_tizen 3.0
  */
 typedef enum {
-    DPM_PACKAGE_RESTRICTION_MODE_ALL        = 0x0F, /**< All package restriction mode */
-    DPM_PACKAGE_RESTRICTION_MODE_INSTALL    = 0x01, /**< Package install restriction */
-    DPM_PACKAGE_RESTRICTION_MODE_UNINSTALL  = 0x02, /**< Package uninstall restriction */
-    DPM_PACKAGE_RESTRICTION_MODE_REINSTALL  = 0x04, /**< Package reinstall restriction */
-    DPM_PACKAGE_RESTRICTION_MODE_MOVE       = 0x08  /**< Package move restriction */
+       DPM_PACKAGE_RESTRICTION_MODE_ALL        = 0x0F, /**< All package restriction mode */
+       DPM_PACKAGE_RESTRICTION_MODE_INSTALL    = 0x01, /**< Package install restriction */
+       DPM_PACKAGE_RESTRICTION_MODE_UNINSTALL  = 0x02, /**< Package uninstall restriction */
+       DPM_PACKAGE_RESTRICTION_MODE_REINSTALL  = 0x04, /**< Package reinstall restriction */
+       DPM_PACKAGE_RESTRICTION_MODE_MOVE       = 0x08  /**< Package move restriction */
 } dpm_package_restriction_mode_e;
 
 /**
index d956a71..2c786c3 100644 (file)
@@ -24,86 +24,86 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_bluetooth_add_device_to_blacklist(device_policy_manager_h handle, const char* mac)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.addDeviceToBlacklist(mac);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.addDeviceToBlacklist(mac);
 }
 
 EXPORT_API int dpm_bluetooth_remove_device_from_blacklist(device_policy_manager_h handle, const char* mac)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.removeDeviceFromBlacklist(mac);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.removeDeviceFromBlacklist(mac);
 }
 
 EXPORT_API int dpm_bluetooth_set_device_restriction(device_policy_manager_h handle, int enable)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.setDeviceRestriction(enable);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.setDeviceRestriction(enable);
 }
 
 EXPORT_API int dpm_bluetooth_is_device_restricted(device_policy_manager_h handle, int *state)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    int ret = bluetooth.isDeviceRestricted();
-    if (ret < 0) {
-        return -1;
-    }
-    *state = ret;
-    return DPM_ERROR_NONE;
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       int ret = bluetooth.isDeviceRestricted();
+       if (ret < 0) {
+               return -1;
+       }
+       *state = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_bluetooth_add_uuid_to_blacklist(device_policy_manager_h handle, const char* uuid)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.addUuidToBlacklist(uuid);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.addUuidToBlacklist(uuid);
 }
 
 EXPORT_API int dpm_bluetooth_remove_uuid_from_blacklist(device_policy_manager_h handle, const char* uuid)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.removeUuidFromBlacklist(uuid);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.removeUuidFromBlacklist(uuid);
 }
 
 EXPORT_API int dpm_bluetooth_set_uuid_restriction(device_policy_manager_h handle, int enable)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.setUuidRestriction(enable);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.setUuidRestriction(enable);
 }
 
 EXPORT_API int dpm_bluetooth_is_uuid_restricted(device_policy_manager_h handle, int *state)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    int ret = bluetooth.isUuidRestricted();
-    if (ret < 0) {
-        return -1;
-    }
-    *state = ret;
-    return DPM_ERROR_NONE;
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       int ret = bluetooth.isUuidRestricted();
+       if (ret < 0) {
+               return -1;
+       }
+       *state = ret;
+       return DPM_ERROR_NONE;
 }
index e375e74..678d9e4 100644 (file)
 
 DevicePolicyContext& GetDevicePolicyContext(void* handle)
 {
-    assert(handle);
-    return *reinterpret_cast<DevicePolicyContext*>(handle);
+       assert(handle);
+       return *reinterpret_cast<DevicePolicyContext*>(handle);
 }
 
 dpm_context_h dpm_context_create(void)
 {
-    DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
+       DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
 
-    assert(client);
+       assert(client);
 
-    if (client->connect() < 0) {
-        delete client;
-        return NULL;
-    }
+       if (client->connect() < 0) {
+               delete client;
+               return NULL;
+       }
 
-    return reinterpret_cast<dpm_context_h>(client);
+       return reinterpret_cast<dpm_context_h>(client);
 }
 
 int dpm_context_destroy(dpm_context_h handle)
 {
-    assert(handle);
+       assert(handle);
 
-    delete &GetDevicePolicyContext(handle);
+       delete &GetDevicePolicyContext(handle);
 
-    return 0;
+       return 0;
 }
 
 int dpm_context_add_policy_changed_cb(dpm_context_h handle, const char* name, dpm_policy_changed_cb callback, void* user_data, int* id)
 {
-    assert(handle);
+       assert(handle);
 
-    DevicePolicyContext& client = GetDevicePolicyContext(handle);
-    int ret = client.subscribePolicyChange(name, callback, user_data);
-    if (ret < 0) {
-        return -1;
-    }
+       DevicePolicyContext& client = GetDevicePolicyContext(handle);
+       int ret = client.subscribePolicyChange(name, callback, user_data);
+       if (ret < 0) {
+               return -1;
+       }
 
-    *id = ret;
-    return 0;
+       *id = ret;
+       return 0;
 }
 
 int dpm_context_remove_policy_changed_cb(dpm_context_h handle, int id)
 {
-    assert(handle);
+       assert(handle);
 
-    DevicePolicyContext& client = GetDevicePolicyContext(handle);
-    client.unsubscribePolicyChange(id);
+       DevicePolicyContext& client = GetDevicePolicyContext(handle);
+       client.unsubscribePolicyChange(id);
 
-    return 0;
+       return 0;
 }
 
 int dpm_context_add_signal_cb(dpm_context_h handle, const char* signal, dpm_signal_cb callback, void* user_data, int *id)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext& context = GetDevicePolicyContext(handle);
-    int ret = context.subscribeSignal(signal, callback, user_data);
-    if (ret < 0) {
-        return -1;
-    }
-
-    *id = ret;
-    return 0;
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext& context = GetDevicePolicyContext(handle);
+       int ret = context.subscribeSignal(signal, callback, user_data);
+       if (ret < 0) {
+               return -1;
+       }
+
+       *id = ret;
+       return 0;
 }
 
 int dpm_context_remove_signal_cb(dpm_context_h handle, int callback_id)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback_id >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback_id >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext& context = GetDevicePolicyContext(handle);
-    return context.unsubscribeSignal(callback_id);
+       DevicePolicyContext& context = GetDevicePolicyContext(handle);
+       return context.unsubscribeSignal(callback_id);
 }
 
 EXPORT_API device_policy_manager_h dpm_manager_create(void)
 {
-    DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
+       DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
 
-    assert(client);
+       assert(client);
 
-    if (client->connect() < 0) {
-        delete client;
-        return NULL;
-    }
+       if (client->connect() < 0) {
+               delete client;
+               return NULL;
+       }
 
-    return reinterpret_cast<device_policy_manager_h>(client);
+       return reinterpret_cast<device_policy_manager_h>(client);
 }
 
 EXPORT_API int dpm_manager_destroy(device_policy_manager_h handle)
 {
-    assert(handle);
+       assert(handle);
 
-    delete &GetDevicePolicyContext(handle);
+       delete &GetDevicePolicyContext(handle);
 
-    return 0;
+       return 0;
 }
 
 EXPORT_API int dpm_add_policy_changed_cb(device_policy_manager_h handle,
-                                         const char* name,
-                                         dpm_policy_changed_cb callback,
-                                         void* user_data,
-                                         int* id)
+                                                                                const char* name,
+                                                                                dpm_policy_changed_cb callback,
+                                                                                void* user_data,
+                                                                                int* id)
 {
-    assert(handle);
+       assert(handle);
 
-    DevicePolicyContext& client = GetDevicePolicyContext(handle);
-    int ret = client.subscribePolicyChange(name, callback, user_data);
-    if (ret < 0) {
-        return -1;
-    }
+       DevicePolicyContext& client = GetDevicePolicyContext(handle);
+       int ret = client.subscribePolicyChange(name, callback, user_data);
+       if (ret < 0) {
+               return -1;
+       }
 
-    *id = ret;
-    return 0;
+       *id = ret;
+       return 0;
 }
 
 EXPORT_API int dpm_remove_policy_changed_cb(device_policy_manager_h handle, int id)
 {
-    assert(handle);
+       assert(handle);
 
-    DevicePolicyContext& client = GetDevicePolicyContext(handle);
-    client.unsubscribePolicyChange(id);
+       DevicePolicyContext& client = GetDevicePolicyContext(handle);
+       client.unsubscribePolicyChange(id);
 
-    return 0;
+       return 0;
 }
 
 EXPORT_API int dpm_add_signal_cb(device_policy_manager_h handle, const char* signal,
-                                 dpm_signal_cb callback, void* user_data, int* id)
+                                                                dpm_signal_cb callback, void* user_data, int* id)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext& context = GetDevicePolicyContext(handle);
-    int ret = context.subscribeSignal(signal, callback, user_data);
-    if (ret < 0) {
-        return -1;
-    }
-
-    *id = ret;
-    return 0;
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(signal, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext& context = GetDevicePolicyContext(handle);
+       int ret = context.subscribeSignal(signal, callback, user_data);
+       if (ret < 0) {
+               return -1;
+       }
+
+       *id = ret;
+       return 0;
 }
 
 EXPORT_API int dpm_remove_signal_cb(device_policy_manager_h handle, int id)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext& context = GetDevicePolicyContext(handle);
-    return context.unsubscribeSignal(id);
+       DevicePolicyContext& context = GetDevicePolicyContext(handle);
+       return context.unsubscribeSignal(id);
 }
index b11a93e..ed6885d 100644 (file)
@@ -125,10 +125,10 @@ DPM_API int dpm_context_destroy(dpm_context_h handle);
  * @see         dpm_context_remove_policy_changed_cb()
  */
 DPM_API int dpm_context_add_policy_changed_cb(dpm_context_h handle,
-                                              const char* name,
-                                              dpm_policy_changed_cb callback,
-                                              void* user_data,
-                                              int* id);
+                                                                                         const char* name,
+                                                                                         dpm_policy_changed_cb callback,
+                                                                                         void* user_data,
+                                                                                         int* id);
 /**
  * @brief       Removes policy change callback from the device policy
  *              manager.
@@ -147,7 +147,7 @@ DPM_API int dpm_context_add_policy_changed_cb(dpm_context_h handle,
  * @see         dpm_context_add_policy_changed_cb()
  */
 DPM_API int dpm_context_remove_policy_changed_cb(dpm_context_h handle,
-                                                 int id);
+                                                                                                int id);
 /**
  * @brief       Called when a zone raises a signal.
  * @since_tizen 3.0
@@ -180,8 +180,8 @@ typedef void(*dpm_signal_cb)(const char* name, const char* object, void *user_da
  * @see         dpm_context_remove_signal_cb()
  */
 DPM_API int dpm_context_add_signal_cb(dpm_context_h context, const char* signal,
-                                      dpm_signal_cb callback, void* user_data,
-                                      int* id);
+                                                                         dpm_signal_cb callback, void* user_data,
+                                                                         int* id);
 
 /**
  * @brief       Removes signal callback.
@@ -207,12 +207,12 @@ DPM_API int dpm_context_remove_signal_cb(dpm_context_h context, int id);
 typedef void* dpm_##_n_##_policy_h;                                                      \
 static inline dpm_##_n_##_policy_h dpm_context_acquire_##_n_##_policy(dpm_context_h handle)       \
 {                                                                                          \
-    return handle;                                                                         \
+       return handle;                                                                         \
 }                                                                                          \
-                                                                                           \
+                                                                                                                                                                                  \
 static inline int dpm_context_release_##_n_##_policy(dpm_context_h context, dpm_##_n_##_policy_h handle) \
 {                                                                                          \
-    return DPM_ERROR_NONE;                                                                 \
+       return DPM_ERROR_NONE;                                                                 \
 }
 
 DEFINE_POLICY_HANDLE(password)
index fd73f67..8e5ebb4 100644 (file)
@@ -18,9 +18,9 @@
 #define __CAPI_DPM_ASSERT_H__
 
 #define RET_ON_FAILURE(cond, ret) \
-        { \
-            if (!(cond)) \
-                return (ret); \
-        }
+{                                 \
+       if (!(cond))                  \
+               return (ret);             \
+}
 
 #endif //! __CAPI_DPM_ASSERT_H__
index ca09d4b..774eb84 100644 (file)
@@ -66,15 +66,15 @@ typedef void* device_policy_manager_h;
  * @since_tizen 3.0
  */
 typedef enum {
-    DPM_ERROR_NONE                 = TIZEN_ERROR_NONE,                 /**< The operation was successful */
-    DPM_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
-    DPM_ERROR_CONNECTION_REFUSED   = TIZEN_ERROR_CONNECTION_REFUSED,   /**< Connection refused */
-    DPM_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,            /**< Time out */
-    DPM_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,    /**< Access privilege is not sufficient */
-    DPM_ERROR_NOT_PERMITTED        = TIZEN_ERROR_NOT_PERMITTED,        /**< Operation not permitted */
-    DPM_ERROR_FILE_EXISTS          = TIZEN_ERROR_FILE_EXISTS,          /**< File exists */
-    DPM_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,        /**< Out of memory */
-    DPM_ERROR_NO_DATA              = TIZEN_ERROR_NO_DATA               /**< No Data */
+       DPM_ERROR_NONE                 = TIZEN_ERROR_NONE,                 /**< The operation was successful */
+       DPM_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
+       DPM_ERROR_CONNECTION_REFUSED   = TIZEN_ERROR_CONNECTION_REFUSED,   /**< Connection refused */
+       DPM_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,            /**< Time out */
+       DPM_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,    /**< Access privilege is not sufficient */
+       DPM_ERROR_NOT_PERMITTED        = TIZEN_ERROR_NOT_PERMITTED,        /**< Operation not permitted */
+       DPM_ERROR_FILE_EXISTS          = TIZEN_ERROR_FILE_EXISTS,          /**< File exists */
+       DPM_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,        /**< Out of memory */
+       DPM_ERROR_NO_DATA              = TIZEN_ERROR_NO_DATA               /**< No Data */
 } dpm_error_type_e;
 
 /**
@@ -133,10 +133,10 @@ int dpm_manager_destroy(device_policy_manager_h handle);
  * @see         dpm_remove_policy_changed_cb()
  */
 int dpm_add_policy_changed_cb(device_policy_manager_h handle,
-                              const char* name,
-                              dpm_policy_changed_cb callback,
-                              void* user_data,
-                              int* id);
+                                                         const char* name,
+                                                         dpm_policy_changed_cb callback,
+                                                         void* user_data,
+                                                         int* id);
 /**
  * @brief       Removes policy change callback from the device policy
  *              manager.
@@ -188,7 +188,7 @@ typedef void(*dpm_signal_cb)(const char* name, const char* object, void *user_da
  * @see         dpm_remove_signal_cb()
  */
 int dpm_add_signal_cb(device_policy_manager_h handle, const char* signal,
-                      dpm_signal_cb callback, void* user_data, int* id);
+                                         dpm_signal_cb callback, void* user_data, int* id);
 
 /**
  * @brief       Removes signal callback.
index 0a741f7..aaabef0 100755 (executable)
@@ -28,385 +28,385 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_password_set_quality(device_policy_manager_h handle, dpm_password_quality_e quality)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setPasswordPolicyQuality(quality);
+       return password.setPasswordPolicyQuality(quality);
 }
 
 EXPORT_API int dpm_password_get_quality(device_policy_manager_h handle, dpm_password_quality_e *quality)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(quality, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(quality, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getPasswordPolicyQuality();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getPasswordPolicyQuality();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *quality = (dpm_password_quality_e)ret;
+       *quality = (dpm_password_quality_e)ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_minimum_length(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setPasswordPolicyMinimumLength(value);
+       return password.setPasswordPolicyMinimumLength(value);
 }
 
 EXPORT_API int dpm_password_get_minimum_length(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getPasswordPolicyMinimumLength();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getPasswordPolicyMinimumLength();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_min_complex_chars(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setMinPasswordPolicyComplexChars(value);
+       return password.setMinPasswordPolicyComplexChars(value);
 }
 
 EXPORT_API int dpm_password_get_min_complex_chars(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getMinPasswordPolicyComplexChars();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getMinPasswordPolicyComplexChars();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_maximum_failed_attempts_for_wipe(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setMaximumFailedPasswordPolicyForWipe(value);
+       return password.setMaximumFailedPasswordPolicyForWipe(value);
 }
 
 EXPORT_API int dpm_password_get_maximum_failed_attempts_for_wipe(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getMaximumFailedPasswordPolicyForWipe();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getMaximumFailedPasswordPolicyForWipe();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_expires(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setPasswordPolicyExpires(value);
+       return password.setPasswordPolicyExpires(value);
 }
 
 EXPORT_API int dpm_password_get_expires(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getPasswordPolicyExpires();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getPasswordPolicyExpires();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_history(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setPasswordPolicyHistory(value);
+       return password.setPasswordPolicyHistory(value);
 }
 
 EXPORT_API int dpm_password_get_history(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getPasswordPolicyHistory();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getPasswordPolicyHistory();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_pattern(device_policy_manager_h handle, const char *pattern)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setPasswordPolicyPattern(pattern);
+       return password.setPasswordPolicyPattern(pattern);
 }
 
 EXPORT_API int dpm_password_reset(device_policy_manager_h handle, const char *passwd)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(passwd, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(passwd, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.resetPasswordPolicy(passwd);
+       return password.resetPasswordPolicy(passwd);
 }
 
 EXPORT_API int dpm_password_enforce_change(device_policy_manager_h handle)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.enforcePasswordPolicyChange();
+       return password.enforcePasswordPolicyChange();
 }
 
 EXPORT_API int dpm_password_set_max_inactivity_time_device_lock(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setMaxInactivityTimeDeviceLock(value);
+       return password.setMaxInactivityTimeDeviceLock(value);
 }
 
 EXPORT_API int dpm_password_get_max_inactivity_time_device_lock(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getMaxInactivityTimeDeviceLock();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getMaxInactivityTimeDeviceLock();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_status(device_policy_manager_h handle, dpm_password_status_e status)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(status >= DPM_PASSWORD_STATUS_NORMAL &&
-                    status <= DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,
-                    DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(status >= DPM_PASSWORD_STATUS_NORMAL &&
+                                       status <= DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,
+                                       DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setPasswordPolicyStatus(status);
+       return password.setPasswordPolicyStatus(status);
 }
 
 EXPORT_API int dpm_password_delete_pattern(device_policy_manager_h handle)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.deletePasswordPolicyPattern();
+       return password.deletePasswordPolicyPattern();
 }
 
 EXPORT_API int dpm_password_get_pattern(device_policy_manager_h handle, char **pattern)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    *pattern = ::strdup(password.getPasswordPolicyPattern().c_str());
+       *pattern = ::strdup(password.getPasswordPolicyPattern().c_str());
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_maximum_character_occurrences(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setMaximumCharacterOccurrences(value);
+       return password.setMaximumCharacterOccurrences(value);
 }
 
 EXPORT_API int dpm_password_get_maximum_character_occurrences(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getMaximumCharacterOccurrences();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getMaximumCharacterOccurrences();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_maximum_numeric_sequence_length(device_policy_manager_h handle, int value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return password.setMaximumNumericSequenceLength(value);
+       return password.setMaximumNumericSequenceLength(value);
 }
 
 EXPORT_API int dpm_password_get_maximum_numeric_sequence_length(device_policy_manager_h handle, int *value)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    int ret = password.getMaximumNumericSequenceLength();
-    if (ret < 0) {
-        return -1;
-    }
+       int ret = password.getMaximumNumericSequenceLength();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *value = ret;
+       *value = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 typedef runtime::Array<std::string> dpm_password_iterator;
 
 EXPORT_API dpm_password_iterator_h dpm_password_create_iterator(device_policy_manager_h handle)
 {
-    RET_ON_FAILURE(handle, NULL);
+       RET_ON_FAILURE(handle, NULL);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    return reinterpret_cast<dpm_password_iterator_h>(new dpm_password_iterator(password.getForbiddenStrings()));
+       return reinterpret_cast<dpm_password_iterator_h>(new dpm_password_iterator(password.getForbiddenStrings()));
 }
 
 EXPORT_API int dpm_password_iterator_next(dpm_password_iterator_h iter, const char **result)
 {
-    RET_ON_FAILURE(iter, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(result, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(iter, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(result, DPM_ERROR_INVALID_PARAMETER);
 
-    dpm_password_iterator *it = reinterpret_cast<dpm_password_iterator *>(iter);
+       dpm_password_iterator *it = reinterpret_cast<dpm_password_iterator *>(iter);
 
-    if (it->isEnd())
-        *result = NULL;
-    else
-        *result = it->next()->c_str();
+       if (it->isEnd())
+               *result = NULL;
+       else
+               *result = it->next()->c_str();
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_destroy_iterator(dpm_password_iterator_h iter)
 {
-    RET_ON_FAILURE(iter, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(iter, DPM_ERROR_INVALID_PARAMETER);
 
-    delete reinterpret_cast<dpm_password_iterator *>(iter);
+       delete reinterpret_cast<dpm_password_iterator *>(iter);
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_password_set_forbidden_strings(device_policy_manager_h handle, const char *strings[], int length)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(strings, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(length >= 0, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(strings, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(length >= 0, DPM_ERROR_INVALID_PARAMETER);
 
-    int iter;
-    std::vector<std::string> forbiddenStrings;
+       int iter;
+       std::vector<std::string> forbiddenStrings;
 
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(strings, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(strings, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
 
-    for (iter = 0; iter < length; iter++)
-        forbiddenStrings.push_back(strings[iter]);
+       for (iter = 0; iter < length; iter++)
+               forbiddenStrings.push_back(strings[iter]);
 
-    return password.setForbiddenStrings(forbiddenStrings);
+       return password.setForbiddenStrings(forbiddenStrings);
 }
index 3d1e287..665f26f 100644 (file)
@@ -39,20 +39,20 @@ extern "C" {
  * @since_tizen 3.0
  */
 typedef enum {
-    DPM_PASSWORD_QUALITY_UNSPECIFIED     = 0x00,    /**< No requirements for password. */
-    DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD = 0x01,    /**< EAS(Exchange ActiveSync) requirement for simple password */
-    DPM_PASSWORD_QUALITY_SOMETHING       = 0x10,    /**< Some kind password is required, but doesn't care what it is */
-    DPM_PASSWORD_QUALITY_NUMERIC         = 0x20,    /**< Containing at least numeric characters */
-    DPM_PASSWORD_QUALITY_ALPHABETIC      = 0x40,    /**< Containing at least alphabetic (or other symbol) characters */
-    DPM_PASSWORD_QUALITY_ALPHANUMERIC    = 0x80,    /**< Containing at least numeric and alphabetic characters */
+       DPM_PASSWORD_QUALITY_UNSPECIFIED     = 0x00,    /**< No requirements for password. */
+       DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD = 0x01,    /**< EAS(Exchange ActiveSync) requirement for simple password */
+       DPM_PASSWORD_QUALITY_SOMETHING       = 0x10,    /**< Some kind password is required, but doesn't care what it is */
+       DPM_PASSWORD_QUALITY_NUMERIC         = 0x20,    /**< Containing at least numeric characters */
+       DPM_PASSWORD_QUALITY_ALPHABETIC      = 0x40,    /**< Containing at least alphabetic (or other symbol) characters */
+       DPM_PASSWORD_QUALITY_ALPHANUMERIC    = 0x80,    /**< Containing at least numeric and alphabetic characters */
 } dpm_password_quality_e;
 
 typedef enum {
-    DPM_PASSWORD_STATUS_NORMAL,                 /**< Password normal status */
-    DPM_PASSWORD_STATUS_CHANGED,                /**< Password successfully changed */
-    DPM_PASSWORD_STATUS_NOT_CHANGED,            /**< Password not changed */
-    DPM_PASSWORD_STATUS_CHANGE_REQUIRED ,       /**< Password change required */
-    DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,  /**< Password Max Attempts Exceeded*/
+       DPM_PASSWORD_STATUS_NORMAL,                 /**< Password normal status */
+       DPM_PASSWORD_STATUS_CHANGED,                /**< Password successfully changed */
+       DPM_PASSWORD_STATUS_NOT_CHANGED,            /**< Password not changed */
+       DPM_PASSWORD_STATUS_CHANGE_REQUIRED ,       /**< Password change required */
+       DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,  /**< Password Max Attempts Exceeded*/
 } dpm_password_status_e;
 
 /**
index aed03cf..74f809c 100644 (file)
@@ -27,327 +27,327 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_restriction_set_camera_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        return restriction.setCameraState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_camera_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        int ret = restriction.getCameraState();
-    if (ret < 0) {
-        return -1;
-    }
+       if (ret < 0) {
+               return -1;
+       }
 
-    *is_allowed = ret;
-    return 0;
+       *is_allowed = ret;
+       return 0;
 }
 
 EXPORT_API int dpm_restriction_set_microphone_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    return restriction.setMicrophoneState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       return restriction.setMicrophoneState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_microphone_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        int ret = restriction.getMicrophoneState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return 0;
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return 0;
 }
 
 EXPORT_API int dpm_restriction_set_location_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
-    return location.setLocationState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+       return location.setLocationState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_location_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
-    int ret = location.getLocationState();
-    if (ret < 0) {
-        return -1;
-    }
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+       int ret = location.getLocationState();
+       if (ret < 0) {
+               return -1;
+       }
 
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_usb_debugging_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        return restriction.setUsbDebuggingState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_usb_debugging_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        int ret = restriction.getUsbDebuggingState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_usb_tethering_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    return restriction.setUsbTetheringState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       return restriction.setUsbTetheringState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_usb_tethering_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    int ret = restriction.getUsbTetheringState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       int ret = restriction.getUsbTetheringState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_external_storage_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    return restriction.setExternalStorageState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       return restriction.setExternalStorageState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_external_storage_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    int ret = restriction.getExternalStorageState();
-    if (ret < 0) {
-        return 0;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       int ret = restriction.getExternalStorageState();
+       if (ret < 0) {
+               return 0;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_clipboard_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    return restriction.setClipboardState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       return restriction.setClipboardState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_clipboard_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        int ret = restriction.getClipboardState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_wifi_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    return wifi.setState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       return wifi.setState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_wifi_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    int ret = wifi.getState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       int ret = wifi.getState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_wifi_hotspot_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    return  wifi.setHotspotState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       return  wifi.setHotspotState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_wifi_hotspot_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    int ret = wifi.getHotspotState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       int ret = wifi.getHotspotState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_bluetooth_tethering_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.setTetheringState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.setTetheringState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_bluetooth_tethering_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    int ret = bluetooth.getTetheringState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       int ret = bluetooth.getTetheringState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_bluetooth_mode_change_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.setModeChangeState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.setModeChangeState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_bluetooth_mode_change_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    int ret = bluetooth.getModeChangeState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       int ret = bluetooth.getModeChangeState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_bluetooth_desktop_connectivity_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.setDesktopConnectivityState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.setDesktopConnectivityState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_bluetooth_desktop_connectivity_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    int ret = bluetooth.getDesktopConnectivityState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       int ret = bluetooth.getDesktopConnectivityState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_bluetooth_pairing_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    return bluetooth.setPairingState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       return bluetooth.setPairingState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_bluetooth_pairing_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
-    int ret = bluetooth.getPairingState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+       int ret = bluetooth.getPairingState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_popimap_email_state(device_policy_manager_h handle, int allow)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        return restriction.setPopImapEmailState(allow);
 }
 
@@ -356,22 +356,22 @@ EXPORT_API int dpm_restriction_get_popimap_email_state(device_policy_manager_h h
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        int ret = restriction.getPopImapEmailState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_messaging_state(device_policy_manager_h handle, int allow)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        return restriction.setMessagingState(allow);
 }
 
@@ -380,36 +380,36 @@ EXPORT_API int dpm_restriction_get_messaging_state(device_policy_manager_h handl
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
        RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
        int ret = restriction.getMessagingState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_restriction_set_browser_state(device_policy_manager_h handle, int allow)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    return restriction.setBrowserState(allow);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       return restriction.setBrowserState(allow);
 }
 
 EXPORT_API int dpm_restriction_get_browser_state(device_policy_manager_h handle, int *is_allowed)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
-    int ret = restriction.getBrowserState();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_allowed = ret;
-    return DPM_ERROR_NONE;
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+       int ret = restriction.getBrowserState();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_allowed = ret;
+       return DPM_ERROR_NONE;
 }
index b20fc3d..5dffa00 100644 (file)
@@ -25,66 +25,66 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_security_lockout_screen(device_policy_manager_h handle)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
        DevicePolicyContext &context = GetDevicePolicyContext(handle);
        SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
-    return security.lockoutScreen();
+       return security.lockoutScreen();
 }
 
 EXPORT_API int dpm_security_set_internal_storage_encryption(device_policy_manager_h handle, int encrypt)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
        DevicePolicyContext &context = GetDevicePolicyContext(handle);
        SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
-    return security.setInternalStorageEncryption(encrypt);
+       return security.setInternalStorageEncryption(encrypt);
 }
 
 EXPORT_API int dpm_security_is_internal_storage_encrypted(device_policy_manager_h handle, int *is_encrypted)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
 
        DevicePolicyContext &context = GetDevicePolicyContext(handle);
        SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
-    int ret = security.isInternalStorageEncrypted();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_encrypted = ret;
-    return DPM_ERROR_NONE;
+       int ret = security.isInternalStorageEncrypted();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_encrypted = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_security_set_external_storage_encryption(device_policy_manager_h handle, int encrypt)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
        DevicePolicyContext &context = GetDevicePolicyContext(handle);
        SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
-    return security.setExternalStorageEncryption(encrypt);
+       return security.setExternalStorageEncryption(encrypt);
 }
 
 EXPORT_API int dpm_security_is_external_storage_encrypted(device_policy_manager_h handle, int *is_encrypted)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
 
        DevicePolicyContext &context = GetDevicePolicyContext(handle);
        SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
-    int ret = security.isExternalStorageEncrypted();
-    if (ret < 0) {
-        return -1;
-    }
-    *is_encrypted = ret;
-    return DPM_ERROR_NONE;
+       int ret = security.isExternalStorageEncrypted();
+       if (ret < 0) {
+               return -1;
+       }
+       *is_encrypted = ret;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_security_wipe_data(device_policy_manager_h handle, dpm_security_wipe_type_e type)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
-    return storage.wipeData(type);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
+       return storage.wipeData(type);
 }
index 9859c36..2f84a4c 100644 (file)
@@ -30,14 +30,14 @@ dpm_storage_policy_h dpm_context_acquire_storage_policy(dpm_context_h handle)
 int dpm_context_release_storage_policy(dpm_storage_policy_h handle)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 int dpm_storage_wipe_data(dpm_storage_policy_h handle, const dpm_wipe_type_e type)
 {
        RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
        return storage.wipeData(type);
 }
index 9008492..2ea4c35 100644 (file)
@@ -38,8 +38,8 @@ extern "C" {
  * @since_tizen 3.0
  */
 typedef enum {
-    WIPE_INTERNAL_STORAGE = (1 << 0), /**< Wipe internal memory. */
-    WIPE_EXTERNAL_STORAGE = (1 << 1)  /**< Wipe external memory. */
+       WIPE_INTERNAL_STORAGE = (1 << 0), /**< Wipe internal memory. */
+       WIPE_EXTERNAL_STORAGE = (1 << 1)  /**< Wipe external memory. */
 } dpm_wipe_type_e;
 
 /**
index d36c534..1952e54 100644 (file)
@@ -24,62 +24,62 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_wifi_set_profile_change_restriction(device_policy_manager_h handle, int enable)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    return wifi.setProfileChangeRestriction(enable);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       return wifi.setProfileChangeRestriction(enable);
 }
 
 EXPORT_API int dpm_wifi_is_profile_change_restricted(device_policy_manager_h handle, int *enable)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    *enable = wifi.isProfileChangeRestricted();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       *enable = wifi.isProfileChangeRestricted();
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_wifi_set_network_access_restriction(device_policy_manager_h handle, int enable)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    return wifi.setNetworkAccessRestriction(enable);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       return wifi.setNetworkAccessRestriction(enable);
 }
 
 EXPORT_API int dpm_wifi_is_network_access_restricted(device_policy_manager_h handle, int *enable)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    *enable = wifi.isNetworkAccessRestricted();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       *enable = wifi.isNetworkAccessRestricted();
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_wifi_add_ssid_to_blocklist(device_policy_manager_h handle, const char* ssid)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    return wifi.addSsidToBlocklist(ssid);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       return wifi.addSsidToBlocklist(ssid);
 }
 
 EXPORT_API int dpm_wifi_remove_ssid_from_blocklist(device_policy_manager_h handle, const char* ssid)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
-    return wifi.removeSsidFromBlocklist(ssid);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+       return wifi.removeSsidFromBlocklist(ssid);
 }
index 6e76ade..dd4dc78 100755 (executable)
@@ -25,55 +25,55 @@ using namespace DevicePolicyManager;
 
 EXPORT_API int dpm_zone_create(device_policy_manager_h handle, const char* name, const char* pkgname)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(pkgname, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(pkgname, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
-    return zone.createZone(name, pkgname);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
+       return zone.createZone(name, pkgname);
 }
 
 EXPORT_API int dpm_zone_destroy(device_policy_manager_h handle, const char* name)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
-    return zone.removeZone(name);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
+       return zone.removeZone(name);
 }
 
 EXPORT_API int dpm_zone_get_state(device_policy_manager_h handle, const char* name, dpm_zone_state_e *state)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
 
-    int result = zone.getZoneState(name);
-    if (result == 0) {
-        return DPM_ERROR_NO_DATA;
-    }
+       int result = zone.getZoneState(name);
+       if (result == 0) {
+               return DPM_ERROR_NO_DATA;
+       }
 
-    *state = (dpm_zone_state_e)result;
-    return DPM_ERROR_NONE;
+       *state = (dpm_zone_state_e)result;
+       return DPM_ERROR_NONE;
 }
 
 EXPORT_API int dpm_zone_foreach_name(device_policy_manager_h handle, dpm_zone_state_e state,
-                                     dpm_zone_foreach_name_cb callback, void* user_data)
+                                                                        dpm_zone_foreach_name_cb callback, void* user_data)
 {
-    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
-    std::vector<std::string> list = zone.getZoneList(state);
-    for (const std::string& name : list) {
-        if (!callback(name.c_str(), user_data))
-            break;
-    }
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
+       std::vector<std::string> list = zone.getZoneList(state);
+       for (const std::string& name : list) {
+               if (!callback(name.c_str(), user_data))
+                       break;
+       }
 
-    return DPM_ERROR_NONE;
+       return DPM_ERROR_NONE;
 }
index 599d674..c67461c 100644 (file)
@@ -92,9 +92,9 @@ int dpm_zone_destroy(device_policy_manager_h handle, const char* name);
  * @since_tizen 3.0
  */
 typedef enum {
-    DPM_ZONE_STATE_LOCKED       = 0x01,  /**< Zone has been defined, but it can not start. */
-    DPM_ZONE_STATE_RUNNING      = 0x02, /**< Zone has been started. */
-    DPM_ZONE_STATE_ALL          = 0xff  /**< This presents all of the state  */
+       DPM_ZONE_STATE_LOCKED       = 0x01,  /**< Zone has been defined, but it can not start. */
+       DPM_ZONE_STATE_RUNNING      = 0x02, /**< Zone has been started. */
+       DPM_ZONE_STATE_ALL          = 0xff  /**< This presents all of the state  */
 } dpm_zone_state_e;
 
 /**
@@ -146,8 +146,8 @@ typedef bool(*dpm_zone_foreach_name_cb)(const char* name, void *user_data);
  * @see         dpm_zone_destroy()
  */
 int dpm_zone_foreach_name(device_policy_manager_h handle,
-                          dpm_zone_state_e state,
-                          dpm_zone_foreach_name_cb callback, void* user_data);
+                                                 dpm_zone_state_e state,
+                                                 dpm_zone_foreach_name_cb callback, void* user_data);
 
 
 /**
index 8d9f027..3070ec0 100644 (file)
 #
 
 SET(POLICY      ${POLICY}
-                password.cpp
-                dpm/password.cpp
+                               password.cpp
+                               dpm/password.cpp
 )
 
 SET(CAPI        ${CAPI}
-                dpm/password.h
+                               dpm/password.h
 )
index b530bea..cca4474 100644 (file)
@@ -19,8 +19,8 @@
 
 namespace DevicePolicyManager {
 
-LocationPolicy::LocationPolicy(PolicyControlContext& ctxt)
-       context(ctxt)
+LocationPolicy::LocationPolicy(PolicyControlContext& ctxt) :
+       context(ctxt)
 {
 }
 
index 38a7a09..45c63ce 100644 (file)
 #
 
 SET(POLICY      ${POLICY}
-                password.cpp
-                zone.cpp
-                dpm/password.cpp
-                dpm/zone.cpp
+                               password.cpp
+                               zone.cpp
+                               dpm/password.cpp
+                               dpm/zone.cpp
 )
 
 SET(CAPI        ${CAPI}
-                dpm/password.h
-                dpm/zone.h
+                               dpm/password.h
+                               dpm/zone.h
 )
index 465094f..4dbc778 100644 (file)
@@ -20,7 +20,7 @@
 namespace DevicePolicyManager {
 
 PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
-    __context(ctxt)
+       __context(ctxt)
 {
 }
 
@@ -30,236 +30,236 @@ PasswordPolicy::~PasswordPolicy()
 
 int PasswordPolicy::setPasswordPolicyQuality(const int quality)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyQuality", quality);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyQuality", quality);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getPasswordPolicyQuality()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyQuality");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyQuality");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setPasswordPolicyMinimumLength(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyMinimumLength", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyMinimumLength", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getPasswordPolicyMinimumLength()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyMinimumLength");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyMinimumLength");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setMinPasswordPolicyComplexChars(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setMinPasswordPolicyComplexChars", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setMinPasswordPolicyComplexChars", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getMinPasswordPolicyComplexChars()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getMinPasswordPolicyComplexChars");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getMinPasswordPolicyComplexChars");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setMaximumFailedPasswordPolicyForWipe(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setMaximumFailedPasswordPolicyForWipe", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setMaximumFailedPasswordPolicyForWipe", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 int PasswordPolicy::getMaximumFailedPasswordPolicyForWipe()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getMaximumFailedPasswordPolicyForWipe");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getMaximumFailedPasswordPolicyForWipe");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setPasswordPolicyExpires(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyExpires", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyExpires", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getPasswordPolicyExpires()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyExpires");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyExpires");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setPasswordPolicyHistory(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyHistory", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyHistory", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getPasswordPolicyHistory()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyHistory");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getPasswordPolicyHistory");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setPasswordPolicyPattern(const std::string& pattern)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyPattern", pattern);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyPattern", pattern);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::resetPasswordPolicy(const std::string& passwd)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::resetPasswordPolicy", passwd);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::resetPasswordPolicy", passwd);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::enforcePasswordPolicyChange()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::enforcePasswordPolicyChange");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::enforcePasswordPolicyChange");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setMaxInactivityTimeDeviceLock(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setMaxInactivityTimeDeviceLock", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setMaxInactivityTimeDeviceLock", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getMaxInactivityTimeDeviceLock()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getMaxInactivityTimeDeviceLock");;
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getMaxInactivityTimeDeviceLock");;
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setPasswordPolicyStatus(const int status)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyStatus", status);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setPasswordPolicyStatus", status);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::deletePasswordPolicyPattern()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::deletePasswordPolicyPattern");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::deletePasswordPolicyPattern");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 std::string PasswordPolicy::getPasswordPolicyPattern()
 {
-    std::string error("Error");
-    try {
-        return __context->methodCall<std::string>("PasswordPolicy::getPasswordPolicyPattern");
-    } catch (runtime::Exception& e) {
-        return error;
-    }
+       std::string error("Error");
+       try {
+               return __context->methodCall<std::string>("PasswordPolicy::getPasswordPolicyPattern");
+       } catch (runtime::Exception& e) {
+               return error;
+       }
 }
 
 int PasswordPolicy::setMaximumCharacterOccurrences(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setMaximumCharacterOccurrences", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setMaximumCharacterOccurrences", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getMaximumCharacterOccurrences()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getMaximumCharacterOccurrences");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getMaximumCharacterOccurrences");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setMaximumNumericSequenceLength(const int value)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setMaximumNumericSequenceLength", value);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setMaximumNumericSequenceLength", value);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::getMaximumNumericSequenceLength()
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::getMaximumNumericSequenceLength");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::getMaximumNumericSequenceLength");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int PasswordPolicy::setForbiddenStrings(const std::vector<std::string>& forbiddenStrings)
 {
-    try {
-        return __context->methodCall<int>("PasswordPolicy::setForbiddenStrings", forbiddenStrings);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return __context->methodCall<int>("PasswordPolicy::setForbiddenStrings", forbiddenStrings);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 std::vector<std::string> PasswordPolicy::getForbiddenStrings()
 {
-    std::vector<std::string> error;
-    try {
-        return __context->methodCall<std::vector<std::string>>("PasswordPolicy::getForbiddenStrings");
-    } catch (runtime::Exception& e) {
-        return error;
-    }
+       std::vector<std::string> error;
+       try {
+               return __context->methodCall<std::vector<std::string>>("PasswordPolicy::getForbiddenStrings");
+       } catch (runtime::Exception& e) {
+               return error;
+       }
 }
 } /* namespace DevicePolicyManager */
index 8a61037..c1a8eb3 100644 (file)
@@ -32,71 +32,71 @@ DevicePolicyContext::DevicePolicyContext() noexcept
 
 DevicePolicyContext::~DevicePolicyContext() noexcept
 {
-    disconnect();
+       disconnect();
 }
 
 int DevicePolicyContext::connect(const std::string& address) noexcept
 {
-    try {
-        client.reset(new rmi::Client(address));
-        client->connect();
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
-
-    return 0;
+       try {
+               client.reset(new rmi::Client(address));
+               client->connect();
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
+
+       return 0;
 }
 
 int DevicePolicyContext::connect() noexcept
 {
-    return connect(POLICY_MANAGER_ADDRESS);
+       return connect(POLICY_MANAGER_ADDRESS);
 }
 
 void DevicePolicyContext::disconnect() noexcept
 {
-    client.reset();
+       client.reset();
 }
 
 int DevicePolicyContext::subscribePolicyChange(const std::string& name,
-                                              const PolicyChangeListener& listener,
-                                              void* data)
+                                                                                         const PolicyChangeListener& listener,
+                                                                                         void* data)
 {
-    auto listenerDispatcher = [listener, data](const std::string& policy, std::string &state) {
-        listener(policy.c_str(), state.c_str(), data);
-    };
-
-    try {
-        return client->subscribe<std::string, std::string>(SUBSCRIBER_REGISTER,
-                                                           name, listenerDispatcher);
-    } catch (runtime::Exception& e) {
-        std::cout << e.what() << std::endl;
-        return -1;
-    }
+       auto listenerDispatcher = [listener, data](const std::string& policy, std::string &state) {
+               listener(policy.c_str(), state.c_str(), data);
+       };
+
+       try {
+               return client->subscribe<std::string, std::string>(SUBSCRIBER_REGISTER,
+                                                                                                                  name, listenerDispatcher);
+       } catch (runtime::Exception& e) {
+               std::cout << e.what() << std::endl;
+               return -1;
+       }
 }
 
 int DevicePolicyContext::unsubscribePolicyChange(int subscriberId)
 {
-    return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
+       return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
 }
 
 int DevicePolicyContext::subscribeSignal(const std::string& name,
-                                        const SignalListener& listener,
-                                        void* data)
+                                                                               const SignalListener& listener,
+                                                                               void* data)
 {
-    auto listenerDispatcher = [listener, data](std::string &name, std::string &from, std::string &object) {
-        listener(from.c_str(), object.c_str(), data);
-    };
-
-    try {
-        return client->subscribe<std::string, std::string, std::string>(SUBSCRIBER_REGISTER,
-                                                                        name, listenerDispatcher);
-    } catch (runtime::Exception& e) {
-        std::cout << e.what() << std::endl;
-        return -1;
-    }
+       auto listenerDispatcher = [listener, data](std::string &name, std::string &from, std::string &object) {
+               listener(from.c_str(), object.c_str(), data);
+       };
+
+       try {
+               return client->subscribe<std::string, std::string, std::string>(SUBSCRIBER_REGISTER,
+                                                                                                                                               name, listenerDispatcher);
+       } catch (runtime::Exception& e) {
+               std::cout << e.what() << std::endl;
+               return -1;
+       }
 }
 
 int DevicePolicyContext::unsubscribeSignal(int subscriberId)
 {
-    return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
+       return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
 }
index 7786ff1..c1ac082 100644 (file)
@@ -28,34 +28,34 @@ typedef std::function<void(const char*, const char*, void*)> SignalListener;
 
 class DevicePolicyContext {
 public:
-    typedef std::unique_ptr<rmi::Client> PolicyControlContext;
+       typedef std::unique_ptr<rmi::Client> PolicyControlContext;
 
-    DevicePolicyContext() noexcept;
-    ~DevicePolicyContext() noexcept;
+       DevicePolicyContext() noexcept;
+       ~DevicePolicyContext() noexcept;
 
-    int connect() noexcept;
-    int connect(const std::string& address) noexcept;
-    void disconnect() noexcept;
+       int connect() noexcept;
+       int connect(const std::string& address) noexcept;
+       void disconnect() noexcept;
 
-    int subscribePolicyChange(const std::string& name, const PolicyChangeListener& listener, void* data);
-    int unsubscribePolicyChange(int subscriberId);
+       int subscribePolicyChange(const std::string& name, const PolicyChangeListener& listener, void* data);
+       int unsubscribePolicyChange(int subscriberId);
 
-    int subscribeSignal(const std::string& name, const SignalListener& listener, void* data);
-    int unsubscribeSignal(int subscriberId);
+       int subscribeSignal(const std::string& name, const SignalListener& listener, void* data);
+       int unsubscribeSignal(int subscriberId);
 
-    template<typename Policy, typename... Args>
-    Policy createPolicyInterface(Args&&... args) noexcept
-    {
-        return Policy(getPolicyControlContext(), std::forward<Args>(args)...);
-    }
+       template<typename Policy, typename... Args>
+       Policy createPolicyInterface(Args&&... args) noexcept
+       {
+               return Policy(getPolicyControlContext(), std::forward<Args>(args)...);
+       }
 
 private:
-    PolicyControlContext& getPolicyControlContext()
-    {
-        return client;
-    }
+       PolicyControlContext& getPolicyControlContext()
+       {
+               return client;
+       }
 
-    PolicyControlContext client;
+       PolicyControlContext client;
 };
 
 DevicePolicyContext& GetDevicePolicyContext(void* handle);
index 9f3d859..b52580a 100644 (file)
@@ -20,8 +20,8 @@
 namespace DevicePolicyManager
 {
 
-RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt)
-       context(ctxt)
+RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) :
+       context(ctxt)
 {
 }
 
@@ -138,56 +138,56 @@ int RestrictionPolicy::getExternalStorageState()
 
 int RestrictionPolicy::setPopImapEmailState(int enable)
 {
-    try {
-        return context->methodCall<int>("RestrictionPolicy::setPopImapEmailState", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       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;
-    }
+       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;
-    }
+       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;
-    }
+       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;
-    }
+       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;
-    }
+       try {
+               return context->methodCall<int>("RestrictionPolicy::getBrowserState");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } //namespace DevicePolicyManager
index ea25c5b..733821a 100644 (file)
@@ -20,7 +20,7 @@
 namespace DevicePolicyManager {
 
 SecurityPolicy::SecurityPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
 }
 
@@ -30,47 +30,47 @@ SecurityPolicy::~SecurityPolicy()
 
 int SecurityPolicy::lockoutScreen()
 {
-    try {
-        return context->methodCall<int>("SecurityPolicy::lockoutScreen");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("SecurityPolicy::lockoutScreen");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int SecurityPolicy::setInternalStorageEncryption(bool encrypt)
 {
-    try {
-        return context->methodCall<int>("SecurityPolicy::setInternalStorageEncryption", encrypt);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("SecurityPolicy::setInternalStorageEncryption", encrypt);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int SecurityPolicy::isInternalStorageEncrypted()
 {
-    try {
-        return context->methodCall<int>("SecurityPolicy::isInternalStorageEncrypted");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("SecurityPolicy::isInternalStorageEncrypted");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int SecurityPolicy::setExternalStorageEncryption(bool encrypt)
 {
-    try {
-        return context->methodCall<int>("SecurityPolicy::setExternalStorageEncryption", encrypt);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("SecurityPolicy::setExternalStorageEncryption", encrypt);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int SecurityPolicy::isExternalStorageEncrypted()
 {
-    try {
-        return context->methodCall<int>("SecurityPolicy::isExternalStorageEncrypted");
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("SecurityPolicy::isExternalStorageEncrypted");
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } // namespace DevicePolicyManager
index 3325de3..d49769f 100644 (file)
@@ -21,7 +21,7 @@
 namespace DevicePolicyManager {
 
 StoragePolicy::StoragePolicy(PolicyControlContext& ctx) :
-    context(ctx)
+       context(ctx)
 {
 }
 
index 8d9f027..3070ec0 100644 (file)
 #
 
 SET(POLICY      ${POLICY}
-                password.cpp
-                dpm/password.cpp
+                               password.cpp
+                               dpm/password.cpp
 )
 
 SET(CAPI        ${CAPI}
-                dpm/password.h
+                               dpm/password.h
 )
index 7a274e9..bc3c6c0 100644 (file)
@@ -20,7 +20,7 @@
 namespace DevicePolicyManager {
 
 WifiPolicy::WifiPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
 }
 
@@ -30,92 +30,92 @@ WifiPolicy::~WifiPolicy()
 
 int WifiPolicy::setState(bool enable)
 {
-    try {
-        return context->methodCall<int>("WifiPolicy::setState", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("WifiPolicy::setState", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool WifiPolicy::getState()
 {
-    try {
-        return context->methodCall<bool>("WifiPolicy::getState");
-    } catch (runtime::Exception &e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("WifiPolicy::getState");
+       } catch (runtime::Exception &e) {
+               return -1;
+       }
 }
 
 int WifiPolicy::setHotspotState(bool enable)
 {
-    try {
-        return context->methodCall<int>("WifiPolicy::setHotspotState", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("WifiPolicy::setHotspotState", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool WifiPolicy::getHotspotState()
 {
-    try {
-        return context->methodCall<bool>("WifiPolicy::getHotspotState");
-    } catch (runtime::Exception &e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("WifiPolicy::getHotspotState");
+       } catch (runtime::Exception &e) {
+               return -1;
+       }
 }
 
 int WifiPolicy::setProfileChangeRestriction(bool enable)
 {
-    try {
-        return context->methodCall<int>("WifiPolicy::setProfileChangeRestriction", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("WifiPolicy::setProfileChangeRestriction", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool WifiPolicy::isProfileChangeRestricted(void)
 {
-    try {
-        return context->methodCall<bool>("WifiPolicy::isProfileChangeRestricted");
-    } catch (runtime::Exception &e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("WifiPolicy::isProfileChangeRestricted");
+       } catch (runtime::Exception &e) {
+               return -1;
+       }
 }
 
 int WifiPolicy::setNetworkAccessRestriction(bool enable)
 {
-    try {
-        return context->methodCall<int>("WifiPolicy::setNetworkAccessRestriction", enable);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("WifiPolicy::setNetworkAccessRestriction", enable);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool WifiPolicy::isNetworkAccessRestricted(void)
 {
-    try {
-        return context->methodCall<bool>("WifiPolicy::isNetworkAccessRestricted");
-    } catch (runtime::Exception &e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("WifiPolicy::isNetworkAccessRestricted");
+       } catch (runtime::Exception &e) {
+               return -1;
+       }
 }
 
 int WifiPolicy::addSsidToBlocklist(const std::string& ssid)
 {
-    try {
-        return context->methodCall<int>("WifiPolicy::addSsidToBlocklist", ssid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("WifiPolicy::addSsidToBlocklist", ssid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int WifiPolicy::removeSsidFromBlocklist(const std::string& ssid)
 {
-    try {
-        return context->methodCall<int>("WifiPolicy::removeSsidFromBlocklist", ssid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("WifiPolicy::removeSsidFromBlocklist", ssid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } // namespace DevicePolicyManager
index 0306f87..4f0768b 100644 (file)
@@ -18,8 +18,8 @@
 
 namespace DevicePolicyManager {
 
-ZonePolicy::ZonePolicy(PolicyControlContext& ctx)
-    : context(ctx)
+ZonePolicy::ZonePolicy(PolicyControlContext& ctx) :
+       context(ctx)
 {
 }
 
@@ -29,57 +29,57 @@ ZonePolicy::~ZonePolicy()
 
 int ZonePolicy::createZone(const std::string& name, const std::string& setupWizAppid)
 {
-    try {
-        return context->methodCall<int>("ZonePolicy::createZone", name, setupWizAppid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZonePolicy::createZone", name, setupWizAppid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZonePolicy::removeZone(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZonePolicy::removeZone", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZonePolicy::removeZone", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZonePolicy::lockZone(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZonePolicy::lockZone", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZonePolicy::lockZone", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZonePolicy::unlockZone(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZonePolicy::unlockZone", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZonePolicy::unlockZone", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZonePolicy::getZoneState(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZonePolicy::getZoneState", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZonePolicy::getZoneState", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 std::vector<std::string> ZonePolicy::getZoneList(int state)
 {
-    std::vector<std::string> empty;
-    try {
-        return context->methodCall<std::vector<std::string>>("ZonePolicy::getZoneList", state);
-    } catch (runtime::Exception& e) {
-        return empty;
-    }
+       std::vector<std::string> empty;
+       try {
+               return context->methodCall<std::vector<std::string>>("ZonePolicy::getZoneList", state);
+       } catch (runtime::Exception& e) {
+               return empty;
+       }
 }
 
 } // namespace DevicePolicyManager
index 69e547f..6015f5f 100644 (file)
@@ -26,14 +26,14 @@ namespace DevicePolicyManager {
 
 class AdministrationPolicy {
 public:
-    AdministrationPolicy(PolicyControlContext& ctxt);
-    ~AdministrationPolicy();
+       AdministrationPolicy(PolicyControlContext& ctxt);
+       ~AdministrationPolicy();
 
-    int registerPolicyClient(const std::string& name);
-    int deregisterPolicyClient(const std::string& name);
+       int registerPolicyClient(const std::string& name);
+       int deregisterPolicyClient(const std::string& name);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index 17e4b38..ca50eac 100644 (file)
@@ -24,35 +24,35 @@ namespace DevicePolicyManager {
 
 class ApplicationPolicy {
 public:
-    enum PrivilegeType {
-        PRIVILEGE_TYPE_WRT = 0,
-        PRIVILEGE_TYPE_CORE = 1
-    };
+       enum PrivilegeType {
+               PRIVILEGE_TYPE_WRT = 0,
+               PRIVILEGE_TYPE_CORE = 1
+       };
 
-    enum RestrictionMode {
-        RESTRICTION_MODE_ALL = 0x0F,
-        RESTRICTION_MODE_INSTALL = 0x01,
-        RESTRICTION_MODE_UNINSTALL = 0x02,
-        RESTRICTION_MODE_REINSTALL = 0x04,
-        RESTRICTION_MODE_MVOE = 0x08
-    };
+       enum RestrictionMode {
+               RESTRICTION_MODE_ALL = 0x0F,
+               RESTRICTION_MODE_INSTALL = 0x01,
+               RESTRICTION_MODE_UNINSTALL = 0x02,
+               RESTRICTION_MODE_REINSTALL = 0x04,
+               RESTRICTION_MODE_MVOE = 0x08
+       };
 
-    ApplicationPolicy(PolicyControlContext& ctxt);
-    ~ApplicationPolicy();
+       ApplicationPolicy(PolicyControlContext& ctxt);
+       ~ApplicationPolicy();
 
-    int installPackage(const std::string& pkgpath);
-    int uninstallPackage(const std::string& pkgid);
+       int installPackage(const std::string& pkgpath);
+       int uninstallPackage(const std::string& pkgid);
 
-    int setModeRestriction(int mode);
-    int unsetModeRestriction(int mode);
-    int getModeRestriction();
+       int setModeRestriction(int mode);
+       int unsetModeRestriction(int mode);
+       int getModeRestriction();
 
-    int addPrivilegeToBlacklist(int type, const std::string& privilege);
-    int removePrivilegeFromBlacklist(int type, const std::string& privilege);
-    int checkPrivilegeIsBlacklisted(int type, const std::string& privilege);
+       int addPrivilegeToBlacklist(int type, const std::string& privilege);
+       int removePrivilegeFromBlacklist(int type, const std::string& privilege);
+       int checkPrivilegeIsBlacklisted(int type, const std::string& privilege);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index ad61845..3d5a23f 100644 (file)
@@ -29,32 +29,32 @@ namespace DevicePolicyManager {
 
 class BluetoothPolicy {
 public:
-    BluetoothPolicy(PolicyControlContext& ctxt);
-    ~BluetoothPolicy();
-
-    // for restriction CPIs
-    int setModeChangeState(const bool enable);
-    bool getModeChangeState();
-    int setDesktopConnectivityState(const bool enable);
-    bool getDesktopConnectivityState();
-    int setTetheringState(bool enable);
-    bool getTetheringState();
-    int setPairingState(const bool enable);
-    bool getPairingState();
-
-    // for bluetooth CAPIs
-    int addDeviceToBlacklist(const std::string& mac);
-    int removeDeviceFromBlacklist(const std::string& mac);
-    int setDeviceRestriction(const bool enable);
-    bool isDeviceRestricted();
-
-    int addUuidToBlacklist(const std::string& uuid);
-    int removeUuidFromBlacklist(const std::string& uuid);
-    int setUuidRestriction(const bool enable);
-    bool isUuidRestricted();
+       BluetoothPolicy(PolicyControlContext& ctxt);
+       ~BluetoothPolicy();
+
+       // for restriction CPIs
+       int setModeChangeState(const bool enable);
+       bool getModeChangeState();
+       int setDesktopConnectivityState(const bool enable);
+       bool getDesktopConnectivityState();
+       int setTetheringState(bool enable);
+       bool getTetheringState();
+       int setPairingState(const bool enable);
+       bool getPairingState();
+
+       // for bluetooth CAPIs
+       int addDeviceToBlacklist(const std::string& mac);
+       int removeDeviceFromBlacklist(const std::string& mac);
+       int setDeviceRestriction(const bool enable);
+       bool isDeviceRestricted();
+
+       int addUuidToBlacklist(const std::string& uuid);
+       int removeUuidFromBlacklist(const std::string& uuid);
+       int setUuidRestriction(const bool enable);
+       bool isUuidRestricted();
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index 34bc1b9..cd1a59b 100644 (file)
@@ -24,57 +24,57 @@ namespace DevicePolicyManager {
 
 class PasswordPolicy {
 public:
-    typedef enum {
-        DPM_PASSWORD_QUALITY_UNSPECIFIED     = 0x00,    /**< No requirements for password. */
-        DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD = 0x01,    /**< Eas requirement for simple password */
-        DPM_PASSWORD_QUALITY_SOMETHING       = 0x10,    /**< Some kind password is required, but doesn't care what it is */
-        DPM_PASSWORD_QUALITY_NUMERIC         = 0x20,    /**< Containing at least numeric characters */
-        DPM_PASSWORD_QUALITY_ALPHABETIC      = 0x40,    /**< Containing at least alphabetic (or other symbol) characters */
-        DPM_PASSWORD_QUALITY_ALPHANUMERIC    = 0x80,    /**< Containing at least numeric and alphabetic characters */
-    } PasswordPolicyQuality;
+       typedef enum {
+               DPM_PASSWORD_QUALITY_UNSPECIFIED     = 0x00,    /**< No requirements for password. */
+               DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD = 0x01,    /**< Eas requirement for simple password */
+               DPM_PASSWORD_QUALITY_SOMETHING       = 0x10,    /**< Some kind password is required, but doesn't care what it is */
+               DPM_PASSWORD_QUALITY_NUMERIC         = 0x20,    /**< Containing at least numeric characters */
+               DPM_PASSWORD_QUALITY_ALPHABETIC      = 0x40,    /**< Containing at least alphabetic (or other symbol) characters */
+               DPM_PASSWORD_QUALITY_ALPHANUMERIC    = 0x80,    /**< Containing at least numeric and alphabetic characters */
+       } PasswordPolicyQuality;
 
-    typedef enum {
-        DPM_PASSWORD_STATUS_NORMAL,                           /**< Password normal status */
-        DPM_PASSWORD_STATUS_CHANGED,                 /**< Password successfully changed */
-        DPM_PASSWORD_STATUS_NOT_CHANGED,             /**< Password not changed */
-        DPM_PASSWORD_STATUS_CHANGE_REQUIRED ,        /**< Password change required */
-        DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,  /**< Password Max Attempts Exceeded*/
-        DPM_PASSWORD_STATUS_MAX
-    } PasswordPolicyStatus;
+       typedef enum {
+               DPM_PASSWORD_STATUS_NORMAL,                           /**< Password normal status */
+               DPM_PASSWORD_STATUS_CHANGED,                 /**< Password successfully changed */
+               DPM_PASSWORD_STATUS_NOT_CHANGED,             /**< Password not changed */
+               DPM_PASSWORD_STATUS_CHANGE_REQUIRED ,        /**< Password change required */
+               DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED,  /**< Password Max Attempts Exceeded*/
+               DPM_PASSWORD_STATUS_MAX
+       } PasswordPolicyStatus;
 
-    PasswordPolicy(PolicyControlContext &ctxt);
-    ~PasswordPolicy();
+       PasswordPolicy(PolicyControlContext &ctxt);
+       ~PasswordPolicy();
 
-    int setPasswordPolicyQuality(const int quality);
-    int getPasswordPolicyQuality();
-    int setPasswordPolicyMinimumLength(const int value);
-    int getPasswordPolicyMinimumLength();
-    int setMinPasswordPolicyComplexChars(const int value);
-    int getMinPasswordPolicyComplexChars();
-    int setMaximumFailedPasswordPolicyForWipe(const int value);
-    int getMaximumFailedPasswordPolicyForWipe();
-    int setPasswordPolicyExpires(const int value);
-    int getPasswordPolicyExpires();
-    int setPasswordPolicyHistory(const int value);
-    int getPasswordPolicyHistory();
-    int setPasswordPolicyPattern(const std::string &pattern);
-    int resetPasswordPolicy(const std::string &passwd);
-    int enforcePasswordPolicyChange();
-    int setMaxInactivityTimeDeviceLock(const int value);
-    int getMaxInactivityTimeDeviceLock();
-    std::string getPasswordPolicyPolicy();
-    int setPasswordPolicyStatus(const int status);
-    int deletePasswordPolicyPattern();
-    std::string getPasswordPolicyPattern();
-    int setMaximumCharacterOccurrences(const int value);
-    int getMaximumCharacterOccurrences();
-    int setMaximumNumericSequenceLength(const int value);
-    int getMaximumNumericSequenceLength();
-    int setForbiddenStrings(const std::vector<std::string> &forbiddenPasswds);
-    std::vector<std::string> getForbiddenStrings();
+       int setPasswordPolicyQuality(const int quality);
+       int getPasswordPolicyQuality();
+       int setPasswordPolicyMinimumLength(const int value);
+       int getPasswordPolicyMinimumLength();
+       int setMinPasswordPolicyComplexChars(const int value);
+       int getMinPasswordPolicyComplexChars();
+       int setMaximumFailedPasswordPolicyForWipe(const int value);
+       int getMaximumFailedPasswordPolicyForWipe();
+       int setPasswordPolicyExpires(const int value);
+       int getPasswordPolicyExpires();
+       int setPasswordPolicyHistory(const int value);
+       int getPasswordPolicyHistory();
+       int setPasswordPolicyPattern(const std::string &pattern);
+       int resetPasswordPolicy(const std::string &passwd);
+       int enforcePasswordPolicyChange();
+       int setMaxInactivityTimeDeviceLock(const int value);
+       int getMaxInactivityTimeDeviceLock();
+       std::string getPasswordPolicyPolicy();
+       int setPasswordPolicyStatus(const int status);
+       int deletePasswordPolicyPattern();
+       std::string getPasswordPolicyPattern();
+       int setMaximumCharacterOccurrences(const int value);
+       int getMaximumCharacterOccurrences();
+       int setMaximumNumericSequenceLength(const int value);
+       int getMaximumNumericSequenceLength();
+       int setForbiddenStrings(const std::vector<std::string> &forbiddenPasswds);
+       std::vector<std::string> getForbiddenStrings();
 
 private:
-    PolicyControlContext &__context;
+       PolicyControlContext &__context;
 };
 
 } /* namespace DevicePolicyManager */
index 5fd485f..ffb6a31 100644 (file)
@@ -47,14 +47,14 @@ public:
        int setExternalStorageState(int enable);
        int getExternalStorageState();
 
-    int setPopImapEmailState(int enable);
-    int getPopImapEmailState();
+       int setPopImapEmailState(int enable);
+       int getPopImapEmailState();
 
-    int setMessagingState(int enable);
-    int getMessagingState();
+       int setMessagingState(int enable);
+       int getMessagingState();
 
-    int setBrowserState(int enable);
-    int getBrowserState();
+       int setBrowserState(int enable);
+       int getBrowserState();
 
 private:
        PolicyControlContext& context;
index 38f2fef..6a539f1 100644 (file)
@@ -29,18 +29,18 @@ namespace DevicePolicyManager {
 
 class SecurityPolicy {
 public:
-    SecurityPolicy(PolicyControlContext& ctxt);
-    ~SecurityPolicy();
+       SecurityPolicy(PolicyControlContext& ctxt);
+       ~SecurityPolicy();
 
-    int lockoutScreen();
-    int wipeData(const int id);
-    int setInternalStorageEncryption(bool encrypt);
-    int isInternalStorageEncrypted();
-    int setExternalStorageEncryption(bool encrypt);
-    int isExternalStorageEncrypted();
+       int lockoutScreen();
+       int wipeData(const int id);
+       int setInternalStorageEncryption(bool encrypt);
+       int isInternalStorageEncrypted();
+       int setExternalStorageEncryption(bool encrypt);
+       int isExternalStorageEncrypted();
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index 8b6baec..89181dc 100644 (file)
@@ -24,18 +24,18 @@ namespace DevicePolicyManager {
 
 class StoragePolicy {
 public:
-    enum {
-        WIPE_INTERNAL_STORAGE = (1 << 0),
-        WIPE_EXTERNAL_STORAGE = (1 << 1)
-    };
+       enum {
+               WIPE_INTERNAL_STORAGE = (1 << 0),
+               WIPE_EXTERNAL_STORAGE = (1 << 1)
+       };
 
-    StoragePolicy(PolicyControlContext& ctxt);
-    ~StoragePolicy();
+       StoragePolicy(PolicyControlContext& ctxt);
+       ~StoragePolicy();
 
        int wipeData(int id);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DeivcePolicyManager
index 2d3fff9..94e88f8 100644 (file)
@@ -28,8 +28,8 @@ namespace DevicePolicyManager {
 
 class WifiPolicy {
 public:
-    WifiPolicy(PolicyControlContext& ctxt);
-    ~WifiPolicy(void);
+       WifiPolicy(PolicyControlContext& ctxt);
+       ~WifiPolicy(void);
 
        int setState(bool enable);
        bool getState();
@@ -37,17 +37,17 @@ public:
        int setHotspotState(bool enable);
        bool getHotspotState();
 
-    int setProfileChangeRestriction(bool restrict);
-    bool isProfileChangeRestricted(void);
+       int setProfileChangeRestriction(bool restrict);
+       bool isProfileChangeRestricted(void);
 
-    int setNetworkAccessRestriction(bool restrict);
-    bool isNetworkAccessRestricted(void);
+       int setNetworkAccessRestriction(bool restrict);
+       bool isNetworkAccessRestricted(void);
 
-    int addSsidToBlocklist(const std::string& ssid);
-    int removeSsidFromBlocklist(const std::string& ssid);
+       int addSsidToBlocklist(const std::string& ssid);
+       int removeSsidFromBlocklist(const std::string& ssid);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index 947c835..6c68c5c 100644 (file)
@@ -24,25 +24,25 @@ namespace DevicePolicyManager {
 
 class ZonePolicy {
 public:
-    enum State {
-        Locked      = 0x01,
-        Running     = 0x02,
-    };
+       enum State {
+               Locked      = 0x01,
+               Running     = 0x02,
+       };
 
-    ZonePolicy(PolicyControlContext& ctxt);
-    ~ZonePolicy();
+       ZonePolicy(PolicyControlContext& ctxt);
+       ~ZonePolicy();
 
-    int createZone(const std::string& name, const std::string& setupWizardAppid);
-    int removeZone(const std::string& name);
-    int lockZone(const std::string& name);
-    int unlockZone(const std::string& name);
+       int createZone(const std::string& name, const std::string& setupWizardAppid);
+       int removeZone(const std::string& name);
+       int lockZone(const std::string& name);
+       int unlockZone(const std::string& name);
 
-    int getZoneState(const std::string& name);
+       int getZoneState(const std::string& name);
 
-    std::vector<std::string> getZoneList(int state);
+       std::vector<std::string> getZoneList(int state);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index 34a789d..0cec21a 100644 (file)
@@ -28,63 +28,63 @@ namespace DevicePolicyManager {
 
 class ZoneAppProxy {
 public:
-    ZoneAppProxy(PolicyControlContext& ctxt);
-    ~ZoneAppProxy();
+       ZoneAppProxy(PolicyControlContext& ctxt);
+       ~ZoneAppProxy();
 
-    //application information
-    struct AppInfo {
-        std::string zone;
-        std::string id;
-        std::string locale;
-        std::string package;
-        std::string type;
-        std::string icon;
-        std::string label;
-        int componentType;
-        bool isNoDisplayed;
-        bool isTaskManaged;
+       //application information
+       struct AppInfo {
+               std::string zone;
+               std::string id;
+               std::string locale;
+               std::string package;
+               std::string type;
+               std::string icon;
+               std::string label;
+               int componentType;
+               bool isNoDisplayed;
+               bool isTaskManaged;
 
-        REFLECTABLE
-        (
-            zone, id, locale, package, type, icon, label,
-            componentType, isNoDisplayed, isTaskManaged
-        );
-    };
+               REFLECTABLE
+               (
+                       zone, id, locale, package, type, icon, label,
+                       componentType, isNoDisplayed, isTaskManaged
+               );
+       };
 
-    AppInfo getAppInfo(const std::string& name, const std::string& appid);
+       AppInfo getAppInfo(const std::string& name, const std::string& appid);
 
-    int createIterator(const std::string& name);
-    AppInfo getIteratorValue(int iterator);
-    bool nextIterator(int iterator);
-    int destroyIterator(int iterator);
+       int createIterator(const std::string& name);
+       AppInfo getIteratorValue(int iterator);
+       bool nextIterator(int iterator);
+       int destroyIterator(int iterator);
 
-    //application bundle
-    struct Bundle {
-        std::string operation;
-        std::string uri;
-        std::string mime;
-        std::string category;
-        std::string appId;
-        struct Extra {
-            std::string key;
-            std::vector<std::string> value;
-            REFLECTABLE(key, value);
-        };
-        std::vector<Extra> extraData;
+       //application bundle
+       struct Bundle {
+               std::string operation;
+               std::string uri;
+               std::string mime;
+               std::string category;
+               std::string appId;
+               struct Extra {
+                       std::string key;
+                       std::vector<std::string> value;
+                       REFLECTABLE(key, value);
+               };
+               std::vector<Extra> extraData;
 
-        REFLECTABLE
-        (
-            operation, uri, mime, category, appId, extraData
-        );
-    };
+               REFLECTABLE
+               (
+                       operation, uri, mime, category, appId, extraData
+               );
+       };
 
-    int launch(const std::string& name, const Bundle& bundle);
-    int resume(const std::string& name, const std::string& appid);
-    int terminate(const std::string& name, const std::string& appid);
-    bool isRunning(const std::string& name, const std::string& appid);
+       int launch(const std::string& name, const Bundle& bundle);
+       int resume(const std::string& name, const std::string& appid);
+       int terminate(const std::string& name, const std::string& appid);
+       bool isRunning(const std::string& name, const std::string& appid);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index 0794adc..b7405e3 100644 (file)
@@ -28,47 +28,47 @@ namespace DevicePolicyManager {
 
 class ZonePackageProxy {
 public:
-    ZonePackageProxy(PolicyControlContext& ctxt);
-    ~ZonePackageProxy();
+       ZonePackageProxy(PolicyControlContext& ctxt);
+       ~ZonePackageProxy();
 
-    //package information
-    struct PackageInfo {
-        std::string zone;
-        std::string id;
-        std::string locale;
-        std::string type;
-        std::string icon;
-        std::string label;
-        std::string description;
-        struct {
-            std::string name;
-            std::string email;
-            std::string href;
-            REFLECTABLE(name, email, href);
-        } author;
-        std::string version;
-        std::string apiVersion;
-        std::string mainAppId;
-        bool isSystem;
-        bool isRemovable;
-        bool isPreload;
+       //package information
+       struct PackageInfo {
+               std::string zone;
+               std::string id;
+               std::string locale;
+               std::string type;
+               std::string icon;
+               std::string label;
+               std::string description;
+               struct {
+                       std::string name;
+                       std::string email;
+                       std::string href;
+                       REFLECTABLE(name, email, href);
+               } author;
+               std::string version;
+               std::string apiVersion;
+               std::string mainAppId;
+               bool isSystem;
+               bool isRemovable;
+               bool isPreload;
 
-        REFLECTABLE
-        (
-            zone, id, locale, type, icon, label, description, author,
-            version, apiVersion, mainAppId, isSystem, isRemovable, isPreload
-        );
-    };
+               REFLECTABLE
+               (
+                       zone, id, locale, type, icon, label, description, author,
+                       version, apiVersion, mainAppId, isSystem, isRemovable, isPreload
+               );
+       };
 
-    PackageInfo getPackageInfo(const std::string& name, const std::string& pkgid);
-    std::vector<std::string> getPackageList(const std::string& name);
+       PackageInfo getPackageInfo(const std::string& name, const std::string& pkgid);
+       std::vector<std::string> getPackageList(const std::string& name);
 
-    //package manager request
-    int install(const std::string& name, const std::string& pkgpath);
-    int uninstall(const std::string& name, const std::string& pkgid);
+       //package manager request
+       int install(const std::string& name, const std::string& pkgpath);
+       int uninstall(const std::string& name, const std::string& pkgid);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index bcbe02c..2f78489 100644 (file)
@@ -24,27 +24,27 @@ namespace DevicePolicyManager {
 
 class ZoneManager {
 public:
-    enum State {
-        Locked      = 0x01,
-        Running     = 0x02,
-    };
+       enum State {
+               Locked      = 0x01,
+               Running     = 0x02,
+       };
 
-    ZoneManager(PolicyControlContext& ctxt);
-    ~ZoneManager();
+       ZoneManager(PolicyControlContext& ctxt);
+       ~ZoneManager();
 
-    int createZone(const std::string& name, const std::string& manifest);
-    int removeZone(const std::string& name);
-    int lockZone(const std::string& name);
-    int unlockZone(const std::string& name);
+       int createZone(const std::string& name, const std::string& manifest);
+       int removeZone(const std::string& name);
+       int lockZone(const std::string& name);
+       int unlockZone(const std::string& name);
 
-    int getZoneState(const std::string& name);
+       int getZoneState(const std::string& name);
 
-    std::vector<std::string> getZoneList(int state);
+       std::vector<std::string> getZoneList(int state);
 
-    int resetZonePassword(const std::string& name, const std::string& newPassword);
+       int resetZonePassword(const std::string& name, const std::string& newPassword);
 
 private:
-    PolicyControlContext& context;
+       PolicyControlContext& context;
 };
 
 } // namespace DevicePolicyManager
index c4880ad..c1eed42 100644 (file)
@@ -54,8 +54,8 @@ SET(DEPENDENCY                glib-2.0
                                        capi-network-bluetooth
                                        notification
                                        libgum
-                    cynara-client
-                    cynara-session
+                                       cynara-client
+                                       cynara-session
 )
 
 INCLUDE("${TIZEN_PROFILE_NAME}.cmake")
@@ -72,9 +72,9 @@ SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fPIE")
 SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_FLAGS "-pie")
 
 TARGET_COMPILE_DEFINITIONS(${TARGET} PRIVATE
-    CONF_PATH="${CONF_INSTALL_DIR}"
-    DATA_PATH="${DATA_INSTALL_DIR}"
-    DB_PATH="${DB_INSTALL_DIR}"
+       CONF_PATH="${CONF_INSTALL_DIR}"
+       DATA_PATH="${DATA_INSTALL_DIR}"
+       DB_PATH="${DB_INSTALL_DIR}"
 )
 
 CONFIGURE_FILE(systemd/device-policy-manager.service.in systemd/device-policy-manager.service)
index 6d7917a..11db16f 100644 (file)
 namespace DevicePolicyManager {
 
 AdministrationPolicy::AdministrationPolicy(PolicyControlContext& ctx) :
-    context(ctx)
+       context(ctx)
 {
-    context.registerParametricMethod(this, "", (int)(AdministrationPolicy::registerPolicyClient)(std::string));
-    context.registerParametricMethod(this, "", (int)(AdministrationPolicy::deregisterPolicyClient)(std::string));
+       context.registerParametricMethod(this, "", (int)(AdministrationPolicy::registerPolicyClient)(std::string));
+       context.registerParametricMethod(this, "", (int)(AdministrationPolicy::deregisterPolicyClient)(std::string));
 }
 
 AdministrationPolicy::~AdministrationPolicy()
@@ -34,30 +34,30 @@ AdministrationPolicy::~AdministrationPolicy()
 
 int AdministrationPolicy::registerPolicyClient(const std::string& name)
 {
-    ClientManager& manager = ClientManager::instance();
+       ClientManager& manager = ClientManager::instance();
 
-    try {
-        manager.registerClient(name);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to register policy client");
-        return -1;
-    }
+       try {
+               manager.registerClient(name);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to register policy client");
+               return -1;
+       }
 
-    return 0;
+       return 0;
 }
 
 int AdministrationPolicy::deregisterPolicyClient(const std::string& name)
 {
-    ClientManager& manager = ClientManager::instance();
+       ClientManager& manager = ClientManager::instance();
 
-    try {
-        manager.deregisterClient(name);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to deregister policy client");
-        return -1;
-    }
+       try {
+               manager.deregisterClient(name);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to deregister policy client");
+               return -1;
+       }
 
-    return 0;
+       return 0;
 }
 
 AdministrationPolicy adminPolicy(Server::instance());
index 779573e..0c253d3 100644 (file)
 #include "audit/logger.h"
 
 Bundle::Bundle() :
-    handle(nullptr)
+       handle(nullptr)
 {
-    handle = ::bundle_create();
-    if (handle == nullptr) {
-        throw runtime::Exception("Failed to create bundle");
-    }
+       handle = ::bundle_create();
+       if (handle == nullptr) {
+               throw runtime::Exception("Failed to create bundle");
+       }
 }
 
 Bundle::~Bundle()
 {
-    ::bundle_free(handle);
+       ::bundle_free(handle);
 }
 
 void Bundle::addInternal(const std::string& key, const std::string& value)
 {
-    ::bundle_add_str(handle, key.c_str(), value.c_str());
+       ::bundle_add_str(handle, key.c_str(), value.c_str());
 }
 
 void Bundle::addArrayInternal(const std::string& key, const std::vector<std::string>& array)
 {
-    std::unique_ptr<const char*[]> arrayptr(new const char*[array.size()]);
+       std::unique_ptr<const char*[]> arrayptr(new const char*[array.size()]);
 
-    int index = 0;
-    for (const std::string& data : array) {
-        arrayptr.get()[index++] = data.c_str();
-    }
+       int index = 0;
+       for (const std::string& data : array) {
+               arrayptr.get()[index++] = data.c_str();
+       }
 
-    ::bundle_add_str_array(handle, key.c_str(), arrayptr.get(), array.size());
+       ::bundle_add_str_array(handle, key.c_str(), arrayptr.get(), array.size());
 }
index da2ab70..887f2a0 100644 (file)
 
 class Bundle {
 public:
-    Bundle();
-    ~Bundle();
-
-    template<typename T>
-    void add(const std::string& key, const std::vector<T>& value)
-    {
-        addArrayInternal(key, value);
-    }
-
-    template<typename T>
-    void add(const std::string& key, const T& value)
-    {
-        addInternal(key, value);
-    }
-
-    bundle* get() const
-    {
-        return handle;
-    }
+       Bundle();
+       ~Bundle();
+
+       template<typename T>
+       void add(const std::string& key, const std::vector<T>& value)
+       {
+               addArrayInternal(key, value);
+       }
+
+       template<typename T>
+       void add(const std::string& key, const T& value)
+       {
+               addInternal(key, value);
+       }
+
+       bundle* get() const
+       {
+               return handle;
+       }
 
 private:
-    void addInternal(const std::string& key, const std::string& value);
-    void addArrayInternal(const std::string& key, const std::vector<std::string>& array);
+       void addInternal(const std::string& key, const std::string& value);
+       void addArrayInternal(const std::string& key, const std::vector<std::string>& array);
 
 private:
-    bundle* handle;
+       bundle* handle;
 };
 
 #endif //__DPM_BUNDLE_H__
index 9152a64..6bcef93 100644 (file)
 namespace DevicePolicyManager {
 
 ApplicationPolicy::ApplicationPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
-    context.registerNonparametricMethod(this, "", (int)(ApplicationPolicy::getModeRestriction)());
-    context.registerParametricMethod(this, "", (int)(ApplicationPolicy::setModeRestriction)(int));
-    context.registerParametricMethod(this, "", (int)(ApplicationPolicy::unsetModeRestriction)(int));
+       context.registerNonparametricMethod(this, "", (int)(ApplicationPolicy::getModeRestriction)());
+       context.registerParametricMethod(this, "", (int)(ApplicationPolicy::setModeRestriction)(int));
+       context.registerParametricMethod(this, "", (int)(ApplicationPolicy::unsetModeRestriction)(int));
 
-    context.registerParametricMethod(this, "", (int)(ApplicationPolicy::addPrivilegeToBlacklist)(int, std::string));
-    context.registerParametricMethod(this, "", (int)(ApplicationPolicy::removePrivilegeFromBlacklist)(int, std::string));
-    context.registerParametricMethod(this, "", (int)(ApplicationPolicy::checkPrivilegeIsBlacklisted)(int, std::string));
+       context.registerParametricMethod(this, "", (int)(ApplicationPolicy::addPrivilegeToBlacklist)(int, std::string));
+       context.registerParametricMethod(this, "", (int)(ApplicationPolicy::removePrivilegeFromBlacklist)(int, std::string));
+       context.registerParametricMethod(this, "", (int)(ApplicationPolicy::checkPrivilegeIsBlacklisted)(int, std::string));
 
-    context.registerParametricMethod(this, "", (int)(ApplicationPolicy::installPackage)(std::string));
-    context.registerParametricMethod(this, "", (int)(ApplicationPolicy::uninstallPackage)(std::string));
+       context.registerParametricMethod(this, "", (int)(ApplicationPolicy::installPackage)(std::string));
+       context.registerParametricMethod(this, "", (int)(ApplicationPolicy::uninstallPackage)(std::string));
 }
 
 ApplicationPolicy::~ApplicationPolicy()
@@ -52,115 +52,115 @@ ApplicationPolicy::~ApplicationPolicy()
 
 int ApplicationPolicy::installPackage(const std::string& pkgpath)
 {
-    try {
-        PackageManager& packman = PackageManager::instance();
-        packman.installPackage(pkgpath, context.getPeerUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Exception on package installation: " + pkgpath);
-        return -1;
-    }
-
-    return 0;
+       try {
+               PackageManager& packman = PackageManager::instance();
+               packman.installPackage(pkgpath, context.getPeerUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Exception on package installation: " + pkgpath);
+               return -1;
+       }
+
+       return 0;
 }
 
 int ApplicationPolicy::uninstallPackage(const std::string& pkgid)
 {
-    try {
-        PackageManager& packman = PackageManager::instance();
-        packman.uninstallPackage(pkgid, context.getPeerUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Exception on package uninstallation: " + pkgid);
-        return -1;
-    }
-
-    return 0;
+       try {
+               PackageManager& packman = PackageManager::instance();
+               packman.uninstallPackage(pkgid, context.getPeerUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Exception on package uninstallation: " + pkgid);
+               return -1;
+       }
+
+       return 0;
 }
 
 int ApplicationPolicy::setModeRestriction(int mode)
 {
-    try {
-        PackageManager& packman = PackageManager::instance();
-        packman.setModeRestriction(mode, context.getPeerUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to set mode restriction");
-        return -1;
-    }
-
-    return 0;
+       try {
+               PackageManager& packman = PackageManager::instance();
+               packman.setModeRestriction(mode, context.getPeerUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to set mode restriction");
+               return -1;
+       }
+
+       return 0;
 }
 
 int ApplicationPolicy::unsetModeRestriction(int mode)
 {
-    try {
-        PackageManager& packman = PackageManager::instance();
-        packman.unsetModeRestriction(mode, context.getPeerUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to unset mode restriction");
-        return -1;
-    }
-
-    return 0;
+       try {
+               PackageManager& packman = PackageManager::instance();
+               packman.unsetModeRestriction(mode, context.getPeerUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to unset mode restriction");
+               return -1;
+       }
+
+       return 0;
 }
 
 int ApplicationPolicy::getModeRestriction()
 {
-    try {
-        PackageManager& packman = PackageManager::instance();
-        return packman.getModeRestriction(context.getPeerUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to get mode restriction");
-        return -1;
-    }
+       try {
+               PackageManager& packman = PackageManager::instance();
+               return packman.getModeRestriction(context.getPeerUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to get mode restriction");
+               return -1;
+       }
 }
 
 int ApplicationPolicy::addPrivilegeToBlacklist(int type, const std::string& privilege)
 {
-    GList* privilegeList = NULL;
-    privilegeList = g_list_append(privilegeList, const_cast<char*>(privilege.c_str()));
-    privilege_manager_package_type_e pkgType = type ? PRVMGR_PACKAGE_TYPE_CORE : PRVMGR_PACKAGE_TYPE_WRT;
-    int ret = privilege_manager_set_black_list(context.getPeerUid(), pkgType, privilegeList);
-    g_list_free(privilegeList);
-    if (ret !=PRVMGR_ERR_NONE) {
-        return -1;
-    }
-
-    return 0;
+       GList* privilegeList = NULL;
+       privilegeList = g_list_append(privilegeList, const_cast<char*>(privilege.c_str()));
+       privilege_manager_package_type_e pkgType = type ? PRVMGR_PACKAGE_TYPE_CORE : PRVMGR_PACKAGE_TYPE_WRT;
+       int ret = privilege_manager_set_black_list(context.getPeerUid(), pkgType, privilegeList);
+       g_list_free(privilegeList);
+       if (ret !=PRVMGR_ERR_NONE) {
+               return -1;
+       }
+
+       return 0;
 }
 
 int ApplicationPolicy::removePrivilegeFromBlacklist(int type, const std::string& privilege)
 {
-    GList* privilegeList = NULL;
-    privilegeList = g_list_append(privilegeList, const_cast<char*>(privilege.c_str()));
+       GList* privilegeList = NULL;
+       privilegeList = g_list_append(privilegeList, const_cast<char*>(privilege.c_str()));
 
-    privilege_manager_package_type_e pkgType = type ? PRVMGR_PACKAGE_TYPE_CORE : PRVMGR_PACKAGE_TYPE_WRT;
-    int ret = privilege_manager_unset_black_list(context.getPeerUid(), pkgType, privilegeList);
-    g_list_free(privilegeList);
-    if (ret != PRVMGR_ERR_NONE) {
-        return -1;
-    }
+       privilege_manager_package_type_e pkgType = type ? PRVMGR_PACKAGE_TYPE_CORE : PRVMGR_PACKAGE_TYPE_WRT;
+       int ret = privilege_manager_unset_black_list(context.getPeerUid(), pkgType, privilegeList);
+       g_list_free(privilegeList);
+       if (ret != PRVMGR_ERR_NONE) {
+               return -1;
+       }
 
-    return 0;
+       return 0;
 }
 
 int ApplicationPolicy::checkPrivilegeIsBlacklisted(int type, const std::string& privilege)
 {
-    GList* blacklist = NULL;
-
-    privilege_manager_package_type_e pkgType = type ? PRVMGR_PACKAGE_TYPE_CORE : PRVMGR_PACKAGE_TYPE_WRT;
-    int ret = privilege_info_get_black_list(context.getPeerUid(), pkgType, &blacklist);
-    if (ret != PRVMGR_ERR_NONE) {
-        return -1;
-    }
-
-    for (GList* l = blacklist; l != NULL; l = l->next) {
-        char *name = (char *)l->data;
-        if (privilege == name) {
-            g_list_free(blacklist);
-            return true;
-        }
-    }
-    g_list_free(blacklist);
-    return false;
+       GList* blacklist = NULL;
+
+       privilege_manager_package_type_e pkgType = type ? PRVMGR_PACKAGE_TYPE_CORE : PRVMGR_PACKAGE_TYPE_WRT;
+       int ret = privilege_info_get_black_list(context.getPeerUid(), pkgType, &blacklist);
+       if (ret != PRVMGR_ERR_NONE) {
+               return -1;
+       }
+
+       for (GList* l = blacklist; l != NULL; l = l->next) {
+               char *name = (char *)l->data;
+               if (privilege == name) {
+                       g_list_free(blacklist);
+                       return true;
+               }
+       }
+       g_list_free(blacklist);
+       return false;
 }
 
 ApplicationPolicy applicationPolicy(Server::instance());
index 7ec7fe2..83405f4 100644 (file)
 #include "dbus/connection.h"
 
 #define POLICY_ENFORCING_FAILED(ret)                    \
-    (((ret) == BLUETOOTH_DPM_RESULT_ACCESS_DENIED) ||   \
-     ((ret) == BLUETOOTH_DPM_RESULT_FAIL))
+       (((ret) == BLUETOOTH_DPM_RESULT_ACCESS_DENIED) ||   \
+        ((ret) == BLUETOOTH_DPM_RESULT_FAIL))
 
 #define POLICY_IS_ALLOWED(enable)                       \
-    ((enable) ? BLUETOOTH_DPM_ALLOWED :                 \
-                BLUETOOTH_DPM_RESTRICTED)
+       ((enable) ? BLUETOOTH_DPM_ALLOWED :                 \
+                               BLUETOOTH_DPM_RESTRICTED)
 
 #define STATE_CHANGE_IS_ALLOWED(enable)                 \
-    ((enable) ? BLUETOOTH_DPM_BT_ALLOWED :              \
-                BLUETOOTH_DPM_BT_RESTRICTED)
+       ((enable) ? BLUETOOTH_DPM_BT_ALLOWED :              \
+                               BLUETOOTH_DPM_BT_RESTRICTED)
 
 
 #define MOBILEAP_INTERFACE             \
 namespace DevicePolicyManager {
 
 struct BluetoothPolicyContext {
-    BluetoothPolicyContext(BluetoothPolicy* p, PolicyControlContext* c) :
-        policy(p), context(c)
-    {
-    }
+       BluetoothPolicyContext(BluetoothPolicy* p, PolicyControlContext* c) :
+               policy(p), context(c)
+       {
+       }
 
-    BluetoothPolicy* policy;
-    PolicyControlContext* context;
+       BluetoothPolicy* policy;
+       PolicyControlContext* context;
 };
 
 static void bluetoothAdapterStateChangedCallback(int result, bt_adapter_state_e state, void *user_data)
 {
-    if (state != BT_ADAPTER_ENABLED) {
-        return;
-    }
-
-    BluetoothPolicyContext *bluetooth = (BluetoothPolicyContext *)user_data;
-    BluetoothPolicy &policy = *bluetooth->policy;
-    PolicyControlContext &context = *bluetooth->context;
-
-    bool allowed = IsPolicyAllowed(context, "bluetooth");
-    if (policy.setModeChangeState(allowed) != BLUETOOTH_DPM_RESULT_SUCCESS) {
-        // TODO(seok85.hong): we can notify to admin client with this notification.
-    }
-
-    allowed = IsPolicyAllowed(context, "bluetooth-desktop-connectivity");
-    if (policy.setDesktopConnectivityState(allowed) != BLUETOOTH_DPM_RESULT_SUCCESS) {
-        // TODO(seok85.hong): we can notify to admin client with this notification.
-    }
-
-    allowed = IsPolicyAllowed(context, "bluetooth-pairing");
-    if (policy.setPairingState(allowed) != BLUETOOTH_DPM_RESULT_SUCCESS) {
-        // TODO(seok85.hong): we can notify to admin client with this notification.
-    }
-
-    bool enabled = IsPolicyEnabled(context, "bluetooth-device-restriction");
-    if (policy.setDeviceRestriction(enabled) != BLUETOOTH_DPM_RESULT_SUCCESS) {
-        // TODO(seok85.hong): we can notify to admin client with this notification.
-    }
-
-    enabled = IsPolicyEnabled(context, "bluetooth-uuid-restriction");
-    if (policy.setUuidRestriction(enabled) != BLUETOOTH_DPM_RESULT_SUCCESS) {
-        // TODO(seok85.hong): we can notify to admin client with this notification.
-    }
+       if (state != BT_ADAPTER_ENABLED) {
+               return;
+       }
+
+       BluetoothPolicyContext *bluetooth = (BluetoothPolicyContext *)user_data;
+       BluetoothPolicy &policy = *bluetooth->policy;
+       PolicyControlContext &context = *bluetooth->context;
+
+       bool allowed = IsPolicyAllowed(context, "bluetooth");
+       if (policy.setModeChangeState(allowed) != BLUETOOTH_DPM_RESULT_SUCCESS) {
+               // TODO(seok85.hong): we can notify to admin client with this notification.
+       }
+
+       allowed = IsPolicyAllowed(context, "bluetooth-desktop-connectivity");
+       if (policy.setDesktopConnectivityState(allowed) != BLUETOOTH_DPM_RESULT_SUCCESS) {
+               // TODO(seok85.hong): we can notify to admin client with this notification.
+       }
+
+       allowed = IsPolicyAllowed(context, "bluetooth-pairing");
+       if (policy.setPairingState(allowed) != BLUETOOTH_DPM_RESULT_SUCCESS) {
+               // TODO(seok85.hong): we can notify to admin client with this notification.
+       }
+
+       bool enabled = IsPolicyEnabled(context, "bluetooth-device-restriction");
+       if (policy.setDeviceRestriction(enabled) != BLUETOOTH_DPM_RESULT_SUCCESS) {
+               // TODO(seok85.hong): we can notify to admin client with this notification.
+       }
+
+       enabled = IsPolicyEnabled(context, "bluetooth-uuid-restriction");
+       if (policy.setUuidRestriction(enabled) != BLUETOOTH_DPM_RESULT_SUCCESS) {
+               // TODO(seok85.hong): we can notify to admin client with this notification.
+       }
 }
 
 BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setModeChangeState)(bool));
-    ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getModeChangeState));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setDesktopConnectivityState)(bool));
-    ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getDesktopConnectivityState));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setTetheringState)(bool));
-    ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getTetheringState));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setPairingState)(bool));
-    ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getPairingState));
-
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::addDeviceToBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::removeDeviceFromBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setDeviceRestriction)(bool));
-    ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::isDeviceRestricted));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::addUuidToBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::removeUuidFromBlacklist)(std::string));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setUuidRestriction)(bool));
-    ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::isUuidRestricted));
-
-    ctxt.createNotification("bluetooth");
-    ctxt.createNotification("bluetooth-tethering");
-    ctxt.createNotification("bluetooth-desktop-connectivity");
-    ctxt.createNotification("bluetooth-pairing");
-    ctxt.createNotification("bluetooth-uuid-restriction");
-    ctxt.createNotification("bluetooth-device-restriction");
-
-    if (::bt_initialize() != BT_ERROR_NONE) {
-        return;
-    }
-
-    if (bt_adapter_set_state_changed_cb(bluetoothAdapterStateChangedCallback,
-                                        new BluetoothPolicyContext(this, &ctxt)) != BT_ERROR_NONE) {
-        return;
-    }
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setModeChangeState)(bool));
+       ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getModeChangeState));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setDesktopConnectivityState)(bool));
+       ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getDesktopConnectivityState));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setTetheringState)(bool));
+       ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getTetheringState));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setPairingState)(bool));
+       ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::getPairingState));
+
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::addDeviceToBlacklist)(std::string));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::removeDeviceFromBlacklist)(std::string));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setDeviceRestriction)(bool));
+       ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::isDeviceRestricted));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::addUuidToBlacklist)(std::string));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::removeUuidFromBlacklist)(std::string));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_BLUETOOTH, (int)(BluetoothPolicy::setUuidRestriction)(bool));
+       ctxt.registerNonparametricMethod(this, "", (bool)(BluetoothPolicy::isUuidRestricted));
+
+       ctxt.createNotification("bluetooth");
+       ctxt.createNotification("bluetooth-tethering");
+       ctxt.createNotification("bluetooth-desktop-connectivity");
+       ctxt.createNotification("bluetooth-pairing");
+       ctxt.createNotification("bluetooth-uuid-restriction");
+       ctxt.createNotification("bluetooth-device-restriction");
+
+       if (::bt_initialize() != BT_ERROR_NONE) {
+               return;
+       }
+
+       if (bt_adapter_set_state_changed_cb(bluetoothAdapterStateChangedCallback,
+                                                                               new BluetoothPolicyContext(this, &ctxt)) != BT_ERROR_NONE) {
+               return;
+       }
 }
 
 BluetoothPolicy::~BluetoothPolicy()
 {
-    bt_deinitialize();
+       bt_deinitialize();
 }
 
 int BluetoothPolicy::setModeChangeState(const bool enable)
 {
-    int ret = bluetooth_dpm_set_allow_mode(STATE_CHANGE_IS_ALLOWED(enable));
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bluetooth_dpm_set_allow_mode(STATE_CHANGE_IS_ALLOWED(enable));
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return SetPolicyAllowed(context, "bluetooth", enable);
+       return SetPolicyAllowed(context, "bluetooth", enable);
 }
 
 bool BluetoothPolicy::getModeChangeState()
 {
-    return IsPolicyAllowed(context, "bluetooth");
+       return IsPolicyAllowed(context, "bluetooth");
 }
 
 int BluetoothPolicy::setDesktopConnectivityState(const bool enable)
 {
-    int ret = bluetooth_dpm_set_desktop_connectivity_state(POLICY_IS_ALLOWED(enable));
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bluetooth_dpm_set_desktop_connectivity_state(POLICY_IS_ALLOWED(enable));
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return SetPolicyAllowed(context, "bluetooth-desktop-connectivity", enable);
+       return SetPolicyAllowed(context, "bluetooth-desktop-connectivity", enable);
 }
 
 bool BluetoothPolicy::getDesktopConnectivityState()
 {
-    return IsPolicyAllowed(context, "bluetooth-desktop-connectivity");
+       return IsPolicyAllowed(context, "bluetooth-desktop-connectivity");
 }
 
 int BluetoothPolicy::setPairingState(const bool enable)
 {
-    int ret = bluetooth_dpm_set_pairing_state(POLICY_IS_ALLOWED(enable));
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bluetooth_dpm_set_pairing_state(POLICY_IS_ALLOWED(enable));
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return SetPolicyAllowed(context, "bluetooth-pairing", enable);
+       return SetPolicyAllowed(context, "bluetooth-pairing", enable);
 }
 
 bool BluetoothPolicy::getPairingState()
 {
-    return IsPolicyAllowed(context, "bluetooth-pairing");
+       return IsPolicyAllowed(context, "bluetooth-pairing");
 }
 
 
 int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
 {
-    int ret = bt_dpm_add_devices_to_blacklist(mac.c_str());
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bt_dpm_add_devices_to_blacklist(mac.c_str());
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return ret;
+       return ret;
 }
 
 int BluetoothPolicy::setTetheringState(bool enable)
 {
-    try {
-        dbus::Connection &systemDBus = dbus::Connection::getSystem();
-        systemDBus.methodcall(MOBILEAP_INTERFACE,
-                              "change_policy",
-                              -1,
-                              "",
-                              "(sb)",
-                              "bluetooth-tethering",
-                              enable);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to change bluetooth tethering state");
-        return -1;
-    }
-
-    return SetPolicyAllowed(context, "bluetooth-tethering", enable);
+       try {
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.methodcall(MOBILEAP_INTERFACE,
+                                                         "change_policy",
+                                                         -1,
+                                                         "",
+                                                         "(sb)",
+                                                         "bluetooth-tethering",
+                                                         enable);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to change bluetooth tethering state");
+               return -1;
+       }
+
+       return SetPolicyAllowed(context, "bluetooth-tethering", enable);
 }
 
 bool BluetoothPolicy::getTetheringState()
 {
-    return IsPolicyAllowed(context, "bluetooth-tethering");
+       return IsPolicyAllowed(context, "bluetooth-tethering");
 }
 
 
 int BluetoothPolicy::removeDeviceFromBlacklist(const std::string& mac)
 {
-    int ret = bt_dpm_remove_device_from_blacklist(mac.c_str());
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bt_dpm_remove_device_from_blacklist(mac.c_str());
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return ret;
+       return ret;
 }
 
 int BluetoothPolicy::setDeviceRestriction(const bool enable)
 {
-    int ret = bluetooth_dpm_activate_device_restriction(POLICY_IS_ALLOWED(!enable));
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bluetooth_dpm_activate_device_restriction(POLICY_IS_ALLOWED(!enable));
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return SetPolicyEnabled(context, "bluetooth-device-restriction", enable);
+       return SetPolicyEnabled(context, "bluetooth-device-restriction", enable);
 }
 
 bool BluetoothPolicy::isDeviceRestricted()
 {
-    return IsPolicyEnabled(context, "bluetooth-device-restriction");
+       return IsPolicyEnabled(context, "bluetooth-device-restriction");
 }
 
 int BluetoothPolicy::addUuidToBlacklist(const std::string& uuid)
 {
-    int ret = bluetooth_dpm_add_uuids_to_blacklist(uuid.c_str());
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bluetooth_dpm_add_uuids_to_blacklist(uuid.c_str());
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return ret;
+       return ret;
 }
 
 int BluetoothPolicy::removeUuidFromBlacklist(const std::string& uuid)
 {
-    int ret = bluetooth_dpm_remove_uuid_from_blacklist(uuid.c_str());
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bluetooth_dpm_remove_uuid_from_blacklist(uuid.c_str());
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return ret;
+       return ret;
 }
 
 int BluetoothPolicy::setUuidRestriction(const bool enable)
 {
-    int ret = bluetooth_dpm_activate_uuid_restriction(POLICY_IS_ALLOWED(!enable));
-    if (POLICY_ENFORCING_FAILED(ret)) {
-        return -1;
-    }
+       int ret = bluetooth_dpm_activate_uuid_restriction(POLICY_IS_ALLOWED(!enable));
+       if (POLICY_ENFORCING_FAILED(ret)) {
+               return -1;
+       }
 
-    return SetPolicyEnabled(context, "bluetooth-uuid-restriction", enable);
+       return SetPolicyEnabled(context, "bluetooth-uuid-restriction", enable);
 }
 
 bool BluetoothPolicy::isUuidRestricted()
 {
-    return IsPolicyEnabled(context, "bluetooth-uuid-restriction");
+       return IsPolicyEnabled(context, "bluetooth-uuid-restriction");
 }
 
 BluetoothPolicy bluetoothPolicy(Server::instance());
index 70bf649..79f3c83 100644 (file)
@@ -33,10 +33,10 @@ const std::string clientPolicyStorage = CONF_PATH "/policy";
 } //namespace
 
 Client::Client(const std::string& pkgname, const std::string& pk) :
-    name(pkgname), key(pk), policyStorage(nullptr)
+       name(pkgname), key(pk), policyStorage(nullptr)
 {
-    std::string storagePath = clientPolicyStorage + "/" + name;
-    policyStorage.reset(new PolicyStorage(storagePath));
+       std::string storagePath = clientPolicyStorage + "/" + name;
+       policyStorage.reset(new PolicyStorage(storagePath));
 }
 
 Client::~Client()
@@ -50,14 +50,14 @@ const std::string clientDBName = ".client.db";
 
 } //namespace
 
-ClientManager::ClientManager()
-    : clientRepository(nullptr)
+ClientManager::ClientManager() :
+       clientRepository(nullptr)
 {
-    std::string location = dataStorageLocation + "/" + clientDBName;
-    clientRepository.reset(new database::Connection(location, database::Connection::ReadWrite |
-                           database::Connection::Create));
-    prepareRepository();
-    loadClients();
+       std::string location = dataStorageLocation + "/" + clientDBName;
+       clientRepository.reset(new database::Connection(location, database::Connection::ReadWrite |
+                                                  database::Connection::Create));
+       prepareRepository();
+       loadClients();
 }
 
 ClientManager::~ClientManager()
@@ -66,89 +66,89 @@ ClientManager::~ClientManager()
 
 void ClientManager::registerClient(const std::string& name)
 {
-    std::lock_guard<Mutex> lock(mutex);
+       std::lock_guard<Mutex> lock(mutex);
 
-    std::string selectQuery = "SELECT * FROM CLIENT WHERE PKG = \"" + name + "\"";
-    database::Statement stmt0(*clientRepository, selectQuery);
-    if (stmt0.step()) {
-        throw runtime::Exception("Client already registered");
-    }
+       std::string selectQuery = "SELECT * FROM CLIENT WHERE PKG = \"" + name + "\"";
+       database::Statement stmt0(*clientRepository, selectQuery);
+       if (stmt0.step()) {
+               throw runtime::Exception("Client already registered");
+       }
 
-    std::string key = generateKey();
+       std::string key = generateKey();
 
-    std::string insertQuery = "INSERT INTO CLIENT (PKG, KEY, VALID) VALUES (?, ?, ?)";
-    database::Statement stmt(*clientRepository, insertQuery);
-    stmt.bind(1, name);
-    stmt.bind(2, key);
-    stmt.bind(3, true);
+       std::string insertQuery = "INSERT INTO CLIENT (PKG, KEY, VALID) VALUES (?, ?, ?)";
+       database::Statement stmt(*clientRepository, insertQuery);
+       stmt.bind(1, name);
+       stmt.bind(2, key);
+       stmt.bind(3, true);
 
-    if (!stmt.exec()) {
-        throw runtime::Exception("Failed to insert client data");
-    }
+       if (!stmt.exec()) {
+               throw runtime::Exception("Failed to insert client data");
+       }
 
-    registeredClients.push_back(Client(name, key));
+       registeredClients.push_back(Client(name, key));
 }
 
 void ClientManager::deregisterClient(const std::string& name)
 {
-    auto removeClient = [](ClientList & list, const std::string & name) {
-        ClientList::iterator iter = list.begin();
-        while (iter != list.end()) {
-            Client& client = *iter;
-            if (client.getName() == name) {
-                list.erase(iter);
-                return true;
-            }
-            ++iter;
-        }
-
-        return false;
-    };
-
-    std::lock_guard<Mutex> lock(mutex);
-
-    std::string query = "DELETE FROM CLIENT WHERE PKG = \"" + name + "\"";
-    if (!clientRepository->exec(query)) {
-        throw runtime::Exception("Failed to delete client data");
-    }
-
-    if (!removeClient(registeredClients, name)) {
-        removeClient(activatedClients, name);
-    }
+       auto removeClient = [](ClientList & list, const std::string & name) {
+               ClientList::iterator iter = list.begin();
+               while (iter != list.end()) {
+                       Client& client = *iter;
+                       if (client.getName() == name) {
+                               list.erase(iter);
+                               return true;
+                       }
+                       ++iter;
+               }
+
+               return false;
+       };
+
+       std::lock_guard<Mutex> lock(mutex);
+
+       std::string query = "DELETE FROM CLIENT WHERE PKG = \"" + name + "\"";
+       if (!clientRepository->exec(query)) {
+               throw runtime::Exception("Failed to delete client data");
+       }
+
+       if (!removeClient(registeredClients, name)) {
+               removeClient(activatedClients, name);
+       }
 }
 
 std::string ClientManager::generateKey()
 {
-    std::string key = "TestKey";
-    return key;
+       std::string key = "TestKey";
+       return key;
 }
 
 void ClientManager::loadClients()
 {
-    std::lock_guard<Mutex> lock(mutex);
+       std::lock_guard<Mutex> lock(mutex);
 
-    database::Statement stmt(*clientRepository, "SELECT * FROM CLIENT");
-    while (stmt.step()) {
-        std::string name = stmt.getColumn(1).getText();
-        std::string key = stmt.getColumn(2).getText();
+       database::Statement stmt(*clientRepository, "SELECT * FROM CLIENT");
+       while (stmt.step()) {
+               std::string name = stmt.getColumn(1).getText();
+               std::string key = stmt.getColumn(2).getText();
 
-        registeredClients.push_back(Client(name, key));
-    }
+               registeredClients.push_back(Client(name, key));
+       }
 }
 
 void ClientManager::prepareRepository()
 {
-    std::string query = "CREATE TABLE IF NOT EXISTS CLIENT ("    \
-                        "ID INTEGER PRIMARY KEY AUTOINCREMENT, " \
-                        "PKG TEXT, "                             \
-                        "KEY TEXT, "                             \
-                        "VALID INTEGER)";
+       std::string query = "CREATE TABLE IF NOT EXISTS CLIENT ("    \
+                                               "ID INTEGER PRIMARY KEY AUTOINCREMENT, " \
+                                               "PKG TEXT, "                             \
+                                               "KEY TEXT, "                             \
+                                               "VALID INTEGER)";
 
-    clientRepository->exec(query);
+       clientRepository->exec(query);
 }
 
 ClientManager& ClientManager::instance()
 {
-    static ClientManager __instance__;
-    return __instance__;
+       static ClientManager __instance__;
+       return __instance__;
 }
index fcdaeb9..41431dc 100644 (file)
 
 class Client {
 public:
-    Client(const Client&) = delete;
-    Client(Client&&) = default;
-    Client(const std::string& name, const std::string& key);
+       Client(const Client&) = delete;
+       Client(Client&&) = default;
+       Client(const std::string& name, const std::string& key);
 
-    ~Client();
+       ~Client();
 
-    Client& operator=(Client&&) = default;
-    Client& operator=(const Client&) = delete;
+       Client& operator=(Client&&) = default;
+       Client& operator=(const Client&) = delete;
 
-    inline std::string getName() const
-    {
-        return name;
-    }
+       inline std::string getName() const
+       {
+               return name;
+       }
 
-    inline std::string getKey() const
-    {
-        return key;
-    }
+       inline std::string getKey() const
+       {
+               return key;
+       }
 
 private:
-    std::string name;
-    std::string key;
+       std::string name;
+       std::string key;
 
-    std::unique_ptr<PolicyStorage> policyStorage;
+       std::unique_ptr<PolicyStorage> policyStorage;
 };
 
 class ClientManager {
 public:
-    ClientManager(const ClientManager&) = delete;
-    ClientManager& operator=(const ClientManager&) = delete;
+       ClientManager(const ClientManager&) = delete;
+       ClientManager& operator=(const ClientManager&) = delete;
 
-    void registerClient(const std::string& name);
-    void deregisterClient(const std::string& name);
+       void registerClient(const std::string& name);
+       void deregisterClient(const std::string& name);
 
-    std::string generateKey();
+       std::string generateKey();
 
-    static ClientManager& instance();
+       static ClientManager& instance();
 
 private:
-    ClientManager();
-    ~ClientManager();
+       ClientManager();
+       ~ClientManager();
 
-    void loadClients();
-    void prepareRepository();
-    std::string getPackageName(int pid);
+       void loadClients();
+       void prepareRepository();
+       std::string getPackageName(int pid);
 
 private:
-    typedef std::vector<Client> ClientList;
-    ClientList activatedClients;
-    ClientList registeredClients;
+       typedef std::vector<Client> ClientList;
+       ClientList activatedClients;
+       ClientList registeredClients;
 
-    std::unique_ptr<database::Connection> clientRepository;
+       std::unique_ptr<database::Connection> clientRepository;
 
-    typedef std::recursive_mutex Mutex;
-    Mutex mutex;
+       typedef std::recursive_mutex Mutex;
+       Mutex mutex;
 };
 
 #endif //__DPM_CLIENT_MANAGER_H__
index dcec61b..1f2cbea 100644 (file)
 #
 
 SET(POLICY      ${POLICY}
-                bluetooth.cpp
-                location.cpp
-                password.cpp
+                               bluetooth.cpp
+                               location.cpp
+                               password.cpp
 )
 
 SET(DEPENDENCY  ${DEPENDENCY}
-                capi-location-manager
-                capi-network-bluetooth
-                auth-fw-admin
-                bluetooth-api
+                               capi-location-manager
+                               capi-network-bluetooth
+                               auth-fw-admin
+                               bluetooth-api
 )
-
index fc40c80..b98bde4 100644 (file)
 #
 
 SET(POLICY      ${POLICY}
-                bluetooth.cpp
-                location.cpp
-                password.cpp
+                               bluetooth.cpp
+                               location.cpp
+                               password.cpp
 )
 
 SET(DEPENDENCY  ${DEPENDENCY}
-                capi-location-manager
-                capi-network-bluetooth
-                auth-fw-admin
-                bluetooth-api
+                               capi-location-manager
+                               capi-network-bluetooth
+                               auth-fw-admin
+                               bluetooth-api
 )
index 60a200e..7ab5cdc 100644 (file)
 #include "dbus/connection.h"
 
 Launchpad::Launchpad(const uid_t uid) :
-    user(uid)
+       user(uid)
 {
-    if (user == 0) {
-        dbus::Connection& systemDBus = dbus::Connection::getSystem();
-        const dbus::Variant& var = systemDBus.methodcall
-                                           ("org.freedesktop.login1",
-                                            "/org/freedesktop/login1",
-                                            "org.freedesktop.login1.Manager",
-                                            "ListSessions",
-                                            -1, "", "");
-        if (var) {
-            dbus::VariantIterator it;
-            var.get("(a(susso))", &it);
-            it.get("(susso)", NULL, &user, NULL, NULL, NULL);
-        }
-    }
-    if (user == 0) {
-        throw runtime::Exception("No logined user for launching app");
-    }
+       if (user == 0) {
+               dbus::Connection& systemDBus = dbus::Connection::getSystem();
+               const dbus::Variant& var = systemDBus.methodcall
+                                                                                  ("org.freedesktop.login1",
+                                                                                       "/org/freedesktop/login1",
+                                                                                       "org.freedesktop.login1.Manager",
+                                                                                       "ListSessions",
+                                                                                       -1, "", "");
+               if (var) {
+                       dbus::VariantIterator it;
+                       var.get("(a(susso))", &it);
+                       it.get("(susso)", NULL, &user, NULL, NULL, NULL);
+               }
+       }
+       if (user == 0) {
+               throw runtime::Exception("No logined user for launching app");
+       }
 }
 
 bool Launchpad::isRunning(const std::string& appid)
 {
-    return ::aul_app_is_running_for_uid(appid.c_str(), user);
+       return ::aul_app_is_running_for_uid(appid.c_str(), user);
 }
 
 void Launchpad::launch(const std::string& appid)
 {
-    launch(appid, Bundle());
+       launch(appid, Bundle());
 }
 
 void Launchpad::launch(const std::string& appid, const Bundle& bundle)
 {
-    if (::aul_launch_app_for_uid(appid.c_str(), bundle.get(), user) < 0) {
-        throw runtime::Exception("Failed to launch app " + appid);
-    }
+       if (::aul_launch_app_for_uid(appid.c_str(), bundle.get(), user) < 0) {
+               throw runtime::Exception("Failed to launch app " + appid);
+       }
 }
 
 void Launchpad::resume(const std::string& appid)
 {
-    if (::aul_resume_app_for_uid(appid.c_str(), user) < 0) {
-        throw runtime::Exception("Failed to resume app " + appid);
-    }
+       if (::aul_resume_app_for_uid(appid.c_str(), user) < 0) {
+               throw runtime::Exception("Failed to resume app " + appid);
+       }
 }
 
 void Launchpad::terminate(const std::string& appid)
 {
-    int pid = ::aul_app_get_pid_for_uid(appid.c_str(), user);
-    if (pid > 0) {
-        if (::aul_terminate_pid_for_uid(pid, user) < 0) {
-            WARN("Failed to terminate app PID=" + std::to_string(pid));
-            ::kill(pid, SIGKILL);
-        }
-    }
+       int pid = ::aul_app_get_pid_for_uid(appid.c_str(), user);
+       if (pid > 0) {
+               if (::aul_terminate_pid_for_uid(pid, user) < 0) {
+                       WARN("Failed to terminate app PID=" + std::to_string(pid));
+                       ::kill(pid, SIGKILL);
+               }
+       }
 }
index 6d72f1e..2435f35 100644 (file)
 
 class Launchpad {
 public:
-    Launchpad(const uid_t uid = 0);
-    Launchpad(const Launchpad&) = delete;
-    Launchpad(Launchpad&&) = delete;
+       Launchpad(const uid_t uid = 0);
+       Launchpad(const Launchpad&) = delete;
+       Launchpad(Launchpad&&) = delete;
 
-    void launch(const std::string& appid);
-    void launch(const std::string& appid, const Bundle& bundle);
-    void resume(const std::string& appid);
-    bool isRunning(const std::string& appid);
-    void terminate(const std::string& appid);
+       void launch(const std::string& appid);
+       void launch(const std::string& appid, const Bundle& bundle);
+       void resume(const std::string& appid);
+       bool isRunning(const std::string& appid);
+       void terminate(const std::string& appid);
 
 private:
-    uid_t user;
+       uid_t user;
 };
 
 #endif //__DPM_LAUNCHPAD_H__
index e095f91..a923416 100644 (file)
@@ -25,7 +25,7 @@
 namespace DevicePolicyManager {
 
 LocationPolicy::LocationPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
        context.registerParametricMethod(this, DPM_PRIVILEGE_LOCATION, (int)(LocationPolicy::setLocationState)(int));
        context.registerNonparametricMethod(this, "", (int)(LocationPolicy::getLocationState));
@@ -39,15 +39,15 @@ LocationPolicy::~LocationPolicy()
 
 int LocationPolicy::setLocationState(int enable)
 {
-    if (location_manager_enable_restriction(!enable) != LOCATIONS_ERROR_NONE)
-           return -1;
+       if (location_manager_enable_restriction(!enable) != LOCATIONS_ERROR_NONE)
+               return -1;
 
-    return SetPolicyAllowed(context, "location", enable);
+       return SetPolicyAllowed(context, "location", enable);
 }
 
 int LocationPolicy::getLocationState()
 {
-    return IsPolicyAllowed(context, "location");
+       return IsPolicyAllowed(context, "location");
 }
 
 LocationPolicy locationPolicy(Server::instance());
index 98ecae9..06158b9 100644 (file)
@@ -38,91 +38,91 @@ void signalHandler(int signum)
 
 static bool daemonize(void)
 {
-    pid_t pid;
-
-    pid = ::fork();
-    if (pid == -1) {
-        std::cerr << "Fork failed" << std::endl;
-        return false;
-    } else if (pid != 0) {
-        exit(EXIT_SUCCESS);
-    }
-
-    if (::setsid() == -1) {
-        return false;
-    }
-
-    if (::chdir("/") == -1) {
-        return false;
-    }
-
-    int fd = ::open("/dev/null", O_RDWR);
-    if (fd == -1) {
-        return false;
-    }
-
-    for (int i = 0; i < 3; i++) {
-        if (::dup2(fd, i) == -1) {
-            ::close(fd);
-            return false;
-        }
-    }
-
-    ::close(fd);
-
-    return true;
+       pid_t pid;
+
+       pid = ::fork();
+       if (pid == -1) {
+               std::cerr << "Fork failed" << std::endl;
+               return false;
+       } else if (pid != 0) {
+               exit(EXIT_SUCCESS);
+       }
+
+       if (::setsid() == -1) {
+               return false;
+       }
+
+       if (::chdir("/") == -1) {
+               return false;
+       }
+
+       int fd = ::open("/dev/null", O_RDWR);
+       if (fd == -1) {
+               return false;
+       }
+
+       for (int i = 0; i < 3; i++) {
+               if (::dup2(fd, i) == -1) {
+                       ::close(fd);
+                       return false;
+               }
+       }
+
+       ::close(fd);
+
+       return true;
 }
 
 static void usage(const std::string& prog)
 {
-    std::cout << "Usage: " << prog << std::endl
-              << "-d            : daemonize" << std::endl
-              << "-l log-level  : chnage log level(default is 0)" << std::endl;
+       std::cout << "Usage: " << prog << std::endl
+                         << "-d            : daemonize" << std::endl
+                         << "-l log-level  : chnage log level(default is 0)" << std::endl;
 }
 
 int main(int argc, char *argv[])
 {
-    int opt, index, logLevel = 0;
-    bool runAsDaemon = false;
-    struct option options[] = {
-        {"daemonize", no_argument, 0, 'd'},
-        {"loglevel", required_argument, 0, 'l'},
-        {0, 0, 0, 0}
-    };
-
-    while ((opt = getopt_long(argc, argv, "dl:", options, &index)) != -1) {
-        switch (opt) {
-        case 'd':
-            runAsDaemon = true;
-            break;
-        case 'l':
-            logLevel = atoi(optarg);
-            break;
-        default:
-            std::cerr << "unknown" << std::endl;
-            usage(argv[0]);
-            exit(EXIT_FAILURE);
-        }
-    }
-
-    std::cout << "Daemonize: " << runAsDaemon << std::endl;
-    std::cout << "Log Level: " << logLevel << std::endl;
-
-    if (runAsDaemon && !daemonize()) {
-        exit(EXIT_FAILURE);
-    }
-
-    ::signal(SIGINT, signalHandler);
-
-    ::umask(0);
-
-    try {
-        Server& server = Server::instance();
-        server.run();
-    } catch (std::exception &e) {
-        std::cerr << e.what() << std::endl;
-        return 1;
-    }
-
-    return 0;
+       int opt, index, logLevel = 0;
+       bool runAsDaemon = false;
+       struct option options[] = {
+               {"daemonize", no_argument, 0, 'd'},
+               {"loglevel", required_argument, 0, 'l'},
+               {0, 0, 0, 0}
+       };
+
+       while ((opt = getopt_long(argc, argv, "dl:", options, &index)) != -1) {
+               switch (opt) {
+               case 'd':
+                       runAsDaemon = true;
+                       break;
+               case 'l':
+                       logLevel = atoi(optarg);
+                       break;
+               default:
+                       std::cerr << "unknown" << std::endl;
+                       usage(argv[0]);
+                       exit(EXIT_FAILURE);
+               }
+       }
+
+       std::cout << "Daemonize: " << runAsDaemon << std::endl;
+       std::cout << "Log Level: " << logLevel << std::endl;
+
+       if (runAsDaemon && !daemonize()) {
+               exit(EXIT_FAILURE);
+       }
+
+       ::signal(SIGINT, signalHandler);
+
+       ::umask(0);
+
+       try {
+               Server& server = Server::instance();
+               server.run();
+       } catch (std::exception &e) {
+               std::cerr << e.what() << std::endl;
+               return 1;
+       }
+
+       return 0;
 }
index f2045ff..43a2559 100644 (file)
 #
 
 SET(POLICY      ${POLICY}
-                bluetooth.cpp
-                location.cpp
-                password.cpp
-                zone.cpp
-                zone/zone.cpp
-                zone/app-proxy.cpp
-                zone/package-proxy.cpp
+                               bluetooth.cpp
+                               location.cpp
+                               password.cpp
+                               zone.cpp
+                               zone/zone.cpp
+                               zone/app-proxy.cpp
+                               zone/package-proxy.cpp
 )
 
 SET(DEPENDENCY  ${DEPENDENCY}
-                capi-location-manager
-                capi-network-bluetooth
-                auth-fw-admin
-                bluetooth-api
+                               capi-location-manager
+                               capi-network-bluetooth
+                               auth-fw-admin
+                               bluetooth-api
 )
index d927256..b3c4d5b 100644 (file)
 namespace {
 
 int PackageEventCallback(uid_t uid, int id, const char* type, const char* name,
-                         const char* key, const char* val, const void* msg, void* data)
+                                                const char* key, const char* val, const void* msg, void* data)
 {
-    return 0;
+       return 0;
 }
 
 int AppListCallback(pkgmgrinfo_appinfo_h handle, void *data)
 {
-    std::vector<ApplicationInfo>* appList = static_cast<std::vector<ApplicationInfo>*>(data);
-    appList->push_back(ApplicationInfo(handle));
+       std::vector<ApplicationInfo>* appList = static_cast<std::vector<ApplicationInfo>*>(data);
+       appList->push_back(ApplicationInfo(handle));
 
-    return 0;
+       return 0;
 }
 
 int PackageListCallback(pkgmgrinfo_pkginfo_h handle, void *data)
 {
-    char* pkgid = nullptr;
-    ::pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+       char* pkgid = nullptr;
+       ::pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
 
-    std::vector<std::string>* packageList = static_cast<std::vector<std::string>*>(data);
-    packageList->push_back(pkgid);
+       std::vector<std::string>* packageList = static_cast<std::vector<std::string>*>(data);
+       packageList->push_back(pkgid);
 
-    return 0;
+       return 0;
 }
 
 } // namespace
 
 PackageInfo::PackageInfo(const std::string& pkgid, uid_t uid) :
-    user(uid), handle(nullptr)
+       user(uid), handle(nullptr)
 {
-    if (uid == 0) {
-        uid = getuid();
-    }
+       if (uid == 0) {
+               uid = getuid();
+       }
 
-    if (::pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid.c_str(), user, &handle) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid Package Id");
-    }
+       if (::pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid.c_str(), user, &handle) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid Package Id");
+       }
 }
 
 PackageInfo::~PackageInfo()
 {
-    ::pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       ::pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
 }
 
 std::vector<ApplicationInfo> PackageInfo::getAppList() const
 {
-    std::vector<ApplicationInfo> appList;
+       std::vector<ApplicationInfo> appList;
 
-    if (::pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, AppListCallback, &appList, user) != PMINFO_R_OK) {
-        ERROR("Error in pkgmgrinfo_appinfo_get_usr_list");
-    }
+       if (::pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, AppListCallback, &appList, user) != PMINFO_R_OK) {
+               ERROR("Error in pkgmgrinfo_appinfo_get_usr_list");
+       }
 
-    return appList;
+       return appList;
 }
 
 std::string PackageInfo::getType() const
 {
-    char *pkgtype;
-    if (::pkgmgrinfo_pkginfo_get_type(handle, &pkgtype) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *pkgtype;
+       if (::pkgmgrinfo_pkginfo_get_type(handle, &pkgtype) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return pkgtype;
+       return pkgtype;
 }
 
 std::string PackageInfo::getLabel() const
 {
-    char *label;
-    if (::pkgmgrinfo_pkginfo_get_label(handle, &label) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *label;
+       if (::pkgmgrinfo_pkginfo_get_label(handle, &label) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return label;
+       return label;
 }
 
 std::string PackageInfo::getIcon() const
 {
-    char *icon;
-    if (::pkgmgrinfo_pkginfo_get_icon(handle, &icon) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *icon;
+       if (::pkgmgrinfo_pkginfo_get_icon(handle, &icon) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return icon;
+       return icon;
 }
 
 std::string PackageInfo::getDescription() const
 {
-    char *desc;
-    if (::pkgmgrinfo_pkginfo_get_description(handle, &desc) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *desc;
+       if (::pkgmgrinfo_pkginfo_get_description(handle, &desc) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return desc;
+       return desc;
 }
 
 std::string PackageInfo::getAuthorName() const
 {
-    char *name;
-    if (::pkgmgrinfo_pkginfo_get_author_name(handle, &name) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *name;
+       if (::pkgmgrinfo_pkginfo_get_author_name(handle, &name) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return name;
+       return name;
 }
 
 std::string PackageInfo::getAuthorEmail() const
 {
-    char *email;
-    if (::pkgmgrinfo_pkginfo_get_author_email(handle, &email) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *email;
+       if (::pkgmgrinfo_pkginfo_get_author_email(handle, &email) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return email;
+       return email;
 }
 
 std::string PackageInfo::getAuthorHref() const
 {
-    char *href;
-    if (::pkgmgrinfo_pkginfo_get_author_name(handle, &href) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *href;
+       if (::pkgmgrinfo_pkginfo_get_author_name(handle, &href) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return href;
+       return href;
 }
 
 std::string PackageInfo::getVersion() const
 {
-    char *version;
-    if (::pkgmgrinfo_pkginfo_get_version(handle, &version) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *version;
+       if (::pkgmgrinfo_pkginfo_get_version(handle, &version) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return version;
+       return version;
 }
 
 std::string PackageInfo::getApiVersion() const
 {
-    char *api;
-    if (::pkgmgrinfo_pkginfo_get_api_version(handle, &api) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *api;
+       if (::pkgmgrinfo_pkginfo_get_api_version(handle, &api) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return api;
+       return api;
 }
 
 std::string PackageInfo::getMainAppId() const
 {
-    char *mainappid;
-    if (::pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       char *mainappid;
+       if (::pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return mainappid;
+       return mainappid;
 }
 
 bool PackageInfo::isSystem() const
 {
-    bool ret;
-    if (::pkgmgrinfo_pkginfo_is_system(handle, &ret) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       bool ret;
+       if (::pkgmgrinfo_pkginfo_is_system(handle, &ret) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return ret;
+       return ret;
 }
 
 bool PackageInfo::isRemovable() const
 {
-    bool ret;
-    if (::pkgmgrinfo_pkginfo_is_removable(handle, &ret) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       bool ret;
+       if (::pkgmgrinfo_pkginfo_is_removable(handle, &ret) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return ret;
+       return ret;
 }
 
 bool PackageInfo::isPreload() const
 {
-    bool ret;
-    if (::pkgmgrinfo_pkginfo_is_preload(handle, &ret) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid operation");
-    }
+       bool ret;
+       if (::pkgmgrinfo_pkginfo_is_preload(handle, &ret) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid operation");
+       }
 
-    return ret;
+       return ret;
 }
 
 ApplicationInfo::ApplicationInfo(const std::string& aid, uid_t uid)
 {
-    pkgmgrinfo_appinfo_h handle;
+       pkgmgrinfo_appinfo_h handle;
 
-    if (::pkgmgrinfo_appinfo_get_usr_appinfo(aid.c_str(), uid, &handle) != PMINFO_R_OK) {
-        throw runtime::Exception("Invalid App Id");
-    }
+       if (::pkgmgrinfo_appinfo_get_usr_appinfo(aid.c_str(), uid, &handle) != PMINFO_R_OK) {
+               throw runtime::Exception("Invalid App Id");
+       }
 
-    load(handle);
+       load(handle);
 
-    ::pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       ::pkgmgrinfo_appinfo_destroy_appinfo(handle);
 }
 
 ApplicationInfo::ApplicationInfo(pkgmgrinfo_appinfo_h handle)
 {
-    load(handle);
+       load(handle);
 }
 
 
@@ -234,231 +234,231 @@ ApplicationInfo::~ApplicationInfo()
 }
 
 void ApplicationInfo::load(pkgmgrinfo_appinfo_h handle) {
-    pkgmgrinfo_app_component comp;
-    char* str;
-    int ret;
+       pkgmgrinfo_app_component comp;
+       char* str;
+       int ret;
 
-    ret = ::pkgmgrinfo_appinfo_get_appid(handle, &str);
-    if (ret == PMINFO_R_OK) {
-        id = str;
-    }
+       ret = ::pkgmgrinfo_appinfo_get_appid(handle, &str);
+       if (ret == PMINFO_R_OK) {
+               id = str;
+       }
 
-    ret = ::pkgmgrinfo_appinfo_get_pkgid(handle, &str);
-    if (ret == PMINFO_R_OK) {
-        package = str;
-    }
+       ret = ::pkgmgrinfo_appinfo_get_pkgid(handle, &str);
+       if (ret == PMINFO_R_OK) {
+               package = str;
+       }
 
-    ret = ::pkgmgrinfo_appinfo_get_apptype(handle, &str);
-    if (ret == PMINFO_R_OK) {
-        type = str;
-    }
+       ret = ::pkgmgrinfo_appinfo_get_apptype(handle, &str);
+       if (ret == PMINFO_R_OK) {
+               type = str;
+       }
 
-    ret = ::pkgmgrinfo_appinfo_get_icon(handle, &str);
-    if (ret == PMINFO_R_OK) {
-        icon = str;
-    }
+       ret = ::pkgmgrinfo_appinfo_get_icon(handle, &str);
+       if (ret == PMINFO_R_OK) {
+               icon = str;
+       }
 
-    ret = ::pkgmgrinfo_appinfo_get_label(handle, &str);
-    if (ret == PMINFO_R_OK) {
-        label = str;
-    }
+       ret = ::pkgmgrinfo_appinfo_get_label(handle, &str);
+       if (ret == PMINFO_R_OK) {
+               label = str;
+       }
 
-    ret = ::pkgmgrinfo_appinfo_get_component(handle, &comp);
-    if (ret == PMINFO_R_OK) {
-        componentType = static_cast<int>(comp);
-    }
+       ret = ::pkgmgrinfo_appinfo_get_component(handle, &comp);
+       if (ret == PMINFO_R_OK) {
+               componentType = static_cast<int>(comp);
+       }
 
-    ::pkgmgrinfo_appinfo_is_nodisplay(handle, &noDisplayed);
-    ::pkgmgrinfo_appinfo_is_taskmanage(handle, &taskManaged);
+       ::pkgmgrinfo_appinfo_is_nodisplay(handle, &noDisplayed);
+       ::pkgmgrinfo_appinfo_is_taskmanage(handle, &taskManaged);
 }
 
 const std::string& ApplicationInfo::getId() const
 {
-    return id;
+       return id;
 }
 
 const std::string& ApplicationInfo::getPackage() const
 {
-    return package;
+       return package;
 }
 
 const std::string& ApplicationInfo::getType() const
 {
-    return type;
+       return type;
 }
 
 const std::string& ApplicationInfo::getIcon() const
 {
-    return icon;
+       return icon;
 }
 
 const std::string& ApplicationInfo::getLabel() const
 {
-    return label;
+       return label;
 }
 
 int ApplicationInfo::getComponentType() const
 {
-    return componentType;
+       return componentType;
 }
 
 bool ApplicationInfo::isNoDisplayed() const
 {
-    return noDisplayed;
+       return noDisplayed;
 }
 
 bool ApplicationInfo::isTaskManaged() const
 {
-    return taskManaged;
+       return taskManaged;
 }
 
 PackageManager::PackageManager() :
-    nativeRequestHandle(nullptr), nativeListenHandle(nullptr)
+       nativeRequestHandle(nullptr), nativeListenHandle(nullptr)
 {
-    nativeRequestHandle = ::pkgmgr_client_new(PC_REQUEST);
-    if (nativeRequestHandle == nullptr) {
-        throw runtime::Exception("No package manager request instance");
-    }
+       nativeRequestHandle = ::pkgmgr_client_new(PC_REQUEST);
+       if (nativeRequestHandle == nullptr) {
+               throw runtime::Exception("No package manager request instance");
+       }
 
-    nativeListenHandle = ::pkgmgr_client_new(PC_LISTENING);
-    if (nativeListenHandle == nullptr) {
-        ::pkgmgr_client_free(nativeRequestHandle);
-        throw runtime::Exception("No package manager listening instance");
-    }
+       nativeListenHandle = ::pkgmgr_client_new(PC_LISTENING);
+       if (nativeListenHandle == nullptr) {
+               ::pkgmgr_client_free(nativeRequestHandle);
+               throw runtime::Exception("No package manager listening instance");
+       }
 }
 
 PackageManager::~PackageManager()
 {
-    ::pkgmgr_client_free(nativeRequestHandle);
-    ::pkgmgr_client_free(nativeListenHandle);
+       ::pkgmgr_client_free(nativeRequestHandle);
+       ::pkgmgr_client_free(nativeListenHandle);
 }
 
 PackageManager& PackageManager::instance()
 {
-    static PackageManager __instance__;
-    return __instance__;
+       static PackageManager __instance__;
+       return __instance__;
 }
 
 void PackageManager::setEventCallback(pkgmgrinfo_handler callback, void* user_data)
 {
-    int ret;
-    ret = ::pkgmgr_client_listen_status(nativeListenHandle, callback, user_data);
-    if (ret < 0) {
-        throw runtime::Exception("Failed to set package event callback");
-    }
+       int ret;
+       ret = ::pkgmgr_client_listen_status(nativeListenHandle, callback, user_data);
+       if (ret < 0) {
+               throw runtime::Exception("Failed to set package event callback");
+       }
 }
 
 void PackageManager::unsetEventCallback()
 {
-    int ret;
-    ret = ::pkgmgr_client_remove_listen_status(nativeListenHandle);
-    if (ret < 0) {
-        throw runtime::Exception("Failed to unset package event callback");
-    }
+       int ret;
+       ret = ::pkgmgr_client_remove_listen_status(nativeListenHandle);
+       if (ret < 0) {
+               throw runtime::Exception("Failed to unset package event callback");
+       }
 }
 
 void PackageManager::activatePackage(const std::string& pkgid, const uid_t user)
 {
-    PackageInfo package(pkgid, user);
+       PackageInfo package(pkgid, user);
 
-    if (::pkgmgr_client_usr_activate(nativeRequestHandle, package.getType().c_str(), pkgid.c_str(), user) != PKGMGR_R_OK) {
-        ERROR("Failed to activate package: " + pkgid);
-        throw runtime::Exception("Operation failed");
-    }
+       if (::pkgmgr_client_usr_activate(nativeRequestHandle, package.getType().c_str(), pkgid.c_str(), user) != PKGMGR_R_OK) {
+               ERROR("Failed to activate package: " + pkgid);
+               throw runtime::Exception("Operation failed");
+       }
 }
 
 void PackageManager::deactivatePackage(const std::string& pkgid, const uid_t user)
 {
-    PackageInfo package(pkgid, user);
+       PackageInfo package(pkgid, user);
 
-    int ret = pkgmgr_client_usr_deactivate(nativeRequestHandle, package.getType().c_str(), pkgid.c_str(), user);
-    if (ret != PKGMGR_R_OK) {
-        ERROR("Failed to deactivate package: " + std::to_string(ret));
-        throw runtime::Exception("Operation failed");
-    }
+       int ret = pkgmgr_client_usr_deactivate(nativeRequestHandle, package.getType().c_str(), pkgid.c_str(), user);
+       if (ret != PKGMGR_R_OK) {
+               ERROR("Failed to deactivate package: " + std::to_string(ret));
+               throw runtime::Exception("Operation failed");
+       }
 }
 
 void PackageManager::installPackage(const std::string& pkgpath, const uid_t user)
 {
-    int ret = ::pkgmgr_client_usr_install(nativeRequestHandle, NULL, NULL, pkgpath.c_str(), NULL, PM_QUIET, PackageEventCallback, nullptr, user);
-    if (ret < PKGMGR_R_OK) {
-        throw runtime::Exception("Package installation failed");
-    }
+       int ret = ::pkgmgr_client_usr_install(nativeRequestHandle, NULL, NULL, pkgpath.c_str(), NULL, PM_QUIET, PackageEventCallback, nullptr, user);
+       if (ret < PKGMGR_R_OK) {
+               throw runtime::Exception("Package installation failed");
+       }
 }
 
 void PackageManager::uninstallPackage(const std::string& pkgid, const uid_t user)
 {
-    std::string pkgtype;
+       std::string pkgtype;
 
-    PackageInfo pkgInfo(pkgid, user);
-    pkgtype = pkgInfo.getType();
+       PackageInfo pkgInfo(pkgid, user);
+       pkgtype = pkgInfo.getType();
 
-    int ret = ::pkgmgr_client_usr_uninstall(nativeRequestHandle, pkgtype.c_str(), pkgid.c_str(), PM_QUIET, PackageEventCallback, nullptr, user);
-    if (ret < PKGMGR_R_OK) {
-        ERROR("Error in pkgmgr_client_uninstall");
-        throw runtime::Exception("Package manager exception");
-    }
+       int ret = ::pkgmgr_client_usr_uninstall(nativeRequestHandle, pkgtype.c_str(), pkgid.c_str(), PM_QUIET, PackageEventCallback, nullptr, user);
+       if (ret < PKGMGR_R_OK) {
+               ERROR("Error in pkgmgr_client_uninstall");
+               throw runtime::Exception("Package manager exception");
+       }
 }
 
 void PackageManager::wipePackageData(const std::string& pkgid, const uid_t user)
 {
-    PackageInfo package(pkgid);
+       PackageInfo package(pkgid);
 
-    int ret = ::pkgmgr_client_usr_clear_user_data(nativeRequestHandle, package.getType().c_str(), pkgid.c_str(), PM_QUIET, user);
-    if (ret != PKGMGR_R_OK) {
-        ERROR("Error in pkgmgr_clear_user_data");
-        throw runtime::Exception("Operation failed");
-    }
+       int ret = ::pkgmgr_client_usr_clear_user_data(nativeRequestHandle, package.getType().c_str(), pkgid.c_str(), PM_QUIET, user);
+       if (ret != PKGMGR_R_OK) {
+               ERROR("Error in pkgmgr_clear_user_data");
+               throw runtime::Exception("Operation failed");
+       }
 }
 
 std::vector<std::string> PackageManager::getPackageList(const uid_t user)
 {
-    std::vector<std::string> packageList;
+       std::vector<std::string> packageList;
 
-    if (::pkgmgrinfo_pkginfo_get_usr_list(PackageListCallback, &packageList, user) != PMINFO_R_OK) {
-        ERROR("Error in pkgmgrinfo_pkginfo_get_list");
-    }
+       if (::pkgmgrinfo_pkginfo_get_usr_list(PackageListCallback, &packageList, user) != PMINFO_R_OK) {
+               ERROR("Error in pkgmgrinfo_pkginfo_get_list");
+       }
 
-    return packageList;
+       return packageList;
 }
 
 std::vector<ApplicationInfo> PackageManager::getAppList(const uid_t user)
 {
-    std::vector<ApplicationInfo> appList;
+       std::vector<ApplicationInfo> appList;
 
-    if (::pkgmgrinfo_appinfo_get_usr_installed_list(AppListCallback, user, &appList) != PMINFO_R_OK) {
-        ERROR("Error in pkgmgrinfo_appinfo_get_installed_list");
-    }
+       if (::pkgmgrinfo_appinfo_get_usr_installed_list(AppListCallback, user, &appList) != PMINFO_R_OK) {
+               ERROR("Error in pkgmgrinfo_appinfo_get_installed_list");
+       }
 
-    return appList;
+       return appList;
 }
 
 void PackageManager::setModeRestriction(int mode, uid_t user)
 {
-    if (::pkgmgr_client_usr_set_restriction_mode(nativeRequestHandle,
-                                                 mode,
-                                                 user) != PKGMGR_R_OK) {
-        throw runtime::Exception("Failed to set package restriction mode");
-    }
+       if (::pkgmgr_client_usr_set_restriction_mode(nativeRequestHandle,
+                                                                                                mode,
+                                                                                                user) != PKGMGR_R_OK) {
+               throw runtime::Exception("Failed to set package restriction mode");
+       }
 }
 
 void PackageManager::unsetModeRestriction(int mode, uid_t user)
 {
-    if (::pkgmgr_client_usr_unset_restriction_mode(nativeRequestHandle,
-                                                   mode,
-                                                   user) != PKGMGR_R_OK) {
-        throw runtime::Exception("Failed to unset package mode restriction");
-    }
+       if (::pkgmgr_client_usr_unset_restriction_mode(nativeRequestHandle,
+                                                                                                  mode,
+                                                                                                  user) != PKGMGR_R_OK) {
+               throw runtime::Exception("Failed to unset package mode restriction");
+       }
 }
 
 int PackageManager::getModeRestriction(uid_t user)
 {
-    int mode;
-    if (::pkgmgr_client_usr_get_restriction_mode(nativeRequestHandle,
-                                                 &mode,
-                                                 user) != PKGMGR_R_OK) {
-        throw runtime::Exception("Failed to get package restriction mode");
-    }
+       int mode;
+       if (::pkgmgr_client_usr_get_restriction_mode(nativeRequestHandle,
+                                                                                                &mode,
+                                                                                                user) != PKGMGR_R_OK) {
+               throw runtime::Exception("Failed to get package restriction mode");
+       }
 
-    return mode;
+       return mode;
 }
index da21106..8affe56 100644 (file)
 
 class ApplicationInfo {
 public:
-    ApplicationInfo(const std::string& aid, uid_t uid = 0);
-    ApplicationInfo(pkgmgrinfo_appinfo_h handle);
-    ~ApplicationInfo();
-
-    const std::string& getId() const;
-    const std::string& getPackage() const;
-    const std::string& getType() const;
-    const std::string& getIcon() const;
-    const std::string& getLabel() const;
-    int getComponentType() const;
-    bool isNoDisplayed() const;
-    bool isTaskManaged() const;
+       ApplicationInfo(const std::string& aid, uid_t uid = 0);
+       ApplicationInfo(pkgmgrinfo_appinfo_h handle);
+       ~ApplicationInfo();
+
+       const std::string& getId() const;
+       const std::string& getPackage() const;
+       const std::string& getType() const;
+       const std::string& getIcon() const;
+       const std::string& getLabel() const;
+       int getComponentType() const;
+       bool isNoDisplayed() const;
+       bool isTaskManaged() const;
 
 private:
-    void load(pkgmgrinfo_appinfo_h handle);
-
-    std::string id;
-    std::string package;
-    std::string type;
-    std::string icon;
-    std::string label;
-    int componentType;
-    bool noDisplayed;
-    bool taskManaged;
+       void load(pkgmgrinfo_appinfo_h handle);
+
+       std::string id;
+       std::string package;
+       std::string type;
+       std::string icon;
+       std::string label;
+       int componentType;
+       bool noDisplayed;
+       bool taskManaged;
 };
 
 class PackageInfo {
 public:
-    PackageInfo(const std::string& pkgid, uid_t uid = 0);
-    ~PackageInfo();
+       PackageInfo(const std::string& pkgid, uid_t uid = 0);
+       ~PackageInfo();
 
-    std::vector<ApplicationInfo> getAppList() const;
+       std::vector<ApplicationInfo> getAppList() const;
 
-    std::string getType() const;
-    std::string getIcon() const;
-    std::string getLabel() const;
-    std::string getDescription() const;
+       std::string getType() const;
+       std::string getIcon() const;
+       std::string getLabel() const;
+       std::string getDescription() const;
 
-    std::string getAuthorName() const;
-    std::string getAuthorEmail() const;
-    std::string getAuthorHref() const;
+       std::string getAuthorName() const;
+       std::string getAuthorEmail() const;
+       std::string getAuthorHref() const;
 
-    std::string getVersion() const;
-    std::string getApiVersion() const;
-    std::string getMainAppId() const;
+       std::string getVersion() const;
+       std::string getApiVersion() const;
+       std::string getMainAppId() const;
 
-    bool isSystem() const;
-    bool isRemovable() const;
-    bool isPreload() const;
+       bool isSystem() const;
+       bool isRemovable() const;
+       bool isPreload() const;
 
 private:
-    uid_t user;
-    pkgmgrinfo_pkginfo_h handle;
+       uid_t user;
+       pkgmgrinfo_pkginfo_h handle;
 };
 
 class PackageManager {
 public:
-    void activatePackage(const std::string& pkgid, const uid_t user);
-    void deactivatePackage(const std::string& pkgid, const uid_t user);
-    void installPackage(const std::string& pkgpath, const uid_t user);
-    void uninstallPackage(const std::string& pkgid, const uid_t user);
-    void wipePackageData(const std::string& pkgid, const uid_t user);
+       void activatePackage(const std::string& pkgid, const uid_t user);
+       void deactivatePackage(const std::string& pkgid, const uid_t user);
+       void installPackage(const std::string& pkgpath, const uid_t user);
+       void uninstallPackage(const std::string& pkgid, const uid_t user);
+       void wipePackageData(const std::string& pkgid, const uid_t user);
 
-    std::vector<std::string> getPackageList(const uid_t user);
-    std::vector<ApplicationInfo> getAppList(const uid_t user);
+       std::vector<std::string> getPackageList(const uid_t user);
+       std::vector<ApplicationInfo> getAppList(const uid_t user);
 
-    void setEventCallback(pkgmgrinfo_handler callback, void* user_data);
-    void unsetEventCallback();
+       void setEventCallback(pkgmgrinfo_handler callback, void* user_data);
+       void unsetEventCallback();
 
-    void setModeRestriction(int mode, uid_t user);
-    void unsetModeRestriction(int mode, uid_t user);
-    int getModeRestriction(uid_t user);
+       void setModeRestriction(int mode, uid_t user);
+       void unsetModeRestriction(int mode, uid_t user);
+       int getModeRestriction(uid_t user);
 
-    void setPackageRestriction(const std::string& pkgid, int mode, uid_t user);
-    void unsetPackageRestriction(const std::string& pkgid, int mode, uid_t user);
-    int getPackageRestriction(const std::string& pkgid, uid_t user);
+       void setPackageRestriction(const std::string& pkgid, int mode, uid_t user);
+       void unsetPackageRestriction(const std::string& pkgid, int mode, uid_t user);
+       int getPackageRestriction(const std::string& pkgid, uid_t user);
 
-    static PackageManager& instance();
+       static PackageManager& instance();
 
 private:
-    PackageManager();
-    ~PackageManager();
+       PackageManager();
+       ~PackageManager();
 
 private:
-    pkgmgr_client *nativeRequestHandle, *nativeListenHandle;
+       pkgmgr_client *nativeRequestHandle, *nativeListenHandle;
 };
 
 #endif // __DPM_PACKMAN_H__
index 212b712..bb936a8 100644 (file)
@@ -190,7 +190,7 @@ int transformQualityFromDPMToAuth(const int dpm_quality, password_quality_type &
 } // namespace
 
 PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
-    __context(ctxt)
+       __context(ctxt)
 {
        ctxt.registerParametricMethod(this, DPM_PRIVILEGE_PASSWORD, (int)(PasswordPolicy::setPasswordPolicyQuality)(int));
        ctxt.registerNonparametricMethod(this, "", (int)(PasswordPolicy::getPasswordPolicyQuality));
index 0dfbaf8..d61895e 100644 (file)
@@ -31,28 +31,28 @@ const std::string defaultPolicyTemplate = CONF_PATH "/policy/PolicyManifest.xml"
 }
 
 PolicyStorage::PolicyStorage(const std::string& path, bool create) :
-    location(path),
-    data(nullptr)
+       location(path),
+       data(nullptr)
 {
-    std::string& source = location;
-    if (create) {
-        struct stat st;
-        if ((stat(location.c_str(), &st) == -1)) {
-            if (errno == ENOENT) {
-                source = defaultPolicyTemplate;
-            } else {
-                throw runtime::Exception(runtime::GetSystemErrorMessage());
-            }
-        }
-    }
+       std::string& source = location;
+       if (create) {
+               struct stat st;
+               if ((stat(location.c_str(), &st) == -1)) {
+                       if (errno == ENOENT) {
+                               source = defaultPolicyTemplate;
+                       } else {
+                               throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       }
+               }
+       }
 
-    data = std::unique_ptr<xml::Document>(xml::Parser::parseFile(source));
-    xml::Node::NodeList nodes = data->evaluate("/manifest/policy-group/policy");
-    xml::Node::NodeList::iterator it = nodes.begin();
-    while (it != nodes.end()) {
-        policyMap.emplace(it->getProp("name"), std::move(*it));
-        ++it;
-    }
+       data = std::unique_ptr<xml::Document>(xml::Parser::parseFile(source));
+       xml::Node::NodeList nodes = data->evaluate("/manifest/policy-group/policy");
+       xml::Node::NodeList::iterator it = nodes.begin();
+       while (it != nodes.end()) {
+               policyMap.emplace(it->getProp("name"), std::move(*it));
+               ++it;
+       }
 }
 
 PolicyStorage::~PolicyStorage()
@@ -61,14 +61,14 @@ PolicyStorage::~PolicyStorage()
 
 Policy& PolicyStorage::getPolicy(const std::string& name)
 {
-    if (policyMap.count(name) == 0) {
-        throw runtime::Exception("Failed to find policy");
-    }
+       if (policyMap.count(name) == 0) {
+               throw runtime::Exception("Failed to find policy");
+       }
 
-    return policyMap.at(name);
+       return policyMap.at(name);
 }
 
 void PolicyStorage::flush()
 {
-    data->write(location, "UTF-8", true);
+       data->write(location, "UTF-8", true);
 }
index 3b2d243..c64eb12 100644 (file)
 
 class PolicyStorage {
 public:
-    PolicyStorage(const std::string& path, bool create = true);
-    ~PolicyStorage();
+       PolicyStorage(const std::string& path, bool create = true);
+       ~PolicyStorage();
 
-    PolicyStorage(const PolicyStorage&) = delete;
-    PolicyStorage& operator=(const PolicyStorage&) = delete;
+       PolicyStorage(const PolicyStorage&) = delete;
+       PolicyStorage& operator=(const PolicyStorage&) = delete;
 
-    Policy& getPolicy(const std::string& name);
+       Policy& getPolicy(const std::string& name);
 
-    void flush();
+       void flush();
 
 private:
-    std::string location;
-    std::unique_ptr<xml::Document> data;
-    std::unordered_map<std::string, Policy> policyMap;
+       std::string location;
+       std::unique_ptr<xml::Document> data;
+       std::unordered_map<std::string, Policy> policyMap;
 };
 
 #endif //__DPM_POLICY_STORAGE_H__
index 11482be..8862ebd 100644 (file)
@@ -17,7 +17,7 @@
 #include "policy.h"
 
 Policy::Policy(xml::Node&& node) :
-    data(std::move(node))
+       data(std::move(node))
 {
-    updateLock.reset(new std::mutex());
+       updateLock.reset(new std::mutex());
 }
index 628a1eb..042843d 100644 (file)
 
 class Policy {
 public:
-    Policy() = delete;
-    Policy(xml::Node&& node);
+       Policy() = delete;
+       Policy(xml::Node&& node);
 
-    const std::string getContent() const
-    {
-        return data.getContent();
-    }
+       const std::string getContent() const
+       {
+               return data.getContent();
+       }
 
-    void setContent(const std::string& content)
-    {
-        updateLock->lock();
-        data.setContent(content);
-        updateLock->unlock();
-    }
+       void setContent(const std::string& content)
+       {
+               updateLock->lock();
+               data.setContent(content);
+               updateLock->unlock();
+       }
 
 private:
-    xml::Node data;
-    std::unique_ptr<std::mutex> updateLock;
+       xml::Node data;
+       std::unique_ptr<std::mutex> updateLock;
 };
 
 #endif //__DPM_POLICY_H__
index ebb6e6c..b0914ba 100644 (file)
 #include "dbus/connection.h"
 
 #define PULSEAUDIO_LOGIN_INTERFACE          \
-    "org.pulseaudio.Server",                \
-    "/org/pulseaudio/StreamManager",        \
-    "org.pulseaudio.StreamManager"
+       "org.pulseaudio.Server",                \
+       "/org/pulseaudio/StreamManager",        \
+       "org.pulseaudio.StreamManager"
 
 #define DEVICED_SYSNOTI_INTERFACE           \
-    "org.tizen.system.deviced",             \
-    "/Org/Tizen/System/DeviceD/SysNoti",    \
-    "org.tizen.system.deviced.SysNoti",     \
-    "control"
+       "org.tizen.system.deviced",             \
+       "/Org/Tizen/System/DeviceD/SysNoti",    \
+       "org.tizen.system.deviced.SysNoti",     \
+       "control"
 
 #define MOBILEAP_INTERFACE                  \
-    "org.tizen.MobileapAgent",              \
-    "/MobileapAgent",                       \
-    "org.tizen.tethering"
+       "org.tizen.MobileapAgent",              \
+       "/MobileapAgent",                       \
+       "org.tizen.tethering"
 
 
 namespace DevicePolicyManager {
@@ -53,8 +53,8 @@ RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) :
        context.registerNonparametricMethod(this, "", (int)(RestrictionPolicy::getClipboardState));
        context.registerParametricMethod(this, DPM_PRIVILEGE_DEBUGGING, (int)(RestrictionPolicy::setUsbDebuggingState)(int));
        context.registerNonparametricMethod(this, "", (int)(RestrictionPolicy::getUsbDebuggingState));
-    context.registerParametricMethod(this, DPM_PRIVILEGE_USB, (int)(RestrictionPolicy::setUsbTetheringState)(int));
-    context.registerNonparametricMethod(this, "", (int)(RestrictionPolicy::getUsbTetheringState));
+       context.registerParametricMethod(this, DPM_PRIVILEGE_USB, (int)(RestrictionPolicy::setUsbTetheringState)(int));
+       context.registerNonparametricMethod(this, "", (int)(RestrictionPolicy::getUsbTetheringState));
        context.registerParametricMethod(this, DPM_PRIVILEGE_STORAGE, (int)(RestrictionPolicy::setExternalStorageState)(int));
        context.registerNonparametricMethod(this, "", (int)(RestrictionPolicy::getExternalStorageState));
        context.registerParametricMethod(this, DPM_PRIVILEGE_EMAIL, (int)(RestrictionPolicy::setPopImapEmailState)(int));
@@ -70,10 +70,10 @@ RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) :
        context.createNotification("microphone");
        context.createNotification("settings-changes");
        context.createNotification("usb-debugging");
-    context.createNotification("usb-tethering");
-    context.createNotification("popimap-email");
-    context.createNotification("messaging");
-    context.createNotification("browser");
+       context.createNotification("usb-tethering");
+       context.createNotification("popimap-email");
+       context.createNotification("messaging");
+       context.createNotification("browser");
 }
 
 RestrictionPolicy::~RestrictionPolicy()
@@ -82,143 +82,143 @@ RestrictionPolicy::~RestrictionPolicy()
 
 int RestrictionPolicy::setCameraState(int enable)
 {
-    return SetPolicyAllowed(context, "camera", enable);
+       return SetPolicyAllowed(context, "camera", enable);
 }
 
 int RestrictionPolicy::getCameraState()
 {
-    return IsPolicyAllowed(context, "camera");
+       return IsPolicyAllowed(context, "camera");
 }
 
 int RestrictionPolicy::setMicrophoneState(int enable)
 {
-    char *result = NULL;
-    try {
-        dbus::Connection &systemDBus = dbus::Connection::getSystem();
-        systemDBus.methodcall(PULSEAUDIO_LOGIN_INTERFACE,
-                              "UpdateRestriction",
-                              -1,
-                              "(s)",
-                              "(su)",
-                              "block_recording_media",
-                              enable).get("(s)", &result);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to enforce location policy");
-        return -1;
-    }
+       char *result = NULL;
+       try {
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.methodcall(PULSEAUDIO_LOGIN_INTERFACE,
+                                                         "UpdateRestriction",
+                                                         -1,
+                                                         "(s)",
+                                                         "(su)",
+                                                         "block_recording_media",
+                                                         enable).get("(s)", &result);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to enforce location policy");
+               return -1;
+       }
 
-    if (strcmp(result, "STREAM_MANAGER_RETURN_OK") == 0) {
-        return SetPolicyAllowed(context, "microphone", enable);
-    }
+       if (strcmp(result, "STREAM_MANAGER_RETURN_OK") == 0) {
+               return SetPolicyAllowed(context, "microphone", enable);
+       }
 
-    return -1;
+       return -1;
 }
 
 int RestrictionPolicy::getMicrophoneState()
 {
-    return IsPolicyAllowed(context, "microphone");
+       return IsPolicyAllowed(context, "microphone");
 }
 
 int RestrictionPolicy::setClipboardState(int enable)
 {
-    return SetPolicyAllowed(context, "clipboard", enable);
+       return SetPolicyAllowed(context, "clipboard", enable);
 }
 
 int RestrictionPolicy::getClipboardState()
 {
-    return IsPolicyAllowed(context, "clipboard");
+       return IsPolicyAllowed(context, "clipboard");
 }
 
 int RestrictionPolicy::setUsbDebuggingState(int enable)
 {
-    return SetPolicyAllowed(context, "usb-debugging", enable);
+       return SetPolicyAllowed(context, "usb-debugging", enable);
 }
 
 int RestrictionPolicy::getUsbDebuggingState()
 {
-    return IsPolicyAllowed(context, "usb-debugging");
+       return IsPolicyAllowed(context, "usb-debugging");
 }
 
 int RestrictionPolicy::setUsbTetheringState(bool enable)
 {
-    try {
-        dbus::Connection &systemDBus = dbus::Connection::getSystem();
-        systemDBus.methodcall(MOBILEAP_INTERFACE,
-                              "change_policy",
-                              -1,
-                              "",
-                              "(sb)",
-                              "usb-tethering",
-                              enable);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to change USB tethering state");
-        return -1;
-    }
+       try {
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.methodcall(MOBILEAP_INTERFACE,
+                                                         "change_policy",
+                                                         -1,
+                                                         "",
+                                                         "(sb)",
+                                                         "usb-tethering",
+                                                         enable);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to change USB tethering state");
+               return -1;
+       }
 
-    return SetPolicyAllowed(context, "usb-tethering", enable);
+       return SetPolicyAllowed(context, "usb-tethering", enable);
 }
 
 bool RestrictionPolicy::getUsbTetheringState()
 {
-    return IsPolicyAllowed(context, "usb-tethering");
+       return IsPolicyAllowed(context, "usb-tethering");
 }
 
 int RestrictionPolicy::setExternalStorageState(int enable)
 {
-    int ret;
-    try {
-        std::string pid(std::to_string(::getpid()));
-        std::string state(std::to_string(enable));
+       int ret;
+       try {
+               std::string pid(std::to_string(::getpid()));
+               std::string state(std::to_string(enable));
 
-        dbus::Connection &systemDBus = dbus::Connection::getSystem();
-        systemDBus.methodcall(DEVICED_SYSNOTI_INTERFACE,
-                              -1, "(i)", "(sisss)",
-                              "control", 3, pid.c_str(),"2", state.c_str()).get("(i)", &ret);
-    } catch(runtime::Exception& e) {
-        ERROR("Failed to enforce external storage policy");
-        return -1;
-    }
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.methodcall(DEVICED_SYSNOTI_INTERFACE,
+                                                         -1, "(i)", "(sisss)",
+                                                         "control", 3, pid.c_str(), "2", state.c_str()).get("(i)", &ret);
+       } catch(runtime::Exception& e) {
+               ERROR("Failed to enforce external storage policy");
+               return -1;
+       }
 
-    if (ret == 0) {
-        return SetPolicyAllowed(context, "external-storage", enable);
-    }
+       if (ret == 0) {
+               return SetPolicyAllowed(context, "external-storage", enable);
+       }
 
-    return -1;
+       return -1;
 }
 
 int RestrictionPolicy::getExternalStorageState()
 {
-    return IsPolicyAllowed(context, "external-storage");
+       return IsPolicyAllowed(context, "external-storage");
 }
 
 int RestrictionPolicy::setPopImapEmailState(int enable)
 {
-    return SetPolicyAllowed(context, "popimap-email", enable);
+       return SetPolicyAllowed(context, "popimap-email", enable);
 }
 
 int RestrictionPolicy::getPopImapEmailState()
 {
-    return IsPolicyAllowed(context, "popimap-email");
+       return IsPolicyAllowed(context, "popimap-email");
 }
 
 int RestrictionPolicy::setMessagingState(int enable)
 {
-    return SetPolicyAllowed(context, "messaging", enable);
+       return SetPolicyAllowed(context, "messaging", enable);
 }
 
 int RestrictionPolicy::getMessagingState()
 {
-    return IsPolicyAllowed(context, "messaging");
+       return IsPolicyAllowed(context, "messaging");
 }
 
 int RestrictionPolicy::setBrowserState(int enable)
 {
-    return SetPolicyAllowed(context, "browser", enable);
+       return SetPolicyAllowed(context, "browser", enable);
 }
 
 int RestrictionPolicy::getBrowserState()
 {
-    return IsPolicyAllowed(context, "browser");
+       return IsPolicyAllowed(context, "browser");
 }
 
 RestrictionPolicy restrictionPolicy(Server::instance());
index cc81e83..112c621 100755 (executable)
@@ -47,13 +47,13 @@ const std::string PROG_POWEROFF = "/usr/sbin/poweroff";
 } // namespace
 
 SecurityPolicy::SecurityPolicy(PolicyControlContext& ctxt) :
-    context(ctxt)
+       context(ctxt)
 {
-    ctxt.registerNonparametricMethod(this, DPM_PRIVILEGE_LOCK, (int)(SecurityPolicy::lockoutScreen));
-    ctxt.registerNonparametricMethod(this, "", (int)(SecurityPolicy::isInternalStorageEncrypted));
-    ctxt.registerNonparametricMethod(this, "", (int)(SecurityPolicy::isExternalStorageEncrypted));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_SECURITY, (int)(SecurityPolicy::setInternalStorageEncryption)(bool));
-    ctxt.registerParametricMethod(this, DPM_PRIVILEGE_SECURITY, (int)(SecurityPolicy::setExternalStorageEncryption)(bool));
+       ctxt.registerNonparametricMethod(this, DPM_PRIVILEGE_LOCK, (int)(SecurityPolicy::lockoutScreen));
+       ctxt.registerNonparametricMethod(this, "", (int)(SecurityPolicy::isInternalStorageEncrypted));
+       ctxt.registerNonparametricMethod(this, "", (int)(SecurityPolicy::isExternalStorageEncrypted));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_SECURITY, (int)(SecurityPolicy::setInternalStorageEncryption)(bool));
+       ctxt.registerParametricMethod(this, DPM_PRIVILEGE_SECURITY, (int)(SecurityPolicy::setExternalStorageEncryption)(bool));
 }
 
 SecurityPolicy::~SecurityPolicy()
@@ -62,81 +62,81 @@ SecurityPolicy::~SecurityPolicy()
 
 int SecurityPolicy::lockoutScreen()
 {
-    try {
-        Launchpad launchpad(context.getPeerUid());
-        launchpad.launch(APPID_LOCKSCREEN);
+       try {
+               Launchpad launchpad(context.getPeerUid());
+               launchpad.launch(APPID_LOCKSCREEN);
    } catch (runtime::Exception &e) {
-        ERROR("Failed to launch lockscreen: " + APPID_LOCKSCREEN);
-        return -1;
-    }
+               ERROR("Failed to launch lockscreen: " + APPID_LOCKSCREEN);
+               return -1;
+       }
 
-    return 0;
+       return 0;
 }
 
 int SecurityPolicy::setInternalStorageEncryption(bool encrypt)
 {
-    std::string policy = context.getPolicy("internal-storage-encryption");
-    if ((encrypt == true) && (policy == "encrypted")) {
-        return 0;
-    } else if ((encrypt == false) && (policy == "decrypted")) {
-        return 0;
-    }
-
-    try {
-        Bundle bundle;
-        bundle.add("viewtype", encrypt ? "ENCRYPT_DEVICE" : "DECRYPT_DEVICE");
-
-        Launchpad launchpad(context.getPeerUid());
-        launchpad.launch(APPID_DEVICE_ENCRYPTION, bundle);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to start device encryption");
-        return -1;
-    }
-
-    return 0;
+       std::string policy = context.getPolicy("internal-storage-encryption");
+       if ((encrypt == true) && (policy == "encrypted")) {
+               return 0;
+       } else if ((encrypt == false) && (policy == "decrypted")) {
+               return 0;
+       }
+
+       try {
+               Bundle bundle;
+               bundle.add("viewtype", encrypt ? "ENCRYPT_DEVICE" : "DECRYPT_DEVICE");
+
+               Launchpad launchpad(context.getPeerUid());
+               launchpad.launch(APPID_DEVICE_ENCRYPTION, bundle);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to start device encryption");
+               return -1;
+       }
+
+       return 0;
 }
 
 int SecurityPolicy::isInternalStorageEncrypted()
 {
-    std::string policy = context.getPolicy("internal-storage-encryption");
-    if (policy == "encrypted") {
-        return true;
-    }
+       std::string policy = context.getPolicy("internal-storage-encryption");
+       if (policy == "encrypted") {
+               return true;
+       }
 
-    return false;
+       return false;
 }
 
 int SecurityPolicy::setExternalStorageEncryption(bool encrypt)
 {
-    std::string policy = context.getPolicy("external-storage-encryption");
-    if ((encrypt == true) && (policy == "encrypted")) {
-        return 0;
-    } else if ((encrypt == false) && (policy == "decrypted")) {
-        return 0;
-    }
-
-    try {
-        Bundle bundle;
-        bundle.add("viewtype", encrypt ? "ENCRYPT_SD_CARD" : "DECRYPT_SD_CARD");
-
-        Launchpad launchpad(context.getPeerUid());
-        launchpad.launch(APPID_DEVICE_ENCRYPTION, bundle);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to start sd card encryption");
-        return -1;
-    }
-
-    return 0;
+       std::string policy = context.getPolicy("external-storage-encryption");
+       if ((encrypt == true) && (policy == "encrypted")) {
+               return 0;
+       } else if ((encrypt == false) && (policy == "decrypted")) {
+               return 0;
+       }
+
+       try {
+               Bundle bundle;
+               bundle.add("viewtype", encrypt ? "ENCRYPT_SD_CARD" : "DECRYPT_SD_CARD");
+
+               Launchpad launchpad(context.getPeerUid());
+               launchpad.launch(APPID_DEVICE_ENCRYPTION, bundle);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to start sd card encryption");
+               return -1;
+       }
+
+       return 0;
 }
 
 int SecurityPolicy::isExternalStorageEncrypted()
 {
-    std::string policy = context.getPolicy("external-storage-encryption");
-    if (policy == "encrypted") {
-        return true;
-    }
+       std::string policy = context.getPolicy("external-storage-encryption");
+       if (policy == "encrypted") {
+               return true;
+       }
 
-    return false;
+       return false;
 }
 
 SecurityPolicy securityPolicy(Server::instance());
index 6bfce52..bdb0be7 100644 (file)
@@ -30,14 +30,14 @@ const std::string POLICY_MANAGER_ADDRESS = "/tmp/.device-policy-manager";
 
 Server::Server()
 {
-    policyStorage.reset(new PolicyStorage("/opt/etc/dpm/policy/PolicyManifest.xml"));
+       policyStorage.reset(new PolicyStorage("/opt/etc/dpm/policy/PolicyManifest.xml"));
 
-    service.reset(new rmi::Service(POLICY_MANAGER_ADDRESS));
+       service.reset(new rmi::Service(POLICY_MANAGER_ADDRESS));
 
-    service->setPrivilegeChecker(std::bind(&Server::checkPeerPrivilege, this, _1, _2));
+       service->setPrivilegeChecker(std::bind(&Server::checkPeerPrivilege, this, _1, _2));
 
-    service->registerParametricMethod(this, "", (FileDescriptor)(Server::registerNotificationSubscriber)(std::string));
-    service->registerParametricMethod(this, "", (int)(Server::unregisterNotificationSubscriber)(std::string, int));
+       service->registerParametricMethod(this, "", (FileDescriptor)(Server::registerNotificationSubscriber)(std::string));
+       service->registerParametricMethod(this, "", (int)(Server::unregisterNotificationSubscriber)(std::string, int));
 }
 
 Server::~Server()
@@ -46,88 +46,88 @@ Server::~Server()
 
 void Server::run()
 {
-    // Prepare execution environment
-    service->start(true);
+       // Prepare execution environment
+       service->start(true);
 }
 
 void Server::terminate()
 {
-    service->stop();
+       service->stop();
 }
 
 FileDescriptor Server::registerNotificationSubscriber(const std::string& name)
 {
-    return FileDescriptor(service->subscribeNotification(name), true);
+       return FileDescriptor(service->subscribeNotification(name), true);
 }
 
 int Server::unregisterNotificationSubscriber(const std::string& name, int id)
 {
-    return service->unsubscribeNotification(name, id);
+       return service->unsubscribeNotification(name, id);
 }
 
 int Server::updatePolicy(const std::string& name, const std::string& value,
-                         const std::string& event, const std::string& info)
+                                                const std::string& event, const std::string& info)
 {
-    try {
-        Policy& policy = policyStorage->getPolicy(name);
-        std::string old = policy.getContent();
-        policy.setContent(value);
-        if (old != value) {
-            if (event != "") {
-                service->notify(event, info);
-            }
-
-            policyStorage->flush();
-        }
-    } catch (runtime::Exception& e) {
-        ERROR("Exception on access to policy: " + name);
-        return -1;
-    }
-
-    return 0;
+       try {
+               Policy& policy = policyStorage->getPolicy(name);
+               std::string old = policy.getContent();
+               policy.setContent(value);
+               if (old != value) {
+                       if (event != "") {
+                               service->notify(event, info);
+                       }
+
+                       policyStorage->flush();
+               }
+       } catch (runtime::Exception& e) {
+               ERROR("Exception on access to policy: " + name);
+               return -1;
+       }
+
+       return 0;
 }
 
 int Server::updatePolicy(const std::string& name, const std::string& value)
 {
-    return updatePolicy(name, value, name, value);
+       return updatePolicy(name, value, name, value);
 }
 
 std::string Server::getPolicy(const std::string& name) const
 {
-    return policyStorage->getPolicy(name).getContent();
+       return policyStorage->getPolicy(name).getContent();
 }
 
 bool Server::checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege)
 {
-    cynara *p_cynara;
+       cynara *p_cynara;
 
-    DEBUG("Peer security: " + cred.security);
+       DEBUG("Peer security: " + cred.security);
 
-    if (privilege.empty()) {
-        return true;
-    }
+       if (privilege.empty()) {
+               return true;
+       }
 
-    if (::cynara_initialize(&p_cynara, NULL) != CYNARA_API_SUCCESS) {
-        ERROR("Failure in cynara API");
-        return false;
-    }
+       if (::cynara_initialize(&p_cynara, NULL) != CYNARA_API_SUCCESS) {
+               ERROR("Failure in cynara API");
+               return false;
+       }
 
-    if (::cynara_check(p_cynara, cred.security.c_str(), "",
-                       std::to_string(cred.uid).c_str(),
-                       privilege.c_str()) != CYNARA_API_ACCESS_ALLOWED) {
-        ::cynara_finish(p_cynara);
-        ERROR("Access denied: " + cred.security + " : " + privilege);
-        return false;
-    }
+       if (::cynara_check(p_cynara, cred.security.c_str(), "",
+                                          std::to_string(cred.uid).c_str(),
+                                          privilege.c_str()) != CYNARA_API_ACCESS_ALLOWED) {
+               ::cynara_finish(p_cynara);
+               ERROR("Access denied: " + cred.security + " : " + privilege);
+               return false;
+       }
 
-    ::cynara_finish(p_cynara);
+       ::cynara_finish(p_cynara);
 
-    return true;
+       return true;
 }
 
 Server& Server::instance()
 {
-    static Server _instance_;
+       static Server _instance_;
 
-    return _instance_;
+       return _instance_;
 }
index c616efb..2ab2be1 100644 (file)
 
 class Server {
 public:
-    void run();
-    void terminate();
+       void run();
+       void terminate();
 
-    template<typename Type, typename... Args>
-    void setMethodHandler(const std::string& privilege, const std::string& method,
-                          const typename rmi::MethodHandler<Type, Args...>::type& handler)
-    {
-        service->setMethodHandler<Type, Args...>(privilege, method, handler);
-    }
+       template<typename Type, typename... Args>
+       void setMethodHandler(const std::string& privilege, const std::string& method,
+                                                 const typename rmi::MethodHandler<Type, Args...>::type& handler)
+       {
+               service->setMethodHandler<Type, Args...>(privilege, method, handler);
+       }
 
-    template <typename... Args>
+       template <typename... Args>
        void notify(const std::string& name, Args&&... args)
-    {
-        service->notify<Args...>(name, std::forward<Args>(args)...);
-    }
+       {
+               service->notify<Args...>(name, std::forward<Args>(args)...);
+       }
 
-    uid_t getPeerUid() const
-    {
-        return service->getPeerUid();
-    }
+       uid_t getPeerUid() const
+       {
+               return service->getPeerUid();
+       }
 
-    gid_t getPeerGid() const
-    {
-        return service->getPeerGid();
-    }
+       gid_t getPeerGid() const
+       {
+               return service->getPeerGid();
+       }
 
-    pid_t getPeerPid() const
-    {
-        return service->getPeerPid();
-    }
+       pid_t getPeerPid() const
+       {
+               return service->getPeerPid();
+       }
 
-    void createNotification(const std::string& name)
-    {
-        service->createNotification(name);
-    }
+       void createNotification(const std::string& name)
+       {
+               service->createNotification(name);
+       }
 
-    int updatePolicy(const std::string& name, const std::string& value);
-    int updatePolicy(const std::string& name, const std::string& value,
-                     const std::string& event, const std::string& info);
-    std::string getPolicy(const std::string& name) const;
+       int updatePolicy(const std::string& name, const std::string& value);
+       int updatePolicy(const std::string& name, const std::string& value,
+                                        const std::string& event, const std::string& info);
+       std::string getPolicy(const std::string& name) const;
 
-    FileDescriptor registerNotificationSubscriber(const std::string& name);
-    int unregisterNotificationSubscriber(const std::string& name, int id);
+       FileDescriptor registerNotificationSubscriber(const std::string& name);
+       int unregisterNotificationSubscriber(const std::string& name, int id);
 
-    bool checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege);
+       bool checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege);
 
-    static Server& instance();
+       static Server& instance();
 
 private:
-    Server();
-    ~Server();
+       Server();
+       ~Server();
 
-    std::string securityLabel;
-    std::unique_ptr<PolicyStorage> policyStorage;
-    std::unique_ptr<rmi::Service> service;
+       std::string securityLabel;
+       std::unique_ptr<PolicyStorage> policyStorage;
+       std::unique_ptr<rmi::Service> service;
 };
 
 #endif //__DPM_SERVER_H__
index 2369a43..1323403 100644 (file)
@@ -39,72 +39,71 @@ const std::string PROG_FACTORY_RESET = "/usr/bin/factory-reset";
 
 std::vector<std::string> getStorageDeviceList(const std::string& type)
 {
-    int intparams[6];
-    char* strparams[7];
-    std::vector<std::string> storages;
-
-    dbus::Connection &systemDBus = dbus::Connection::getSystem();
-    const dbus::Variant &var = systemDBus.methodcall("org.tizen.system.storage",
-                                                     "/Org/Tizen/System/Storage/Block/Manager",
-                                                     "org.tizen.system.storage.BlockManager",
-                                                     "GetDeviceList",
-                                                     -1,
-                                                     "(a(issssssisibii))",
-                                                     "(s)",
-                                                     type.c_str());
-    dbus::VariantIterator it;
-    var.get("(a(issssssisibii))", &it);
-    while (it.get("(issssssisibii)",
-                  &intparams[0], // block type: 0 - scsi, 1 : mmc
-                  &strparams[0], // devnode
-                  &strparams[1], // syspath
-                  &strparams[2], // usage
-                  &strparams[3], // fs type
-                  &strparams[4], // fs version
-                  &strparams[5], // fs uuid enc
-                  &intparams[1], // readonly: 0 - rw, 1 - ro
-                  &strparams[6], // mount point
-                  &intparams[2], // state: 0 - unmount, 1 - mount
-                  &intparams[3], // primary: 0 - flase, 1 - true
-                  &intparams[4], // flags: 1 - unmounted
-                                 //        2 - broken filesystem
-                                 //        4 - no filesystem
-                                 //        8 - not supported
-                                 //       16 - readonly
-                  &intparams[5])) { // strage id
-
-        storages.push_back(strrchr(strparams[0], '/') + 1);
-        for (int i = 0; i < 7; i++) {
-            if (strparams[i]) {
-                ::free(strparams[i]);
-            }
-        }
-    }
-
-    return storages;
+       int intparams[6];
+       char* strparams[7];
+       std::vector<std::string> storages;
+
+       dbus::Connection &systemDBus = dbus::Connection::getSystem();
+       const dbus::Variant &var = systemDBus.methodcall("org.tizen.system.storage",
+                                                                                                        "/Org/Tizen/System/Storage/Block/Manager",
+                                                                                                        "org.tizen.system.storage.BlockManager",
+                                                                                                        "GetDeviceList",
+                                                                                                        -1,
+                                                                                                        "(a(issssssisibii))",
+                                                                                                        "(s)",
+                                                                                                        type.c_str());
+       dbus::VariantIterator it;
+       var.get("(a(issssssisibii))", &it);
+       while (it.get("(issssssisibii)",
+                                 &intparams[0], // block type: 0 - scsi, 1 : mmc
+                                 &strparams[0], // devnode
+                                 &strparams[1], // syspath
+                                 &strparams[2], // usage
+                                 &strparams[3], // fs type
+                                 &strparams[4], // fs version
+                                 &strparams[5], // fs uuid enc
+                                 &intparams[1], // readonly: 0 - rw, 1 - ro
+                                 &strparams[6], // mount point
+                                 &intparams[2], // state: 0 - unmount, 1 - mount
+                                 &intparams[3], // primary: 0 - flase, 1 - true
+                                 &intparams[4], // flags: 1 - unmounted
+                                                                //        2 - broken filesystem
+                                                                //        4 - no filesystem
+                                                                //        8 - not supported
+                                                                //       16 - readonly
+                                 &intparams[5])) { // strage id
+               storages.push_back(strrchr(strparams[0], '/') + 1);
+               for (int i = 0; i < 7; i++) {
+                       if (strparams[i]) {
+                               ::free(strparams[i]);
+                       }
+               }
+       }
+
+       return storages;
 }
 
 void requestDeviceFormat(const std::string& devnode, int option)
 {
-    int ret;
-    dbus::Connection &systemDBus = dbus::Connection::getSystem();
-    systemDBus.methodcall("org.tizen.system.storage",
-                          "/Org/Tizen/System/Storage/Block/Devices/" + devnode,
-                          "org.tizen.system.storage.Block",
-                          "Format",
-                          G_MAXINT,
-                          "(i)",
-                          "(i)",
-                          option).get("(i)", &ret);
-    if (ret != 0) {
-        throw runtime::Exception("Failed to format " + devnode);
-    }
+       int ret;
+       dbus::Connection &systemDBus = dbus::Connection::getSystem();
+       systemDBus.methodcall("org.tizen.system.storage",
+                                                 "/Org/Tizen/System/Storage/Block/Devices/" + devnode,
+                                                 "org.tizen.system.storage.Block",
+                                                 "Format",
+                                                 G_MAXINT,
+                                                 "(i)",
+                                                 "(i)",
+                                                 option).get("(i)", &ret);
+       if (ret != 0) {
+               throw runtime::Exception("Failed to format " + devnode);
+       }
 }
 
 } // namespace
 
 StoragePolicy::StoragePolicy(PolicyControlContext& ctx) :
-    context(ctx)
+       context(ctx)
 {
        context.registerParametricMethod(this, DPM_PRIVILEGE_WIPE, (int)(StoragePolicy::wipeData)(int));
 }
@@ -115,36 +114,36 @@ StoragePolicy::~StoragePolicy()
 
 int StoragePolicy::wipeData(int id)
 {
-    auto worker = [id]() {
-        if (id & WIPE_INTERNAL_STORAGE) {
-            runtime::Process proc(PROG_FACTORY_RESET);
-            if (proc.execute() != 0) {
-                ERROR("Failed to launch factory-reset");
-                return -1;
-            }
-        }
-
-        if (id & WIPE_EXTERNAL_STORAGE) {
-            try {
-                std::vector<std::string> devices = getStorageDeviceList("mmc");
-                for (const std::string& devnode : devices) {
-                    std::cout << "Erase device: " << devnode << std::endl;
-                    requestDeviceFormat(devnode, 1);
-                    std::cout << "Erase device: " << devnode << " completed" << std::endl;
-                }
-            } catch(runtime::Exception& e) {
-                ERROR("Failed to enforce external storage policy");
-                return -1;
-            }
-        }
-
-        return 0;
-    };
-
-    std::thread deviceWiper(worker);
-    deviceWiper.detach();
-
-    return 0;
+       auto worker = [id]() {
+               if (id & WIPE_INTERNAL_STORAGE) {
+                       runtime::Process proc(PROG_FACTORY_RESET);
+                       if (proc.execute() != 0) {
+                               ERROR("Failed to launch factory-reset");
+                               return -1;
+                       }
+               }
+
+               if (id & WIPE_EXTERNAL_STORAGE) {
+                       try {
+                               std::vector<std::string> devices = getStorageDeviceList("mmc");
+                               for (const std::string& devnode : devices) {
+                                       std::cout << "Erase device: " << devnode << std::endl;
+                                       requestDeviceFormat(devnode, 1);
+                                       std::cout << "Erase device: " << devnode << " completed" << std::endl;
+                               }
+                       } catch(runtime::Exception& e) {
+                               ERROR("Failed to enforce external storage policy");
+                               return -1;
+                       }
+               }
+
+               return 0;
+       };
+
+       std::thread deviceWiper(worker);
+       deviceWiper.detach();
+
+       return 0;
 }
 
 StoragePolicy storagePolicy(Server::instance());
index ddbb36e..950cf6f 100644 (file)
 # limitations under the License.
 #
 SET(POLICY      ${POLICY}
-                bluetooth.cpp
-                location.cpp
-                password.cpp
+                               bluetooth.cpp
+                               location.cpp
+                               password.cpp
 )
 
 SET(DEPENDENCY  ${DEPENDENCY}
-                capi-location-manager
-                capi-network-bluetooth
-                auth-fw-admin
-                bluetooth-api
+                               capi-location-manager
+                               capi-network-bluetooth
+                               auth-fw-admin
+                               bluetooth-api
 )
-
index ee52d32..ed8f0e3 100644 (file)
@@ -13,8 +13,8 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  */
-#include <arpa/inet.h>
 
+#include <arpa/inet.h>
 #include <cstdlib>
 #include <functional>
 #include <unordered_set>
@@ -52,47 +52,47 @@ std::unordered_set<std::string> blockSsidList;
 
 inline void applyBlocklist(wifi_ap_h ap)
 {
-    char *ssid;
-    ::wifi_ap_get_essid(ap, &ssid);
-    if (blockSsidList.find(ssid) != blockSsidList.end()) {
-        ::wifi_forget_ap(ap);
-    }
+       char *ssid;
+       ::wifi_ap_get_essid(ap, &ssid);
+       if (blockSsidList.find(ssid) != blockSsidList.end()) {
+               ::wifi_forget_ap(ap);
+       }
 
-    ::free(ssid);
+       ::free(ssid);
 }
 
 void connectionStateChanged(wifi_connection_state_e state,
-                                   wifi_ap_h ap, void *user_data)
+                                                                  wifi_ap_h ap, void *user_data)
 {
-    WifiPolicy* policy = reinterpret_cast<WifiPolicy*>(user_data);
+       WifiPolicy* policy = reinterpret_cast<WifiPolicy*>(user_data);
 
-    if (state == WIFI_CONNECTION_STATE_FAILURE ||
-        state == WIFI_CONNECTION_STATE_DISCONNECTED) {
-        return;
-    }
+       if (state == WIFI_CONNECTION_STATE_FAILURE ||
+               state == WIFI_CONNECTION_STATE_DISCONNECTED) {
+               return;
+       }
 
-    if (!policy->isNetworkAccessRestricted()) {
-        return;
+       if (!policy->isNetworkAccessRestricted()) {
+               return;
        }
 
-    applyBlocklist(ap);
+       applyBlocklist(ap);
 }
 
 inline void applyBlocklistToConnectedAP()
 {
-    wifi_ap_h ap;
+       wifi_ap_h ap;
 
-    ::wifi_initialize();
-    if (::wifi_get_connected_ap(&ap) == WIFI_ERROR_NONE) {
-        applyBlocklist(ap);
-        ::wifi_ap_destroy(ap);
-    }
+       ::wifi_initialize();
+       if (::wifi_get_connected_ap(&ap) == WIFI_ERROR_NONE) {
+               applyBlocklist(ap);
+               ::wifi_ap_destroy(ap);
+       }
 }
 
 } // namespace
 
 WifiPolicy::WifiPolicy(PolicyControlContext& ctx) :
-    context(ctx)
+       context(ctx)
 {
        context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::setState)(bool));
        context.registerNonparametricMethod(this, "", (bool)(WifiPolicy::getState));
@@ -100,141 +100,141 @@ WifiPolicy::WifiPolicy(PolicyControlContext& ctx) :
        context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::setHotspotState)(bool));
        context.registerNonparametricMethod(this, "", (bool)(WifiPolicy::getHotspotState));
 
-    context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::setProfileChangeRestriction)(bool));
-    context.registerNonparametricMethod(this, "", (bool)(WifiPolicy::isProfileChangeRestricted));
+       context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::setProfileChangeRestriction)(bool));
+       context.registerNonparametricMethod(this, "", (bool)(WifiPolicy::isProfileChangeRestricted));
 
-    context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::setNetworkAccessRestriction)(bool));
-    context.registerNonparametricMethod(this, "", (bool)(WifiPolicy::isNetworkAccessRestricted));
-    context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::addSsidToBlocklist)(std::string));
-    context.registerParametricMethod(this, "", (int)(WifiPolicy::removeSsidFromBlocklist)(std::string));
+       context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::setNetworkAccessRestriction)(bool));
+       context.registerNonparametricMethod(this, "", (bool)(WifiPolicy::isNetworkAccessRestricted));
+       context.registerParametricMethod(this, DPM_PRIVILEGE_WIFI, (int)(WifiPolicy::addSsidToBlocklist)(std::string));
+       context.registerParametricMethod(this, "", (int)(WifiPolicy::removeSsidFromBlocklist)(std::string));
 
        context.createNotification("wifi");
        context.createNotification("wifi-hotspot");
-    context.createNotification("wifi-profile-change");
-    context.createNotification("wifi-ssid-restriction");
+       context.createNotification("wifi-profile-change");
+       context.createNotification("wifi-ssid-restriction");
 
-    ::wifi_initialize();
-    ::wifi_set_connection_state_changed_cb(connectionStateChanged, this);
+       ::wifi_initialize();
+       ::wifi_set_connection_state_changed_cb(connectionStateChanged, this);
 }
 
 WifiPolicy::~WifiPolicy()
 {
-    ::wifi_unset_connection_state_changed_cb();
+       ::wifi_unset_connection_state_changed_cb();
 }
 
 int WifiPolicy::setState(bool enable)
 {
        try {
-           dbus::Connection &systemDBus = dbus::Connection::getSystem();
-           systemDBus.methodcall(NETCONFIG_INTERFACE,
-                                 "DevicePolicySetWifi",
-                                 -1,
-                                 "",
-                                 "(i)",
-                                 enable);
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.methodcall(NETCONFIG_INTERFACE,
+                                                         "DevicePolicySetWifi",
+                                                         -1,
+                                                         "",
+                                                         "(i)",
+                                                         enable);
        } catch (runtime::Exception& e) {
                ERROR("Failed to chaneg Wi-Fi state");
                return -1;
        }
 
        SetPolicyAllowed(context, "wifi", enable);
-    return 0;
+       return 0;
 }
 
 bool WifiPolicy::getState()
 {
-    return IsPolicyAllowed(context, "wifi");
+       return IsPolicyAllowed(context, "wifi");
 }
 
 int WifiPolicy::setHotspotState(bool enable)
 {
        try {
-           dbus::Connection &systemDBus = dbus::Connection::getSystem();
-           systemDBus.methodcall(MOBILEAP_INTERFACE,
-                                 "change_policy",
-                                 -1,
-                                 "",
-                                 "(sb)",
-                                 "wifi-hotspot",
-                                 enable);
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.methodcall(MOBILEAP_INTERFACE,
+                                                         "change_policy",
+                                                         -1,
+                                                         "",
+                                                         "(sb)",
+                                                         "wifi-hotspot",
+                                                         enable);
        } catch (runtime::Exception& e) {
                ERROR("Failed to change Wi-Fi hotspot state");
                return -1;
        }
 
-    SetPolicyAllowed(context, "wifi-hotspot", enable);
-    return 0;
+       SetPolicyAllowed(context, "wifi-hotspot", enable);
+       return 0;
 }
 
 bool WifiPolicy::getHotspotState()
 {
-    return IsPolicyAllowed(context, "wifi-hotspot");
+       return IsPolicyAllowed(context, "wifi-hotspot");
 }
 
 int WifiPolicy::setProfileChangeRestriction(bool enable)
 {
        try {
-           dbus::Connection &systemDBus = dbus::Connection::getSystem();
-           systemDBus.methodcall(NETCONFIG_INTERFACE,
-                                 "DevicePolicySetWifiProfile",
-                                 -1,
-                                 "",
-                                 "(i)",
-                                 enable);
+               dbus::Connection &systemDBus = dbus::Connection::getSystem();
+               systemDBus.methodcall(NETCONFIG_INTERFACE,
+                                                         "DevicePolicySetWifiProfile",
+                                                         -1,
+                                                         "",
+                                                         "(i)",
+                                                         enable);
        } catch (runtime::Exception& e) {
                ERROR("Failed to set Wi-Fi profile change restriction");
        }
 
-    SetPolicyAllowed(context, "wifi-profile-change", enable);
-    return 0;
+       SetPolicyAllowed(context, "wifi-profile-change", enable);
+       return 0;
 }
 
 bool WifiPolicy::isProfileChangeRestricted(void)
 {
-    return IsPolicyAllowed(context, "wifi-profile-change");
+       return IsPolicyAllowed(context, "wifi-profile-change");
 }
 
 int WifiPolicy::setNetworkAccessRestriction(bool enable)
 {
-    SetPolicyEnabled(context, "wifi-ssid-restriction", enable);
+       SetPolicyEnabled(context, "wifi-ssid-restriction", enable);
 
-    if (enable) {
-        applyBlocklistToConnectedAP();
-    }
+       if (enable) {
+               applyBlocklistToConnectedAP();
+       }
 
-    return 0;
+       return 0;
 }
 
 bool WifiPolicy::isNetworkAccessRestricted(void)
 {
-    return IsPolicyEnabled(context, "wifi-ssid-restriction");
+       return IsPolicyEnabled(context, "wifi-ssid-restriction");
 }
 
 int WifiPolicy::addSsidToBlocklist(const std::string& ssid)
 {
-    try {
-        blockSsidList.insert(ssid);
-        if (IsPolicyEnabled(context, "wifi-ssid-restriction")) {
-            applyBlocklistToConnectedAP();
-        }
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to allocate memory for wifi blocklist");
-        return -1;
-    }
-
-    return 0;
+       try {
+               blockSsidList.insert(ssid);
+               if (IsPolicyEnabled(context, "wifi-ssid-restriction")) {
+                       applyBlocklistToConnectedAP();
+               }
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to allocate memory for wifi blocklist");
+               return -1;
+       }
+
+       return 0;
 }
 
 int WifiPolicy::removeSsidFromBlocklist(const std::string& ssid)
 {
-    std::unordered_set<std::string>::iterator it = blockSsidList.find(ssid);
+       std::unordered_set<std::string>::iterator it = blockSsidList.find(ssid);
 
-    if (it == blockSsidList.end()) {
-        return -1;
+       if (it == blockSsidList.end()) {
+               return -1;
        }
 
-    blockSsidList.erase(it);
-    return 0;
+       blockSsidList.erase(it);
+       return 0;
 }
 
 WifiPolicy wifiPolicy(Server::instance());
index 56e847e..04f4f01 100755 (executable)
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  */
-#include <regex>
-#include <algorithm>
 
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/inotify.h>
 
+#include <regex>
+#include <algorithm>
+
 #include <tzplatform_config.h>
 
 #include "zone.hxx"
@@ -44,33 +45,33 @@ std::regex zoneNamePattern(NAME_PATTERN);
 }
 
 bool isAllowedName(const std::string& name) {
-    if (!std::regex_match(name, zoneNamePattern)) {
-        return false;
-    }
+       if (!std::regex_match(name, zoneNamePattern)) {
+               return false;
+       }
 
-    bool exists = false;
-    try {
-        runtime::User user(name);
-        exists = true;
-    } catch (runtime::Exception& e) {}
+       bool exists = false;
+       try {
+               runtime::User user(name);
+               exists = true;
+       } catch (runtime::Exception& e) {}
 
-    return !exists;
+       return !exists;
 }
 
 }
 
-ZonePolicy::ZonePolicy(PolicyControlContext& ctx)
-    : context(ctx)
+ZonePolicy::ZonePolicy(PolicyControlContext& ctx) :
+       context(ctx)
 {
-    context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::createZone)(std::string, std::string));
-    context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::removeZone)(std::string));
-    context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::lockZone)(std::string));
-    context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::unlockZone)(std::string));
-    context.registerParametricMethod(this, "", (int)(ZonePolicy::getZoneState)(std::string));
-    context.registerParametricMethod(this, "", (std::vector<std::string>)(ZonePolicy::getZoneList)(int));
-
-    context.createNotification("ZonePolicy::created");
-    context.createNotification("ZonePolicy::removed");
+       context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::createZone)(std::string, std::string));
+       context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::removeZone)(std::string));
+       context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::lockZone)(std::string));
+       context.registerParametricMethod(this, DPM_PRIVILEGE_ZONE, (int)(ZonePolicy::unlockZone)(std::string));
+       context.registerParametricMethod(this, "", (int)(ZonePolicy::getZoneState)(std::string));
+       context.registerParametricMethod(this, "", (std::vector<std::string>)(ZonePolicy::getZoneList)(int));
+
+       context.createNotification("ZonePolicy::created");
+       context.createNotification("ZonePolicy::removed");
 }
 
 ZonePolicy::~ZonePolicy()
@@ -80,54 +81,54 @@ ZonePolicy::~ZonePolicy()
 
 int ZonePolicy::createZone(const std::string& name, const std::string& setupWizAppid)
 {
-    if (!std::regex_match(name, zoneNamePattern)) {
-        return -1;
-    }
-
-    if (!isAllowedName(name)) {
-        return -1;
-    }
-
-    try {
-        std::vector<std::string> data = {"app-id", "org.tizen.krate-setup-wizard",
-                                         "mode", "create",
-                                         "zone", name};
-        Bundle bundle;
-        bundle.add("id", "zone-create");
-        bundle.add("user-data", data);
-
-        Launchpad launchpad(context.getPeerUid());
-        launchpad.launch("org.tizen.dpm-syspopup", bundle);
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
-
-    return 0;
+       if (!std::regex_match(name, zoneNamePattern)) {
+               return -1;
+       }
+
+       if (!isAllowedName(name)) {
+               return -1;
+       }
+
+       try {
+               std::vector<std::string> data = {"app-id", "org.tizen.krate-setup-wizard",
+                                                                                "mode", "create",
+                                                                                "zone", name};
+               Bundle bundle;
+               bundle.add("id", "zone-create");
+               bundle.add("user-data", data);
+
+               Launchpad launchpad(context.getPeerUid());
+               launchpad.launch("org.tizen.dpm-syspopup", bundle);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
 }
 
 int ZonePolicy::removeZone(const std::string& name)
 {
-    if (getZoneState(name) == 0) {
-        return -1;
-    }
-
-    try {
-        std::vector<std::string> data = {"app-id", "org.tizen.krate-setup-wizard",
-                                         "mode", "remove",
-                                         "zone", name};
-        Bundle bundle;
-        bundle.add("id", "zone-remove");
-        bundle.add("user-data", data);
-
-        Launchpad launchpad(context.getPeerUid());
-        launchpad.launch("org.tizen.dpm-syspopup", bundle);
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
-
-    return 0;
+       if (getZoneState(name) == 0) {
+               return -1;
+       }
+
+       try {
+               std::vector<std::string> data = {"app-id", "org.tizen.krate-setup-wizard",
+                                                                                "mode", "remove",
+                                                                                "zone", name};
+               Bundle bundle;
+               bundle.add("id", "zone-remove");
+               bundle.add("user-data", data);
+
+               Launchpad launchpad(context.getPeerUid());
+               launchpad.launch("org.tizen.dpm-syspopup", bundle);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
 }
 
 /* [TBD] remove dependency with zoneManager like this */
@@ -135,22 +136,22 @@ extern ZoneManager zoneManager;
 
 int ZonePolicy::lockZone(const std::string& name)
 {
-    return zoneManager.lockZone(name);
+       return zoneManager.lockZone(name);
 }
 
 int ZonePolicy::unlockZone(const std::string& name)
 {
-    return zoneManager.unlockZone(name);
+       return zoneManager.unlockZone(name);
 }
 
 int ZonePolicy::getZoneState(const std::string& name)
 {
-    return zoneManager.getZoneState(name);
+       return zoneManager.getZoneState(name);
 }
 
 std::vector<std::string> ZonePolicy::getZoneList(int state)
 {
-    return zoneManager.getZoneList(state);
+       return zoneManager.getZoneList(state);
 }
 
 ZonePolicy zonePolicy(Server::instance());
index 99d2200..dc9bb5d 100644 (file)
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  */
-#include <unordered_map>
 
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <system_settings.h>
 
+#include <unordered_map>
+
 #include "zone/app-proxy.hxx"
 
 #include "error.h"
@@ -31,10 +32,10 @@ namespace DevicePolicyManager {
 
 namespace {
 
-struct IteratorData{
-    std::string zone;
-    std::vector<ApplicationInfo> list;
-    unsigned int current;
+struct IteratorData {
+       std::string zone;
+       std::vector<ApplicationInfo> list;
+       unsigned int current;
 };
 
 std::unordered_map<int, IteratorData> iteratorMap;
@@ -42,20 +43,20 @@ int newIteratorId = 0;
 
 } // namespace
 
-ZoneAppProxy::ZoneAppProxy(PolicyControlContext& ctx)
-    : context(ctx)
+ZoneAppProxy::ZoneAppProxy(PolicyControlContext& ctx) :
+       context(ctx)
 {
-    context.registerParametricMethod(this, "", (ZoneAppProxy::AppInfo)(ZoneAppProxy::getAppInfo)(std::string, std::string));
+       context.registerParametricMethod(this, "", (ZoneAppProxy::AppInfo)(ZoneAppProxy::getAppInfo)(std::string, std::string));
 
-    context.registerParametricMethod(this, "", (int)(ZoneAppProxy::createIterator)(std::string));
-    context.registerParametricMethod(this, "", (ZoneAppProxy::AppInfo)(ZoneAppProxy::getIteratorValue)(int));
-    context.registerParametricMethod(this, "", (bool)(ZoneAppProxy::nextIterator)(int));
-    context.registerParametricMethod(this, "", (int)(ZoneAppProxy::destroyIterator)(int));
+       context.registerParametricMethod(this, "", (int)(ZoneAppProxy::createIterator)(std::string));
+       context.registerParametricMethod(this, "", (ZoneAppProxy::AppInfo)(ZoneAppProxy::getIteratorValue)(int));
+       context.registerParametricMethod(this, "", (bool)(ZoneAppProxy::nextIterator)(int));
+       context.registerParametricMethod(this, "", (int)(ZoneAppProxy::destroyIterator)(int));
 
-    context.registerParametricMethod(this, "", (int)(ZoneAppProxy::launch)(std::string, ZoneAppProxy::Bundle));
-    context.registerParametricMethod(this, "", (int)(ZoneAppProxy::resume)(std::string, std::string));
-    context.registerParametricMethod(this, "", (int)(ZoneAppProxy::terminate)(std::string, std::string));
-    context.registerParametricMethod(this, "", (int)(ZoneAppProxy::isRunning)(std::string, std::string));
+       context.registerParametricMethod(this, "", (int)(ZoneAppProxy::launch)(std::string, ZoneAppProxy::Bundle));
+       context.registerParametricMethod(this, "", (int)(ZoneAppProxy::resume)(std::string, std::string));
+       context.registerParametricMethod(this, "", (int)(ZoneAppProxy::terminate)(std::string, std::string));
+       context.registerParametricMethod(this, "", (int)(ZoneAppProxy::isRunning)(std::string, std::string));
 }
 
 ZoneAppProxy::~ZoneAppProxy()
@@ -64,189 +65,191 @@ ZoneAppProxy::~ZoneAppProxy()
 
 ZoneAppProxy::AppInfo ZoneAppProxy::getAppInfo(const std::string& name, const std::string& appid)
 {
-    AppInfo appInfo;
-
-    try {
-        runtime::User user(name);
-        ApplicationInfo appinfo(appid, user.getUid());
-        char* locale;
-
-        system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
-        if (locale == NULL) {
-            appInfo.locale = "No locale";
-        } else {
-            appInfo.locale = locale;
-            free(locale);
-        }
-
-        appInfo.zone = name;
-        appInfo.id = appid;
-        appInfo.package = appinfo.getPackage();
-        appInfo.type = appinfo.getType();
-        appInfo.icon = appinfo.getIcon();
-        appInfo.label = appinfo.getLabel();
-        appInfo.componentType = appinfo.getComponentType();
-        appInfo.isNoDisplayed = appinfo.isNoDisplayed();
-        appInfo.isTaskManaged = appinfo.isTaskManaged();
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to retrieve application info installed in the zone: " + appid);
-    }
-
-    return appInfo;
+       AppInfo appInfo;
+
+       try {
+               runtime::User user(name);
+               ApplicationInfo appinfo(appid, user.getUid());
+               char* locale;
+
+               system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+               if (locale == NULL) {
+                       appInfo.locale = "No locale";
+               } else {
+                       appInfo.locale = locale;
+                       free(locale);
+               }
+
+               appInfo.zone = name;
+               appInfo.id = appid;
+               appInfo.package = appinfo.getPackage();
+               appInfo.type = appinfo.getType();
+               appInfo.icon = appinfo.getIcon();
+               appInfo.label = appinfo.getLabel();
+               appInfo.componentType = appinfo.getComponentType();
+               appInfo.isNoDisplayed = appinfo.isNoDisplayed();
+               appInfo.isTaskManaged = appinfo.isTaskManaged();
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to retrieve application info installed in the zone: " + appid);
+       }
+
+       return appInfo;
 }
 
 int ZoneAppProxy::createIterator(const std::string& name)
 {
-    int iteratorId = -1;
-    try {
-        PackageManager& packman = PackageManager::instance();
-        runtime::User user(name);
-        IteratorData data;
-
-        iteratorId = newIteratorId;
-
-        data.zone = name;
-        data.list = packman.getAppList(user.getUid());
-        data.current = 0;
-
-        iteratorMap.insert(std::make_pair(iteratorId, data));
-
-        if (++newIteratorId < 0) {
-            newIteratorId = 0;
-        }
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to retrieve package info installed in the zone");
-    }
-    return iteratorId;
+       int iteratorId = -1;
+       try {
+               PackageManager& packman = PackageManager::instance();
+               runtime::User user(name);
+               IteratorData data;
+
+               iteratorId = newIteratorId;
+
+               data.zone = name;
+               data.list = packman.getAppList(user.getUid());
+               data.current = 0;
+
+               iteratorMap.insert(std::make_pair(iteratorId, data));
+
+               if (++newIteratorId < 0) {
+                       newIteratorId = 0;
+               }
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to retrieve package info installed in the zone");
+       }
+       return iteratorId;
 }
 
 ZoneAppProxy::AppInfo ZoneAppProxy::getIteratorValue(int iterator)
 {
-    AppInfo appInfo;
-
-    auto it = iteratorMap.find(iterator);
-    if (it == iteratorMap.end()) {
-        return appInfo;
-    }
-    if (it->second.current >= it->second.list.size()) {
-        return appInfo;
-    }
-
-    const ApplicationInfo& appinfo = it->second.list.at(it->second.current);
-    char* locale;
-
-    system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
-    if (locale == NULL) {
-        appInfo.locale = "No locale";
-    } else {
-        appInfo.locale = locale;
-        free(locale);
-    }
-
-    appInfo.zone = it->second.zone;
-    appInfo.id = appinfo.getId();
-    appInfo.package = appinfo.getPackage();
-    appInfo.type = appinfo.getType();
-    appInfo.icon = appinfo.getIcon();
-    appInfo.label = appinfo.getLabel();
-    appInfo.componentType = appinfo.getComponentType();
-    appInfo.isNoDisplayed = appinfo.isNoDisplayed();
-    appInfo.isTaskManaged = appinfo.isTaskManaged();
-
-    return appInfo;
+       AppInfo appInfo;
+
+       auto it = iteratorMap.find(iterator);
+       if (it == iteratorMap.end()) {
+               return appInfo;
+       }
+       if (it->second.current >= it->second.list.size()) {
+               return appInfo;
+       }
+
+       const ApplicationInfo& appinfo = it->second.list.at(it->second.current);
+       char* locale;
+
+       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+       if (locale == NULL) {
+               appInfo.locale = "No locale";
+       } else {
+               appInfo.locale = locale;
+               free(locale);
+       }
+
+       appInfo.zone = it->second.zone;
+       appInfo.id = appinfo.getId();
+       appInfo.package = appinfo.getPackage();
+       appInfo.type = appinfo.getType();
+       appInfo.icon = appinfo.getIcon();
+       appInfo.label = appinfo.getLabel();
+       appInfo.componentType = appinfo.getComponentType();
+       appInfo.isNoDisplayed = appinfo.isNoDisplayed();
+       appInfo.isTaskManaged = appinfo.isTaskManaged();
+
+       return appInfo;
 }
 
-bool ZoneAppProxy::nextIterator(int iterator) {
-    auto it = iteratorMap.find(iterator);
-    if (it != iteratorMap.end()) {
-        if (++it->second.current < it->second.list.size()) {
-            return true;
-        }
-    }
-    return false;
+bool ZoneAppProxy::nextIterator(int iterator)
+{
+       auto it = iteratorMap.find(iterator);
+       if (it != iteratorMap.end()) {
+               if (++it->second.current < it->second.list.size()) {
+                       return true;
+               }
+       }
+       return false;
 }
 
-int ZoneAppProxy::destroyIterator(int iterator) {
-    auto it = iteratorMap.find(iterator);
-    if (it != iteratorMap.end()) {
-        iteratorMap.erase(it);
-        return 0;
-    }
-    return -1;
+int ZoneAppProxy::destroyIterator(int iterator)
+{
+       auto it = iteratorMap.find(iterator);
+       if (it != iteratorMap.end()) {
+               iteratorMap.erase(it);
+               return 0;
+       }
+       return -1;
 }
 
 int ZoneAppProxy::launch(const std::string& name, const ZoneAppProxy::Bundle& bundle)
 {
-    try {
-        runtime::User user(name);
-        ::Bundle b;
-
-        if (!bundle.operation.empty()) {
-            b.add("__APP_SVC_OP_TYPE__", bundle.operation);
-        }
-        if (!bundle.uri.empty()) {
-            b.add("__APP_SVC_URI__", bundle.uri);
-        }
-        if (!bundle.mime.empty()) {
-            b.add("__APP_SVC_MIME__", bundle.mime);
-        }
-        if (!bundle.category.empty()) {
-            b.add("__APP_SVC_CATEGORY__", bundle.category);
-        }
-
-        for (Bundle::Extra extra : bundle.extraData) {
-            if (extra.value.size() > 1) {
-                b.add(extra.key, extra.value);
-            } else if (extra.value.size() == 1) {
-                b.add(extra.key, extra.value.at(0));
-            }
-        }
-
-        Launchpad launchpad(user.getUid());
-        launchpad.launch(bundle.appId, b);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to launch app in the zone");
-        return -1;
-    }
-    return 0;
+       try {
+               runtime::User user(name);
+               ::Bundle b;
+
+               if (!bundle.operation.empty()) {
+                       b.add("__APP_SVC_OP_TYPE__", bundle.operation);
+               }
+               if (!bundle.uri.empty()) {
+                       b.add("__APP_SVC_URI__", bundle.uri);
+               }
+               if (!bundle.mime.empty()) {
+                       b.add("__APP_SVC_MIME__", bundle.mime);
+               }
+               if (!bundle.category.empty()) {
+                       b.add("__APP_SVC_CATEGORY__", bundle.category);
+               }
+
+               for (Bundle::Extra extra : bundle.extraData) {
+                       if (extra.value.size() > 1) {
+                               b.add(extra.key, extra.value);
+                       } else if (extra.value.size() == 1) {
+                               b.add(extra.key, extra.value.at(0));
+                       }
+               }
+
+               Launchpad launchpad(user.getUid());
+               launchpad.launch(bundle.appId, b);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to launch app in the zone");
+               return -1;
+       }
+       return 0;
 }
 
 int ZoneAppProxy::resume(const std::string& name, const std::string& appid)
 {
-    try {
-        runtime::User user(name);
-        Launchpad launchpad(user.getUid());
-        launchpad.resume(appid);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to terminate app in the zone");
-        return -1;
-    }
-    return 0;
+       try {
+               runtime::User user(name);
+               Launchpad launchpad(user.getUid());
+               launchpad.resume(appid);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to terminate app in the zone");
+               return -1;
+       }
+       return 0;
 }
 
 int ZoneAppProxy::terminate(const std::string& name, const std::string& appid)
 {
-    try {
-        runtime::User user(name);
-        Launchpad launchpad(user.getUid());
-        launchpad.terminate(appid);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to terminate app in the zone");
-        return -1;
-    }
-    return 0;
+       try {
+               runtime::User user(name);
+               Launchpad launchpad(user.getUid());
+               launchpad.terminate(appid);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to terminate app in the zone");
+               return -1;
+       }
+       return 0;
 }
 
 bool ZoneAppProxy::isRunning(const std::string& name, const std::string& appid)
 {
-    try {
-        runtime::User user(name);
-        Launchpad launchpad(user.getUid());
-        return launchpad.isRunning(appid);
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to get app running state in the zone");
-    }
-    return false;
+       try {
+               runtime::User user(name);
+               Launchpad launchpad(user.getUid());
+               return launchpad.isRunning(appid);
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to get app running state in the zone");
+       }
+       return false;
 }
 
 ZoneAppProxy zoneAppManager(Server::instance());
index c490a36..1313b7a 100644 (file)
 
 namespace DevicePolicyManager {
 
-ZonePackageProxy::ZonePackageProxy(PolicyControlContext& ctx)
-    : context(ctx)
+ZonePackageProxy::ZonePackageProxy(PolicyControlContext& ctx) :
+       context(ctx)
 {
-    context.registerParametricMethod(this, "", (ZonePackageProxy::PackageInfo)(ZonePackageProxy::getPackageInfo)(std::string, std::string));
-    context.registerParametricMethod(this, "", (std::vector<std::string>)(ZonePackageProxy::getPackageList)(std::string));
+       context.registerParametricMethod(this, "", (ZonePackageProxy::PackageInfo)(ZonePackageProxy::getPackageInfo)(std::string, std::string));
+       context.registerParametricMethod(this, "", (std::vector<std::string>)(ZonePackageProxy::getPackageList)(std::string));
 
-    context.registerParametricMethod(this, "", (int)(ZonePackageProxy::install)(std::string, std::string));
-    context.registerParametricMethod(this, "", (int)(ZonePackageProxy::uninstall)(std::string, std::string));
+       context.registerParametricMethod(this, "", (int)(ZonePackageProxy::install)(std::string, std::string));
+       context.registerParametricMethod(this, "", (int)(ZonePackageProxy::uninstall)(std::string, std::string));
 }
 
 ZonePackageProxy::~ZonePackageProxy()
@@ -42,85 +42,85 @@ ZonePackageProxy::~ZonePackageProxy()
 
 ZonePackageProxy::PackageInfo ZonePackageProxy::getPackageInfo(const std::string& name, const std::string& pkgid)
 {
-    ZonePackageProxy::PackageInfo package;
-    char* locale = NULL;
+       ZonePackageProxy::PackageInfo package;
+       char* locale = NULL;
 
-    system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
-    if (locale == NULL) {
-        locale = strdup("No locale");
-    }
+       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+       if (locale == NULL) {
+               locale = strdup("No locale");
+       }
 
-    package.zone = name;
-    package.id = pkgid;
-    package.locale = locale;
+       package.zone = name;
+       package.id = pkgid;
+       package.locale = locale;
 
-    free(locale);
+       free(locale);
 
-    try {
-        runtime::User user(name);
-        ::PackageInfo pkginfo(pkgid, user.getUid());
+       try {
+               runtime::User user(name);
+               ::PackageInfo pkginfo(pkgid, user.getUid());
 
-        package.type = pkginfo.getType();
-        package.icon = pkginfo.getIcon();
-        package.label = pkginfo.getLabel();
-        package.description = pkginfo.getDescription();
+               package.type = pkginfo.getType();
+               package.icon = pkginfo.getIcon();
+               package.label = pkginfo.getLabel();
+               package.description = pkginfo.getDescription();
 
-        package.author.name = pkginfo.getAuthorName();
-        package.author.email = pkginfo.getAuthorEmail();
-        package.author.href = pkginfo.getAuthorHref();
+               package.author.name = pkginfo.getAuthorName();
+               package.author.email = pkginfo.getAuthorEmail();
+               package.author.href = pkginfo.getAuthorHref();
 
-        package.version = pkginfo.getVersion();
-        package.apiVersion = pkginfo.getApiVersion();
-        package.mainAppId = pkginfo.getMainAppId();
+               package.version = pkginfo.getVersion();
+               package.apiVersion = pkginfo.getApiVersion();
+               package.mainAppId = pkginfo.getMainAppId();
 
-        package.isSystem = pkginfo.isSystem();
-        package.isRemovable = pkginfo.isRemovable();
-        package.isPreload = pkginfo.isPreload();
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to retrieve package info installed in the zone");
-    }
+               package.isSystem = pkginfo.isSystem();
+               package.isRemovable = pkginfo.isRemovable();
+               package.isPreload = pkginfo.isPreload();
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to retrieve package info installed in the zone");
+       }
 
-    return package;
+       return package;
 }
 
 std::vector<std::string> ZonePackageProxy::getPackageList(const std::string& name)
 {
-    try {
-        runtime::User user(name);
-        PackageManager& packman = PackageManager::instance();
-        return packman.getPackageList(user.getUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to retrieve package info installed in the zone");
-    }
-    return std::vector<std::string>();
+       try {
+               runtime::User user(name);
+               PackageManager& packman = PackageManager::instance();
+               return packman.getPackageList(user.getUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to retrieve package info installed in the zone");
+       }
+       return std::vector<std::string>();
 }
 
 
 int ZonePackageProxy::install(const std::string& name, const std::string& pkgpath)
 {
-    try {
-        runtime::User user(name);
-        PackageManager& packman = PackageManager::instance();
-        packman.installPackage(pkgpath, user.getUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to install package in the zone");
-        return -1;
-    }
-
-    return 0;
+       try {
+               runtime::User user(name);
+               PackageManager& packman = PackageManager::instance();
+               packman.installPackage(pkgpath, user.getUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to install package in the zone");
+               return -1;
+       }
+
+       return 0;
 }
 
 int ZonePackageProxy::uninstall(const std::string& name, const std::string& pkgid)
 {
-    try {
-        runtime::User user(name);
-        PackageManager& packman = PackageManager::instance();
-        packman.uninstallPackage(pkgid, user.getUid());
-    } catch (runtime::Exception& e) {
-        ERROR("Failed to uninstall package of pkgid in the zone");
-        return -1;
-    }
-    return 0;
+       try {
+               runtime::User user(name);
+               PackageManager& packman = PackageManager::instance();
+               packman.uninstallPackage(pkgid, user.getUid());
+       } catch (runtime::Exception& e) {
+               ERROR("Failed to uninstall package of pkgid in the zone");
+               return -1;
+       }
+       return 0;
 }
 
 ZonePackageProxy zonePackageManager(Server::instance());
index 0ec13b4..edb5dc4 100644 (file)
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  */
-#include <algorithm>
+
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/inotify.h>
 
+#include <algorithm>
+
 #include <gum/gum-user.h>
 #include <gum/common/gum-user-types.h>
 #include <notification.h>
@@ -46,15 +48,15 @@ namespace DevicePolicyManager {
 namespace {
 
 const std::vector<std::string> defaultGroups = {
-    "audio",
-    "video",
-    "display",
-    "log"
+       "audio",
+       "video",
+       "display",
+       "log"
 };
 
 const std::vector<std::string> unitsToMask = {
-    "starter.service",
-    "scim.service"
+       "starter.service",
+       "scim.service"
 };
 
 const std::string ZONE_MANIFEST_DIR = CONF_PATH "/zone/";
@@ -74,134 +76,134 @@ std::unordered_map<int, notification_h> notiHandleMap;
 
 inline void maskUserServices(const runtime::User& user)
 {
-    ::tzplatform_set_user(user.getUid());
-    std::string pivot(::tzplatform_getenv(TZ_USER_HOME));
-    ::tzplatform_reset_user();
-
-    runtime::File unitbase(pivot + "/.config/systemd/user");
-    unitbase.makeDirectory(true);
-    unitbase.chmod(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
-
-    for (const std::string& unit : unitsToMask) {
-        std::string target = unitbase.getPath() + "/" + unit;
-        if (::symlink("/dev/null", target.c_str()) == -1) {
-            throw runtime::Exception(runtime::GetSystemErrorMessage());
-        }
-    }
+       ::tzplatform_set_user(user.getUid());
+       std::string pivot(::tzplatform_getenv(TZ_USER_HOME));
+       ::tzplatform_reset_user();
+
+       runtime::File unitbase(pivot + "/.config/systemd/user");
+       unitbase.makeDirectory(true);
+       unitbase.chmod(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+
+       for (const std::string& unit : unitsToMask) {
+               std::string target = unitbase.getPath() + "/" + unit;
+               if (::symlink("/dev/null", target.c_str()) == -1) {
+                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+               }
+       }
 }
 
 inline void setZoneState(uid_t id, int state)
 {
-    dbus::Connection& systemDBus = dbus::Connection::getSystem();
-    systemDBus.methodcall("org.freedesktop.login1",
-                          "/org/freedesktop/login1",
-                          "org.freedesktop.login1.Manager",
-                          "SetUserLinger",
-                          -1, "", "(ubb)", id, state, 1);
+       dbus::Connection& systemDBus = dbus::Connection::getSystem();
+       systemDBus.methodcall("org.freedesktop.login1",
+                                                 "/org/freedesktop/login1",
+                                                 "org.freedesktop.login1.Manager",
+                                                 "SetUserLinger",
+                                                 -1, "", "(ubb)", id, state, 1);
 }
 
 inline const std::string convertPathForOwner(const std::string& path, const runtime::User& user, const runtime::User& owner)
 {
-    ::tzplatform_set_user(owner.getUid());
-    std::string ownerHome(::tzplatform_getenv(TZ_USER_HOME));
-    ::tzplatform_reset_user();
-    ownerHome += "/.zone";
+       ::tzplatform_set_user(owner.getUid());
+       std::string ownerHome(::tzplatform_getenv(TZ_USER_HOME));
+       ::tzplatform_reset_user();
+       ownerHome += "/.zone";
 
-    ::tzplatform_set_user(user.getUid());
-    std::string userHome(::tzplatform_getenv(TZ_USER_HOME));
-    ::tzplatform_reset_user();
+       ::tzplatform_set_user(user.getUid());
+       std::string userHome(::tzplatform_getenv(TZ_USER_HOME));
+       ::tzplatform_reset_user();
 
-    std::string userHomeForOwner(ownerHome + "/" + user.getName());
+       std::string userHomeForOwner(ownerHome + "/" + user.getName());
 
-    std::string convertedPath(path);
+       std::string convertedPath(path);
 
-    if (convertedPath.compare(0, userHome.size(), userHome) == 0) {
-        convertedPath.replace(0, userHome.size(), userHomeForOwner);
-    }
+       if (convertedPath.compare(0, userHome.size(), userHome) == 0) {
+               convertedPath.replace(0, userHome.size(), userHomeForOwner);
+       }
 
-    return convertedPath;
+       return convertedPath;
 }
 
 inline void prepareFileForOwner(const std::string path, const runtime::User& pkgUser, const runtime::User& owner)
 {
-    std::string pathLink = convertPathForOwner(path, pkgUser, owner);
-
-    if (path != pathLink) {
-        runtime::File linkFile(pathLink);
-        linkFile.makeBaseDirectory(pkgUser.getUid(), pkgUser.getGid());
-        if (linkFile.exists()) {
-            linkFile.remove();
-        }
-
-        int ret = ::link(path.c_str(), pathLink.c_str());
-        if (ret != 0) {
-            //TODO: copy the icon instead of linking
-            throw runtime::Exception("Failed to link from " + path +
-                                     " to " + pathLink);
-        }
-    }
+       std::string pathLink = convertPathForOwner(path, pkgUser, owner);
+
+       if (path != pathLink) {
+               runtime::File linkFile(pathLink);
+               linkFile.makeBaseDirectory(pkgUser.getUid(), pkgUser.getGid());
+               if (linkFile.exists()) {
+                       linkFile.remove();
+               }
+
+               int ret = ::link(path.c_str(), pathLink.c_str());
+               if (ret != 0) {
+                       //TODO: copy the icon instead of linking
+                       throw runtime::Exception("Failed to link from " + path +
+                                                                        " to " + pathLink);
+               }
+       }
 }
 
 int packageEventHandler(uid_t target_uid, int req_id,
-                        const char *pkg_type, const char *pkgid,
-                        const char *key, const char *val,
-                        const void *pmsg, void *data)
+                                               const char *pkg_type, const char *pkgid,
+                                               const char *key, const char *val,
+                                               const void *pmsg, void *data)
 {
-    static std::string type;
-    std::string keystr = key;
-
-    if (target_uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) {
-        return 0;
-    }
-
-    std::transform(keystr.begin(), keystr.end(), keystr.begin(), ::tolower);
-    if (keystr == "start") {
-        type = val;
-        std::transform(type.begin(), type.end(), type.begin(), ::tolower);
-        return 0;
-    } else if (keystr != "end" && keystr != "ok") {
-        return 0;
-    }
-
-    try {
-        runtime::User owner(ZONE_DEFAULT_OWNER), pkgUser(target_uid);
-
-        if (type == "install" || type == "update") {
-            PackageInfo pkg(pkgid, pkgUser.getUid());
-            std::string icon = pkg.getIcon();
-            prepareFileForOwner(icon, pkgUser, owner);
-
-            for (const ApplicationInfo& app : pkg.getAppList()) {
-                std::string icon = app.getIcon();
-                prepareFileForOwner(icon, pkgUser, owner);
-            }
-        } else {
-            ::tzplatform_set_user(pkgUser.getUid());
-            std::string pkgPath(::tzplatform_getenv(TZ_USER_APP));
-            pkgPath = pkgPath + "/" + pkgid;
-            ::tzplatform_reset_user();
-
-            runtime::File pkgDirForOwner(convertPathForOwner(pkgPath, pkgUser, owner));
-            pkgDirForOwner.remove(true);
-        }
-    } catch (runtime::Exception &e) {
-        ERROR(e.what());
-    }
-
-    return 0;
+       static std::string type;
+       std::string keystr = key;
+
+       if (target_uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) {
+               return 0;
+       }
+
+       std::transform(keystr.begin(), keystr.end(), keystr.begin(), ::tolower);
+       if (keystr == "start") {
+               type = val;
+               std::transform(type.begin(), type.end(), type.begin(), ::tolower);
+               return 0;
+       } else if (keystr != "end" && keystr != "ok") {
+               return 0;
+       }
+
+       try {
+               runtime::User owner(ZONE_DEFAULT_OWNER), pkgUser(target_uid);
+
+               if (type == "install" || type == "update") {
+                       PackageInfo pkg(pkgid, pkgUser.getUid());
+                       std::string icon = pkg.getIcon();
+                       prepareFileForOwner(icon, pkgUser, owner);
+
+                       for (const ApplicationInfo& app : pkg.getAppList()) {
+                               std::string icon = app.getIcon();
+                               prepareFileForOwner(icon, pkgUser, owner);
+                       }
+               } else {
+                       ::tzplatform_set_user(pkgUser.getUid());
+                       std::string pkgPath(::tzplatform_getenv(TZ_USER_APP));
+                       pkgPath = pkgPath + "/" + pkgid;
+                       ::tzplatform_reset_user();
+
+                       runtime::File pkgDirForOwner(convertPathForOwner(pkgPath, pkgUser, owner));
+                       pkgDirForOwner.remove(true);
+               }
+       } catch (runtime::Exception &e) {
+               ERROR(e.what());
+       }
+
+       return 0;
 }
 
 void initializeCreatedZoneList() {
-    try {
-        runtime::DirectoryIterator iter(ZONE_MANIFEST_DIR), end;
-
-        while (iter != end) {
-            const std::string& file = iter->getName();
-            const std::string& name(file.substr(0, file.rfind(".xml")));
-            createdZoneList.push_back(name);
-            ++iter;
-        }
-    } catch (runtime::Exception& e) {}
+       try {
+               runtime::DirectoryIterator iter(ZONE_MANIFEST_DIR), end;
+
+               while (iter != end) {
+                       const std::string& file = iter->getName();
+                       const std::string& name(file.substr(0, file.rfind(".xml")));
+                       createdZoneList.push_back(name);
+                       ++iter;
+               }
+       } catch (runtime::Exception& e) {}
 }
 
 #define NT_TITLE     NOTIFICATION_TEXT_TYPE_TITLE
@@ -219,477 +221,476 @@ void initializeCreatedZoneList() {
 #define NT_ERROR_NONE   NOTIFICATION_ERROR_NONE
 
 void zoneProcessCallback(GDBusConnection *connection,
-                            const gchar *sender, const gchar *objectPath,
-                            const gchar *interface, const gchar *signalName,
-                            GVariant *params, gpointer userData)
+                                                const gchar *sender, const gchar *objectPath,
+                                                const gchar *interface, const gchar *signalName,
+                                                GVariant *params, gpointer userData)
 {
-    static runtime::User owner(ZONE_DEFAULT_OWNER);
-    int pid, status;
-
-    notification_h noti = reinterpret_cast<notification_h>(userData);
-
-    g_variant_get(params, "(ii)", &status, &pid);
-
-    if (status != 5) {
-        return;
-    }
-
-    struct stat st;
-    std::string proc("/proc/" + std::to_string(pid));
-    if (::stat(proc.c_str(), &st) != 0) {
-        return;
-    }
-
-    if (owner.getUid() != st.st_uid) {
-        if (!isZoneForeground) {
-            notification_set_text(noti, NT_CONTENT, NT_APPINFO, NULL, NT_NONE);
-            notification_post_for_uid(noti, owner.getUid());
-            isZoneForeground = true;
-        }
-    } else {
-        if (isZoneForeground) {
-            notification_delete_for_uid(noti, owner.getUid());
-            isZoneForeground = false;
-        }
-    }
+       static runtime::User owner(ZONE_DEFAULT_OWNER);
+       int pid, status;
+
+       notification_h noti = reinterpret_cast<notification_h>(userData);
+
+       g_variant_get(params, "(ii)", &status, &pid);
+
+       if (status != 5) {
+               return;
+       }
+
+       struct stat st;
+       std::string proc("/proc/" + std::to_string(pid));
+       if (::stat(proc.c_str(), &st) != 0) {
+               return;
+       }
+
+       if (owner.getUid() != st.st_uid) {
+               if (!isZoneForeground) {
+                       notification_set_text(noti, NT_CONTENT, NT_APPINFO, NULL, NT_NONE);
+                       notification_post_for_uid(noti, owner.getUid());
+                       isZoneForeground = true;
+               }
+       } else {
+               if (isZoneForeground) {
+                       notification_delete_for_uid(noti, owner.getUid());
+                       isZoneForeground = false;
+               }
+       }
 }
 
 notification_h createNotification()
 {
-    notification_h noti = notification_create(NOTIFICATION_TYPE_ONGOING);
-    if (noti == NULL) {
-        return NULL;
-    }
-
-    if (notification_set_text(noti, NT_TITLE, NT_TEXT, NULL, NT_NONE) != NT_ERROR_NONE) {
-        notification_free(noti);
-        return NULL;
-    }
-    if (notification_set_image(noti, NT_ICON, NT_ICON_PATH) != NT_ERROR_NONE) {
-        notification_free(noti);
-        return NULL;
-    }
-
-    if (notification_set_image(noti, NT_INDICATOR, NT_ICON_PATH) != NT_ERROR_NONE) {
-        notification_free(noti);
-        return NULL;
-    }
-
-    if (notification_set_layout(noti, NT_EVENT) != NT_ERROR_NONE) {
-        notification_free(noti);
-        return NULL;
-    }
-
-    if (notification_set_display_applist(noti, NT_APP) != NT_ERROR_NONE) {
-        notification_free(noti);
-        return NULL;
-    }
-
-    return noti;
+       notification_h noti = notification_create(NOTIFICATION_TYPE_ONGOING);
+       if (noti == NULL) {
+               return NULL;
+       }
+
+       if (notification_set_text(noti, NT_TITLE, NT_TEXT, NULL, NT_NONE) != NT_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+       if (notification_set_image(noti, NT_ICON, NT_ICON_PATH) != NT_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       if (notification_set_image(noti, NT_INDICATOR, NT_ICON_PATH) != NT_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       if (notification_set_layout(noti, NT_EVENT) != NT_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       if (notification_set_display_applist(noti, NT_APP) != NT_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       return noti;
 }
 
 void zoneProcessMonitor()
 {
-    GError *error = NULL;
-    GDBusConnection* connection;
-    connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-    if (connection == NULL) {
-        ERROR("GBus Connection failed");
-        g_error_free(error);
-        return;
-    }
-
-    notification_h noti = createNotification();
-    if (noti == NULL) {
-        ERROR("Failed to created notification");
-        return;
-    }
-
-    g_dbus_connection_signal_subscribe(connection,
-                                        NULL,
-                                        "org.tizen.resourced.process",
-                                        "ProcStatus",
-                                        "/Org/Tizen/ResourceD/Process",
-                                        NULL,
-                                        G_DBUS_SIGNAL_FLAGS_NONE,
-                                        zoneProcessCallback,
-                                        reinterpret_cast<gpointer>(noti),
-                                        NULL);
+       GError *error = NULL;
+       GDBusConnection* connection;
+       connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (connection == NULL) {
+               ERROR("GBus Connection failed");
+               g_error_free(error);
+               return;
+       }
+
+       notification_h noti = createNotification();
+       if (noti == NULL) {
+               ERROR("Failed to created notification");
+               return;
+       }
+
+       g_dbus_connection_signal_subscribe(connection,
+                                                                               NULL,
+                                                                               "org.tizen.resourced.process",
+                                                                               "ProcStatus",
+                                                                               "/Org/Tizen/ResourceD/Process",
+                                                                               NULL,
+                                                                               G_DBUS_SIGNAL_FLAGS_NONE,
+                                                                               zoneProcessCallback,
+                                                                               reinterpret_cast<gpointer>(noti),
+                                                                               NULL);
 }
 
 void notiProxyInsert(const runtime::User& owner, const runtime::User& user, int privId, notification_h noti)
 {
-    std::string zoneLauncherUri;
-    notification_h newNoti;
-    app_control_h appControl;
-    char* pkgId;
-
-    notification_clone(noti, &newNoti);
-
-    notification_get_pkgname(noti, &pkgId);
-    PackageInfo pkg(pkgId, user.getUid());
-    notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON, pkg.getIcon().c_str());
-    notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, NOTIFICATION_SUB_ICON_PATH);
-
-    notification_get_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)&appControl);
-    if (appControl != NULL) {
-        char* appId = NULL, *uri = NULL;
-
-        app_control_get_app_id(appControl, &appId);
-        if (appId == NULL) {
-            appId = strdup("");
-        }
-
-        zoneLauncherUri = "zone://enter/" + user.getName() + "/" + appId;
-
-        app_control_get_uri(appControl, &uri);
-        if (uri != NULL) {
-            zoneLauncherUri += "?uri=";
-            zoneLauncherUri +=  uri;
-            free(uri);
-        }
-
-        free(appId);
-        app_control_set_app_id(appControl, ZONE_DELEGATOR_APP);
-        app_control_set_uri(appControl, zoneLauncherUri.c_str());
-        notification_set_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl);
-    }
-
-    notification_post_for_uid(newNoti, owner.getUid());
-    notiHandleMap.insert(std::make_pair(privId, newNoti));
+       std::string zoneLauncherUri;
+       notification_h newNoti;
+       app_control_h appControl;
+       char* pkgId;
+
+       notification_clone(noti, &newNoti);
+
+       notification_get_pkgname(noti, &pkgId);
+       PackageInfo pkg(pkgId, user.getUid());
+       notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON, pkg.getIcon().c_str());
+       notification_set_image(newNoti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, NOTIFICATION_SUB_ICON_PATH);
+
+       notification_get_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)&appControl);
+       if (appControl != NULL) {
+               char* appId = NULL, *uri = NULL;
+
+               app_control_get_app_id(appControl, &appId);
+               if (appId == NULL) {
+                       appId = strdup("");
+               }
+
+               zoneLauncherUri = "zone://enter/" + user.getName() + "/" + appId;
+
+               app_control_get_uri(appControl, &uri);
+               if (uri != NULL) {
+                       zoneLauncherUri += "?uri=";
+                       zoneLauncherUri +=  uri;
+                       free(uri);
+               }
+
+               free(appId);
+               app_control_set_app_id(appControl, ZONE_DELEGATOR_APP);
+               app_control_set_uri(appControl, zoneLauncherUri.c_str());
+               notification_set_launch_option(newNoti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl);
+       }
+
+       notification_post_for_uid(newNoti, owner.getUid());
+       notiHandleMap.insert(std::make_pair(privId, newNoti));
 }
 
 void notiProxyDelete(const runtime::User& owner, int privId)
 {
-    std::unordered_map<int, notification_h>::iterator it;
-
-    it = notiHandleMap.find(privId);
-    if (it == notiHandleMap.end()) {
-        return;
-    }
-    notification_delete_for_uid(it->second, owner.getUid());
-    notification_free(it->second);
-    notiHandleMap.erase(it);
+       std::unordered_map<int, notification_h>::iterator it;
+
+       it = notiHandleMap.find(privId);
+       if (it == notiHandleMap.end()) {
+               return;
+       }
+       notification_delete_for_uid(it->second, owner.getUid());
+       notification_free(it->second);
+       notiHandleMap.erase(it);
 }
 
 void notiProxyUpdate(const runtime::User& owner, const runtime::User& user, int privId, notification_h noti) {
-    std::unordered_map<int, notification_h>::iterator it;
-    double progress;
-    char *str;
-
-    it = notiHandleMap.find(privId);
-    if (it == notiHandleMap.end()) {
-        return;
-    }
-
-    notification_image_type_e imageTypes[] = {
-        NOTIFICATION_IMAGE_TYPE_ICON,
-        NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR,
-        NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK,
-        NOTIFICATION_IMAGE_TYPE_THUMBNAIL,
-        NOTIFICATION_IMAGE_TYPE_THUMBNAIL_FOR_LOCK,
-        NOTIFICATION_IMAGE_TYPE_ICON_SUB,
-        NOTIFICATION_IMAGE_TYPE_BACKGROUND,
-        NOTIFICATION_IMAGE_TYPE_LIST_1,
-        NOTIFICATION_IMAGE_TYPE_LIST_2,
-        NOTIFICATION_IMAGE_TYPE_LIST_3,
-        NOTIFICATION_IMAGE_TYPE_LIST_4,
-        NOTIFICATION_IMAGE_TYPE_LIST_5,
-        NOTIFICATION_IMAGE_TYPE_BUTTON_1,
-        NOTIFICATION_IMAGE_TYPE_BUTTON_2,
-        NOTIFICATION_IMAGE_TYPE_BUTTON_3,
-        NOTIFICATION_IMAGE_TYPE_BUTTON_4,
-        NOTIFICATION_IMAGE_TYPE_BUTTON_5,
-        NOTIFICATION_IMAGE_TYPE_BUTTON_6
-    };
-
-    for (notification_image_type_e type : imageTypes) {
-        notification_get_image(noti, type, &str);
-        notification_set_image(it->second, type, str);
-    }
-
-    notification_text_type_e textTypes[] = {
-        NOTIFICATION_TEXT_TYPE_TITLE,
-        NOTIFICATION_TEXT_TYPE_CONTENT,
-        NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
-        NOTIFICATION_TEXT_TYPE_EVENT_COUNT,
-        NOTIFICATION_TEXT_TYPE_INFO_1,
-        NOTIFICATION_TEXT_TYPE_INFO_SUB_1,
-        NOTIFICATION_TEXT_TYPE_INFO_2,
-        NOTIFICATION_TEXT_TYPE_INFO_SUB_2,
-        NOTIFICATION_TEXT_TYPE_INFO_3,
-        NOTIFICATION_TEXT_TYPE_INFO_SUB_3,
-        NOTIFICATION_TEXT_TYPE_GROUP_TITLE,
-        NOTIFICATION_TEXT_TYPE_GROUP_CONTENT,
-        NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
-        NOTIFICATION_TEXT_TYPE_BUTTON_1,
-        NOTIFICATION_TEXT_TYPE_BUTTON_2,
-        NOTIFICATION_TEXT_TYPE_BUTTON_3,
-        NOTIFICATION_TEXT_TYPE_BUTTON_4,
-        NOTIFICATION_TEXT_TYPE_BUTTON_5,
-        NOTIFICATION_TEXT_TYPE_BUTTON_6,
-    };
-
-    for (notification_text_type_e type : textTypes) {
-        notification_get_text(noti, type, &str);
-        notification_set_text(it->second, type, str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-    }
-
-    notification_get_size(noti, &progress);
-    notification_set_size(it->second, progress);
-
-    notification_get_progress(noti, &progress);
-    notification_set_progress(it->second, progress);
-
-    notification_update_for_uid(it->second, owner.getUid());
+       std::unordered_map<int, notification_h>::iterator it;
+       double progress;
+       char *str;
+
+       it = notiHandleMap.find(privId);
+       if (it == notiHandleMap.end()) {
+               return;
+       }
+
+       notification_image_type_e imageTypes[] = {
+               NOTIFICATION_IMAGE_TYPE_ICON,
+               NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR,
+               NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK,
+               NOTIFICATION_IMAGE_TYPE_THUMBNAIL,
+               NOTIFICATION_IMAGE_TYPE_THUMBNAIL_FOR_LOCK,
+               NOTIFICATION_IMAGE_TYPE_ICON_SUB,
+               NOTIFICATION_IMAGE_TYPE_BACKGROUND,
+               NOTIFICATION_IMAGE_TYPE_LIST_1,
+               NOTIFICATION_IMAGE_TYPE_LIST_2,
+               NOTIFICATION_IMAGE_TYPE_LIST_3,
+               NOTIFICATION_IMAGE_TYPE_LIST_4,
+               NOTIFICATION_IMAGE_TYPE_LIST_5,
+               NOTIFICATION_IMAGE_TYPE_BUTTON_1,
+               NOTIFICATION_IMAGE_TYPE_BUTTON_2,
+               NOTIFICATION_IMAGE_TYPE_BUTTON_3,
+               NOTIFICATION_IMAGE_TYPE_BUTTON_4,
+               NOTIFICATION_IMAGE_TYPE_BUTTON_5,
+               NOTIFICATION_IMAGE_TYPE_BUTTON_6
+       };
+
+       for (notification_image_type_e type : imageTypes) {
+               notification_get_image(noti, type, &str);
+               notification_set_image(it->second, type, str);
+       }
+
+       notification_text_type_e textTypes[] = {
+               NOTIFICATION_TEXT_TYPE_TITLE,
+               NOTIFICATION_TEXT_TYPE_CONTENT,
+               NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
+               NOTIFICATION_TEXT_TYPE_EVENT_COUNT,
+               NOTIFICATION_TEXT_TYPE_INFO_1,
+               NOTIFICATION_TEXT_TYPE_INFO_SUB_1,
+               NOTIFICATION_TEXT_TYPE_INFO_2,
+               NOTIFICATION_TEXT_TYPE_INFO_SUB_2,
+               NOTIFICATION_TEXT_TYPE_INFO_3,
+               NOTIFICATION_TEXT_TYPE_INFO_SUB_3,
+               NOTIFICATION_TEXT_TYPE_GROUP_TITLE,
+               NOTIFICATION_TEXT_TYPE_GROUP_CONTENT,
+               NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
+               NOTIFICATION_TEXT_TYPE_BUTTON_1,
+               NOTIFICATION_TEXT_TYPE_BUTTON_2,
+               NOTIFICATION_TEXT_TYPE_BUTTON_3,
+               NOTIFICATION_TEXT_TYPE_BUTTON_4,
+               NOTIFICATION_TEXT_TYPE_BUTTON_5,
+               NOTIFICATION_TEXT_TYPE_BUTTON_6,
+       };
+
+       for (notification_text_type_e type : textTypes) {
+               notification_get_text(noti, type, &str);
+               notification_set_text(it->second, type, str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       }
+
+       notification_get_size(noti, &progress);
+       notification_set_size(it->second, progress);
+
+       notification_get_progress(noti, &progress);
+       notification_set_progress(it->second, progress);
+
+       notification_update_for_uid(it->second, owner.getUid());
 }
 
 void notiProxyCallback(void *data, notification_type_e type, notification_op *op_list, int num_op)
 {
-    static runtime::User owner(ZONE_DEFAULT_OWNER);
-    runtime::User user(*reinterpret_cast<std::string*>(data));
-
-    // TODO : should remove noti in the zone when related-zone is removed
-    //        This will be imlemented when notification bug is fixed
-
-    for (int i = 0; i < num_op; i++) {
-        notification_h noti = NULL;
-        int opType, privId;
-
-        notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_TYPE, &opType);
-        notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_PRIV_ID, &privId);
-
-        switch (opType) {
-        case NOTIFICATION_OP_INSERT:
-            notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_NOTI, &noti);
-            notiProxyInsert(owner, user, privId, noti);
-            break;
-        case NOTIFICATION_OP_DELETE:
-            notiProxyDelete(owner, privId);
-            break;
-        case NOTIFICATION_OP_UPDATE:
-            notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_NOTI, &noti);
-            notiProxyUpdate(owner, user, privId, noti);
-            break;
-        }
-    }
+       static runtime::User owner(ZONE_DEFAULT_OWNER);
+       runtime::User user(*reinterpret_cast<std::string*>(data));
+
+       // TODO : should remove noti in the zone when related-zone is removed
+       //        This will be imlemented when notification bug is fixed
+
+       for (int i = 0; i < num_op; i++) {
+               notification_h noti = NULL;
+               int opType, privId;
+
+               notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_TYPE, &opType);
+               notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_PRIV_ID, &privId);
+
+               switch (opType) {
+               case NOTIFICATION_OP_INSERT:
+                       notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_NOTI, &noti);
+                       notiProxyInsert(owner, user, privId, noti);
+                       break;
+               case NOTIFICATION_OP_DELETE:
+                       notiProxyDelete(owner, privId);
+                       break;
+               case NOTIFICATION_OP_UPDATE:
+                       notification_op_get_data(op_list + i, NOTIFICATION_OP_DATA_NOTI, &noti);
+                       notiProxyUpdate(owner, user, privId, noti);
+                       break;
+               }
+       }
 }
 
 } // namespace
 
-ZoneManager::ZoneManager(PolicyControlContext& ctx)
-    : context(ctx)
+ZoneManager::ZoneManager(PolicyControlContext& ctx) :
+       context(ctx)
 {
-    context.registerParametricMethod(this, "", (int)(ZoneManager::createZone)(std::string, std::string));
-    context.registerParametricMethod(this, "", (int)(ZoneManager::removeZone)(std::string));
-    context.registerParametricMethod(this, "", (int)(ZoneManager::lockZone)(std::string));
-    context.registerParametricMethod(this, "", (int)(ZoneManager::unlockZone)(std::string));
-    context.registerParametricMethod(this, "", (int)(ZoneManager::getZoneState)(std::string));
-    context.registerParametricMethod(this, "", (std::vector<std::string>)(ZoneManager::getZoneList)(int));
-    context.registerParametricMethod(this, "", (int)(ZoneManager::resetZonePassword)(std::string, std::string));
-
-    context.createNotification("ZoneManager::created");
-    context.createNotification("ZoneManager::removed");
-
-    PackageManager& packageManager = PackageManager::instance();
-    packageManager.setEventCallback(packageEventHandler, this);
-
-    zoneProcessMonitor();
-
-    initializeCreatedZoneList();
-    for (std::string& name : createdZoneList) {
-        if (name == ZONE_DEFAULT_OWNER) {
-            continue;
-        }
-
-        runtime::User zone(name);
-        int noti = notification_register_detailed_changed_cb_for_uid(notiProxyCallback, &name, zone.getUid());
-        notiProxyCallbackMap.insert(std::make_pair(name, noti));
-    }
+       context.registerParametricMethod(this, "", (int)(ZoneManager::createZone)(std::string, std::string));
+       context.registerParametricMethod(this, "", (int)(ZoneManager::removeZone)(std::string));
+       context.registerParametricMethod(this, "", (int)(ZoneManager::lockZone)(std::string));
+       context.registerParametricMethod(this, "", (int)(ZoneManager::unlockZone)(std::string));
+       context.registerParametricMethod(this, "", (int)(ZoneManager::getZoneState)(std::string));
+       context.registerParametricMethod(this, "", (std::vector<std::string>)(ZoneManager::getZoneList)(int));
+       context.registerParametricMethod(this, "", (int)(ZoneManager::resetZonePassword)(std::string, std::string));
+
+       context.createNotification("ZoneManager::created");
+       context.createNotification("ZoneManager::removed");
+
+       PackageManager& packageManager = PackageManager::instance();
+       packageManager.setEventCallback(packageEventHandler, this);
+
+       zoneProcessMonitor();
+
+       initializeCreatedZoneList();
+       for (std::string& name : createdZoneList) {
+               if (name == ZONE_DEFAULT_OWNER) {
+                       continue;
+               }
+
+               runtime::User zone(name);
+               int noti = notification_register_detailed_changed_cb_for_uid(notiProxyCallback, &name, zone.getUid());
+               notiProxyCallbackMap.insert(std::make_pair(name, noti));
+       }
 }
 
 ZoneManager::~ZoneManager()
 {
-    PackageManager& packageManager = PackageManager::instance();
-    packageManager.unsetEventCallback();
+       PackageManager& packageManager = PackageManager::instance();
+       packageManager.unsetEventCallback();
 }
 
 int ZoneManager::createZone(const std::string& name, const std::string& manifest)
 {
-    auto provisioningWorker = [name, manifest, this]() {
-        std::unique_ptr<xml::Document> manifestFile;
-
-        try {
-            //create zone user by gumd
-            GumUser *guser = gum_user_create_sync(FALSE);
-            g_object_set(G_OBJECT(guser), "username", name.c_str(),
-                            "usertype", GUM_USERTYPE_SECURITY, NULL);
-            gboolean ret = gum_user_add_sync(guser);
-            g_object_unref(guser);
+       auto provisioningWorker = [name, manifest, this]() {
+               std::unique_ptr<xml::Document> manifestFile;
 
-            if (!ret) {
-                throw runtime::Exception("Failed to remove user (" + name + ") by gumd");
-            }
+               try {
+                       //create zone user by gumd
+                       GumUser *guser = gum_user_create_sync(FALSE);
+                       g_object_set(G_OBJECT(guser), "username", name.c_str(),
+                                                       "usertype", GUM_USERTYPE_SECURITY, NULL);
+                       gboolean ret = gum_user_add_sync(guser);
+                       g_object_unref(guser);
 
-            runtime::User user(name);
+                       if (!ret) {
+                               throw runtime::Exception("Failed to remove user (" + name + ") by gumd");
+                       }
 
-            maskUserServices(user);
+                       runtime::User user(name);
 
-            manifestFile.reset(xml::Parser::parseString(manifest));
-            mode_t omask = ::umask(0077);
-            manifestFile->write(ZONE_MANIFEST_DIR + name + ".xml", "UTF-8", true);
-            ::umask(omask);
+                       maskUserServices(user);
 
-            //TODO: write container owner info
+                       manifestFile.reset(xml::Parser::parseString(manifest));
+                       mode_t omask = ::umask(0077);
+                       manifestFile->write(ZONE_MANIFEST_DIR + name + ".xml", "UTF-8", true);
+                       ::umask(omask);
 
-            //unlock the user
-            setZoneState(user.getUid(), 1);
+                       //TODO: write container owner info
 
-            //wait for launchpad in the zone
-            sleep(1);
+                       //unlock the user
+                       setZoneState(user.getUid(), 1);
 
-            auto it = createdZoneList.insert(createdZoneList.begin(), name);
-            int noti = notification_register_detailed_changed_cb_for_uid(notiProxyCallback, &(*it), user.getUid());
-            notiProxyCallbackMap.insert(std::make_pair(name, noti));
-            context.notify("ZoneManager::created", name, std::string());
-        } catch (runtime::Exception& e) {
-            ERROR(e.what());
-            context.notify("ZoneManager::removed", name, std::string());
-        }
+                       //wait for launchpad in the zone
+                       sleep(1);
 
-    };
+                       auto it = createdZoneList.insert(createdZoneList.begin(), name);
+                       int noti = notification_register_detailed_changed_cb_for_uid(notiProxyCallback, &(*it), user.getUid());
+                       notiProxyCallbackMap.insert(std::make_pair(name, noti));
+                       context.notify("ZoneManager::created", name, std::string());
+               } catch (runtime::Exception& e) {
+                       ERROR(e.what());
+                       context.notify("ZoneManager::removed", name, std::string());
+               }
+       };
 
-    std::thread asyncWork(provisioningWorker);
-    asyncWork.detach();
+       std::thread asyncWork(provisioningWorker);
+       asyncWork.detach();
 
-    return 0;
+       return 0;
 }
 
 int ZoneManager::removeZone(const std::string& name)
 {
-    if (lockZone(name) != 0) {
-        return -1;
-    }
-
-    try {
-        runtime::File manifest(ZONE_MANIFEST_DIR + name + ".xml");
-        manifest.remove();
-    }  catch (runtime::Exception& e) {
-        return -1;
-    }
-
-    auto remove = [name, this] {
-        try {
-            runtime::User user(name);
-
-            //remove zone user
-            GumUser *guser = gum_user_get_sync(user.getUid(), FALSE);
-            gboolean ret = gum_user_delete_sync(guser, TRUE);
-            g_object_unref(guser);
-
-            if (!ret) {
-                throw runtime::Exception("Failed to remove user (" + name + ") by gumd");
-            }
-
-            for (std::vector<std::string>::iterator it = createdZoneList.begin();
-                 it != createdZoneList.end(); it++) {
-                createdZoneList.erase(it);
-            }
-            notiProxyCallbackMap.erase(name);
-            context.notify("ZoneManager::removed", name, std::string());
-        } catch (runtime::Exception& e) {
-            ERROR(e.what());
-            return;
-        }
-    };
-
-    std::thread asyncWork(remove);
-    asyncWork.detach();
-
-    return 0;
+       if (lockZone(name) != 0) {
+               return -1;
+       }
+
+       try {
+               runtime::File manifest(ZONE_MANIFEST_DIR + name + ".xml");
+               manifest.remove();
+       }  catch (runtime::Exception& e) {
+               return -1;
+       }
+
+       auto remove = [name, this] {
+               try {
+                       runtime::User user(name);
+
+                       //remove zone user
+                       GumUser *guser = gum_user_get_sync(user.getUid(), FALSE);
+                       gboolean ret = gum_user_delete_sync(guser, TRUE);
+                       g_object_unref(guser);
+
+                       if (!ret) {
+                               throw runtime::Exception("Failed to remove user (" + name + ") by gumd");
+                       }
+
+                       for (std::vector<std::string>::iterator it = createdZoneList.begin();
+                                it != createdZoneList.end(); it++) {
+                               createdZoneList.erase(it);
+                       }
+                       notiProxyCallbackMap.erase(name);
+                       context.notify("ZoneManager::removed", name, std::string());
+               } catch (runtime::Exception& e) {
+                       ERROR(e.what());
+                       return;
+               }
+       };
+
+       std::thread asyncWork(remove);
+       asyncWork.detach();
+
+       return 0;
 }
 
 int ZoneManager::lockZone(const std::string& name)
 {
-    try {
-        runtime::User user(name);
-        setZoneState(user.getUid(), 0);
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
-
-    return 0;
+       try {
+               runtime::User user(name);
+               setZoneState(user.getUid(), 0);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
 }
 
 int ZoneManager::unlockZone(const std::string& name)
 {
-    try {
-        runtime::User user(name);
-        setZoneState(user.getUid(), 1);
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
-
-    return 0;
+       try {
+               runtime::User user(name);
+               setZoneState(user.getUid(), 1);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
 }
 
 int ZoneManager::getZoneState(const std::string& name)
 {
-    auto it = std::find(createdZoneList.begin(), createdZoneList.end(), name);
-    if (it == createdZoneList.end()) {
-        return 0;
-    }
-
-    try {
-        runtime::User user(name);
-        dbus::Connection& systemDBus = dbus::Connection::getSystem();
-        const dbus::Variant& var = systemDBus.methodcall
-                                           ("org.freedesktop.login1",
-                                            "/org/freedesktop/login1",
-                                            "org.freedesktop.login1.Manager",
-                                            "GetUser",
-                                            -1, "(o)", "(u)", user.getUid());
-        if (var) {
-            return ZoneManager::State::Running;
-        } else {
-            return ZoneManager::State::Locked;
-        }
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return 0;
-    }
-
-    return 0;
+       auto it = std::find(createdZoneList.begin(), createdZoneList.end(), name);
+       if (it == createdZoneList.end()) {
+               return 0;
+       }
+
+       try {
+               runtime::User user(name);
+               dbus::Connection& systemDBus = dbus::Connection::getSystem();
+               const dbus::Variant& var = systemDBus.methodcall
+                                                                                  ("org.freedesktop.login1",
+                                                                                       "/org/freedesktop/login1",
+                                                                                       "org.freedesktop.login1.Manager",
+                                                                                       "GetUser",
+                                                                                       -1, "(o)", "(u)", user.getUid());
+               if (var) {
+                       return ZoneManager::State::Running;
+               } else {
+                       return ZoneManager::State::Locked;
+               }
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return 0;
+       }
+
+       return 0;
 }
 
 std::vector<std::string> ZoneManager::getZoneList(int state)
 {
-    std::vector<std::string> list;
-
-    for (const std::string& name : createdZoneList) {
-        if (getZoneState(name) & state) {
-            list.push_back(name);
-        }
-    }
-    return list;
+       std::vector<std::string> list;
+
+       for (const std::string& name : createdZoneList) {
+               if (getZoneState(name) & state) {
+                       list.push_back(name);
+               }
+       }
+       return list;
 }
 
 int ZoneManager::resetZonePassword(const std::string& name, const std::string& newPassword)
 {
-    try {
-        runtime::User user(name);
-        int ret = auth_passwd_reset_passwd(AUTH_PWD_NORMAL, user.getUid(), newPassword.c_str());
-        if (ret != AUTH_PASSWD_API_SUCCESS) {
-            throw runtime::Exception("Failed to reset password for " + name);
-        }
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
-
-    return 0;
+       try {
+               runtime::User user(name);
+               int ret = auth_passwd_reset_passwd(AUTH_PWD_NORMAL, user.getUid(), newPassword.c_str());
+               if (ret != AUTH_PASSWD_API_SUCCESS) {
+                       throw runtime::Exception("Failed to reset password for " + name);
+               }
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       return 0;
 }
 
 ZoneManager zoneManager(Server::instance());
index 470f12f..8511ba4 100644 (file)
 SET(API_TEST_TARGET    "dpm-api-tests")
 
 SET(API_TEST_SOURCES main.c
-                     testbench.c
-                     admin.c
-                     application.c
-                     context.c
-                     bluetooth.c
-                     manager.c
-                     restriction.c
-                     security.c
-                     wifi.c
+                                        testbench.c
+                                        admin.c
+                                        application.c
+                                        context.c
+                                        bluetooth.c
+                                        manager.c
+                                        restriction.c
+                                        security.c
+                                        wifi.c
 )
 
 INCLUDE("${TIZEN_PROFILE_NAME}.cmake")
index 8f9037f..b534c10 100644 (file)
 
 static int admin_register_client(struct testcase* tc)
 {
-    int ret;
-    device_policy_manager_h handle;
+       int ret;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    ret = TEST_SUCCESSED;
-    if (dpm_admin_register_client(handle, "org.tizen.dpm-toolkit") != DPM_ERROR_NONE) {
-        ret = TEST_FAILED;
-    }
+       ret = TEST_SUCCESSED;
+       if (dpm_admin_register_client(handle, "org.tizen.dpm-toolkit") != DPM_ERROR_NONE) {
+               ret = TEST_FAILED;
+       }
 
-    dpm_manager_destroy(handle);
+       dpm_manager_destroy(handle);
 
-    return ret;
+       return ret;
 }
 
 static int admin_deregister_client(struct testcase* tc)
 {
-    int ret;
-    device_policy_manager_h handle;
+       int ret;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    ret = TEST_SUCCESSED;
-    if (dpm_admin_deregister_client(handle, "org.tizen.dpm-toolkit") != DPM_ERROR_NONE) {
-        ret = TEST_FAILED;
-    }
+       ret = TEST_SUCCESSED;
+       if (dpm_admin_deregister_client(handle, "org.tizen.dpm-toolkit") != DPM_ERROR_NONE) {
+               ret = TEST_FAILED;
+       }
 
-    dpm_manager_destroy(handle);
+       dpm_manager_destroy(handle);
 
-    return ret;
+       return ret;
 }
 
 struct testcase admin_testcase_register_client = {
-    .description = "admin_testcase_register_client",
-    .handler = admin_register_client
+       .description = "admin_testcase_register_client",
+       .handler = admin_register_client
 };
 
 struct testcase admin_testcase_deregister_client = {
-    .description = "admin_testcase_deregister_client",
-    .handler = admin_deregister_client
+       .description = "admin_testcase_deregister_client",
+       .handler = admin_deregister_client
 };
 
 void TESTCASE_CONSTRUCTOR admin_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&admin_testcase_deregister_client);
-    testbench_populate_testcase(&admin_testcase_register_client);
+       testbench_populate_testcase(&admin_testcase_deregister_client);
+       testbench_populate_testcase(&admin_testcase_register_client);
 }
index 9fc507d..5774759 100644 (file)
 
 static int application_mode_restriction(struct testcase* tc)
 {
-    int allow = false;
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_application_set_mode_restriction(handle, DPM_PACKAGE_RESTRICTION_MODE_ALL) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    if (dpm_application_get_mode_restriction(handle, &allow) != DPM_ERROR_NONE) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    if (dpm_application_unset_mode_restriction(handle, DPM_PACKAGE_RESTRICTION_MODE_ALL) != DPM_ERROR_NONE) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       int allow = false;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_application_set_mode_restriction(handle, DPM_PACKAGE_RESTRICTION_MODE_ALL) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_application_get_mode_restriction(handle, &allow) != DPM_ERROR_NONE) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_application_unset_mode_restriction(handle, DPM_PACKAGE_RESTRICTION_MODE_ALL) != DPM_ERROR_NONE) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int application_privilege_restriction(struct testcase* tc)
 {
-    int allow = false;
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_application_add_privilege_to_blacklist(handle, 0, "http://tizen.org/privilege/internet") != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    if (dpm_application_check_privilege_is_blacklisted(handle, 0, "http://tizen.org/privilege/internet", &allow) != DPM_ERROR_NONE) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    if (dpm_application_remove_privilege_from_blacklist(handle, 0, "http://tizen.org/privilege/internet") != DPM_ERROR_NONE) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       int allow = false;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_application_add_privilege_to_blacklist(handle, 0, "http://tizen.org/privilege/internet") != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_application_check_privilege_is_blacklisted(handle, 0, "http://tizen.org/privilege/internet", &allow) != DPM_ERROR_NONE) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_application_remove_privilege_from_blacklist(handle, 0, "http://tizen.org/privilege/internet") != DPM_ERROR_NONE) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 struct testcase application_testcase_privilege_restriction = {
-    .description = "application_testcase_privilege_restriction",
-    .handler = application_privilege_restriction
+       .description = "application_testcase_privilege_restriction",
+       .handler = application_privilege_restriction
 };
 
 struct testcase application_testcase_mode_restriction = {
-    .description = "application_testcase_mode_restriction",
-    .handler = application_mode_restriction
+       .description = "application_testcase_mode_restriction",
+       .handler = application_mode_restriction
 };
 
 void TESTCASE_CONSTRUCTOR application_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&application_testcase_mode_restriction);
-    testbench_populate_testcase(&application_testcase_privilege_restriction);
+       testbench_populate_testcase(&application_testcase_mode_restriction);
+       testbench_populate_testcase(&application_testcase_privilege_restriction);
 }
index c2c852c..6775df5 100644 (file)
 
 static int bluetooth_add_device_to_blacklist(struct testcase* tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    const char* dummy_mac = "e8:11:32:30:78:9c";
-    if (dpm_bluetooth_add_device_to_blacklist(handle, dummy_mac) != 0) {
-        printf("Failed to add device from blacklist\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
+       const char* dummy_mac = "e8:11:32:30:78:9c";
+       if (dpm_bluetooth_add_device_to_blacklist(handle, dummy_mac) != 0) {
+               printf("Failed to add device from blacklist\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
 
-    dpm_manager_destroy(handle);
+       dpm_manager_destroy(handle);
 
-    return TEST_SUCCESSED;
+       return TEST_SUCCESSED;
 }
 
 static int bluetooth_remove_device_from_blacklist(struct testcase* tc)
 {
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    const char* dummy_mac = "e8:11:32:30:78:9c";
-    if (dpm_bluetooth_remove_device_from_blacklist(handle, dummy_mac) != 0) {
-        printf("Failed to remove device from blacklist\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       const char* dummy_mac = "e8:11:32:30:78:9c";
+       if (dpm_bluetooth_remove_device_from_blacklist(handle, dummy_mac) != 0) {
+               printf("Failed to remove device from blacklist\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int bluetooth_device_restriction(struct testcase* tc)
 {
-    int allow = false;
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_bluetooth_set_device_restriction(handle, true) != 0) {
-        printf("Failed to set device restriction\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    // the 'allow' will be always 'true' before server/bluetooth.cpp has been implemented.
-    if (dpm_bluetooth_is_device_restricted(handle, &allow) != DPM_ERROR_NONE) {
-        printf("Failed to check device restriction\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       int allow = false;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_bluetooth_set_device_restriction(handle, true) != 0) {
+               printf("Failed to set device restriction\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_bluetooth_is_device_restricted(handle, &allow) != DPM_ERROR_NONE) {
+               printf("Failed to check device restriction\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int bluetooth_add_uuid_to_blacklist(struct testcase* tc)
 {
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    const char* dummy_uuid = "ff8ca1f3-0221-40c9-91fd-25ebbbfa68c3";
-    if (dpm_bluetooth_add_uuid_to_blacklist(handle, dummy_uuid) != 0) {
-        printf("Failed to add uuid to blacklist\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       const char* dummy_uuid = "ff8ca1f3-0221-40c9-91fd-25ebbbfa68c3";
+       if (dpm_bluetooth_add_uuid_to_blacklist(handle, dummy_uuid) != 0) {
+               printf("Failed to add uuid to blacklist\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int bluetooth_remove_uuid_from_blacklist(struct testcase* tc)
 {
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    const char* dummy_uuid = "ff8ca1f3-0221-40c9-91fd-25ebbbfa68c3";
-    if (dpm_bluetooth_remove_uuid_from_blacklist(handle, dummy_uuid) != 0) {
-        printf("Failed to remove uuid from blacklist\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       const char* dummy_uuid = "ff8ca1f3-0221-40c9-91fd-25ebbbfa68c3";
+       if (dpm_bluetooth_remove_uuid_from_blacklist(handle, dummy_uuid) != 0) {
+               printf("Failed to remove uuid from blacklist\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int bluetooth_uuid_restriction(struct testcase* tc)
 {
-    int allow = false;
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_bluetooth_set_uuid_restriction(handle, true) != 0) {
-        printf("Failed to set uuid restriction\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    // the 'allow' will be always 'true' before server/bluetooth.cpp has been implemented.
-    if (dpm_bluetooth_is_uuid_restricted(handle, &allow) != DPM_ERROR_NONE) {
-        printf("Failed to check uuid restriction\n");
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       int allow = false;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_bluetooth_set_uuid_restriction(handle, true) != 0) {
+               printf("Failed to set uuid restriction\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_bluetooth_is_uuid_restricted(handle, &allow) != DPM_ERROR_NONE) {
+               printf("Failed to check uuid restriction\n");
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 struct testcase bluetooth_testcase_add_device_to_blacklist = {
-    .description = "dpm_add_device_to_blacklist",
-    .handler = bluetooth_add_device_to_blacklist
+       .description = "dpm_add_device_to_blacklist",
+       .handler = bluetooth_add_device_to_blacklist
 };
 
 struct testcase bluetooth_testcase_remove_device_from_blacklist = {
-    .description = "dpm_remove_device_from_blacklist",
-    .handler = bluetooth_remove_device_from_blacklist
+       .description = "dpm_remove_device_from_blacklist",
+       .handler = bluetooth_remove_device_from_blacklist
 };
 
 struct testcase bluetooth_testcase_device_restriction = {
-    .description = "dpm_device_restriction",
-    .handler = bluetooth_device_restriction
+       .description = "dpm_device_restriction",
+       .handler = bluetooth_device_restriction
 };
 
 struct testcase bluetooth_testcase_add_uuid_to_blacklist = {
-    .description = "dpm_add_uuid_to_blacklist",
-    .handler = bluetooth_add_uuid_to_blacklist
+       .description = "dpm_add_uuid_to_blacklist",
+       .handler = bluetooth_add_uuid_to_blacklist
 };
 
 struct testcase bluetooth_testcase_remove_uuid_from_blacklist = {
-    .description = "dpm_remove_uuid_from_blacklist",
-    .handler = bluetooth_remove_uuid_from_blacklist
+       .description = "dpm_remove_uuid_from_blacklist",
+       .handler = bluetooth_remove_uuid_from_blacklist
 };
 
 struct testcase bluetooth_testcase_uuid_restriction = {
-    .description = "dpm_uuid_restriction",
-    .handler = bluetooth_uuid_restriction
+       .description = "dpm_uuid_restriction",
+       .handler = bluetooth_uuid_restriction
 };
 
 void TESTCASE_CONSTRUCTOR bluetooth_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&bluetooth_testcase_add_device_to_blacklist);
-    testbench_populate_testcase(&bluetooth_testcase_remove_device_from_blacklist);
-    testbench_populate_testcase(&bluetooth_testcase_device_restriction);
-    testbench_populate_testcase(&bluetooth_testcase_add_uuid_to_blacklist);
-    testbench_populate_testcase(&bluetooth_testcase_remove_uuid_from_blacklist);
-    testbench_populate_testcase(&bluetooth_testcase_uuid_restriction);
+       testbench_populate_testcase(&bluetooth_testcase_add_device_to_blacklist);
+       testbench_populate_testcase(&bluetooth_testcase_remove_device_from_blacklist);
+       testbench_populate_testcase(&bluetooth_testcase_device_restriction);
+       testbench_populate_testcase(&bluetooth_testcase_add_uuid_to_blacklist);
+       testbench_populate_testcase(&bluetooth_testcase_remove_uuid_from_blacklist);
+       testbench_populate_testcase(&bluetooth_testcase_uuid_restriction);
 }
index ac6dfb2..f7d054d 100644 (file)
@@ -15,5 +15,5 @@
 #
 
 SET(API_TEST_SOURCES    ${API_TEST_SOURCES}
-                        password.c
+                                               password.c
 )
index f6a9169..36b0471 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <stdio.h>
 #include <unistd.h>
@@ -28,121 +29,121 @@ static volatile int completed = 0;
 
 static void device_policy_handle_callback(const char* name, const char* state, void* user_data)
 {
-    int *triggered = user_data;
-    printf("*");
-    *triggered = 1;
+       int *triggered = user_data;
+       printf("*");
+       *triggered = 1;
 }
 
 static void* getter(void* data)
 {
-    int i = 0;
-    dpm_context_h handle;
-    volatile int triggered = 0;;
+       int i = 0;
+       dpm_context_h handle;
+       volatile int triggered = 0;;
 
-    printf("Policy receiver %d is ready\n", *((int *)data));
+       printf("Policy receiver %d is ready\n", *((int *)data));
 
-    while(1) {
-        handle = dpm_context_create();
-        if (handle == NULL) {
-            printf("Failed to create client handle\n");
-            return (void *)TEST_FAILED;
-        }
+       while (1) {
+               handle = dpm_context_create();
+               if (handle == NULL) {
+                       printf("Failed to create client handle\n");
+                       return (void *)TEST_FAILED;
+               }
 
-        int id;
-        dpm_context_add_policy_changed_cb(handle, "camera", device_policy_handle_callback, (void *)&triggered, &id);
+               int id;
+               dpm_context_add_policy_changed_cb(handle, "camera", device_policy_handle_callback, (void *)&triggered, &id);
 
-        while (!triggered) {
-            if (completed) {
-                dpm_context_remove_policy_changed_cb(handle, id);
-                dpm_context_destroy(handle);
-                return (void *)TEST_SUCCESSED;
-            }
-        }
+               while (!triggered) {
+                       if (completed) {
+                               dpm_context_remove_policy_changed_cb(handle, id);
+                               dpm_context_destroy(handle);
+                               return (void *)TEST_SUCCESSED;
+                       }
+               }
 
-        triggered = 0;
+               triggered = 0;
 
-        if ((i % 10) == 0) {
-            printf("\n");
-        }
+               if ((i % 10) == 0) {
+                       printf("\n");
+               }
 
-        dpm_context_remove_policy_changed_cb(handle, id);
-        dpm_context_destroy(handle);
+               dpm_context_remove_policy_changed_cb(handle, id);
+               dpm_context_destroy(handle);
 
-        printf("G");
+               printf("G");
 
-        i++;
-    }
+               i++;
+       }
 
-    return (void *)TEST_SUCCESSED;
+       return (void *)TEST_SUCCESSED;
 }
 
 static void* setter(void *data)
 {
-    int i;
-    dpm_context_h handle;
+       int i;
+       dpm_context_h handle;
 
-    printf("Thread setter %d is ready\n", *((int *)data));
+       printf("Thread setter %d is ready\n", *((int *)data));
 
-    for (i = 0; i < MAX_ITERATIONS; i++) {
-        handle = dpm_context_create();
-        if (handle == NULL) {
-            printf("Failed to create client handle\n");
-            completed = 1;
-            return (void *)TEST_FAILED;
-        }
+       for (i = 0; i < MAX_ITERATIONS; i++) {
+               handle = dpm_context_create();
+               if (handle == NULL) {
+                       printf("Failed to create client handle\n");
+                       completed = 1;
+                       return (void *)TEST_FAILED;
+               }
 
-        int state = 0;
+               int state = 0;
 
-        dpm_restriction_get_camera_state(handle, &state);
-        dpm_restriction_set_camera_state(handle, state ? 0 : 1);
+               dpm_restriction_get_camera_state(handle, &state);
+               dpm_restriction_set_camera_state(handle, state ? 0 : 1);
 
-        if ((i % 10) == 0) {
-            printf("\n");
-        }
+               if ((i % 10) == 0) {
+                       printf("\n");
+               }
 
-        dpm_context_destroy(handle);
+               dpm_context_destroy(handle);
 
-    }
+       }
 
-    printf("\n");
+       printf("\n");
 
-    completed = 1;
+       completed = 1;
 
-    return (void *)TEST_SUCCESSED;
+       return (void *)TEST_SUCCESSED;
 }
 
 static int device_policy_handle(struct testcase* tc)
 {
-    pthread_t handle[MAX_WORKER_THREADS];
-    int i, ret, status, idx[MAX_WORKER_THREADS];
-
-    for (i = 0; i < MAX_WORKER_THREADS; i++) {
-        idx[i] = i;
-
-        if (i == 0) {
-            pthread_create(&handle[i], NULL, setter, (void *)&idx[i]);
-        } else {
-            pthread_create(&handle[i], NULL, getter, (void *)&idx[i]);
-        }
-    }
-
-    ret = TEST_SUCCESSED;
-    for (i = 0; i < MAX_WORKER_THREADS; i++) {
-        pthread_join(handle[i], (void *)&status);
-        if (status == TEST_FAILED) {
-            ret = TEST_FAILED;
-        }
-    }
-
-    return ret;
+       pthread_t handle[MAX_WORKER_THREADS];
+       int i, ret, status, idx[MAX_WORKER_THREADS];
+
+       for (i = 0; i < MAX_WORKER_THREADS; i++) {
+               idx[i] = i;
+
+               if (i == 0) {
+                       pthread_create(&handle[i], NULL, setter, (void *)&idx[i]);
+               } else {
+                       pthread_create(&handle[i], NULL, getter, (void *)&idx[i]);
+               }
+       }
+
+       ret = TEST_SUCCESSED;
+       for (i = 0; i < MAX_WORKER_THREADS; i++) {
+               pthread_join(handle[i], (void *)&status);
+               if (status == TEST_FAILED) {
+                       ret = TEST_FAILED;
+               }
+       }
+
+       return ret;
 }
 
 struct testcase device_policy_handle_testcase = {
-    .description = "device policy handle",
-    .handler = device_policy_handle
+       .description = "device policy handle",
+       .handler = device_policy_handle
 };
 
 void TESTCASE_CONSTRUCTOR device_policy_handle_build_testcase(void)
 {
-    testbench_populate_testcase(&device_policy_handle_testcase);
+       testbench_populate_testcase(&device_policy_handle_testcase);
 }
index fc4a304..66ff896 100644 (file)
@@ -15,5 +15,5 @@
 #
 
 SET(API_TEST_SOURCES    ${API_TEST_SOURCES}
-                        password.c
+                                               password.c
 )
index 41fe901..4260479 100644 (file)
@@ -1,23 +1,24 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include "testbench.h"
 
 int main(int argc, char** argv)
 {
-    testbench_execute_testcases();
+       testbench_execute_testcases();
 
-    return 0;
+       return 0;
 }
index 9b884a9..3b09183 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <stdio.h>
 #include <unistd.h>
@@ -28,121 +29,121 @@ static volatile int completed = 0;
 
 static void device_policy_handle_callback(const char* name, const char* state, void* user_data)
 {
-    int *triggered = user_data;
-    printf("*");
-    *triggered = 1;
+       int *triggered = user_data;
+       printf("*");
+       *triggered = 1;
 }
 
 static void* getter(void* data)
 {
-    int i = 0;
-    device_policy_manager_h handle;
-    volatile int triggered = 0;;
+       int i = 0;
+       device_policy_manager_h handle;
+       volatile int triggered = 0;;
 
-    printf("Policy receiver %d is ready\n", *((int *)data));
+       printf("Policy receiver %d is ready\n", *((int *)data));
 
-    while(1) {
-        handle = dpm_manager_create();
-        if (handle == NULL) {
-            printf("Failed to create client handle\n");
-            return (void *)TEST_FAILED;
-        }
+       while (1) {
+               handle = dpm_manager_create();
+               if (handle == NULL) {
+                       printf("Failed to create client handle\n");
+                       return (void *)TEST_FAILED;
+               }
 
-        int id;
-        dpm_add_policy_changed_cb(handle, "camera", device_policy_handle_callback, (void *)&triggered, &id);
+               int id;
+               dpm_add_policy_changed_cb(handle, "camera", device_policy_handle_callback, (void *)&triggered, &id);
 
-        while (!triggered) {
-            if (completed) {
-                dpm_remove_policy_changed_cb(handle, id);
-                dpm_manager_destroy(handle);
-                return (void *)TEST_SUCCESSED;
-            }
-        }
+               while (!triggered) {
+                       if (completed) {
+                               dpm_remove_policy_changed_cb(handle, id);
+                               dpm_manager_destroy(handle);
+                               return (void *)TEST_SUCCESSED;
+                       }
+               }
 
-        triggered = 0;
+               triggered = 0;
 
-        if ((i % 10) == 0) {
-            printf("\n");
-        }
+               if ((i % 10) == 0) {
+                       printf("\n");
+               }
 
-        dpm_remove_policy_changed_cb(handle, id);
-        dpm_manager_destroy(handle);
+               dpm_remove_policy_changed_cb(handle, id);
+               dpm_manager_destroy(handle);
 
-        printf("G");
+               printf("G");
 
-        i++;
-    }
+               i++;
+       }
 
-    return (void *)TEST_SUCCESSED;
+       return (void *)TEST_SUCCESSED;
 }
 
 static void* setter(void *data)
 {
-    int i;
-    device_policy_manager_h handle;
+       int i;
+       device_policy_manager_h handle;
 
-    printf("Thread setter %d is ready\n", *((int *)data));
+       printf("Thread setter %d is ready\n", *((int *)data));
 
-    for (i = 0; i < MAX_ITERATIONS; i++) {
-        handle = dpm_manager_create();
-        if (handle == NULL) {
-            printf("Failed to create client handle\n");
-            completed = 1;
-            return (void *)TEST_FAILED;
-        }
+       for (i = 0; i < MAX_ITERATIONS; i++) {
+               handle = dpm_manager_create();
+               if (handle == NULL) {
+                       printf("Failed to create client handle\n");
+                       completed = 1;
+                       return (void *)TEST_FAILED;
+               }
 
-        int state = 0;
+               int state = 0;
 
-        dpm_restriction_get_camera_state(handle, &state);
-        dpm_restriction_set_camera_state(handle, state ? 0 : 1);
+               dpm_restriction_get_camera_state(handle, &state);
+               dpm_restriction_set_camera_state(handle, state ? 0 : 1);
 
-        if ((i % 10) == 0) {
-            printf("\n");
-        }
+               if ((i % 10) == 0) {
+                       printf("\n");
+               }
 
-        dpm_manager_destroy(handle);
+               dpm_manager_destroy(handle);
 
-    }
+       }
 
-    printf("\n");
+       printf("\n");
 
-    completed = 1;
+       completed = 1;
 
-    return (void *)TEST_SUCCESSED;
+       return (void *)TEST_SUCCESSED;
 }
 
 static int device_context_handle(struct testcase* tc)
 {
-    pthread_t handle[MAX_WORKER_THREADS];
-    int i, ret, status, idx[MAX_WORKER_THREADS];
-
-    for (i = 0; i < MAX_WORKER_THREADS; i++) {
-        idx[i] = i;
-
-        if (i == 0) {
-            pthread_create(&handle[i], NULL, setter, (void *)&idx[i]);
-        } else {
-            pthread_create(&handle[i], NULL, getter, (void *)&idx[i]);
-        }
-    }
-
-    ret = TEST_SUCCESSED;
-    for (i = 0; i < MAX_WORKER_THREADS; i++) {
-        pthread_join(handle[i], (void *)&status);
-        if (status == TEST_FAILED) {
-            ret = TEST_FAILED;
-        }
-    }
-
-    return ret;
+       pthread_t handle[MAX_WORKER_THREADS];
+       int i, ret, status, idx[MAX_WORKER_THREADS];
+
+       for (i = 0; i < MAX_WORKER_THREADS; i++) {
+               idx[i] = i;
+
+               if (i == 0) {
+                       pthread_create(&handle[i], NULL, setter, (void *)&idx[i]);
+               } else {
+                       pthread_create(&handle[i], NULL, getter, (void *)&idx[i]);
+               }
+       }
+
+       ret = TEST_SUCCESSED;
+       for (i = 0; i < MAX_WORKER_THREADS; i++) {
+               pthread_join(handle[i], (void *)&status);
+               if (status == TEST_FAILED) {
+                       ret = TEST_FAILED;
+               }
+       }
+
+       return ret;
 }
 
 struct testcase device_context_handle_testcase = {
-    .description = "device context handle",
-    .handler = device_context_handle
+       .description = "device context handle",
+       .handler = device_context_handle
 };
 
 void TESTCASE_CONSTRUCTOR device_context_handle_build_testcase(void)
 {
-    testbench_populate_testcase(&device_context_handle_testcase);
+       testbench_populate_testcase(&device_context_handle_testcase);
 }
index 64efca4..96ae0fd 100644 (file)
@@ -15,6 +15,6 @@
 #
 
 SET(API_TEST_SOURCES    ${API_TEST_SOURCES}
-                        password.c
-                        zone.c
+                                               password.c
+                                               zone.c
 )
index 0059cd1..ff963c7 100644 (file)
 
 static int password_set_password_quality(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_UNSPECIFIED) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-    if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-    if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_SOMETHING) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-    if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_NUMERIC) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-    if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_ALPHABETIC) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-    if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_ALPHANUMERIC) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_UNSPECIFIED) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+       if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+       if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_SOMETHING) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+       if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_NUMERIC) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+       if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_ALPHABETIC) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+       if (dpm_password_set_quality(handle, DPM_PASSWORD_QUALITY_ALPHANUMERIC) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int password_get_password_quality(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    dpm_password_quality_e quality = DPM_PASSWORD_QUALITY_UNSPECIFIED;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_quality(handle, &quality) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       dpm_password_quality_e quality = DPM_PASSWORD_QUALITY_UNSPECIFIED;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_quality(handle, &quality) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_password_minimum_length(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_minimum_length(handle, 27) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_minimum_length(handle, 27) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_password_minimum_length(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int min_length = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_minimum_length(handle, &min_length) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int min_length = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_minimum_length(handle, &min_length) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_min_password_complex_chars(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_min_complex_chars(handle, 10) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_min_complex_chars(handle, 10) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_min_password_complex_chars(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int min_complex_chars = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_min_complex_chars(handle, &min_complex_chars) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int min_complex_chars = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_min_complex_chars(handle, &min_complex_chars) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_maximum_failed_password_for_wipe(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_maximum_failed_attempts_for_wipe(handle, 11) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_maximum_failed_attempts_for_wipe(handle, 11) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_maximum_failed_password_for_wipe(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int max_failed_attempts = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_maximum_failed_attempts_for_wipe(handle, &max_failed_attempts) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int max_failed_attempts = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_maximum_failed_attempts_for_wipe(handle, &max_failed_attempts) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_password_expires(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_expires(handle, 30) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_expires(handle, 30) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_password_expires(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int expires = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_expires(handle, &expires) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int expires = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_expires(handle, &expires) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_password_history(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_history(handle, 12) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_history(handle, 12) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_password_history(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int history = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_history(handle, &history) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int history = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_history(handle, &history) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_reset_password(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_reset(handle, "tizen") == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_reset(handle, "tizen") == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_enforce_password_change(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_enforce_change(handle) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_enforce_change(handle) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_max_inactivity_time_device_lock(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_max_inactivity_time_device_lock(handle, 30) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_max_inactivity_time_device_lock(handle, 30) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_max_inactivity_time_device_lock(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int max_inactivity_time = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_max_inactivity_time_device_lock(handle, &max_inactivity_time) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int max_inactivity_time = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_max_inactivity_time_device_lock(handle, &max_inactivity_time) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_password_status(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    dpm_password_status_e status = DPM_PASSWORD_STATUS_NORMAL;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    status = DPM_PASSWORD_STATUS_CHANGE_REQUIRED;
-    if (dpm_password_set_status(handle, status) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-    status = DPM_PASSWORD_STATUS_CHANGED;
-    if (dpm_password_set_status(handle, status) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       device_policy_manager_h handle;
+       dpm_password_status_e status = DPM_PASSWORD_STATUS_NORMAL;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       status = DPM_PASSWORD_STATUS_CHANGE_REQUIRED;
+       if (dpm_password_set_status(handle, status) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+       status = DPM_PASSWORD_STATUS_CHANGED;
+       if (dpm_password_set_status(handle, status) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int password_set_password_pattern(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_pattern(handle, "[a-zA-Z]{4}[0-9]{4}") == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_pattern(handle, "[a-zA-Z]{4}[0-9]{4}") == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_password_pattern(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    char *passwd_pattern;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    dpm_password_get_pattern(handle, &passwd_pattern);
-    if (passwd_pattern != NULL) {
-        free(passwd_pattern);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       char *passwd_pattern;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       dpm_password_get_pattern(handle, &passwd_pattern);
+       if (passwd_pattern != NULL) {
+               free(passwd_pattern);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_delete_password_pattern(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_delete_pattern(handle) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_delete_pattern(handle) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_maximum_character_occurrences(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_maximum_character_occurrences(handle, 15) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_maximum_character_occurrences(handle, 15) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_maximum_character_occurrences(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int maximum_char_occurences = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_maximum_character_occurrences(handle, &maximum_char_occurences) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int maximum_char_occurences = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_maximum_character_occurrences(handle, &maximum_char_occurences) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_set_maximum_numeric_sequence_length(struct testcase *tc)
 {
-    device_policy_manager_h handle;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_password_set_maximum_numeric_sequence_length(handle, 7) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
+       if (dpm_password_set_maximum_numeric_sequence_length(handle, 7) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
 
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 static int password_get_maximum_numeric_sequence_length(struct testcase *tc)
 {
-    device_policy_manager_h handle;
-    int maximum_num_seq_length = 0;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_password_get_maximum_numeric_sequence_length(handle, &maximum_num_seq_length) == 0) {
-        dpm_manager_destroy(handle);
-        return TEST_SUCCESSED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_FAILED;
+       device_policy_manager_h handle;
+       int maximum_num_seq_length = 0;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_password_get_maximum_numeric_sequence_length(handle, &maximum_num_seq_length) == 0) {
+               dpm_manager_destroy(handle);
+               return TEST_SUCCESSED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_FAILED;
 }
 
 struct testcase security_testcase_set_password_quality = {
-    .description = "dpm_set_password_quality",
-    .handler = password_set_password_quality
+       .description = "dpm_set_password_quality",
+       .handler = password_set_password_quality
 };
 
 struct testcase security_testcase_get_password_quality = {
-    .description = "dpm_get_password_quality",
-    .handler = password_get_password_quality
+       .description = "dpm_get_password_quality",
+       .handler = password_get_password_quality
 };
 
 struct testcase security_testcase_set_password_minimum_length = {
-    .description = "dpm_set_password_minimum_length",
-    .handler = password_set_password_minimum_length
+       .description = "dpm_set_password_minimum_length",
+       .handler = password_set_password_minimum_length
 };
 
 struct testcase security_testcase_get_password_minimum_length = {
-    .description = "dpm_get_password_minimum_length",
-    .handler = password_get_password_minimum_length
+       .description = "dpm_get_password_minimum_length",
+       .handler = password_get_password_minimum_length
 };
 
 struct testcase security_testcase_set_min_password_complex_chars = {
-    .description = "dpm_set_min_password_complex_chars",
-    .handler = password_set_min_password_complex_chars
+       .description = "dpm_set_min_password_complex_chars",
+       .handler = password_set_min_password_complex_chars
 };
 
 struct testcase security_testcase_get_min_password_complex_chars = {
-    .description = "dpm_get_min_password_complex_chars",
-    .handler = password_get_min_password_complex_chars
+       .description = "dpm_get_min_password_complex_chars",
+       .handler = password_get_min_password_complex_chars
 };
 
 struct testcase security_testcase_set_maximum_failed_password_for_wipe = {
-    .description = "dpm_set_maximum_failed_password_for_wipe",
-    .handler = password_set_maximum_failed_password_for_wipe
+       .description = "dpm_set_maximum_failed_password_for_wipe",
+       .handler = password_set_maximum_failed_password_for_wipe
 };
 
 struct testcase security_testcase_get_maximum_failed_password_for_wipe = {
-    .description = "dpm_get_maximum_failed_password_for_wipe",
-    .handler = password_get_maximum_failed_password_for_wipe
+       .description = "dpm_get_maximum_failed_password_for_wipe",
+       .handler = password_get_maximum_failed_password_for_wipe
 };
 
 struct testcase security_testcase_set_password_expires = {
-    .description = "dpm_set_password_expires",
-    .handler = password_set_password_expires
+       .description = "dpm_set_password_expires",
+       .handler = password_set_password_expires
 };
 
 struct testcase security_testcase_get_password_expires = {
-    .description = "dpm_get_password_expires",
-    .handler = password_get_password_expires
+       .description = "dpm_get_password_expires",
+       .handler = password_get_password_expires
 };
 
 struct testcase security_testcase_set_password_history = {
-    .description = "dpm_set_password_history",
-    .handler = password_set_password_history
+       .description = "dpm_set_password_history",
+       .handler = password_set_password_history
 };
 
 struct testcase security_testcase_get_password_history = {
-    .description = "dpm_get_password_history",
-    .handler = password_get_password_history
+       .description = "dpm_get_password_history",
+       .handler = password_get_password_history
 };
 
 struct testcase security_testcase_reset_password = {
-    .description = "dpm_reset_password",
-    .handler = password_reset_password
+       .description = "dpm_reset_password",
+       .handler = password_reset_password
 };
 
 struct testcase security_testcase_enforce_password_change = {
-    .description = "dpm_enforce_password_change",
-    .handler = password_enforce_password_change
+       .description = "dpm_enforce_password_change",
+       .handler = password_enforce_password_change
 };
 
 struct testcase security_testcase_set_max_inactivity_time_device_lock = {
-    .description = "dpm_set_max_inactivity_time_device_lock",
-    .handler = password_set_max_inactivity_time_device_lock
+       .description = "dpm_set_max_inactivity_time_device_lock",
+       .handler = password_set_max_inactivity_time_device_lock
 };
 
 struct testcase security_testcase_get_max_inactivity_time_device_lock = {
-    .description = "dpm_get_max_inactivity_time_device_lock",
-    .handler = password_get_max_inactivity_time_device_lock
+       .description = "dpm_get_max_inactivity_time_device_lock",
+       .handler = password_get_max_inactivity_time_device_lock
 };
 
 struct testcase security_testcase_set_password_status = {
-    .description = "dpm_set_password_status",
-    .handler = password_set_password_status
+       .description = "dpm_set_password_status",
+       .handler = password_set_password_status
 };
 
 struct testcase security_testcase_set_password_pattern = {
-    .description = "dpm_set_password_pattern",
-    .handler = password_set_password_pattern
+       .description = "dpm_set_password_pattern",
+       .handler = password_set_password_pattern
 };
 
 struct testcase security_testcase_get_password_pattern = {
-    .description = "dpm_get_password_pattern",
-    .handler = password_get_password_pattern
+       .description = "dpm_get_password_pattern",
+       .handler = password_get_password_pattern
 };
 
 struct testcase security_testcase_delete_password_pattern = {
-    .description = "dpm_delete_password_pattern",
-    .handler = password_delete_password_pattern
+       .description = "dpm_delete_password_pattern",
+       .handler = password_delete_password_pattern
 };
 
 struct testcase security_testcase_set_maximum_character_occurrences = {
-    .description = "dpm_set_maximum_character_occurrences",
-    .handler = password_set_maximum_character_occurrences
+       .description = "dpm_set_maximum_character_occurrences",
+       .handler = password_set_maximum_character_occurrences
 };
 
 struct testcase security_testcase_get_maximum_character_occurrences = {
-    .description = "dpm_get_maximum_character_occurrences",
-    .handler = password_get_maximum_character_occurrences
+       .description = "dpm_get_maximum_character_occurrences",
+       .handler = password_get_maximum_character_occurrences
 };
 
 struct testcase security_testcase_set_maximum_numeric_sequence_length = {
-    .description = "dpm_set_maximum_numeric_sequence_length",
-    .handler = password_set_maximum_numeric_sequence_length
+       .description = "dpm_set_maximum_numeric_sequence_length",
+       .handler = password_set_maximum_numeric_sequence_length
 };
 
 struct testcase security_testcase_get_maximum_numeric_sequence_length = {
-    .description = "dpm_get_maximum_numeric_sequence_length",
-    .handler = password_get_maximum_numeric_sequence_length
+       .description = "dpm_get_maximum_numeric_sequence_length",
+       .handler = password_get_maximum_numeric_sequence_length
 };
 
 void TESTCASE_CONSTRUCTOR password_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&security_testcase_get_password_quality);
-    testbench_populate_testcase(&security_testcase_set_password_quality);
-    testbench_populate_testcase(&security_testcase_get_password_minimum_length);
-    testbench_populate_testcase(&security_testcase_set_password_minimum_length);
-    testbench_populate_testcase(&security_testcase_get_min_password_complex_chars);
-    testbench_populate_testcase(&security_testcase_set_min_password_complex_chars);
-    testbench_populate_testcase(&security_testcase_get_maximum_failed_password_for_wipe);
-    testbench_populate_testcase(&security_testcase_set_maximum_failed_password_for_wipe);
-    testbench_populate_testcase(&security_testcase_get_password_expires);
-    testbench_populate_testcase(&security_testcase_set_password_expires);
-    testbench_populate_testcase(&security_testcase_get_password_history);
-    testbench_populate_testcase(&security_testcase_set_password_history);
-    testbench_populate_testcase(&security_testcase_enforce_password_change);
-    testbench_populate_testcase(&security_testcase_get_max_inactivity_time_device_lock);
-    testbench_populate_testcase(&security_testcase_set_max_inactivity_time_device_lock);
-    testbench_populate_testcase(&security_testcase_set_password_status);
-    testbench_populate_testcase(&security_testcase_delete_password_pattern);
-    testbench_populate_testcase(&security_testcase_get_password_pattern);
-    testbench_populate_testcase(&security_testcase_set_password_pattern);
-    testbench_populate_testcase(&security_testcase_get_maximum_character_occurrences);
-    testbench_populate_testcase(&security_testcase_set_maximum_character_occurrences);
-    testbench_populate_testcase(&security_testcase_get_maximum_numeric_sequence_length);
-    testbench_populate_testcase(&security_testcase_set_maximum_numeric_sequence_length);
-    testbench_populate_testcase(&security_testcase_reset_password);
+       testbench_populate_testcase(&security_testcase_get_password_quality);
+       testbench_populate_testcase(&security_testcase_set_password_quality);
+       testbench_populate_testcase(&security_testcase_get_password_minimum_length);
+       testbench_populate_testcase(&security_testcase_set_password_minimum_length);
+       testbench_populate_testcase(&security_testcase_get_min_password_complex_chars);
+       testbench_populate_testcase(&security_testcase_set_min_password_complex_chars);
+       testbench_populate_testcase(&security_testcase_get_maximum_failed_password_for_wipe);
+       testbench_populate_testcase(&security_testcase_set_maximum_failed_password_for_wipe);
+       testbench_populate_testcase(&security_testcase_get_password_expires);
+       testbench_populate_testcase(&security_testcase_set_password_expires);
+       testbench_populate_testcase(&security_testcase_get_password_history);
+       testbench_populate_testcase(&security_testcase_set_password_history);
+       testbench_populate_testcase(&security_testcase_enforce_password_change);
+       testbench_populate_testcase(&security_testcase_get_max_inactivity_time_device_lock);
+       testbench_populate_testcase(&security_testcase_set_max_inactivity_time_device_lock);
+       testbench_populate_testcase(&security_testcase_set_password_status);
+       testbench_populate_testcase(&security_testcase_delete_password_pattern);
+       testbench_populate_testcase(&security_testcase_get_password_pattern);
+       testbench_populate_testcase(&security_testcase_set_password_pattern);
+       testbench_populate_testcase(&security_testcase_get_maximum_character_occurrences);
+       testbench_populate_testcase(&security_testcase_set_maximum_character_occurrences);
+       testbench_populate_testcase(&security_testcase_get_maximum_numeric_sequence_length);
+       testbench_populate_testcase(&security_testcase_set_maximum_numeric_sequence_length);
+       testbench_populate_testcase(&security_testcase_reset_password);
 }
index 994172b..9b62ceb 100644 (file)
@@ -28,60 +28,51 @@ static int restriction_##__name__(struct testcase *tc)                 \
 {                                                                      \
        device_policy_manager_h handle;                                    \
        int state, enable = false;                                         \
-                                                                       \
        handle = dpm_manager_create();                                     \
        if (handle == NULL) {                                              \
                printf("Failed to create client handle\n");                    \
                return TEST_FAILED;                                            \
        }                                                                  \
-                                                                       \
-    if (dpm_restriction_get_##__name__##_state(NULL, &state) == 0) {   \
+       if (dpm_restriction_get_##__name__##_state(NULL, &state) == 0) {   \
                printf("NULL handle test in getter failed\n");                 \
                dpm_context_destroy(handle);                                   \
                return TEST_FAILED;                                            \
-    }                                                                  \
-                                                                       \
-    if (dpm_restriction_get_##__name__##_state(handle, NULL) == 0) {   \
+       }                                                                  \
+       if (dpm_restriction_get_##__name__##_state(handle, NULL) == 0) {   \
                printf("NULL param test failed\n");                            \
                dpm_context_destroy(handle);                                   \
                return TEST_FAILED;                                            \
-    }                                                                  \
-                                                                       \
-    if (dpm_restriction_set_##__name__##_state(NULL, false) == 0) {    \
+       }                                                                  \
+       if (dpm_restriction_set_##__name__##_state(NULL, false) == 0) {    \
                printf("NULL handle test in setter failed\n");                 \
                dpm_context_destroy(handle);                                   \
                return TEST_FAILED;                                            \
-    }                                                                  \
-                                                                       \
-    if (dpm_restriction_get_##__name__##_state(handle, &state) != 0) { \
+       }                                                                  \
+       if (dpm_restriction_get_##__name__##_state(handle, &state) != 0) { \
                printf("Policy query failed\n");                               \
                dpm_context_destroy(handle);                                   \
                return TEST_FAILED;                                            \
-    }                                                                  \
-    enable = !state;                                                   \
+       }                                                                  \
+       enable = !state;                                                   \
        if (dpm_restriction_set_##__name__##_state(handle, enable) != 0) { \
                printf("Policy enforce failed\n");                             \
                dpm_context_destroy(handle);                                   \
                return TEST_FAILED;                                            \
        }                                                                  \
-                                                                       \
        dpm_restriction_get_##__name__##_state(handle, &enable);           \
        if (enable != !state) {                                            \
                printf("Policy check failed\n");                               \
                dpm_context_destroy(handle);                                   \
                return TEST_FAILED;                                            \
        }                                                                  \
-                                                                       \
        if (dpm_restriction_set_##__name__##_state(handle, state) != 0) {  \
                printf("Policy recovery failed\n");                            \
                dpm_context_destroy(handle);                                   \
                return TEST_FAILED;                                            \
        }                                                                  \
-                                                                       \
        dpm_context_destroy(handle);                                       \
        return TEST_SUCCESSED;                                             \
 }                                                                      \
-                                                                       \
 struct testcase restriction_testcase_##__name__ = {                    \
        .description = STRINGIFY(__name__),                                \
        .handler = restriction_##__name__                                  \
@@ -112,14 +103,14 @@ void TESTCASE_CONSTRUCTOR restriction_policy_build_testcase(void)
        testbench_populate_testcase(&restriction_testcase_location);
        testbench_populate_testcase(&restriction_testcase_microphone);
        testbench_populate_testcase(&restriction_testcase_camera);
-    testbench_populate_testcase(&restriction_testcase_wifi);
-    testbench_populate_testcase(&restriction_testcase_wifi_hotspot);
-    testbench_populate_testcase(&restriction_testcase_bluetooth_tethering);
-    testbench_populate_testcase(&restriction_testcase_usb_tethering);
-    testbench_populate_testcase(&restriction_testcase_bluetooth_mode_change);
-    testbench_populate_testcase(&restriction_testcase_bluetooth_desktop_connectivity);
-    testbench_populate_testcase(&restriction_testcase_bluetooth_pairing);
-    testbench_populate_testcase(&restriction_testcase_messaging);
-    testbench_populate_testcase(&restriction_testcase_popimap_email);
-    testbench_populate_testcase(&restriction_testcase_browser);
+       testbench_populate_testcase(&restriction_testcase_wifi);
+       testbench_populate_testcase(&restriction_testcase_wifi_hotspot);
+       testbench_populate_testcase(&restriction_testcase_bluetooth_tethering);
+       testbench_populate_testcase(&restriction_testcase_usb_tethering);
+       testbench_populate_testcase(&restriction_testcase_bluetooth_mode_change);
+       testbench_populate_testcase(&restriction_testcase_bluetooth_desktop_connectivity);
+       testbench_populate_testcase(&restriction_testcase_bluetooth_pairing);
+       testbench_populate_testcase(&restriction_testcase_messaging);
+       testbench_populate_testcase(&restriction_testcase_popimap_email);
+       testbench_populate_testcase(&restriction_testcase_browser);
 }
index b66bbc5..bf82870 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #include <stdio.h>
 
 
 static int security_lock_screen(struct testcase* tc)
 {
-    device_policy_manager_h handle;
-    int ret;
+       device_policy_manager_h handle;
+       int ret;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
 
-    ret = TEST_SUCCESSED;
-    if (dpm_security_lockout_screen(handle) != 0) {
-        printf("Failed to lockout screen\n");
-        ret = TEST_FAILED;
-    }
+       ret = TEST_SUCCESSED;
+       if (dpm_security_lockout_screen(handle) != 0) {
+               printf("Failed to lockout screen\n");
+               ret = TEST_FAILED;
+       }
 
-    dpm_manager_destroy(handle);
+       dpm_manager_destroy(handle);
 
-    return ret;
+       return ret;
 }
 
 static int security_wipe_data(struct testcase* tc)
@@ -73,10 +74,10 @@ static int security_internal_storage_encryption(struct testcase* tc)
                return TEST_FAILED;
        }
 
-    ret = TEST_SUCCESSED;
-    if (dpm_security_is_internal_storage_encrypted(handle, &state) != DPM_ERROR_NONE) {
-        ret = TEST_FAILED;
-    }
+       ret = TEST_SUCCESSED;
+       if (dpm_security_is_internal_storage_encrypted(handle, &state) != DPM_ERROR_NONE) {
+               ret = TEST_FAILED;
+       }
 
        dpm_manager_destroy(handle);
 
@@ -94,10 +95,10 @@ static int security_external_storage_encryption(struct testcase* tc)
                return TEST_FAILED;
        }
 
-    ret = TEST_SUCCESSED;
-    if (dpm_security_is_external_storage_encrypted(handle, &state) != DPM_ERROR_NONE) {
-        ret = TEST_FAILED;
-    }
+       ret = TEST_SUCCESSED;
+       if (dpm_security_is_external_storage_encrypted(handle, &state) != DPM_ERROR_NONE) {
+               ret = TEST_FAILED;
+       }
 
        dpm_manager_destroy(handle);
 
@@ -126,9 +127,9 @@ struct testcase security_testcase_external_storage_encryption = {
 
 void TESTCASE_CONSTRUCTOR security_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&security_testcase_lock_screen);
-    testbench_populate_testcase(&security_testcase_wipe_data);
-    testbench_populate_testcase(&security_testcase_internal_storage_encryption);
-    testbench_populate_testcase(&security_testcase_external_storage_encryption);
+       testbench_populate_testcase(&security_testcase_lock_screen);
+       testbench_populate_testcase(&security_testcase_wipe_data);
+       testbench_populate_testcase(&security_testcase_internal_storage_encryption);
+       testbench_populate_testcase(&security_testcase_external_storage_encryption);
 
 }
index 1f36e6f..5c7d796 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #include "testbench.h"
 
@@ -19,31 +20,31 @@ static struct testcase *testbench_testcase_head = NULL;
 
 void testbench_populate_testcase(struct testcase* tc)
 {
-    tc->next = testbench_testcase_head;
-    testbench_testcase_head = tc;
+       tc->next = testbench_testcase_head;
+       testbench_testcase_head = tc;
 }
 
 void testbench_execute_testcases(void)
 {
-    int passed, failed;;
-    struct testcase *tc = testbench_testcase_head;
+       int passed, failed;;
+       struct testcase *tc = testbench_testcase_head;
 
-    passed = failed = 0;
+       passed = failed = 0;
 
-    while (tc != NULL) {
-        int ret;
-        ret = tc->handler(tc);
-        if (ret == TEST_SUCCESSED) {
-            passed++;
-        } else {
-            failed++;
-        }
+       while (tc != NULL) {
+               int ret;
+               ret = tc->handler(tc);
+               if (ret == TEST_SUCCESSED) {
+                       passed++;
+               } else {
+                       failed++;
+               }
 
-        printf("TESTCASE(%s) = %s\n", tc->description,
-               ret == TEST_SUCCESSED ? "SUCCESSED" : "FAILED");
+               printf("TESTCASE(%s) = %s\n", tc->description,
+                          ret == TEST_SUCCESSED ? "SUCCESSED" : "FAILED");
 
-        tc = tc->next;
-    }
+               tc = tc->next;
+       }
 
-    printf("Test finished: passed(%d), failed(%d)\n", passed, failed);
+       printf("Test finished: passed(%d), failed(%d)\n", passed, failed);
 }
index 4ee27bd..16c60b8 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #ifndef __DPM_API_TESTBENCH_H__
 #define __DPM_API_TESTBENCH_H__
@@ -24,9 +25,9 @@
 #define TESTCASE_CONSTRUCTOR __attribute__((constructor))
 
 struct testcase {
-    char* description;
-    int (*handler)(struct testcase* tc);
-    struct testcase* next;
+       char* description;
+       int (*handler)(struct testcase* tc);
+       struct testcase* next;
 };
 
 void testbench_populate_testcase(struct testcase* tc);
index fc4a304..66ff896 100644 (file)
@@ -15,5 +15,5 @@
 #
 
 SET(API_TEST_SOURCES    ${API_TEST_SOURCES}
-                        password.c
+                                               password.c
 )
index ace5a9d..9e65e21 100644 (file)
 
 static int wifi_profile_change_restriction(struct testcase* tc)
 {
-    int allow = false;
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_wifi_set_profile_change_restriction(handle, true) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    if (dpm_wifi_is_profile_change_restricted(handle, &allow) != DPM_ERROR_NONE) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       int allow = false;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_wifi_set_profile_change_restriction(handle, true) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_wifi_is_profile_change_restricted(handle, &allow) != DPM_ERROR_NONE) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int wifi_network_access_restriction(struct testcase* tc)
 {
-    int allow = false;
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_wifi_set_network_access_restriction(handle, true) != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    if (dpm_wifi_is_network_access_restricted(handle, &allow) != DPM_ERROR_NONE) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       int allow = false;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_wifi_set_network_access_restriction(handle, true) != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_wifi_is_network_access_restricted(handle, &allow) != DPM_ERROR_NONE) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 static int wifi_blacklist(struct testcase* tc)
 {
-    device_policy_manager_h handle;
-
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client handle\n");
-        return TEST_FAILED;
-    }
-
-    if (dpm_wifi_add_ssid_to_blocklist(handle, "testssid") != 0) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    if (dpm_wifi_remove_ssid_from_blocklist(handle, "testssid") != DPM_ERROR_NONE) {
-        dpm_manager_destroy(handle);
-        return TEST_FAILED;
-    }
-
-    dpm_manager_destroy(handle);
-    return TEST_SUCCESSED;
+       device_policy_manager_h handle;
+
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client handle\n");
+               return TEST_FAILED;
+       }
+
+       if (dpm_wifi_add_ssid_to_blocklist(handle, "testssid") != 0) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       if (dpm_wifi_remove_ssid_from_blocklist(handle, "testssid") != DPM_ERROR_NONE) {
+               dpm_manager_destroy(handle);
+               return TEST_FAILED;
+       }
+
+       dpm_manager_destroy(handle);
+       return TEST_SUCCESSED;
 }
 
 struct testcase wifi_testcase_profile_change_restriction = {
-    .description = "wifi_testcase_profile_change_restriction",
-    .handler = wifi_profile_change_restriction
+       .description = "wifi_testcase_profile_change_restriction",
+       .handler = wifi_profile_change_restriction
 };
 
 struct testcase wifi_testcase_network_access_restriction = {
-    .description = "wifi_testcase_network_access_restriction",
-    .handler = wifi_network_access_restriction
+       .description = "wifi_testcase_network_access_restriction",
+       .handler = wifi_network_access_restriction
 };
 
 struct testcase wifi_testcase_blacklist = {
-    .description = "wifi_testcase_blacklist",
-    .handler = wifi_blacklist
+       .description = "wifi_testcase_blacklist",
+       .handler = wifi_blacklist
 };
 
 void TESTCASE_CONSTRUCTOR wifi_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&wifi_testcase_blacklist);
-    testbench_populate_testcase(&wifi_testcase_network_access_restriction);
-    testbench_populate_testcase(&wifi_testcase_profile_change_restriction);
+       testbench_populate_testcase(&wifi_testcase_blacklist);
+       testbench_populate_testcase(&wifi_testcase_network_access_restriction);
+       testbench_populate_testcase(&wifi_testcase_profile_change_restriction);
 }
index edef35f..9843f3a 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #include <stdio.h>
 #include <string.h>
 
 static int zone_create(struct testcase* tc)
 {
-    int ret = TEST_SUCCESSED;
-    device_policy_manager_h handle;
+       int ret = TEST_SUCCESSED;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client context\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client context\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_zone_create(handle, TEST_ZONE_ID, TEST_SETUP_WIZARD_PKG_ID) != DPM_ERROR_NONE) {
-        ret = TEST_FAILED;
-        goto out;
-    }
+       if (dpm_zone_create(handle, TEST_ZONE_ID, TEST_SETUP_WIZARD_PKG_ID) != DPM_ERROR_NONE) {
+               ret = TEST_FAILED;
+               goto out;
+       }
 
 out:
-    dpm_manager_destroy(handle);
+       dpm_manager_destroy(handle);
 
-    return ret;
+       return ret;
 }
 
 static int zone_get_state(struct testcase* tc)
 {
-    int ret = TEST_SUCCESSED;
-    device_policy_manager_h handle;
-    dpm_zone_state_e state;
+       int ret = TEST_SUCCESSED;
+       device_policy_manager_h handle;
+       dpm_zone_state_e state;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client context\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client context\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_zone_get_state(handle, OWNER_ZONE_ID, &state) != DPM_ERROR_NONE) {
-        ret = TEST_FAILED;
-        goto out;
-    }
+       if (dpm_zone_get_state(handle, OWNER_ZONE_ID, &state) != DPM_ERROR_NONE) {
+               ret = TEST_FAILED;
+               goto out;
+       }
 
-    if (state == 0) {
-        ret = TEST_FAILED;
-    }
+       if (state == 0) {
+               ret = TEST_FAILED;
+       }
 
 out:
-    dpm_manager_destroy(handle);
+       dpm_manager_destroy(handle);
 
-    return ret;
+       return ret;
 }
 
 static bool get_list_cb(const char* name, void* result)
 {
-    *((int*)result) = TEST_SUCCESSED;
-    return true;
+       *((int*)result) = TEST_SUCCESSED;
+       return true;
 }
 
 static int zone_get_list(struct testcase* tc)
 {
-    int ret = TEST_SUCCESSED;
-    device_policy_manager_h handle;
+       int ret = TEST_SUCCESSED;
+       device_policy_manager_h handle;
 
-    handle = dpm_manager_create();
-    if (handle == NULL) {
-        printf("Failed to create client context\n");
-        return TEST_FAILED;
-    }
+       handle = dpm_manager_create();
+       if (handle == NULL) {
+               printf("Failed to create client context\n");
+               return TEST_FAILED;
+       }
 
-    if (dpm_zone_foreach_name(handle, DPM_ZONE_STATE_ALL, get_list_cb, &ret) != DPM_ERROR_NONE) {
-        ret = TEST_FAILED;
-        goto out;
-    }
+       if (dpm_zone_foreach_name(handle, DPM_ZONE_STATE_ALL, get_list_cb, &ret) != DPM_ERROR_NONE) {
+               ret = TEST_FAILED;
+               goto out;
+       }
 
 out:
-    dpm_manager_destroy(handle);
+       dpm_manager_destroy(handle);
 
-    return ret;
+       return ret;
 }
 
 struct testcase dpm_zone_testcase_lifecycle = {
-    .description = "dpm_zone_lifecycle",
-    .handler = zone_create
+       .description = "dpm_zone_lifecycle",
+       .handler = zone_create
 };
 
 struct testcase dpm_zone_testcase_state = {
-    .description = "dpm_zone_state",
-    .handler = zone_get_state
+       .description = "dpm_zone_state",
+       .handler = zone_get_state
 };
 
 struct testcase dpm_zone_testcase_list = {
-    .description = "dpm_zone_list",
-    .handler = zone_get_list
+       .description = "dpm_zone_list",
+       .handler = zone_get_list
 };
 
 void TESTCASE_CONSTRUCTOR zone_policy_build_testcase(void)
 {
-    testbench_populate_testcase(&dpm_zone_testcase_lifecycle);
-    testbench_populate_testcase(&dpm_zone_testcase_state);
-    testbench_populate_testcase(&dpm_zone_testcase_list);
+       testbench_populate_testcase(&dpm_zone_testcase_lifecycle);
+       testbench_populate_testcase(&dpm_zone_testcase_state);
+       testbench_populate_testcase(&dpm_zone_testcase_list);
 }
index d649dce..bbd0df2 100644 (file)
 namespace testbench {
 
 Source::Source(const std::string& file, long line, const std::string& msg) :
-    fileName(file), lineNumber(line), message(msg)
+       fileName(file), lineNumber(line), message(msg)
 {
 }
 
 TestResult::TestResult() :
-    __failureCount(0)
+       __failureCount(0)
 {
 }
 
@@ -41,27 +41,27 @@ void TestResult::testsStarted()
 
 void TestResult::addFailure(const std::string& name, const Source& source)
 {
-    std::cout << "Testcase \"" << name << "\""
-              << " failed: \"" << source.message << "\""
-              << " line " << source.lineNumber
-              << " in " << source.fileName << std::endl;
+       std::cout << "Testcase \"" << name << "\""
+                         << " failed: \"" << source.message << "\""
+                         << " line " << source.lineNumber
+                         << " in " << source.fileName << std::endl;
 
-    __failureCount++;
+       __failureCount++;
 }
 
 void TestResult::testsEnded()
 {
-    if (__failureCount > 0) {
-        std::cout << "\nThere were " << __failureCount << " failures" << std::endl;
-    } else {
-        std::cout << "\nThere were no test failures" << std::endl;
-    }
+       if (__failureCount > 0) {
+               std::cout << "\nThere were " << __failureCount << " failures" << std::endl;
+       } else {
+               std::cout << "\nThere were no test failures" << std::endl;
+       }
 }
 
 TestSuite::TestSuite(const std::string& name)
-    : __testName(name)
+       : __testName(name)
 {
-    Testbench::addTestSuite(this);
+       Testbench::addTestSuite(this);
 }
 
 TestSuite::~TestSuite()
@@ -78,90 +78,90 @@ void TestSuite::teardown()
 
 void TestSuite::run()
 {
-    setup();
+       setup();
 
-    TestCaseRegistry::iterator iter = __registry.begin();
-    while (iter != __registry.end()) {
-        TestSuite::TestCase& testcase = (*iter);
+       TestCaseRegistry::iterator iter = __registry.begin();
+       while (iter != __registry.end()) {
+               TestSuite::TestCase& testcase = (*iter);
 
-        std::cout << "Entering testcase: "
-                  << testcase.testName << std::endl;
-        try {
-            (this->*testcase.function)();
-        } catch (...) {
-            TEST_FAIL("Caught exception from " +
-                      testcase.testName + " testcase");
-        }
-        std::cout << "Leaving testcase: "
-                  << testcase.testName << std::endl;
+               std::cout << "Entering testcase: "
+                                 << testcase.testName << std::endl;
+               try {
+                       (this->*testcase.function)();
+               } catch (...) {
+                       TEST_FAIL("Caught exception from " +
+                                         testcase.testName + " testcase");
+               }
+               std::cout << "Leaving testcase: "
+                                 << testcase.testName << std::endl;
 
-        iter++;
-    }
+               iter++;
+       }
 
-    teardown();
+       teardown();
 }
 
 void TestSuite::registerTestCase(TestFunction func, const std::string& name)
 {
-    __registry.push_back(TestCase(func, name));
+       __registry.push_back(TestCase(func, name));
 }
 
 bool TestSuite::check(long expected, long actual, const std::string& file, long line)
 {
-    if (expected == actual) {
-        return true;
-    }
+       if (expected == actual) {
+               return true;
+       }
 
-    std::stringstream stream;
-    stream << "expected " << expected << " but it was " << actual;
-    Testbench::report(__testName, Source(file, line, stream.str()));
+       std::stringstream stream;
+       stream << "expected " << expected << " but it was " << actual;
+       Testbench::report(__testName, Source(file, line, stream.str()));
 
-    return false;
+       return false;
 }
 
 std::unique_ptr<TestResult> Testbench::collector(new TestResult());
 
 void Testbench::addTestSuite(TestSuite *testSuite)
 {
-    instance().add(testSuite);
+       instance().add(testSuite);
 }
 
 void Testbench::runAllTestSuites()
 {
-    instance().run();
+       instance().run();
 }
 
 Testbench& Testbench::instance()
 {
-    static Testbench testbench;
-    return testbench;
+       static Testbench testbench;
+       return testbench;
 }
 
 void Testbench::add(TestSuite *testSuite)
 {
-    __testSuites.push_back(testSuite);
+       __testSuites.push_back(testSuite);
 }
 
 void Testbench::report(const std::string& name, const Source& source)
 {
-    collector->addFailure(name, source);
+       collector->addFailure(name, source);
 }
 
 void Testbench::run()
 {
-    collector->testsStarted();
+       collector->testsStarted();
 
-    TestSuiteRegistry::iterator iter = __testSuites.begin();
-    while (iter != __testSuites.end()) {
-        try {
-            (*iter)->run();
-        } catch (...) {
-            // Logging exception
-        }
-        iter++;
-    }
+       TestSuiteRegistry::iterator iter = __testSuites.begin();
+       while (iter != __testSuites.end()) {
+               try {
+                       (*iter)->run();
+               } catch (...) {
+                       // Logging exception
+               }
+               iter++;
+       }
 
-    collector->testsEnded();
+       collector->testsEnded();
 }
 
 } //namespace testbench
index 0a8f53c..1fd6841 100644 (file)
 namespace testbench {
 
 struct Source {
-    Source(const std::string& file, long line, const std::string& msg);
+       Source(const std::string& file, long line, const std::string& msg);
 
-    std::string fileName;
-    long lineNumber;
-    std::string        message;
+       std::string fileName;
+       long lineNumber;
+       std::string     message;
 };
 
 class TestResult {
 public:
-    TestResult();
-    virtual ~TestResult();
-    virtual void testsStarted();
-    virtual void addFailure(const std::string& name, const Source& source);
-    virtual void testsEnded();
+       TestResult();
+       virtual ~TestResult();
+       virtual void testsStarted();
+       virtual void addFailure(const std::string& name, const Source& source);
+       virtual void testsEnded();
 
 private:
-    int        __failureCount;
+       int     __failureCount;
 };
 
 class TestSuite {
 public:
-    TestSuite(const std::string& name);
-    virtual ~TestSuite();
+       TestSuite(const std::string& name);
+       virtual ~TestSuite();
 
-    TestSuite(const TestSuite&) = delete;
-    TestSuite& operator=(const TestSuite&) = delete;
+       TestSuite(const TestSuite&) = delete;
+       TestSuite& operator=(const TestSuite&) = delete;
 
-    void run();
+       void run();
 
-    const std::string& name() const {
-        return __testName;
-    }
+       const std::string& name() const {
+               return __testName;
+       }
 
 protected:
-    typedef void (TestSuite::*TestFunction)();
+       typedef void (TestSuite::*TestFunction)();
 
-    struct TestCase {
-        TestCase(TestFunction func, const std::string& name) :
-            function(func), testName(name)
-        {
-        }
+       struct TestCase {
+               TestCase(TestFunction func, const std::string& name) :
+                       function(func), testName(name)
+               {
+               }
 
-        TestFunction function;
-        std::string testName;
-    };
+               TestFunction function;
+               std::string testName;
+       };
 
-    virtual void setup();
-    virtual void teardown();
+       virtual void setup();
+       virtual void teardown();
 
 #define addTest(func)  \
        registerTestCase(static_cast<TestFunction>(&func), #func)
@@ -82,35 +82,35 @@ protected:
 #define addTestWithName(func, name)    \
        registerTestCase(static_cast<TestFunction>(&func), name)
 
-    void registerTestCase(TestFunction func, const std::string& name);
-    bool check(long expected, long actual, const std::string& file, long line);
+       void registerTestCase(TestFunction func, const std::string& name);
+       bool check(long expected, long actual, const std::string& file, long line);
 
 protected:
-    std::string __testName;
+       std::string __testName;
 
 private:
-    typedef std::vector<TestCase> TestCaseRegistry;
+       typedef std::vector<TestCase> TestCaseRegistry;
 
-    TestCaseRegistry __registry;
+       TestCaseRegistry __registry;
 };
 
 class Testbench {
 public:
-    static void addTestSuite(TestSuite *testSuite);
-    static void runAllTestSuites();
-    static void report(const std::string& name, const Source& source);
+       static void addTestSuite(TestSuite *testSuite);
+       static void runAllTestSuites();
+       static void report(const std::string& name, const Source& source);
 
 private:
-    static Testbench& instance();
+       static Testbench& instance();
 
-    void add(TestSuite *testSuite);
-    void run();
+       void add(TestSuite *testSuite);
+       void run();
 
 private:
-    static std::unique_ptr<TestResult> collector;
+       static std::unique_ptr<TestResult> collector;
 
-    typedef std::vector<TestSuite *> TestSuiteRegistry;
-    TestSuiteRegistry __testSuites;
+       typedef std::vector<TestSuite *> TestSuiteRegistry;
+       TestSuiteRegistry __testSuites;
 };
 
 #ifndef __FILENAME__
@@ -121,43 +121,43 @@ private:
 #define TESTCASE(TestName)                              \
 class TestName##TestCase : public testbench::TestSuite {\
 public:                                                 \
-    TestName##TestCase()                                \
-        : TestSuite(#TestName)                          \
-    {                                                   \
-        addTestWithName(TestName##TestCase::standalone, #TestName); \
-    }                                                   \
-    void standalone();                                  \
+       TestName##TestCase()                                \
+               : TestSuite(#TestName)                          \
+       {                                                   \
+               addTestWithName(TestName##TestCase::standalone, #TestName); \
+       }                                                   \
+       void standalone();                                  \
 } TestName##TestCase##Instance;                         \
 void TestName##TestCase::standalone()
 
 #define TEST_CHECK(condition)                           \
 {                                                       \
-    if (!(condition)) {                                 \
-        testbench::Testbench::report(__testName,        \
-        testbench::Source(__FILENAME__, __LINE__, #condition));  \
-        return;                                         \
-    }                                                   \
+       if (!(condition)) {                                 \
+               testbench::Testbench::report(__testName,        \
+               testbench::Source(__FILENAME__, __LINE__, #condition));  \
+               return;                                         \
+       }                                                   \
 }
 
 #define TEST_EXPECT(expected, actual)                   \
 {                                                       \
-    __typeof__(expected) _exp = (expected);             \
-    __typeof__(actual) _act = (actual);                 \
-    if (_exp != _act) {                                 \
-        std::stringstream _stream;                      \
-        _stream << "expected " << _exp                  \
-                << " but it was " << _act;              \
-        testbench::Testbench::report(__testName,        \
-        testbench::Source(__FILENAME__, __LINE__, _stream.str())); \
-        return;                                         \
-    }                                                   \
+       __typeof__(expected) _exp = (expected);             \
+       __typeof__(actual) _act = (actual);                 \
+       if (_exp != _act) {                                 \
+               std::stringstream _stream;                      \
+               _stream << "expected " << _exp                  \
+                               << " but it was " << _act;              \
+               testbench::Testbench::report(__testName,        \
+               testbench::Source(__FILENAME__, __LINE__, _stream.str())); \
+               return;                                         \
+       }                                                   \
 }
 
 #define TEST_FAIL(text)                                 \
 {                                                       \
-    testbench::Testbench::report(__testName,            \
-    testbench::Source(__FILENAME__, __LINE__, (text))); \
-    return;                                             \
+       testbench::Testbench::report(__testName,            \
+       testbench::Source(__FILENAME__, __LINE__, (text))); \
+       return;                                             \
 }
 } // namespace testbench
 #endif //!__DPM_TESTBENCH_H__
index d1c0c09..bdae908 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <sys/types.h>
 #include <sys/wait.h>
 
 TESTCASE(DatabaseTest)
 {
-    std::string query = "CREATE TABLE IF NOT EXISTS CLIENT("     \
-                        "ID INTEGER PRIMARY KEY AUTOINCREMENT,"  \
-                        "PKG TEXT,"                              \
-                        "KEY TEXT,"                              \
-                        "IS_USED INTEGER,"                       \
-                        "USER INTEGER)";
-
-    try {
-        database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
-        db.exec(query);
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       std::string query = "CREATE TABLE IF NOT EXISTS CLIENT("     \
+                                               "ID INTEGER PRIMARY KEY AUTOINCREMENT,"  \
+                                               "PKG TEXT,"                              \
+                                               "KEY TEXT,"                              \
+                                               "IS_USED INTEGER,"                       \
+                                               "USER INTEGER)";
+
+       try {
+               database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+               db.exec(query);
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(InvalidStatementTest)
 {
-    try {
-        database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
-        database::Statement stmt(db, "INVALID STATEMENT");
-    } catch (runtime::Exception& e) {
-    }
+       try {
+               database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+               database::Statement stmt(db, "INVALID STATEMENT");
+       } catch (runtime::Exception& e) {
+       }
 }
 
 TESTCASE(ColumnBindTestWithIndex1)
 {
-    std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?, ?)";
-
-    try {
-        const char *str = "PACKAGE";
-        void *blob = (void *)str;
-        double user=5001;
-        sqlite3_int64 used = 1;
-        std::string key = "test key";
-
-        database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
-        database::Statement stmt(db, query);
-        stmt.bind(1, blob, 8);
-        stmt.bind(2, key);
-        stmt.bind(3, used);
-        stmt.bind(4, user);
-        stmt.exec();
-        database::Statement select(db, "SELECT * FROM CLIENT");
-
-        TEST_EXPECT(5, select.getColumnCount());
-        stmt.clearBindings();
-        stmt.reset();
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?, ?)";
+
+       try {
+               const char *str = "PACKAGE";
+               void *blob = (void *)str;
+               double user = 5001;
+               sqlite3_int64 used = 1;
+               std::string key = "test key";
+
+               database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+               database::Statement stmt(db, query);
+               stmt.bind(1, blob, 8);
+               stmt.bind(2, key);
+               stmt.bind(3, used);
+               stmt.bind(4, user);
+               stmt.exec();
+               database::Statement select(db, "SELECT * FROM CLIENT");
+
+               TEST_EXPECT(5, select.getColumnCount());
+               stmt.clearBindings();
+               stmt.reset();
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(ColumnBindTestWithIndex2)
 {
-    std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?, ?)";
-
-    try {
-        database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
-        database::Statement stmt(db, query);
-        stmt.bind(1, "TEST PACKAGE");
-        stmt.bind(2, "TEST KEY");
-        stmt.bind(3, false);
-        stmt.bind(4, 5001);
-        stmt.exec();
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       std::string query = "INSERT INTO CLIENT VALUES (NULL, ?, ?, ?, ?)";
+
+       try {
+               database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+               database::Statement stmt(db, query);
+               stmt.bind(1, "TEST PACKAGE");
+               stmt.bind(2, "TEST KEY");
+               stmt.bind(3, false);
+               stmt.bind(4, 5001);
+               stmt.exec();
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(ColumnBindTestWithName1)
 {
-    std::string query = "INSERT INTO CLIENT VALUES (NULL, :PKG, :KEY, :IS_USED, :USER)";
-
-    try {
-        database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
-        database::Statement stmt(db, query);
-        stmt.bind(":PKG", "TEST PACKAGE");
-        stmt.bind(":KEY", "TEST KEY");
-        stmt.bind(":IS_USED", true);
-        stmt.bind(":USER", 5001);
-        stmt.exec();
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       std::string query = "INSERT INTO CLIENT VALUES (NULL, :PKG, :KEY, :IS_USED, :USER)";
+
+       try {
+               database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+               database::Statement stmt(db, query);
+               stmt.bind(":PKG", "TEST PACKAGE");
+               stmt.bind(":KEY", "TEST KEY");
+               stmt.bind(":IS_USED", true);
+               stmt.bind(":USER", 5001);
+               stmt.exec();
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(ColumnBindTestWithName2)
 {
-    std::string query = "INSERT INTO CLIENT VALUES (NULL, :PKG, :KEY, :IS_USED, :USER)";
-
-    try {
-        const char *str = "PACKAGE";
-        void *blob = (void *)str;
-        double user = 5001;
-        sqlite3_int64 used = 1;
-        std::string key = "test key";
-
-        database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
-        database::Statement stmt(db, query);
-        stmt.bind(":PKG", blob, 8);
-        stmt.bind(":KEY", key);
-        stmt.bind(":IS_USED", used);
-        stmt.bind(":USER", user);
-        stmt.exec();
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       std::string query = "INSERT INTO CLIENT VALUES (NULL, :PKG, :KEY, :IS_USED, :USER)";
+
+       try {
+               const char *str = "PACKAGE";
+               void *blob = (void *)str;
+               double user = 5001;
+               sqlite3_int64 used = 1;
+               std::string key = "test key";
+
+               database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+               database::Statement stmt(db, query);
+               stmt.bind(":PKG", blob, 8);
+               stmt.bind(":KEY", key);
+               stmt.bind(":IS_USED", used);
+               stmt.bind(":USER", user);
+               stmt.exec();
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(ColumnTest)
 {
-    try {
-        database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
-        database::Statement select(db, "SELECT * FROM CLIENT");
-        while (select.step()) {
-            for (int  i = 0; i < select.getColumnCount(); i++) {
-                TEST_EXPECT(false, select.isNullColumn(i));
-                std::cout << "C: " << select.getColumnName(i);
-            }
-            std::cout << std::endl;
-
-            database::Column id = select.getColumn(0);
-            database::Column pkg = select.getColumn(1);
-            database::Column key = select.getColumn(2);
-            database::Column used = select.getColumn(3);
-
-            std::cout << "Column: " << id.getName()
-                      << ", Int: " << id.getInt()
-                      << ", Int64: " << id.getInt64()
-                      << ", Double: " << id.getDouble()
-                      << ", Type: " << id.getType()
-                      << ", Bytes: " << id.getBytes()
-                      << ", Double: " << id.getDouble()
-                      << std::endl;
-            std::cout << "Column: " << pkg.getName()
-                      << ", Text: " << pkg.getText()
-                      << ", Type: " << pkg.getType()
-                      << ", Bytes: " << pkg.getBytes()
-                      << ", Blob: " << (const char*)pkg.getBlob()
-                      << std::endl;
-            std::cout << "Column: " << key.getName()
-                      << ", Text: " << key.getText()
-                      << ", Type: " << key.getType()
-                      << ", Bytes: " << key.getBytes()
-                      << ", Blob: " << (const char*)key.getBlob()
-                      << std::endl;
-            std::cout << "Column: " << used.getName()
-                      << ", Int: " << used.getInt()
-                      << ", Int64: " << used.getInt64()
-                      << ", Double: " << used.getDouble()
-                      << ", Type: " << used.getType()
-                      << ", Bytes: " << used.getBytes()
-                      << std::endl;
-        }
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       try {
+               database::Connection db("/tmp/test.db", database::Connection::ReadWrite | database::Connection::Create);
+               database::Statement select(db, "SELECT * FROM CLIENT");
+               while (select.step()) {
+                       for (int  i = 0; i < select.getColumnCount(); i++) {
+                               TEST_EXPECT(false, select.isNullColumn(i));
+                               std::cout << "C: " << select.getColumnName(i);
+                       }
+                       std::cout << std::endl;
+
+                       database::Column id = select.getColumn(0);
+                       database::Column pkg = select.getColumn(1);
+                       database::Column key = select.getColumn(2);
+                       database::Column used = select.getColumn(3);
+
+                       std::cout << "Column: " << id.getName()
+                                         << ", Int: " << id.getInt()
+                                         << ", Int64: " << id.getInt64()
+                                         << ", Double: " << id.getDouble()
+                                         << ", Type: " << id.getType()
+                                         << ", Bytes: " << id.getBytes()
+                                         << ", Double: " << id.getDouble()
+                                         << std::endl;
+                       std::cout << "Column: " << pkg.getName()
+                                         << ", Text: " << pkg.getText()
+                                         << ", Type: " << pkg.getType()
+                                         << ", Bytes: " << pkg.getBytes()
+                                         << ", Blob: " << (const char*)pkg.getBlob()
+                                         << std::endl;
+                       std::cout << "Column: " << key.getName()
+                                         << ", Text: " << key.getText()
+                                         << ", Type: " << key.getType()
+                                         << ", Bytes: " << key.getBytes()
+                                         << ", Blob: " << (const char*)key.getBlob()
+                                         << std::endl;
+                       std::cout << "Column: " << used.getName()
+                                         << ", Int: " << used.getInt()
+                                         << ", Int64: " << used.getInt64()
+                                         << ", Double: " << used.getDouble()
+                                         << ", Type: " << used.getType()
+                                         << ", Bytes: " << used.getBytes()
+                                         << std::endl;
+               }
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(InvalidDB)
 {
-    try {
-        database::Connection db("/tmp/invalid.db", database::Connection::ReadWrite);
-    } catch (runtime::Exception& e) {
-
-    }
+       try {
+               database::Connection db("/tmp/invalid.db", database::Connection::ReadWrite);
+       } catch (runtime::Exception& e) {
+       }
 }
index 0e540fb..ea76709 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <sys/types.h>
 #include <sys/wait.h>
 
 TESTCASE(DirectoryIteration)
 {
-    runtime::DirectoryIterator iter("/dev");
-    runtime::DirectoryIterator end;
+       runtime::DirectoryIterator iter("/dev");
+       runtime::DirectoryIterator end;
 
-    TEST_EXPECT(false, iter == end);
+       TEST_EXPECT(false, iter == end);
 
-    while (iter != end) {
-        ++iter;
-    }
+       while (iter != end) {
+               ++iter;
+       }
 }
 
 TESTCASE(FileIO)
 {
-    char readbuf[100];
-    char testbuf[100] = "Test Data";
+       char readbuf[100];
+       char testbuf[100] = "Test Data";
 
-    runtime::File tmp("/tmp/test-file");
-    try {
-        tmp.create(755);
-        tmp.lock();
-        tmp.write(testbuf, ::strlen(testbuf));
-        tmp.unlock();
-        tmp.close();
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       runtime::File tmp("/tmp/test-file");
+       try {
+               tmp.create(755);
+               tmp.lock();
+               tmp.write(testbuf, ::strlen(testbuf));
+               tmp.unlock();
+               tmp.close();
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 
-    try {
-        runtime::File tmpFile("/tmp/test-file", O_RDWR);
-        tmpFile.read(readbuf, ::strlen(testbuf));
-        tmpFile.close();
-        tmpFile.remove();
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       try {
+               runtime::File tmpFile("/tmp/test-file", O_RDWR);
+               tmpFile.read(readbuf, ::strlen(testbuf));
+               tmpFile.close();
+               tmpFile.remove();
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(DirOperation)
 {
-    runtime::File testDir("/tmp/dpm-unit-test/dir");
-    try {
-        testDir.makeDirectory(true, ::getuid(), ::getgid());
-        testDir.chown(::getuid(), ::getgid(), false);
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       runtime::File testDir("/tmp/dpm-unit-test/dir");
+       try {
+               testDir.makeDirectory(true, ::getuid(), ::getgid());
+               testDir.chown(::getuid(), ::getgid(), false);
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 
-    runtime::File dir("/tmp/dpm-unit-test");
-    try {
-        dir.chmod(777, true);
-        dir.remove(true);
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       runtime::File dir("/tmp/dpm-unit-test");
+       try {
+               dir.chmod(777, true);
+               dir.remove(true);
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(FileAttribute)
 {
-    runtime::File tmp("/tmp");
+       runtime::File tmp("/tmp");
 
-    TEST_EXPECT(true, tmp.exists());
-    TEST_EXPECT(true, tmp.canRead());
-    TEST_EXPECT(true, tmp.canWrite());
-    TEST_EXPECT(true, tmp.canExecute());
-    TEST_EXPECT(false, tmp.isLink());
-    TEST_EXPECT(false, tmp.isFile());
-    TEST_EXPECT(true, tmp.isDirectory());
-    TEST_EXPECT(false, tmp.isDevice());
+       TEST_EXPECT(true, tmp.exists());
+       TEST_EXPECT(true, tmp.canRead());
+       TEST_EXPECT(true, tmp.canWrite());
+       TEST_EXPECT(true, tmp.canExecute());
+       TEST_EXPECT(false, tmp.isLink());
+       TEST_EXPECT(false, tmp.isFile());
+       TEST_EXPECT(true, tmp.isDirectory());
+       TEST_EXPECT(false, tmp.isDevice());
 
-    std::cout << " UID: " << tmp.getUid()
-              << " GID: " << tmp.getGid()
-              << " Size: " << tmp.size()
-              << " Mode: " << tmp.getMode()
-              << " Path: " << tmp.getPath()
-              << " File: " << tmp.getName() << std::endl;
+       std::cout << " UID: " << tmp.getUid()
+                         << " GID: " << tmp.getGid()
+                         << " Size: " << tmp.size()
+                         << " Mode: " << tmp.getMode()
+                         << " Path: " << tmp.getPath()
+                         << " File: " << tmp.getName() << std::endl;
 }
index 27485bb..126fe94 100644 (file)
@@ -1,30 +1,31 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include "testbench/testbench.h"
 #include "audit/logger.h"
 
 int main(int /*argc*/, char** /*argv*/)
 {
-    audit::Logger::setLogLevel(audit::LogLevel::Trace);
+       audit::Logger::setLogLevel(audit::LogLevel::Trace);
        TRACE("Trace");
        INFO("Info");
        DEBUG("Debug");
        WARN("Warning");
        ERROR("Error");
-    testbench::Testbench::runAllTestSuites();
+       testbench::Testbench::runAllTestSuites();
 
-    return 0;
+       return 0;
 }
index 382b6dc..a67e22b 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <string>
 #include <vector>
 
 TESTCASE(ProcTerminate)
 {
-    try {
-        runtime::Process proc("/bin/bash");
-        proc.execute();
-        if (proc.isRunning()) {
-            proc.terminate();
-        }
-    } catch (runtime::Exception& e) {
-    }
+       try {
+               runtime::Process proc("/bin/bash");
+               proc.execute();
+               if (proc.isRunning()) {
+                       proc.terminate();
+               }
+       } catch (runtime::Exception& e) {
+       }
 }
 
 TESTCASE(ProcWithArg)
 {
-    try {
-        std::vector<std::string> args = {
-            "-l",
-            "-a"
-        };
-        runtime::Process proc("/bin/ls", args);
-        proc.execute();
-    } catch (runtime::Exception& e) {
-    }
+       try {
+               std::vector<std::string> args = {
+                       "-l",
+                       "-a"
+               };
+               runtime::Process proc("/bin/ls", args);
+               proc.execute();
+       } catch (runtime::Exception& e) {
+       }
 }
index cc5e5e2..ffcff81 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -36,308 +37,308 @@ const std::string IPC_TEST_ADDRESS = "/tmp/.dpm-test";
 
 class TestServer {
 public:
-    TestServer()
-    {
-        service.reset(new rmi::Service(IPC_TEST_ADDRESS));
-
-        service->registerMethod(this, "", (String)(TestServer::method1)(String));
-        service->registerMethod(this, "", (String)(TestServer::method2)(String, String));
-        service->registerMethod(this, "", (String)(TestServer::method3)(String, String, String));
-        service->registerMethod(this, "", (String)(TestServer::method4)(String, String, String, String));
-
-        service->registerMethod(this, "", (FileDescriptor)(TestServer::signalProvider)(std::string));
-        service->registerMethod(this, "", (FileDescriptor)(TestServer::policyNotificationProvider)(std::string));
-
-        service->registerNonparametricMethod(this, "", (int)(TestServer::sendSignal)());
-        service->registerNonparametricMethod(this, "", (int)(TestServer::sendPolicyChangeNotification)());
-
-        service->createNotification("TestPolicyChanged");
-        service->createNotification("TestSignal");
-    }
-
-    void run()
-    {
-        service->start();
-    }
-
-    String method1(String& arg1)
-    {
-        return String("Method1 result");
-    }
-
-    String method2(String& arg1, String& arg2)
-    {
-        return String("Method2 result");
-    }
-
-    String method3(String& arg1, String& arg2, String& arg3)
-    {
-        return String("Method3 result");
-    }
-
-    String method4(String& arg1, String& arg2, String& arg3, String& arg4)
-    {
-        return String("Method4 result");
-    }
-
-    int sendPolicyChangeNotification()
-    {
-        service->notify("TestPolicyChanged", 1234);
-        return 0;
-    }
-
-    int sendSignal()
-    {
-        service->notify("TestSignal");
-        return 0;
-    }
-
-    FileDescriptor signalProvider(const std::string& name)
-    {
-        return service->subscribeNotification(name);
-    }
-
-    FileDescriptor policyNotificationProvider(const std::string& name)
-    {
-        return service->subscribeNotification(name);
-    }
+       TestServer()
+       {
+               service.reset(new rmi::Service(IPC_TEST_ADDRESS));
+
+               service->registerMethod(this, "", (String)(TestServer::method1)(String));
+               service->registerMethod(this, "", (String)(TestServer::method2)(String, String));
+               service->registerMethod(this, "", (String)(TestServer::method3)(String, String, String));
+               service->registerMethod(this, "", (String)(TestServer::method4)(String, String, String, String));
+
+               service->registerMethod(this, "", (FileDescriptor)(TestServer::signalProvider)(std::string));
+               service->registerMethod(this, "", (FileDescriptor)(TestServer::policyNotificationProvider)(std::string));
+
+               service->registerNonparametricMethod(this, "", (int)(TestServer::sendSignal)());
+               service->registerNonparametricMethod(this, "", (int)(TestServer::sendPolicyChangeNotification)());
+
+               service->createNotification("TestPolicyChanged");
+               service->createNotification("TestSignal");
+       }
+
+       void run()
+       {
+               service->start();
+       }
+
+       String method1(String& arg1)
+       {
+               return String("Method1 result");
+       }
+
+       String method2(String& arg1, String& arg2)
+       {
+               return String("Method2 result");
+       }
+
+       String method3(String& arg1, String& arg2, String& arg3)
+       {
+               return String("Method3 result");
+       }
+
+       String method4(String& arg1, String& arg2, String& arg3, String& arg4)
+       {
+               return String("Method4 result");
+       }
+
+       int sendPolicyChangeNotification()
+       {
+               service->notify("TestPolicyChanged", 1234);
+               return 0;
+       }
+
+       int sendSignal()
+       {
+               service->notify("TestSignal");
+               return 0;
+       }
+
+       FileDescriptor signalProvider(const std::string& name)
+       {
+               return service->subscribeNotification(name);
+       }
+
+       FileDescriptor policyNotificationProvider(const std::string& name)
+       {
+               return service->subscribeNotification(name);
+       }
 
 private:
-    std::unique_ptr<rmi::Service> service;
+       std::unique_ptr<rmi::Service> service;
 };
 
 class TestClient {
 public:
-    TestClient() :
-        signalTriggered(false),
-        policyChangeNotificationTriggered(false)
-    {
-    }
-
-    void connect()
-    {
-        auto policyChangedListener = [this](const std::string& name, int value) {
-            policyChangeNotificationTriggered = true;
-        };
-
-        auto policySignalListener = [this](const std::string& name) {
-            signalTriggered = true;
-        };
-
-        client.reset(new rmi::Client(IPC_TEST_ADDRESS));
-        client->connect();
-
-        client->subscribe<std::string, int>("TestServer::policyNotificationProvider",
-                                            "TestPolicyChanged", policyChangedListener);
-        client->subscribe<std::string>("TestServer::signalProvider",
-                                       "TestSignal", policySignalListener);
-    }
-
-    void disconnect()
-    {
-        client.reset();
-    }
-
-    String method1(String& arg1)
-    {
-        return client->methodCall<String>("TestServer::method1", arg1);
-    }
-
-    String method2(String& arg1, String& arg2)
-    {
-        return client->methodCall<String>("TestServer::method2", arg1, arg2);
-    }
-
-    String method3(String& arg1, String& arg2, String& arg3)
-    {
-        return client->methodCall<String>("TestServer::method3", arg1, arg2, arg3);
-    }
-
-    String method4(String& arg1, String& arg2, String& arg3, String& arg4)
-    {
-        return client->methodCall<String>("TestServer::method4", arg1, arg2, arg3, arg4);
-    }
-
-    void requestSignal()
-    {
-        signalTriggered = false;
-        client->methodCall<int>("TestServer::sendSignal");
-        while (!signalTriggered) {
-            ::sleep(1);
-        }
-    }
-
-    void requestPolicyChangeNotification()
-    {
-        policyChangeNotificationTriggered = false;
-        client->methodCall<int>("TestServer::sendPolicyChangeNotification");
-        while (!policyChangeNotificationTriggered) {
-            sleep(1);
-        }
-    }
-
-    String invalidMethod(String& arg)
-    {
-        return client->methodCall<String>("TestServer::invalidMethod", arg);
-    }
+       TestClient() :
+               signalTriggered(false),
+               policyChangeNotificationTriggered(false)
+       {
+       }
+
+       void connect()
+       {
+               auto policyChangedListener = [this](const std::string& name, int value) {
+                       policyChangeNotificationTriggered = true;
+               };
+
+               auto policySignalListener = [this](const std::string& name) {
+                       signalTriggered = true;
+               };
+
+               client.reset(new rmi::Client(IPC_TEST_ADDRESS));
+               client->connect();
+
+               client->subscribe<std::string, int>("TestServer::policyNotificationProvider",
+                                                                                       "TestPolicyChanged", policyChangedListener);
+               client->subscribe<std::string>("TestServer::signalProvider",
+                                                                          "TestSignal", policySignalListener);
+       }
+
+       void disconnect()
+       {
+               client.reset();
+       }
+
+       String method1(String& arg1)
+       {
+               return client->methodCall<String>("TestServer::method1", arg1);
+       }
+
+       String method2(String& arg1, String& arg2)
+       {
+               return client->methodCall<String>("TestServer::method2", arg1, arg2);
+       }
+
+       String method3(String& arg1, String& arg2, String& arg3)
+       {
+               return client->methodCall<String>("TestServer::method3", arg1, arg2, arg3);
+       }
+
+       String method4(String& arg1, String& arg2, String& arg3, String& arg4)
+       {
+               return client->methodCall<String>("TestServer::method4", arg1, arg2, arg3, arg4);
+       }
+
+       void requestSignal()
+       {
+               signalTriggered = false;
+               client->methodCall<int>("TestServer::sendSignal");
+               while (!signalTriggered) {
+                       ::sleep(1);
+               }
+       }
+
+       void requestPolicyChangeNotification()
+       {
+               policyChangeNotificationTriggered = false;
+               client->methodCall<int>("TestServer::sendPolicyChangeNotification");
+               while (!policyChangeNotificationTriggered) {
+                       sleep(1);
+               }
+       }
+
+       String invalidMethod(String& arg)
+       {
+               return client->methodCall<String>("TestServer::invalidMethod", arg);
+       }
 
 private:
-    volatile bool signalTriggered;
-    volatile bool policyChangeNotificationTriggered;
-    std::unique_ptr<rmi::Client> client;
+       volatile bool signalTriggered;
+       volatile bool policyChangeNotificationTriggered;
+       std::unique_ptr<rmi::Client> client;
 };
 
 int WaitForFile(const std::string& path, const unsigned int timeout)
 {
-    struct stat st;
-    unsigned int loop = 0;
+       struct stat st;
+       unsigned int loop = 0;
 
-    while (stat(path.c_str(), &st) == -1) {
-        if (errno != ENOENT) {
-            ERROR("Error on waitting for: " + path);
-            return -1;
-        }
+       while (stat(path.c_str(), &st) == -1) {
+               if (errno != ENOENT) {
+                       ERROR("Error on waitting for: " + path);
+                       return -1;
+               }
 
-        if (((++loop) * 100) > timeout) {
-            ERROR("Error on waitting for: " + path);
-            return -1;
-        }
+               if (((++loop) * 100) > timeout) {
+                       ERROR("Error on waitting for: " + path);
+                       return -1;
+               }
 
-        usleep(100 * 1000);
-    }
+               usleep(100 * 1000);
+       }
 
-    return 0;
+       return 0;
 }
 
 int WaitForPid(pid_t pid)
 {
-    int status, ret;
-    char errmsg[256];
-
-    do {
-        ret = waitpid(pid, &status, 0);
-        if (ret == -1) {
-            if (errno != EINTR) {
-                ERROR("Wait Pid failed: " + std::to_string(pid) + "(" + strerror_r(errno, errmsg, sizeof(errmsg)) + ")");
-                return -1;
-            }
-        }
-    } while (ret == EINTR || ret != pid);
-
-    return status;
+       int status, ret;
+       char errmsg[256];
+
+       do {
+               ret = waitpid(pid, &status, 0);
+               if (ret == -1) {
+                       if (errno != EINTR) {
+                               ERROR("Wait Pid failed: " + std::to_string(pid) + "(" + strerror_r(errno, errmsg, sizeof(errmsg)) + ")");
+                               return -1;
+                       }
+               }
+       } while (ret == EINTR || ret != pid);
+
+       return status;
 }
 
 pid_t PrepareTestServer(void)
 {
-    ::unlink(IPC_TEST_ADDRESS.c_str());
+       ::unlink(IPC_TEST_ADDRESS.c_str());
 
-    pid_t pid = fork();
+       pid_t pid = fork();
 
-    if (pid < 0) {
-        return -1;
-    }
+       if (pid < 0) {
+               return -1;
+       }
 
-    if (pid == 0) {
-        try {
-            TestServer server;
-            server.run();
-        } catch (std::exception& e) {
-            ERROR(e.what());
-            return -1;
-        }
+       if (pid == 0) {
+               try {
+                       TestServer server;
+                       server.run();
+               } catch (std::exception& e) {
+                       ERROR(e.what());
+                       return -1;
+               }
 
-        return 0;
-    }
+               return 0;
+       }
 
-    return pid;
+       return pid;
 }
 
 class IpcTestSuite : public testbench::TestSuite {
 public:
-    IpcTestSuite(const std::string& name) :
-        testbench::TestSuite(name)
-    {
-        addTest(IpcTestSuite::connectionTest);
-        addTest(IpcTestSuite::remoteMethodCallTest);
-        addTest(IpcTestSuite::notificationTest);
-    }
-
-    void setup()
-    {
-        pid = PrepareTestServer();
-        if (pid == -1) {
-            ERROR("Preparing test server failed");
-            return;
-        }
-
-        WaitForFile(IPC_TEST_ADDRESS, 1000);
-    }
-
-    void teardown()
-    {
-        if (::kill(pid, SIGTERM) == -1) {
-            return;
-        }
-
-        int status = WaitForPid(pid);
-        if (status == -1 || !WIFEXITED(status)) {
-            return;
-        }
-    }
-
-    void connectionTest()
-    {
-        try {
-            TestClient client;
-            client.connect();
-            client.disconnect();
-        } catch (runtime::Exception& e) {
-            ERROR(e.what());
-        }
-    }
-
-    void notificationTest()
-    {
-        try {
-            TestClient client;
-            client.connect();
-
-            client.requestSignal();
-            client.requestPolicyChangeNotification();
-
-            client.disconnect();
-        } catch (runtime::Exception& e) {
-            ERROR(e.what());
-        }
-    }
-
-    void remoteMethodCallTest()
-    {
-        try {
-            TestClient client;
-            client.connect();
-
-            String param1("First Parameter");
-            String param2("Second Parameter");
-            String param3("Third Parameter");
-            String param4("Fourth Parameter");
-
-            String result1 = client.method1(param1);
-            String result2 = client.method2(param1, param2);
-            String result3 = client.method3(param1, param2, param3);
-            String result4 = client.method4(param1, param2, param3, param4);
-
-            client.requestSignal();
-            client.requestPolicyChangeNotification();
-
-            client.disconnect();
-        } catch (runtime::Exception& e) {
-            ERROR(e.what());
-        }
-    }
+       IpcTestSuite(const std::string& name) :
+               testbench::TestSuite(name)
+       {
+               addTest(IpcTestSuite::connectionTest);
+               addTest(IpcTestSuite::remoteMethodCallTest);
+               addTest(IpcTestSuite::notificationTest);
+       }
+
+       void setup()
+       {
+               pid = PrepareTestServer();
+               if (pid == -1) {
+                       ERROR("Preparing test server failed");
+                       return;
+               }
+
+               WaitForFile(IPC_TEST_ADDRESS, 1000);
+       }
+
+       void teardown()
+       {
+               if (::kill(pid, SIGTERM) == -1) {
+                       return;
+               }
+
+               int status = WaitForPid(pid);
+               if (status == -1 || !WIFEXITED(status)) {
+                       return;
+               }
+       }
+
+       void connectionTest()
+       {
+               try {
+                       TestClient client;
+                       client.connect();
+                       client.disconnect();
+               } catch (runtime::Exception& e) {
+                       ERROR(e.what());
+               }
+       }
+
+       void notificationTest()
+       {
+               try {
+                       TestClient client;
+                       client.connect();
+
+                       client.requestSignal();
+                       client.requestPolicyChangeNotification();
+
+                       client.disconnect();
+               } catch (runtime::Exception& e) {
+                       ERROR(e.what());
+               }
+       }
+
+       void remoteMethodCallTest()
+       {
+               try {
+                       TestClient client;
+                       client.connect();
+
+                       String param1("First Parameter");
+                       String param2("Second Parameter");
+                       String param3("Third Parameter");
+                       String param4("Fourth Parameter");
+
+                       String result1 = client.method1(param1);
+                       String result2 = client.method2(param1, param2);
+                       String result3 = client.method3(param1, param2, param3);
+                       String result4 = client.method4(param1, param2, param3, param4);
+
+                       client.requestSignal();
+                       client.requestPolicyChangeNotification();
+
+                       client.disconnect();
+               } catch (runtime::Exception& e) {
+                       ERROR(e.what());
+               }
+       }
 
 private:
-    pid_t pid;
+       pid_t pid;
 };
 
 IpcTestSuite ipcTestSuite("IpcTestSuite");
index 41932d3..9bc48ee 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <string>
 #include <unistd.h>
 
 TESTCASE(GetGroupTest)
 {
-    try {
-        runtime::Group group("users");
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       try {
+               runtime::Group group("users");
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(GetUserTest)
 {
-    try {
-        runtime::User user("root");
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       try {
+               runtime::User user("root");
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
index 38c8807..56f80dc 100644 (file)
@@ -1,17 +1,18 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
 
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -35,68 +36,68 @@ const std::string testXmlFilePath = "/opt/data/dpm/sample-policy.xml";
 
 TESTCASE(XPath)
 {
-    try {
-        xml::Document* document = xml::Parser::parseFile(testXmlFilePath);
-        xml::Node::NodeList nodes = document->evaluate("//policy-group[@name='APPLICATION']/policy[@name='SET_APP_INSTALLATION_MODE']");
-        xml::Node::NodeList::iterator iter = nodes.begin();
-
-        TEST_EXPECT(false, iter == nodes.end());
-
-        while (iter != nodes.end()) {
-            ++iter;
-        }
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+       try {
+               xml::Document* document = xml::Parser::parseFile(testXmlFilePath);
+               xml::Node::NodeList nodes = document->evaluate("//policy-group[@name='APPLICATION']/policy[@name='SET_APP_INSTALLATION_MODE']");
+               xml::Node::NodeList::iterator iter = nodes.begin();
+
+               TEST_EXPECT(false, iter == nodes.end());
+
+               while (iter != nodes.end()) {
+                       ++iter;
+               }
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(XmlDomTree)
 {
-    try {
-        xml::Document* document = xml::Parser::parseFile(testXmlFilePath);
+       try {
+               xml::Document* document = xml::Parser::parseFile(testXmlFilePath);
 
-        xml::Node& root = document->getRootNode();
+               xml::Node& root = document->getRootNode();
 
-        xml::Node::NodeList list = root.getChildren();
-        xml::Node::NodeList::iterator iter = list.begin();
+               xml::Node::NodeList list = root.getChildren();
+               xml::Node::NodeList::iterator iter = list.begin();
 
-        TEST_EXPECT(false, iter == list.end());
+               TEST_EXPECT(false, iter == list.end());
 
-        while (iter != list.end()) {
-            ++iter;
-        }
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+               while (iter != list.end()) {
+                       ++iter;
+               }
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(XmlGenerate)
 {
-    try {
-        xml::Document doc("TestNode", "0.1");
-        xml::Node &root = doc.getRootNode();
-        xml::Node node = root.addNewChild("ChildNode");
-        TEST_EXPECT("ChildNode", node.getName());
+       try {
+               xml::Document doc("TestNode", "0.1");
+               xml::Node &root = doc.getRootNode();
+               xml::Node node = root.addNewChild("ChildNode");
+               TEST_EXPECT("ChildNode", node.getName());
 
-        node.setName("ModifiedChildNode");
-        TEST_EXPECT("ModifiedChildNode", node.getName());
+               node.setName("ModifiedChildNode");
+               TEST_EXPECT("ModifiedChildNode", node.getName());
 
-        node.setContent("Content");
-        TEST_EXPECT("Content", node.getContent());
+               node.setContent("Content");
+               TEST_EXPECT("Content", node.getContent());
 
-        node.setProp("Prop", "Value");
-        TEST_EXPECT("Value", node.getProp("Prop"));
+               node.setProp("Prop", "Value");
+               TEST_EXPECT("Value", node.getProp("Prop"));
 
-        doc.write("/tmp/test.xml", "UTF-8", true);
-    } catch (runtime::Exception& e) {
-        TEST_FAIL(e.what());
-    }
+               doc.write("/tmp/test.xml", "UTF-8", true);
+       } catch (runtime::Exception& e) {
+               TEST_FAIL(e.what());
+       }
 }
 
 TESTCASE(XmlException)
 {
-    try {
-        xml::Parser::parseFile("Invalid Source");
-    } catch (runtime::Exception& e) {
-    }
+       try {
+               xml::Parser::parseFile("Invalid Source");
+       } catch (runtime::Exception& e) {
+       }
 }
index 1f4e3ac..acc1d86 100644 (file)
@@ -14,8 +14,8 @@
 # limitations under the License.
 #
 
-SET(DPM_CLI ${DPM_TOOLS}/cli)
-SET(DPM_ODE ${DPM_TOOLS}/ode)
+SET(DPM_CLI      ${DPM_TOOLS}/cli)
+SET(DPM_ODE      ${DPM_TOOLS}/ode)
 SET(DPM_SYSPOPUP ${DPM_TOOLS}/syspopup)
 
 ADD_SUBDIRECTORY(${DPM_CLI})
index cd5dd0f..fbdcbda 100755 (executable)
@@ -6,7 +6,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,6 +20,7 @@
 #define __ODE_APP_WIDGET_H__
 
 #include "ode-app.h"
+
 Evas_Object* dpm_encryption_create_layout(Evas_Object* parent, const char* file, const char* group);
 Evas_Object* dpm_encryption_create_navigation(Evas_Object* parent);
 Evas_Object* dpm_encryption_create_button(Evas_Object* parent, const char* text, const char* style);
index ee94582..a4bdd62 100755 (executable)
@@ -9,7 +9,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
index 262b2f5..1a84300 100755 (executable)
@@ -6,7 +6,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
index 94e2ead..19d5dc2 100755 (executable)
@@ -6,7 +6,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
index 892288e..a8569de 100755 (executable)
@@ -231,12 +231,12 @@ static void set_icon(appdata_s* ad, int type, char* part)
                evas_object_size_hint_weight_set(icon_check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
                ret = elm_layout_content_set(ad->dpm_encryption_layout, part, icon_check);
-               if (!ret){
+               if (!ret) {
                        dlog_print(DLOG_ERROR, LOG_TAG, "elm_layout_content_set failed");
                        return;
                }
                evas_object_show(icon_check);
-       } else if (type == ICON_BAR){
+       } else if (type == ICON_BAR) {
                icon_bar = elm_image_add(ad->dpm_encryption_layout);
                if (icon_bar == NULL) {
                        dlog_print(DLOG_ERROR, LOG_TAG, "elm_image_add failed");
@@ -248,7 +248,7 @@ static void set_icon(appdata_s* ad, int type, char* part)
                evas_object_size_hint_weight_set(icon_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
                ret = elm_layout_content_set(ad->dpm_encryption_layout, part, icon_bar);
-               if (!ret){
+               if (!ret) {
                        dlog_print(DLOG_ERROR, LOG_TAG, "elm_layout_content_set failed");
                        return;
                }
index 9fe517f..1b92cfb 100644 (file)
@@ -5,8 +5,8 @@ INCLUDE_DIRECTORIES(./include)
 
 FIND_PACKAGE(PkgConfig REQUIRED)
 PKG_CHECK_MODULES(dpm_syspopup_pkgs REQUIRED
-        dlog
-        glib-2.0
+               dlog
+               glib-2.0
        bundle
        efl-extension
        elementary
@@ -21,8 +21,8 @@ LINK_DIRECTORIES(${dpm_syspopup_pkgs_LIBRARY_DIRS})
 
 SET(PKG_NAME "${PROJECT_NAME}")
 SET(PKG_SRC src/main.c
-            src/ui.c
-            src/popup-list.c)
+                       src/ui.c
+                       src/popup-list.c)
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
index ba84e5d..5a0499a 100644 (file)
@@ -7,7 +7,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
index f4eaa12..e7782dd 100644 (file)
@@ -7,7 +7,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
index 0ca8ac2..890dcf6 100644 (file)
@@ -7,7 +7,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,6 +16,7 @@
  * limitations under the License.
  *
  */
+
 #include <dpm/password.h>
 
 #include "dpm-syspopup.h"
index 3276062..a116468 100644 (file)
@@ -7,7 +7,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,6 +16,7 @@
  * limitations under the License.
  *
  */
+
 #include <notification.h>
 #include <efl_util.h>
 
index 9bd9229..19c6ec8 100755 (executable)
 # limitations under the License.
 #
 
-SET(ZONE_MODULE                  ${DPM_ZONE}/module)
-SET(ZONE_LIBS            ${DPM_ZONE}/libs)
-SET(ZONE_CLI             ${DPM_ZONE}/cli)
-SET(ZONE_VOLUME           ${DPM_ZONE}/volume)
+SET(ZONE_MODULE  ${DPM_ZONE}/module)
+SET(ZONE_LIBS    ${DPM_ZONE}/libs)
+SET(ZONE_CLI     ${DPM_ZONE}/cli)
+SET(ZONE_VOLUME  ${DPM_ZONE}/volume)
 
 ADD_SUBDIRECTORY(${ZONE_MODULE})
 ADD_SUBDIRECTORY(${ZONE_LIBS})
index 1ca3a43..44a6cb1 100644 (file)
 PROJECT(zone-cli)
 
 FILE(GLOB ZONE_CLI_SRCS        zone-admin-cli.cpp
-                        ${ZONE_MODULE}/session.cpp
-                        ${ZONE_MODULE}/zone-builder.cpp
+                                               ${ZONE_MODULE}/session.cpp
+                                               ${ZONE_MODULE}/zone-builder.cpp
 )
 
 SET(ZONE_CLI_NAME "zone-admin-cli")
 
 ADD_EXECUTABLE(${ZONE_CLI_NAME} ${ZONE_CLI_SRCS})
 SET_TARGET_PROPERTIES(${ZONE_CLI_NAME} PROPERTIES PREFIX ""
-    COMPILE_DEFINITIONS PID_FILE_PATH="${RUN_INSTALL_DIR}/zone"
-    COMPILE_FLAGS "-fPIE"
-    LINK_FLAGS "-pie"
+       COMPILE_DEFINITIONS PID_FILE_PATH="${RUN_INSTALL_DIR}/zone"
+       COMPILE_FLAGS "-fPIE"
+       LINK_FLAGS "-pie"
 )
 
 PKG_CHECK_MODULES(ZONE_CLI_DEPS  REQUIRED
-                                 glib-2.0
-                                 capi-appfw-package-manager
-                                 capi-appfw-app-manager
+                                                                glib-2.0
+                                                                capi-appfw-package-manager
+                                                                capi-appfw-app-manager
 )
 
 INCLUDE_DIRECTORIES(SYSTEM ${ZONE_CLI_DEPS_INCLUDE_DIRS} ${DPM_COMMON} ${ZONE_MODULE} ${ZONE_LIBS})
index 81f9fba..65a502c 100644 (file)
@@ -22,6 +22,7 @@
  * @author  Sungbae Yoo (sungbae.yoo@samsung.com)
  * @brief   CLI tool to attach to existing namespace by pam-attach.so
  */
+
 #define _XOPEN_SOURCE
 #include <glib.h>
 #include <sys/wait.h>
 typedef std::pair<std::string, int> NamespacePair;
 
 std::vector<NamespacePair> namespaces = {
-    {"mnt",  CLONE_NEWNS},
-    {"net",  CLONE_NEWNET},
-    {"uts",  CLONE_NEWUTS},
-    {"user", CLONE_NEWUSER},
-    {"ipc",  CLONE_NEWIPC},
-    {"pid",  CLONE_NEWPID}
+       {"mnt",  CLONE_NEWNS},
+       {"net",  CLONE_NEWNET},
+       {"uts",  CLONE_NEWUTS},
+       {"user", CLONE_NEWUSER},
+       {"ipc",  CLONE_NEWIPC},
+       {"pid",  CLONE_NEWPID}
 };
 
 extern char** environ;
 
 static inline void usage(const std::string name)
 {
-    std::cout << "Usage: " << name << " [Option] -- COMMAND" << std::endl
-              << "Run a program in the zone" << std::endl
-              << std::endl
-              << "Options :" << std::endl
-              << "   -a, --attach=zone  execute command in the zone" << std::endl
-              << "   -p, --pkginfo=zone show all packages in the zone" << std::endl
-              << "   -q, --appinfo=zone show all applications in the zone" << std::endl
-              << "   -m, --zone-monitor monitor all zone events" << std::endl
-              << "   -n, --pkg-monitor  monitor all package events in the zone" << std::endl
-              << "   -l, --list         show all zone instances" << std::endl
-              << "   -h, --help         show this" << std::endl
-              << std::endl;
+       std::cout << "Usage: " << name << " [Option] -- COMMAND" << std::endl
+                         << "Run a program in the zone" << std::endl
+                         << std::endl
+                         << "Options :" << std::endl
+                         << "   -a, --attach=zone  execute command in the zone" << std::endl
+                         << "   -p, --pkginfo=zone show all packages in the zone" << std::endl
+                         << "   -q, --appinfo=zone show all applications in the zone" << std::endl
+                         << "   -m, --zone-monitor monitor all zone events" << std::endl
+                         << "   -n, --pkg-monitor  monitor all package events in the zone" << std::endl
+                         << "   -l, --list         show all zone instances" << std::endl
+                         << "   -h, --help         show this" << std::endl
+                         << std::endl;
 }
 
 int showZoneInstances()
 {
-    try {
-        runtime::DirectoryIterator iter("/var/run/zone"), end;
-
-        while (iter != end) {
-            const std::string& path = (*iter).getPath();
-            size_t name = path.rfind('/') + 1;
-            std::cout << path.substr(name) << std::endl;
-            ++iter;
-        }
-    } catch (runtime::Exception& e) {
-        std::cerr << e.what() << std::endl;
-        return -1;
-    }
-
-    return 0;
+       try {
+               runtime::DirectoryIterator iter("/var/run/zone"), end;
+
+               while (iter != end) {
+                       const std::string& path = (*iter).getPath();
+                       size_t name = path.rfind('/') + 1;
+                       std::cout << path.substr(name) << std::endl;
+                       ++iter;
+               }
+       } catch (runtime::Exception& e) {
+               std::cerr << e.what() << std::endl;
+               return -1;
+       }
+
+       return 0;
 }
 
 void attachNamespaces(pid_t pid)
 {
-    int fd;
-    for (const NamespacePair& ns : namespaces) {
-        std::string nspath = "/proc/" + std::to_string(pid) + "/ns/" + ns.first;
-
-        do {
-            fd = ::open(nspath.c_str(), O_RDONLY);
-        } while (fd == -1 && errno == EINTR);
-
-        if (fd == -1) {
-            if (errno != ENOENT) {
-                throw runtime::Exception("Failed to open namesapce: " + nspath);
-            }
-        } else {
-            if (::setns(fd, ns.second)) {
-                ::close(fd);
-                throw runtime::Exception("Failed to attach namespace: " + nspath);
-            }
-            ::close(fd);
-        }
-    }
+       int fd;
+       for (const NamespacePair& ns : namespaces) {
+               std::string nspath = "/proc/" + std::to_string(pid) + "/ns/" + ns.first;
+
+               do {
+                       fd = ::open(nspath.c_str(), O_RDONLY);
+               } while (fd == -1 && errno == EINTR);
+
+               if (fd == -1) {
+                       if (errno != ENOENT) {
+                               throw runtime::Exception("Failed to open namesapce: " + nspath);
+                       }
+               } else {
+                       if (::setns(fd, ns.second)) {
+                               ::close(fd);
+                               throw runtime::Exception("Failed to attach namespace: " + nspath);
+                       }
+                       ::close(fd);
+               }
+       }
 }
 
 void launchProcess(runtime::User& user, char** args)
 {
-    int status;
-
-    pid_t pid = ::fork();
-    if (pid == -1) {
-        throw runtime::Exception("Failed to create child process");
-    }
-
-    if (pid != 0) {
-        ::waitpid(pid, &status, 0);
-        if (WEXITSTATUS(status) != EXIT_SUCCESS) {
-            throw runtime::Exception("Child process terminated abnormally");
-        }
-        return;
-    }
-
-    if (::initgroups(user.getName().c_str(), user.getGid()) == -1) {
-        std::cerr << "Failed to initgroups()" << std::endl;
-        ::exit(EXIT_FAILURE);
-    }
-
-    if (::setgid(user.getGid()) == -1) {
-        std::cerr << "Failed to setgid()" << std::endl;
-        ::exit(EXIT_FAILURE);
-    }
-
-    if (::setuid(user.getUid()) == -1) {
-        std::cerr << "Failed to setuid()" << std::endl;
-        ::exit(EXIT_FAILURE);
-    }
-
-    char *default_args[2];
-    default_args[0] = ::strdup(DEFAULT_SHELL);
-    default_args[1] = NULL;
-
-    if (args == NULL) {
-        args = default_args;
-    }
-
-    ::execve(*args, args, environ);
-    std::cerr << "Failed to execute " << args[0] << std::endl;
-
-    ::free(default_args[0]);
-
-    ::exit(EXIT_FAILURE);
+       int status;
+
+       pid_t pid = ::fork();
+       if (pid == -1) {
+               throw runtime::Exception("Failed to create child process");
+       }
+
+       if (pid != 0) {
+               ::waitpid(pid, &status, 0);
+               if (WEXITSTATUS(status) != EXIT_SUCCESS) {
+                       throw runtime::Exception("Child process terminated abnormally");
+               }
+               return;
+       }
+
+       if (::initgroups(user.getName().c_str(), user.getGid()) == -1) {
+               std::cerr << "Failed to initgroups()" << std::endl;
+               ::exit(EXIT_FAILURE);
+       }
+
+       if (::setgid(user.getGid()) == -1) {
+               std::cerr << "Failed to setgid()" << std::endl;
+               ::exit(EXIT_FAILURE);
+       }
+
+       if (::setuid(user.getUid()) == -1) {
+               std::cerr << "Failed to setuid()" << std::endl;
+               ::exit(EXIT_FAILURE);
+       }
+
+       char *default_args[2];
+       default_args[0] = ::strdup(DEFAULT_SHELL);
+       default_args[1] = NULL;
+
+       if (args == NULL) {
+               args = default_args;
+       }
+
+       ::execve(*args, args, environ);
+       std::cerr << "Failed to execute " << args[0] << std::endl;
+
+       ::free(default_args[0]);
+
+       ::exit(EXIT_FAILURE);
 }
 
 int attachToZone(const std::string& name, char* args[])
 {
-    try {
-        runtime::User user(name);
+       try {
+               runtime::User user(name);
 
-        attachNamespaces(getSessionLeader(user));
-        launchProcess(user, args);
-    } catch (runtime::Exception& e) {
-        std::cerr << e.what() << std::endl;
-        return -1;
-    }
+               attachNamespaces(getSessionLeader(user));
+               launchProcess(user, args);
+       } catch (runtime::Exception& e) {
+               std::cerr << e.what() << std::endl;
+               return -1;
+       }
 
-    return 0;
+       return 0;
 }
 
 bool packgeListCallback(package_info_h info, void *user_data)
 {
-    bool checked;
-    char *val;
-
-    std::cout << "Package #" << (*(int*)user_data)++ << " :" << std::endl;
-
-    package_info_get_package(info, &val);
-    std::cout << val;
-    free(val);
-
-    package_info_get_version(info, &val);
-    std::cout << " (" << val << ")" << std::endl;
-    free(val);
-
-    package_info_get_type(info, &val);
-    std::cout << "    Type : " << val << " (";
-    free(val);
-
-    package_info_is_system_package(info, &checked);
-    if (checked) {
-        std::cout <<" System ";
-    }
-    package_info_is_removable_package(info, &checked);
-    if (checked) {
-        std::cout <<" Removable ";
-    }
-    package_info_is_preload_package(info, &checked);
-    if (checked) {
-        std::cout <<" Preload ";
-    }
-    std::cout << ")" << std::endl;
-
-    package_info_get_label(info, &val);
-    std::cout << "    Label : " << val << std::endl;
-    free(val);
-
-    package_info_get_icon(info, &val);
-    std::cout << "    Icon : " << val << std::endl;
-    free(val);
-
-    std::cout << std::endl;
-
-    return true;
+       bool checked;
+       char *val;
+
+       std::cout << "Package #" << (*(int*)user_data)++ << " :" << std::endl;
+
+       package_info_get_package(info, &val);
+       std::cout << val;
+       free(val);
+
+       package_info_get_version(info, &val);
+       std::cout << " (" << val << ")" << std::endl;
+       free(val);
+
+       package_info_get_type(info, &val);
+       std::cout << "    Type : " << val << " (";
+       free(val);
+
+       package_info_is_system_package(info, &checked);
+       if (checked) {
+               std::cout <<" System ";
+       }
+       package_info_is_removable_package(info, &checked);
+       if (checked) {
+               std::cout <<" Removable ";
+       }
+       package_info_is_preload_package(info, &checked);
+       if (checked) {
+               std::cout <<" Preload ";
+       }
+       std::cout << ")" << std::endl;
+
+       package_info_get_label(info, &val);
+       std::cout << "    Label : " << val << std::endl;
+       free(val);
+
+       package_info_get_icon(info, &val);
+       std::cout << "    Icon : " << val << std::endl;
+       free(val);
+
+       std::cout << std::endl;
+
+       return true;
 }
 
 int showPkgInfo(const std::string& name)
 {
-    int num = 0;
+       int num = 0;
 
-    zone_manager_h zoneMgr;
-    zone_package_proxy_h pkgProxy;
+       zone_manager_h zoneMgr;
+       zone_package_proxy_h pkgProxy;
 
-    zone_manager_create(&zoneMgr);
-    zone_package_proxy_create(zoneMgr, name.c_str(), &pkgProxy);
-    zone_package_proxy_foreach_package_info(pkgProxy, packgeListCallback, &num);
-    std::cout << num << " packages are found" << std::endl;
-    zone_package_proxy_destroy(pkgProxy);
-    zone_manager_destroy(zoneMgr);
+       zone_manager_create(&zoneMgr);
+       zone_package_proxy_create(zoneMgr, name.c_str(), &pkgProxy);
+       zone_package_proxy_foreach_package_info(pkgProxy, packgeListCallback, &num);
+       std::cout << num << " packages are found" << std::endl;
+       zone_package_proxy_destroy(pkgProxy);
+       zone_manager_destroy(zoneMgr);
 
-    return 0;
+       return 0;
 }
 
 bool applicationListCallback(app_info_h info, void *user_data)
 {
-    bool checked;
-    char *val;
+       bool checked;
+       char *val;
 
-    std::cout << "Application #" << (*(int*)user_data)++ << " :" << std::endl;
+       std::cout << "Application #" << (*(int*)user_data)++ << " :" << std::endl;
 
-    app_info_get_app_id(info, &val);
-    std::cout << val;
-    free(val);
+       app_info_get_app_id(info, &val);
+       std::cout << val;
+       free(val);
 
-    app_info_get_package(info, &val);
-    std::cout << " (" << val << ")" << std::endl;
-    free(val);
+       app_info_get_package(info, &val);
+       std::cout << " (" << val << ")" << std::endl;
+       free(val);
 
-    app_info_get_type(info, &val);
-    std::cout << "    Type : " << val << " (";
-    free(val);
+       app_info_get_type(info, &val);
+       std::cout << "    Type : " << val << " (";
+       free(val);
 
-    app_info_is_nodisplay(info, &checked);
-    if (checked) {
-        std::cout <<" NoDisplay ";
-    }
-    std::cout << ")"<< std::endl;
+       app_info_is_nodisplay(info, &checked);
+       if (checked) {
+               std::cout <<" NoDisplay ";
+       }
+       std::cout << ")"<< std::endl;
 
-    app_info_get_label(info, &val);
-    std::cout << "    Label : " << val << std::endl;
-    free(val);
+       app_info_get_label(info, &val);
+       std::cout << "    Label : " << val << std::endl;
+       free(val);
 
-    if (app_info_get_icon(info, &val) == APP_MANAGER_ERROR_NONE) {
-        std::cout << "    Icon : " << val << std::endl;
-        free(val);
-    } else {
-        std::cout << "App Manager error" << std::endl;
-    }
+       if (app_info_get_icon(info, &val) == APP_MANAGER_ERROR_NONE) {
+               std::cout << "    Icon : " << val << std::endl;
+               free(val);
+       } else {
+               std::cout << "App Manager error" << std::endl;
+       }
 
-    std::cout << std::endl;
+       std::cout << std::endl;
 
-    return true;
+       return true;
 }
 
 int showAppInfo(const std::string& name)
 {
-    int num = 0;
+       int num = 0;
 
-    zone_manager_h zoneMgr;
-    zone_app_proxy_h appMgr;
+       zone_manager_h zoneMgr;
+       zone_app_proxy_h appMgr;
 
-    zone_manager_create(&zoneMgr);
-    zone_app_proxy_create(zoneMgr, name.c_str(), &appMgr);
-    zone_app_proxy_foreach_app_info(appMgr, applicationListCallback, &num);
-    std::cout << num << " applications are found" << std::endl;
-    zone_app_proxy_destroy(appMgr);
-    zone_manager_destroy(zoneMgr);
+       zone_manager_create(&zoneMgr);
+       zone_app_proxy_create(zoneMgr, name.c_str(), &appMgr);
+       zone_app_proxy_foreach_app_info(appMgr, applicationListCallback, &num);
+       std::cout << num << " applications are found" << std::endl;
+       zone_app_proxy_destroy(appMgr);
+       zone_manager_destroy(zoneMgr);
 
-    return 0;
+       return 0;
 }
 
 GMainLoop *gmainloop = NULL;
 
 void monitorSigHandler(int sig)
 {
-    g_main_loop_quit(gmainloop);
+       g_main_loop_quit(gmainloop);
 }
 
 void zoneCallback(const char* name, const char* object, void *user_data)
 {
-    std::cout << "--- Zone event ---" << std::endl;
-    std::cout << "Type : " << (char*)user_data << std::endl;
-    std::cout << "Name : " << name <<std::endl;
-    std::cout << std::endl;
+       std::cout << "--- Zone event ---" << std::endl;
+       std::cout << "Type : " << (char*)user_data << std::endl;
+       std::cout << "Name : " << name <<std::endl;
+       std::cout << std::endl;
 }
 
 int monitorEvent()
 {
-    int zoneCallbackId[2];
-    zone_manager_h zoneMgr;
-    zone_manager_create(&zoneMgr);
+       int zoneCallbackId[2];
+       zone_manager_h zoneMgr;
+       zone_manager_create(&zoneMgr);
 
-    zone_manager_add_event_cb(zoneMgr, "created", zoneCallback,
-                                (void*)"created", &zoneCallbackId[0]);
-    zone_manager_add_event_cb(zoneMgr, "removed", zoneCallback,
-                                (void*)"removed", &zoneCallbackId[1]);
+       zone_manager_add_event_cb(zoneMgr, "created", zoneCallback,
+                                                               (void*)"created", &zoneCallbackId[0]);
+       zone_manager_add_event_cb(zoneMgr, "removed", zoneCallback,
+                                                               (void*)"removed", &zoneCallbackId[1]);
 
-    std::cout << "=== Monitoring start ===" << std::endl << std::endl;
+       std::cout << "=== Monitoring start ===" << std::endl << std::endl;
 
-    signal(SIGINT, monitorSigHandler);
+       signal(SIGINT, monitorSigHandler);
 
-    gmainloop = g_main_loop_new(NULL, FALSE);
-    g_main_loop_run(gmainloop);
-    g_main_loop_unref(gmainloop);
+       gmainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(gmainloop);
+       g_main_loop_unref(gmainloop);
 
-    zone_manager_remove_event_cb(zoneMgr, zoneCallbackId[0]);
-    zone_manager_remove_event_cb(zoneMgr, zoneCallbackId[1]);
+       zone_manager_remove_event_cb(zoneMgr, zoneCallbackId[0]);
+       zone_manager_remove_event_cb(zoneMgr, zoneCallbackId[1]);
 
-    std::cout << "===  Monitoring end  ===" << std::endl;
+       std::cout << "===  Monitoring end  ===" << std::endl;
 
-    zone_manager_destroy(zoneMgr);
+       zone_manager_destroy(zoneMgr);
 
-    return 0;
+       return 0;
 }
 
 void packageEventCallback(const char *type,
-                          const char *package,
-                          package_manager_event_type_e event_type,
-                          package_manager_event_state_e event_state,
-                          int progress, package_manager_error_e error,
-                          void *user_data)
+                                                 const char *package,
+                                                 package_manager_event_type_e event_type,
+                                                 package_manager_event_state_e event_state,
+                                                 int progress, package_manager_error_e error,
+                                                 void *user_data)
 {
-    std::cout << "--- Package event ---" << std::endl;
-    std::cout << "Pacakge : " << package << std::endl;
-    std::cout << "Pacakge type : " << type << std::endl;
-
-    std::cout << "Event state : ";
-    switch (event_state) {
-    case PACKAGE_MANAGER_EVENT_STATE_STARTED:
-        std::cout << "started" << std::endl;
-        std::cout << "Event type : ";
-        switch (event_type) {
-        case PACKAGE_MANAGER_EVENT_TYPE_INSTALL:
-            std::cout << "install";
-            break;
-        case PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL:
-            std::cout << "uninstall";
-            break;
-        case PACKAGE_MANAGER_EVENT_TYPE_UPDATE:
-            std::cout << "update";
-            break;
-        }
-        break;
-    case PACKAGE_MANAGER_EVENT_STATE_PROCESSING:
-        std::cout << "processing" << std::endl;
-        std::cout << "Progress : " << std::to_string(progress) << "%";
-        break;
-    case PACKAGE_MANAGER_EVENT_STATE_FAILED:
-        std::cout << "failed";
-        break;
-    case PACKAGE_MANAGER_EVENT_STATE_COMPLETED:
-        std::cout << "completed";
-        break;
-    }
-    std::cout << std::endl;
-
-    std::cout << std::endl;
+       std::cout << "--- Package event ---" << std::endl;
+       std::cout << "Pacakge : " << package << std::endl;
+       std::cout << "Pacakge type : " << type << std::endl;
+
+       std::cout << "Event state : ";
+       switch (event_state) {
+       case PACKAGE_MANAGER_EVENT_STATE_STARTED:
+               std::cout << "started" << std::endl;
+               std::cout << "Event type : ";
+               switch (event_type) {
+               case PACKAGE_MANAGER_EVENT_TYPE_INSTALL:
+                       std::cout << "install";
+                       break;
+               case PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL:
+                       std::cout << "uninstall";
+                       break;
+               case PACKAGE_MANAGER_EVENT_TYPE_UPDATE:
+                       std::cout << "update";
+                       break;
+               }
+               break;
+       case PACKAGE_MANAGER_EVENT_STATE_PROCESSING:
+               std::cout << "processing" << std::endl;
+               std::cout << "Progress : " << std::to_string(progress) << "%";
+               break;
+       case PACKAGE_MANAGER_EVENT_STATE_FAILED:
+               std::cout << "failed";
+               break;
+       case PACKAGE_MANAGER_EVENT_STATE_COMPLETED:
+               std::cout << "completed";
+               break;
+       }
+       std::cout << std::endl;
+
+       std::cout << std::endl;
 }
 
 int monitorPkgEvent(const std::string& name)
 {
-    zone_manager_h zoneMgr;
-    zone_package_proxy_h pkgProxy;
+       zone_manager_h zoneMgr;
+       zone_package_proxy_h pkgProxy;
 
-    zone_manager_create(&zoneMgr);
-    zone_package_proxy_create(zoneMgr, name.c_str(), &pkgProxy);
+       zone_manager_create(&zoneMgr);
+       zone_package_proxy_create(zoneMgr, name.c_str(), &pkgProxy);
 
-    zone_package_proxy_set_event_cb(pkgProxy, packageEventCallback, NULL);
+       zone_package_proxy_set_event_cb(pkgProxy, packageEventCallback, NULL);
 
-    std::cout << "=== Monitoring start ===" << std::endl << std::endl;
+       std::cout << "=== Monitoring start ===" << std::endl << std::endl;
 
-    signal(SIGINT, monitorSigHandler);
+       signal(SIGINT, monitorSigHandler);
 
-    gmainloop = g_main_loop_new(NULL, FALSE);
-    g_main_loop_run(gmainloop);
-    g_main_loop_unref(gmainloop);
+       gmainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(gmainloop);
+       g_main_loop_unref(gmainloop);
 
-    zone_package_proxy_unset_event_cb(pkgProxy);
+       zone_package_proxy_unset_event_cb(pkgProxy);
 
-    std::cout << "===  Monitoring end  ===" << std::endl;
+       std::cout << "===  Monitoring end  ===" << std::endl;
 
-    zone_package_proxy_destroy(pkgProxy);
-    zone_manager_destroy(zoneMgr);
+       zone_package_proxy_destroy(pkgProxy);
+       zone_manager_destroy(zoneMgr);
 
-    return 0;
+       return 0;
 }
 
 int main(int argc, char* argv[])
 {
-    int opt = 0, index, ret = 0;
-
-    struct option options[] = {
-        {"attach", required_argument, 0, 'a'},
-        {"list", no_argument, 0, 'l'},
-        {"pkginfo", required_argument, 0, 'p'},
-        {"appinfo", required_argument, 0, 'q'},
-        {"zone-monitor", no_argument, 0, 'm'},
-        {"pkg-monitor", no_argument, 0, 'n'},
-        {"help", no_argument, 0, 'h'},
-        {0, 0, 0, 0}
-    };
-
-    if (argc <= 1) {
-        usage(argv[0]);
-        return EXIT_SUCCESS;
-    }
-
-    while ((opt = getopt_long(argc, argv, "a:p:q:mn:lh", options, &index)) != -1) {
-        switch (opt) {
-        case 'a':
-            ret = attachToZone(optarg, optind >= argc ? NULL : argv + optind);
-            break;
-        case 'p':
-            ret = showPkgInfo(optarg);
-            break;
-        case 'q':
-            ret = showAppInfo(optarg);
-            break;
-        case 'm':
-            ret = monitorEvent();
-            break;
-        case 'n':
-            ret = monitorPkgEvent(optarg);
-            break;
-        case 'l':
-            ret = showZoneInstances();
-            break;
-        case 'h':
-            usage(argv[0]);
-            break;
-        default:
-            usage(argv[0]);
-            ret = -1;
-        }
-    }
-
-    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+       int opt = 0, index, ret = 0;
+
+       struct option options[] = {
+               {"attach", required_argument, 0, 'a'},
+               {"list", no_argument, 0, 'l'},
+               {"pkginfo", required_argument, 0, 'p'},
+               {"appinfo", required_argument, 0, 'q'},
+               {"zone-monitor", no_argument, 0, 'm'},
+               {"pkg-monitor", no_argument, 0, 'n'},
+               {"help", no_argument, 0, 'h'},
+               {0, 0, 0, 0}
+       };
+
+       if (argc <= 1) {
+               usage(argv[0]);
+               return EXIT_SUCCESS;
+       }
+
+       while ((opt = getopt_long(argc, argv, "a:p:q:mn:lh", options, &index)) != -1) {
+               switch (opt) {
+               case 'a':
+                       ret = attachToZone(optarg, optind >= argc ? NULL : argv + optind);
+                       break;
+               case 'p':
+                       ret = showPkgInfo(optarg);
+                       break;
+               case 'q':
+                       ret = showAppInfo(optarg);
+                       break;
+               case 'm':
+                       ret = monitorEvent();
+                       break;
+               case 'n':
+                       ret = monitorPkgEvent(optarg);
+                       break;
+               case 'l':
+                       ret = showZoneInstances();
+                       break;
+               case 'h':
+                       usage(argv[0]);
+                       break;
+               default:
+                       usage(argv[0]);
+                       ret = -1;
+               }
+       }
+
+       return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index b715f94..6575ea5 100755 (executable)
@@ -38,11 +38,11 @@ SET(CAPI_INCLUDE_FILES  zone/zone.h
 SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
 
 PKG_CHECK_MODULES(ZONE_LIBS_DEPS  REQUIRED
-                                  glib-2.0
-                                  capi-appfw-package-manager
-                                  capi-appfw-app-manager
-                                  capi-appfw-app-control
-                                  libtzplatform-config
+                                                                 glib-2.0
+                                                                 capi-appfw-package-manager
+                                                                 capi-appfw-app-manager
+                                                                 capi-appfw-app-control
+                                                                 libtzplatform-config
 )
 
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCES})
index 878f664..da64314 100644 (file)
@@ -19,7 +19,7 @@
 namespace DevicePolicyManager {
 
 ZoneAppProxy::ZoneAppProxy(PolicyControlContext& ctx)
-    : context(ctx)
+       : context(ctx)
 {
 }
 
@@ -29,78 +29,78 @@ ZoneAppProxy::~ZoneAppProxy()
 
 ZoneAppProxy::AppInfo ZoneAppProxy::getAppInfo(const std::string& name, const std::string& appid)
 {
-    try {
-        return context->methodCall<ZoneAppProxy::AppInfo>("ZoneAppProxy::getAppInfo", name, appid);
-    } catch (runtime::Exception& e) {}
-    return ZoneAppProxy::AppInfo();
+       try {
+               return context->methodCall<ZoneAppProxy::AppInfo>("ZoneAppProxy::getAppInfo", name, appid);
+       } catch (runtime::Exception& e) {}
+       return ZoneAppProxy::AppInfo();
 }
 
 int ZoneAppProxy::createIterator(const std::string& zone)
 {
-    try {
-        return context->methodCall<int>("ZoneAppProxy::createIterator", zone);
-    } catch (runtime::Exception& e) {}
-    return -1;
+       try {
+               return context->methodCall<int>("ZoneAppProxy::createIterator", zone);
+       } catch (runtime::Exception& e) {}
+       return -1;
 }
 
 ZoneAppProxy::AppInfo ZoneAppProxy::getIteratorValue(int iterator)
 {
-    try {
-        return context->methodCall<ZoneAppProxy::AppInfo>("ZoneAppProxy::getIteratorValue", iterator);
-    } catch (runtime::Exception& e) {}
-    return ZoneAppProxy::AppInfo();
+       try {
+               return context->methodCall<ZoneAppProxy::AppInfo>("ZoneAppProxy::getIteratorValue", iterator);
+       } catch (runtime::Exception& e) {}
+       return ZoneAppProxy::AppInfo();
 }
 
 bool ZoneAppProxy::nextIterator(int iterator)
 {
-    try {
-        return context->methodCall<bool>("ZoneAppProxy::nextIterator", iterator);
-    } catch (runtime::Exception& e) {}
-    return false;
+       try {
+               return context->methodCall<bool>("ZoneAppProxy::nextIterator", iterator);
+       } catch (runtime::Exception& e) {}
+       return false;
 }
 
 int ZoneAppProxy::destroyIterator(int iterator)
 {
-    try {
-        return context->methodCall<int>("ZoneAppProxy::destroyIterator", iterator);
-    } catch (runtime::Exception& e) {}
-    return -1;
+       try {
+               return context->methodCall<int>("ZoneAppProxy::destroyIterator", iterator);
+       } catch (runtime::Exception& e) {}
+       return -1;
 }
 
 int ZoneAppProxy::launch(const std::string& name, const ZoneAppProxy::Bundle& bundle)
 {
-    try {
-        return context->methodCall<int>("ZoneAppProxy::launch", name, bundle);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneAppProxy::launch", name, bundle);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZoneAppProxy::resume(const std::string& name, const std::string& appid)
 {
-    try {
-        return context->methodCall<int>("ZoneAppProxy::resume", name, appid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneAppProxy::resume", name, appid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZoneAppProxy::terminate(const std::string& name, const std::string& appid)
 {
-    try {
-        return context->methodCall<int>("ZoneAppProxy::terminate", name, appid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneAppProxy::terminate", name, appid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 bool ZoneAppProxy::isRunning(const std::string& name, const std::string& appid)
 {
-    try {
-        return context->methodCall<bool>("ZoneAppProxy::isRunning", name, appid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<bool>("ZoneAppProxy::isRunning", name, appid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } // namespace DevicePolicyManager
index 3d0648a..1fd8e81 100644 (file)
@@ -17,8 +17,8 @@
 
 namespace DevicePolicyManager {
 
-ZonePackageProxy::ZonePackageProxy(PolicyControlContext& ctx)
-    : context(ctx)
+ZonePackageProxy::ZonePackageProxy(PolicyControlContext& ctx) :
+       context(ctx)
 {
 }
 
@@ -28,36 +28,36 @@ ZonePackageProxy::~ZonePackageProxy()
 
 ZonePackageProxy::PackageInfo ZonePackageProxy::getPackageInfo(const std::string& name, const std::string& pkgid)
 {
-    try {
-        return context->methodCall<ZonePackageProxy::PackageInfo>("ZonePackageProxy::getPackageInfo", name, pkgid);
-    } catch (runtime::Exception& e) {}
-    return ZonePackageProxy::PackageInfo();
+       try {
+               return context->methodCall<ZonePackageProxy::PackageInfo>("ZonePackageProxy::getPackageInfo", name, pkgid);
+       } catch (runtime::Exception& e) {}
+       return ZonePackageProxy::PackageInfo();
 }
 
 std::vector<std::string> ZonePackageProxy::getPackageList(const std::string& zone)
 {
-    try {
-        return context->methodCall<std::vector<std::string>>("ZonePackageProxy::getPackageList", zone);
-    } catch (runtime::Exception& e) {}
-    return std::vector<std::string>();;
+       try {
+               return context->methodCall<std::vector<std::string>>("ZonePackageProxy::getPackageList", zone);
+       } catch (runtime::Exception& e) {}
+       return std::vector<std::string>();;
 }
 
 int ZonePackageProxy::install(const std::string& name, const std::string& pkgid)
 {
-    try {
-        return context->methodCall<int>("ZonePackageProxy::install", name, pkgid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZonePackageProxy::install", name, pkgid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZonePackageProxy::uninstall(const std::string& name, const std::string& pkgid)
 {
-    try {
-        return context->methodCall<int>("ZonePackageProxy::uninstall", name, pkgid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZonePackageProxy::uninstall", name, pkgid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } // namespace DevicePolicyManager
index cbc1aa8..9f6a9ff 100644 (file)
@@ -18,8 +18,8 @@
 
 namespace DevicePolicyManager {
 
-ZoneManager::ZoneManager(PolicyControlContext& ctx)
-    : context(ctx)
+ZoneManager::ZoneManager(PolicyControlContext& ctx) :
+       context(ctx)
 {
 }
 
@@ -29,66 +29,66 @@ ZoneManager::~ZoneManager()
 
 int ZoneManager::createZone(const std::string& name, const std::string& setupWizAppid)
 {
-    try {
-        return context->methodCall<int>("ZoneManager::createZone", name, setupWizAppid);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneManager::createZone", name, setupWizAppid);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZoneManager::removeZone(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZoneManager::removeZone", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneManager::removeZone", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZoneManager::lockZone(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZoneManager::lockZone", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneManager::lockZone", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZoneManager::unlockZone(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZoneManager::unlockZone", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneManager::unlockZone", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 int ZoneManager::getZoneState(const std::string& name)
 {
-    try {
-        return context->methodCall<int>("ZoneManager::getZoneState", name);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneManager::getZoneState", name);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 std::vector<std::string> ZoneManager::getZoneList(int state)
 {
-    std::vector<std::string> empty;
-    try {
-        return context->methodCall<std::vector<std::string>>("ZoneManager::getZoneList", state);
-    } catch (runtime::Exception& e) {
-        return empty;
-    }
+       std::vector<std::string> empty;
+       try {
+               return context->methodCall<std::vector<std::string>>("ZoneManager::getZoneList", state);
+       } catch (runtime::Exception& e) {
+               return empty;
+       }
 }
 
 int ZoneManager::resetZonePassword(const std::string& name, const std::string& newPassword)
 {
-    try {
-        return context->methodCall<int>("ZoneManager::resetZonePassword", name, newPassword);
-    } catch (runtime::Exception& e) {
-        return -1;
-    }
+       try {
+               return context->methodCall<int>("ZoneManager::resetZonePassword", name, newPassword);
+       } catch (runtime::Exception& e) {
+               return -1;
+       }
 }
 
 } // namespace DevicePolicyManager
index 5a200a7..96f1a7a 100644 (file)
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct icon_x {
-        char *text;
-        char *lang;
-        char *section;
-        char *size;
-        char *resolution;
-        char *dpi;
+               char *text;
+               char *lang;
+               char *section;
+               char *size;
+               char *resolution;
+               char *dpi;
 } icon_x;
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct label_x {
-        char *name;
-        char *text;
-        char *lang;
+               char *name;
+               char *text;
+               char *lang;
 } label_x;
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct application_x {
-    char *appid;    /*attr*/
-    char *exec;     /*attr*/
-    char *nodisplay;    /*attr, default: "false"*/
-    char *multiple; /*attr, default: "false"*/
-    char *taskmanage;       /*attr, default: "true"*/
-    char *enabled;  /*attr, default: "true"*/
-    char *type;     /*attr*/
-    char *categories;       /*attr*/
-    char *extraid;  /*attr*/
-    char *hwacceleration;   /*attr, default: "default"*/
-    char *screenreader;     /*attr, default: "use-system-setting"*/
-    char *mainapp;  /*attr, default: "false"*/
-    char *package;  /*set from package_x*/
-    char *recentimage;      /*attr, default: "false"*/
-    char *launchcondition;  /*attr, default: "false"*/
-    char *indicatordisplay; /*attr, default: "true"*/
-    char *portraitimg;      /*attr*/
-    char *landscapeimg;     /*attr*/
-    char *effectimage_type; /*attr, default: "image"*/
-    char *guestmode_visibility;     /*attr, default: "true"*/
-    char *component;    /*no xml part*/
-    char *permission_type;  /*attr, default: "normal"*/
-    char *component_type;   /*attr, default: "uiapp"*/
-    char *preload;  /*no xml part*/
-    char *submode;  /*attr, default: "false"*/
-    char *submode_mainid;   /*attr, default: "false"*/
-    char *process_pool;     /*attr, default: "false"*/
-    char *installed_storage;
-    char *autorestart;      /*attr, default: "false"*/
-    char *onboot;   /*attr, default: "false"*/
-    char *support_disable;  /*set from package_x*/
-    char *ui_gadget;    /*attr, default: "false"*/
-    char *launch_mode;      /*attr, default: "single"*/
-    char *ambient_support;  /*attr, default: "false"*/
-    char *alias_appid;      /*attr*/
-    char *effective_appid;  /*attr*/
-    char *package_type;     /*set from package_x*/
-    char *tep_name; /*set from package_x*/
-    char *zip_mount_file;   /*set from package_x*/
-    char *root_path;    /*set from package_x*/
-    char *api_version;      /*set from package_x*/
-    char *for_all_users; /**< Flag that indicates if the package is available for everyone or for current user only, no xml part*/
-    char *is_disabled; /**< Flag that indicates if the application is disabled or not, no xml part*/
-    char *splash_screen_display; /*attr, default: "true"*/
-    GList *label;   /*element*/
-    GList *icon;    /*element*/
-    GList *image;   /*element*/
-    GList *category; /*element*/
-    GList *metadata;    /*element*/
-    GList *permission;      /*element*/
-    GList *launchconditions;    /*element*/
-    GList *notification;    /*element*/
-    GList *datashare;       /*element*/
-    GList *datacontrol; /*element*/
-    GList *background_category; /*element*/
-    GList *appcontrol; /*element*/
-    GList *splashscreens; /*element*/
+       char *appid;    /*attr*/
+       char *exec;     /*attr*/
+       char *nodisplay;    /*attr, default: "false"*/
+       char *multiple; /*attr, default: "false"*/
+       char *taskmanage;       /*attr, default: "true"*/
+       char *enabled;  /*attr, default: "true"*/
+       char *type;     /*attr*/
+       char *categories;       /*attr*/
+       char *extraid;  /*attr*/
+       char *hwacceleration;   /*attr, default: "default"*/
+       char *screenreader;     /*attr, default: "use-system-setting"*/
+       char *mainapp;  /*attr, default: "false"*/
+       char *package;  /*set from package_x*/
+       char *recentimage;      /*attr, default: "false"*/
+       char *launchcondition;  /*attr, default: "false"*/
+       char *indicatordisplay; /*attr, default: "true"*/
+       char *portraitimg;      /*attr*/
+       char *landscapeimg;     /*attr*/
+       char *effectimage_type; /*attr, default: "image"*/
+       char *guestmode_visibility;     /*attr, default: "true"*/
+       char *component;    /*no xml part*/
+       char *permission_type;  /*attr, default: "normal"*/
+       char *component_type;   /*attr, default: "uiapp"*/
+       char *preload;  /*no xml part*/
+       char *submode;  /*attr, default: "false"*/
+       char *submode_mainid;   /*attr, default: "false"*/
+       char *process_pool;     /*attr, default: "false"*/
+       char *installed_storage;
+       char *autorestart;      /*attr, default: "false"*/
+       char *onboot;   /*attr, default: "false"*/
+       char *support_disable;  /*set from package_x*/
+       char *ui_gadget;    /*attr, default: "false"*/
+       char *launch_mode;      /*attr, default: "single"*/
+       char *ambient_support;  /*attr, default: "false"*/
+       char *alias_appid;      /*attr*/
+       char *effective_appid;  /*attr*/
+       char *package_type;     /*set from package_x*/
+       char *tep_name; /*set from package_x*/
+       char *zip_mount_file;   /*set from package_x*/
+       char *root_path;    /*set from package_x*/
+       char *api_version;      /*set from package_x*/
+       char *for_all_users; /**< Flag that indicates if the package is available for everyone or for current user only, no xml part*/
+       char *is_disabled; /**< Flag that indicates if the application is disabled or not, no xml part*/
+       char *splash_screen_display; /*attr, default: "true"*/
+       GList *label;   /*element*/
+       GList *icon;    /*element*/
+       GList *image;   /*element*/
+       GList *category; /*element*/
+       GList *metadata;    /*element*/
+       GList *permission;      /*element*/
+       GList *launchconditions;    /*element*/
+       GList *notification;    /*element*/
+       GList *datashare;       /*element*/
+       GList *datacontrol; /*element*/
+       GList *background_category; /*element*/
+       GList *appcontrol; /*element*/
+       GList *splashscreens; /*element*/
 } application_x;
 
 // pkgmgr-info : include/pkgmgrinfo_private.h
 typedef struct _pkgmgr_appinfo_x {
-    const char *package;
-    char *locale;
-    int app_component;
-    application_x *app_info;
+       const char *package;
+       char *locale;
+       int app_component;
+       application_x *app_info;
 } pkgmgr_appinfo_x;
 
 // app-manager : src/app_info.c
 typedef struct app_info_s {
-    char *app_id;
-    pkgmgr_appinfo_x *pkg_app_info;
+       char *app_id;
+       pkgmgr_appinfo_x *pkg_app_info;
 } app_info_s;
 
 
index 57461a9..51275e5 100644 (file)
 using namespace DevicePolicyManager;
 
 struct zone_app_proxy_s {
-    ZoneAppProxy proxy;
-    std::string zoneName;
+       ZoneAppProxy proxy;
+       std::string zoneName;
 };
 
 static inline zone_app_proxy_s* getInstance(zone_app_proxy_h handle)
 {
-    return reinterpret_cast<zone_app_proxy_s *>(handle);
+       return reinterpret_cast<zone_app_proxy_s *>(handle);
 }
 
 static app_info_h make_app_info_handle(const ZoneAppProxy::AppInfo& info)
 {
-    if (info.id.empty()) {
-        return NULL;
-    }
-
-    application_x* app = (application_x*)::malloc(sizeof(application_x));
-    pkgmgr_appinfo_x* pkgappinfo = (pkgmgr_appinfo_x*)::malloc(sizeof(pkgmgr_appinfo_x));
-    app_info_s* appinfo = (app_info_s*)::malloc(sizeof(struct app_info_s));
-
-    ::memset(appinfo, 0, sizeof(app_info_s));
-    appinfo->app_id = ::strdup(info.id.c_str());
-    appinfo->pkg_app_info = pkgappinfo;
-
-    ::memset(pkgappinfo, 0, sizeof(pkgmgr_appinfo_x));
-    pkgappinfo->package = ::strdup(info.package.c_str());
-    pkgappinfo->locale = ::strdup(info.locale.c_str());
-    pkgappinfo->app_component = info.componentType;
-    pkgappinfo->app_info = app;
-
-    ::memset(app, 0, sizeof(application_x));
-    app->appid = ::strdup(info.id.c_str());
-    app->nodisplay = ::strdup(info.isNoDisplayed? "true":"false");
-    app->taskmanage = ::strdup(info.isTaskManaged? "true":"false");
-    app->type = ::strdup(info.type.c_str());
-
-    icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x));
-    icon->text = ::strdup(info.icon.c_str());
-    icon->lang = ::strdup(info.locale.c_str());
-    app->icon = ::g_list_append(NULL, icon);
-
-    label_x* label = (label_x*)::calloc(1, sizeof(label_x));
-    label->text = ::strdup(info.label.c_str());
-    label->lang = ::strdup(info.locale.c_str());
-    app->label = ::g_list_append(NULL, label);
-
-    return reinterpret_cast<app_info_h>(appinfo);
+       if (info.id.empty()) {
+               return NULL;
+       }
+
+       application_x* app = (application_x*)::malloc(sizeof(application_x));
+       pkgmgr_appinfo_x* pkgappinfo = (pkgmgr_appinfo_x*)::malloc(sizeof(pkgmgr_appinfo_x));
+       app_info_s* appinfo = (app_info_s*)::malloc(sizeof(struct app_info_s));
+
+       ::memset(appinfo, 0, sizeof(app_info_s));
+       appinfo->app_id = ::strdup(info.id.c_str());
+       appinfo->pkg_app_info = pkgappinfo;
+
+       ::memset(pkgappinfo, 0, sizeof(pkgmgr_appinfo_x));
+       pkgappinfo->package = ::strdup(info.package.c_str());
+       pkgappinfo->locale = ::strdup(info.locale.c_str());
+       pkgappinfo->app_component = info.componentType;
+       pkgappinfo->app_info = app;
+
+       ::memset(app, 0, sizeof(application_x));
+       app->appid = ::strdup(info.id.c_str());
+       app->nodisplay = ::strdup(info.isNoDisplayed? "true":"false");
+       app->taskmanage = ::strdup(info.isTaskManaged? "true":"false");
+       app->type = ::strdup(info.type.c_str());
+
+       icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x));
+       icon->text = ::strdup(info.icon.c_str());
+       icon->lang = ::strdup(info.locale.c_str());
+       app->icon = ::g_list_append(NULL, icon);
+
+       label_x* label = (label_x*)::calloc(1, sizeof(label_x));
+       label->text = ::strdup(info.label.c_str());
+       label->lang = ::strdup(info.locale.c_str());
+       app->label = ::g_list_append(NULL, label);
+
+       return reinterpret_cast<app_info_h>(appinfo);
 }
 
 int zone_app_proxy_create(zone_manager_h manager, const char* name, zone_app_proxy_h *handle)
 {
-    RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
 
-    zone_app_proxy_s* instance = new zone_app_proxy_s {
-        GetDevicePolicyContext(manager).createPolicyInterface<ZoneAppProxy>(),
-        name
-    };
+       zone_app_proxy_s* instance = new zone_app_proxy_s {
+               GetDevicePolicyContext(manager).createPolicyInterface<ZoneAppProxy>(),
+               name
+       };
 
-    *handle = reinterpret_cast<zone_app_proxy_h>(instance);
-    return ZONE_ERROR_NONE;
+       *handle = reinterpret_cast<zone_app_proxy_h>(instance);
+       return ZONE_ERROR_NONE;
 }
 
 int zone_app_proxy_destroy(zone_app_proxy_h handle)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
 
-    delete reinterpret_cast<ZoneAppProxy*>(handle);
+       delete reinterpret_cast<ZoneAppProxy*>(handle);
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_app_proxy_get_app_info(zone_app_proxy_h handle, const char* app_id, app_info_h* app_info)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(app_info, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(app_info, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
 
-    const auto info = proxy.getAppInfo(name, app_id);
-    app_info_h ret = make_app_info_handle(info);
-    if (ret == NULL) {
-        return ZONE_ERROR_INVALID_PARAMETER;
-    }
+       const auto info = proxy.getAppInfo(name, app_id);
+       app_info_h ret = make_app_info_handle(info);
+       if (ret == NULL) {
+               return ZONE_ERROR_INVALID_PARAMETER;
+       }
 
-    *app_info = ret;
+       *app_info = ret;
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_app_proxy_foreach_app_info(zone_app_proxy_h handle, app_manager_app_info_cb callback, void *user_data)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
-
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
-
-    int iter = proxy.createIterator(name);
-    do {
-        app_info_h info = make_app_info_handle(proxy.getIteratorValue(iter));
-        int ret = callback(info, user_data);
-        app_info_destroy(info);
-        if (!ret) {
-            break;
-        }
-    } while (proxy.nextIterator(iter));
-    proxy.destroyIterator(iter);
-
-    return ZONE_ERROR_NONE;
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
+
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
+
+       int iter = proxy.createIterator(name);
+       do {
+               app_info_h info = make_app_info_handle(proxy.getIteratorValue(iter));
+               int ret = callback(info, user_data);
+               app_info_destroy(info);
+               if (!ret) {
+                       break;
+               }
+       } while (proxy.nextIterator(iter));
+       proxy.destroyIterator(iter);
+
+       return ZONE_ERROR_NONE;
 }
 
 static bool appExtraCallback(app_control_h app_control, const char *key, void *user_data)
 {
-    ZoneAppProxy::Bundle *bundle = reinterpret_cast<ZoneAppProxy::Bundle*>(user_data);
-    ZoneAppProxy::Bundle::Extra extra;
-    bool isArray;
-
-    extra.key = key;
-
-    app_control_is_extra_data_array(app_control, key, &isArray);
-    if (isArray) {
-        char **values;
-        int length = 0;
-        app_control_get_extra_data_array(app_control, key, &values, &length);
-        for (int i = 0; i < length; i++) {
-            extra.value.push_back(values[i]);
-            free(values[i]);
-        }
-        free(values);
-    } else {
-        char *value;
-        app_control_get_extra_data(app_control, key, &value);
-        extra.value.push_back(value);
-        free(value);
-    }
-    bundle->extraData.push_back(extra);
-
-    return true;
+       ZoneAppProxy::Bundle *bundle = reinterpret_cast<ZoneAppProxy::Bundle*>(user_data);
+       ZoneAppProxy::Bundle::Extra extra;
+       bool isArray;
+
+       extra.key = key;
+
+       app_control_is_extra_data_array(app_control, key, &isArray);
+       if (isArray) {
+               char **values;
+               int length = 0;
+               app_control_get_extra_data_array(app_control, key, &values, &length);
+               for (int i = 0; i < length; i++) {
+                       extra.value.push_back(values[i]);
+                       free(values[i]);
+               }
+               free(values);
+       } else {
+               char *value;
+               app_control_get_extra_data(app_control, key, &value);
+               extra.value.push_back(value);
+               free(value);
+       }
+       bundle->extraData.push_back(extra);
+
+       return true;
 }
 
 int zone_app_proxy_send_launch_request(zone_app_proxy_h handle, app_control_h app_control)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(app_control, ZONE_ERROR_INVALID_PARAMETER);
-
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
-    char *str;
-
-    ZoneAppProxy::Bundle bundle;
-    app_control_get_operation(app_control, &str);
-    if (str != NULL) {
-        bundle.operation = str;
-        free(str);
-        str = NULL;
-    }
-    app_control_get_uri(app_control, &str);
-    if (str != NULL) {
-        bundle.uri = str;
-        free(str);
-        str = NULL;
-    }
-    app_control_get_mime(app_control, &str);
-    if (str != NULL) {
-        bundle.mime = str;
-        free(str);
-        str = NULL;
-    }
-    app_control_get_category(app_control, &str);
-    if (str != NULL) {
-        bundle.category = str;
-        free(str);
-        str = NULL;
-    }
-    app_control_get_app_id(app_control, &str);
-    if (str != NULL) {
-        bundle.appId = str;
-        free(str);
-        str = NULL;
-    }
-    app_control_foreach_extra_data(app_control, appExtraCallback, &bundle);
-
-    return proxy.launch(name, bundle);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(app_control, ZONE_ERROR_INVALID_PARAMETER);
+
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
+       char *str;
+
+       ZoneAppProxy::Bundle bundle;
+       app_control_get_operation(app_control, &str);
+       if (str != NULL) {
+               bundle.operation = str;
+               free(str);
+               str = NULL;
+       }
+       app_control_get_uri(app_control, &str);
+       if (str != NULL) {
+               bundle.uri = str;
+               free(str);
+               str = NULL;
+       }
+       app_control_get_mime(app_control, &str);
+       if (str != NULL) {
+               bundle.mime = str;
+               free(str);
+               str = NULL;
+       }
+       app_control_get_category(app_control, &str);
+       if (str != NULL) {
+               bundle.category = str;
+               free(str);
+               str = NULL;
+       }
+       app_control_get_app_id(app_control, &str);
+       if (str != NULL) {
+               bundle.appId = str;
+               free(str);
+               str = NULL;
+       }
+       app_control_foreach_extra_data(app_control, appExtraCallback, &bundle);
+
+       return proxy.launch(name, bundle);
 }
 
 int zone_app_proxy_terminate(zone_app_proxy_h handle, const char* app_id)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
 
-    return proxy.terminate(name, app_id);
+       return proxy.terminate(name, app_id);
 }
 
 int zone_app_proxy_resume(zone_app_proxy_h handle, const char* app_id)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
 
-    return proxy.resume(name, app_id);
+       return proxy.resume(name, app_id);
 }
 
 int zone_app_proxy_is_running(zone_app_proxy_h handle, const char* app_id, int *result)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(result, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(result, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
 
-    *result = proxy.isRunning(name, app_id);
-    return ZONE_ERROR_NONE;
+       *result = proxy.isRunning(name, app_id);
+       return ZONE_ERROR_NONE;
 }
index 8d555d0..d5212ba 100644 (file)
@@ -18,9 +18,9 @@
 #define __CAPI_ZONE_ASSERT_H__
 
 #define RET_ON_FAILURE(cond, ret) \
-        { \
-            if (!(cond)) \
-                return (ret); \
-        }
+{                                 \
+       if (!(cond))                  \
+               return (ret);             \
+}
 
 #endif //! __CAPI_ZONE_ASSERT_H__
index 948371b..0b7fabf 100644 (file)
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct icon_x {
-        char *text;
-        char *lang;
-        char *section;
-        char *size;
-        char *resolution;
-        char *dpi;
+               char *text;
+               char *lang;
+               char *section;
+               char *size;
+               char *resolution;
+               char *dpi;
 } icon_x;
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct description_x {
-        char *name;
-        char *text;
-        char *lang;
+               char *name;
+               char *text;
+               char *lang;
 } description_x;
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct label_x {
-        char *name;
-        char *text;
-        char *lang;
+               char *name;
+               char *text;
+               char *lang;
 } label_x;
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct author_x {
-        char *email;
-        char *href;
-        char *text;
-        char *lang;
+               char *email;
+               char *href;
+               char *text;
+               char *lang;
 } author_x;
 
 // pkgmgr-info : include/pkgmgrinfo_basic.h
 typedef struct package_x {
-    char *for_all_users;        /**< Flag that indicates if the package is available for everyone or for current user only, no xml part*/
-    char *package;              /**< package name, attr*/
-    char *version;              /**< package version, attr*/
-    char *installlocation;      /**< package install location, attr, default: "internal-only"*/
-    char *ns;                   /**<name space, attr*/
-    char *removable;            /**< package removable flag, no xml part*/
-    char *preload;              /**< package preload flag, no xml part*/
-    char *readonly;             /**< package readonly flag, no xml part*/
-    char *update;               /**< package update flag, no xml part*/
-    char *appsetting;           /**< package app setting flag, attr, default: "false"*/
-    char *system;               /**< package system flag, no xml part*/
-    char *type;                 /**< package type, attr*/
-    char *package_size;         /**< package size for external installation, attr*/
-    char *installed_time;       /**< installed time after finishing of installation, no xml part*/
-    char *installed_storage;    /**< package currently installed storage, no xml part*/
-    char *storeclient_id;       /**< id of store client for installed package, attr*/
-    char *mainapp_id;           /**< app id of main application, no xml part*/
-    char *package_url;          /**< app id of main application, attr*/
-    char *root_path;            /**< package root path, attr*/
-    char *csc_path;             /**< package csc path, attr*/
-    char *nodisplay_setting;    /**< package no display setting menu, attr, default: "false"*/
-    char *support_disable;      /**< package support disable flag, attr, default: "false"*/
-    char *api_version;          /**< minimum version of API package using, attr, default: patch_version trimmed version from tizen_full_version*/
-    char *tep_name;             /*no xml part*/
-    char *zip_mount_file;       /*no xml part*/
-    char *backend_installer;    /**< package backend installer, attr*/
-    GList *icon;                /**< package icon, element*/
-    GList *label;               /**< package label, element*/
-    GList *author;              /**< package author, element*/
-    GList *description;         /**< package description, element*/
-    GList *license;             /**< package license, no xml part*/
-    GList *privileges;          /**< package privileges, element*/
-    GList *application;         /**< package's application, element*/
-    GList *compatibility;       /**< package compatibility, element*/
-    GList *deviceprofile;       /**< package device profile, element*/
+       char *for_all_users;        /**< Flag that indicates if the package is available for everyone or for current user only, no xml part*/
+       char *package;              /**< package name, attr*/
+       char *version;              /**< package version, attr*/
+       char *installlocation;      /**< package install location, attr, default: "internal-only"*/
+       char *ns;                   /**<name space, attr*/
+       char *removable;            /**< package removable flag, no xml part*/
+       char *preload;              /**< package preload flag, no xml part*/
+       char *readonly;             /**< package readonly flag, no xml part*/
+       char *update;               /**< package update flag, no xml part*/
+       char *appsetting;           /**< package app setting flag, attr, default: "false"*/
+       char *system;               /**< package system flag, no xml part*/
+       char *type;                 /**< package type, attr*/
+       char *package_size;         /**< package size for external installation, attr*/
+       char *installed_time;       /**< installed time after finishing of installation, no xml part*/
+       char *installed_storage;    /**< package currently installed storage, no xml part*/
+       char *storeclient_id;       /**< id of store client for installed package, attr*/
+       char *mainapp_id;           /**< app id of main application, no xml part*/
+       char *package_url;          /**< app id of main application, attr*/
+       char *root_path;            /**< package root path, attr*/
+       char *csc_path;             /**< package csc path, attr*/
+       char *nodisplay_setting;    /**< package no display setting menu, attr, default: "false"*/
+       char *support_disable;      /**< package support disable flag, attr, default: "false"*/
+       char *api_version;          /**< minimum version of API package using, attr, default: patch_version trimmed version from tizen_full_version*/
+       char *tep_name;             /*no xml part*/
+       char *zip_mount_file;       /*no xml part*/
+       char *backend_installer;    /**< package backend installer, attr*/
+       GList *icon;                /**< package icon, element*/
+       GList *label;               /**< package label, element*/
+       GList *author;              /**< package author, element*/
+       GList *description;         /**< package description, element*/
+       GList *license;             /**< package license, no xml part*/
+       GList *privileges;          /**< package privileges, element*/
+       GList *application;         /**< package's application, element*/
+       GList *compatibility;       /**< package compatibility, element*/
+       GList *deviceprofile;       /**< package device profile, element*/
 } package_x;
 
 // pkgmgr-info : include/pkgmgrinfo_private.h
 typedef struct _pkgmgr_pkginfo_x {
-    uid_t uid;
-    package_x *pkg_info;
-    char *locale;
+       uid_t uid;
+       package_x *pkg_info;
+       char *locale;
 } pkgmgr_pkginfo_x;
 
 // package-manager : src/package_info.c
 typedef struct package_info_s {
-    char *package;
-    pkgmgr_pkginfo_x *pkgmgr_pkginfo;
+       char *package;
+       pkgmgr_pkginfo_x *pkgmgr_pkginfo;
 } package_info_s;
 
 #endif //__ZONE_PACKAGE_INFO_INTERNAL_H__
index 7ddf357..8fc20aa 100644 (file)
 using namespace DevicePolicyManager;
 
 struct zone_package_proxy_s {
-    ZonePackageProxy proxy;
-    std::string zoneName;
-    pkgmgr_client* pNativeHandle;
-    package_manager_event_cb pCallback;
-    void *pCallbackUserData;
+       ZonePackageProxy proxy;
+       std::string zoneName;
+       pkgmgr_client* pNativeHandle;
+       package_manager_event_cb pCallback;
+       void *pCallbackUserData;
 };
 
 static inline zone_package_proxy_s* getInstance(zone_package_proxy_h handle)
 {
-    return reinterpret_cast<zone_package_proxy_s *>(handle);
+       return reinterpret_cast<zone_package_proxy_s *>(handle);
 }
 
 static int packageEventHandler(uid_t target_uid, int req_id,
-                               const char *pkg_type, const char *pkg_name,
-                               const char *key, const char *val,
-                               const void *pmsg, void *data)
+                                                          const char *pkg_type, const char *pkg_name,
+                                                          const char *key, const char *val,
+                                                          const void *pmsg, void *data)
 {
-    static auto event_type = (package_manager_event_type_e)-1;
-    auto event_state = PACKAGE_MANAGER_EVENT_STATE_FAILED;
-    auto instance = getInstance(data);
-    std::string keystr = key;
-    int progress = 0;
-
-    if (target_uid != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) {
-        try {
-            runtime::User pkgOwner(target_uid);
-            if (pkgOwner.getName() != instance->zoneName) {
-                return PACKAGE_MANAGER_ERROR_NONE;
-            }
-        } catch (runtime::Exception &e) {
-            return PACKAGE_MANAGER_ERROR_NONE;
-        }
-    }
-
-    std::transform(keystr.begin(), keystr.end(), keystr.begin(), ::tolower);
-
-    if (keystr == "start") {
-        if (val == NULL) {
-            return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER;
-        }
-
-        std::string valstr = val;
-        std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower);
-        if (valstr == "install") {
-            event_type = PACKAGE_MANAGER_EVENT_TYPE_INSTALL;
-        } else if (valstr == "uninstall") {
-            event_type = PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL;
-        } else if (valstr == "update") {
-            event_type = PACKAGE_MANAGER_EVENT_TYPE_UPDATE;
-        } else {
-            return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER;
-        }
-
-        event_state = PACKAGE_MANAGER_EVENT_STATE_STARTED;
-    } else if (keystr == "install_percent" ||
-               keystr == "progress_percent") {
-        event_state = PACKAGE_MANAGER_EVENT_STATE_PROCESSING;
-        progress = std::stoi(val);
-    } else if (keystr == "error") {
-        event_state = PACKAGE_MANAGER_EVENT_STATE_FAILED;
-    } else if (keystr == "end" ||
-               keystr == "ok") {
-        event_state = PACKAGE_MANAGER_EVENT_STATE_COMPLETED;
-        progress = 100;
-    }
-
-    instance->pCallback(pkg_type, pkg_name,
-                        event_type, event_state, progress,
-                        PACKAGE_MANAGER_ERROR_NONE,
-                        instance->pCallbackUserData);
-
-
-    return PACKAGE_MANAGER_ERROR_NONE;
+       static auto event_type = (package_manager_event_type_e)-1;
+       auto event_state = PACKAGE_MANAGER_EVENT_STATE_FAILED;
+       auto instance = getInstance(data);
+       std::string keystr = key;
+       int progress = 0;
+
+       if (target_uid != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) {
+               try {
+                       runtime::User pkgOwner(target_uid);
+                       if (pkgOwner.getName() != instance->zoneName) {
+                               return PACKAGE_MANAGER_ERROR_NONE;
+                       }
+               } catch (runtime::Exception &e) {
+                       return PACKAGE_MANAGER_ERROR_NONE;
+               }
+       }
+
+       std::transform(keystr.begin(), keystr.end(), keystr.begin(), ::tolower);
+
+       if (keystr == "start") {
+               if (val == NULL) {
+                       return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER;
+               }
+
+               std::string valstr = val;
+               std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower);
+               if (valstr == "install") {
+                       event_type = PACKAGE_MANAGER_EVENT_TYPE_INSTALL;
+               } else if (valstr == "uninstall") {
+                       event_type = PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL;
+               } else if (valstr == "update") {
+                       event_type = PACKAGE_MANAGER_EVENT_TYPE_UPDATE;
+               } else {
+                       return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER;
+               }
+
+               event_state = PACKAGE_MANAGER_EVENT_STATE_STARTED;
+       } else if (keystr == "install_percent" ||
+                          keystr == "progress_percent") {
+               event_state = PACKAGE_MANAGER_EVENT_STATE_PROCESSING;
+               progress = std::stoi(val);
+       } else if (keystr == "error") {
+               event_state = PACKAGE_MANAGER_EVENT_STATE_FAILED;
+       } else if (keystr == "end" ||
+                          keystr == "ok") {
+               event_state = PACKAGE_MANAGER_EVENT_STATE_COMPLETED;
+               progress = 100;
+       }
+
+       instance->pCallback(pkg_type, pkg_name,
+                                               event_type, event_state, progress,
+                                               PACKAGE_MANAGER_ERROR_NONE,
+                                               instance->pCallbackUserData);
+
+
+       return PACKAGE_MANAGER_ERROR_NONE;
 }
 
 static package_info_h make_package_info_handle(const ZonePackageProxy::PackageInfo& info)
 {
-    uid_t zone_uid;
-
-    if (info.id.empty()) {
-        return NULL;
-    }
-
-    try {
-        runtime::User pkgOwner(info.zone);
-        zone_uid = pkgOwner.getUid();
-    } catch (runtime::Exception &e) {
-        return NULL;
-    }
-
-    package_x* package = (package_x*)::calloc(1, sizeof(package_x));
-    pkgmgr_pkginfo_x* pkginfo = (pkgmgr_pkginfo_x*)::calloc(1, sizeof(pkgmgr_pkginfo_x));
-    package_info_s* packageinfo = (package_info_s*)::calloc(1, sizeof(package_info_s));
-
-    packageinfo->package = ::strdup(info.id.c_str());
-    packageinfo->pkgmgr_pkginfo = pkginfo;
-
-    pkginfo->uid = zone_uid;
-    pkginfo->locale = ::strdup(info.locale.c_str());
-    pkginfo->pkg_info = package;
-
-    package->for_all_users = ::strdup("false");
-    package->package = ::strdup(info.id.c_str());
-    package->version = ::strdup(info.version.c_str());
-    package->removable = ::strdup(info.isRemovable? "true":"false");
-    package->preload = ::strdup(info.isPreload? "true":"false");
-    package->system = ::strdup(info.isSystem? "true":"false");
-    package->type = ::strdup(info.type.c_str());
-    package->mainapp_id = ::strdup(info.mainAppId.c_str());
-    package->api_version = ::strdup(info.apiVersion.c_str());
-
-    icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x));
-    icon->text = ::strdup(info.icon.c_str());
-    icon->lang = ::strdup(info.locale.c_str());
-    package->icon = ::g_list_append(NULL, icon);
-
-    label_x* label = (label_x*)::calloc(1, sizeof(label_x));
-    label->text = ::strdup(info.label.c_str());
-    label->lang = ::strdup(info.locale.c_str());
-    package->label = ::g_list_append(NULL, label);
-
-    description_x* desc = (description_x*)::calloc(1, sizeof(description_x));
-    desc->text = ::strdup(info.description.c_str());
-    desc->lang = ::strdup(info.locale.c_str());
-    package->description = ::g_list_append(NULL, desc);
-
-    author_x* author = (author_x*)::calloc(1, sizeof(author_x));
-    author->text = ::strdup(info.author.name.c_str());
-    author->email = ::strdup(info.author.email.c_str());
-    author->href = ::strdup(info.author.href.c_str());
-    author->lang = ::strdup(info.locale.c_str());
-    package->author = ::g_list_append(NULL, author);
-
-    return reinterpret_cast<package_info_h>(packageinfo);
+       uid_t zone_uid;
+
+       if (info.id.empty()) {
+               return NULL;
+       }
+
+       try {
+               runtime::User pkgOwner(info.zone);
+               zone_uid = pkgOwner.getUid();
+       } catch (runtime::Exception &e) {
+               return NULL;
+       }
+
+       package_x* package = (package_x*)::calloc(1, sizeof(package_x));
+       pkgmgr_pkginfo_x* pkginfo = (pkgmgr_pkginfo_x*)::calloc(1, sizeof(pkgmgr_pkginfo_x));
+       package_info_s* packageinfo = (package_info_s*)::calloc(1, sizeof(package_info_s));
+
+       packageinfo->package = ::strdup(info.id.c_str());
+       packageinfo->pkgmgr_pkginfo = pkginfo;
+
+       pkginfo->uid = zone_uid;
+       pkginfo->locale = ::strdup(info.locale.c_str());
+       pkginfo->pkg_info = package;
+
+       package->for_all_users = ::strdup("false");
+       package->package = ::strdup(info.id.c_str());
+       package->version = ::strdup(info.version.c_str());
+       package->removable = ::strdup(info.isRemovable? "true":"false");
+       package->preload = ::strdup(info.isPreload? "true":"false");
+       package->system = ::strdup(info.isSystem? "true":"false");
+       package->type = ::strdup(info.type.c_str());
+       package->mainapp_id = ::strdup(info.mainAppId.c_str());
+       package->api_version = ::strdup(info.apiVersion.c_str());
+
+       icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x));
+       icon->text = ::strdup(info.icon.c_str());
+       icon->lang = ::strdup(info.locale.c_str());
+       package->icon = ::g_list_append(NULL, icon);
+
+       label_x* label = (label_x*)::calloc(1, sizeof(label_x));
+       label->text = ::strdup(info.label.c_str());
+       label->lang = ::strdup(info.locale.c_str());
+       package->label = ::g_list_append(NULL, label);
+
+       description_x* desc = (description_x*)::calloc(1, sizeof(description_x));
+       desc->text = ::strdup(info.description.c_str());
+       desc->lang = ::strdup(info.locale.c_str());
+       package->description = ::g_list_append(NULL, desc);
+
+       author_x* author = (author_x*)::calloc(1, sizeof(author_x));
+       author->text = ::strdup(info.author.name.c_str());
+       author->email = ::strdup(info.author.email.c_str());
+       author->href = ::strdup(info.author.href.c_str());
+       author->lang = ::strdup(info.locale.c_str());
+       package->author = ::g_list_append(NULL, author);
+
+       return reinterpret_cast<package_info_h>(packageinfo);
 }
 
 int zone_package_proxy_create(zone_manager_h manager, const char* name, zone_package_proxy_h *handle)
 {
-    RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-
-    zone_package_proxy_s* instance = new zone_package_proxy_s {
-        GetDevicePolicyContext(manager).
-                                createPolicyInterface<ZonePackageProxy>(),
-        name, ::pkgmgr_client_new(PC_LISTENING), NULL, NULL
-    };
-
-    *handle = reinterpret_cast<zone_package_proxy_h>(instance);
-    return ZONE_ERROR_NONE;
+       RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+
+       zone_package_proxy_s* instance = new zone_package_proxy_s {
+               GetDevicePolicyContext(manager).
+                                                               createPolicyInterface<ZonePackageProxy>(),
+               name, ::pkgmgr_client_new(PC_LISTENING), NULL, NULL
+       };
+
+       *handle = reinterpret_cast<zone_package_proxy_h>(instance);
+       return ZONE_ERROR_NONE;
 }
 
 int zone_package_proxy_destroy(zone_package_proxy_h handle)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
 
-    zone_package_proxy_s* instance = getInstance(handle);
+       zone_package_proxy_s* instance = getInstance(handle);
 
-    ::pkgmgr_client_free(instance->pNativeHandle);
+       ::pkgmgr_client_free(instance->pNativeHandle);
 
-    delete instance;
+       delete instance;
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_package_proxy_get_package_info(zone_package_proxy_h handle, const char* package_id, package_info_h* package_info)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(package_id, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(package_info, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(package_id, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(package_info, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
 
-    const auto& info = proxy.getPackageInfo(name, package_id);
-    package_info_h ret = make_package_info_handle(info);
+       const auto& info = proxy.getPackageInfo(name, package_id);
+       package_info_h ret = make_package_info_handle(info);
 
-    if (ret == NULL) {
-        return ZONE_ERROR_INVALID_PARAMETER;
-    }
+       if (ret == NULL) {
+               return ZONE_ERROR_INVALID_PARAMETER;
+       }
 
-    *package_info = ret;
+       *package_info = ret;
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_package_proxy_foreach_package_info(zone_package_proxy_h handle, package_manager_package_info_cb callback, void *user_data)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
-
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
-
-    for (const auto& pkgid : proxy.getPackageList(name)) {
-        package_info_h info_h = make_package_info_handle(proxy.getPackageInfo(name, pkgid));
-        int ret = callback(info_h, user_data);
-        package_info_destroy(info_h);
-        if (!ret) {
-            break;
-        }
-    }
-
-    return ZONE_ERROR_NONE;
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
+
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
+
+       for (const auto& pkgid : proxy.getPackageList(name)) {
+               package_info_h info_h = make_package_info_handle(proxy.getPackageInfo(name, pkgid));
+               int ret = callback(info_h, user_data);
+               package_info_destroy(info_h);
+               if (!ret) {
+                       break;
+               }
+       }
+
+       return ZONE_ERROR_NONE;
 }
 
 int zone_package_proxy_set_event_status(zone_package_proxy_h handle, int status_type)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
+       auto instance = getInstance(handle);
 
-    int ret;
-    ret = pkgmgrinfo_client_set_status_type(instance->pNativeHandle, status_type);
+       int ret;
+       ret = pkgmgrinfo_client_set_status_type(instance->pNativeHandle, status_type);
 
-    if (ret != PACKAGE_MANAGER_ERROR_NONE)
-        return ZONE_ERROR_INVALID_PARAMETER;
+       if (ret != PACKAGE_MANAGER_ERROR_NONE)
+               return ZONE_ERROR_INVALID_PARAMETER;
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_package_proxy_set_event_cb(zone_package_proxy_h handle, package_manager_event_cb callback, void *user_data)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
+       auto instance = getInstance(handle);
 
-    instance->pCallback = callback;
-    instance->pCallbackUserData = user_data;
+       instance->pCallback = callback;
+       instance->pCallbackUserData = user_data;
 
-    int ret;
-    ret = pkgmgr_client_listen_status(instance->pNativeHandle, packageEventHandler, handle);
+       int ret;
+       ret = pkgmgr_client_listen_status(instance->pNativeHandle, packageEventHandler, handle);
 
-    if (ret < 0)
-        return ZONE_ERROR_INVALID_PARAMETER;
+       if (ret < 0)
+               return ZONE_ERROR_INVALID_PARAMETER;
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_package_proxy_unset_event_cb(zone_package_proxy_h handle)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
+       auto instance = getInstance(handle);
 
-    int ret;
-    ret = pkgmgr_client_remove_listen_status(instance->pNativeHandle);
+       int ret;
+       ret = pkgmgr_client_remove_listen_status(instance->pNativeHandle);
 
-    if (ret < 0)
-        return ZONE_ERROR_INVALID_PARAMETER;
+       if (ret < 0)
+               return ZONE_ERROR_INVALID_PARAMETER;
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_package_proxy_install(zone_package_proxy_h handle, const char* package_path)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(package_path, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(package_path, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
 
-    return proxy.install(name, package_path);
+       return proxy.install(name, package_path);
 }
 
 int zone_package_proxy_uninstall(zone_package_proxy_h handle, const char* package_id)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(package_id, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(package_id, ZONE_ERROR_INVALID_PARAMETER);
 
-    auto instance = getInstance(handle);
-    auto& proxy = instance->proxy;
-    const std::string& name = instance->zoneName;
+       auto instance = getInstance(handle);
+       auto& proxy = instance->proxy;
+       const std::string& name = instance->zoneName;
 
-    return proxy.uninstall(name, package_id);
+       return proxy.uninstall(name, package_id);
 }
index bce2286..a580bb4 100644 (file)
@@ -27,132 +27,132 @@ using namespace DevicePolicyManager;
 
 DevicePolicyContext& GetDevicePolicyContext(void* handle)
 {
-    return *reinterpret_cast<DevicePolicyContext*>(handle);
+       return *reinterpret_cast<DevicePolicyContext*>(handle);
 }
 
 int zone_manager_create(zone_manager_h* handle)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
+       DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
 
-    RET_ON_FAILURE(handle, ZONE_ERROR_CONNECTION_REFUSED);
+       RET_ON_FAILURE(handle, ZONE_ERROR_CONNECTION_REFUSED);
 
-    if (client->connect() < 0) {
-        delete client;
-        RET_ON_FAILURE(handle, ZONE_ERROR_CONNECTION_REFUSED);
-    }
+       if (client->connect() < 0) {
+               delete client;
+               RET_ON_FAILURE(handle, ZONE_ERROR_CONNECTION_REFUSED);
+       }
 
-    *handle = reinterpret_cast<zone_manager_h>(client);
+       *handle = reinterpret_cast<zone_manager_h>(client);
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_manager_destroy(zone_manager_h handle)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
 
-    delete &GetDevicePolicyContext(handle);
+       delete &GetDevicePolicyContext(handle);
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_manager_add_event_cb(zone_manager_h handle, const char* event, zone_event_cb callback, void* user_data, int *id)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(event, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext &context = GetDevicePolicyContext(handle);
-    int ret = context.subscribeSignal(std::string("ZoneManager::") + event,
-                                      callback, user_data);
-    if (ret < 0)
-        return ZONE_ERROR_INVALID_PARAMETER;
-
-    *id = ret;
-    return ZONE_ERROR_NONE;
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(event, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext &context = GetDevicePolicyContext(handle);
+       int ret = context.subscribeSignal(std::string("ZoneManager::") + event,
+                                                                         callback, user_data);
+       if (ret < 0)
+               return ZONE_ERROR_INVALID_PARAMETER;
+
+       *id = ret;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_manager_remove_event_cb(zone_manager_h handle, int callback_id)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback_id >= 0, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback_id >= 0, ZONE_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &context = GetDevicePolicyContext(handle);
-    int ret =  context.unsubscribeSignal(callback_id);
-    if (ret)
-        return ZONE_ERROR_INVALID_PARAMETER;
+       DevicePolicyContext &context = GetDevicePolicyContext(handle);
+       int ret =  context.unsubscribeSignal(callback_id);
+       if (ret)
+               return ZONE_ERROR_INVALID_PARAMETER;
 
-    return ZONE_ERROR_NONE;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_manager_create_zone(zone_manager_h handle, const char* name, const char* manifest)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(manifest, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(manifest, ZONE_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZoneManager zone = client.createPolicyInterface<ZoneManager>();
-    return zone.createZone(name, manifest);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZoneManager zone = client.createPolicyInterface<ZoneManager>();
+       return zone.createZone(name, manifest);
 }
 
 int zone_manager_destroy_zone(zone_manager_h handle, const char* name)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZoneManager zone = client.createPolicyInterface<ZoneManager>();
-    return zone.removeZone(name);
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZoneManager zone = client.createPolicyInterface<ZoneManager>();
+       return zone.removeZone(name);
 }
 
 int zone_manager_get_zone_state(zone_manager_h handle, const char* name, zone_state_e *state)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZoneManager zone = client.createPolicyInterface<ZoneManager>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZoneManager zone = client.createPolicyInterface<ZoneManager>();
 
-    int result = zone.getZoneState(name);
-    if (result == 0) {
-        return ZONE_ERROR_NO_DATA;
-    }
+       int result = zone.getZoneState(name);
+       if (result == 0) {
+               return ZONE_ERROR_NO_DATA;
+       }
 
-    *state = (zone_state_e)result;
-    return ZONE_ERROR_NONE;
+       *state = (zone_state_e)result;
+       return ZONE_ERROR_NONE;
 }
 
 int zone_manager_foreach_name(zone_manager_h handle, zone_state_e state,
-                          zone_manager_foreach_cb callback, void* user_data)
+                                                 zone_manager_foreach_cb callback, void* user_data)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
-
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZoneManager zone = client.createPolicyInterface<ZoneManager>();
-    std::vector<std::string> list = zone.getZoneList(state);
-    for (std::vector<std::string>::iterator it = list.begin();
-         it != list.end(); it++) {
-        if (!callback((*it).c_str(), user_data))
-            break;
-    }
-
-    return ZONE_ERROR_NONE;
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
+
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZoneManager zone = client.createPolicyInterface<ZoneManager>();
+       std::vector<std::string> list = zone.getZoneList(state);
+       for (std::vector<std::string>::iterator it = list.begin();
+                it != list.end(); it++) {
+               if (!callback((*it).c_str(), user_data))
+                       break;
+       }
+
+       return ZONE_ERROR_NONE;
 }
 
 int zone_manager_reset_zone_password(zone_manager_h handle, const char* name, const char* new_password)
 {
-    RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
-    RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+       RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
 
-    if (new_password == NULL) {
-        new_password = "";
-    }
+       if (new_password == NULL) {
+               new_password = "";
+       }
 
-    DevicePolicyContext &client = GetDevicePolicyContext(handle);
-    ZoneManager zone = client.createPolicyInterface<ZoneManager>();
+       DevicePolicyContext &client = GetDevicePolicyContext(handle);
+       ZoneManager zone = client.createPolicyInterface<ZoneManager>();
 
-    return zone.resetZonePassword(name, new_password);
+       return zone.resetZonePassword(name, new_password);
 }
index 3e3e2bb..ef12f2c 100644 (file)
@@ -50,16 +50,16 @@ extern "C" {
  * @since_tizen 3.0
  */
 typedef enum {
-    ZONE_ERROR_NONE                 = TIZEN_ERROR_NONE,                 /**< The operation was successful */
-    ZONE_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
-    ZONE_ERROR_CONNECTION_REFUSED   = TIZEN_ERROR_CONNECTION_REFUSED,   /**< Connection refused */
-    ZONE_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,            /**< Time out */
-    ZONE_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,    /**< Access privilege is not sufficient */
-    ZONE_ERROR_NOT_SUPPORTED        = TIZEN_ERROR_NOT_SUPPORTED,        /**< Operation is not supported */
-    ZONE_ERROR_NO_SUCH_FILE         = TIZEN_ERROR_NO_SUCH_FILE,         /**< No such file or directory */
-    ZONE_ERROR_FILE_EXISTS          = TIZEN_ERROR_FILE_EXISTS,          /**< File exists */
-    ZONE_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,        /**< Out of memory */
-    ZONE_ERROR_NO_DATA              = TIZEN_ERROR_NO_DATA               /**< No Data */
+       ZONE_ERROR_NONE                 = TIZEN_ERROR_NONE,                 /**< The operation was successful */
+       ZONE_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
+       ZONE_ERROR_CONNECTION_REFUSED   = TIZEN_ERROR_CONNECTION_REFUSED,   /**< Connection refused */
+       ZONE_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,            /**< Time out */
+       ZONE_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,    /**< Access privilege is not sufficient */
+       ZONE_ERROR_NOT_SUPPORTED        = TIZEN_ERROR_NOT_SUPPORTED,        /**< Operation is not supported */
+       ZONE_ERROR_NO_SUCH_FILE         = TIZEN_ERROR_NO_SUCH_FILE,         /**< No such file or directory */
+       ZONE_ERROR_FILE_EXISTS          = TIZEN_ERROR_FILE_EXISTS,          /**< File exists */
+       ZONE_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,        /**< Out of memory */
+       ZONE_ERROR_NO_DATA              = TIZEN_ERROR_NO_DATA               /**< No Data */
 } zone_error_type_e;
 
 /**
@@ -140,9 +140,9 @@ typedef void(*zone_event_cb)(const char* name, const char* object, void* user_da
  * @see         zone_manager_remove_event_cb()
  */
 ZONE_API int zone_manager_add_event_cb(zone_manager_h handle,
-                                      const char* event,
-                                      zone_event_cb callback, void* user_data,
-                                      int* id);
+                                                                         const char* event,
+                                                                         zone_event_cb callback, void* user_data,
+                                                                         int* id);
 
 /**
  * @brief       Removes zone event callback.
@@ -213,9 +213,9 @@ ZONE_API int zone_manager_destroy_zone(zone_manager_h handle, const char* name);
  * @since_tizen 3.0
  */
 typedef enum {
-    ZONE_STATE_LOCKED       = 0x01,  /**< Zone has been defined, but it can not start. */
-    ZONE_STATE_RUNNING      = 0x02, /**< Zone has been started. */
-    ZONE_STATE_ALL          = 0xff  /**< This presents all of the state  */
+       ZONE_STATE_LOCKED       = 0x01,  /**< Zone has been defined, but it can not start. */
+       ZONE_STATE_RUNNING      = 0x02, /**< Zone has been started. */
+       ZONE_STATE_ALL          = 0xff  /**< This presents all of the state  */
 } zone_state_e;
 
 /**
@@ -269,9 +269,9 @@ typedef bool(*zone_manager_foreach_cb)(const char* name, void* user_data);
  * @see         zone_manager_destroy_zone()
  */
 ZONE_API int zone_manager_foreach_name(zone_manager_h handle,
-                                       zone_state_e state,
-                                       zone_manager_foreach_cb callback,
-                                       void* user_data);
+                                                                          zone_state_e state,
+                                                                          zone_manager_foreach_cb callback,
+                                                                          void* user_data);
 
 /**
  * @brief       Reset password for the zone.
index d7ef612..c62674c 100644 (file)
@@ -26,12 +26,12 @@ SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack"
 SET(ZONE_PAM_NAME "pam_zone")
 ADD_LIBRARY(${ZONE_PAM_NAME} MODULE ${ZONE_PAM_SRCS})
 SET_TARGET_PROPERTIES(${ZONE_PAM_NAME} PROPERTIES  PREFIX ""
-    COMPILE_DEFINITIONS PID_FILE_PATH="${RUN_INSTALL_DIR}/zone"
-    COMPILE_FLAGS "-fvisibility=hidden"
+       COMPILE_DEFINITIONS PID_FILE_PATH="${RUN_INSTALL_DIR}/zone"
+       COMPILE_FLAGS "-fvisibility=hidden"
 )
 
 FIND_PATH(PAM_INCLUDE_DIR NAMES security/pam_appl.h security/pam_ext.h security/pam_modules.h
-    HINTS ${PAM_ROOT_DIR} PATH_SUFFIXES include)
+       HINTS ${PAM_ROOT_DIR} PATH_SUFFIXES include)
 FIND_LIBRARY(PAM_LIBRARY pam  HINTS ${PAM_ROOT_DIR} PATH_SUFFIXES ${LIB_INSTALL_DIR})
 MARK_AS_ADVANCED(PAM_INCLUDE_DIR PAM_LIBRARY)
 
@@ -42,7 +42,7 @@ INCLUDE_DIRECTORIES(${PAM_INCLUDE_DIR} ${DPM_COMMON})
 TARGET_LINK_LIBRARIES(${ZONE_PAM_NAME} ${PAM_LIBRARY} dpm-common pthread)
 
 TARGET_COMPILE_DEFINITIONS(${ZONE_PAM_NAME} PRIVATE
-    CONF_PATH="${CONF_INSTALL_DIR}"
+       CONF_PATH="${CONF_INSTALL_DIR}"
 )
 
 INSTALL(TARGETS ${ZONE_PAM_NAME} DESTINATION ${LIB_INSTALL_DIR}/security)
index 24b71ae..5977a9f 100644 (file)
 
 bool isValidSessionLeader(pid_t pid)
 {
-    runtime::File proc("/proc/" + std::to_string(pid));
-    return proc.exists();
+       runtime::File proc("/proc/" + std::to_string(pid));
+       return proc.exists();
 }
 
 void createSession(const runtime::User& user, const SessionBuilder& sessionBuilder)
 {
-    runtime::File file("/var/run/zone/" + user.getName());
-    if (file.exists()) {
-        if (isValidSessionLeader(getSessionLeader(user))) {
-            throw runtime::Exception("Session already opened");
-        }
-        file.remove();
-    } else {
-        file.makeBaseDirectory();
-    }
+       runtime::File file("/var/run/zone/" + user.getName());
+       if (file.exists()) {
+               if (isValidSessionLeader(getSessionLeader(user))) {
+                       throw runtime::Exception("Session already opened");
+               }
+               file.remove();
+       } else {
+               file.makeBaseDirectory();
+       }
 
-    sessionBuilder(user);
+       sessionBuilder(user);
 
-    file.create(0600);
-    file.lock();
-    file.chown(user.getUid(), user.getGid());
-    pid_t pid = ::getpid();
-    file.write(&pid, sizeof(pid_t));
-    file.unlock();
+       file.create(0600);
+       file.lock();
+       file.chown(user.getUid(), user.getGid());
+       pid_t pid = ::getpid();
+       file.write(&pid, sizeof(pid_t));
+       file.unlock();
 }
 
 pid_t getSessionLeader(const runtime::User& user)
 {
-    runtime::File file("/var/run/zone/" + user.getName(), O_RDONLY);
-    file.lock();
-    pid_t pid = -1;
-    file.read(&pid, sizeof(pid_t));
-    file.unlock();
+       runtime::File file("/var/run/zone/" + user.getName(), O_RDONLY);
+       file.lock();
+       pid_t pid = -1;
+       file.read(&pid, sizeof(pid_t));
+       file.unlock();
 
-    return pid;
+       return pid;
 }
 
 void destroySession(const runtime::User& user)
 {
-    std::string path = "/var/run/zone/" + user.getName();
-    ::unlink(path.c_str());
+       std::string path = "/var/run/zone/" + user.getName();
+       ::unlink(path.c_str());
 }
index c36e9da..d786a0d 100644 (file)
@@ -26,9 +26,9 @@
 #include "filesystem.h"
 
 ZoneBuilder::ZoneBuilder(const runtime::User& user, const std::string& manifestPath) :
-    name(user.getName()), uid(user.getUid()), gid(user.getGid())
+       name(user.getName()), uid(user.getUid()), gid(user.getGid())
 {
-    manifest.reset(xml::Parser::parseFile(manifestPath));
+       manifest.reset(xml::Parser::parseFile(manifestPath));
 }
 
 ZoneBuilder::~ZoneBuilder()
@@ -36,41 +36,41 @@ ZoneBuilder::~ZoneBuilder()
 }
 
 void ZoneBuilder::bindFilesystemNode(const std::string& source, const std::string& target,
-                                     const std::string& type, const std::string& options,
-                                     bool create)
+                                                                        const std::string& type, const std::string& options,
+                                                                        bool create)
 {
-    if (create) {
-        runtime::File dir(target);
-        if (!dir.exists()) {
-            dir.makeDirectory(true, uid, gid);
-        }
-    }
+       if (create) {
+               runtime::File dir(target);
+               if (!dir.exists()) {
+                       dir.makeDirectory(true, uid, gid);
+               }
+       }
 
-    runtime::Mount::mountEntry(source, target, type, options);
+       runtime::Mount::mountEntry(source, target, type, options);
 }
 
 void ZoneBuilder::containerize(bool create)
 {
-    int nsFlags = CLONE_NEWIPC | CLONE_NEWNS;
+       int nsFlags = CLONE_NEWIPC | CLONE_NEWNS;
 
-    if (::unshare(nsFlags)) {
-        throw runtime::Exception("Failed to unshare namespace");
-    }
+       if (::unshare(nsFlags)) {
+               throw runtime::Exception("Failed to unshare namespace");
+       }
 
-    if (::mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
-        throw runtime::Exception("Failed to mount root filesystem");
-    }
+       if (::mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
+               throw runtime::Exception("Failed to mount root filesystem");
+       }
 
-    xml::Node::NodeList entries = manifest->evaluate("/manifest/filesystem/entry");
-    for (const xml::Node& entry : entries) {
-        bindFilesystemNode(entry.getProp("source"), entry.getProp("target"),
-                           entry.getProp("type"), entry.getProp("options"));
-    }
+       xml::Node::NodeList entries = manifest->evaluate("/manifest/filesystem/entry");
+       for (const xml::Node& entry : entries) {
+               bindFilesystemNode(entry.getProp("source"), entry.getProp("target"),
+                                                  entry.getProp("type"), entry.getProp("options"));
+       }
 
-    bindFilesystemNode("/home/" + name,
-                       "/home/" + name + "/.zone/" + name,
-                       "none", "rw,bind");
+       bindFilesystemNode("/home/" + name,
+                                          "/home/" + name + "/.zone/" + name,
+                                          "none", "rw,bind");
 
-    bindFilesystemNode("/home/" + name + "/.zone", "/home",
-                       "none", "rw,rbind");
+       bindFilesystemNode("/home/" + name + "/.zone", "/home",
+                                          "none", "rw,rbind");
 }
index 52b02a4..7a1890d 100644 (file)
 
 class ZoneBuilder {
 public:
-    ZoneBuilder(const runtime::User& user, const std::string& manifestPath);
-    virtual ~ZoneBuilder();
+       ZoneBuilder(const runtime::User& user, const std::string& manifestPath);
+       virtual ~ZoneBuilder();
 
-    void containerize(bool create = true);
+       void containerize(bool create = true);
 
 protected:
-    void bindFilesystemNode(const std::string& source, const std::string& target,
-                            const std::string& type, const std::string& options,
-                            bool create = true);
+       void bindFilesystemNode(const std::string& source, const std::string& target,
+                                                       const std::string& type, const std::string& options,
+                                                       bool create = true);
 private:
-    std::string name;
-    uid_t uid;
-    gid_t gid;
-    std::unique_ptr<xml::Document> manifest;
+       std::string name;
+       uid_t uid;
+       gid_t gid;
+       std::unique_ptr<xml::Document> manifest;
 };
 
  #endif //!__ZONE_BUILDER_H__
index ded6ba2..1e33d2f 100644 (file)
 
 class ZoneGuard {
 public:
-    ZoneGuard(const std::string& name) :
-        zoneName(name),
-        semaphore(nullptr)
-    {
-        semaphore = ::sem_open(zoneName.c_str(), O_CREAT, 0700, 1);
-        if (semaphore == nullptr) {
-            throw runtime::Exception("Filed to create semaphore for zone guard");
-        }
-    }
-
-    ~ZoneGuard()
-    {
-        if (semaphore == nullptr) {
-            return;
-        }
-
-        ::sem_post(semaphore);
-        ::sem_close(semaphore);
-        ::sem_unlink(zoneName.c_str());
-    }
-
-    void wait()
-    {
-        while ((::sem_wait(semaphore) == -1) && (errno == EINTR));
-    }
+       ZoneGuard(const std::string& name) :
+               zoneName(name), semaphore(nullptr)
+       {
+               semaphore = ::sem_open(zoneName.c_str(), O_CREAT, 0700, 1);
+               if (semaphore == nullptr) {
+                       throw runtime::Exception("Filed to create semaphore for zone guard");
+               }
+       }
+
+       ~ZoneGuard()
+       {
+               if (semaphore == nullptr) {
+                       return;
+               }
+
+               ::sem_post(semaphore);
+               ::sem_close(semaphore);
+               ::sem_unlink(zoneName.c_str());
+       }
+
+       void wait()
+       {
+               while ((::sem_wait(semaphore) == -1) && (errno == EINTR));
+       }
 
 private:
-    std::string zoneName;
-    sem_t* semaphore;
+       std::string zoneName;
+       sem_t* semaphore;
 };
 
 #endif //!__ZONE_GUARD_H__
index 99b9699..b702454 100644 (file)
 
 std::string buildZoneManifestPath(const std::string& name)
 {
-    return ZONE_MANIFEST_DIR + name + ".xml";
+       return ZONE_MANIFEST_DIR + name + ".xml";
 }
 
 std::string getZoneName(pam_handle_t* handle)
 {
-    const void* retItem;
-    int error = ::pam_get_item(handle, PAM_USER, &retItem);
-    if (error != PAM_SUCCESS) {
-        throw runtime::Exception("Failed to get user");
-    }
+       const void* retItem;
+       int error = ::pam_get_item(handle, PAM_USER, &retItem);
+       if (error != PAM_SUCCESS) {
+               throw runtime::Exception("Failed to get user");
+       }
 
-    return static_cast<const char*>(retItem);
+       return static_cast<const char*>(retItem);
 }
 
 void openZoneSession(const std::string& name)
 {
-    auto sessionBuilder = [](const runtime::User& user) {
-        ZoneBuilder builder(user, buildZoneManifestPath(user.getName()));
-        builder.containerize();
-    };
+       auto sessionBuilder = [](const runtime::User& user) {
+               ZoneBuilder builder(user, buildZoneManifestPath(user.getName()));
+               builder.containerize();
+       };
 
-    createSession(runtime::User(name), sessionBuilder);
+       createSession(runtime::User(name), sessionBuilder);
 }
 
 void closeZoneSession(const std::string& name)
 {
-    destroySession(runtime::User(name));
+       destroySession(runtime::User(name));
 }
 
 extern "C" {
 PAM_EXTERN  __attribute__((visibility("default")))
 int pam_sm_open_session(pam_handle_t* pamh, int flags, int argc, const char* argv[])
 {
-    try {
-        std::string name = getZoneName(pamh);
-        ZoneGuard zoneGuard(name);
-        zoneGuard.wait();
-
-        openZoneSession(name);
-    } catch (runtime::Exception& e) {
-        ::pam_syslog(pamh, LOG_ERR, "%s", e.what());
-        return PAM_SESSION_ERR;
-    }
-
-    return PAM_SUCCESS;
+       try {
+               std::string name = getZoneName(pamh);
+               ZoneGuard zoneGuard(name);
+               zoneGuard.wait();
+
+               openZoneSession(name);
+       } catch (runtime::Exception& e) {
+               ::pam_syslog(pamh, LOG_ERR, "%s", e.what());
+               return PAM_SESSION_ERR;
+       }
+
+       return PAM_SUCCESS;
 }
 
 PAM_EXTERN  __attribute__((visibility("default")))
 int pam_sm_close_session(pam_handle_t* pamh, int flags, int argc, const char* argv[])
 {
-    try {
-        std::string name = getZoneName(pamh);
-        ZoneGuard zoneGuard(name);
-        zoneGuard.wait();
-
-        closeZoneSession(name);
-    } catch (runtime::Exception& e) {
-        ::pam_syslog(pamh, LOG_ERR, "%s", e.what());
-        return PAM_SESSION_ERR;
-    }
-
-    return PAM_SUCCESS;
+       try {
+               std::string name = getZoneName(pamh);
+               ZoneGuard zoneGuard(name);
+               zoneGuard.wait();
+
+               closeZoneSession(name);
+       } catch (runtime::Exception& e) {
+               ::pam_syslog(pamh, LOG_ERR, "%s", e.what());
+               return PAM_SESSION_ERR;
+       }
+
+       return PAM_SUCCESS;
 }
 
 #ifdef PAM_MODULE_ENTRY
index 23b85b7..36ffd9a 100644 (file)
@@ -16,9 +16,9 @@
 SET(ZONE_VOLUME_MANAGER_TARGET "zone-volume-manager")
 
 SET(ZONE_VOLUME_MANAGER_SOURCES key-manager.cpp
-                                key-generator.cpp
-                                kernel-keyring.cpp
-                                main.cpp
+                                                               key-generator.cpp
+                                                               kernel-keyring.cpp
+                                                               main.cpp
 )
 
 PKG_CHECK_MODULES(ZONE_VOLUME_MANAGER_DEPS REQUIRED key-manager)
index 561ffdf..9962e34 100755 (executable)
@@ -55,52 +55,52 @@ struct ecryptfs_session_key {
 #define ECRYPTFS_USERSPACE_SHOULD_TRY_TO_ENCRYPT    0x00000002
 #define ECRYPTFS_CONTAINS_DECRYPTED_KEY             0x00000004
 #define ECRYPTFS_CONTAINS_ENCRYPTED_KEY             0x00000008
-    int32_t flags;
-    int32_t encrypted_key_size;
-    int32_t decrypted_key_size;
-    u_int8_t encrypted_key[ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES];
-    u_int8_t decrypted_key[ECRYPTFS_MAX_KEY_HEX];
+       int32_t flags;
+       int32_t encrypted_key_size;
+       int32_t decrypted_key_size;
+       u_int8_t encrypted_key[ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES];
+       u_int8_t decrypted_key[ECRYPTFS_MAX_KEY_HEX];
 };
 
 struct ecryptfs_password {
-    int32_t password_bytes;
-    int32_t hash_algo;
-    int32_t hash_iterations;
-    int32_t session_key_encryption_key_bytes;
+       int32_t password_bytes;
+       int32_t hash_algo;
+       int32_t hash_iterations;
+       int32_t session_key_encryption_key_bytes;
 #define ECRYPTFS_PERSISTENT_PASSWORD                0x01
 #define ECRYPTFS_SESSION_KEY_ENCRYPTION_KEY_SET     0x02
-    u_int32_t flags;
-    /* Iterated-hash concatenation of salt and passphrase */
-    u_int8_t session_key_encryption_key[ECRYPTFS_MAX_KEY_HEX];
-    u_int8_t signature[ECRYPTFS_PASSWORD_SIG_SIZE + 1];
-    /* Always in expanded hex */
-    u_int8_t salt[ECRYPTFS_MAX_SALT_SIZE];
+       u_int32_t flags;
+       /* Iterated-hash concatenation of salt and passphrase */
+       u_int8_t session_key_encryption_key[ECRYPTFS_MAX_KEY_HEX];
+       u_int8_t signature[ECRYPTFS_PASSWORD_SIG_SIZE + 1];
+       /* Always in expanded hex */
+       u_int8_t salt[ECRYPTFS_MAX_SALT_SIZE];
 };
 
 enum ecryptfs_token_types {
-    ECRYPTFS_PASSWORD,
-    ECRYPTFS_PRIVATE_KEY
+       ECRYPTFS_PASSWORD,
+       ECRYPTFS_PRIVATE_KEY
 };
 
 struct ecryptfs_private_key {
-    u_int32_t key_size;
-    u_int32_t data_len;
-    u_int8_t signature[ECRYPTFS_PASSWORD_SIG_SIZE + 1];
-    char pki_type[ECRYPTFS_MAX_PKI_NAME_BYTES + 1];
-    u_int8_t data[];
+       u_int32_t key_size;
+       u_int32_t data_len;
+       u_int8_t signature[ECRYPTFS_PASSWORD_SIG_SIZE + 1];
+       char pki_type[ECRYPTFS_MAX_PKI_NAME_BYTES + 1];
+       u_int8_t data[];
 };
 
 struct ecryptfs_auth_tok {
-    u_int16_t version; /* 8-bit major and 8-bit minor */
-    u_int16_t token_type;
+       u_int16_t version; /* 8-bit major and 8-bit minor */
+       u_int16_t token_type;
 #define ECRYPTFS_ENCRYPT_ONLY                       0x00000001
-    u_int32_t flags;
-    struct ecryptfs_session_key session_key;
-    u_int8_t reserved[32];
-    union {
-        struct ecryptfs_password password;
-        struct ecryptfs_private_key private_key;
-    } token;
+       u_int32_t flags;
+       struct ecryptfs_session_key session_key;
+       u_int8_t reserved[32];
+       union {
+               struct ecryptfs_password password;
+               struct ecryptfs_private_key private_key;
+       } token;
 }  __attribute__((packed));
 
 typedef struct ecryptfs_auth_tok ecryptfs_payload;
index c2b99a4..11d2373 100755 (executable)
 
 KeySerial KernelKeyRing::add(const char *type, const char* description, const void* payload, size_t plen, KeySerial ringid)
 {
-    return ::syscall(__NR_add_key, type, description, payload, plen, ringid);
+       return ::syscall(__NR_add_key, type, description, payload, plen, ringid);
 }
 
 long KernelKeyRing::search(KeySerial ringid, const char* type, const char* description, KeySerial destringid)
 {
-    return ::syscall(__NR_keyctl, KEYCTL_SEARCH, ringid, type, description, destringid);
+       return ::syscall(__NR_keyctl, KEYCTL_SEARCH, ringid, type, description, destringid);
 }
 
 long KernelKeyRing::link(KeySerial keyid, KeySerial ringid)
 {
-    return ::syscall(__NR_keyctl, KEYCTL_LINK, keyid, ringid);
+       return ::syscall(__NR_keyctl, KEYCTL_LINK, keyid, ringid);
 }
 
 long KernelKeyRing::unlink(KeySerial keyid, KeySerial ringid)
 {
-    return ::syscall(__NR_keyctl, KEYCTL_UNLINK, keyid, ringid);
+       return ::syscall(__NR_keyctl, KEYCTL_UNLINK, keyid, ringid);
 }
index 05d35f9..c23d70f 100755 (executable)
@@ -26,17 +26,17 @@ typedef int32_t KeySerial;
 
 class KernelKeyRing {
 public:
-    KernelKeyRing() = delete;
-    KernelKeyRing(const KernelKeyRing&) = delete;
-    KernelKeyRing(KernelKeyRing&&) = delete;
+       KernelKeyRing() = delete;
+       KernelKeyRing(const KernelKeyRing&) = delete;
+       KernelKeyRing(KernelKeyRing&&) = delete;
 
-    KernelKeyRing& operator=(const KernelKeyRing&) = delete;
-    KernelKeyRing& operator=(KernelKeyRing&&) = delete;
+       KernelKeyRing& operator=(const KernelKeyRing&) = delete;
+       KernelKeyRing& operator=(KernelKeyRing&&) = delete;
 
-    static KeySerial add(const char* type, const char* description, const void* payload, size_t plen, KeySerial ringid);
-    static long search(KeySerial ringid, const char* type, const char* description, KeySerial destringid);
-    static long link(KeySerial keyid, KeySerial ringid);
-    static long unlink(KeySerial keyid, KeySerial ringid);
+       static KeySerial add(const char* type, const char* description, const void* payload, size_t plen, KeySerial ringid);
+       static long search(KeySerial ringid, const char* type, const char* description, KeySerial destringid);
+       static long link(KeySerial keyid, KeySerial ringid);
+       static long unlink(KeySerial keyid, KeySerial ringid);
 };
 
 #endif //!__KERNEL_KEY_RING_H__
index 6eb545f..b9d6a46 100755 (executable)
 #define blk0(i) block->l[i]
 #else
 #define blk0(i) (block->l[i] = (rol(block->l[i], 24)&0xff00ff00) \
-    |(rol(block->l[i], 8)&0x00ff00ff))
+       |(rol(block->l[i], 8)&0x00ff00ff))
 #endif
 #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
-    ^block->l[(i+2)&15]^block->l[i&15], 1))
+       ^block->l[(i+2)&15]^block->l[i&15], 1))
 
 /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
 #define R0(v, w, x, y, z, i) \
-    z+=((w&(x^y))^y)+blk0(i)+0x5a827999+rol(v, 5);w=rol(w, 30);
+       z+=((w&(x^y))^y)+blk0(i)+0x5a827999+rol(v, 5);w=rol(w, 30);
 #define R1(v, w, x, y, z, i) \
-    z+=((w&(x^y))^y)+blk(i)+0x5a827999+rol(v, 5);w=rol(w, 30);
+       z+=((w&(x^y))^y)+blk(i)+0x5a827999+rol(v, 5);w=rol(w, 30);
 #define R2(v, w, x, y, z, i) \
-    z+=(w^x^y)+blk(i)+0x6ed9eba1+rol(v, 5);w=rol(w, 30);
+       z+=(w^x^y)+blk(i)+0x6ed9eba1+rol(v, 5);w=rol(w, 30);
 #define R3(v, w, x, y, z, i) \
-    z+=(((w|x)&y)|(w&x))+blk(i)+0x8f1bbcdc+rol(v, 5);w=rol(w, 30);
+       z+=(((w|x)&y)|(w&x))+blk(i)+0x8f1bbcdc+rol(v, 5);w=rol(w, 30);
 #define R4(v, w, x, y, z, i) \
-    z+=(w^x^y)+blk(i)+0xca62c1d6+rol(v, 5);w=rol(w, 30);
+       z+=(w^x^y)+blk(i)+0xca62c1d6+rol(v, 5);w=rol(w, 30);
 
 #define __min__(a, b) (((a) < (b)) ? (a) : (b))
 
 std::string KeyGenerator::hexConvert(unsigned char* src, int srcLen)
 {
-    std::ostringstream ss;
+       std::ostringstream ss;
 
-    for (int i = 0; i <srcLen; i++) {
-        ss << std::hex << std::setfill('0') << std::setw(2);
-        ss << (src[i] & 0xffffffff);
-    }
+       for (int i = 0; i <srcLen; i++) {
+               ss << std::hex << std::setfill('0') << std::setw(2);
+               ss << (src[i] & 0xffffffff);
+       }
 
-    return ss.str();
+       return ss.str();
 }
 
 std::string KeyGenerator::generateKey(int len)
 {
-    int randomLen = 0;
-    unsigned char buf[len];
-    int randomDev;
+       int randomLen = 0;
+       unsigned char buf[len];
+       int randomDev;
 
-    while (((randomDev = ::open("/dev/urandom", O_RDONLY)) == -1) && (errno == EINTR));
+       while (((randomDev = ::open("/dev/urandom", O_RDONLY)) == -1) && (errno == EINTR));
 
-    if (randomDev == -1) {
-        throw runtime::Exception(runtime::GetSystemErrorMessage());
-    }
+       if (randomDev == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
 
-    while (randomLen < len) {
-        ssize_t result = ::read(randomDev, buf + randomLen, len - randomLen);
-        if (result == -1) {
-            if (errno != EINTR) {
-                throw runtime::Exception(runtime::GetSystemErrorMessage());
-            } else {
-                continue;
-            }
-        }
+       while (randomLen < len) {
+               ssize_t result = ::read(randomDev, buf + randomLen, len - randomLen);
+               if (result == -1) {
+                       if (errno != EINTR) {
+                               throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       } else {
+                               continue;
+                       }
+               }
 
-        randomLen += result;
-    }
+               randomLen += result;
+       }
 
-    std::string ret = hexConvert(buf, len);
+       std::string ret = hexConvert(buf, len);
 
-    while (::close(randomDev) == -1 && errno == EINTR);
+       while (::close(randomDev) == -1 && errno == EINTR);
 
-    return ret;
+       return ret;
 }
 
 std::string KeyGenerator::wrapKey(const std::string& decrypted, const std::string& salt, int len)
 {
-    unsigned char encrypted[len];
-    int ret;
-
-    ret = pbkdf2(decrypted.c_str(), decrypted.size(),
-                 (const unsigned char *)salt.c_str(), salt.size(),
-                 PBKDF2_ITERATION, len,
-                 encrypted);
-    if (ret < 0) {
-        throw runtime::Exception("Failed to wrap key");
-    }
-
-    return hexConvert(encrypted, len);
+       unsigned char encrypted[len];
+       int ret;
+
+       ret = pbkdf2(decrypted.c_str(), decrypted.size(),
+                                (const unsigned char *)salt.c_str(), salt.size(),
+                                PBKDF2_ITERATION, len,
+                                encrypted);
+       if (ret < 0) {
+               throw runtime::Exception("Failed to wrap key");
+       }
+
+       return hexConvert(encrypted, len);
 }
 
 void KeyGenerator::sha1Init(SHA1_CTX* context)
 {
-    /* SHA1 initialization constants */
-    context->state[0] = 0x67452301;
-    context->state[1] = 0xefcdab89;
-    context->state[2] = 0x98badcfe;
-    context->state[3] = 0x10325476;
-    context->state[4] = 0xc3d2e1f0;
-    context->count[0] = context->count[1] = 0;
+       /* SHA1 initialization constants */
+       context->state[0] = 0x67452301;
+       context->state[1] = 0xefcdab89;
+       context->state[2] = 0x98badcfe;
+       context->state[3] = 0x10325476;
+       context->state[4] = 0xc3d2e1f0;
+       context->count[0] = context->count[1] = 0;
 }
 
 void KeyGenerator::sha1Update(SHA1_CTX* context, const void* p, unsigned int len)
 {
-    const unsigned char* data = (unsigned char*)p;
-    unsigned int i, j;
-
-    j = (context->count[0] >> 3) & 63;
-    if ((context->count[0] += (len << 3)) < (len << 3)) {
-        context->count[1]++;
-    }
-    context->count[1] += (len >> 29);
-    if ((j + len) > 63) {
-        ::memcpy(&context->buffer[j], data, (i = 64 - j));
-        sha1Transform(context->state, context->buffer);
-        for (; i + 63 < len; i += 64) {
-            sha1Transform(context->state, data + i);
-        }
-        j = 0;
-    } else i = 0;
-
-    ::memcpy(&context->buffer[j], &data[i], len - i);
+       const unsigned char* data = (unsigned char*)p;
+       unsigned int i, j;
+
+       j = (context->count[0] >> 3) & 63;
+       if ((context->count[0] += (len << 3)) < (len << 3)) {
+               context->count[1]++;
+       }
+       context->count[1] += (len >> 29);
+       if ((j + len) > 63) {
+               ::memcpy(&context->buffer[j], data, (i = 64 - j));
+               sha1Transform(context->state, context->buffer);
+               for (; i + 63 < len; i += 64) {
+                       sha1Transform(context->state, data + i);
+               }
+               j = 0;
+       } else i = 0;
+
+       ::memcpy(&context->buffer[j], &data[i], len - i);
 }
 
 void KeyGenerator::sha1Final(unsigned char digest[SHA1_DIGEST_SIZE], SHA1_CTX* context)
 {
-    unsigned int i;
-    unsigned char finalcount[8];
-    for (i = 0; i < 8; i++) {
-        finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)]
-            >> ((3 - (i & 3)) * 8)) & 255);
-    }
-    sha1Update(context, (unsigned char*) "\200", 1);
-    while ((context->count[0] & 504) != 448) {
-        sha1Update(context, (unsigned char*) "\0", 1);
-    }
-    sha1Update(context, finalcount, 8);
-    /* Should cause SHA1_Transform */
-    for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
-        digest[i] = (unsigned char)
-            ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
-    }
-    /* Wipe variables */
-    i = 0;
-    ::memset(context->buffer, 0, 64);
-    ::memset(context->state, 0, 20);
-    ::memset(context->count, 0, 8);
-    ::memset(finalcount, 0, 8);    /* SWR */
+       unsigned int i;
+       unsigned char finalcount[8];
+       for (i = 0; i < 8; i++) {
+               finalcount[i] = (unsigned char) ((context->count[(i >= 4 ? 0 : 1)]
+                       >> ((3 - (i & 3)) * 8)) & 255);
+       }
+       sha1Update(context, (unsigned char*) "\200", 1);
+       while ((context->count[0] & 504) != 448) {
+               sha1Update(context, (unsigned char*) "\0", 1);
+       }
+       sha1Update(context, finalcount, 8);
+       /* Should cause SHA1_Transform */
+       for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
+               digest[i] = (unsigned char)
+                       ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
+       }
+       /* Wipe variables */
+       i = 0;
+       ::memset(context->buffer, 0, 64);
+       ::memset(context->state, 0, 20);
+       ::memset(context->count, 0, 8);
+       ::memset(finalcount, 0, 8);    /* SWR */
 
 #ifdef SHA1HANDSOFF    /* make SHA1Transform overwrite its own static vars */
-    transform(context->state, context->buffer);
+       transform(context->state, context->buffer);
 #endif
 }
 
 void KeyGenerator::sha1Transform(unsigned int state[5], const unsigned char buffer[64])
 {
-    uint32_t a, b, c, d, e;
-    typedef union {
-        unsigned char c[64];
-        unsigned int l[16];
-    } CHAR64LONG16;
-    CHAR64LONG16 *block;
+       uint32_t a, b, c, d, e;
+       typedef union {
+               unsigned char c[64];
+               unsigned int l[16];
+       } CHAR64LONG16;
+       CHAR64LONG16 *block;
 
 #ifdef SHA1HANDSOFF
-    CHAR64LONG16 workspace;
-    block = &workspace;
-    ::memcpy(block, buffer, 64);
+       CHAR64LONG16 workspace;
+       block = &workspace;
+       ::memcpy(block, buffer, 64);
 #else
-    block = (CHAR64LONG16*)buffer;
+       block = (CHAR64LONG16*)buffer;
 #endif
 
-    a = state[0];
-    b = state[1];
-    c = state[2];
-    d = state[3];
-    e = state[4];
-
-    /* 4 rounds of 20 operations each. Loop unrolled. */
-    R0(a, b, c, d, e, 0);    R0(e, a, b, c, d, 1);    R0(d, e, a, b, c, 2);    R0(c, d, e, a, b, 3);
-    R0(b, c, d, e, a, 4);    R0(a, b, c, d, e, 5);    R0(e, a, b, c, d, 6);    R0(d, e, a, b, c, 7);
-    R0(c, d, e, a, b, 8);    R0(b, c, d, e, a, 9);    R0(a, b, c, d, e, 10);    R0(e, a, b, c, d, 11);
-    R0(d, e, a, b, c, 12);    R0(c, d, e, a, b, 13);    R0(b, c, d, e, a, 14);    R0(a, b, c, d, e, 15);
-    R1(e, a, b, c, d, 16);    R1(d, e, a, b, c, 17);    R1(c, d, e, a, b, 18);    R1(b, c, d, e, a, 19);
-    R2(a, b, c, d, e, 20);    R2(e, a, b, c, d, 21);    R2(d, e, a, b, c, 22);    R2(c, d, e, a, b, 23);
-    R2(b, c, d, e, a, 24);    R2(a, b, c, d, e, 25);    R2(e, a, b, c, d, 26);    R2(d, e, a, b, c, 27);
-    R2(c, d, e, a, b, 28);    R2(b, c, d, e, a, 29);    R2(a, b, c, d, e, 30);    R2(e, a, b, c, d, 31);
-    R2(d, e, a, b, c, 32);    R2(c, d, e, a, b, 33);    R2(b, c, d, e, a, 34);    R2(a, b, c, d, e, 35);
-    R2(e, a, b, c, d, 36);    R2(d, e, a, b, c, 37);    R2(c, d, e, a, b, 38);    R2(b, c, d, e, a, 39);
-    R3(a, b, c, d, e, 40);    R3(e, a, b, c, d, 41);    R3(d, e, a, b, c, 42);    R3(c, d, e, a, b, 43);
-    R3(b, c, d, e, a, 44);    R3(a, b, c, d, e, 45);    R3(e, a, b, c, d, 46);    R3(d, e, a, b, c, 47);
-    R3(c, d, e, a, b, 48);    R3(b, c, d, e, a, 49);    R3(a, b, c, d, e, 50);    R3(e, a, b, c, d, 51);
-    R3(d, e, a, b, c, 52);    R3(c, d, e, a, b, 53);    R3(b, c, d, e, a, 54);    R3(a, b, c, d, e, 55);
-    R3(e, a, b, c, d, 56);    R3(d, e, a, b, c, 57);    R3(c, d, e, a, b, 58);    R3(b, c, d, e, a, 59);
-    R4(a, b, c, d, e, 60);    R4(e, a, b, c, d, 61);    R4(d, e, a, b, c, 62);    R4(c, d, e, a, b, 63);
-    R4(b, c, d, e, a, 64);    R4(a, b, c, d, e, 65);    R4(e, a, b, c, d, 66);    R4(d, e, a, b, c, 67);
-    R4(c, d, e, a, b, 68);    R4(b, c, d, e, a, 69);    R4(a, b, c, d, e, 70);    R4(e, a, b, c, d, 71);
-    R4(d, e, a, b, c, 72);    R4(c, d, e, a, b, 73);    R4(b, c, d, e, a, 74);    R4(a, b, c, d, e, 75);
-    R4(e, a, b, c, d, 76);    R4(d, e, a, b, c, 77);    R4(c, d, e, a, b, 78);    R4(b, c, d, e, a, 79);
-
-    /* Add the working vars back into context.state[] */
-    state[0] += a;
-    state[1] += b;
-    state[2] += c;
-    state[3] += d;
-    state[4] += e;
-
-    /* Wipe variables */
-    a = b = c = d = e = 0;
+       a = state[0];
+       b = state[1];
+       c = state[2];
+       d = state[3];
+       e = state[4];
+
+       /* 4 rounds of 20 operations each. Loop unrolled. */
+       R0(a, b, c, d, e, 0);    R0(e, a, b, c, d, 1);    R0(d, e, a, b, c, 2);    R0(c, d, e, a, b, 3);
+       R0(b, c, d, e, a, 4);    R0(a, b, c, d, e, 5);    R0(e, a, b, c, d, 6);    R0(d, e, a, b, c, 7);
+       R0(c, d, e, a, b, 8);    R0(b, c, d, e, a, 9);    R0(a, b, c, d, e, 10);    R0(e, a, b, c, d, 11);
+       R0(d, e, a, b, c, 12);    R0(c, d, e, a, b, 13);    R0(b, c, d, e, a, 14);    R0(a, b, c, d, e, 15);
+       R1(e, a, b, c, d, 16);    R1(d, e, a, b, c, 17);    R1(c, d, e, a, b, 18);    R1(b, c, d, e, a, 19);
+       R2(a, b, c, d, e, 20);    R2(e, a, b, c, d, 21);    R2(d, e, a, b, c, 22);    R2(c, d, e, a, b, 23);
+       R2(b, c, d, e, a, 24);    R2(a, b, c, d, e, 25);    R2(e, a, b, c, d, 26);    R2(d, e, a, b, c, 27);
+       R2(c, d, e, a, b, 28);    R2(b, c, d, e, a, 29);    R2(a, b, c, d, e, 30);    R2(e, a, b, c, d, 31);
+       R2(d, e, a, b, c, 32);    R2(c, d, e, a, b, 33);    R2(b, c, d, e, a, 34);    R2(a, b, c, d, e, 35);
+       R2(e, a, b, c, d, 36);    R2(d, e, a, b, c, 37);    R2(c, d, e, a, b, 38);    R2(b, c, d, e, a, 39);
+       R3(a, b, c, d, e, 40);    R3(e, a, b, c, d, 41);    R3(d, e, a, b, c, 42);    R3(c, d, e, a, b, 43);
+       R3(b, c, d, e, a, 44);    R3(a, b, c, d, e, 45);    R3(e, a, b, c, d, 46);    R3(d, e, a, b, c, 47);
+       R3(c, d, e, a, b, 48);    R3(b, c, d, e, a, 49);    R3(a, b, c, d, e, 50);    R3(e, a, b, c, d, 51);
+       R3(d, e, a, b, c, 52);    R3(c, d, e, a, b, 53);    R3(b, c, d, e, a, 54);    R3(a, b, c, d, e, 55);
+       R3(e, a, b, c, d, 56);    R3(d, e, a, b, c, 57);    R3(c, d, e, a, b, 58);    R3(b, c, d, e, a, 59);
+       R4(a, b, c, d, e, 60);    R4(e, a, b, c, d, 61);    R4(d, e, a, b, c, 62);    R4(c, d, e, a, b, 63);
+       R4(b, c, d, e, a, 64);    R4(a, b, c, d, e, 65);    R4(e, a, b, c, d, 66);    R4(d, e, a, b, c, 67);
+       R4(c, d, e, a, b, 68);    R4(b, c, d, e, a, 69);    R4(a, b, c, d, e, 70);    R4(e, a, b, c, d, 71);
+       R4(d, e, a, b, c, 72);    R4(c, d, e, a, b, 73);    R4(b, c, d, e, a, 74);    R4(a, b, c, d, e, 75);
+       R4(e, a, b, c, d, 76);    R4(d, e, a, b, c, 77);    R4(c, d, e, a, b, 78);    R4(b, c, d, e, a, 79);
+
+       /* Add the working vars back into context.state[] */
+       state[0] += a;
+       state[1] += b;
+       state[2] += c;
+       state[3] += d;
+       state[4] += e;
+
+       /* Wipe variables */
+       a = b = c = d = e = 0;
 }
 
 void KeyGenerator::sha1Hmac(const unsigned char* key, int keyLen, const unsigned char* data, int dataLen, unsigned char out[SHA1_DIGEST_SIZE])
 {
-    SHA1_CTX ctx;
-    unsigned char buf[SHA_BLOCKSIZE], outPad[SHA_BLOCKSIZE], inPad[SHA_BLOCKSIZE];
-    unsigned char tempKey[SHA1_DIGEST_SIZE];
-    int i;
-
-    ::memset(buf, 0, SHA_BLOCKSIZE);
-
-    if (keyLen > SHA_BLOCKSIZE) {
-        sha1Init(&ctx);
-        sha1Update(&ctx, key, keyLen);
-        sha1Final(tempKey, &ctx);
-        key = tempKey;
-        keyLen = SHA1_DIGEST_SIZE;
-    }
-
-    ::memcpy(buf, key, keyLen);
-    ::memset(inPad, 0, SHA_BLOCKSIZE);
-    ::memset(outPad, 0, SHA_BLOCKSIZE);
-
-    for (i = 0; i < SHA_BLOCKSIZE; i++) {
-        outPad[i] = buf[i] ^ 0x5c;
-        inPad[i]= buf[i] ^ 0x36;
-    }
-
-    sha1Init(&ctx);
-    sha1Update(&ctx, inPad, SHA_BLOCKSIZE);
-    sha1Update(&ctx, data, dataLen);
-    sha1Final(out, &ctx);
-
-    sha1Init(&ctx);
-    sha1Update(&ctx, outPad, SHA_BLOCKSIZE);
-    sha1Update(&ctx, out, SHA1_DIGEST_SIZE);
-    sha1Final(out, &ctx);
+       SHA1_CTX ctx;
+       unsigned char buf[SHA_BLOCKSIZE], outPad[SHA_BLOCKSIZE], inPad[SHA_BLOCKSIZE];
+       unsigned char tempKey[SHA1_DIGEST_SIZE];
+       int i;
+
+       ::memset(buf, 0, SHA_BLOCKSIZE);
+
+       if (keyLen > SHA_BLOCKSIZE) {
+               sha1Init(&ctx);
+               sha1Update(&ctx, key, keyLen);
+               sha1Final(tempKey, &ctx);
+               key = tempKey;
+               keyLen = SHA1_DIGEST_SIZE;
+       }
+
+       ::memcpy(buf, key, keyLen);
+       ::memset(inPad, 0, SHA_BLOCKSIZE);
+       ::memset(outPad, 0, SHA_BLOCKSIZE);
+
+       for (i = 0; i < SHA_BLOCKSIZE; i++) {
+               outPad[i] = buf[i] ^ 0x5c;
+               inPad[i]= buf[i] ^ 0x36;
+       }
+
+       sha1Init(&ctx);
+       sha1Update(&ctx, inPad, SHA_BLOCKSIZE);
+       sha1Update(&ctx, data, dataLen);
+       sha1Final(out, &ctx);
+
+       sha1Init(&ctx);
+       sha1Update(&ctx, outPad, SHA_BLOCKSIZE);
+       sha1Update(&ctx, out, SHA1_DIGEST_SIZE);
+       sha1Final(out, &ctx);
 }
 
 int KeyGenerator::pbkdf2(const char * pass, int passLen, const unsigned char* salt, int saltLen, int iter, int keyLen, unsigned char* out)
 {
-    unsigned char digtmp1[SHA1_DIGEST_SIZE], digtmp2[SHA1_DIGEST_SIZE], itmp[saltLen + 4];
-    int j, k;
-    int genKeyLen = 0, toWriteLen;
-    unsigned long i = 1;
-
-    if (passLen <= 0 || saltLen <= 0 || iter <= 0 || keyLen <= 0)
-        return -1;
-
-    ::memcpy(itmp, salt, saltLen);
-    while (genKeyLen < keyLen) {
-        itmp[saltLen + 0] = (unsigned char)((i >> 24) & 0xff);
-        itmp[saltLen + 1] = (unsigned char)((i >> 16) & 0xff);
-        itmp[saltLen + 2] = (unsigned char)((i >> 8) & 0xff);
-        itmp[saltLen + 3] = (unsigned char)(i & 0xff);
-
-        sha1Hmac((unsigned char*)pass, passLen, itmp, saltLen+4,  digtmp1);
-        ::memcpy(digtmp2, digtmp1, SHA1_DIGEST_SIZE);
-
-        for (j = 1; j < iter; j++) {
-            sha1Hmac((unsigned char*)pass, passLen, digtmp1, SHA1_DIGEST_SIZE,  digtmp1);
-            for (k = 0; k < SHA1_DIGEST_SIZE; k++) {
-                digtmp2[k] ^= digtmp1[k];
-            }
-        }
-        toWriteLen = __min__((keyLen - genKeyLen), SHA1_DIGEST_SIZE);
-        ::memcpy(out+genKeyLen, digtmp2, toWriteLen);
-        genKeyLen += toWriteLen;
-        ++i;
-    }
-
-    return 1;
+       unsigned char digtmp1[SHA1_DIGEST_SIZE], digtmp2[SHA1_DIGEST_SIZE], itmp[saltLen + 4];
+       int j, k;
+       int genKeyLen = 0, toWriteLen;
+       unsigned long i = 1;
+
+       if (passLen <= 0 || saltLen <= 0 || iter <= 0 || keyLen <= 0)
+               return -1;
+
+       ::memcpy(itmp, salt, saltLen);
+       while (genKeyLen < keyLen) {
+               itmp[saltLen + 0] = (unsigned char)((i >> 24) & 0xff);
+               itmp[saltLen + 1] = (unsigned char)((i >> 16) & 0xff);
+               itmp[saltLen + 2] = (unsigned char)((i >> 8) & 0xff);
+               itmp[saltLen + 3] = (unsigned char)(i & 0xff);
+
+               sha1Hmac((unsigned char*)pass, passLen, itmp, saltLen+4,  digtmp1);
+               ::memcpy(digtmp2, digtmp1, SHA1_DIGEST_SIZE);
+
+               for (j = 1; j < iter; j++) {
+                       sha1Hmac((unsigned char*)pass, passLen, digtmp1, SHA1_DIGEST_SIZE,  digtmp1);
+                       for (k = 0; k < SHA1_DIGEST_SIZE; k++) {
+                               digtmp2[k] ^= digtmp1[k];
+                       }
+               }
+               toWriteLen = __min__((keyLen - genKeyLen), SHA1_DIGEST_SIZE);
+               ::memcpy(out+genKeyLen, digtmp2, toWriteLen);
+               genKeyLen += toWriteLen;
+               ++i;
+       }
+
+       return 1;
 }
index cc64c3d..e0d9796 100755 (executable)
 #define SHA1_DIGEST_SIZE 20
 
 typedef struct {
-    unsigned int state[5];
-    unsigned int count[2];
-    unsigned char buffer[64];
+       unsigned int state[5];
+       unsigned int count[2];
+       unsigned char buffer[64];
 } SHA1_CTX;
 
 class KeyGenerator {
 public:
-    KeyGenerator() = delete;
-    KeyGenerator(const KeyGenerator&) = delete;
-    KeyGenerator(KeyGenerator&&) = delete;
+       KeyGenerator() = delete;
+       KeyGenerator(const KeyGenerator&) = delete;
+       KeyGenerator(KeyGenerator&&) = delete;
 
-    KeyGenerator& operator=(const KeyGenerator&) = delete;
-    KeyGenerator& operator=(KeyGenerator&&) = delete;
+       KeyGenerator& operator=(const KeyGenerator&) = delete;
+       KeyGenerator& operator=(KeyGenerator&&) = delete;
 
-    static std::string wrapKey(const std::string& decrypted, const std::string& salt, int len);
-    static std::string generateKey(int len);
-    static void generateToken(char* key, ecryptfs_payload** outToken);
+       static std::string wrapKey(const std::string& decrypted, const std::string& salt, int len);
+       static std::string generateKey(int len);
+       static void generateToken(char* key, ecryptfs_payload** outToken);
 
 private:
-    static void sha1Init(SHA1_CTX* context);
-    static void sha1Update(SHA1_CTX* context, const void* p, unsigned int len);
-    static void sha1Final(unsigned char digsest[SHA1_DIGEST_SIZE], SHA1_CTX* context);
-    static void sha1Transform(unsigned int state[5], const unsigned char buffer[64]);
-    static void sha1Hmac(const unsigned char* key, int keyLen, const unsigned char* data, int dataLen, unsigned char out[SHA1_DIGEST_SIZE]);
-
-    static int pbkdf2(const char* pass, int passLen, const unsigned char* salt, int saltLen, int iter, int keyLen, unsigned char* out);
-    static std::string hexConvert(unsigned char* src, int srcLen);
+       static void sha1Init(SHA1_CTX* context);
+       static void sha1Update(SHA1_CTX* context, const void* p, unsigned int len);
+       static void sha1Final(unsigned char digsest[SHA1_DIGEST_SIZE], SHA1_CTX* context);
+       static void sha1Transform(unsigned int state[5], const unsigned char buffer[64]);
+       static void sha1Hmac(const unsigned char* key, int keyLen, const unsigned char* data, int dataLen, unsigned char out[SHA1_DIGEST_SIZE]);
+
+       static int pbkdf2(const char* pass, int passLen, const unsigned char* salt, int saltLen, int iter, int keyLen, unsigned char* out);
+       static std::string hexConvert(unsigned char* src, int srcLen);
 };
 
 #endif //!__VOLUME_MANAGER_KEY_GENERATOR_H__
index 8d618b4..78b0d83 100755 (executable)
@@ -34,52 +34,52 @@ const std::string ckmcIdSeperator = ckmc_owner_id_separator;
 
 bool KeyManager::isKeyExist(const std::string& keyName)
 {
-    int ret;
-    ckmc_raw_buffer_s* keyData = NULL;
-    std::string ckmAlias = addAliasPrefix(keyName);
+       int ret;
+       ckmc_raw_buffer_s* keyData = NULL;
+       std::string ckmAlias = addAliasPrefix(keyName);
 
-    ret = ::ckmc_get_data(ckmAlias.c_str(), NULL, &keyData);
-    ::ckmc_buffer_free(keyData);
+       ret = ::ckmc_get_data(ckmAlias.c_str(), NULL, &keyData);
+       ::ckmc_buffer_free(keyData);
 
-    return (ret != CKMC_ERROR_DB_ALIAS_UNKNOWN);
+       return (ret != CKMC_ERROR_DB_ALIAS_UNKNOWN);
 }
 
 void KeyManager::addKey(const std::string& keyName, const std::string& data)
 {
-    int ret;
-    const std::string ckmAlias = addAliasPrefix(keyName);
-    ckmc_raw_buffer_s keyData;
-    ckmc_policy_s keyPolicy;
+       int ret;
+       const std::string ckmAlias = addAliasPrefix(keyName);
+       ckmc_raw_buffer_s keyData;
+       ckmc_policy_s keyPolicy;
 
-    keyData.data = (unsigned char*)data.c_str();
-    keyData.size = data.size();
+       keyData.data = (unsigned char*)data.c_str();
+       keyData.size = data.size();
 
-    keyPolicy.password = NULL;
-    keyPolicy.extractable = true;
+       keyPolicy.password = NULL;
+       keyPolicy.extractable = true;
 
-    ret = ::ckmc_save_data(ckmAlias.c_str(), keyData, keyPolicy);
-    if (ret != 0) {
-        throw runtime::Exception("Failed to add key data");
-    }
+       ret = ::ckmc_save_data(ckmAlias.c_str(), keyData, keyPolicy);
+       if (ret != 0) {
+               throw runtime::Exception("Failed to add key data");
+       }
 }
 
 std::string KeyManager::getKey(const std::string& keyName)
 {
-    int ret;
-    const std::string ckmAlias = addAliasPrefix(keyName);
-    ckmc_raw_buffer_s* keyData;
-    std::string result;
+       int ret;
+       const std::string ckmAlias = addAliasPrefix(keyName);
+       ckmc_raw_buffer_s* keyData;
+       std::string result;
 
-    ret = ::ckmc_get_data(ckmAlias.c_str(), NULL, &keyData);
-    if (ret != CKMC_ERROR_NONE) {
-        throw runtime::Exception("Failed to get key data");
-    }
+       ret = ::ckmc_get_data(ckmAlias.c_str(), NULL, &keyData);
+       if (ret != CKMC_ERROR_NONE) {
+               throw runtime::Exception("Failed to get key data");
+       }
 
-    result = std::string(reinterpret_cast<char*>(keyData->data), keyData->size);
+       result = std::string(reinterpret_cast<char*>(keyData->data), keyData->size);
 
-    ::ckmc_buffer_free(keyData);
+       ::ckmc_buffer_free(keyData);
 
-    return result;
+       return result;
 }
 
 void KeyManager::removeKey(const std::string& keyName)
index 2bdf74d..6baf4ca 100644 (file)
 
 class KeyManager {
 public:
-    KeyManager() = delete;
-    KeyManager(const KeyManager&) = delete;
-    KeyManager(KeyManager&&) = delete;
+       KeyManager() = delete;
+       KeyManager(const KeyManager&) = delete;
+       KeyManager(KeyManager&&) = delete;
 
-    KeyManager& operator=(const KeyManager&) = delete;
-    KeyManager& operator=(KeyManager&&) = delete;
+       KeyManager& operator=(const KeyManager&) = delete;
+       KeyManager& operator=(KeyManager&&) = delete;
 
-    static bool isKeyExist(const std::string& keyName);
-    static void addKey(const std::string& keyName, const std::string& data);
-    static std::string getKey(const std::string& keyName);
-    static void removeKey(const std::string& keyName);
+       static bool isKeyExist(const std::string& keyName);
+       static void addKey(const std::string& keyName, const std::string& data);
+       static std::string getKey(const std::string& keyName);
+       static void removeKey(const std::string& keyName);
 };
 
 #endif //!__ZONE_KEY_MANAGER_H__*/
index 9b76a95..0fab661 100755 (executable)
 
 int generateKey(const std::string& keyName)
 {
-    if (KeyManager::isKeyExist(keyName)) {
-        ERROR("Key already registered");
+       if (KeyManager::isKeyExist(keyName)) {
+               ERROR("Key already registered");
                return -1;
        }
 
-    try {
-       std::string pass = KeyGenerator::generateKey(ECRYPTFS_MAX_KEY_SIZE);
-       std::string salt = KeyGenerator::generateKey(ECRYPTFS_MAX_SALT_SIZE);
-       std::string wrappedKey = KeyGenerator::wrapKey(pass, salt, ECRYPTFS_MAX_KEY_SIZE);
+       try {
+               std::string pass = KeyGenerator::generateKey(ECRYPTFS_MAX_KEY_SIZE);
+               std::string salt = KeyGenerator::generateKey(ECRYPTFS_MAX_SALT_SIZE);
+               std::string wrappedKey = KeyGenerator::wrapKey(pass, salt, ECRYPTFS_MAX_KEY_SIZE);
 
-       KeyManager::addKey(keyName, wrappedKey);
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
+               KeyManager::addKey(keyName, wrappedKey);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
 
        return 0;
 }
 
 ecryptfs_payload* generateToken(char* key)
 {
-    struct ecryptfs_password* tokenKey;
+       struct ecryptfs_password* tokenKey;
 
-    unsigned char keyBuffer[ECRYPTFS_MAX_KEY_SIZE+1];
+       unsigned char keyBuffer[ECRYPTFS_MAX_KEY_SIZE+1];
 
-    ecryptfs_payload* authToken = (ecryptfs_payload *)::malloc(sizeof(ecryptfs_payload));
-    if (authToken == NULL) {
-        return NULL;
-    }
+       ecryptfs_payload* authToken = (ecryptfs_payload *)::malloc(sizeof(ecryptfs_payload));
+       if (authToken == NULL) {
+               return NULL;
+       }
 
-    ::memset(authToken, 0, sizeof(ecryptfs_payload));
-    ::strncpy((char*)keyBuffer, key, ECRYPTFS_MAX_KEY_SIZE);
-    keyBuffer[ECRYPTFS_MAX_KEY_SIZE] = '\0';
+       ::memset(authToken, 0, sizeof(ecryptfs_payload));
+       ::strncpy((char*)keyBuffer, key, ECRYPTFS_MAX_KEY_SIZE);
+       keyBuffer[ECRYPTFS_MAX_KEY_SIZE] = '\0';
 
-    tokenKey = &authToken->token.password;
+       tokenKey = &authToken->token.password;
 
-    authToken->version = ECRYPTFS_VERSION;
-    authToken->token_type = ECRYPTFS_PWD_PAYLOAD_TYPE;
-    tokenKey->session_key_encryption_key_bytes = ECRYPTFS_MAX_KEY_SIZE;
-    tokenKey->flags = ECRYPTFS_SESSION_KEY_ENCRYPTION_KEY_SET;
-    ::memcpy(tokenKey->session_key_encryption_key, keyBuffer, ECRYPTFS_MAX_KEY_SIZE);
-    ::memcpy(tokenKey->signature, keyBuffer, ECRYPTFS_MAX_SIG_HEX);
+       authToken->version = ECRYPTFS_VERSION;
+       authToken->token_type = ECRYPTFS_PWD_PAYLOAD_TYPE;
+       tokenKey->session_key_encryption_key_bytes = ECRYPTFS_MAX_KEY_SIZE;
+       tokenKey->flags = ECRYPTFS_SESSION_KEY_ENCRYPTION_KEY_SET;
+       ::memcpy(tokenKey->session_key_encryption_key, keyBuffer, ECRYPTFS_MAX_KEY_SIZE);
+       ::memcpy(tokenKey->signature, keyBuffer, ECRYPTFS_MAX_SIG_HEX);
 
-    return authToken;
+       return authToken;
 }
 
 int mountEcryptfs(const std::string& src, const std::string& keyName)
 {
-    int rc;
-    char ecryptfsOpts[1024];
-    ecryptfs_payload* authTok = NULL;
-
-    std::string key;
-    try {
-        key = KeyManager::getKey(keyName);
-    } catch (runtime::Exception& e) {
-        ERROR(e.what());
-        return -1;
-    }
-
-    if (KernelKeyRing::link(KEY_SPEC_USER_KEYRING, KEY_SPEC_SESSION_KEYRING) != 0) {
-        ERROR("Failed to link key");
-        return -1;
-    }
-
-    if ((authTok = generateToken((char*)key.c_str())) == NULL) {
-        ERROR("Failed to generate Token");
-        return -1;
-    }
-
-    const char* signature = (const char*)authTok->token.password.signature;
-    rc = KernelKeyRing::search(KEY_SPEC_USER_KEYRING,
-                               "user",
-                               signature,
-                               0);
-    if (rc == -1 && errno != ENOKEY) {
-        ERROR("Failed to find key");
-        return -1;
-    }
-    if (rc == -1) {
-        rc = KernelKeyRing::add("user",
-                                signature,
-                                (void*)authTok,
-                                sizeof(ecryptfs_payload),
-                                KEY_SPEC_USER_KEYRING);
-        if (rc == -1) {
-            ERROR("Failed to add key");
-            return -1;
-        }
-    }
-
-    ::snprintf(ecryptfsOpts, 1024,
-               "ecryptfs_passthrough,"
-               "ecryptfs_cipher=aes,"
-               "ecryptfs_key_bytes=%d,"
-               "ecryptfs_sig=%s,"
-               "smackfsroot=*,smackfsdef=*",
-               ECRYPTFS_MAX_KEY_SIZE, signature);
-
-    rc = ::mount(src.c_str(), src.c_str(), "ecryptfs", MS_NODEV, ecryptfsOpts);
-    if (rc != 0) {
-        ERROR(runtime::GetSystemErrorMessage());
-        return -1;
-    }
-
-    return 0;
+       int rc;
+       char ecryptfsOpts[1024];
+       ecryptfs_payload* authTok = NULL;
+
+       std::string key;
+       try {
+               key = KeyManager::getKey(keyName);
+       } catch (runtime::Exception& e) {
+               ERROR(e.what());
+               return -1;
+       }
+
+       if (KernelKeyRing::link(KEY_SPEC_USER_KEYRING, KEY_SPEC_SESSION_KEYRING) != 0) {
+               ERROR("Failed to link key");
+               return -1;
+       }
+
+       if ((authTok = generateToken((char*)key.c_str())) == NULL) {
+               ERROR("Failed to generate Token");
+               return -1;
+       }
+
+       const char* signature = (const char*)authTok->token.password.signature;
+       rc = KernelKeyRing::search(KEY_SPEC_USER_KEYRING,
+                                                          "user",
+                                                          signature,
+                                                          0);
+       if (rc == -1 && errno != ENOKEY) {
+               ERROR("Failed to find key");
+               return -1;
+       }
+       if (rc == -1) {
+               rc = KernelKeyRing::add("user",
+                                                               signature,
+                                                               (void*)authTok,
+                                                               sizeof(ecryptfs_payload),
+                                                               KEY_SPEC_USER_KEYRING);
+               if (rc == -1) {
+                       ERROR("Failed to add key");
+                       return -1;
+               }
+       }
+
+       ::snprintf(ecryptfsOpts, 1024,
+                          "ecryptfs_passthrough,"
+                          "ecryptfs_cipher=aes,"
+                          "ecryptfs_key_bytes=%d,"
+                          "ecryptfs_sig=%s,"
+                          "smackfsroot=*,smackfsdef=*",
+                          ECRYPTFS_MAX_KEY_SIZE, signature);
+
+       rc = ::mount(src.c_str(), src.c_str(), "ecryptfs", MS_NODEV, ecryptfsOpts);
+       if (rc != 0) {
+               ERROR(runtime::GetSystemErrorMessage());
+               return -1;
+       }
+
+       return 0;
 }
 
 int mountEcryptfsToAll()
 {
-    return 0;
+       return 0;
 }
 
 void usage(const std::string& prog)
 {
-    std::cout << "Usage: " << prog << std::endl
-              << "-a            : Automount" << std::endl
-              << "-g name       : Generate key for zone" << std::endl
-              << "-m name       : Apply filesystem encrytion to zone" << std::endl;
+       std::cout << "Usage: " << prog << std::endl
+                         << "-a            : Automount" << std::endl
+                         << "-g name       : Generate key for zone" << std::endl
+                         << "-m name       : Apply filesystem encrytion to zone" << std::endl;
 }
 
 int main(int argc, char* argv[])
 {
-    int opt, index, ret = -1;
-    struct option options[] = {
-        {"automount", no_argument, 0, 'a'},
-        {"generate", required_argument, 0, 'g'},
-        {"mount", required_argument, 0, 'm'},
-        {0, 0, 0, 0}
-    };
-
-    while ((opt = getopt_long(argc, argv, "ag:m:", options, &index)) != -1) {
-        switch (opt) {
-        case 'a':
-            ret = mountEcryptfsToAll();
-            break;
-        case 'g':
-            ret = generateKey(optarg);
-            break;
-        case 'm':
-            ret = mountEcryptfs("/home/" + std::string(optarg), optarg);
-            break;
-        default:
-            std::cerr << "unknown" << std::endl;
-            usage(argv[0]);
-            break;
-        }
-    }
-
-    if (ret != 0) {
-        return EXIT_FAILURE;
-    }
-
-    return EXIT_SUCCESS;
+       int opt, index, ret = -1;
+       struct option options[] = {
+               {"automount", no_argument, 0, 'a'},
+               {"generate", required_argument, 0, 'g'},
+               {"mount", required_argument, 0, 'm'},
+               {0, 0, 0, 0}
+       };
+
+       while ((opt = getopt_long(argc, argv, "ag:m:", options, &index)) != -1) {
+               switch (opt) {
+               case 'a':
+                       ret = mountEcryptfsToAll();
+                       break;
+               case 'g':
+                       ret = generateKey(optarg);
+                       break;
+               case 'm':
+                       ret = mountEcryptfs("/home/" + std::string(optarg), optarg);
+                       break;
+               default:
+                       std::cerr << "unknown" << std::endl;
+                       usage(argv[0]);
+                       break;
+               }
+       }
+
+       if (ret != 0) {
+               return EXIT_FAILURE;
+       }
+
+       return EXIT_SUCCESS;
 }