Updated Branches: refs/heads/master d716e31b3 -> da4150649
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/FileTransferProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/FileTransferProxy.js b/lib/windows8/plugin/windows8/FileTransferProxy.js deleted file mode 100644 index 1ce79d0..0000000 --- a/lib/windows8/plugin/windows8/FileTransferProxy.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - * - * 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 FileTransferError = require('cordova/plugin/FileTransferError'), - FileUploadResult = require('cordova/plugin/FileUploadResult'), - FileEntry = require('cordova/plugin/FileEntry'); - -module.exports = { - - upload:function(successCallback, error, options) { - var filePath = options[0]; - var server = options[1]; - - - var win = function (fileUploadResult) { - successCallback(fileUploadResult); - }; - - if (filePath === null || typeof filePath === 'undefined') { - error(FileTransferError.FILE_NOT_FOUND_ERR); - return; - } - - if (String(filePath).substr(0, 8) == "file:///") { - filePath = Windows.Storage.ApplicationData.current.localFolder.path + String(filePath).substr(8).split("/").join("\\"); - } - - Windows.Storage.StorageFile.getFileFromPathAsync(filePath).then(function (storageFile) { - storageFile.openAsync(Windows.Storage.FileAccessMode.read).then(function (stream) { - var blob = MSApp.createBlobFromRandomAccessStream(storageFile.contentType, stream); - var formData = new FormData(); - formData.append("source\";filename=\"" + storageFile.name + "\"", blob); - WinJS.xhr({ type: "POST", url: server, data: formData }).then(function (response) { - var code = response.status; - storageFile.getBasicPropertiesAsync().done(function (basicProperties) { - - Windows.Storage.FileIO.readBufferAsync(storageFile).done(function (buffer) { - var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer); - var fileContent = dataReader.readString(buffer.length); - dataReader.close(); - win(new FileUploadResult(basicProperties.size, code, fileContent)); - - }); - - }); - }, function () { - error(FileTransferError.INVALID_URL_ERR); - }); - }); - - },function(){error(FileTransferError.FILE_NOT_FOUND_ERR);}); - }, - - download:function(win, error, options) { - var source = options[0]; - var target = options[1]; - - - if (target === null || typeof target === undefined) { - error(FileTransferError.FILE_NOT_FOUND_ERR); - return; - } - if (String(target).substr(0, 8) == "file:///") { - target = Windows.Storage.ApplicationData.current.localFolder.path + String(target).substr(8).split("/").join("\\"); - } - var path = target.substr(0, String(target).lastIndexOf("\\")); - var fileName = target.substr(String(target).lastIndexOf("\\") + 1); - if (path === null || fileName === null) { - error(FileTransferError.FILE_NOT_FOUND_ERR); - return; - } - - var download = null; - - - Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(function (storageFolder) { - storageFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.generateUniqueName).then(function (storageFile) { - var uri = Windows.Foundation.Uri(source); - var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader(); - download = downloader.createDownload(uri, storageFile); - download.startAsync().then(function () { - win(new FileEntry(storageFile.name, storageFile.path)); - }, function () { - error(FileTransferError.INVALID_URL_ERR); - }); - }); - }); - } -}; - -require("cordova/commandProxy").add("FileTransfer",module.exports); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/MediaFile.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/MediaFile.js b/lib/windows8/plugin/windows8/MediaFile.js deleted file mode 100644 index 1709b9e..0000000 --- a/lib/windows8/plugin/windows8/MediaFile.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * 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. - * -*/ - -/*global Windows:true */ - -var MediaFileData = require('cordova/plugin/MediaFileData'); -var CaptureError = require('cordova/plugin/CaptureError'); - -module.exports = { - - getFormatData: function (successCallback, errorCallback, args) { - Windows.Storage.StorageFile.getFileFromPathAsync(this.fullPath).then( - function (storageFile) { - var mediaTypeFlag = String(storageFile.contentType).split("/")[0].toLowerCase(); - if (mediaTypeFlag === "audio") { - storageFile.properties.getMusicPropertiesAsync().then( - function (audioProperties) { - successCallback(new MediaFileData(null, audioProperties.bitrate, 0, 0, audioProperties.duration / 1000)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - } - ); - } else if (mediaTypeFlag === "video") { - storageFile.properties.getVideoPropertiesAsync().then( - function (videoProperties) { - successCallback(new MediaFileData(null, videoProperties.bitrate, videoProperties.height, videoProperties.width, videoProperties.duration / 1000)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - } - ); - } else if (mediaTypeFlag === "image") { - storageFile.properties.getImagePropertiesAsync().then( - function (imageProperties) { - successCallback(new MediaFileData(null, 0, imageProperties.height, imageProperties.width, 0)); - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - } - ); - } else { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - } - }, function () { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - } - ); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/MediaProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/MediaProxy.js b/lib/windows8/plugin/windows8/MediaProxy.js deleted file mode 100644 index 5b8e7ef..0000000 --- a/lib/windows8/plugin/windows8/MediaProxy.js +++ /dev/null @@ -1,183 +0,0 @@ -/* - * - * 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. - * -*/ - -/*global Windows:true */ - -var cordova = require('cordova'), - Media = require('cordova/plugin/Media'); - -var MediaError = require('cordova/plugin/MediaError'); - -module.exports = { - mediaCaptureMrg:null, - - // Initiates the audio file - create:function(win, lose, args) { - var id = args[0]; - var src = args[1]; - var thisM = Media.get(id); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STARTING); - - Media.prototype.node = null; - - var fn = src.split('.').pop(); // gets the file extension - if (thisM.node === null) { - if (fn === 'mp3' || fn === 'wma' || fn === 'wma' || - fn === 'cda' || fn === 'adx' || fn === 'wm' || - fn === 'm3u' || fn === 'wmx') { - thisM.node = new Audio(src); - thisM.node.load(); - var dur = thisM.node.duration; - if (isNaN(dur)) { - dur = -1; - } - Media.onStatus(id, Media.MEDIA_DURATION, dur); - } - else { - lose && lose({code:MediaError.MEDIA_ERR_ABORTED}); - } - } - }, - - // Start playing the audio - startPlayingAudio:function(win, lose, args) { - var id = args[0]; - //var src = args[1]; - //var options = args[2]; - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_RUNNING); - - (Media.get(id)).node.play(); - }, - - // Stops the playing audio - stopPlayingAudio:function(win, lose, args) { - var id = args[0]; - try { - (Media.get(id)).node.pause(); - (Media.get(id)).node.currentTime = 0; - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED); - win(); - } catch (err) { - lose("Failed to stop: "+err); - } - }, - - // Seeks to the position in the audio - seekToAudio:function(win, lose, args) { - var id = args[0]; - var milliseconds = args[1]; - try { - (Media.get(id)).node.currentTime = milliseconds / 1000; - win(); - } catch (err) { - lose("Failed to seek: "+err); - } - }, - - // Pauses the playing audio - pausePlayingAudio:function(win, lose, args) { - var id = args[0]; - var thisM = Media.get(id); - try { - thisM.node.pause(); - Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_PAUSED); - } catch (err) { - lose("Failed to pause: "+err); - } - }, - - // Gets current position in the audio - getCurrentPositionAudio:function(win, lose, args) { - var id = args[0]; - try { - var p = (Media.get(id)).node.currentTime; - Media.onStatus(id, Media.MEDIA_POSITION, p); - win(p); - } catch (err) { - lose(err); - } - }, - - // Start recording audio - startRecordingAudio:function(win, lose, args) { - var id = args[0]; - var src = args[1]; - // Initialize device - Media.prototype.mediaCaptureMgr = null; - var thisM = (Media.get(id)); - var captureInitSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings(); - captureInitSettings.streamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.audio; - thisM.mediaCaptureMgr = new Windows.Media.Capture.MediaCapture(); - thisM.mediaCaptureMgr.addEventListener("failed", lose); - - thisM.mediaCaptureMgr.initializeAsync(captureInitSettings).done(function (result) { - thisM.mediaCaptureMgr.addEventListener("recordlimitationexceeded", lose); - thisM.mediaCaptureMgr.addEventListener("failed", lose); - }, lose); - // Start recording - Windows.Storage.KnownFolders.musicLibrary.createFileAsync(src, Windows.Storage.CreationCollisionOption.replaceExisting).done(function (newFile) { - var storageFile = newFile; - var fileType = this.src.split('.').pop(); - var encodingProfile = null; - switch (fileType) { - case 'm4a': - encodingProfile = Windows.Media.MediaProperties.MediaEncodingProfile.createM4a(Windows.Media.MediaProperties.AudioEncodingQuality.auto); - break; - case 'mp3': - encodingProfile = Windows.Media.MediaProperties.MediaEncodingProfile.createMp3(Windows.Media.MediaProperties.AudioEncodingQuality.auto); - break; - case 'wma': - encodingProfile = Windows.Media.MediaProperties.MediaEncodingProfile.createWma(Windows.Media.MediaProperties.AudioEncodingQuality.auto); - break; - default: - lose("Invalid file type for record"); - break; - } - thisM.mediaCaptureMgr.startRecordToStorageFileAsync(encodingProfile, storageFile).done(win, lose); - }, lose); - }, - - // Stop recording audio - stopRecordingAudio:function(win, lose, args) { - var id = args[0]; - var thisM = Media.get(id); - thisM.mediaCaptureMgr.stopRecordAsync().done(win, lose); - }, - - // Release the media object - release:function(win, lose, args) { - var id = args[0]; - var thisM = Media.get(id); - try { - delete thisM.node; - } catch (err) { - lose("Failed to release: "+err); - } - }, - setVolume:function(win, lose, args) { - var id = args[0]; - var volume = args[1]; - var thisM = Media.get(id); - thisM.volume = volume; - } -}; - -require("cordova/commandProxy").add("Media",module.exports); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/NetworkStatusProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/NetworkStatusProxy.js b/lib/windows8/plugin/windows8/NetworkStatusProxy.js deleted file mode 100644 index f1ea02b..0000000 --- a/lib/windows8/plugin/windows8/NetworkStatusProxy.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * 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. - * -*/ - -/*global Windows:true */ - -var cordova = require('cordova'); -var Connection = require('cordova/plugin/Connection'); - -module.exports = { - - getConnectionInfo:function(win,fail,args) - { - console.log("NetworkStatusProxy::getConnectionInfo"); - var winNetConn = Windows.Networking.Connectivity; - var networkInfo = winNetConn.NetworkInformation; - var networkCostInfo = winNetConn.NetworkCostType; - var networkConnectivityInfo = winNetConn.NetworkConnectivityLevel; - var networkAuthenticationInfo = winNetConn.NetworkAuthenticationType; - var networkEncryptionInfo = winNetConn.NetworkEncryptionType; - - var connectionType; - - var profile = Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile(); - if(profile) { - var conLevel = profile.getNetworkConnectivityLevel(); - var interfaceType = profile.networkAdapter.ianaInterfaceType; - - if (conLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.none) { - connectionType = Connection.NONE; - } - else { - switch (interfaceType) { - case 71: - connectionType = Connection.WIFI; - break; - case 6: - connectionType = Connection.ETHERNET; - break; - case 243: // (3GPP WWAN) // Fallthrough is intentional - case 244: // (3GPP2 WWAN) - connectionType = Connection.CELL_3G; - break; - default: - connectionType = Connection.UNKNOWN; - break; - } - } - } - // FYI - //Connection.UNKNOWN 'Unknown connection'; - //Connection.ETHERNET 'Ethernet connection'; - //Connection.WIFI 'WiFi connection'; - //Connection.CELL_2G 'Cell 2G connection'; - //Connection.CELL_3G 'Cell 3G connection'; - //Connection.CELL_4G 'Cell 4G connection'; - //Connection.NONE 'No network connection'; - - setTimeout(function () { - if (connectionType) { - win(connectionType); - } else { - win(Connection.NONE); - } - },0); - } - -}; - -require("cordova/commandProxy").add("NetworkStatus",module.exports); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/NotificationProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/NotificationProxy.js b/lib/windows8/plugin/windows8/NotificationProxy.js deleted file mode 100644 index 5cfac61..0000000 --- a/lib/windows8/plugin/windows8/NotificationProxy.js +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * 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. - * -*/ - -/*global Windows:true */ - -var cordova = require('cordova'); - -var isAlertShowing = false; -var alertStack = []; - -module.exports = { - alert:function(win, loseX, args) { - - if (isAlertShowing) { - var later = function () { - module.exports.alert(win, loseX, args); - }; - alertStack.push(later); - return; - } - isAlertShowing = true; - - var message = args[0]; - var _title = args[1]; - var _buttonLabel = args[2]; - - var md = new Windows.UI.Popups.MessageDialog(message, _title); - md.commands.append(new Windows.UI.Popups.UICommand(_buttonLabel)); - md.showAsync().then(function() { - isAlertShowing = false; - win && win(); - - if (alertStack.length) { - setTimeout(alertStack.shift(), 0); - } - - }); - }, - - confirm:function(win, loseX, args) { - - if (isAlertShowing) { - var later = function () { - module.exports.confirm(win, loseX, args); - }; - alertStack.push(later); - return; - } - - isAlertShowing = true; - - var message = args[0]; - var _title = args[1]; - var _buttonLabels = args[2]; - - var btnList = []; - function commandHandler (command) { - win && win(btnList[command.label]); - } - - var md = new Windows.UI.Popups.MessageDialog(message, _title); - var button = _buttonLabels.split(','); - - for (var i = 0; i<button.length; i++) { - btnList[button[i]] = i+1; - md.commands.append(new Windows.UI.Popups.UICommand(button[i],commandHandler)); - } - md.showAsync().then(function() { - isAlertShowing = false; - if (alertStack.length) { - setTimeout(alertStack.shift(), 0); - } - - }); - }, - - vibrate:function(winX, loseX, args) { - var mills = args[0]; - - //... - }, - - beep:function(winX, loseX, args) { - var count = args[0]; - /* - var src = //filepath// - var playTime = 500; // ms - var quietTime = 1000; // ms - var media = new Media(src, function(){}); - var hit = 1; - var intervalId = window.setInterval( function () { - media.play(); - sleep(playTime); - media.stop(); - media.seekTo(0); - if (hit < count) { - hit++; - } else { - window.clearInterval(intervalId); - } - }, playTime + quietTime); */ - } -}; - -require("cordova/commandProxy").add("Notification",module.exports); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/console.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/console.js b/lib/windows8/plugin/windows8/console.js deleted file mode 100644 index a71a2c5..0000000 --- a/lib/windows8/plugin/windows8/console.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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. - * -*/ - - -if(!console || !console.log) -{ - var exec = require('cordova/exec'); - - var debugConsole = { - log:function(msg){ - exec(null,null,"DebugConsole","log",msg); - }, - warn:function(msg){ - exec(null,null,"DebugConsole","warn",msg); - }, - error:function(msg){ - exec(null,null,"DebugConsole","error",msg); - } - }; - - module.exports = debugConsole; -} -else if(console && console.log) { - - console.log("console.log exists already!"); - console.warn = console.warn || function(msg){console.log("warn:"+msg);}; - console.error = console.error || function(msg){console.log("error:"+msg);}; -} http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/console/symbols.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/console/symbols.js b/lib/windows8/plugin/windows8/console/symbols.js deleted file mode 100644 index c91f429..0000000 --- a/lib/windows8/plugin/windows8/console/symbols.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 modulemapper = require('cordova/modulemapper'); - -modulemapper.clobbers('cordova/plugin/windows8/console', 'navigator.console'); http://git-wip-us.apache.org/repos/asf/cordova-js/blob/da415064/lib/windows8/plugin/windows8/notification/plugininit.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/notification/plugininit.js b/lib/windows8/plugin/windows8/notification/plugininit.js deleted file mode 100644 index 38ba60f..0000000 --- a/lib/windows8/plugin/windows8/notification/plugininit.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - * -*/ - -window.alert = window.alert || require("cordova/plugin/notification").alert; -window.confirm = window.confirm || require("cordova/plugin/notification").confirm; -
