[Push] Plugin stubs
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Wed, 11 Feb 2015 13:01:10 +0000 (14:01 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Fri, 13 Feb 2015 12:33:58 +0000 (13:33 +0100)
[Verification]
tizen.push exists and has methods:
> tizen.push.__proto__
{ registerService: [Function],
  unregisterService: [Function],
  connectService: [Function],
  disconnectService: [Function],
  getRegistrationId: [Function],
  getUnreadNotifications: [Function] }

Change-Id: Ic299568c87d09a037dc3fc6869cfcb154af56d7d
Signed-off-by: Przemyslaw Ciezkowski <p.ciezkowski@samsung.com>
packaging/webapi-plugins.spec
src/push/push.gyp [new file with mode: 0644]
src/push/push_api.js [new file with mode: 0644]
src/push/push_extension.cc [new file with mode: 0644]
src/push/push_extension.h [new file with mode: 0644]
src/push/push_instance.cc [new file with mode: 0644]
src/push/push_instance.h [new file with mode: 0644]
src/push/push_manager.cc [new file with mode: 0644]
src/push/push_manager.h [new file with mode: 0644]
src/tizen-wrt.gyp

index 208b8bd..1fe9c5c 100644 (file)
@@ -43,7 +43,7 @@ Source0:    %{name}-%{version}.tar.gz
 %define tizen_feature_nfc_support                 1
 %define tizen_feature_notification_support        1
 %define tizen_feature_power_support               1
-%define tizen_feature_push_support                0
+%define tizen_feature_push_support                1
 %define tizen_feature_sap_support                 0
 %define tizen_feature_se_support                  1
 %define tizen_feature_sensor_support              1
@@ -199,6 +199,11 @@ BuildRequires: pkgconfig(capi-data-control)
 BuildRequires: pkgconfig(capi-system-power)
 %endif
 
+%if 0%{?tizen_feature_power_support}
+BuildRequires: pkgconfig(push)
+BuildRequires: pkgconfig(capi-appfw-application)
+%endif
+
 %if 0%{?tizen_feature_tv_display_support}
 BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(vconf)
diff --git a/src/push/push.gyp b/src/push/push.gyp
new file mode 100644 (file)
index 0000000..7e57a01
--- /dev/null
@@ -0,0 +1,33 @@
+{
+  'includes':[
+    '../common/common.gypi',
+  ],
+  'targets': [
+    {
+      'target_name': 'tizen_push',
+      'type': 'loadable_module',
+      'sources': [
+        'push_api.js',
+        'push_extension.cc',
+        'push_extension.h',
+        'push_instance.cc',
+        'push_instance.h',
+        'push_manager.cc',
+        'push_manager.h'
+      ],
+      'includes': [
+        '../common/pkg-config.gypi',
+      ],
+      'conditions': [
+        ['tizen == 1', {
+          'variables': {
+            'packages': [
+              'push',
+              'capi-appfw-application',
+            ]
+          },
+        }],
+      ],
+    },
+  ],
+}
diff --git a/src/push/push_api.js b/src/push/push_api.js
new file mode 100644 (file)
index 0000000..ba8f49d
--- /dev/null
@@ -0,0 +1,46 @@
+/* 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 native = new xwalk.utils.NativeManager(extension);
+var validator = xwalk.utils.validator;
+
+
+
+/**
+ * @constructor
+ */
+function PushManager() {
+  if (!(this instanceof PushManager)) {
+    throw new TypeError;
+  }
+}
+
+PushManager.prototype.registerService = function(appControl, successCallback, errorCallback) {
+
+};
+
+PushManager.prototype.unregisterService = function(successCallback, errorCallback) {
+
+};
+
+PushManager.prototype.connectService = function(notificationCallback) {
+
+};
+
+PushManager.prototype.disconnectService = function() {
+
+};
+
+PushManager.prototype.getRegistrationId = function() {
+
+};
+
+PushManager.prototype.getUnreadNotifications = function() {
+
+};
+
+exports = new PushManager();
diff --git a/src/push/push_extension.cc b/src/push/push_extension.cc
new file mode 100644 (file)
index 0000000..9474f9b
--- /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 "push/push_extension.h"
+#include "push/push_instance.h"
+
+// This will be generated from push_api.js
+extern const char kSource_push_api[];
+
+namespace extension {
+namespace push {
+
+PushExtension::PushExtension() {
+    SetExtensionName("tizen.push");
+    SetJavaScriptAPI(kSource_push_api);
+}
+
+PushExtension::~PushExtension() {}
+
+PushManager& PushExtension::manager() {
+    // Initialize API on first request
+    return PushManager::getInstance();
+}
+
+common::Instance* PushExtension::CreateInstance() {
+    return new PushInstance;
+}
+
+}  // namespace push
+}  // namespace extension
+
+common::Extension* CreateExtension() {
+    return new extension::push::PushExtension;
+}
diff --git a/src/push/push_extension.h b/src/push/push_extension.h
new file mode 100644 (file)
index 0000000..71cfb6b
--- /dev/null
@@ -0,0 +1,29 @@
+// 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 SRC_PUSH_PUSH_EXTENSION_H_
+#define SRC_PUSH_PUSH_EXTENSION_H_
+
+#include "common/extension.h"
+#include "push/push_manager.h"
+
+namespace extension {
+namespace push {
+
+class PushExtension : public common::Extension {
+ public:
+    PushExtension();
+    virtual ~PushExtension();
+
+    PushManager& manager();
+
+ private:
+    virtual common::Instance* CreateInstance();
+};
+
+}  // namespace push
+}  // namespace extension
+
+#endif  // SRC_PUSH_PUSH_EXTENSION_H_
+
diff --git a/src/push/push_instance.cc b/src/push/push_instance.cc
new file mode 100644 (file)
index 0000000..ff1dde7
--- /dev/null
@@ -0,0 +1,22 @@
+// 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 "common/logger.h"
+
+#include "push/push_instance.h"
+#include "push/push_manager.h"
+
+namespace extension {
+namespace push {
+
+PushInstance::PushInstance() {
+    LoggerD("Enter");
+}
+
+PushInstance::~PushInstance() {
+    LoggerD("Enter");
+}
+
+}  // namespace push
+}  // namespace extension
diff --git a/src/push/push_instance.h b/src/push/push_instance.h
new file mode 100644 (file)
index 0000000..c572357
--- /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 SRC_PUSH_PUSH_INSTANCE_H_
+#define SRC_PUSH_PUSH_INSTANCE_H_
+
+#include "common/extension.h"
+
+#include "push/push_manager.h"
+
+namespace extension {
+namespace push {
+
+class PushInstance: public common::ParsedInstance {
+ public:
+    PushInstance();
+    virtual ~PushInstance();
+
+ private:
+};
+
+}  // namespace push
+}  // namespace extension
+
+#endif  // SRC_PUSH_PUSH_INSTANCE_H_
diff --git a/src/push/push_manager.cc b/src/push/push_manager.cc
new file mode 100644 (file)
index 0000000..d53ffe9
--- /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.
+
+#include "common/logger.h"
+#include "push/push_manager.h"
+
+namespace extension {
+namespace push {
+
+PushManager::PushManager() {
+    LoggerD("Enter");
+}
+
+PushManager::~PushManager() {
+    LoggerD("Enter");
+}
+
+PushManager& PushManager::getInstance() {
+  static PushManager instance;
+  return instance;
+}
+
+}  // namespace push
+}  // namespace extension
+
diff --git a/src/push/push_manager.h b/src/push/push_manager.h
new file mode 100644 (file)
index 0000000..30f5510
--- /dev/null
@@ -0,0 +1,25 @@
+// 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 SRC_PUSH_PUSH_MANAGER_H_
+#define SRC_PUSH_PUSH_MANAGER_H_
+
+namespace extension {
+namespace push {
+
+
+class PushManager {
+ public:
+    static PushManager& getInstance();
+    virtual ~PushManager();
+
+ private:
+    PushManager();
+};
+
+}  // namespace push
+}  // namespace extension
+
+#endif  // SRC_PUSH_PUSH_MANAGER_H_
+
index 21ea313..b8511ce 100644 (file)
@@ -42,6 +42,7 @@
               'sound/sound.gyp:*',
               'notification/notification.gyp:*',
               'sensor/sensor.gyp:*',
+              'push/push.gyp:*',
             ],
           },
         ], # end mobile