%define tizen_feature_se_support 1
%define tizen_feature_sensor_support 0
%define tizen_feature_sound_support 0
-%define tizen_feature_system_setting_support 0
+%define tizen_feature_system_setting_support 1
%define tizen_feature_telephony_support 0
%define tizen_feature_web_setting_support 0
%define tizen_feature_wi_fi_support 0
BuildRequires: pkgconfig(appcore-common)
BuildRequires: pkgconfig(capi-system-device)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-system-system-settings)
BuildRequires: pkgconfig(libpcrecpp)
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(dbus-glib-1)
--- /dev/null
+{
+ 'includes':[
+ '../common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_systemsetting',
+ 'type': 'loadable_module',
+ 'sources': [
+ 'systemsetting_api.js',
+ 'systemsetting_extension.cc',
+ 'systemsetting_extension.h',
+ 'systemsetting_instance.cc',
+ 'systemsetting_instance.h',
+ ],
+ 'conditions': [
+ ['tizen == 1', {
+ 'variables': {
+ 'packages': [
+ 'capi-system-system-settings',
+ 'vconf',
+ ]
+ },
+ }],
+ ],
+ },
+ ],
+}
--- /dev/null
+/* global xwalk, extension, tizen */
+
+// Copyright 2014 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.
+
+
+var validator_ = xwalk.utils.validator;
+var type_ = xwalk.utils.type;
+var types_ = validator_.Types;
+var native_ = new xwalk.utils.NativeManager(extension);
+
+function throwException_(err) {
+ throw new tizen.WebAPIException(err.code, err.name, err.message);
+}
+
+function callSync_(msg) {
+ var ret = extension.internal.sendSyncMessage(JSON.stringify(msg));
+ var obj = JSON.parse(ret);
+ if (obj.error)
+ throwException_(obj.error);
+ return obj.result;
+}
+
+var SystemSettingType = {
+ HOME_SCREEN : 'HOME_SCREEN',
+ LOCK_SCREEN : 'LOCK_SCREEN',
+ INCOMING_CALL : 'INCOMING_CALL',
+ NOTIFICATION_EMAIL : 'NOTIFICATION_EMAIL'
+};
+
+function SystemSettingManager() {
+}
+
+SystemSettingManager.prototype.getProperty = function() {
+ var args = validator_.validateArgs(arguments, [
+ {name: 'type', type: types_.STRING},
+ {name: 'successCallback', type: types_.FUNCTION},
+ {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
+ ]);
+
+ if (!SystemSettingType.hasOwnProperty(args.type))
+ throw new tizen.WebAPIException(0, 'Invalid setting type', 'InvalidValuesError');
+
+ var callback = function(result) {
+ if (result.status === 'error') {
+ if (!type_.isNullOrUndefined(args.errorCallback)) {
+ args.errorCallback(result.error);
+ }
+ }
+ else {
+ args.successCallback(result.result.value);
+ }
+ }
+
+ var callArgs = {
+ type: args.type
+ };
+
+ native_.call('SystemSettingManager_getProperty', callArgs, callback);
+};
+
+// Exports
+exports = new SystemSettingManager();
+
--- /dev/null
+// Copyright 2014 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 "systemsetting/systemsetting_extension.h"
+
+#include "systemsetting/systemsetting_instance.h"
+
+// This will be generated from systemsetting_api.js
+extern const char kSource_systemsetting_api[];
+
+common::Extension* CreateExtension() {
+ return new SystemSettingExtension;
+}
+
+SystemSettingExtension::SystemSettingExtension() {
+ SetExtensionName("tizen.systemsetting");
+ SetJavaScriptAPI(kSource_systemsetting_api);
+}
+
+SystemSettingExtension::~SystemSettingExtension() {}
+
+common::Instance* SystemSettingExtension::CreateInstance() {
+ return new extension::systemsetting::SystemSettingInstance;
+}
--- /dev/null
+// Copyright 2014 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 SYSTEMSETTING_SYSTEMSETTING_EXTENSION_H_
+#define SYSTEMSETTING_SYSTEMSETTING_EXTENSION_H_
+
+#include "common/extension.h"
+
+class SystemSettingExtension : public common::Extension {
+ public:
+ SystemSettingExtension();
+ virtual ~SystemSettingExtension();
+
+ private:
+ virtual common::Instance* CreateInstance();
+};
+
+#endif // SYSTEMSETTING_SYSTEMSETTING_EXTENSION_H_
+
--- /dev/null
+// Copyright 2014 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 "systemsetting/systemsetting_instance.h"
+
+#include <memory>
+
+#include "common/picojson.h"
+#include "common/logger.h"
+#include "common/platform_exception.h"
+#include "common/task-queue.h"
+
+#include <system_settings.h>
+
+
+namespace extension {
+namespace systemsetting {
+
+namespace {
+const std::string SETTING_HOME_SCREEN = "HOME_SCREEN";
+const std::string SETTING_LOCK_SCREEN = "LOCK_SCREEN";
+const std::string SETTING_INCOMING_CALL = "INCOMING_CALL";
+const std::string SETTING_NOTIFICATION_EMAIL = "NOTIFICATION_EMAIL";
+}
+
+using namespace common;
+using namespace extension::systemsetting;
+
+SystemSettingInstance::SystemSettingInstance()
+{
+ using namespace std::placeholders;
+
+#define REGISTER(c,x) \
+RegisterHandler(c, std::bind(&SystemSettingInstance::x, this, _1, _2));
+
+ REGISTER("SystemSettingManager_getProperty", getProperty);
+
+#undef REGISTER
+}
+
+SystemSettingInstance::~SystemSettingInstance()
+{
+}
+
+void SystemSettingInstance::getProperty(const picojson::value& args, picojson::object& out)
+{
+ LoggerD("");
+ const double callback_id = args.get("callbackId").get<double>();
+
+ const std::string& type = args.get("type").get<std::string>();
+ LoggerD("Getting property type: %s ", type.c_str());
+
+ auto get = [this, type](const std::shared_ptr<picojson::value>& response) -> void {
+ LoggerD("Getting platform value");
+ try {
+ int platformResult;
+ picojson::value result = getPlatformPropertyValue(type, platformResult);
+ ReportSuccess(result, response->get<picojson::object>());
+ } catch (const PlatformException& e) {
+ ReportError(e, response->get<picojson::object>());
+ }
+ };
+
+ auto get_response = [this, callback_id](const std::shared_ptr<picojson::value>& response) -> void {
+ LoggerD("Getting response");
+ picojson::object& obj = response->get<picojson::object>();
+ obj.insert(std::make_pair("callbackId", callback_id));
+ PostMessage(response->serialize().c_str());
+ };
+
+ TaskQueue::GetInstance().Queue<picojson::value>
+ (get, get_response, std::shared_ptr<picojson::value>(new picojson::value(picojson::object())));
+}
+
+picojson::value SystemSettingInstance::getPlatformPropertyValue(
+ const std::string &valueType, int &platformResult)
+{
+ int ret;
+ char *value = NULL;
+ picojson::value result = picojson::value(picojson::object());
+ picojson::object& result_obj = result.get<picojson::object>();
+
+ if (valueType == SETTING_HOME_SCREEN) {
+ ret = system_settings_get_value_string(
+ SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &value);
+ }
+ else if (valueType == SETTING_LOCK_SCREEN) {
+ ret = system_settings_get_value_string(
+ SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value);
+ }
+ else if (valueType == SETTING_INCOMING_CALL) {
+ ret = system_settings_get_value_string(
+ SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &value);
+ }
+ else if (valueType == SETTING_NOTIFICATION_EMAIL) {
+ ret = system_settings_get_value_string(
+ SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, &value);
+ }
+ // other values (not specified in the documentation) are handled in JS
+
+ platformResult = ret;
+
+ if (ret == SYSTEM_SETTINGS_ERROR_NONE) {
+ LoggerD("ret == SYSTEM_SETTINGS_ERROR_NONE");
+ result_obj.insert(std::make_pair("value", value));
+ free(value);
+ }
+ else if (ret == SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API) {
+ LoggerD("ret == SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API");
+ throw NotSupportedException("This property is not supported.");
+ }
+ else {
+ LoggerD("Other error");
+ throw UnknownException("Unknown error");
+ }
+
+ return result;
+}
+
+
+} // namespace systemsetting
+} // namespace extension
+
--- /dev/null
+// Copyright 2014 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 SYSTEMSETTING_SYSTEMSETTING_INSTANCE_H_
+#define SYSTEMSETTING_SYSTEMSETTING_INSTANCE_H_
+
+#include "common/extension.h"
+
+namespace extension {
+namespace systemsetting {
+
+class SystemSettingInstance : public common::ParsedInstance
+{
+public:
+ SystemSettingInstance();
+ virtual ~SystemSettingInstance();
+
+private:
+
+ void getProperty(const picojson::value& args, picojson::object& out);
+ picojson::value getPlatformPropertyValue(const std::string &valueType, int &platformResult);
+};
+
+} // namespace systemsetting
+} // namespace extension
+
+#endif // SYSTEMSETTING_SYSTEMSETTING_INSTANCE_H_
'archive/archive.gyp:*',
'exif/exif.gyp:*',
'websetting/websetting.gyp:*',
+ 'systemsetting/systemsetting.gyp:*',
],
'conditions': [
[