%if "%{?profile}" == "mobile"
%define tizen_feature_account_support 1
+%define tizen_feature_alarm_support 1
%define tizen_feature_application_support 1
%define tizen_feature_archive_support 1
%define tizen_feature_badge_support 1
%if "%{?profile}" == "wearable"
%define tizen_feature_account_support 0
+%define tizen_feature_alarm_support 0
%define tizen_feature_application_support 0
%define tizen_feature_archive_support 0
%define tizen_feature_badge_support 0
%if "%{?profile}" == "tv"
%define tizen_feature_account_support 0
+%define tizen_feature_alarm_support 0
%define tizen_feature_application_support 1
%define tizen_feature_archive_support 1
%define tizen_feature_badge_support 0
BuildRequires: pkgconfig(accounts-svc)
%endif
+%if 0%{?tizen_feature_alarm_support}
+BuildRequires: pkgconfig(capi-appfw-alarm)
+%endif
+
%if 0%{?tizen_feature_application_support}
BuildRequires: pkgconfig(wrt-plugins-ipc-message)
%endif
# feature flags
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_account_support=%{?tizen_feature_account_support}"
+GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_alarm_support=%{?tizen_feature_alarm_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_application_support=%{?tizen_feature_application_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_archive_support=%{?tizen_feature_archive_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_badge_support=%{?tizen_feature_badge_support}"
--- /dev/null
+{
+ 'includes':[
+ '../common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_alarm',
+ 'type': 'loadable_module',
+ 'sources': [
+ 'alarm_api.js',
+ 'alarm_extension.cc',
+ 'alarm_extension.h',
+ 'alarm_instance.cc',
+ 'alarm_instance.h',
+ 'alarm_manager.cc',
+ 'alarm_manager.h',
+ 'alarm_utils.cc',
+ 'alarm_utils.h',
+ ],
+ 'conditions': [
+ ['tizen == 1', {
+ 'variables': {
+ 'packages': [
+ 'capi-appfw-alarm',
+ ]
+ },
+ }],
+ ],
+ },
+ ],
+}
\ No newline at end of file
--- /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.
+
+var T = xwalk.utils.type;
+var Converter = xwalk.utils.converter;
+var AV = xwalk.utils.validator;
+
+var native = new xwalk.utils.NativeManager(extension);
+
+var AlarmManager = function () {
+ Object.defineProperties(this, {
+ PERIOD_MINUTE: { value: 60, writable: false, enumerable: true},
+ PERIOD_HOUR: { value: 3600, writable: false, enumerable: true},
+ PERIOD_DAY: { value: 86400, writable: false, enumerable: true},
+ PERIOD_WEEK: { value: 604800, writable: false, enumerable: true},
+ });
+};
+
+//internal /////////////////////////////////////////////////////////////
+//this function should be kept in internal scope
+function InternalData(id) {
+ this.id = id;
+}
+
+//class AlarmManager ////////////////////////////////////////////////////
+AlarmManager.prototype.add = function () {
+ var args = AV.validateMethod(arguments, [
+ {
+ name : 'alarm',
+ type : AV.Types.PLATFORM_OBJECT,
+ values : [tizen.AlarmRelative, tizen.AlarmAbsolute]
+ },
+ {
+ name : 'applicationId',
+ type : AV.Types.STRING,
+ },
+ {
+ name : 'appControl',
+ type : AV.Types.PLATFORM_OBJECT,
+ values : tizen.ApplicationControl,
+ optional : true,
+ nullable : true
+ },
+ ]);
+
+ var type = null, seconds = 0;
+ if (args.alarm instanceof tizen.AlarmRelative) {
+ type = 'AlarmRelative';
+ } else if (args.alarm instanceof tizen.AlarmAbsolute) {
+ type = 'AlarmAbsolute';
+ seconds = args.alarm.date.getTime();
+ }
+
+ var callArgs = {};
+ callArgs.alarm = args.alarm;
+ callArgs.applicationId = args.applicationId;
+ if (args.has.appControl) {
+ callArgs.appControl = args.appControl;
+ }
+
+ callArgs.type = type;
+ callArgs.seconds = Converter.toString(seconds);
+
+ var result = native.callSync('AlarmManager_add', callArgs);
+ if (native.isFailure(result)) {
+ throw native.getErrorObject(result);
+ } else {
+ Object.defineProperties(args.alarm, {
+ id: {
+ value: Converter.toString(native.getResultObject(result).alarm_id),
+ writable: false, enumerable: true, configurable: true}
+ });
+ }
+};
+
+AlarmManager.prototype.remove = function () {
+ var args = AV.validateMethod(arguments, [
+ {
+ name : 'id',
+ type : AV.Types.STRING,
+ }
+ ]);
+
+ var result = native.callSync('AlarmManager_remove', {id: Number(args.id)});
+
+ if (native.isFailure(result)) {
+ throw native.getErrorObject(result);
+ }
+};
+
+AlarmManager.prototype.removeAll = function () {
+ var result = native.callSync('AlarmManager_removeAll', {});
+
+ if (native.isFailure(result)) {
+ throw native.getErrorObject(result);
+ }
+};
+
+AlarmManager.prototype.get = function () {
+ var args = AV.validateMethod(arguments, [
+ {
+ name : 'id',
+ type : AV.Types.STRING,
+ }
+ ]);
+
+ var result = native.callSync('AlarmManager_get', {id: Number(args.id)});
+
+ if (native.isFailure(result)) {
+ throw native.getErrorObject(result);
+ } else {
+ result = native.getResultObject(result);
+ if ('AlarmRelative' === result.type) {
+ return new tizen.AlarmRelative(result.delay, result.period,
+ new InternalData(result.id));
+ } else {
+ var date = new Date(result.year, result.month, result.day,
+ result.hour, result.min, result.sec);
+
+ return new tizen.AlarmAbsolute(date, result.second,
+ new InternalData(result.id));
+ }
+ }
+};
+
+AlarmManager.prototype.getAll = function () {
+ var result = native.callSync('AlarmManager_getAll', {});
+
+ if (native.isFailure(result)) {
+ throw native.getErrorObject(result);
+ } else {
+ var data = native.getResultObject(result);
+ var md = [];
+ data.forEach(function (i) {
+ if ('AlarmRelative'=== i.type) {
+ md.push(new tizen.AlarmRelative(i.delay, i.period,
+ new InternalData(i.id)));
+ } else {
+ var date = new Date(i.year, i.month, i.day,
+ i.hour, i.min, i.sec);
+ md.push(new tizen.AlarmAbsolute(date, i.second,
+ new InternalData(i.id)));
+ }
+ });
+ return md;
+ }
+};
+
+//class Alarm //////////////////////////////////////////////////////////
+function Alarm(id) {
+ var m_id = null;
+
+ if (!T.isNullOrUndefined(id)) {
+ m_id = Converter.toString(id);
+ }
+
+ Object.defineProperties(this, {
+ id: { value: m_id, writable: false, enumerable: true, configurable: true}
+ });
+}
+//class AlarmRelative //////////////////////////////////////////////////
+
+tizen.AlarmRelative = function(delay, period, internal) {
+ AV.validateConstructorCall(this, tizen.AlarmRelative);
+
+ var m_period = null;
+
+ var m_delay = Converter.toLong(delay);
+
+ if (arguments.length >= 2) {
+ m_period = Converter.toLong(period, true);
+ }
+ if (internal instanceof InternalData) {
+ Alarm.call(this, internal.id);
+ }
+
+ Object.defineProperties(this, {
+ delay: { value: m_delay, writable: false, enumerable: true},
+ period: { value: m_period, writable: false, enumerable: true}
+ });
+}
+
+tizen.AlarmRelative.prototype = new Alarm();
+
+tizen.AlarmRelative.prototype.constructor = tizen.AlarmRelative;
+
+tizen.AlarmRelative.prototype.getRemainingSeconds = function () {
+ var result = native.callSync('AlarmRelative_getRemainingSeconds', {id: Number(this.id)});
+
+ if (native.isFailure(result)) {
+ throw native.getErrorObject(result);
+ } else {
+ return Converter.toLong(native.getResultObject(result).seconds, true);
+ }
+};
+
+function makeDateConst(obj) {
+ console.log('Enter MakeConst');
+ obj.setDate = function() {};
+ obj.setFullYear = function() {};
+ obj.setHours = function() {};
+ obj.setMilliseconds = function() {};
+ obj.setMinutes = function() {};
+ obj.setMonth = function() {};
+ obj.setSeconds = function() {};
+ obj.setTime = function() {};
+ obj.setUTCDate = function() {};
+ obj.setUTCFullYear = function() {};
+ obj.setUTCHours = function() {};
+ obj.setUTCMilliseconds = function() {};
+ obj.setUTCMinutes = function() {};
+ obj.setUTCMonth = function() {};
+ obj.setUTCSeconds = function() {};
+ obj.setYear = function() {};
+ console.log('Leave MakeConst');
+}
+
+//class AlarmAbsolute //////////////////////////////////////////////////
+
+tizen.AlarmAbsolute = function(date, second, internal) {
+ AV.validateConstructorCall(this, tizen.AlarmAbsolute);
+
+ var m_period = null, m_daysOfWeek = [], m_date;
+
+ if (T.isDate(date)) {
+ m_date = date;
+ if (arguments.length >= 2) {
+ if(T.isArray(second)){
+ m_daysOfWeek = second;
+ } else {
+ m_period = Converter.toLong(second);
+ }
+ }
+
+ if (internal instanceof InternalData) {
+ Alarm.call(this, internal.id);
+ }
+ } else {
+ m_period = undefined;
+ }
+ makeDateConst(m_date);
+ Object.defineProperties(this, {
+ date: { value: m_date, writable: false, enumerable: true},
+ period: { value: m_period, writable: false, enumerable: true},
+ daysOfTheWeek: { value: m_daysOfWeek, writable: false, enumerable: true}
+ });
+}
+
+tizen.AlarmAbsolute.prototype = new Alarm();
+
+tizen.AlarmAbsolute.prototype.constructor = tizen.AlarmAbsolute;
+
+tizen.AlarmAbsolute.prototype.getNextScheduledDate = function () {
+ var result = native.callSync('AlarmAbsolute_getNextScheduledDate', {id: Number(this.id)});
+
+ if (native.isFailure(result)) {
+ throw native.getErrorObject(result);
+ } else {
+ var d = native.getResultObject(result);
+ if (T.isNull(d.year)) {
+ return null;
+ } else {
+ var date = new Date(d.year, d.month, d.day, d.hour, d.min, d.sec);
+ return date;
+ }
+ }
+};
+
+//exports //////////////////////////////////////////////////////////////
+exports = new AlarmManager();
--- /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 "alarm_extension.h"
+#include "alarm_instance.h"
+
+namespace {
+const char* kAlarm = "tizen.alarm";
+const char* kAlarmRelative = "tizen.AlarmRelative";
+const char* kAlarmAbsolute = "tizen.AlarmAbsolute";
+}
+
+// This will be generated from alarm_api.js.
+extern const char kSource_alarm_api[];
+
+common::Extension* CreateExtension() {
+ return new AlarmExtension;
+}
+
+AlarmExtension::AlarmExtension() {
+ SetExtensionName(kAlarm);
+ SetJavaScriptAPI(kSource_alarm_api);
+ const char* entry_points[] = {
+ kAlarmRelative,
+ kAlarmAbsolute,
+ NULL
+ };
+ SetExtraJSEntryPoints(entry_points);
+}
+
+AlarmExtension::~AlarmExtension() {}
+
+common::Instance* AlarmExtension::CreateInstance() {
+ return &extension::alarm::AlarmInstance::GetInstance();
+}
--- /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 ALARM_ALARM_EXTENSION_H_
+#define ALARM_ALARM_EXTENSION_H_
+
+#include "common/extension.h"
+
+class AlarmExtension : public common::Extension {
+ public:
+ AlarmExtension();
+ virtual ~AlarmExtension();
+
+ private:
+ virtual common::Instance* CreateInstance();
+};
+
+#endif // ALARM_ALARM_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 "alarm_instance.h"
+
+#include "alarm_manager.h"
+#include "common/picojson.h"
+#include "common/logger.h"
+
+namespace extension {
+namespace alarm {
+
+using namespace common;
+
+namespace {
+AlarmManager* alarm_manager = &AlarmManager::GetInstance();
+}
+
+AlarmInstance& AlarmInstance::GetInstance() {
+ static AlarmInstance instance;
+ return instance;
+}
+
+AlarmInstance::AlarmInstance() {
+ LoggerD("Entered");
+ using namespace std::placeholders;
+
+ RegisterSyncHandler("AlarmManager_add",
+ std::bind(&AlarmManager::Add, alarm_manager, _1, _2));
+ RegisterSyncHandler("AlarmManager_remove",
+ std::bind(&AlarmManager::Remove, alarm_manager, _1, _2));
+ RegisterSyncHandler("AlarmManager_removeAll",
+ std::bind(&AlarmManager::RemoveAll, alarm_manager, _1, _2));
+ RegisterSyncHandler("AlarmManager_get",
+ std::bind(&AlarmManager::Get, alarm_manager, _1, _2));
+ RegisterSyncHandler("AlarmManager_getAll",
+ std::bind(&AlarmManager::GetAll, alarm_manager, _1, _2));
+ //AlarmRelative
+ RegisterSyncHandler("AlarmRelative_getRemainingSeconds",
+ std::bind(&AlarmManager::GetRemainingSeconds, alarm_manager, _1, _2));
+ //AlarmAbsolute
+ RegisterSyncHandler("AlarmAbsolute_getNextScheduledDate",
+ std::bind(&AlarmManager::GetNextScheduledDate, alarm_manager, _1, _2));
+}
+
+AlarmInstance::~AlarmInstance() {
+ LoggerD("Entered");
+}
+
+} // namespace Alarm
+} // 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 ALARM_ALARM_INSTANCE_H_
+#define ALARM_ALARM_INSTANCE_H_
+
+#include "common/extension.h"
+
+namespace extension {
+namespace alarm {
+
+class AlarmInstance: public common::ParsedInstance {
+ public:
+ static AlarmInstance& GetInstance();
+ private:
+ AlarmInstance();
+ virtual ~AlarmInstance();
+};
+
+} // namespace alarm
+} // namespace extension
+
+#endif // ALARM_ALARM_INSTANCE_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 "alarm_manager.h"
+
+#include <app.h>
+#include <app_alarm.h>
+
+#include "common/logger.h"
+#include "common/converter.h"
+#include "common/platform_result.h"
+
+#include "alarm_instance.h"
+#include "alarm_utils.h"
+
+using namespace common;
+using namespace common::tools;
+
+namespace extension {
+namespace alarm {
+
+AlarmManager::AlarmManager() {
+}
+
+AlarmManager::~AlarmManager() {
+}
+
+AlarmManager& AlarmManager::GetInstance() {
+ static AlarmManager instance;
+ return instance;
+}
+
+void AlarmManager::Add(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+}
+
+void AlarmManager::Remove(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+}
+
+void AlarmManager::RemoveAll(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+}
+
+void AlarmManager::Get(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+}
+
+void AlarmManager::GetAll(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+}
+
+void AlarmManager::GetRemainingSeconds(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+}
+
+void AlarmManager::GetNextScheduledDate(const picojson::value& args, picojson::object& out) {
+ LoggerD("Entered");
+}
+
+} // namespace alarm
+} // namespace extension
--- /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 ALARM_ALARM_MANAGER_H_
+#define ALARM_ALARM_MANAGER_H_
+
+#include "common/picojson.h"
+
+namespace extension {
+namespace alarm {
+
+class AlarmManager {
+ public:
+ static AlarmManager& GetInstance();
+ virtual ~AlarmManager();
+
+ void Add(const picojson::value& args, picojson::object& out);
+ void Remove(const picojson::value& args, picojson::object& out);
+ void RemoveAll(const picojson::value& args, picojson::object& out);
+ void Get(const picojson::value& args, picojson::object& out);
+ void GetAll(const picojson::value& args, picojson::object& out);
+
+ //AlarmRelative
+ void GetRemainingSeconds(const picojson::value& args, picojson::object& out);
+ //AlarmAbsolute
+ void GetNextScheduledDate(const picojson::value& args, picojson::object& out);
+
+ private:
+ AlarmManager();
+ AlarmManager(const AlarmManager&) = delete;
+ AlarmManager& operator=(const AlarmManager&) = delete;
+
+};
+
+} // namespace alarm
+} // namespace extension
+
+#endif // ALARM_ALARM_MANAGER_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 "alarm_utils.h"
+
+#include "common/logger.h"
+
+namespace extension {
+namespace alarm {
+namespace util {
+
+using namespace common;
+
+void CheckAccess(const std::string& privilege) {
+ // TODO: check access to privilege, throw exception on failure
+}
+
+PlatformResult AppControlToService(const picojson::object& obj, app_control_h *app_control) {
+ LoggerD("Entered");
+}
+
+PlatformResult AppControlToServiceExtraData(const picojson::object& app_obj,
+ app_control_h *app_control) {
+ LoggerD("Entered");
+}
+
+} // util
+} // alarm
+} // 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 ALARM_ALARM_UTILS_H_
+#define ALARM_ALARM_UTILS_H_
+
+#include <app_control.h>
+
+#include "common/picojson.h"
+#include "common/platform_result.h"
+
+namespace extension {
+namespace alarm {
+namespace util {
+
+void CheckAccess(const std::string& privilege);
+
+common::PlatformResult AppControlToService(const picojson::object& obj, app_control_h *app_control);
+common::PlatformResult AppControlToServiceExtraData(const picojson::object& app_obj,
+ app_control_h *app_control);
+} // util
+} // alarm
+} // extension
+
+#endif // ALARM_ALARM_UTILS_H_
],
},
],
+ [
+ 'tizen_feature_alarm_support==1', {
+ 'dependencies': [
+ 'alarm/alarm.gyp:*',
+ ],
+ },
+ ],
[
'tizen_feature_application_support==1', {
'dependencies': [