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/01/23 01:19:52 UTC

[11/21] 2.4.0rc1 release prep

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/bef9a814/templates/full/www/index.html
----------------------------------------------------------------------
diff --git a/templates/full/www/index.html b/templates/full/www/index.html
index 922a683..2a1c7a9 100644
--- a/templates/full/www/index.html
+++ b/templates/full/www/index.html
@@ -33,7 +33,7 @@
                 <p class="event received">Device is Ready</p>
             </div>
         </div>
-        <script type="text/javascript" src="cordova-2.3.0.js"></script>
+        <script type="text/javascript" src="cordova-2.4.0.js"></script>
         <script type="text/javascript" src="js/index.js"></script>
         <script type="text/javascript">
             app.initialize();

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/bef9a814/templates/standalone/CordovaAppProj.csproj
----------------------------------------------------------------------
diff --git a/templates/standalone/CordovaAppProj.csproj b/templates/standalone/CordovaAppProj.csproj
index 38b6cae..763933f 100644
--- a/templates/standalone/CordovaAppProj.csproj
+++ b/templates/standalone/CordovaAppProj.csproj
@@ -205,7 +205,7 @@
   </ItemGroup>
   <ItemGroup>
     <Content Include="resources\notification-beep.wav" />
-    <Content Include="www\cordova-2.3.0.js" />
+    <Content Include="www\cordova-2.4.0.js" />
     <Content Include="www\img\logo.png" />
     <Content Include="www\js\index.js" />
     <None Include="VERSION" />

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/bef9a814/templates/standalone/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/Properties/AssemblyInfo.cs b/templates/standalone/Properties/AssemblyInfo.cs
index bac2738..8d9eb89 100644
--- a/templates/standalone/Properties/AssemblyInfo.cs
+++ b/templates/standalone/Properties/AssemblyInfo.cs
@@ -11,7 +11,7 @@ using System.Resources;
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("Apache Cordova")]
 [assembly: AssemblyProduct("CordovaAppProj")]
