[Badge] Initial commit
authorAdam Banasiak <a.banasiak@samsung.com>
Wed, 7 Jan 2015 09:46:56 +0000 (10:46 +0100)
committerRafal Galka <r.galka@samsung.com>
Mon, 12 Jan 2015 10:16:39 +0000 (19:16 +0900)
Change-Id: Ia444ec987450d0b2bf711746417ef0da7ee5d67e
Signed-off-by: Adam Banasiak <a.banasiak@samsung.com>
src/badge/badge.gyp [new file with mode: 0644]
src/badge/badge_api.js [new file with mode: 0644]
src/badge/badge_extension.cc [new file with mode: 0644]
src/badge/badge_extension.h [new file with mode: 0644]
src/badge/badge_instance.cc [new file with mode: 0644]
src/badge/badge_instance.h [new file with mode: 0644]
src/badge/badge_manager.cc [new file with mode: 0644]
src/badge/badge_manager.h [new file with mode: 0644]
src/tizen-wrt.gyp

diff --git a/src/badge/badge.gyp b/src/badge/badge.gyp
new file mode 100644 (file)
index 0000000..3819d43
--- /dev/null
@@ -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 (file)
index 0000000..c62e856
--- /dev/null
@@ -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 (file)
index 0000000..919cea5
--- /dev/null
@@ -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 (file)
index 0000000..ecb1f95
--- /dev/null
@@ -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 (file)
index 0000000..d0394bc
--- /dev/null
@@ -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 (file)
index 0000000..c04a5c3
--- /dev/null
@@ -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 (file)
index 0000000..353b5de
--- /dev/null
@@ -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 <cstring>
+
+#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 (file)
index 0000000..795c5bc
--- /dev/null
@@ -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 <string>
+
+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_
index b83552b2fe6b0c96cdfc2bf1507cb1a46eed2f81..59feb6a7da4f0daa93b3dc00d2894be9ec222047 100644 (file)
@@ -20,6 +20,7 @@
         [
           'extension_host_os == "mobile"', {
             'dependencies': [
+              'badge/badge.gyp:*',
               'callhistory/callhistory.gyp:*',
               'contact/contact.gyp:*',
               'calendar/calendar.gyp:*',