Merge pull request #21 from bennmapes/gitignore
removed bin scripts from gitignore
diff --git a/templates/standalone/CordovaAppProj.csproj b/templates/standalone/CordovaAppProj.csproj
index 61b3be1..560c1d7 100644
--- a/templates/standalone/CordovaAppProj.csproj
+++ b/templates/standalone/CordovaAppProj.csproj
@@ -98,9 +98,6 @@
<Compile Include="cordovalib\OrientationHelper.cs" />
<Compile Include="cordovalib\PluginResult.cs" />
<Compile Include="cordovalib\ScriptCallback.cs" />
-
-
-
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
@@ -115,12 +112,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
-
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
-
<Page Include="Plugins\UI\AudioRecorder.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -137,16 +132,29 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
-
</ItemGroup>
<ItemGroup>
+ <None Include="cordova\lib\build.js" />
+ <None Include="cordova\lib\clean.js" />
+ <None Include="cordova\lib\deploy.js" />
+ <None Include="cordova\lib\log.js" />
+ <None Include="cordova\lib\target-list.js" />
<Content Include="www\**" />
<Content Include="config.xml" />
<Content Include="Images\**" />
-
<Content Include="resources\notification-beep.wav" />
+ <None Include="cordova\build.bat" />
+ <None Include="cordova\clean.bat" />
+ <None Include="cordova\lib\install-device.bat" />
+ <None Include="cordova\lib\install-emulator.bat" />
+ <None Include="cordova\lib\list-devices.bat" />
+ <None Include="cordova\lib\list-emulator-images.bat" />
+ <None Include="cordova\lib\list-started-emulators.bat" />
+ <None Include="cordova\lib\start-emulator.bat" />
+ <None Include="cordova\log.bat" />
+ <None Include="cordova\run.bat" />
+ <None Include="cordova\version.bat" />
<None Include="VERSION" />
-
<Content Include="CordovaSourceDictionary.xml">
<SubType>Designer</SubType>
</Content>
@@ -174,8 +182,8 @@
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Plugins\*" />
- <Compile Include="Plugins\UI\*.cs" />
+ <Compile Include="Plugins\*" />
+ <Compile Include="Plugins\UI\*.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
diff --git a/templates/standalone/cordova/version.bat b/templates/standalone/cordova/version.bat
new file mode 100644
index 0000000..714e876
--- /dev/null
+++ b/templates/standalone/cordova/version.bat
@@ -0,0 +1,9 @@
+@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
diff --git a/templates/standalone/cordovalib/ConfigHandler.cs b/templates/standalone/cordovalib/ConfigHandler.cs
index d90e9b5..31934c1 100644
--- a/templates/standalone/cordovalib/ConfigHandler.cs
+++ b/templates/standalone/cordovalib/ConfigHandler.cs
@@ -13,16 +13,29 @@
{
class ConfigHandler
{
- protected List<string> AllowedPlugins;
+ 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 List<string>();
+ AllowedPlugins = new Dictionary<string, PluginConfig>();
AllowedDomains = new List<string>();
Preferences = new Dictionary<string, string>();
}
@@ -32,37 +45,6 @@
return Preferences[key];
}
-/*
- - (BOOL)URLIsAllowed:(NSURL*)url
-{
- if (self.expandedWhitelist == nil) {
- return NO;
- }
-
- if (self.allowAll) {
- return YES;
- }
-
- // iterate through settings ExternalHosts, check for equality
- NSEnumerator* enumerator = [self.expandedWhitelist objectEnumerator];
- id regex = nil;
- NSString* urlHost = [url host];
-
- // if the url host IS found in the whitelist, load it in the app (however UIWebViewNavigationTypeOther kicks it out to Safari)
- // if the url host IS NOT found in the whitelist, we do nothing
- while (regex = [enumerator nextObject]) {
- NSPredicate* regex_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
-
- if ([regex_test evaluateWithObject:urlHost] == YES) {
- // if it matches at least one rule, return
- return YES;
- }
- }
-
- NSLog(@"%@", [self errorStringForURL:url]);
- // if we got here, the url host is not in the white-list, do nothing
- return NO;
-}*/
protected static string[] AllowedSchemes = {"http","https","ftp","ftps"};
protected bool SchemeIsAllowed(string scheme)
{
@@ -182,9 +164,54 @@
public bool IsPluginAllowed(string key)
{
- return AllowAllPlugins || AllowedPlugins.Contains(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()
{
@@ -196,23 +223,7 @@
//This will Read Keys Collection for the xml file
XDocument document = XDocument.Parse(sr.ReadToEnd());
- var plugins = from results in document.Descendants("plugin")
- select new { name = (string)results.Attribute("name") };
-
-
- foreach (var plugin in plugins)
- {
- Debug.WriteLine("plugin " + plugin.name);
- if (plugin.name == "*")
- {
- AllowAllPlugins = true;
- break;
- }
- else
- {
- AllowedPlugins.Add(plugin.name);
- }
- }
+ LoadPluginFeatures(document);
var preferences = from results in document.Descendants("preference")
select new
@@ -223,6 +234,7 @@
foreach (var pref in preferences)
{
+ Preferences[pref.name] = pref.value;
Debug.WriteLine("pref" + pref.name + ", " + pref.value);
}
@@ -237,6 +249,13 @@
{
AddWhiteListEntry(accessElem.origin, accessElem.subdomains);
}
+
+ var contentsTag = document.Descendants("content").FirstOrDefault();
+ if (contentsTag != null)
+ {
+ var src = contentsTag.Attribute("src");
+ ContentSrc = (string)src.Value;
+ }
}
else
{
diff --git a/templates/standalone/cordovalib/CordovaView.xaml.cs b/templates/standalone/cordovalib/CordovaView.xaml.cs
index f6584a8..d57249a 100644
--- a/templates/standalone/cordovalib/CordovaView.xaml.cs
+++ b/templates/standalone/cordovalib/CordovaView.xaml.cs
@@ -152,6 +152,18 @@
configHandler = new ConfigHandler();
configHandler.LoadAppPackageConfig();
+ if (configHandler.ContentSrc != null)
+ {
+ if (Uri.IsWellFormedUriString(configHandler.ContentSrc, UriKind.Absolute))
+ {
+ this.StartPageUri = new Uri(configHandler.ContentSrc, UriKind.Absolute);
+ }
+ else
+ {
+ this.StartPageUri = new Uri(AppRoot + "www/" + configHandler.ContentSrc, UriKind.Relative);
+ }
+ }
+
// initializes native execution logic
nativeExecution = new NativeExecution(ref this.CordovaBrowser);
bmHelper = new BrowserMouseHelper(ref this.CordovaBrowser);