--- /dev/null
+{
+ 'includes':[
+ '../common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_sound',
+ 'type': 'loadable_module',
+ 'variables': {
+ 'packages': [
+ 'icu-i18n',
+ ],
+ },
+ 'sources': [
+ 'sound_api.js',
+ 'sound_extension.cc',
+ 'sound_extension.h',
+ 'sound_instance.cc',
+ 'sound_instance.h',
+ ],
+ 'conditions': [
+ [ 'tizen == 1', {
+ 'variables': { 'packages': ['vconf'] },
+ }],
+ ],
+ },
+ ],
+}
--- /dev/null
+// Copyright 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.
+
+
+var utils_ = xwalk.utils;
+var type_ = utils_.type;
+var converter_ = utils_.converter;
+var validator_ = utils_.validator;
+var types_ = validator_.Types;
+var native_ = new xwalk.utils.NativeManager(extension);
+
+
+var SoundType = {
+ SYSTEM: 'SYSTEM',
+ NOTIFICATION: 'NOTIFICATION',
+ ALARM: 'ALARM',
+ MEDIA: 'MEDIA',
+ VOICE: 'VOICE',
+ RINGTONE: 'RINGTONE'
+};
+
+var SoundModeType = {
+ SOUND: 'SOUND',
+ VIBRATE: 'VIBRATE',
+ MUTE: 'MUTE'
+};
+
+
+function SoundManager() {}
+
+SoundManager.prototype.getSoundMode = function() {
+ var result = native_.callSync('SoundManager_getSoundMode');
+ if (native_.isFailure(result)) {
+ throw native_.getErrorObject(result);
+ }
+
+ return native_.getResultObject(result);
+};
+
+SoundManager.prototype.setVolume = function(type, volume) {
+ var args = validator_.validateArgs(arguments, [
+ {name: 'type', type: types_.ENUM, values: Object.keys(SoundType)},
+ {name: 'volume', type: types_.DOUBLE}
+ ]);
+
+ var result = native_.callSync('SoundManager_setVolume', args);
+ if (native_.isFailure(result)) {
+ throw native_.getErrorObject(result);
+ }
+
+ return native_.getResultObject(result);
+};
+
+SoundManager.prototype.getVolume = function(type) {
+ var args = validator_.validateArgs(arguments, [
+ {name: 'type', type: types_.ENUM, values: Object.keys(SoundType)}
+ ]);
+
+ var result = native_.callSync('SoundManager_getVolume', args);
+ if (native_.isFailure(result)) {
+ throw native_.getErrorObject(result);
+ }
+
+ return native_.getResultObject(result);
+};
+
+SoundManager.prototype.setSoundModeChangeListener = function(callback) {
+ var args = validator_.validateArgs(arguments, [
+ {name: 'callback', type: types_.FUNCTION}
+ ]);
+
+ var callback = function(result) {
+ if (native_.isFailure(result)) {
+ native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
+ return;
+ }
+
+ var _result = native_.getResultObject(result);
+
+ native_.callIfPossible(args.successCallback);
+ };
+
+ native_.call('SoundManager_setSoundModeChangeListener', args, callback);
+};
+
+SoundManager.prototype.unsetSoundModeChangeListener = function() {
+ var result = native_.callSync('SoundManager_unsetSoundModeChangeListener');
+ if (native_.isFailure(result)) {
+ throw native_.getErrorObject(result);
+ }
+
+ return native_.getResultObject(result);
+};
+
+SoundManager.prototype.setVolumeChangeListener = function(callback) {
+ var args = validator_.validateArgs(arguments, [
+ {name: 'callback', type: types_.FUNCTION}
+ ]);
+
+ var callback = function(result) {
+ if (native_.isFailure(result)) {
+ native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
+ return;
+ }
+
+ var _result = native_.getResultObject(result);
+
+ native_.callIfPossible(args.successCallback);
+ };
+
+ native_.call('SoundManager_setVolumeChangeListener', args, callback);
+};
+
+SoundManager.prototype.unsetVolumeChangeListener = function() {
+ var result = native_.callSync('SoundManager_unsetVolumeChangeListener');
+ if (native_.isFailure(result)) {
+ throw native_.getErrorObject(result);
+ }
+
+ return native_.getResultObject(result);
+};
+
+
+exports = new SoundManager();
--- /dev/null
+// Copyright 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 "sound/sound_extension.h"
+
+#include "sound/sound_instance.h"
+
+// This will be generated from sound_api.js
+extern const char kSource_sound_api[];
+
+common::Extension* CreateExtension() {
+ return new SoundExtension;
+}
+
+SoundExtension::SoundExtension() {
+ SetExtensionName("tizen.sound");
+ SetJavaScriptAPI(kSource_sound_api);
+}
+
+SoundExtension::~SoundExtension() {}
+
+common::Instance* SoundExtension::CreateInstance() {
+ return new extension::sound::SoundInstance;
+}
\ No newline at end of file
--- /dev/null
+// Copyright 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 SOUND_SOUND_EXTENSION_H_
+#define SOUND_SOUND_EXTENSION_H_
+
+#include "common/extension.h"
+
+class SoundExtension : public common::Extension {
+ public:
+ SoundExtension();
+ virtual ~SoundExtension();
+
+ private:
+ virtual common::Instance* CreateInstance();
+};
+
+#endif // SOUND_SOUND_EXTENSION_H_
--- /dev/null
+// Copyright 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 "sound/sound_instance.h"
+
+#include <functional>
+
+#include "common/picojson.h"
+#include "common/logger.h"
+#include "common/platform_exception.h"
+
+namespace extension {
+namespace sound {
+
+namespace {
+// The privileges that required in Sound API
+const std::string kPrivilegeSound = "";
+
+} // namespace
+
+using namespace common;
+using namespace extension::sound;
+
+SoundInstance::SoundInstance() {
+ using namespace std::placeholders;
+ #define REGISTER_SYNC(c,x) \
+ RegisterSyncHandler(c, std::bind(&SoundInstance::x, this, _1, _2));
+ REGISTER_SYNC("SoundManager_setVolume", SoundManagerSetVolume);
+ REGISTER_SYNC("SoundManager_unsetSoundModeChangeListener", SoundManagerUnsetSoundModeChangeListener);
+ REGISTER_SYNC("SoundManager_getVolume", SoundManagerGetVolume);
+ REGISTER_SYNC("SoundManager_unsetVolumeChangeListener", SoundManagerUnsetVolumeChangeListener);
+ REGISTER_SYNC("SoundManager_setSoundModeChangeListener", SoundManagerSetSoundModeChangeListener);
+ REGISTER_SYNC("SoundManager_setVolumeChangeListener", SoundManagerSetVolumeChangeListener);
+ REGISTER_SYNC("SoundManager_getSoundMode", SoundManagerGetSoundMode);
+ #undef REGISTER_SYNC
+}
+
+SoundInstance::~SoundInstance() {
+}
+
+
+
+#define CHECK_EXIST(args, name, out) \
+ if (!args.contains(name)) {\
+ ReportError(TypeMismatchException(name" is required argument"), out);\
+ return;\
+ }
+
+
+void SoundInstance::SoundManagerGetSoundMode(const picojson::value& args, picojson::object& out) {
+
+
+ // implement it
+
+
+ // if success
+ // ReportSuccess(out);
+ // if error
+ // ReportError(out);
+}
+void SoundInstance::SoundManagerSetVolume(const picojson::value& args, picojson::object& out) {
+ CHECK_EXIST(args, "volume", out)
+
+ double volume = args.get("volume").get<double>();
+
+ // implement it
+
+
+ // if success
+ // ReportSuccess(out);
+ // if error
+ // ReportError(out);
+}
+void SoundInstance::SoundManagerGetVolume(const picojson::value& args, picojson::object& out) {
+
+
+ // implement it
+
+
+ // if success
+ // ReportSuccess(out);
+ // if error
+ // ReportError(out);
+}
+void SoundInstance::SoundManagerSetSoundModeChangeListener(const picojson::value& args, picojson::object& out) {
+ CHECK_EXIST(args, "callbackId", out)
+
+ int callbackId = static_cast<int>(args.get("callbackId").get<double>());
+
+ // implement it
+
+ // call ReplyAsync in later (Asynchronously)
+
+ // if success
+ // ReportSuccess(out);
+ // if error
+ // ReportError(out);
+}
+void SoundInstance::SoundManagerUnsetSoundModeChangeListener(const picojson::value& args, picojson::object& out) {
+
+
+ // implement it
+
+
+ // if success
+ // ReportSuccess(out);
+ // if error
+ // ReportError(out);
+}
+void SoundInstance::SoundManagerSetVolumeChangeListener(const picojson::value& args, picojson::object& out) {
+ CHECK_EXIST(args, "callbackId", out)
+
+ int callbackId = static_cast<int>(args.get("callbackId").get<double>());
+
+ // implement it
+
+ // call ReplyAsync in later (Asynchronously)
+
+ // if success
+ // ReportSuccess(out);
+ // if error
+ // ReportError(out);
+}
+void SoundInstance::SoundManagerUnsetVolumeChangeListener(const picojson::value& args, picojson::object& out) {
+
+
+ // implement it
+
+
+ // if success
+ // ReportSuccess(out);
+ // if error
+ // ReportError(out);
+}
+
+
+#undef CHECK_EXIST
+
+} // namespace sound
+} // namespace extension
\ No newline at end of file
--- /dev/null
+// Copyright 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 SOUND_SOUND_INSTANCE_H_
+#define SOUND_SOUND_INSTANCE_H_
+
+#include "common/extension.h"
+
+namespace extension {
+namespace sound {
+
+class SoundInstance : public common::ParsedInstance {
+ public:
+ SoundInstance();
+ virtual ~SoundInstance();
+
+ private:
+ void SoundManagerSetVolume(const picojson::value& args, picojson::object& out);
+ void SoundManagerUnsetSoundModeChangeListener(const picojson::value& args, picojson::object& out);
+ void SoundManagerGetVolume(const picojson::value& args, picojson::object& out);
+ void SoundManagerUnsetVolumeChangeListener(const picojson::value& args, picojson::object& out);
+ void SoundManagerSetSoundModeChangeListener(const picojson::value& args, picojson::object& out);
+ void SoundManagerSetVolumeChangeListener(const picojson::value& args, picojson::object& out);
+ void SoundManagerGetSoundMode(const picojson::value& args, picojson::object& out);
+};
+
+} // namespace sound
+} // namespace extension
+
+#endif // SOUND_SOUND_INSTANCE_H_
\ No newline at end of file
'systeminfo/systeminfo.gyp:*',
#'radio/radio.gyp:*',
'secureelement/secureelement.gyp:*',
+ 'sound/sound.gyp:*',
'notification/notification.gyp:*',
],
},