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/05/09 08:14:52 UTC
[01/11] git commit: update to fix concurrent api calls issue
Updated Branches:
refs/heads/master aee42fae0 -> 9f0d74c12
update to fix concurrent api calls issue
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/9b532e67
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/9b532e67
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/9b532e67
Branch: refs/heads/master
Commit: 9b532e6757b750949a1c9de13b14af9b51415adf
Parents: aee42fa
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 30 13:56:34 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 30 13:56:34 2013 -0700
----------------------------------------------------------------------
.../standalone/cordovalib/Commands/BaseCommand.cs | 67 ++++++++++-----
templates/standalone/cordovalib/ConfigHandler.cs | 15 ++--
.../standalone/cordovalib/CordovaCommandCall.cs | 15 +++-
templates/standalone/cordovalib/NativeExecution.cs | 28 ++++--
templates/standalone/cordovalib/PluginResult.cs | 2 +
5 files changed, 88 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/9b532e67/templates/standalone/cordovalib/Commands/BaseCommand.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/Commands/BaseCommand.cs b/templates/standalone/cordovalib/Commands/BaseCommand.cs
index 43f5d90..c390047 100644
--- a/templates/standalone/cordovalib/Commands/BaseCommand.cs
+++ b/templates/standalone/cordovalib/Commands/BaseCommand.cs
@@ -16,6 +16,8 @@ using System;
using System.Reflection;
using Microsoft.Phone.Shell;
using System.Diagnostics;
+using System.Collections;
+using System.Collections.Generic;
namespace WPCordovaClassLib.Cordova.Commands
{
@@ -30,17 +32,37 @@ namespace WPCordovaClassLib.Cordova.Commands
public event EventHandler<ScriptCallback> OnCustomScript;
+ public string CurrentCommandCallbackId { get; set; }
+
public BaseCommand()
{
+ ResultHandlers = new Dictionary<string, EventHandler<PluginResult>>();
PhoneApplicationService service = PhoneApplicationService.Current;
service.Activated += this.OnResume;
service.Deactivated += this.OnPause;
}
+ protected Dictionary<string, EventHandler<PluginResult>> ResultHandlers;
+ public void AddResultHandler(string callbackId, EventHandler<PluginResult> handler)
+ {
+ ResultHandlers.Add(callbackId, handler);
+ }
+ public bool RemoveResultHandler(string callbackId)
+ {
+ return ResultHandlers.Remove(callbackId);
+ }
+
/*
* InvokeMethodNamed will call the named method of a BaseCommand subclass if it exists and pass the variable arguments list along.
**/
+ public object InvokeMethodNamed(string callbackId, string methodName, params object[] args)
+ {
+ Debug.WriteLine(string.Format("InvokeMethodNamed:{0} callbackId:{1}",methodName,callbackId));
+ this.CurrentCommandCallbackId = callbackId;
+ return InvokeMethodNamed(methodName, args);
+ }
+
public object InvokeMethodNamed(string methodName, params object[] args)
{
MethodInfo mInfo = this.GetType().GetMethod(methodName);
@@ -58,7 +80,6 @@ namespace WPCordovaClassLib.Cordova.Commands
PropertyInfo pInfo = this.GetType().GetProperty(methodName);
if (pInfo != null)
{
-
object res = pInfo.GetValue(this, null);
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
@@ -89,51 +110,55 @@ namespace WPCordovaClassLib.Cordova.Commands
this.DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
}
- public void DispatchCommandResult(PluginResult result)
+ public void DispatchCommandResult(PluginResult result,string callbackId="")
{
- if (this.OnCommandResult != null)
+ if (!string.IsNullOrEmpty(callbackId))
+ {
+ result.CallbackId = callbackId;
+ }
+ else
{
- this.OnCommandResult(this, result);
+ result.CallbackId = this.CurrentCommandCallbackId;
+ }
- if (!result.KeepCallback)
- {
- this.Dispose();
- }
+ if (ResultHandlers.ContainsKey(result.CallbackId))
+ {
+ ResultHandlers[result.CallbackId](this, result);
+ }
+ else if (this.OnCommandResult != null)
+ {
+ OnCommandResult(this, result);
+ }
+ if (!result.KeepCallback)
+ {
+ this.Dispose();
}
+
}
/// <summary>
/// Occurs when the application is being deactivated.
/// </summary>
- public virtual void OnReset()
- {
- }
+ public virtual void OnReset() {}
/// <summary>
/// Occurs when the application is being loaded, and the config.xml has an autoload entry
/// </summary>
- public virtual void OnInit()
- {
-
- }
+ public virtual void OnInit() {}
/// <summary>
/// Occurs when the application is being deactivated.
/// </summary>
- public virtual void OnPause(object sender, DeactivatedEventArgs e)
- {
- }
+ public virtual void OnPause(object sender, DeactivatedEventArgs e) {}
/// <summary>
/// Occurs when the application is being made active after previously being put
/// into a dormant state or tombstoned.
/// </summary>
- public virtual void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
- {
- }
+ public virtual void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e) {}
public void Dispose()
{
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/9b532e67/templates/standalone/cordovalib/ConfigHandler.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/ConfigHandler.cs b/templates/standalone/cordovalib/ConfigHandler.cs
index 0684f6a..06806d3 100644
--- a/templates/standalone/cordovalib/ConfigHandler.cs
+++ b/templates/standalone/cordovalib/ConfigHandler.cs
@@ -44,7 +44,7 @@ namespace WPCordovaClassLib.CordovaLib
return Preferences[key];
}
- protected static string[] AllowedSchemes = {"http","https","ftp","ftps"};
+ protected static string[] AllowedSchemes = { "http", "https", "ftp", "ftps" };
protected bool SchemeIsAllowed(string scheme)
{
return AllowedSchemes.Contains(scheme);
@@ -110,14 +110,14 @@ namespace WPCordovaClassLib.CordovaLib
{
// Debug.WriteLine("Testing URLIsAllowed : " + url);
// easy case first
- if (this.AllowAllDomains )
+ if (this.AllowAllDomains)
{
return true;
}
else
{
// start simple
- Uri uri = new Uri(url,UriKind.RelativeOrAbsolute);
+ Uri uri = new Uri(url, UriKind.RelativeOrAbsolute);
if (uri.IsAbsoluteUri)
{
if (this.SchemeIsAllowed(uri.Scheme))
@@ -134,7 +134,7 @@ namespace WPCordovaClassLib.CordovaLib
{
// make sure it is at the start, and not part of the query string
// special case :: http://some.other.domain/page.html?x=1&g=http://build.apache.org/
- if ( Regex.IsMatch(uri.Scheme + "://" + uri.Host + "/", pattern) ||
+ if (Regex.IsMatch(uri.Scheme + "://" + uri.Host + "/", pattern) ||
(!Regex.IsMatch(uri.PathAndQuery, pattern)))
{
return true;
@@ -156,13 +156,14 @@ namespace WPCordovaClassLib.CordovaLib
return AllowAllPlugins || AllowedPlugins.Keys.Contains(key);
}
- public string[] AutoloadPlugins {
+ public string[] AutoloadPlugins
+ {
get
{
var res = from results in AllowedPlugins.TakeWhile(p => p.Value.isAutoLoad)
- select results.Value.Name ;
+ select results.Value.Name;
- foreach(var s in res)
+ foreach (var s in res)
{
Debug.WriteLine(s);
}
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/9b532e67/templates/standalone/cordovalib/CordovaCommandCall.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/CordovaCommandCall.cs b/templates/standalone/cordovalib/CordovaCommandCall.cs
index 084fd2c..a73ac68 100644
--- a/templates/standalone/cordovalib/CordovaCommandCall.cs
+++ b/templates/standalone/cordovalib/CordovaCommandCall.cs
@@ -56,12 +56,23 @@ namespace WPCordovaClassLib.Cordova
}
CordovaCommandCall commandCallParameters = new CordovaCommandCall();
-
commandCallParameters.Service = split[0];
commandCallParameters.Action = split[1];
commandCallParameters.CallbackId = split[2];
- commandCallParameters.Args = split.Length <= 3 ? String.Empty : String.Join("/", split.Skip(3));
+
+ try
+ {
+ string arg = split.Length <= 3 ? String.Empty : String.Join("/", split.Skip(3));
+ //string[] _args = JSON.JsonHelper.Deserialize<string[]>(arg);
+ System.Collections.Generic.List<string> args = JSON.JsonHelper.Deserialize<System.Collections.Generic.List<string>>(arg);
+ args.Add(commandCallParameters.CallbackId);
+ commandCallParameters.Args = JSON.JsonHelper.Serialize(args.ToArray());
+ }
+ catch (Exception)
+ {
+ return null;
+ }
// sanity check for illegal names
// was failing with ::
// CordovaCommandResult :: 1, Device1, {"status":1,"message":"{\"name\":\"XD.....
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/9b532e67/templates/standalone/cordovalib/NativeExecution.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/NativeExecution.cs b/templates/standalone/cordovalib/NativeExecution.cs
index 8d56225..af6b207 100644
--- a/templates/standalone/cordovalib/NativeExecution.cs
+++ b/templates/standalone/cordovalib/NativeExecution.cs
@@ -95,36 +95,40 @@ namespace WPCordovaClassLib.Cordova
EventHandler<PluginResult> OnCommandResultHandler = delegate(object o, PluginResult res)
{
- this.OnCommandResult(commandCallParams.CallbackId, res);
+ if (res.CallbackId == null || res.CallbackId == commandCallParams.CallbackId)
+ {
+ this.OnCommandResult(commandCallParams.CallbackId, res);
+ if (!res.KeepCallback)
+ {
+ bc.RemoveResultHandler(commandCallParams.CallbackId);
+ }
+ }
};
- bc.OnCommandResult += OnCommandResultHandler;
+ //bc.OnCommandResult += OnCommandResultHandler;
+ bc.AddResultHandler(commandCallParams.CallbackId, OnCommandResultHandler);
EventHandler<ScriptCallback> OnCustomScriptHandler = delegate(object o, ScriptCallback script)
{
this.InvokeScriptCallback(script);
};
-
bc.OnCustomScript += OnCustomScriptHandler;
ThreadStart methodInvokation = () =>
{
-
try
{
- bc.InvokeMethodNamed(commandCallParams.Action, commandCallParams.Args);
+ bc.InvokeMethodNamed(commandCallParams.CallbackId,commandCallParams.Action, commandCallParams.Args);
}
catch (Exception ex)
{
Debug.WriteLine("ERROR: Exception in ProcessCommand :: " + ex.Message);
- bc.OnCommandResult -= OnCommandResultHandler;
+ bc.RemoveResultHandler(commandCallParams.CallbackId);
bc.OnCustomScript -= OnCustomScriptHandler;
Debug.WriteLine("ERROR: failed to InvokeMethodNamed :: " + commandCallParams.Action + " on Object :: " + commandCallParams.Service);
-
this.OnCommandResult(commandCallParams.CallbackId, new PluginResult(PluginResult.Status.INVALID_ACTION));
-
return;
}
};
@@ -140,7 +144,7 @@ namespace WPCordovaClassLib.Cordova
new Thread(methodInvokation).Start();
}
-
+
}
catch (Exception ex)
{
@@ -174,6 +178,12 @@ namespace WPCordovaClassLib.Cordova
return;
}
+ if (!String.IsNullOrEmpty(result.CallbackId) && callbackId != result.CallbackId)
+ {
+ Debug.WriteLine("Multiple Overlapping Results :: " + result.CallbackId + " :: " + callbackId);
+ return;
+ }
+
#endregion
string jsonResult = result.ToJSONString();
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/9b532e67/templates/standalone/cordovalib/PluginResult.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/PluginResult.cs b/templates/standalone/cordovalib/PluginResult.cs
index e6d0c56..00017d2 100644
--- a/templates/standalone/cordovalib/PluginResult.cs
+++ b/templates/standalone/cordovalib/PluginResult.cs
@@ -69,6 +69,7 @@ namespace WPCordovaClassLib.Cordova
public Status Result { get; private set; }
public string Message { get; set; }
public bool KeepCallback { get; set; }
+ public string CallbackId { get; set; }
/// <summary>
/// Whether command succeded or not
@@ -113,6 +114,7 @@ namespace WPCordovaClassLib.Cordova
}
+ [Obsolete]
public string ToCallbackString(string callbackId, string successCallback, string errorCallback)
{
if (this.IsSuccess)
[07/11] git commit: command deserialization tweaks,
massage it if we can
Posted by pu...@apache.org.
command deserialization tweaks, massage it if we can
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/68a09337
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/68a09337
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/68a09337
Branch: refs/heads/master
Commit: 68a093379254f2fd505e1033d44ff1e1b3de7e61
Parents: a3b381b
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed May 1 00:12:20 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed May 1 00:24:21 2013 -0700
----------------------------------------------------------------------
.../standalone/cordovalib/CordovaCommandCall.cs | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/68a09337/templates/standalone/cordovalib/CordovaCommandCall.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/CordovaCommandCall.cs b/templates/standalone/cordovalib/CordovaCommandCall.cs
index a73ac68..810f5e2 100644
--- a/templates/standalone/cordovalib/CordovaCommandCall.cs
+++ b/templates/standalone/cordovalib/CordovaCommandCall.cs
@@ -23,6 +23,7 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
+using System.Collections.Generic;
namespace WPCordovaClassLib.Cordova
{
@@ -46,7 +47,6 @@ namespace WPCordovaClassLib.Cordova
if (string.IsNullOrEmpty(commandStr))
{
return null;
- //throw new ArgumentNullException("commandStr");
}
string[] split = commandStr.Split('/');
@@ -60,12 +60,14 @@ namespace WPCordovaClassLib.Cordova
commandCallParameters.Action = split[1];
commandCallParameters.CallbackId = split[2];
-
try
{
- string arg = split.Length <= 3 ? String.Empty : String.Join("/", split.Skip(3));
- //string[] _args = JSON.JsonHelper.Deserialize<string[]>(arg);
- System.Collections.Generic.List<string> args = JSON.JsonHelper.Deserialize<System.Collections.Generic.List<string>>(arg);
+ string arg = split.Length <= 3 ? "[]" : String.Join("/", split.Skip(3));
+ if (!arg.StartsWith("[")) // save the exception
+ {
+ arg = string.Format("[{0}]", arg);
+ }
+ List<string> args = JSON.JsonHelper.Deserialize<List<string>>(arg);
args.Add(commandCallParameters.CallbackId);
commandCallParameters.Args = JSON.JsonHelper.Serialize(args.ToArray());
}
@@ -81,7 +83,6 @@ namespace WPCordovaClassLib.Cordova
return null;
}
-
return commandCallParameters;
}
[02/11] git commit: removed debug console output
Posted by pu...@apache.org.
removed debug console output
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/30d24d87
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/30d24d87
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/30d24d87
Branch: refs/heads/master
Commit: 30d24d877570865c58e62a4cb3fc6dd2593e29ba
Parents: 9b532e6
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 30 13:58:56 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 30 13:58:56 2013 -0700
----------------------------------------------------------------------
.../standalone/cordovalib/Commands/BaseCommand.cs | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/30d24d87/templates/standalone/cordovalib/Commands/BaseCommand.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/Commands/BaseCommand.cs b/templates/standalone/cordovalib/Commands/BaseCommand.cs
index c390047..fd5d595 100644
--- a/templates/standalone/cordovalib/Commands/BaseCommand.cs
+++ b/templates/standalone/cordovalib/Commands/BaseCommand.cs
@@ -58,7 +58,6 @@ namespace WPCordovaClassLib.Cordova.Commands
public object InvokeMethodNamed(string callbackId, string methodName, params object[] args)
{
- Debug.WriteLine(string.Format("InvokeMethodNamed:{0} callbackId:{1}",methodName,callbackId));
this.CurrentCommandCallbackId = callbackId;
return InvokeMethodNamed(methodName, args);
}
[10/11] git commit: confirm maintains callbackId - was crashing on
overlaps
Posted by pu...@apache.org.
confirm maintains callbackId - was crashing on overlaps
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/d240aa69
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/d240aa69
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/d240aa69
Branch: refs/heads/master
Commit: d240aa696010cf6278c38938d049a0bae52e85a6
Parents: da5bce6
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed May 8 00:09:39 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed May 8 00:09:39 2013 -0700
----------------------------------------------------------------------
templates/standalone/Plugins/Notification.cs | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/d240aa69/templates/standalone/Plugins/Notification.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/Notification.cs b/templates/standalone/Plugins/Notification.cs
index 17825c8..0759c72 100644
--- a/templates/standalone/Plugins/Notification.cs
+++ b/templates/standalone/Plugins/Notification.cs
@@ -88,10 +88,7 @@ namespace WPCordovaClassLib.Cordova.Commands
alertOpts.message = args[0];
alertOpts.title = args[1];
alertOpts.buttonLabel = args[2];
-
- //Debug.WriteLine("this.CurrentCommandCallbackId = " + this.CurrentCommandCallbackId);
-
- string aliasCurrentCommandCallbackId = args[args.Length - 1];// this.CurrentCommandCallbackId; // it may change by the time the new thread invokes
+ string aliasCurrentCommandCallbackId = args[3];
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
@@ -128,14 +125,15 @@ namespace WPCordovaClassLib.Cordova.Commands
public void confirm(string options)
{
+ string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
+ AlertOptions alertOpts = new AlertOptions();
+ alertOpts.message = args[0];
+ alertOpts.title = args[1];
+ alertOpts.buttonLabel = args[2];
+ string aliasCurrentCommandCallbackId = args[3];
+
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- AlertOptions alertOpts = new AlertOptions();
- alertOpts.message = args[0];
- alertOpts.title = args[1];
- alertOpts.buttonLabel = args[2];
-
PhoneApplicationPage page = Page;
if (page != null)
{
@@ -144,7 +142,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
var previous = notifyBox;
notifyBox = new NotificationBox();
- notifyBox.Tag = previous;
+ notifyBox.Tag = new { previous = previous, callbackId = aliasCurrentCommandCallbackId };
notifyBox.PageTitle.Text = alertOpts.title;
notifyBox.SubTitle.Text = alertOpts.message;
[09/11] git commit: All calls keep their own callback id to resolve
concurrency issues. Added slice methods and byteArray binaryString methods.
Posted by pu...@apache.org.
All calls keep their own callback id to resolve concurrency issues. Added slice methods and byteArray binaryString methods.
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/da5bce69
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/da5bce69
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/da5bce69
Branch: refs/heads/master
Commit: da5bce69fefd6260558850dae62ea0fb98209263
Parents: 1541ae0
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed May 8 00:00:59 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed May 8 00:00:59 2013 -0700
----------------------------------------------------------------------
templates/standalone/Plugins/File.cs | 398 ++++++++++++++++-------------
1 files changed, 224 insertions(+), 174 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/da5bce69/templates/standalone/Plugins/File.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/File.cs b/templates/standalone/Plugins/File.cs
index 3c0aaf8..cde7a1c 100644
--- a/templates/standalone/Plugins/File.cs
+++ b/templates/standalone/Plugins/File.cs
@@ -14,14 +14,14 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.IO.IsolatedStorage;
using System.Runtime.Serialization;
using System.Security;
using System.Text;
-using System.Diagnostics;
-using System.Windows.Resources;
using System.Windows;
+using System.Windows.Resources;
namespace WPCordovaClassLib.Cordova.Commands
{
@@ -335,18 +335,6 @@ namespace WPCordovaClassLib.Cordova.Commands
return entry;
}
- //public static FileEntry GetEntry(Uri uri)
- //{
- // FileEntry entry = null;
- // //try
- // //{
- // // this.Name = Path.GetFileName(uri.OriginalString);
- // // entry = new FileEntry(uri.OriginalString);
- // // entry
- // //}
- // return entry;
- //}
-
/// <summary>
/// Creates object and sets necessary properties
/// </summary>
@@ -477,38 +465,19 @@ namespace WPCordovaClassLib.Cordova.Commands
}
- /// <summary>
- /// File options
- /// </summary>
- private FileOptions fileOptions;
-
- private bool LoadFileOptions(string options)
- {
- try
- {
- fileOptions = JSON.JsonHelper.Deserialize<FileOptions>(options);
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
- return false;
- }
- return true;
- }
-
// returns null value if it fails.
- private string getSingleStringOption(string options)
+ private string[] getOptionStrings(string options)
{
- string result = null;
+ string[] optStings = null;
try
{
- result = JSON.JsonHelper.Deserialize<string[]>(options)[0];
+ optStings = JSON.JsonHelper.Deserialize<string[]>(options);
}
catch (Exception)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION), CurrentCommandCallbackId);
}
- return result;
+ return optStings;
}
/// <summary>
@@ -517,22 +486,24 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <param name="options">No options is needed for this method</param>
public void getFreeDiskSpace(string options)
{
+ string callbackId = getOptionStrings(options)[0];
+
try
{
using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, isoFile.AvailableFreeSpace));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, isoFile.AvailableFreeSpace), callbackId);
}
}
catch (IsolatedStorageException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
catch (Exception ex)
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
@@ -562,9 +533,14 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <param name="isDirectory">Flag to recognize what we should check</param>
public void IsDirectoryOrFileExist(string options, bool isDirectory)
{
- if (!LoadFileOptions(options))
+ string[] args = getOptionStrings(options);
+ string callbackId = args[1];
+ FileOptions fileOptions = JSON.JsonHelper.Deserialize<FileOptions>(args[0]);
+ string filePath = args[0];
+
+ if (fileOptions == null)
{
- return;
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION), callbackId);
}
try
@@ -580,18 +556,18 @@ namespace WPCordovaClassLib.Cordova.Commands
{
isExist = isoFile.FileExists(fileOptions.FilePath);
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, isExist));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, isExist), callbackId);
}
}
catch (IsolatedStorageException) // default handler throws INVALID_MODIFICATION_ERR
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
catch (Exception ex)
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
}
}
@@ -599,8 +575,12 @@ namespace WPCordovaClassLib.Cordova.Commands
public void readAsDataURL(string options)
{
- // exception+PluginResult are handled by getSingleStringOptions
- string filePath = getSingleStringOption(options);
+ string[] optStrings = getOptionStrings(options);
+ string filePath = optStrings[0];
+ int startPos = int.Parse(optStrings[1]);
+ int endPos = int.Parse(optStrings[2]);
+ string callbackId = optStrings[3];
+
if (filePath != null)
{
try
@@ -611,7 +591,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (!isoFile.FileExists(filePath))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
return;
}
string mimeType = MimeTypeMapper.GetMimeType(filePath);
@@ -623,34 +603,55 @@ namespace WPCordovaClassLib.Cordova.Commands
}
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, base64URL));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, base64URL), callbackId);
}
catch (Exception ex)
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
}
+ public void readAsArrayBuffer(string options)
+ {
+ string[] optStrings = getOptionStrings(options);
+ string filePath = optStrings[0];
+ int startPos = int.Parse(optStrings[1]);
+ int endPos = int.Parse(optStrings[2]);
+ string callbackId = optStrings[3];
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR), callbackId);
+ }
+
+ public void readAsBinaryString(string options)
+ {
+ string[] optStrings = getOptionStrings(options);
+ string filePath = optStrings[0];
+ int startPos = int.Parse(optStrings[1]);
+ int endPos = int.Parse(optStrings[2]);
+ string callbackId = optStrings[3];
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR), callbackId);
+ }
+
public void readAsText(string options)
{
- // TODO: try/catch
- string[] optStrings = JSON.JsonHelper.Deserialize<string[]>(options);
+ string[] optStrings = getOptionStrings(options);
string filePath = optStrings[0];
string encStr = optStrings[1];
+ int startPos = int.Parse(optStrings[2]);
+ int endPos = int.Parse(optStrings[3]);
+ string callbackId = optStrings[4];
try
{
- string text;
+ string text = "";
using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!isoFile.FileExists(filePath))
{
- //DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
readResourceAsText(options);
return;
}
@@ -659,16 +660,37 @@ namespace WPCordovaClassLib.Cordova.Commands
using (TextReader reader = new StreamReader(isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read), encoding))
{
text = reader.ReadToEnd();
+ if (startPos < 0)
+ {
+ startPos = Math.Max(text.Length + startPos, 0);
+ }
+ else if (startPos > 0)
+ {
+ startPos = Math.Min(text.Length, startPos);
+ }
+
+ if (endPos > 0)
+ {
+ endPos = Math.Min(text.Length, endPos);
+ }
+ else if (endPos < 0)
+ {
+ endPos = Math.Max(endPos + text.Length, 0);
+ }
+
+
+ text = text.Substring(startPos, endPos - startPos);
+
}
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, text));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, text), callbackId);
}
catch (Exception ex)
{
- if (!this.HandleException(ex))
+ if (!this.HandleException(ex, callbackId))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
@@ -679,18 +701,13 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <param name="options">Path to a resource</param>
public void readResourceAsText(string options)
{
- string pathToResource;
- try
- {
- string[] optStrings = JSON.JsonHelper.Deserialize<string[]>(options);
- pathToResource = optStrings[0];
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
- return;
- }
-
+ string[] optStrings = getOptionStrings(options);
+ string pathToResource = optStrings[0];
+ string encStr = optStrings[1];
+ int start = int.Parse(optStrings[2]);
+ int endMarker = int.Parse(optStrings[3]);
+ string callbackId = optStrings[4];
+
try
{
if (pathToResource.StartsWith("/"))
@@ -702,32 +719,32 @@ namespace WPCordovaClassLib.Cordova.Commands
if (resource == null)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
return;
}
string text;
StreamReader streamReader = new StreamReader(resource.Stream);
text = streamReader.ReadToEnd();
-
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, text));
+
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, text), callbackId);
}
catch (Exception ex)
{
- if (!this.HandleException(ex))
+ if (!this.HandleException(ex, callbackId))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
public void truncate(string options)
{
- // TODO: try/catch
- string[] optStrings = JSON.JsonHelper.Deserialize<string[]>(options);
+ string[] optStrings = getOptionStrings(options);
string filePath = optStrings[0];
int size = int.Parse(optStrings[1]);
+ string callbackId = optStrings[2];
try
{
@@ -737,7 +754,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (!isoFile.FileExists(filePath))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
return;
}
@@ -747,18 +764,17 @@ namespace WPCordovaClassLib.Cordova.Commands
{
stream.SetLength(size);
}
-
streamLength = stream.Length;
}
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, streamLength));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, streamLength), callbackId);
}
catch (Exception ex)
{
- if (!this.HandleException(ex))
+ if (!this.HandleException(ex, callbackId))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
@@ -767,18 +783,19 @@ namespace WPCordovaClassLib.Cordova.Commands
public void write(string options)
{
// TODO: try/catch
- string[] optStrings = JSON.JsonHelper.Deserialize<string[]>(options);
+ string[] optStrings = getOptionStrings(options);
string filePath = optStrings[0];
string data = optStrings[1];
int position = int.Parse(optStrings[2]);
+ string callbackId = optStrings[3];
try
{
if (string.IsNullOrEmpty(data))
{
Debug.WriteLine("Expected some data to be send in the write command to {0}", filePath);
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION), callbackId);
return;
}
@@ -805,13 +822,13 @@ namespace WPCordovaClassLib.Cordova.Commands
}
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, data.Length));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, data.Length), callbackId);
}
catch (Exception ex)
{
- if (!this.HandleException(ex))
+ if (!this.HandleException(ex, callbackId))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
@@ -822,7 +839,9 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <param name="options">filePath to entry</param>
public void getMetadata(string options)
{
- string filePath = getSingleStringOption(options);
+ string[] optStings = getOptionStrings(options);
+ string filePath = optStings[0];
+ string callbackId = optStings[1];
if (filePath != null)
{
@@ -833,29 +852,29 @@ namespace WPCordovaClassLib.Cordova.Commands
if (isoFile.FileExists(filePath))
{
DispatchCommandResult(new PluginResult(PluginResult.Status.OK,
- new ModificationMetadata() { modificationTime = isoFile.GetLastWriteTime(filePath).DateTime.ToString() }));
+ new ModificationMetadata() { modificationTime = isoFile.GetLastWriteTime(filePath).DateTime.ToString() }), callbackId);
}
else if (isoFile.DirectoryExists(filePath))
{
string modTime = isoFile.GetLastWriteTime(filePath).DateTime.ToString();
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new ModificationMetadata() { modificationTime = modTime }));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new ModificationMetadata() { modificationTime = modTime }), callbackId);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
}
}
}
catch (IsolatedStorageException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
catch (Exception ex)
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
@@ -870,23 +889,26 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <returns></returns>
public void getFileMetadata(string options)
{
- string filePath = getSingleStringOption(options);
+ string[] optStings = getOptionStrings(options);
+ string filePath = optStings[0];
+ string callbackId = optStings[1];
+
if (filePath != null)
{
try
{
FileMetadata metaData = new FileMetadata(filePath);
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, metaData));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, metaData), callbackId);
}
catch (IsolatedStorageException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
catch (Exception ex)
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_READABLE_ERR), callbackId);
}
}
}
@@ -899,14 +921,17 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <param name="options"></param>
public void getParent(string options)
{
- string filePath = getSingleStringOption(options);
+ string[] optStings = getOptionStrings(options);
+ string filePath = optStings[0];
+ string callbackId = optStings[1];
+
if (filePath != null)
{
try
{
if (string.IsNullOrEmpty(filePath))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION),callbackId);
return;
}
@@ -920,11 +945,11 @@ namespace WPCordovaClassLib.Cordova.Commands
string path = this.GetParentDirectory(filePath);
entry = FileEntry.GetEntry(path);
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry),callbackId);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR),callbackId);
}
}
@@ -933,7 +958,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR),callbackId);
}
}
}
@@ -941,7 +966,10 @@ namespace WPCordovaClassLib.Cordova.Commands
public void remove(string options)
{
- string filePath = getSingleStringOption(options);
+ string[] args = getOptionStrings(options);
+ string filePath = args[0];
+ string callbackId = args[1];
+
if (filePath != null)
{
try
@@ -964,18 +992,18 @@ namespace WPCordovaClassLib.Cordova.Commands
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR),callbackId);
return;
}
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK),callbackId);
}
}
catch (Exception ex)
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR),callbackId);
}
}
}
@@ -983,31 +1011,39 @@ namespace WPCordovaClassLib.Cordova.Commands
public void removeRecursively(string options)
{
- string filePath = getSingleStringOption(options);
+ string[] args = getOptionStrings(options);
+ string filePath = args[0];
+ string callbackId = args[1];
+
if (filePath != null)
{
if (string.IsNullOrEmpty(filePath))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION),callbackId);
}
else
{
- removeDirRecursively(filePath);
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
+ if (removeDirRecursively(filePath, callbackId))
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId);
+ }
}
}
}
public void readEntries(string options)
{
- string filePath = getSingleStringOption(options);
+ string[] args = getOptionStrings(options);
+ string filePath = args[0];
+ string callbackId = args[1];
+
if (filePath != null)
{
try
{
if (string.IsNullOrEmpty(filePath))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION),callbackId);
return;
}
@@ -1027,11 +1063,11 @@ namespace WPCordovaClassLib.Cordova.Commands
{
entries.Add(FileEntry.GetEntry(path + dir + "/"));
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entries));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entries),callbackId);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR),callbackId);
}
}
}
@@ -1039,7 +1075,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR),callbackId);
}
}
}
@@ -1048,16 +1084,18 @@ namespace WPCordovaClassLib.Cordova.Commands
public void requestFileSystem(string options)
{
// TODO: try/catch
- double[] optVals = JSON.JsonHelper.Deserialize<double[]>(options);
+ string[] optVals = getOptionStrings(options);
+ //FileOptions fileOptions = new FileOptions();
+ int fileSystemType = int.Parse(optVals[0]);
+ double size = double.Parse(optVals[1]);
+ string callbackId = optVals[2];
- double fileSystemType = optVals[0];
- double size = optVals[1];
IsolatedStorageFile.GetUserStoreForApplication();
if (size > (10 * 1024 * 1024)) // 10 MB, compier will clean this up!
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, QUOTA_EXCEEDED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, QUOTA_EXCEEDED_ERR), callbackId);
return;
}
@@ -1070,7 +1108,7 @@ namespace WPCordovaClassLib.Cordova.Commands
long availableSize = isoFile.AvailableFreeSpace;
if (size > availableSize)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, QUOTA_EXCEEDED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, QUOTA_EXCEEDED_ERR), callbackId);
return;
}
}
@@ -1079,7 +1117,7 @@ namespace WPCordovaClassLib.Cordova.Commands
if (fileSystemType == PERSISTENT)
{
// TODO: this should be in it's own folder to prevent overwriting of the app assets, which are also in ISO
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("persistent", FileEntry.GetEntry("/"))));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("persistent", FileEntry.GetEntry("/"))), callbackId);
}
else if (fileSystemType == TEMPORARY)
{
@@ -1093,19 +1131,19 @@ namespace WPCordovaClassLib.Cordova.Commands
string tmpFolder = "/" + TMP_DIRECTORY_NAME + "/";
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("temporary", FileEntry.GetEntry(tmpFolder))));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("temporary", FileEntry.GetEntry(tmpFolder))), callbackId);
}
- else if (fileOptions.FileSystemType == RESOURCE)
+ else if (fileSystemType == RESOURCE)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("resource")));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("resource")), callbackId);
}
- else if (fileOptions.FileSystemType == APPLICATION)
+ else if (fileSystemType == APPLICATION)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("application")));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileSystemInfo("application")), callbackId);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR), callbackId);
}
}
@@ -1113,22 +1151,24 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR), callbackId);
}
}
}
public void resolveLocalFileSystemURI(string options)
{
- string uri = getSingleStringOption(options).Split('?')[0];
+
+ string[] optVals = getOptionStrings(options);
+ string uri = optVals[0].Split('?')[0];
+ string callbackId = optVals[1];
if (uri != null)
{
// a single '/' is valid, however, '/someDir' is not, but '/tmp//somedir' and '///someDir' are valid
if (uri.StartsWith("/") && uri.IndexOf("//") < 0 && uri != "/")
{
- Debug.WriteLine("Starts with / ::: " + uri);
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR), callbackId);
return;
}
try
@@ -1139,18 +1179,18 @@ namespace WPCordovaClassLib.Cordova.Commands
FileEntry uriEntry = FileEntry.GetEntry(path);
if (uriEntry != null)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, uriEntry));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, uriEntry), callbackId);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
}
}
catch (Exception ex)
{
- if (!this.HandleException(ex))
+ if (!this.HandleException(ex, callbackId))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR), callbackId);
}
}
}
@@ -1204,14 +1244,14 @@ namespace WPCordovaClassLib.Cordova.Commands
return result;
}
- private void removeDirRecursively(string fullPath)
+ private bool removeDirRecursively(string fullPath,string callbackId)
{
try
{
if (fullPath == "/")
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
- return;
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR),callbackId);
+ return false;
}
using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
@@ -1232,14 +1272,17 @@ namespace WPCordovaClassLib.Cordova.Commands
{
foreach (string dir in dirs)
{
- removeDirRecursively(tempPath + dir);
+ if (!removeDirRecursively(tempPath + dir, callbackId))
+ {
+ return false;
+ }
}
}
isoFile.DeleteDirectory(fullPath);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR),callbackId);
}
}
}
@@ -1247,9 +1290,11 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR),callbackId);
+ return false;
}
}
+ return true;
}
private bool CanonicalCompare(string pathA, string pathB)
@@ -1267,16 +1312,17 @@ namespace WPCordovaClassLib.Cordova.Commands
private void TransferTo(string options, bool move)
{
// TODO: try/catch
- string[] optStrings = JSON.JsonHelper.Deserialize<string[]>(options);
+ string[] optStrings = getOptionStrings(options);
string fullPath = optStrings[0];
string parent = optStrings[1];
string newFileName = optStrings[2];
+ string callbackId = optStrings[3];
char[] invalids = Path.GetInvalidPathChars();
if (newFileName.IndexOfAny(invalids) > -1 || newFileName.IndexOf(":") > -1 )
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR), callbackId);
return;
}
@@ -1284,7 +1330,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if ((parent == null) || (string.IsNullOrEmpty(parent)) || (string.IsNullOrEmpty(fullPath)))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
return;
}
@@ -1299,7 +1345,7 @@ namespace WPCordovaClassLib.Cordova.Commands
if ( ( !isFileExist && !isDirectoryExist ) || !isParentExist )
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
return;
}
string newName;
@@ -1316,13 +1362,13 @@ namespace WPCordovaClassLib.Cordova.Commands
// cannot copy file onto itself
if (CanonicalCompare(newPath,currentPath)) //(parent + newFileName))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_MODIFICATION_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_MODIFICATION_ERR), callbackId);
return;
}
else if (isoFile.DirectoryExists(newPath))
{
// there is already a folder with the same name, operation is not allowed
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_MODIFICATION_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_MODIFICATION_ERR), callbackId);
return;
}
else if (isoFile.FileExists(newPath))
@@ -1366,50 +1412,51 @@ namespace WPCordovaClassLib.Cordova.Commands
FileEntry entry = FileEntry.GetEntry(newPath);
if (entry != null)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry), callbackId);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
}
}
}
catch (Exception ex)
{
- if (!this.HandleException(ex))
+ if (!this.HandleException(ex, callbackId))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR), callbackId);
}
}
}
- private bool HandleException(Exception ex)
+ private bool HandleException(Exception ex, string cbId="")
{
bool handled = false;
+ string callbackId = String.IsNullOrEmpty(cbId) ? this.CurrentCommandCallbackId : cbId;
if (ex is SecurityException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, SECURITY_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, SECURITY_ERR), callbackId);
handled = true;
}
else if (ex is FileNotFoundException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
handled = true;
}
else if (ex is ArgumentException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR), callbackId);
handled = true;
}
else if (ex is IsolatedStorageException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_MODIFICATION_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_MODIFICATION_ERR), callbackId);
handled = true;
}
else if (ex is DirectoryNotFoundException)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
handled = true;
}
return handled;
@@ -1450,17 +1497,20 @@ namespace WPCordovaClassLib.Cordova.Commands
private void GetFileOrDirectory(string options, bool getDirectory)
{
FileOptions fOptions = new FileOptions();
+ string[] args = getOptionStrings(options);
+
+ fOptions.FullPath = args[0];
+ fOptions.Path = args[1];
+
+ string callbackId = args[3];
+
try
{
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
-
- fOptions.FullPath = args[0];
- fOptions.Path = args[1];
fOptions.CreatingOpt = JSON.JsonHelper.Deserialize<CreatingOptions>(args[2]);
}
catch (Exception)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION), callbackId);
return;
}
@@ -1468,7 +1518,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if ((string.IsNullOrEmpty(fOptions.Path)) || (string.IsNullOrEmpty(fOptions.FullPath)))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
return;
}
@@ -1476,7 +1526,7 @@ namespace WPCordovaClassLib.Cordova.Commands
if (fOptions.Path.Split(':').Length > 2)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR), callbackId);
return;
}
@@ -1486,7 +1536,7 @@ namespace WPCordovaClassLib.Cordova.Commands
}
catch (Exception)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ENCODING_ERR), callbackId);
return;
}
@@ -1500,7 +1550,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (exclusive && (isoFile.FileExists(path) || isoFile.DirectoryExists(path)))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, PATH_EXISTS_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, PATH_EXISTS_ERR), callbackId);
return;
}
@@ -1515,7 +1565,7 @@ namespace WPCordovaClassLib.Cordova.Commands
if (!isoFile.DirectoryExists(builtPath))
{
Debug.WriteLine(String.Format("Error :: Parent folder \"{0}\" does not exist, when attempting to create \"{1}\"",builtPath,path));
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
return;
}
}
@@ -1546,7 +1596,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
FileEntry _entry = FileEntry.GetEntry(fileUri.OriginalString,true);
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, _entry));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, _entry), callbackId);
//using (BinaryReader br = new BinaryReader(streamInfo.Stream))
//{
@@ -1557,31 +1607,31 @@ namespace WPCordovaClassLib.Cordova.Commands
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
}
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
}
return;
}
if (((getDirectory) && (!isDirectory)) || ((!getDirectory) && (!isFile)))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, TYPE_MISMATCH_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, TYPE_MISMATCH_ERR), callbackId);
return;
}
}
FileEntry entry = FileEntry.GetEntry(path);
if (entry != null)
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry), callbackId);
}
else
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR), callbackId);
}
}
}
@@ -1589,7 +1639,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
if (!this.HandleException(ex))
{
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NO_MODIFICATION_ALLOWED_ERR), callbackId);
}
}
}
[04/11] git commit: error logging for missing callbackId
Posted by pu...@apache.org.
error logging for missing callbackId
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/66273d3e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/66273d3e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/66273d3e
Branch: refs/heads/master
Commit: 66273d3ed33caa5ae461b29187ad67fbe81aad48
Parents: f6240be
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 30 23:21:41 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 30 23:21:41 2013 -0700
----------------------------------------------------------------------
.../standalone/cordovalib/Commands/BaseCommand.cs | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/66273d3e/templates/standalone/cordovalib/Commands/BaseCommand.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/Commands/BaseCommand.cs b/templates/standalone/cordovalib/Commands/BaseCommand.cs
index fd5d595..9de0e4d 100644
--- a/templates/standalone/cordovalib/Commands/BaseCommand.cs
+++ b/templates/standalone/cordovalib/Commands/BaseCommand.cs
@@ -58,6 +58,7 @@ namespace WPCordovaClassLib.Cordova.Commands
public object InvokeMethodNamed(string callbackId, string methodName, params object[] args)
{
+ //Debug.WriteLine(string.Format("InvokeMethodNamed:{0} callbackId:{1}",methodName,callbackId));
this.CurrentCommandCallbackId = callbackId;
return InvokeMethodNamed(methodName, args);
}
@@ -128,6 +129,10 @@ namespace WPCordovaClassLib.Cordova.Commands
{
OnCommandResult(this, result);
}
+ else
+ {
+ Debug.WriteLine("Failed to locate callback for id : " + result.CallbackId);
+ }
if (!result.KeepCallback)
{
[03/11] git commit: each alert/confirm keeps track of it's own
callback id
Posted by pu...@apache.org.
each alert/confirm keeps track of it's own callback id
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/f6240be7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/f6240be7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/f6240be7
Branch: refs/heads/master
Commit: f6240be7e2dcbfbe544bac4ee9059b9d61284e98
Parents: 30d24d8
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 30 16:34:25 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 30 16:34:25 2013 -0700
----------------------------------------------------------------------
templates/standalone/Plugins/Notification.cs | 54 +++++++++++---------
1 files changed, 30 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/f6240be7/templates/standalone/Plugins/Notification.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/Notification.cs b/templates/standalone/Plugins/Notification.cs
index 912df2b..4bc3942 100644
--- a/templates/standalone/Plugins/Notification.cs
+++ b/templates/standalone/Plugins/Notification.cs
@@ -22,6 +22,7 @@ using System.Windows.Resources;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework.Audio;
using WPCordovaClassLib.Cordova.UI;
+using System.Diagnostics;
namespace WPCordovaClassLib.Cordova.Commands
@@ -48,7 +49,7 @@ namespace WPCordovaClassLib.Cordova.Commands
}
// blink api - doesn't look like there is an equivalent api we can use...
-
+
[DataContract]
public class AlertOptions
{
@@ -82,14 +83,18 @@ namespace WPCordovaClassLib.Cordova.Commands
public void alert(string options)
{
+ string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
+ AlertOptions alertOpts = new AlertOptions();
+ alertOpts.message = args[0];
+ alertOpts.title = args[1];
+ alertOpts.buttonLabel = args[2];
+
+ //Debug.WriteLine("this.CurrentCommandCallbackId = " + this.CurrentCommandCallbackId);
+
+ string aliasCurrentCommandCallbackId = args[args.Length - 1];// this.CurrentCommandCallbackId; // it may change by the time the new thread invokes
+
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
- AlertOptions alertOpts = new AlertOptions();
- alertOpts.message = args[0];
- alertOpts.title = args[1];
- alertOpts.buttonLabel = args[2];
-
PhoneApplicationPage page = Page;
if (page != null)
{
@@ -98,7 +103,7 @@ namespace WPCordovaClassLib.Cordova.Commands
{
var previous = notifyBox;
notifyBox = new NotificationBox();
- notifyBox.Tag = previous;
+ notifyBox.Tag = new { previous = previous, callbackId = aliasCurrentCommandCallbackId };
notifyBox.PageTitle.Text = alertOpts.title;
notifyBox.SubTitle.Text = alertOpts.message;
Button btnOK = new Button();
@@ -139,17 +144,11 @@ namespace WPCordovaClassLib.Cordova.Commands
{
var previous = notifyBox;
notifyBox = new NotificationBox();
- notifyBox.Tag = previous;
+ notifyBox.Tag = previous;
notifyBox.PageTitle.Text = alertOpts.title;
notifyBox.SubTitle.Text = alertOpts.message;
- string[] labels = JSON.JsonHelper.Deserialize<string[]>(alertOpts.buttonLabel);
-
- if (labels == null)
- {
- labels = alertOpts.buttonLabel.Split(',');
- }
-
+ string[] labels = alertOpts.buttonLabel.Split(',');
for (int n = 0; n < labels.Length; n++)
{
Button btn = new Button();
@@ -176,14 +175,16 @@ namespace WPCordovaClassLib.Cordova.Commands
void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
PhoneApplicationPage page = sender as PhoneApplicationPage;
-
+ string callbackId = "";
if (page != null && notifyBox != null)
{
Grid grid = page.FindName("LayoutRoot") as Grid;
if (grid != null)
{
grid.Children.Remove(notifyBox);
- notifyBox = notifyBox.Tag as NotificationBox;
+ dynamic notifBoxData = notifyBox.Tag;
+ notifyBox = notifBoxData.previous as NotificationBox;
+ callbackId = notifBoxData.callbackId as string;
}
if (notifyBox == null)
{
@@ -192,7 +193,7 @@ namespace WPCordovaClassLib.Cordova.Commands
e.Cancel = true;
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, 0));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, 0), callbackId);
}
void btnOK_Click(object sender, RoutedEventArgs e)
@@ -200,13 +201,14 @@ namespace WPCordovaClassLib.Cordova.Commands
Button btn = sender as Button;
FrameworkElement notifBoxParent = null;
int retVal = 0;
+ string callbackId = "";
if (btn != null)
{
retVal = (int)btn.Tag + 1;
notifBoxParent = btn.Parent as FrameworkElement;
while ((notifBoxParent = notifBoxParent.Parent as FrameworkElement) != null &&
- !(notifBoxParent is NotificationBox));
+ !(notifBoxParent is NotificationBox)) ;
}
if (notifBoxParent != null)
{
@@ -218,15 +220,19 @@ namespace WPCordovaClassLib.Cordova.Commands
{
grid.Children.Remove(notifBoxParent);
}
- notifyBox = notifBoxParent.Tag as NotificationBox;
+
+ dynamic notifBoxData = notifBoxParent.Tag;
+ notifyBox = notifBoxData.previous as NotificationBox;
+ callbackId = notifBoxData.callbackId as string;
+
if (notifyBox == null)
{
page.BackKeyPress -= page_BackKeyPress;
}
}
-
+
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, retVal));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, retVal),callbackId);
}
@@ -324,7 +330,7 @@ namespace WPCordovaClassLib.Cordova.Commands
public void vibrate(string vibrateDuration)
{
-
+
int msecs = 200; // set default
try
[06/11] git commit: command deserialization tweaks,
massage it if we can
Posted by pu...@apache.org.
command deserialization tweaks, massage it if we can
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/297468e6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/297468e6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/297468e6
Branch: refs/heads/master
Commit: 297468e69f8013b877dfa5f15171facccdc7824b
Parents: a3b381b
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed May 1 00:12:20 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed May 1 00:12:20 2013 -0700
----------------------------------------------------------------------
.../standalone/cordovalib/CordovaCommandCall.cs | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/297468e6/templates/standalone/cordovalib/CordovaCommandCall.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/CordovaCommandCall.cs b/templates/standalone/cordovalib/CordovaCommandCall.cs
index a73ac68..facc991 100644
--- a/templates/standalone/cordovalib/CordovaCommandCall.cs
+++ b/templates/standalone/cordovalib/CordovaCommandCall.cs
@@ -23,6 +23,7 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
+using System.Collections.Generic;
namespace WPCordovaClassLib.Cordova
{
@@ -43,10 +44,10 @@ namespace WPCordovaClassLib.Cordova
/// <returns>New class instance or null of string does not represent Cordova command</returns>
public static CordovaCommandCall Parse(string commandStr)
{
+ System.Diagnostics.Debug.WriteLine("CommandString : " + commandStr);
if (string.IsNullOrEmpty(commandStr))
{
return null;
- //throw new ArgumentNullException("commandStr");
}
string[] split = commandStr.Split('/');
@@ -60,12 +61,14 @@ namespace WPCordovaClassLib.Cordova
commandCallParameters.Action = split[1];
commandCallParameters.CallbackId = split[2];
-
try
{
- string arg = split.Length <= 3 ? String.Empty : String.Join("/", split.Skip(3));
- //string[] _args = JSON.JsonHelper.Deserialize<string[]>(arg);
- System.Collections.Generic.List<string> args = JSON.JsonHelper.Deserialize<System.Collections.Generic.List<string>>(arg);
+ string arg = split.Length <= 3 ? "[]" : String.Join("/", split.Skip(3));
+ if (!arg.StartsWith("[")) // save the exception
+ {
+ arg = string.Format("[{0}]", arg);
+ }
+ List<string> args = JSON.JsonHelper.Deserialize<List<string>>(arg);
args.Add(commandCallParameters.CallbackId);
commandCallParameters.Args = JSON.JsonHelper.Serialize(args.ToArray());
}
@@ -81,7 +84,6 @@ namespace WPCordovaClassLib.Cordova
return null;
}
-
return commandCallParameters;
}
[08/11] git commit: Merge branch 'CB-2671' of
github.com:purplecabbage/cordova-wp8 into CB-2671
Posted by pu...@apache.org.
Merge branch 'CB-2671' of github.com:purplecabbage/cordova-wp8 into CB-2671
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/1541ae07
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/1541ae07
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/1541ae07
Branch: refs/heads/master
Commit: 1541ae070a4180a4c20fd9c4126fd33fcf924f74
Parents: 68a0933 297468e
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed May 1 00:26:19 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed May 1 00:26:19 2013 -0700
----------------------------------------------------------------------
.../standalone/cordovalib/CordovaCommandCall.cs | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
[05/11] git commit: handle confirm args of JSON array,
or comma delimited.
Posted by pu...@apache.org.
handle confirm args of JSON array, or comma delimited.
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/a3b381b9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/a3b381b9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/a3b381b9
Branch: refs/heads/master
Commit: a3b381b9a4a55d88a77bfa6940e2c11c576cdbe3
Parents: 66273d3
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed May 1 00:11:30 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed May 1 00:11:30 2013 -0700
----------------------------------------------------------------------
templates/standalone/Plugins/Notification.cs | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/a3b381b9/templates/standalone/Plugins/Notification.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Plugins/Notification.cs b/templates/standalone/Plugins/Notification.cs
index 4bc3942..17825c8 100644
--- a/templates/standalone/Plugins/Notification.cs
+++ b/templates/standalone/Plugins/Notification.cs
@@ -148,7 +148,13 @@ namespace WPCordovaClassLib.Cordova.Commands
notifyBox.PageTitle.Text = alertOpts.title;
notifyBox.SubTitle.Text = alertOpts.message;
- string[] labels = alertOpts.buttonLabel.Split(',');
+ string[] labels = JSON.JsonHelper.Deserialize<string[]>(alertOpts.buttonLabel);
+
+ if (labels == null)
+ {
+ labels = alertOpts.buttonLabel.Split(',');
+ }
+
for (int n = 0; n < labels.Length; n++)
{
Button btn = new Button();
[11/11] git commit: Merge pull request #25 from purplecabbage/CB-2671
Posted by pu...@apache.org.
Merge pull request #25 from purplecabbage/CB-2671
Cb 2671
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/9f0d74c1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/9f0d74c1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/9f0d74c1
Branch: refs/heads/master
Commit: 9f0d74c12913bf171f93951b90f02cdeb6a793af
Parents: aee42fa d240aa6
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed May 8 21:18:33 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed May 8 21:18:33 2013 -0700
----------------------------------------------------------------------
templates/standalone/Plugins/File.cs | 398 ++++++++-------
templates/standalone/Plugins/Notification.cs | 56 ++-
.../standalone/cordovalib/Commands/BaseCommand.cs | 71 ++-
templates/standalone/cordovalib/ConfigHandler.cs | 15 +-
.../standalone/cordovalib/CordovaCommandCall.cs | 21 +-
templates/standalone/cordovalib/NativeExecution.cs | 28 +-
templates/standalone/cordovalib/PluginResult.cs | 2 +
7 files changed, 353 insertions(+), 238 deletions(-)
----------------------------------------------------------------------