[Common] Added CHECK_PRIVILEGE macro. 25/70125/1
authorTomasz Marciniak <t.marciniak@samsung.com>
Wed, 18 May 2016 07:21:11 +0000 (09:21 +0200)
committerTomasz Marciniak <t.marciniak@samsung.com>
Wed, 18 May 2016 07:21:11 +0000 (09:21 +0200)
[Feature] This macro is used by new modules which
return TizenPlatform object to JS layer.

[Verification] Code compiles.

Change-Id: Id471face94ea52896092221f3ad03052d18007ac
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/common/tools.h

index c3df3a98405bf39e06f876bf8b27ff5402dccd3f..f48e4fa10bd6e56af73b45de5e33f696750c01be 100644 (file)
@@ -37,6 +37,15 @@ common::PlatformResult CheckAccess(const std::string& privilege);
 common::PlatformResult CheckAccess(const std::vector<std::string>& privileges);
 common::PlatformResult GetPkgApiVersion(std::string* api_version);
 
+//it is used for modules which return TizenResult objects to JS layer
+#define CHECK_PRIVILEGE(privilege) \
+do { \
+  auto r = common::tools::CheckAccess(privilege); \
+  if (!r) { \
+    return common::SecurityError("Application does not have privilege to call this method"); \
+  } \
+} while (0)
+
 #define CHECK_PRIVILEGE_ACCESS(privilege, out) \
 do { \
   auto r = common::tools::CheckAccess(privilege); \