-[assembly: AssemblyCopyright("Copyright © Apache Cordova 2012")]
+[assembly: AssemblyCopyright("Copyright © Apache Cordova 2013")]
 [assembly: AssemblyTrademark("Apache Cordova")]
 [assembly: AssemblyCulture("")]
 

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/bef9a814/templates/standalone/VERSION
----------------------------------------------------------------------
diff --git a/templates/standalone/VERSION b/templates/standalone/VERSION
index cc6612c..edf28ac 100644
--- a/templates/standalone/VERSION
+++ b/templates/standalone/VERSION
@@ -1 +1 @@
-2.3.0
\ No newline at end of file
+2.4.0rc1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/bef9a814/templates/standalone/cordovalib/Commands/Device.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/Commands/Device.cs b/templates/standalone/cordovalib/Commands/Device.cs
index e23b6f9..9d03d89 100644
--- a/templates/standalone/cordovalib/Commands/Device.cs
+++ b/templates/standalone/cordovalib/Commands/Device.cs
@@ -73,7 +73,7 @@ namespace WPCordovaClassLib.Cordova.Commands
             get
             {
                 // TODO: should be able to dynamically read the Cordova version from somewhere...
-                return "2.3.0";
+                return "2.4.0rc1";
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/bef9a814/templates/standalone/cordovalib/Commands/InAppBrowser.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/Commands/InAppBrowser.cs b/templates/standalone/cordovalib/Commands/InAppBrowser.cs
new file mode 100644
index 0000000..6a29044
--- /dev/null
+++ b/templates/standalone/cordovalib/Commands/InAppBrowser.cs
@@ -0,0 +1,267 @@
+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 Microsoft.Phone.Controls;
+using System.Diagnostics;
+using System.Runtime.Serialization;
+using WPCordovaClassLib.Cordova;
+using WPCordovaClassLib.Cordova.Commands;
+using WPCordovaClassLib.Cordova.JSON;
+using Microsoft.Phone.Shell;
+using Microsoft.Phone.Tasks;
+
+namespace WPCordovaClassLib.Cordova.Commands
+{
+    [DataContract]
+    public class BrowserOptions
+    {
+        [DataMember]
+        public string url;
+
+        [DataMember]
+        public bool isGeolocationEnabled;
+    }
+
+    public class InAppBrowser : BaseCommand
+    {
+
+        private static WebBrowser browser;
+        private static ApplicationBarIconButton backButton;
+        private static ApplicationBarIconButton fwdButton;
+
+        public void open(string options)
+        {
+            string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
+            //BrowserOptions opts = JSON.JsonHelper.Deserialize<BrowserOptions>(options);
+            string urlLoc = args[0];
+            string target = args[1];
+/*
+    _self - opens in the Cordova WebView if url is in the white-list, else it opens in the InAppBrowser 
+    _blank - always open in the InAppBrowser 
+    _system - always open in the system web browser 
+*/
+            switch (target) 
+            {
+                case "_blank" :
+                    ShowInAppBrowser(urlLoc);
+                    break;
+                case "_self" :
+                    ShowCordovaBrowser(urlLoc);
+                    break;
+                case "_system" :
+                    ShowSystemBrowser(urlLoc);
+                    break;
+            }
+
+
+        }
+
+        private void ShowCordovaBrowser(string url)
+        {
+            Uri loc = new Uri(url,UriKind.RelativeOrAbsolute);
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
+                if (frame != null)
+                {
+                    PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
+                    if (page != null)
+                    {
+                        CordovaView cView = page.FindName("CordovaView") as CordovaView;
+                        if(cView != null)
+                        {
+                            WebBrowser br = cView.Browser;
+                            br.Navigate(loc);
+                        }
+                    }
+
+                }
+            });
+        }
+
+        private void ShowSystemBrowser(string url)
+        {
+            WebBrowserTask webBrowserTask = new WebBrowserTask();
+            webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
+            webBrowserTask.Show();
+        }
+
+
+        // Display an inderminate progress indicator
+        private void ShowInAppBrowser(string url)
+        {
+            Uri loc = new Uri(url);
+
+            Deployment.Current.Dispatcher.BeginInvoke(() =>
+            {
+                if (browser != null)
+                {
+                    //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
+                    browser.Navigate(loc);
+                }
+                else
+                {
+                    PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
+                    if (frame != null)
+                    {
+                        PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
+                        WebBrowser br = (page.FindName("CordovaView") as CordovaView).Browser;
+
+                        if (page != null)
+                        {
+                            Grid grid = page.FindName("LayoutRoot") as Grid;
+                            if (grid != null)
+                            {
+                                browser = new WebBrowser();
+                                browser.Navigate(loc);
+
+                                browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);
+
+                                browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
+                                browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
+                                browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
+                                browser.IsScriptEnabled = true;
+                                //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
+                                grid.Children.Add(browser);
+                            }
+
+                            ApplicationBar bar = new ApplicationBar();
+                            bar.BackgroundColor = Colors.Gray;
+                            bar.IsMenuEnabled = false;
+
+                            backButton = new ApplicationBarIconButton();
+                            backButton.Text = "Back";
+                            backButton.IconUri = new Uri("/Images/appbar.back.rest.png", UriKind.Relative);
+                            backButton.Click += new EventHandler(backButton_Click);
+                            backButton.IsEnabled = false;
+                            bar.Buttons.Add(backButton);
+
+
+                            fwdButton = new ApplicationBarIconButton();
+                            fwdButton.Text = "Forward";
+                            fwdButton.IconUri = new Uri("/Images/appbar.next.rest.png", UriKind.Relative);
+                            fwdButton.Click += new EventHandler(fwdButton_Click);
+                            fwdButton.IsEnabled = false;
+                            bar.Buttons.Add(fwdButton);
+
+                            ApplicationBarIconButton closeBtn = new ApplicationBarIconButton();
+                            closeBtn.Text = "Close";
+                            closeBtn.IconUri = new Uri("/Images/appbar.close.rest.png", UriKind.Relative);
+                            closeBtn.Click += new EventHandler(closeBtn_Click);
+                            bar.Buttons.Add(closeBtn);
+
+                            page.ApplicationBar = bar;
+                        }
+
+                    }
+                }
+            });
+        }
+
+        void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
+        {
+            
+        }
+
+        void fwdButton_Click(object sender, EventArgs e)
+        {
+            if (browser != null)
+            {
+                try
+                {
+                    browser.GoForward();
+                    //browser.InvokeScript("execScript", "history.forward();");
+                }
+                catch(Exception)
+                {
+
+                }
+            }
+        }
+
+        void backButton_Click(object sender, EventArgs e)
+        {
+            if (browser != null)
+            {
+                try
+                {
+                    browser.GoBack();
+                    //browser.InvokeScript("execScript", "history.back();");
+                }
+                catch (Exception)
+                {
+
+                }
+            }
+        }
+
+        void closeBtn_Click(object sender, EventArgs e)
+        {
+            this.close();
+        }
+
+
+        public void close(string options="")
+        {
+            if (browser != null)
+            {
+                Deployment.Current.Dispatcher.BeginInvoke(() =>
+                {
+                    PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
+                    if (frame != null)
+                    {
+                        PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
+                        if (page != null)
+                        {
+                            Grid grid = page.FindName("LayoutRoot") as Grid;
+                            if (grid != null)
+                            {
+                                grid.Children.Remove(browser);
+                            }
+                            page.ApplicationBar = null;
+                        }
+                    }
+                    browser = null;
+                });
+            }
+        }
+
+        void browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
+        {
+            if (browser != null)
+            {
+                backButton.IsEnabled = browser.CanGoBack;
+                fwdButton.IsEnabled = browser.CanGoForward;
+
+            }
+            string message = "{\"type\":\"locationChanged\", \"location\":\"" + e.Uri.AbsoluteUri + "\"}";
+            PluginResult result = new PluginResult(PluginResult.Status.OK, message);
+            result.KeepCallback = true;
+            this.DispatchCommandResult(result);
+        }
+
+        void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)
+        {
+            string message = "{\"type\":\"navigationError\",\"location\":\"" + e.Uri.AbsoluteUri + "\"}";
+            PluginResult result = new PluginResult(PluginResult.Status.ERROR, message);
+            result.KeepCallback = true;
+            this.DispatchCommandResult(result);
+        }
+
+        void browser_Navigating(object sender, NavigatingEventArgs e)
+        {
+            string message = "{\"type\":\"locationAboutToChange\",\"location\":\"" + e.Uri.AbsoluteUri + "\"}";
+            PluginResult result = new PluginResult(PluginResult.Status.OK, message);
+            result.KeepCallback = true;
+            this.DispatchCommandResult(result);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/bef9a814/templates/standalone/cordovalib/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/CordovaView.xaml.cs b/templates/standalone/cordovalib/CordovaView.xaml.cs
index 4b13644..c277d77 100644
--- a/templates/standalone/cordovalib/CordovaView.xaml.cs
+++ b/templates/standalone/cordovalib/CordovaView.xaml.cs
@@ -38,6 +38,7 @@ using WPCordovaClassLib.Cordova;
 using System.Threading;
 using Microsoft.Phone.Shell;
 using WPCordovaClassLib.Cordova.JSON;
+using WPCordovaClassLib.CordovaLib;
 
 
 
@@ -73,10 +74,11 @@ namespace WPCordovaClassLib
         private NativeExecution nativeExecution;
 
         protected BrowserMouseHelper bmHelper;
-
         protected DOMStorageHelper domStorageHelper;
         protected OrientationHelper orientationHelper;
 
+        private ConfigHandler configHandler;
+
         public System.Windows.Controls.Grid _LayoutRoot
         {
             get
@@ -157,8 +159,38 @@ namespace WPCordovaClassLib
             }
 
             // initializes native execution logic
-            this.nativeExecution = new NativeExecution(ref this.CordovaBrowser);
-            this.bmHelper = new BrowserMouseHelper(ref this.CordovaBrowser);
+            configHandler = new ConfigHandler();
+            configHandler.LoadAppPackageConfig();
+
+    configHandler.URLIsAllowed("http://app.google.com");
+    configHandler.URLIsAllowed("http://10.2.3.1/");
+    configHandler.URLIsAllowed("http://www.google.ca");
+    configHandler.URLIsAllowed("http://www.google.com/");
+    configHandler.URLIsAllowed("http://www.google.com?q=bobby");
+
+    configHandler.URLIsAllowed("https://app.google.com");
+    configHandler.URLIsAllowed("https://10.2.3.1/");
+    configHandler.URLIsAllowed("https://www.google.ca");
+    configHandler.URLIsAllowed("https://www.google.com/");
+    configHandler.URLIsAllowed("https://www.google.com?q=bobby");
+
+    configHandler.URLIsAllowed("http://build.apache.org");
+    configHandler.URLIsAllowed("http://build.apache.org/page.html?x=1&g=32");
+
+    configHandler.URLIsAllowed("http://apache.org" );
+    configHandler.URLIsAllowed("http://apache.org/page.html?x=1&g=32");
+
+    configHandler.URLIsAllowed("http://sub1.sub0.build.apache.org");
+    configHandler.URLIsAllowed("http://sub1.sub0.build.apache.org/page.html?x=1&g=32");
+
+    configHandler.URLIsAllowed("http://apache.org.ca");
+    configHandler.URLIsAllowed("http://apache.org.ca/page.html?x=1&g=32");
+
+    configHandler.URLIsAllowed("http://some.other.domain/page.html?x=1&g=http://build.apache.org/");
+
+
+            nativeExecution = new NativeExecution(ref this.CordovaBrowser);
+            bmHelper = new BrowserMouseHelper(ref this.CordovaBrowser);
         }
 
 
@@ -394,6 +426,12 @@ namespace WPCordovaClassLib
 
         void GapBrowser_Navigating(object sender, NavigatingEventArgs e)
         {
+            if (!configHandler.URLIsAllowed(e.Uri.ToString()))
+            {
+                e.Cancel = true;
+                return;
+            }
+
             this.PageDidChange = true;
             // Debug.WriteLine("GapBrowser_Navigating to :: " + e.Uri.ToString());
             this.nativeExecution.ResetAllCommands();
@@ -445,10 +483,22 @@ namespace WPCordovaClassLib
             }
             else
             {
-                this.nativeExecution.ProcessCommand(commandCallParams);
+                if (configHandler.IsPluginAllowed(commandCallParams.Service))
+                {
+                    nativeExecution.ProcessCommand(commandCallParams);
+                }
+                else
+                {
+                    Debug.WriteLine("Error::Plugin not allowed in config.xml. " + commandCallParams.Service); 
+                }
             }
         }
 
+        public void LoadPage(string url)
+        {
+            this.configHandler.URLIsAllowed(url);
+        }
+
         private void GapBrowser_Unloaded(object sender, RoutedEventArgs e)
         {