You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2013/07/31 01:38:26 UTC
[04/10] Killed the cordova-wp7 master branch
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs b/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
deleted file mode 100644
index 2e70187..0000000
--- a/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
+++ /dev/null
@@ -1,235 +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.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.SmartDevice.Connectivity;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.IO;
-using System.Xml.XPath;
-using System.Xml;
-using System.Xml.Linq;
-
-
-namespace CordovaDeploy
-{
-
- class DeployTool
- {
-
- static void Usage()
- {
- Log("Usage: CordovaDeploy [ -devices BuildOutputPath -d:DeviceIndex ]");
- Log(" -devices : lists the devices and exits");
- Log(" BuildOutputPath : path to the built application, typically Bin/Debug/ or Bin/Release/");
- Log(" -d : index of the device to deploy, default is 0 ");
- Log("examples:");
- Log(" CordovaDeploy -devices");
- Log(" CordovaDeploy Bin/Debug");
- Log(" CordovaDeploy Bin/Release -d:1");
-
- }
-
- static void ReadWait()
- {
- //Console.WriteLine("\nPress ENTER to continue...");
- //Console.Read();
- }
-
- static void Log(string msg, bool error = false)
- {
- Debug.WriteLine(msg);
- if (error)
- {
- Console.Error.WriteLine(msg);
- }
- else
- {
- Console.Out.WriteLine(msg);
- }
- }
-
- static Guid ReadAppId(string root)
- {
- Guid appID = Guid.Empty;
- string manifestFilePath = root + @"\Properties\WMAppManifest.xml";
-
- if (File.Exists(manifestFilePath))
- {
- XDocument xdoc = XDocument.Load(manifestFilePath);
- var appNode = xdoc.Root.Descendants("App").FirstOrDefault();
- if (appNode != null)
- {
- string guidStr = appNode.Attribute("ProductID").Value;
- appID = new Guid(guidStr);
- }
- else
- {
- Log(string.Format("Unable to find appID, expected to find an App.ProductID property defined in the file {0}", manifestFilePath), true);
- }
- }
- else
- {
- Log(string.Format("Error: the file {0} does not exist", manifestFilePath), true);
- }
-
-
- return appID;
- }
-
-
-
- static void ListDevices()
- {
- // Get CoreCon WP7 SDK
- DatastoreManager dsmgrObj = new DatastoreManager(1033);
- Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
- Collection<Device> devices = WP7SDK.GetDevices();
- for (int index = 0; index < devices.Count; index++)
- {
- Device d = devices[index];
- string info = string.Format("{0} : {1} : {2}", index.ToString(), d.Id, d.Name);
- Log(info);
- }
- }
-
- static void Main(string[] args)
- {
- int deviceIndex = 0;
-
- string iconFilePath = "";
- string xapFilePath = "";
- Guid appID = Guid.Empty;
-
- string root = Directory.GetCurrentDirectory();
-
- if (args.Length < 1)
- {
- Usage();
- ReadWait();
- return;
- }
- else if (args[0] == "-devices")
- {
- ListDevices();
- return;
- }
- else if (args.Length > 1 && args[1].StartsWith("-d:"))
- {
- deviceIndex = int.Parse(args[1].Substring(3));
- }
-
-
- if (Directory.Exists(args[0]))
- {
- DirectoryInfo info = new DirectoryInfo(args[0]);
- root = info.FullName;
- }
-
- appID = ReadAppId(root);
- if (appID == Guid.Empty)
- {
- // Logging of errors is done in ReadAppId
- return;
- }
-
- if (File.Exists(root + @"\ApplicationIcon.png"))
- {
- iconFilePath = root + @"\ApplicationIcon.png";
- }
- else
- {
- Log(string.Format("Error: could not find application icon at {0}", root + @"\ApplicationIcon.png"), true);
- ReadWait();
- return;
- }
-
- try {
- xapFilePath = Directory.GetFiles(root + @"\Bin\Debug", "*.xap").FirstOrDefault();
- } catch (DirectoryNotFoundException e) {
- try {
- xapFilePath = Directory.GetFiles(root + @"\Bin\Release", "*.xap").FirstOrDefault();
- } catch (DirectoryNotFoundException ex) {
- Log(string.Format("Error: could not find project build directoy in {0}", root), true);
- Log("make sure your app has been successfully built before deploying.", true);
- }
- }
-
- if (string.IsNullOrEmpty(xapFilePath))
- {
- Log(string.Format("Error: could not find application .xap in folder {0}", root), true);
- ReadWait();
- return;
- }
-
-
- // Get CoreCon WP7 SDK
- DatastoreManager dsmgrObj = new DatastoreManager(1033);
- Collection<Platform> WP7SDKs = dsmgrObj.GetPlatforms();
- Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
-
- Collection<Device> devices = null;
-
- devices = WP7SDK.GetDevices();
-
- //// Get Emulator / Device
- Device WP7Device = devices[deviceIndex];
-
- if (WP7Device != null)
- {
- RemoteApplication app;
- bool isConnected = WP7Device.IsConnected();
-
- Debug.WriteLine(WP7Device.ToString());
-
- if (!isConnected)
- {
- try
- {
- WP7Device.Connect();
- }
- catch (Exception ex)
- {
- Log("Error: " + ex.Message, true);
- ReadWait();
- return;
- }
- }
-
- if (WP7Device.IsApplicationInstalled(appID))
- {
- Log("Uninstalling XAP from " + WP7Device.Name);
- app = WP7Device.GetApplication(appID);
- app.Uninstall();
- }
-
- Log("Installing app on " + WP7Device.Name);
- app = WP7Device.InstallApplication(appID, appID, "NormalApp", iconFilePath, xapFilePath);
-
- Log("Launching app on " + WP7Device.Name);
- app.Launch();
-
- ReadWait();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs b/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
deleted file mode 100644
index 3c26c87..0000000
--- a/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("CordovaDeploy")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("CordovaDeploy")]
-[assembly: AssemblyCopyright("Copyright © 2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("256b11aa-d4bb-48cf-8024-7c040421fa8d")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/build.js b/templates/standalone/cordova/lib/build.js
deleted file mode 100644
index 1375c54..0000000
--- a/templates/standalone/cordova/lib/build.js
+++ /dev/null
@@ -1,194 +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 fso = WScript.CreateObject('Scripting.FileSystemObject');
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-
-var args = WScript.Arguments;
-
-// working dir
-var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\build.js').join('');
-
-// help/usage function
-function Usage() {
- Log("");
- Log("Usage: build [ --debug | --release ]");
- Log(" --help : Displays this dialog.");
- Log(" --debug : Cleans and builds project in debug mode.");
- Log(" --release : Cleans and builds project in release mode.");
- Log("examples:");
- Log(" build ");
- Log(" build --debug");
- Log(" build --release");
- Log("");
-}
-
-// logs messaged to stdout and stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-// executes a commmand in the shell
-function exec_verbose(command) {
- //Log("Command: " + command);
- var oShell=wscript_shell.Exec(command);
- while (oShell.Status == 0) {
- //Wait a little bit so we're not super looping
- WScript.sleep(100);
- //Print any stdout output from the script
- if (!oShell.StdOut.AtEndOfStream) {
- var line = oShell.StdOut.ReadLine();
- Log(line);
- }
- }
- //Check to make sure our scripts did not encounter an error
- if (!oShell.StdErr.AtEndOfStream) {
- var line = oShell.StdErr.ReadAll();
- Log(line, true);
- WScript.Quit(2);
- }
-}
-
-// checks to see if a .csproj file exists in the project root
-function is_cordova_project(path) {
- if (fso.FolderExists(path)) {
- var proj_folder = fso.GetFolder(path);
- var proj_files = new Enumerator(proj_folder.Files);
- for (;!proj_files.atEnd(); proj_files.moveNext()) {
- if (fso.GetExtensionName(proj_files.item()) == 'csproj') {
- return true;
- }
- }
- }
- return false;
-}
-
-function get_solution_name(path) {
- if (fso.FolderExists(path)) {
- var proj_folder = fso.GetFolder(path);
- var proj_files = new Enumerator(proj_folder.Files);
- for (;!proj_files.atEnd(); proj_files.moveNext()) {
- if (fso.GetExtensionName(proj_files.item()) == 'sln') {
- return proj_files.item();
- }
- }
- }
- return null;
-}
-
-// builds the project and .xap in release mode
-function build_xap_release(path) {
- Log("Building Cordova-WP7 Project:");
- Log("\tConfiguration : Release");
- Log("\tDirectory : " + path);
-
- wscript_shell.CurrentDirectory = path;
- exec_verbose('msbuild ' + get_solution_name(path) + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Release');
-
- // check if file xap was created
- if (fso.FolderExists(path + '\\Bin\\Release')) {
- var out_folder = fso.GetFolder(path + '\\Bin\\Release');
- var out_files = new Enumerator(out_folder.Files);
- for (;!out_files.atEnd(); out_files.moveNext()) {
- if (fso.GetExtensionName(out_files.item()) == 'xap') {
- Log("BUILD SUCCESS.");
- return;
- }
- }
- }
- Log('ERROR: MSBuild failed to create .xap when building cordova-wp7 for release.', true);
- WScript.Quit(2);
-}
-
-// builds the project and .xap in debug mode
-function build_xap_debug(path) {
- Log("Building Cordova-WP7 Project:");
- Log("\tConfiguration : Debug");
- Log("\tDirectory : " + path);
-
- wscript_shell.CurrentDirectory = path;
- exec_verbose('msbuild ' + get_solution_name(path) + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug');
-
- // check if file xap was created
- if (fso.FolderExists(path + '\\Bin\\Debug')) {
- var out_folder = fso.GetFolder(path + '\\Bin\\Debug');
- var out_files = new Enumerator(out_folder.Files);
- for (;!out_files.atEnd(); out_files.moveNext()) {
- if (fso.GetExtensionName(out_files.item()) == 'xap') {
- Log("BUILD SUCCESS.");
- return;
- }
- }
- }
- Log('ERROR: MSBuild failed to create .xap when building cordova-wp7 for debugging.', true);
- WScript.Quit(2);
-}
-
-
-Log("");
-
-if (args.Count() > 0) {
- // support help flags
- if (args(0) == "--help" || args(0) == "/?" ||
- args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
- Usage();
- WScript.Quit(2);
- }
- else if (args.Count() > 1) {
- Log("Error: Too many arguments.", true);
- Usage();
- WScript.Quit(2);
- }
- else if (fso.FolderExists(ROOT)) {
- if (!is_cordova_project(ROOT)) {
- Log('Error: .csproj file not found in ' + ROOT, true);
- Log('could not build project.', true);
- WScript.Quit(2);
- }
-
- if (args(0) == "--debug" || args(0) == "-d") {
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean');
- build_xap_debug(ROOT);
- }
- else if (args(0) == "--release" || args(0) == "-r") {
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean');
- build_xap_release(ROOT);
- }
- else {
- Log("Error: \"" + args(0) + "\" is not recognized as a build option", true);
- Usage();
- WScript.Quit(2);
- }
- }
- else {
- Log("Error: Project directory not found,", true);
- Usage();
- WScript.Quit(2);
- }
-}
-else {
- Log("WARNING: [ --debug | --release ] not specified, defaulting to debug...");
- build_xap_debug(ROOT);
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/clean.js b/templates/standalone/cordova/lib/clean.js
deleted file mode 100644
index f5bdbfc..0000000
--- a/templates/standalone/cordova/lib/clean.js
+++ /dev/null
@@ -1,88 +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 fso = WScript.CreateObject('Scripting.FileSystemObject');
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-var args = WScript.Arguments;
-// working dir
-var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\clean.js').join('');
-
-
-// help function
-function Usage() {
- Log("");
- Log("Usage: clean");
- Log("examples:");
- Log(" clean");
- Log(" - deletes all generated files in project");
- Log("");
-}
-
-// logs to stdout or stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-// cleans any generated files in the cordova project
-function clean_project(path) {
- delete_if_exists(path + "\\obj");
- delete_if_exists(path + "\\Bin");
-}
-
-// deletes the path element if it exists
-function delete_if_exists(path) {
- if (fso.FolderExists(path)) {
- fso.DeleteFolder(path);
- }
- else if (fso.FileExists(path)) {
- fso.DeleteFile(path);
- }
-}
-
-
-if (args.Count() > 0) {
- // support help flags
- if (args(0) == "--help" || args(0) == "/?" ||
- args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
- Usage();
- WScript.Quit(2);
- }
- else {
- Log("Error: \"" + args(0) + "\" is not recognized as a valid option", true);
- Usage();
- WScript.Quit(2);
- }
-}
-else {
- if (fso.FolderExists(ROOT)) {
- Log("Cleaning cordova project...");
- clean_project(ROOT);
- }
- else {
- Log("Error: Project directory not found,", true);
- Usage();
- WScript.Quit(2);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/deploy.js
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/deploy.js b/templates/standalone/cordova/lib/deploy.js
deleted file mode 100644
index 448fa78..0000000
--- a/templates/standalone/cordova/lib/deploy.js
+++ /dev/null
@@ -1,337 +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 fso = WScript.CreateObject('Scripting.FileSystemObject');
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-
-var args = WScript.Arguments;
-// working dir
-var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\deploy.js').join('');
- // path to CordovaDeploy.exe
-var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
- // path to CordovaDeploy
-var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
-//device_id for targeting specific device
-var device_id;
-
-//build types
-var NONE = 0,
- DEBUG = 1,
- RELEASE = 2,
- NO_BUILD = 3;
-var build_type = NONE;
-
-//deploy tpyes
-var NONE = 0,
- EMULATOR = 1,
- DEVICE = 2,
- TARGET = 3;
-var deploy_type = NONE;
-
-
-// help function
-function Usage() {
- Log("");
- Log("Usage:");
- Log(" run [ --device || --emulator || --target=<id> ] ");
- Log(" [ --debug || --release || --nobuild ]");
- Log(" --device : Deploys and runs the project on the connected device.");
- Log(" --emulator : [DEFAULT] Deploys and runs the project on an emulator.");
- Log(" --target=<id> : Deploys and runs the project on the specified target.");
- Log(" --debug : [DEFAULT] Builds project in debug mode.");
- Log(" --release : Builds project in release mode.");
- Log(" --nobuild : Ueses pre-built xap, or errors if project is not built.");
- Log("Examples:");
- Log(" run");
- Log(" run --emulator");
- Log(" run --device");
- Log(" run --target=7988B8C3-3ADE-488d-BA3E-D052AC9DC710");
- Log(" run --device --release");
- Log(" run --emulator --debug");
- Log("");
-}
-
-// log to stdout or stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-var ForReading = 1, ForWriting = 2, ForAppending = 8;
-var TristateUseDefault = 2, TristateTrue = 1, TristateFalse = 0;
-
-
-// executes a commmand in the shell
-function exec(command) {
- var oShell=wscript_shell.Exec(command);
- while (oShell.Status == 0) {
- WScript.sleep(100);
- }
-}
-
-// executes a commmand in the shell
-function exec_verbose(command) {
- //Log("Command: " + command);
- var oShell=wscript_shell.Exec(command);
- while (oShell.Status == 0) {
- //Wait a little bit so we're not super looping
- WScript.sleep(100);
- //Print any stdout output from the script
- if (!oShell.StdOut.AtEndOfStream) {
- var line = oShell.StdOut.ReadAll();
- Log(line);
- }
- }
- //Check to make sure our scripts did not encounter an error
- if (!oShell.StdErr.AtEndOfStream) {
- var line = oShell.StdErr.ReadAll();
- Log(line, true);
- WScript.Quit(2);
- }
-}
-
-// returns the contents of a file
-function read(filename) {
- if (fso.FileExists(filename)) {
- var f=fso.OpenTextFile(filename, 1,2);
- var s=f.ReadAll();
- f.Close();
- return s;
- }
- else {
- Log('Cannot read non-existant file : ' + filename, true);
- WScript.Quit(2);
- }
- return null;
-}
-
-// builds the CordovaDeploy.exe if it does not already exist
-function cordovaDeploy(path) {
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- return;
- }
-
- Log('CordovaDeploy.exe not found, attempting to build CordovaDeploy.exe...');
-
- // build CordovaDeploy.exe
- if (fso.FolderExists(path + '\\cordova') && fso.FolderExists(path + CORDOVA_DEPLOY) &&
- fso.FileExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln')) {
- // delete any previously generated files
- if (fso.FolderExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\obj')) {
- fso.DeleteFolder(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\obj');
- }
- if (fso.FolderExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\Bin')) {
- fso.DeleteFolder(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\Bin');
- }
- exec_verbose('msbuild ' + path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln');
-
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- Log('CordovaDeploy.exe compiled, SUCCESS.');
- }
- else {
- Log('ERROR: MSBUILD FAILED TO COMPILE CordovaDeploy.exe', true);
- WScript.Quit(2);
- }
- }
- else {
- Log('ERROR: CordovaDeploy.sln not found, unable to compile CordovaDeploy tool.', true);
- WScript.Quit(2);
- }
-}
-
-// launches project on device
-function device(path)
-{
- cordovaDeploy(path);
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- Log('Deploying to device ...');
- //TODO: get device ID from list-devices and deploy to first one
- exec_verbose('%comspec% /c ' + path + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:0');
- }
- else
- {
- Log('Error: Failed to find CordovaDeploy.exe in ' + path, true);
- Log('DEPLOY FAILED.', true);
- WScript.Quit(2);
- }
-}
-
-// launches project on emulator
-function emulator(path)
-{
- cordovaDeploy(path);
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- Log('Deploying to emulator ...');
- //TODO: get emulator ID from list-emulators and deploy to first one
- exec_verbose('%comspec% /c ' + path + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:1');
- }
- else
- {
- Log('Error: Failed to find CordovaDeploy.exe in ' + path, true);
- Log('DEPLOY FAILED.', true);
- WScript.Quit(2);
- }
-}
-
-// builds and launches the project on the specified target
-function target(path) {
- if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- cordovaDeploy(path);
- }
- wscript_shell.CurrentDirectory = path + CORDOVA_DEPLOY + '\\CordovaDeploy\\bin\\Debug';
- var cmd = 'CordovaDeploy -devices';
- var out = wscript_shell.Exec(cmd);
- while(out.Status == 0) {
- WScript.Sleep(100);
- }
- if (!out.StdErr.AtEndOfStream) {
- var line = out.StdErr.ReadAll();
- Log("Error calling CordovaDeploy : ", true);
- Log(line, true);
- WScript.Quit(2);
- }
- else {
- if (!out.StdOut.AtEndOfStream) {
- var line = out.StdOut.ReadAll();
- var targets = line.split('\r\n');
- var check_id = new RegExp(device_id);
- for (target in targets) {
- if (targets[target].match(check_id)) {
- //TODO: this only gets single digit index, account for device index of 10+?
- var index = targets[target].substr(0,1);
- exec_verbose(path + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:' + index);
- return;
- }
- }
- Log('Error : target ' + device_id + ' was not found.', true);
- Log('DEPLOY FAILED.', true);
- WScript.Quit(2);
- }
- else {
- Log('Error : CordovaDeploy Failed to find any devices', true);
- Log('DEPLOY FAILED.', true);
- WScript.Quit(2);
- }
- }
-}
-
-function build(path) {
- switch (build_type) {
- case DEBUG :
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --debug');
- break;
- case RELEASE :
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --release');
- break;
- case NO_BUILD :
- break;
- case NONE :
- Log("WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug.");
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --debug');
- break;
- default :
- Log("Build option not recognized: " + build_type, true);
- WScript.Quit(2);
- break;
- }
-}
-
-function run(path) {
- switch(deploy_type) {
- case EMULATOR :
- build(path);
- emulator(path);
- break;
- case DEVICE :
- build(path);
- device(path);
- break;
- case TARGET :
- build(path);
- target(path);
- break;
- case NONE :
- Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
- build(path);
- emulator(path);
- break;
- default :
- Log("Deploy option not recognized: " + deploy_type, true);
- WScript.Quit(2);
- break;
- }
-}
-
-
-if (args.Count() > 0) {
- // limit args
- if (args.Count() > 2) {
- Log('Error: Too many arguments.', true);
- Usage();
- WScript.Quit(2);
- }
- else if (fso.FolderExists(ROOT)) {
- // parse arguments
- for(var i = 0; i < args.Count(); i++) {
- if (args(i) == "--release") {
- build_type = RELEASE;
- }
- else if (args(i) == "--debug") {
- build_type = DEBUG;
- }
- else if (args(i) == "--nobuild") {
- build_type = NO_BUILD;
- }
- else if (args(i) == "--emulator" || args(i) == "-e") {
- deploy_type = EMULATOR;
- }
- else if (args(i) == "--device" || args(i) == "-d") {
- deploy_type = DEVICE;
- }
- else if (args(i).substr(0,9) == "--target=") {
- device_id = args(i).split("--target=").join("");
- deploy_type = TARGET;
- }
- // support help flags
- else if (args(0) == "--help" || args(0) == "/?" ||
- args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
- Usage();
- WScript.Quit(2);
- }
- else {
- Log('Error: \"' + args(0) + '\" is not recognized as a deploy option', true);
- Usage();
- WScript.Quit(2);
- }
- }
- }
- else {
- Log('Error: Project directory not found,', true);
- Usage();
- WScript.Quit(2);
- }
-}
-
-// Finally run the project!
-run(ROOT);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/install-device.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/install-device.bat b/templates/standalone/cordova/lib/install-device.bat
deleted file mode 100644
index 9507c36..0000000
--- a/templates/standalone/cordova/lib/install-device.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%deploy.js (
- cscript "%full_path%deploy.js" %* --device --nobuild //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'deploy.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/install-emulator.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/install-emulator.bat b/templates/standalone/cordova/lib/install-emulator.bat
deleted file mode 100644
index b3ee451..0000000
--- a/templates/standalone/cordova/lib/install-emulator.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%deploy.js (
- cscript "%full_path%deploy.js" %* --emulator --nobuild //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'deploy.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/list-devices.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/list-devices.bat b/templates/standalone/cordova/lib/list-devices.bat
deleted file mode 100644
index bf4492b..0000000
--- a/templates/standalone/cordova/lib/list-devices.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%target-list.js (
- cscript "%full_path%target-list.js" %* --devices //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'target-list.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/list-emulator-images.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/list-emulator-images.bat b/templates/standalone/cordova/lib/list-emulator-images.bat
deleted file mode 100644
index 3f571c7..0000000
--- a/templates/standalone/cordova/lib/list-emulator-images.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%target-list.js (
- cscript "%full_path%target-list.js" %* --emulators //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'target-list.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/list-started-emulators.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/list-started-emulators.bat b/templates/standalone/cordova/lib/list-started-emulators.bat
deleted file mode 100644
index d779b5d..0000000
--- a/templates/standalone/cordova/lib/list-started-emulators.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@ECHO OFF
-ECHO Sorry, list-started-emulators is not availible yet for Windows Phone. 1>&2
-EXIT /B 1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/log.js
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/log.js b/templates/standalone/cordova/lib/log.js
deleted file mode 100644
index 0b4ea7d..0000000
--- a/templates/standalone/cordova/lib/log.js
+++ /dev/null
@@ -1,77 +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 fso = WScript.CreateObject('Scripting.FileSystemObject');
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-var args = WScript.Arguments;
-// working dir
-var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\log.js').join('');
-
-
-// help function
-function Usage() {
- Log("");
- Log("Usage: log");
- Log("examples:");
- Log(" log");
- Log(" - logs output from running application *NOT IMPLIMENTED*");
- Log("");
-}
-
-// logs to stdout or stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-// log output from running projects *NOT IMPLEMENTED*
-function log_output(path) {
- Log("ERROR: Logging is not supported on Windows Phone", true);
- WScript.Quit(1);
-}
-
-
-if (args.Count() > 0) {
- // support help flags
- if (args(0) == "--help" || args(0) == "/?" ||
- args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
- Usage();
- WScript.Quit(2);
- }
- else {
- Log("Error: \"" + args(0) + "\" is not recognized as a log option.", true);
- Usage();
- WScript.Quit(2);
- }
-}
-else {
- if (fso.FolderExists(ROOT)) {
- log_output(ROOT);
- }
- else {
- Log("Error: Project directory not found,", true);
- Usage();
- WScript.Quit(2);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/start-emulator.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/start-emulator.bat b/templates/standalone/cordova/lib/start-emulator.bat
deleted file mode 100644
index 19983fd..0000000
--- a/templates/standalone/cordova/lib/start-emulator.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@ECHO OFF
-ECHO Sorry, start-emulator is not availible yet for Windows Phone. 1>&2
-EXIT /B 1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/lib/target-list.js
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/lib/target-list.js b/templates/standalone/cordova/lib/target-list.js
deleted file mode 100644
index 805eea5..0000000
--- a/templates/standalone/cordova/lib/target-list.js
+++ /dev/null
@@ -1,233 +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 fso = WScript.CreateObject('Scripting.FileSystemObject');
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-
-var args = WScript.Arguments;
-// working dir
-var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\target-list.js').join('');
- // path to CordovaDeploy.exe
-var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
- // path to CordovaDeploy
-var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
-
-// help/usage function
-function Usage() {
- Log("");
- Log("Usage: cscript target-list.js [ --emulators | --devices | --started_emulators | --all ]");
- Log(" --emulators : List the possible target emulators availible.");
- Log(" --devices : List the possible target devices availible. *NOT IMPLEMENTED YET*");
- Log(" --started_emulators : List any started emulators availible. *NOT IMPLEMENTED YET*");
- Log(" --all : List all devices returned by CordovaDeploy.exe -devices ");
- Log("examples:");
- Log(" cscript target-list.js --emulators");
- Log(" cscript target-list.js --devices");
- Log(" cscript target-list.js --started_emulators");
- Log(" cscript target-list.js --all");
- Log("");
-}
-
-// logs messaged to stdout and stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-// executes a commmand in the shell
-function exec(command) {
- var oShell=wscript_shell.Exec(command);
- while (oShell.Status == 0) {
- //Wait a little bit so we're not super looping
- WScript.sleep(100);
- //Print output? Naa.....
- if (!oShell.StdOut.AtEndOfStream) {
- var line = oShell.StdOut.ReadAll();
- //Log(line);
- }
- }
- //Check to make sure our scripts did not encounter an error
- if (!oShell.StdErr.AtEndOfStream) {
- var line = oShell.StdErr.ReadAll();
- Log(line, true);
- WScript.Quit(2);
- }
-}
-
-// returns all possible targets generated by the CordovaDeploy tool
-function get_targets(path) {
- if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- cordovaDeploy(path);
- }
- wscript_shell.CurrentDirectory = path + CORDOVA_DEPLOY + '\\CordovaDeploy\\bin\\Debug';
- var cmd = 'CordovaDeploy -devices';
- var out = wscript_shell.Exec(cmd);
- while(out.Status == 0) {
- WScript.Sleep(100);
- }
- //Check to make sure our script did not encounter an error
- if (!out.StdErr.AtEndOfStream) {
- var line = out.StdErr.ReadAll();
- Log("Error calling CordovaDeploy : ", true);
- Log(line, true);
- WScript.Quit(2);
- }
- else {
- if (!out.StdOut.AtEndOfStream) {
- var line = out.StdOut.ReadAll();
- var targets = line.split('\r\n');
- //format (ID DESCRIPTION)
- for (i in targets) {
- // remove device index and separator colen
- targets[i] = targets[i].replace(/\d*\s\:\s/, '').replace(/\:\s/, '');
- }
- return targets;
- }
- else {
- Log('Error : CordovaDeploy Failed to find any devices', true);
- WScript.Quit(2);
- }
- }
-}
-
-function list_targets(path) {
- var targets = get_targets(path);
- for (i in targets) {
- Log(targets[i]);
- }
-}
-
-// lists the Device returned by CordovaDeploy (NOTE: this does not indicate that a device is connected)
-function list_devices(path) {
- var targets = get_targets(path);
- var device_found = false;
- for (i in targets) {
- if (targets[i].match(/Device/)) {
- Log(targets[i]);
- device_found = true;
- }
- }
- if (device_found) {
- Log('');
- Log('WARNING : This does not mean that a device is connected, make');
- Log(' sure your device is connected before deploying to it.');
- }
-}
-
-// lists the emulators availible to CordovaDeploy
-function list_emulator_images(path) {
- var targets = get_targets(path);
- for (i in targets) {
- if (targets[i].match(/Emulator/)) {
- Log(targets[i]);
- }
- }
-}
-
-// lists any started emulators *NOT IMPLEMENTED*
-function list_started_emulators(path) {
- Log('ERROR : list-started-emulators is not supported on Windows Phone.', true);
- WScript.Quit(1);
-}
-
-// builds the CordovaDeploy.exe if it does not already exist
-function cordovaDeploy(path) {
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- return;
- }
-
- // build CordovaDeploy.exe
- if (fso.FolderExists(path + '\\cordova') && fso.FolderExists(path + CORDOVA_DEPLOY) &&
- fso.FileExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln')) {
- // delete any previously generated files
- if (fso.FolderExists(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\obj")) {
- fso.DeleteFolder(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\obj");
- }
- if (fso.FolderExists(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\Bin")) {
- fso.DeleteFolder(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\Bin");
- }
- exec('msbuild ' + path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln');
-
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- return;
- }
- else {
- Log("ERROR: MSBUILD FAILED TO COMPILE CordovaDeploy.exe", true);
- WScript.Quit(2);
- }
- }
- else {
- Log("ERROR: CordovaDeploy.sln not found, unable to compile CordovaDeploy tool.", true);
- WScript.Quit(2);
- }
-}
-
-
-if (args.Count() > 0) {
- // support help flags
- if (args(0) == "--help" || args(0) == "/?" ||
- args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
- Usage();
- WScript.Quit(2);
- }
- else if (args.Count() > 1) {
- Log("Error: Too many arguments.", true);
- Usage();
- WScript.Quit(2);
- }
- else if (fso.FolderExists(ROOT)) {
- if (!fso.FolderExists(ROOT + '\\cordova')) {
- Log("Error: cordova tooling folder not found in project directory,", true);
- Log("could not lsit targets.", true);
- WScript.Quit(2);
- }
-
- if (args(0) == "--emulators" || args(0) == "-e") {
- list_emulator_images(ROOT);
- }
- else if (args(0) == "--devices" || args(0) == "-d") {
- list_devices(ROOT);
- }
- else if (args(0) == "--started_emulators" || args(0) == "-s") {
- list_started_emulators(ROOT);
- }
- else if (args(0) == "--all" || args(0) == "-a") {
- list_targets(ROOT);
- }
- else {
- Log("Error: \"" + args(0) + "\" is not recognized as a target-list option", true);
- Usage();
- WScript.Quit(2);
- }
- }
- else {
- Log("Error: Project directory not found,", true);
- Usage();
- WScript.Quit(2);
- }
-}
-else {
- Log("WARNING: target list not specified, showing all targets...");
- list_targets(ROOT);
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/log.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/log.bat b/templates/standalone/cordova/log.bat
deleted file mode 100644
index d34a8ab..0000000
--- a/templates/standalone/cordova/log.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-@ECHO OFF
-ECHO Sorry, logging is not supported for Windows Phone. 1>&2
-EXIT /B 1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/run.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/run.bat b/templates/standalone/cordova/run.bat
deleted file mode 100644
index b966856..0000000
--- a/templates/standalone/cordova/run.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%lib\deploy.js (
- cscript "%full_path%lib\deploy.js" %* //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'deploy.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordova/version.bat
----------------------------------------------------------------------
diff --git a/templates/standalone/cordova/version.bat b/templates/standalone/cordova/version.bat
deleted file mode 100644
index 714e876..0000000
--- a/templates/standalone/cordova/version.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST "%full_path%..\VERSION" (
- type "%full_path%..\VERSION"
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find file VERSION in project folder
- EXIT /B 1
-)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordovalib/BaseCommand.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/BaseCommand.cs b/templates/standalone/cordovalib/BaseCommand.cs
deleted file mode 100644
index ac1d2d6..0000000
--- a/templates/standalone/cordovalib/BaseCommand.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using System;
-using System.Reflection;
-using Microsoft.Phone.Shell;
-using System.Diagnostics;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- public abstract class BaseCommand : IDisposable
- {
- /*
- * All commands + plugins must extend BaseCommand, because they are dealt with as BaseCommands in CordovaView.xaml.cs
- *
- **/
-
- public event EventHandler<PluginResult> OnCommandResult;
-
- 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);
-
- if (mInfo != null)
- {
- // every function handles DispatchCommandResult by itself
- return mInfo.Invoke(this, args);
- }
-
- // actually methodName could refer to a property
- if (args == null || args.Length == 0 ||
- (args.Length == 1 && "undefined".Equals(args[0])))
- {
- PropertyInfo pInfo = this.GetType().GetProperty(methodName);
- if (pInfo != null)
- {
- object res = pInfo.GetValue(this, null);
-
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
-
- return res;
- }
- }
-
- throw new MissingMethodException(methodName);
-
- }
-
- [Obsolete]
- public void InvokeCustomScript(ScriptCallback script, bool removeHandler)
- {
- if (this.OnCustomScript != null)
- {
- this.OnCustomScript(this, script);
- if (removeHandler)
- {
- this.OnCustomScript = null;
- }
- }
- }
-
- public void DispatchCommandResult()
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
- }
-
- public void DispatchCommandResult(PluginResult result, string callbackId = "")
- {
- if (!string.IsNullOrEmpty(callbackId))
- {
- result.CallbackId = callbackId;
- }
- else
- {
- result.CallbackId = this.CurrentCommandCallbackId;
- }
-
- if (ResultHandlers.ContainsKey(result.CallbackId))
- {
- ResultHandlers[result.CallbackId](this, result);
- }
- else if (this.OnCommandResult != null)
- {
- OnCommandResult(this, result);
- }
- else
- {
- Debug.WriteLine("Failed to locate callback for id : " + result.CallbackId);
- }
-
- if (!result.KeepCallback)
- {
- this.Dispose();
- }
-
- }
-
-
- /// <summary>
- /// Occurs when the application is being deactivated.
- /// </summary>
- 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() {}
-
-
- /// <summary>
- /// Occurs when the application is being deactivated.
- /// </summary>
- 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 void Dispose()
- {
- PhoneApplicationService service = PhoneApplicationService.Current;
- service.Activated -= this.OnResume;
- service.Deactivated -= this.OnPause;
- this.OnCommandResult = null;
- }
-
- public static string GetBaseURL()
- {
-#if CORDOVA_CLASSLIB
- return "/WPCordovaClassLib;component/";
-#else
- return "./";
-#endif
- }
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordovalib/BrowserMouseHelper.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/BrowserMouseHelper.cs b/templates/standalone/cordovalib/BrowserMouseHelper.cs
deleted file mode 100644
index acd1bcd..0000000
--- a/templates/standalone/cordovalib/BrowserMouseHelper.cs
+++ /dev/null
@@ -1,345 +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.
- */
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using Microsoft.Phone.Controls;
-using System.Windows.Input;
-using System.Diagnostics;
-using System.Windows.Media;
-using System;
-using System.Collections.Generic;
-
-namespace WPCordovaClassLib
-{
-
- /// <summary>
- /// Suppresses pinch zoom and optionally scrolling of the WebBrowser control
- /// </summary>
- public class BrowserMouseHelper
- {
-
- /**
- *
- * Full Script below, in use it is minified.
- */
- /*
- private static string mouseScript =
- @"(function(win,doc){
- var mPro = MouseEvent.prototype;
- var def = Object.defineProperty;
- def( mPro, 'pageX', {
- configurable: true,
- get: function(){ return this.clientX }
- });
- def( mPro, 'pageY', {
- configurable: true,
- get: function(){ return this.clientY }
- });
-
- win.onNativeMouseEvent = function(type,x,y){
- try {
- var xMod = screen.logicalXDPI / screen.deviceXDPI;
- var yMod = screen.logicalYDPI / screen.deviceYDPI;
- var evt = doc.createEvent('MouseEvents');
- var xPos = doc.body.scrollLeft + Math.round(xMod * x);
- var yPos = doc.body.scrollTop + Math.round(yMod * y);
- var element = doc.elementFromPoint(xPos,yPos);
-
- evt.initMouseEvent(type, true, true, win, 1, xPos, yPos, xPos, yPos, false, false, false, false, 0, element);
- evt.timeStamp = +new Date;
- evt.isCordovaEvent = true;
-
- var canceled = element ? !element.dispatchEvent(evt) : !doc.dispatchEvent(evt);
- return canceled ? 'true' : 'false';
- }
- catch(e) { return e;}
- }
- })(window,document);";
- */
-
- private static string MinifiedMouseScript = "(function(g,a){var c=MouseEvent.prototype,d=Object.defineProperty;d(c,'pageX',{configurable:!0,get:function(){return this.clientX}});d(c,'pageY',{configurable:!0,get:function(){return this.clientY}});g.onNativeMouseEvent=function(c,d,i)"
- + "{try{var j=screen.logicalXDPI/screen.deviceXDPI,k=screen.logicalYDPI/screen.deviceYDPI,b=a.createEvent('MouseEvents'),e=a.body.scrollLeft+Math.round(j*d),f=a.body.scrollTop+Math.round(k*i),h=a.elementFromPoint(e,f);b.initMouseEvent(c,!0,!0,g,1,e,f,e,f,!1,!1,!1,!1,0,"
- + "h);b.timeStamp=+new Date;b.isCordovaEvent=!0;return(h?!h.dispatchEvent(b):!a.dispatchEvent(b))?'true':'false'}catch(l){return l}}})(window,document);";
-
-
- private WebBrowser _browser;
-
- /// <summary>
- /// Gets or sets whether to suppress the scrolling of
- /// the WebBrowser control;
- /// </summary>
- public bool ScrollDisabled { get; set; }
-
- private bool userScalable = true;
- private double maxScale = 2.0;
- private double minScale = 0.5;
- protected Border border;
- private bool firstMouseMove = false;
-
- /// <summary>
- /// Represents last known mouse down position.
- /// Used to determine mouse move delta to avoid duplicate mouse events.
- /// </summary>
- private Point mouseDownPos;
-
- /// <summary>
- /// Represent min delta value to consider event as a mouse move. Experimental calculated.
- /// </summary>
- private const int MouseMoveDeltaThreshold = 10;
-
-
- public BrowserMouseHelper(ref WebBrowser browser)
- {
- _browser = browser;
- browser.Loaded += new RoutedEventHandler(browser_Loaded);
- }
-
- private void browser_Loaded(object sender, RoutedEventArgs e)
- {
- var border0 = VisualTreeHelper.GetChild(_browser, 0);
- var border1 = VisualTreeHelper.GetChild(border0, 0);
- var panZoom = VisualTreeHelper.GetChild(border1, 0);
- var grid = VisualTreeHelper.GetChild(panZoom, 0);
- border = VisualTreeHelper.GetChild(grid, 0) as Border;
-
- if (border != null)
- {
- border.ManipulationStarted += Border_ManipulationStarted;
- border.ManipulationDelta += Border_ManipulationDelta;
- border.ManipulationCompleted += Border_ManipulationCompleted;
- border.DoubleTap += Border_DoubleTap;
- border.Tap += Border_Tap;
- border.Hold += Border_Hold;
- border.MouseLeftButtonDown += Border_MouseLeftButtonDown;
- }
-
- _browser.LoadCompleted += Browser_LoadCompleted;
-
- }
-
-
-
-
- void ParseViewportMeta()
- {
- string metaScript = "(function() { return document.querySelector('meta[name=viewport]').content; })()";
-
- try
- {
- string metaContent = _browser.InvokeScript("eval", new string[] { metaScript }) as string;
- string[] arr = metaContent.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
- Dictionary<string, string> metaDictionary = new Dictionary<string, string>();
- foreach (string val in arr)
- {
- string[] keyVal = val.Split('=');
- metaDictionary.Add(keyVal[0], keyVal[1]);
- }
-
- this.userScalable = false; // reset to default
- if (metaDictionary.ContainsKey("user-scalable"))
- {
- this.userScalable = metaDictionary["user-scalable"] == "yes";
- }
-
- this.maxScale = 2.0;// reset to default
- if (metaDictionary.ContainsKey("maximum-scale"))
- {
- this.maxScale = double.Parse(metaDictionary["maximum-scale"]);
- }
-
- this.minScale = 0.5;// reset to default
- if (metaDictionary.ContainsKey("minimum-scale"))
- {
- this.minScale = double.Parse(metaDictionary["minimum-scale"]);
- }
- }
- catch (Exception)
- {
-
- }
- }
-
- void Browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
- ParseViewportMeta();
-
- try
- {
- _browser.InvokeScript("execScript", MinifiedMouseScript);
- }
- catch (Exception)
- {
- Debug.WriteLine("BrowserHelper Failed to install mouse script in WebBrowser");
- }
- }
-
- bool InvokeSimulatedMouseEvent(string eventName, Point pos)
- {
- bool bCancelled = false;
- try
- {
- string strCancelled = _browser.InvokeScript("onNativeMouseEvent", new string[] { eventName, pos.X.ToString(), pos.Y.ToString() }) as string;
- if (bool.TryParse(strCancelled, out bCancelled))
- {
- return bCancelled;
- }
- }
- catch (Exception)
- {
- // script error
- }
-
- return bCancelled;
- }
-
- #region Hold
-
- void Border_Hold(object sender, GestureEventArgs e)
- {
- //Debug.WriteLine("Border_Hold");
- e.Handled = true;
- }
-
- #endregion
-
- #region DoubleTap
-
- void Border_DoubleTap(object sender, GestureEventArgs e)
- {
- //Debug.WriteLine("Border_DoubleTap");
- e.Handled = true;
- }
-
- #endregion
-
- #region Tap
-
- void Border_Tap(object sender, GestureEventArgs e)
- {
- // prevents generating duplicated mouse events
- // firstMouseMove == FALSE means we already handled this situation and generated mouse events
- e.Handled = !this.firstMouseMove;
- }
- #endregion
-
- #region MouseEvents
-
- void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- //Debug.WriteLine("Border_MouseLeftButtonDown");
- border.MouseMove += new MouseEventHandler(Border_MouseMove);
- border.MouseLeftButtonUp += new MouseButtonEventHandler(Border_MouseLeftButtonUp);
-
- this.mouseDownPos = e.GetPosition(_browser);
- // don't fire the down event until we know if this is a 'move' or not
- firstMouseMove = true;
- }
- //
- void Border_MouseMove(object sender, MouseEventArgs e)
- {
- //Debug.WriteLine("Border_MouseMove");
- Point pos = e.GetPosition(_browser);
- // only the return value from the first mouse move event should be used to determine if scrolling is prevented.
- if (firstMouseMove)
- {
- // even for simple tap there are situations where ui control generates move with some little delta value
- // we should avoid such situations allowing to browser control generate native js mousedown/up/click events
- if (Math.Abs(pos.X - mouseDownPos.X) + Math.Abs(pos.Y - mouseDownPos.Y) <= MouseMoveDeltaThreshold)
- {
- return;
- }
-
- InvokeSimulatedMouseEvent("mousedown", pos);
- firstMouseMove = false;
- ScrollDisabled = InvokeSimulatedMouseEvent("mousemove", pos);
- }
- else
- {
- InvokeSimulatedMouseEvent("mousemove", pos);
- }
-
- }
-
- void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- //Debug.WriteLine("Border_MouseLeftButtonUp");
- border.MouseMove -= new MouseEventHandler(Border_MouseMove);
- border.MouseLeftButtonUp -= new MouseButtonEventHandler(Border_MouseLeftButtonUp);
- // if firstMouseMove is false, then we have sent our simulated mousedown, so we should also send a matching mouseup
- if (!firstMouseMove)
- {
- Point pos = e.GetPosition(_browser);
- e.Handled = InvokeSimulatedMouseEvent("mouseup", pos);
- }
- ScrollDisabled = false;
- }
-
-
- #endregion
-
- #region ManipulationEvents
-
- void Border_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
- {
- //Debug.WriteLine("Border_ManipulationStarted");
-
- if (ScrollDisabled)
- {
- e.Handled = true;
- e.Complete();
- }
- }
-
- private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
- {
- //Debug.WriteLine("Border_ManipulationDelta");
- // optionally suppress zoom
- if ((ScrollDisabled || !userScalable) && (e.DeltaManipulation.Scale.X != 0.0 || e.DeltaManipulation.Scale.Y != 0.0))
- {
- e.Handled = true;
- e.Complete();
- }
- // optionally suppress scrolling
- if (ScrollDisabled && (e.DeltaManipulation.Translation.X != 0.0 || e.DeltaManipulation.Translation.Y != 0.0))
- {
- e.Handled = true;
- e.Complete();
- }
- }
-
- private void Border_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
- {
- //Debug.WriteLine("Border_ManipulationCompleted");
- // suppress zoom
- if (!userScalable && e.FinalVelocities != null)
- {
- if (e.FinalVelocities.ExpansionVelocity.X != 0.0 ||
- e.FinalVelocities.ExpansionVelocity.Y != 0.0)
- {
- e.Handled = true;
- }
- }
- }
-
-
- #endregion
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordovalib/CommandFactory.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/CommandFactory.cs b/templates/standalone/cordovalib/CommandFactory.cs
deleted file mode 100644
index 893ce80..0000000
--- a/templates/standalone/cordovalib/CommandFactory.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using System.Collections.Generic;
-using WPCordovaClassLib.Cordova.Commands;
-using System.Reflection;
-using System.Diagnostics;
-
-namespace WPCordovaClassLib.Cordova
-{
- /// <summary>
- /// Provides functionality to create phone gap command by name.
- /// </summary>
- public static class CommandFactory
- {
- /// <summary>
- /// Represents predefined namespace name for custom plugins
- /// </summary>
- private static readonly string CustomPluginNamespacePrefix = "Cordova.Extension.Commands.";
-
- private static readonly string BaseCommandNamespacePrefix = "WPCordovaClassLib.Cordova.Commands.";
-
- /// <summary>
- /// Cache instantiated commands in a map.
- /// </summary>
-
- private static Dictionary<string, BaseCommand> commandMap = new Dictionary<string, BaseCommand>();
-
- /// <summary>
- /// Creates command using command class name. Returns null for unknown commands.
- /// </summary>
- /// <param name="service">Command class name, for example Device or Notification</param>
- /// <returns>Command class instance or null</returns>
- public static BaseCommand CreateByServiceName(string service)
- {
-
- if (string.IsNullOrEmpty(service))
- {
- throw new ArgumentNullException("service", "service to create can't be null");
- }
-
- if (!commandMap.ContainsKey(service))
- {
-
- Type t = Type.GetType(BaseCommandNamespacePrefix + service);
-
- // custom plugin could be defined in own namespace and assembly
- if (t == null)
- {
- string serviceFullName = service.Contains(".") ? service : CustomPluginNamespacePrefix + service;
-
- foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
- {
- // in this case service name represents full type name including namespace
- t = a.GetType(serviceFullName);
-
- if (t == null) // try the Commands Namespace
- {
- t = a.GetType(BaseCommandNamespacePrefix + service);
- }
-
- if (t != null)
- {
- break;
- }
- }
-
- }
-
- // unknown command, still didn't find it
- if (t == null)
- {
- Debug.WriteLine("Unable to locate command :: " + service);
- return null;
- }
-
- commandMap[service] = Activator.CreateInstance(t) as BaseCommand;
- }
-
- return commandMap[service];
- }
-
- public static void ResetAllCommands()
- {
- foreach (BaseCommand bc in commandMap.Values)
- {
- bc.OnReset();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordovalib/ConfigHandler.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/ConfigHandler.cs b/templates/standalone/cordovalib/ConfigHandler.cs
deleted file mode 100644
index 31934c1..0000000
--- a/templates/standalone/cordovalib/ConfigHandler.cs
+++ /dev/null
@@ -1,268 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Windows;
-using System.Windows.Resources;
-using System.Xml.Linq;
-
-namespace WPCordovaClassLib.CordovaLib
-{
- class ConfigHandler
- {
- public class PluginConfig
- {
- public PluginConfig(string name, bool autoLoad = false)
- {
- Name = name;
- isAutoLoad = autoLoad;
- }
- public string Name;
- public bool isAutoLoad;
- }
-
- protected Dictionary<string, PluginConfig> AllowedPlugins;
- protected List<string> AllowedDomains;
- protected Dictionary<string, string> Preferences;
-
- public string ContentSrc { get; private set; }
-
- protected bool AllowAllDomains = false;
- protected bool AllowAllPlugins = false;
-
- public ConfigHandler()
- {
- AllowedPlugins = new Dictionary<string, PluginConfig>();
- AllowedDomains = new List<string>();
- Preferences = new Dictionary<string, string>();
- }
-
- public string GetPreference(string key)
- {
- return Preferences[key];
- }
-
- protected static string[] AllowedSchemes = {"http","https","ftp","ftps"};
- protected bool SchemeIsAllowed(string scheme)
- {
- return AllowedSchemes.Contains(scheme);
- }
-
- protected string PathAndQuery(Uri uri)
- {
- string result = uri.LocalPath;
- if (uri.Query.Length > 0)
- {
- result += uri.Query;
- }
- return result;
- }
-
- protected void AddWhiteListEntry(string origin, bool allowSubdomains)
- {
-
- if (origin == "*")
- {
- AllowAllDomains = true;
- }
-
- if (AllowAllDomains)
- {
- return;
- }
-
- string hostMatchingRegex = "";
- string hostName;
-
- try
- {
-
- Uri uri = new Uri(origin.Replace("*", "replaced-text"), UriKind.Absolute);
-
- string tempHostName = uri.Host.Replace("replaced-text", "*");
- //if (uri.HostNameType == UriHostNameType.Dns){}
- // starts with wildcard match - we make the first '.' optional (so '*.org.apache.cordova' will match 'org.apache.cordova')
- if (tempHostName.StartsWith("*."))
- { //"(\\s{0}|*.)"
- hostName = @"\w*.*" + tempHostName.Substring(2).Replace(".", @"\.").Replace("*", @"\w*");
- }
- else
- {
- hostName = tempHostName.Replace(".", @"\.").Replace("*", @"\w*");
- }
-
- // "^https?://"
- hostMatchingRegex = uri.Scheme + "://" + hostName + PathAndQuery(uri);
- //Debug.WriteLine("Adding regex :: " + hostMatchingRegex);
- AllowedDomains.Add(hostMatchingRegex);
-
- }
- catch (Exception)
- {
- Debug.WriteLine("Invalid Whitelist entry (probably missing the protocol):: " + origin);
- }
-
- }
-
- /**
-
- An access request is granted for a given URI if there exists an item inside the access-request list such that:
-
- - The URI's scheme component is the same as scheme; and
- - if subdomains is false or if the URI's host component is not a domain name (as defined in [RFC1034]), the URI's host component is the same as host; or
- - if subdomains is true, the URI's host component is either the same as host, or is a subdomain of host (as defined in [RFC1034]); and
- - the URI's port component is the same as port.
-
- **/
-
- public bool URLIsAllowed(string url)
- {
- // easy case first
- if (AllowAllDomains )
- {
- return true;
- }
- else
- {
- // start simple
- Uri uri = new Uri(url,UriKind.RelativeOrAbsolute);
- if (uri.IsAbsoluteUri)
- {
- if (this.SchemeIsAllowed(uri.Scheme))
- {
- // additional test because our pattern will always have a trailing '/'
- string matchUrl = url;
- if (PathAndQuery(uri) == "/")
- {
- matchUrl = url + "/";
- }
- foreach (string pattern in AllowedDomains)
- {
- if (Regex.IsMatch(matchUrl, pattern))
- {
- // 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) ||
- (!Regex.IsMatch(PathAndQuery(uri), pattern)))
- {
- return true;
- }
- }
- }
- }
- }
- else
- {
- return true;
- }
- }
- return false;
- }
-
- public bool IsPluginAllowed(string key)
- {
- return AllowAllPlugins || AllowedPlugins.Keys.Contains(key);
- }
-
- private void LoadPluginFeatures(XDocument document)
- {
- var plugins = from results in document.Descendants("plugin")
- select new
- {
- name = (string)results.Attribute("name"),
- autoLoad = results.Attribute("onload")
- };
-
- foreach (var plugin in plugins)
- {
- Debug.WriteLine("Warning: Deprecated use of <plugin> by plugin : " + plugin.name);
- PluginConfig pConfig = new PluginConfig(plugin.name, plugin.autoLoad != null && plugin.autoLoad.Value == "true");
- if (pConfig.Name == "*")
- {
- AllowAllPlugins = true;
- // break; wait, don't, some still could be autoload
- }
- else
- {
- AllowedPlugins[pConfig.Name] = pConfig;
- }
- }
-
- var features = document.Descendants("feature");
-
-
- foreach (var feature in features)
- {
- var name = feature.Attribute("name");
- var values = from results in feature.Descendants("param")
- where ((string)results.Attribute("name") == "wp-package")
- select results;
-
- var value = values.FirstOrDefault();
- if (value != null)
- {
- string key = (string)value.Attribute("value");
- Debug.WriteLine("Adding feature.value=" + key);
- var onload = value.Attribute("onload");
- PluginConfig pConfig = new PluginConfig(key, onload != null && onload.Value == "true");
- AllowedPlugins[key] = pConfig;
- }
- }
- }
-
- public void LoadAppPackageConfig()
- {
- StreamResourceInfo streamInfo = Application.GetResourceStream(new Uri("config.xml", UriKind.Relative));
-
- if (streamInfo != null)
- {
- StreamReader sr = new StreamReader(streamInfo.Stream);
- //This will Read Keys Collection for the xml file
- XDocument document = XDocument.Parse(sr.ReadToEnd());
-
- LoadPluginFeatures(document);
-
- var preferences = from results in document.Descendants("preference")
- select new
- {
- name = (string)results.Attribute("name"),
- value = (string)results.Attribute("value")
- };
-
- foreach (var pref in preferences)
- {
- Preferences[pref.name] = pref.value;
- Debug.WriteLine("pref" + pref.name + ", " + pref.value);
- }
-
- var accessList = from results in document.Descendants("access")
- select new
- {
- origin = (string)results.Attribute("origin"),
- subdomains = (string)results.Attribute("subdomains") == "true"
- };
-
- foreach (var accessElem in accessList)
- {
- AddWhiteListEntry(accessElem.origin, accessElem.subdomains);
- }
-
- var contentsTag = document.Descendants("content").FirstOrDefault();
- if (contentsTag != null)
- {
- var src = contentsTag.Attribute("src");
- ContentSrc = (string)src.Value;
- }
- }
- else
- {
- // no config.xml, allow all
- AllowAllDomains = true;
- AllowAllPlugins = true;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/5c361be6/templates/standalone/cordovalib/CordovaCommandCall.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/CordovaCommandCall.cs b/templates/standalone/cordovalib/CordovaCommandCall.cs
deleted file mode 100644
index 810f5e2..0000000
--- a/templates/standalone/cordovalib/CordovaCommandCall.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using System.Linq;
-using System.Collections.Generic;
-
-namespace WPCordovaClassLib.Cordova
-{
- /// <summary>
- /// Represents Cordova native command call: action callback, etc
- /// </summary>
- public class CordovaCommandCall
- {
- public String Service { get; private set; }
- public String Action { get; private set; }
- public String CallbackId { get; private set; }
- public String Args { get; private set; }
-
- /// <summary>
- /// Retrieves command call parameters and creates wrapper for them
- /// </summary>
- /// <param name="commandStr">Command string in the form 'service/action/callback/args'</param>
- /// <returns>New class instance or null of string does not represent Cordova command</returns>
- public static CordovaCommandCall Parse(string commandStr)
- {
- if (string.IsNullOrEmpty(commandStr))
- {
- return null;
- }
-
- string[] split = commandStr.Split('/');
- if (split.Length < 3)
- {
- return null;
- }
-
- CordovaCommandCall commandCallParameters = new CordovaCommandCall();
- commandCallParameters.Service = split[0];
- commandCallParameters.Action = split[1];
- commandCallParameters.CallbackId = split[2];
-
- try
- {
- 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());
- }
- catch (Exception)
- {
- return null;
- }
- // sanity check for illegal names
- // was failing with ::
- // CordovaCommandResult :: 1, Device1, {"status":1,"message":"{\"name\":\"XD.....
- if (commandCallParameters.Service.IndexOfAny(new char[] { '@', ':', ',', '!', ' ' }) > -1)
- {
- return null;
- }
-
- return commandCallParameters;
- }
-
-
- /// <summary>
- /// Private ctr to disable class creation.
- /// New class instance must be initialized via CordovaCommandCall.Parse static method.
- /// </summary>
- private CordovaCommandCall() { }
-
-
- }
-}