'utils_api.js',
'utils_extension.cc',
'utils_extension.h',
+ 'utils_instance.cc',
+ 'utils_instance.h',
],
},
],
return true;
};
+Utils.prototype.checkPrivilegeAccess = function(privilege) {
+ var result = native_.callSync('Utils_checkPrivilegeAccess', {
+ privilege : _toString(privilege),
+ });
+ if (native_.isFailure(result)) {
+ throw native_.getErrorObject(result);
+ }
+};
/////////////////////////////////////////////////////////////////////////////
/** @constructor */
Utils.prototype.NativeManager = NativeManager;
Utils.prototype.NativeBridge = NativeBridge;
+var native_ = new NativeManager(extension);
+
exports = new Utils();
// found in the LICENSE file.
#include "utils/utils_extension.h"
+#include "utils/utils_instance.h"
// This will be generated from tizen_api.js.
extern const char kSource_utils_api[];
}
UtilsExtension::~UtilsExtension() {}
+
+common::Instance* UtilsExtension::CreateInstance() {
+ return new extension::utils::UtilsInstance();
+}
public:
UtilsExtension();
virtual ~UtilsExtension();
+
+ private:
+ virtual common::Instance* CreateInstance();
};
#endif // UTILS_UTILS_EXTENSION_H_
--- /dev/null
+// Copyright (c) 2013 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "utils/utils_instance.h"
+
+namespace extension {
+namespace utils {
+
+UtilsInstance::UtilsInstance() {
+ using std::placeholders::_1;
+ using std::placeholders::_2;
+
+#define REGISTER_SYNC(c, x) \
+ RegisterSyncHandler(c, std::bind(&UtilsInstance::x, this, _1, _2));
+#define REGISTER_ASYNC(c, x) \
+ RegisterSyncHandler(c, std::bind(&UtilsInstance::x, this, _1, _2));
+
+ REGISTER_SYNC("Utils_checkPrivilegeAccess", CheckPrivilegeAccess);
+
+#undef REGISTER_SYNC
+#undef REGISTER_ASYNC
+}
+
+void UtilsInstance::CheckPrivilegeAccess(const picojson::value& args, picojson::object& out) {
+ const auto& privilege = args.get("privilege").to_str();
+ CHECK_PRIVILEGE_ACCESS(privilege, &out);
+ ReportSuccess(out);
+}
+
+} // namespace utils
+} // namespace extension
--- /dev/null
+// Copyright (c) 2013 Intel Corporation. All rights reserved.
+// Copyright (c) 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UTILS_UTILS_INSTANCE_H_
+#define UTILS_UTILS_INSTANCE_H_
+
+#include "common/extension.h"
+
+namespace extension {
+namespace utils {
+
+class UtilsInstance : public common::ParsedInstance {
+ public:
+ UtilsInstance();
+ virtual ~UtilsInstance() {}
+
+ private:
+ void CheckPrivilegeAccess(const picojson::value& args, picojson::object& out);
+};
+} // namespace utils
+} // namespace extension
+
+#endif // UTILS_UTILS_INSTANCE_H_