From: Adam Banasiak Date: Wed, 7 Jan 2015 09:46:56 +0000 (+0100) Subject: [Badge] Initial commit X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~649 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39956414a7d872ddf332c67682eda642b29d002c;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Badge] Initial commit Change-Id: Ia444ec987450d0b2bf711746417ef0da7ee5d67e Signed-off-by: Adam Banasiak --- diff --git a/src/badge/badge.gyp b/src/badge/badge.gyp new file mode 100644 index 00000000..3819d43c --- /dev/null +++ b/src/badge/badge.gyp @@ -0,0 +1,29 @@ +{ + 'includes':[ + '../common/common.gypi', + ], + 'targets': [ + { + 'target_name': 'tizen_badge', + 'type': 'loadable_module', + 'sources': [ + 'badge_api.js', + 'badge_extension.cc', + 'badge_extension.h', + 'badge_instance.cc', + 'badge_instance.h', + 'badge_manager.cc', + 'badge_manager.h', + ], + 'conditions': [ + ['tizen == 1', { + 'variables': { + 'packages': [ + 'vconf', + ] + }, + }], + ], + }, + ], +} diff --git a/src/badge/badge_api.js b/src/badge/badge_api.js new file mode 100644 index 00000000..c62e8567 --- /dev/null +++ b/src/badge/badge_api.js @@ -0,0 +1,53 @@ +/* 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 types_ = validator_.Types; +var native_ = new xwalk.utils.NativeManager(extension); + +/** + * This class provides functions to request and release badge resource. + * @constructor + */ +function BadgeManager() { +} + +/** + * Sets the badge count for the designated application. + * @param {!ApplicationId} ID of the application to update the badge + * @param {!number} Number to display as the badge on the application icon + */ +BadgeManager.prototype.setBadgeCount = function() { + throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERROR, 'Not implemented'); +} + +/** + * Gets the badge count for the designated application. + * @param {!ApplicationId} ID of the designated application + * @return {number} long Count of the badge + */ +BadgeManager.prototype.getBadgeCount = function() { + throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERROR, 'Not implemented'); +} + +/** + * Gets the badge count for the designated application. + * @param {!ApplicationId} Array of the ID of the designated application + * @param {!function} Callback method to be invoked when a badge number change notification is received + */ +BadgeManager.prototype.addChangeListener = function() { + throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERROR, 'Not implemented'); +} + +/** + * Gets the badge count for the designated application. + * @param {!ApplicationId} Array of the ID of the designated application + */ +BadgeManager.prototype.removeChangeListener = function() { + throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERROR, 'Not implemented'); +} + +exports.badge = new BadgeManager(); diff --git a/src/badge/badge_extension.cc b/src/badge/badge_extension.cc new file mode 100644 index 00000000..919cea58 --- /dev/null +++ b/src/badge/badge_extension.cc @@ -0,0 +1,23 @@ +// 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 "badge/badge_extension.h" + +#include "badge/badge_instance.h" + +// This will be generated from badge_api.js +extern const char kSource_badge_api[]; + +common::Extension* CreateExtension() { return new BadgeExtension; } + +BadgeExtension::BadgeExtension() { + SetExtensionName("tizen.badge"); + SetJavaScriptAPI(kSource_badge_api); +} + +BadgeExtension::~BadgeExtension() {} + +common::Instance* BadgeExtension::CreateInstance() { + return new extension::badge::BadgeInstance; +} diff --git a/src/badge/badge_extension.h b/src/badge/badge_extension.h new file mode 100644 index 00000000..ecb1f950 --- /dev/null +++ b/src/badge/badge_extension.h @@ -0,0 +1,19 @@ +// 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 BADGE_BADGE_EXTENSION_H_ +#define BADGE_BADGE_EXTENSION_H_ + +#include "common/extension.h" + +class BadgeExtension : public common::Extension { + public: + BadgeExtension(); + virtual ~BadgeExtension(); + + private: + virtual common::Instance* CreateInstance(); +}; + +#endif // BADGE_BADGE_EXTENSION_H_ diff --git a/src/badge/badge_instance.cc b/src/badge/badge_instance.cc new file mode 100644 index 00000000..d0394bce --- /dev/null +++ b/src/badge/badge_instance.cc @@ -0,0 +1,34 @@ +// 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 "badge/badge_instance.h" + +#include "common/picojson.h" +#include "common/logger.h" +#include "common/platform_exception.h" + +namespace extension { +namespace badge { + +namespace { +// The privileges that required in Badge API +const std::string kPrivilegeBadge = "http://tizen.org/privilege/badge"; + +} // namespace + +using namespace common; +using namespace extension::badge; + +BadgeInstance::BadgeInstance() { + using namespace std::placeholders; +#define REGISTER_SYNC(c, x) \ + RegisterSyncHandler(c, std::bind(&BadgeInstance::x, this, _1, _2)); + +#undef REGISTER_SYNC +} + +BadgeInstance::~BadgeInstance() {} + +} // namespace badge +} // namespace extension diff --git a/src/badge/badge_instance.h b/src/badge/badge_instance.h new file mode 100644 index 00000000..c04a5c35 --- /dev/null +++ b/src/badge/badge_instance.h @@ -0,0 +1,23 @@ +// 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 BADGE_BADGE_INSTANCE_H_ +#define BADGE_BADGE_INSTANCE_H_ + +#include "common/extension.h" + +namespace extension { +namespace badge { + +class BadgeInstance : public common::ParsedInstance { + public: + BadgeInstance(); + virtual ~BadgeInstance(); + +}; + +} // namespace badge +} // namespace extension + +#endif // BADGE_BADGE_INSTANCE_H_ diff --git a/src/badge/badge_manager.cc b/src/badge/badge_manager.cc new file mode 100644 index 00000000..353b5de6 --- /dev/null +++ b/src/badge/badge_manager.cc @@ -0,0 +1,35 @@ +// 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 "badge_manager.h" + +#include + +#include "common/logger.h" +#include "common/platform_exception.h" + +using namespace common; + +namespace extension { +namespace badge { + +BadgeManager::BadgeManager() {} + +BadgeManager::~BadgeManager() {} + +BadgeManager* BadgeManager::GetInstance() { + static BadgeManager instance; + return &instance; +} + +void setBadgeCount(std::string appId, long count) { + throw UnknownException("Not implemented."); +} + +long getBadgeCount(std::string appId) { + throw UnknownException("Not implemented."); +} + +} // namespace badge +} // namespace extension diff --git a/src/badge/badge_manager.h b/src/badge/badge_manager.h new file mode 100644 index 00000000..795c5bc3 --- /dev/null +++ b/src/badge/badge_manager.h @@ -0,0 +1,26 @@ +// 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 BADGE_BADGE_MANAGER_H_ +#define BADGE_BADGE_MANAGER_H_ + +#include + +namespace extension { +namespace badge { + +class BadgeManager { + public: + BadgeManager(); + ~BadgeManager(); + BadgeManager* GetInstance(); + + void setBadgeCount(std::string appId, long count); + long getBadgeCount(std::string appId); +}; + +} // namespace badge +} // namespace extension + +#endif // BADGE_BADGE_MANAGER_H_ diff --git a/src/tizen-wrt.gyp b/src/tizen-wrt.gyp index b83552b2..59feb6a7 100644 --- a/src/tizen-wrt.gyp +++ b/src/tizen-wrt.gyp @@ -20,6 +20,7 @@ [ 'extension_host_os == "mobile"', { 'dependencies': [ + 'badge/badge.gyp:*', 'callhistory/callhistory.gyp:*', 'contact/contact.gyp:*', 'calendar/calendar.gyp:*',