Updated Branches: refs/heads/master b7a7410d6 -> 8a361f958
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/91b9453d/blackberry10/plugins/Media/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/blackberry10/plugins/Media/src/blackberry10/index.js b/blackberry10/plugins/Media/src/blackberry10/index.js deleted file mode 100644 index 32192c8..0000000 --- a/blackberry10/plugins/Media/src/blackberry10/index.js +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2010-2011 Research In Motion Limited. - * - * Licensed 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 audioObjects = {}, - mediaErrorsHandled = false; - -// There is a bug in the webplatform handling of media error -// dialogs prior to 10.2. This function needs to be run once -// on the webview which plays audio to prevent freezing. -function handleMediaErrors() { - var webview = qnx.webplatform.getWebViews()[0], - handler = webview.onDialogRequested; - if (!mediaErrorsHandled) { - webview.allowWebEvent("DialogRequested"); - webview.onDialogRequested = undefined; - webview.onDialogRequested = function (eventArgs) { - var parsedArgs = JSON.parse(eventArgs); - if (parsedArgs.dialogType === 'MediaError') { - return '{"setPreventDefault": true}'; - } - handler(eventArgs); - }; - mediaErrorsHandled = true; - } -} - -module.exports = { - - create: function (success, fail, args, env) { - var result = new PluginResult(args, env), - id; - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - id = JSON.parse(decodeURIComponent(args[0])); - - if (!args[1]){ - audioObjects[id] = new Audio(); - } else { - audioObjects[id] = new Audio(JSON.parse(decodeURIComponent(args[1]))); - } - - handleMediaErrors(); - - result.ok(); - }, - - startPlayingAudio: function (success, fail, args, env) { - - var audio, - id, - result = new PluginResult(args, env); - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - id = JSON.parse(decodeURIComponent(args[0])); - - audio = audioObjects[id]; - - if (!audio) { - result.error("Audio object has not been initialized"); - } else { - audio.play(); - result.ok(); - } - }, - - stopPlayingAudio: function (success, fail, args, env) { - - var audio, - id, - result = new PluginResult(args, env); - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - id = JSON.parse(decodeURIComponent(args[0])); - - audio = audioObjects[id]; - - if (!audio) { - result.error("Audio Object has not been initialized"); - return; - } - - audio.pause(); - audio.currentTime = 0; - - result.ok(); - }, - - seekToAudio: function (success, fail, args, env) { - - var audio, - result = new PluginResult(args, env); - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - audio = audioObjects[JSON.parse(decodeURIComponent(args[0]))]; - - if (!audio) { - result.error("Audio Object has not been initialized"); - } else if (!args[1]) { - result.error("Media seek time argument not found"); - } else { - try { - audio.currentTime = JSON.parse(decodeURIComponent(args[1])) / 1000; - result.ok(); - } catch (e) { - result.error("Error seeking audio: " + e); - } - } - }, - - pausePlayingAudio: function (success, fail, args, env) { - - var audio, - result = new PluginResult(args, env); - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - audio = audioObjects[JSON.parse(decodeURIComponent(args[0]))]; - - if (!audio) { - result.error("Audio Object has not been initialized"); - return; - } - - audio.pause(); - }, - - getCurrentPositionAudio: function (success, fail, args, env) { - - var audio, - result = new PluginResult(args, env); - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - audio = audioObjects[JSON.parse(decodeURIComponent(args[0]))]; - - if (!audio) { - result.error("Audio Object has not been initialized"); - return; - } - - result.ok(audio.currentTime); - }, - - getDuration: function (success, fail, args, env) { - - var audio, - result = new PluginResult(args, env); - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - audio = audioObjects[JSON.parse(decodeURIComponent(args[0]))]; - - if (!audio) { - result.error("Audio Object has not been initialized"); - return; - } - - result.ok(audio.duration); - }, - - startRecordingAudio: function (success, fail, args, env) { - var result = new PluginResult(args, env); - result.error("Not supported"); - }, - - stopRecordingAudio: function (success, fail, args, env) { - var result = new PluginResult(args, env); - result.error("Not supported"); - }, - - release: function (success, fail, args, env) { - var audio, - id, - result = new PluginResult(args, env); - - if (!args[0]) { - result.error("Media Object id was not sent in arguments"); - return; - } - - id = JSON.parse(decodeURIComponent(args[0])); - - audio = audioObjects[id]; - - if (audio) { - if(audio.src !== ""){ - audio.src = undefined; - } - audioObjects[id] = undefined; - } - - result.ok(); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/91b9453d/blackberry10/plugins/NetworkStatus/plugin.xml ---------------------------------------------------------------------- diff --git a/blackberry10/plugins/NetworkStatus/plugin.xml b/blackberry10/plugins/NetworkStatus/plugin.xml deleted file mode 100644 index 47eea68..0000000 --- a/blackberry10/plugins/NetworkStatus/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed 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. - ---> - -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" - id="org.apache.cordova.core.Network" - version="0.0.1"> - - <name>Network Information</name> - - <platform name="blackberry10"> - <source-file src="src/blackberry10/index.js" target-dir="NetworkStatus" /> - <config-file target="www/config.xml" parent="/widget"> - <feature name="NetworkStatus" value="NetworkStatus"/> - </config-file> - </platform> -</plugin> http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/91b9453d/blackberry10/plugins/NetworkStatus/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/blackberry10/plugins/NetworkStatus/src/blackberry10/index.js b/blackberry10/plugins/NetworkStatus/src/blackberry10/index.js deleted file mode 100644 index 5a991fe..0000000 --- a/blackberry10/plugins/NetworkStatus/src/blackberry10/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2010-2011 Research In Motion Limited. - * - * Licensed 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. - */ - -//map from BB10 to cordova connection types: -//https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js -function mapConnectionType(con) { - switch (con.type) { - case 'wired': - return 'ethernet'; - case 'wifi': - return 'wifi'; - case 'none': - return 'none'; - case 'cellular': - switch (con.technology) { - case 'edge': - case 'gsm': - return '2g'; - case 'evdo': - return '3g'; - case 'umts': - return '3g'; - case 'lte': - return '4g'; - } - return "cellular"; - } - return 'unknown'; -} - -function currentConnectionType() { - try { - //possible for webplatform to throw pps exception - return mapConnectionType(window.qnx.webplatform.device.activeConnection || { type : 'none' }); - } - catch (e) { - return 'unknown'; - } -} - -module.exports = { - getConnectionInfo: function (success, fail, args, env) { - var result = new PluginResult(args, env); - result.ok(currentConnectionType()); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/91b9453d/blackberry10/plugins/Notification/plugin.xml ---------------------------------------------------------------------- diff --git a/blackberry10/plugins/Notification/plugin.xml b/blackberry10/plugins/Notification/plugin.xml deleted file mode 100644 index 49566b2..0000000 --- a/blackberry10/plugins/Notification/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed 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. - ---> - -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" - id="org.apache.cordova.core.Notification" - version="0.0.1"> - - <name>Notification</name> - - <platform name="blackberry10"> - <source-file src="src/blackberry10/index.js" target-dir="Notification" /> - <config-file target="www/config.xml" parent="/widget"> - <feature name="Notification" value="Notification"/> - </config-file> - </platform> -</plugin> http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/91b9453d/blackberry10/plugins/Notification/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/blackberry10/plugins/Notification/src/blackberry10/index.js b/blackberry10/plugins/Notification/src/blackberry10/index.js deleted file mode 100644 index fad04f7..0000000 --- a/blackberry10/plugins/Notification/src/blackberry10/index.js +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Copyright 2013 Research In Motion Limited. -* -* Licensed 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. -*/ - -function showDialog(args, dialogType, result) { - //Unpack and map the args - var msg = JSON.parse(decodeURIComponent(args[0])), - title = JSON.parse(decodeURIComponent(args[1])), - btnLabel = JSON.parse(decodeURIComponent(args[2])); - - if (!Array.isArray(btnLabel)) { - //Converts to array for (string) and (string,string, ...) cases - btnLabel = btnLabel.split(","); - } - - if (msg && typeof msg === "string") { - msg = msg.replace(/^"|"$/g, "").replace(/\\"/g, '"').replace(/\\\\/g, '\\'); - } else { - result.error("message is undefined"); - return; - } - - var messageObj = { - title : title, - htmlmessage : msg, - dialogType : dialogType, - optionalButtons : btnLabel - }; - - //TODO replace with getOverlayWebview() when available in webplatform - qnx.webplatform.getWebViews()[2].dialog.show(messageObj, function (data) { - if (typeof data === "number") { - //Confirm dialog call back needs to be called with one-based indexing [1,2,3 etc] - result.callbackOk(++data, false); - } else { - //Prompt dialog callback expects object - result.callbackOk({ - buttonIndex: data.ok ? 1 : 0, - input1: (data.oktext) ? decodeURIComponent(data.oktext) : "" - }, false); - } - }); - - result.noResult(true); -} - -module.exports = { - alert: function (success, fail, args, env) { - var result = new PluginResult(args, env); - - if (Object.keys(args).length < 3) { - result.error("Notification action - alert arguments not found."); - } else { - showDialog(args, "CustomAsk", result); - } - }, - confirm: function (success, fail, args, env) { - var result = new PluginResult(args, env); - - if (Object.keys(args).length < 3) { - result.error("Notification action - confirm arguments not found."); - } else { - showDialog(args, "CustomAsk", result); - } - }, - prompt: function (success, fail, args, env) { - var result = new PluginResult(args, env); - - if (Object.keys(args).length < 3) { - result.error("Notification action - prompt arguments not found."); - } else { - showDialog(args, "JavaScriptPrompt", result); - } - }, - beep: function (success, fail, args, env) { - var result = new PluginResult(args, env); - result.error("Beep not supported"); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/91b9453d/blackberry10/plugins/SplashScreen/plugin.xml ---------------------------------------------------------------------- diff --git a/blackberry10/plugins/SplashScreen/plugin.xml b/blackberry10/plugins/SplashScreen/plugin.xml deleted file mode 100644 index 0b33d5a..0000000 --- a/blackberry10/plugins/SplashScreen/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed 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. - ---> - -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" - id="org.apache.cordova.core.SplashScreen" - version="0.0.1"> - - <name>SplashScreen</name> - - <platform name="blackberry10"> - <source-file src="src/blackberry10/index.js" target-dir="SplashScreen" /> - <config-file target="www/config.xml" parent="/widget"> - <feature name="SplashScreen" value="SplashScreen"/> - </config-file> - </platform> -</plugin> http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/91b9453d/blackberry10/plugins/SplashScreen/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/blackberry10/plugins/SplashScreen/src/blackberry10/index.js b/blackberry10/plugins/SplashScreen/src/blackberry10/index.js deleted file mode 100644 index bd7e48c..0000000 --- a/blackberry10/plugins/SplashScreen/src/blackberry10/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013 Research In Motion Limited. - * - * Licensed 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. - */ - -module.exports = { - show: function (success, fail, args, env) { - var result = new PluginResult(args, env); - result.error("Not supported on platform", false); - }, - - hide: function (success, fail, args, env) { - var result = new PluginResult(args, env); - window.qnx.webplatform.getApplication().windowVisible = true; - result.ok(undefined, false); - } -};
