[CB-4592] [Blackberry10] Added beep support
diff --git a/plugin.xml b/plugin.xml
index 4e8a52a..3d47847 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -20,18 +20,18 @@
<param name="android-package" value="org.apache.cordova.dialogs.Notification"/>
</feature>
</config-file>
-
+
<source-file src="src/android/Notification.java" target-dir="src/org/apache/cordova/dialogs" />
<!-- android specific notification apis -->
<js-module src="www/android/notification.js" name="notification_android">
<merges target="navigator.notification" />
</js-module>
-
+
</platform>
<!-- ios -->
- <platform name="ios">
+ <platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="Notification">
<param name="ios-package" value="CDVNotification"/>
@@ -40,7 +40,7 @@
<header-file src="src/ios/CDVNotification.h" />
<source-file src="src/ios/CDVNotification.m" />
<resource-file src="src/ios/CDVNotification.bundle" />
- <framework src="AudioToolbox.framework" weak="true" />
+ <framework src="AudioToolbox.framework" weak="true" />
</platform>
<!-- blackberry10 -->
@@ -49,6 +49,9 @@
<config-file target="www/config.xml" parent="/widget">
<feature name="Notification" value="Notification"/>
</config-file>
+ <js-module src="www/blackberry10/beep.js" name="beep">
+ <clobbers target="window.navigator.notification.beep" />
+ </js-module>
</platform>
<!-- wp7 -->
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index fad04f7..b218eab 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -83,9 +83,5 @@
} else {
showDialog(args, "JavaScriptPrompt", result);
}
- },
- beep: function (success, fail, args, env) {
- var result = new PluginResult(args, env);
- result.error("Beep not supported");
}
};
diff --git a/www/blackberry10/beep.js b/www/blackberry10/beep.js
new file mode 100644
index 0000000..6d4a77a
--- /dev/null
+++ b/www/blackberry10/beep.js
@@ -0,0 +1,42 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+var beep,
+ count = 0,
+ beepObj = new Audio('file:///usr/share/sounds/notification_text_message_im_received.wav');
+
+beep = function (quantity) {
+ var callback = function () {
+ if (--count > 0) {
+ beepObj.play();
+ } else {
+ beepObj.removeEventListener("ended", callback);
+ delete beepObj;
+ }
+ };
+
+ count += quantity;
+ if (count === quantity) {
+ beepObj.addEventListener("ended", callback);
+ beepObj.play();
+ }
+};
+
+module.exports = beep;