You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/06/25 01:55:38 UTC
[1/3] git commit: update location of Plugin objects
Updated Branches:
refs/heads/master 184d55f5a -> 4aab5f757
update location of Plugin objects
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/d023ed63
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/d023ed63
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/d023ed63
Branch: refs/heads/master
Commit: d023ed63e6edb4b844a656f6c9e9b2e1afb22f6c
Parents: 184d55f
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Jun 24 14:29:40 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Jun 24 14:29:40 2013 -0700
----------------------------------------------------------------------
wp8/framework/WPCordovaClassLib.csproj | 98 +++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/d023ed63/wp8/framework/WPCordovaClassLib.csproj
----------------------------------------------------------------------
diff --git a/wp8/framework/WPCordovaClassLib.csproj b/wp8/framework/WPCordovaClassLib.csproj
index d80e811..9667080 100644
--- a/wp8/framework/WPCordovaClassLib.csproj
+++ b/wp8/framework/WPCordovaClassLib.csproj
@@ -119,6 +119,84 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
+ <Compile Include="..\..\common\Plugins\Accelerometer.cs">
+ <Link>Plugins\Accelerometer.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\AudioFormatsHelper.cs">
+ <Link>Plugins\AudioFormatsHelper.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\AudioPlayer.cs">
+ <Link>Plugins\AudioPlayer.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Battery.cs">
+ <Link>Plugins\Battery.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Camera.cs">
+ <Link>Plugins\Camera.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Capture.cs">
+ <Link>Plugins\Capture.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Compass.cs">
+ <Link>Plugins\Compass.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Contacts.cs">
+ <Link>Plugins\Contacts.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\DebugConsole.cs">
+ <Link>Plugins\DebugConsole.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Device.cs">
+ <Link>Plugins\Device.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\File.cs">
+ <Link>Plugins\File.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\FileTransfer.cs">
+ <Link>Plugins\FileTransfer.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\GeoLocation.cs">
+ <Link>Plugins\GeoLocation.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Globalization.cs">
+ <Link>Plugins\Globalization.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\ImageExifHelper.cs">
+ <Link>Plugins\ImageExifHelper.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\InAppBrowser.cs">
+ <Link>Plugins\InAppBrowser.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Media.cs">
+ <Link>Plugins\Media.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\MimeTypeMapper.cs">
+ <Link>Plugins\MimeTypeMapper.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\NetworkStatus.cs">
+ <Link>Plugins\NetworkStatus.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\Notification.cs">
+ <Link>Plugins\Notification.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\UI\AudioCaptureTask.cs">
+ <Link>Plugins\UI\AudioCaptureTask.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\UI\AudioRecorder.xaml.cs">
+ <Link>Plugins\UI\AudioRecorder.xaml.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\UI\ImageCapture.xaml.cs">
+ <Link>Plugins\UI\ImageCapture.xaml.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\UI\NotificationBox.xaml.cs">
+ <Link>Plugins\UI\NotificationBox.xaml.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\UI\VideoCaptureTask.cs">
+ <Link>Plugins\UI\VideoCaptureTask.cs</Link>
+ </Compile>
+ <Compile Include="..\..\common\Plugins\UI\VideoRecorder.xaml.cs">
+ <Link>Plugins\UI\VideoRecorder.xaml.cs</Link>
+ </Compile>
<Compile Include="..\template\cordovalib\BrowserMouseHelper.cs">
<Link>CordovaLib\BrowserMouseHelper.cs</Link>
</Compile>
@@ -181,6 +259,26 @@
<Resource Include="resources\notification-beep.wav" />
</ItemGroup>
<ItemGroup>
+ <Page Include="..\..\common\Plugins\UI\AudioRecorder.xaml">
+ <Link>Plugins\UI\AudioRecorder.xaml</Link>
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Page Include="..\..\common\Plugins\UI\ImageCapture.xaml">
+ <Link>Plugins\UI\ImageCapture.xaml</Link>
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Page Include="..\..\common\Plugins\UI\NotificationBox.xaml">
+ <Link>Plugins\UI\NotificationBox.xaml</Link>
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Page Include="..\..\common\Plugins\UI\VideoRecorder.xaml">
+ <Link>Plugins\UI\VideoRecorder.xaml</Link>
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="..\template\cordovalib\CordovaView.xaml">
<Link>CordovaLib\CordovaView.xaml</Link>
<Generator>MSBuild:Compile</Generator>
[2/3] git commit: get rid of compiler warning
Posted by pu...@apache.org.
get rid of compiler warning
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/7efd80f4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/7efd80f4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/7efd80f4
Branch: refs/heads/master
Commit: 7efd80f43c7fbc65f7af47f8abb1d4fc3e13c557
Parents: d023ed6
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Jun 24 16:52:55 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Jun 24 16:52:55 2013 -0700
----------------------------------------------------------------------
common/Plugins/Notification.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/7efd80f4/common/Plugins/Notification.cs
----------------------------------------------------------------------
diff --git a/common/Plugins/Notification.cs b/common/Plugins/Notification.cs
index 6d4b93b..57262d2 100644
--- a/common/Plugins/Notification.cs
+++ b/common/Plugins/Notification.cs
@@ -36,8 +36,8 @@ namespace WPCordovaClassLib.Cordova.Commands
private class NotifBoxData
{
- public NotificationBox previous;
- public string callbackId;
+ public NotificationBox previous {get;set;}
+ public string callbackId { get; set; }
}
private PhoneApplicationPage Page
[3/3] git commit: [CB-3993] XHR is built into WP8,
no need for cordova-js to do it.
Posted by pu...@apache.org.
[CB-3993] XHR is built into WP8, no need for cordova-js to do it.
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/4aab5f75
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/4aab5f75
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/4aab5f75
Branch: refs/heads/master
Commit: 4aab5f75756c9998305b93a954663f5617746d9a
Parents: 7efd80f
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Jun 24 16:55:03 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Jun 24 16:55:03 2013 -0700
----------------------------------------------------------------------
wp8/framework/CordovaLib/XHRProxy.cs | 262 +++++++++++++++++++++++
wp8/framework/WPCordovaClassLib.csproj | 1 +
wp8/template/cordovalib/CordovaView.xaml.cs | 7 +
3 files changed, 270 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/4aab5f75/wp8/framework/CordovaLib/XHRProxy.cs
----------------------------------------------------------------------
diff --git a/wp8/framework/CordovaLib/XHRProxy.cs b/wp8/framework/CordovaLib/XHRProxy.cs
new file mode 100644
index 0000000..8a53f0b
--- /dev/null
+++ b/wp8/framework/CordovaLib/XHRProxy.cs
@@ -0,0 +1,262 @@
+using Microsoft.Phone.Controls;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.IO.IsolatedStorage;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace WPCordovaClassLib.CordovaLib
+{
+ public class XHRProxy
+ {
+
+ private WebBrowser webBrowser;
+
+ public XHRProxy(ref WebBrowser browser)
+ {
+ this.webBrowser = browser;
+ browser.ScriptNotify += browser_ScriptNotify;
+ browser.Navigated += browser_Navigated;
+ }
+
+ void browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
+ {
+
+
+ string script = @"(function(win, doc) {
+
+ var docDomain = null;
+ try {
+ docDomain = doc.domain;
+ } catch (err) {}
+
+ if (!docDomain || docDomain.length === 0) {
+
+ var aliasXHR = win.XMLHttpRequest;
+
+ var XHRShim = function() {};
+ win.XMLHttpRequest = XHRShim;
+ XHRShim.noConflict = aliasXHR;
+ XHRShim.UNSENT = 0;
+ XHRShim.OPENED = 1;
+ XHRShim.HEADERS_RECEIVED = 2;
+ XHRShim.LOADING = 3;
+ XHRShim.DONE = 4;
+ XHRShim.prototype = {
+ isAsync: false,
+ onreadystatechange: null,
+ readyState: 0,
+ _url: '',
+ timeout: 0,
+ withCredentials: false,
+ _requestHeaders: null,
+ open: function (reqType, uri, isAsync, user, password) {
+
+ if (uri && uri.indexOf('http') === 0) {
+ if (!this.wrappedXHR) {
+ this.wrappedXHR = new aliasXHR();
+ var self = this;
+ if (this.timeout > 0) {
+ this.wrappedXHR.timeout = this.timeout;
+ }
+ Object.defineProperty(this, 'timeout', {
+ set: function(val) {
+ this.wrappedXHR.timeout = val;
+ },
+ get: function() {
+ return this.wrappedXHR.timeout;
+ }
+ });
+ if (this.withCredentials) {
+ this.wrappedXHR.withCredentials = this.withCredentials;
+ }
+ Object.defineProperty(this, 'withCredentials', {
+ set: function(val) {
+ this.wrappedXHR.withCredentials = val;
+ },
+ get: function() {
+ return this.wrappedXHR.withCredentials;
+ }
+ });
+ Object.defineProperty(this, 'status', {
+ get: function() {
+ return this.wrappedXHR.status;
+ }
+ });
+ Object.defineProperty(this, 'responseText', {
+ get: function() {
+ return this.wrappedXHR.responseText;
+ }
+ });
+ Object.defineProperty(this, 'statusText', {
+ get: function() {
+ return this.wrappedXHR.statusText;
+ }
+ });
+ Object.defineProperty(this, 'responseXML', {
+ get: function() {
+ return this.wrappedXHR.responseXML;
+ }
+ });
+ this.getResponseHeader = function(header) {
+ return this.wrappedXHR.getResponseHeader(header);
+ };
+ this.getAllResponseHeaders = function() {
+ return this.wrappedXHR.getAllResponseHeaders();
+ };
+ this.wrappedXHR.onreadystatechange = function() {
+ self.changeReadyState(self.wrappedXHR.readyState);
+ };
+ }
+ return this.wrappedXHR.open(reqType, uri, isAsync, user, password);
+ }
+ else
+ {
+ this.isAsync = isAsync;
+ this.reqType = reqType;
+ var newUrl = uri;
+ this._url = newUrl;
+ }
+ },
+ statusText: '',
+ changeReadyState: function(newState) {
+ this.readyState = newState;
+ if (this.onreadystatechange) {
+ this.onreadystatechange();
+ }
+ },
+ setRequestHeader: function(header, value) {
+ if (this.wrappedXHR) {
+ this.wrappedXHR.setRequestHeader(header, value);
+ }
+ },
+ getResponseHeader: function(header) {
+ return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : '';
+ },
+ getAllResponseHeaders: function() {
+ return this.wrappedXHR ? this.wrappedXHR.getAllResponseHeaders() : '';
+ },
+ responseText: '',
+ responseXML: '',
+ onResult: function(res) {
+ this.status = 200;
+ if (typeof res == 'object') {
+ res = JSON.stringify(res);
+ }
+ this.responseText = res;
+ this.responseXML = res;
+ this.changeReadyState(XHRShim.DONE);
+ },
+ onError: function(err) {
+ this.status = 404;
+ this.changeReadyState(XHRShim.DONE);
+ },
+ abort: function() {
+ if (this.wrappedXHR) {
+ return this.wrappedXHR.abort();
+ }
+ },
+ send: function(data) {
+ if (this.wrappedXHR) {
+ return this.wrappedXHR.send(data);
+ }
+ else {
+ this.changeReadyState(XHRShim.OPENED);
+ var alias = this;
+ var funk = function () {
+ window.__onXHRLocalCallback = function (responseCode, responseText) {
+ alias.status = responseCode;
+ if (responseCode == '200') {
+ alias.responseText = responseText;
+ }
+ else {
+ alias.onerror && alias.onerror(responseCode);
+ }
+
+ alias.changeReadyState(XHRShim.DONE);
+ alias.onload && alias.onload();
+
+ }
+ alias.changeReadyState(XHRShim.LOADING);
+ window.external.Notify('XHRLOCAL/' + alias._url);
+ }
+ if (this.isAsync) {
+ setTimeout(funk, 0);
+ }
+ else {
+ funk();
+ }
+ }
+ },
+ getContentLocation: function() {
+ if (window.contentLocation === undefined) {
+ window.contentLocation = navigator.userAgent.toUpperCase().indexOf('MSIE 10') > -1 ? this.contentLocation.RESOURCES : this.contentLocation.ISOLATED_STORAGE;
+ }
+ return window.contentLocation;
+ },
+ contentLocation: {
+ ISOLATED_STORAGE: 0,
+ RESOURCES: 1
+ },
+ status: 404
+ };
+ }
+})(window, document); ";
+
+
+ webBrowser.InvokeScript("execScript", new string[] { script });
+
+
+ }
+
+ void browser_ScriptNotify(object sender, NotifyEventArgs e)
+ {
+ Debug.WriteLine("ScriptNotify::" + e.Value);
+ string commandStr = e.Value;
+
+ if (commandStr.IndexOf("XHRLOCAL") == 0)
+ {
+ string url = commandStr.Replace("XHRLOCAL/", "");
+
+ Uri uri = new Uri(url, UriKind.RelativeOrAbsolute);
+
+ using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
+ {
+ if (isoFile.FileExists(uri.AbsolutePath))
+ {
+ using (TextReader reader = new StreamReader(isoFile.OpenFile(uri.AbsolutePath, FileMode.Open, FileAccess.Read)))
+ {
+ string text = reader.ReadToEnd();
+ webBrowser.InvokeScript("__onXHRLocalCallback", new string[] { "200", text });
+ return;
+ }
+ }
+ }
+
+ Uri relUri = new Uri(uri.AbsolutePath,UriKind.Relative);
+
+ var resource = Application.GetResourceStream(relUri);
+
+ if (resource == null)
+ {
+ // 404 ?
+ webBrowser.InvokeScript("__onXHRLocalCallback", new string[] { "404" });
+ return;
+ }
+ else
+ {
+ using (StreamReader streamReader = new StreamReader(resource.Stream))
+ {
+ string text = streamReader.ReadToEnd();
+ webBrowser.InvokeScript("__onXHRLocalCallback", new string[] { "200", text });
+ return;
+ }
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/4aab5f75/wp8/framework/WPCordovaClassLib.csproj
----------------------------------------------------------------------
diff --git a/wp8/framework/WPCordovaClassLib.csproj b/wp8/framework/WPCordovaClassLib.csproj
index 9667080..a1b4dbb 100644
--- a/wp8/framework/WPCordovaClassLib.csproj
+++ b/wp8/framework/WPCordovaClassLib.csproj
@@ -230,6 +230,7 @@
<Compile Include="..\template\cordovalib\ScriptCallback.cs">
<Link>CordovaLib\ScriptCallback.cs</Link>
</Compile>
+ <Compile Include="CordovaLib\XHRProxy.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/4aab5f75/wp8/template/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CordovaView.xaml.cs b/wp8/template/cordovalib/CordovaView.xaml.cs
index 791b23c..0b27fea 100644
--- a/wp8/template/cordovalib/CordovaView.xaml.cs
+++ b/wp8/template/cordovalib/CordovaView.xaml.cs
@@ -75,6 +75,7 @@ namespace WPCordovaClassLib
protected BrowserMouseHelper bmHelper;
protected OrientationHelper orientationHelper;
+ protected XHRProxy xhrProxy;
private ConfigHandler configHandler;
@@ -176,6 +177,7 @@ namespace WPCordovaClassLib
nativeExecution = new NativeExecution(ref this.CordovaBrowser);
bmHelper = new BrowserMouseHelper(ref this.CordovaBrowser);
+ xhrProxy = new XHRProxy(ref this.CordovaBrowser);
}
@@ -443,6 +445,11 @@ namespace WPCordovaClassLib
this.orientationHelper.HandleCommand(commandStr);
return;
}
+ else if (commandStr.IndexOf("XHRLOCAL") == 0)
+ {
+ // XHRProxy listens for this itself
+ return;
+ }
CordovaCommandCall commandCallParams = CordovaCommandCall.Parse(commandStr);