[banshee/webkit#] Port from libossifer to not-yet-released soup# and webkit#



commit b343da67c6fed83fb807f4445e59a49bfd15e3e3
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Apr 1 17:08:26 2011 -0500

    Port from libossifer to not-yet-released soup# and webkit#
    
    The new webkit# bindings are much better and complete, and depend on the
    new soup# bindings.  They haven't been released yet.  Get them from:
    
      https://github.com/andreiagaita/soup-sharp (master branch) and
      https://github.com/andreiagaita/webkit-sharp (webkitgtk-1-2-5 branch)
    
    Still TODO with this port:
     * Handle cookies (blocked on fixes to soup#)
     * Handle GNOME integration (blocked on not-yet-existant soup-gnome#)
     * Add Banshee.WebBrowser and other projects to Windows build

 build/build.environment.mk                         |    3 +-
 build/m4/banshee/libwebkit.m4                      |   29 +--
 configure.ac                                       |    5 +-
 .../Banshee.WebBrowser/Banshee.WebBrowser.csproj   |    8 +-
 .../Banshee.WebBrowser/NavigationControl.cs        |   15 +-
 .../Banshee.WebBrowser/OssiferCookie.cs            |   74 ----
 .../Banshee.WebBrowser/OssiferDownloadStatus.cs    |   39 --
 .../Banshee.WebBrowser/OssiferLoadStatus.cs        |   39 --
 .../OssiferNavigationResponse.cs                   |   40 --
 .../Banshee.WebBrowser/OssiferSession.cs           |  157 --------
 .../Banshee.WebBrowser/OssiferWebView.cs           |  314 ----------------
 .../Banshee.WebSource/WebBrowserShell.cs           |    3 +-
 .../Banshee.WebSource/WebSource.cs                 |    4 +-
 .../Banshee.WebSource/WebView.cs                   |   99 +++++-
 src/Core/Banshee.WebBrowser/Makefile.am            |    8 -
 src/Core/Banshee.WebBrowser/libossifer/Makefile.am |   30 --
 .../libossifer/ossifer-session.c                   |  131 -------
 .../libossifer/ossifer-web-view.c                  |  382 --------------------
 .../libossifer/ossifer-web-view.h                  |   31 --
 .../Banshee.AmazonMp3.Store/StoreView.cs           |   58 ++-
 .../Banshee.Emusic.Store/StoreView.cs              |   31 +-
 .../Banshee.MiroGuide/Banshee.MiroGuide/View.cs    |   42 ++-
 .../Banshee.Wikipedia/WikipediaView.cs             |    6 +-
 23 files changed, 196 insertions(+), 1352 deletions(-)
---
diff --git a/build/build.environment.mk b/build/build.environment.mk
index 0ba40dc..629a7e6 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -29,6 +29,7 @@ LINK_MONO_ADDINS_DEPS = $(MONO_ADDINS_LIBS)
 LINK_MONO_ADDINS_SETUP_DEPS = $(MONO_ADDINS_SETUP_LIBS)
 LINK_INDICATESHARP = $(INDICATESHARP_LIBS)
 LINK_UBUNTUONESHARP = $(UBUNTUONESHARP_LIBS)
+LINK_WEBKITSHARP = $(WEBKITSHARP_LIBS)
 
 DIR_BIN = $(top_builddir)/bin
 
@@ -100,7 +101,7 @@ LINK_BANSHEE_THICKCLIENT = -r:$(DIR_BIN)/Banshee.ThickClient.dll
 LINK_BANSHEE_THICKCLIENT_DEPS = $(REF_BANSHEE_THICKCLIENT) \
 	$(LINK_BANSHEE_THICKCLIENT)
 
-REF_BANSHEE_WEBBROWSER = $(LINK_BANSHEE_THICKCLIENT_DEPS)
+REF_BANSHEE_WEBBROWSER = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_WEBKITSHARP)
 LINK_BANSHEE_WEBBROWSER = -r:$(DIR_BIN)/Banshee.WebBrowser.dll
 LINK_BANSHEE_WEBBROWSER_DEPS = $(REF_BANSHEE_WEBBROWSER) $(LINK_BANSHEE_WEBBROWSER)
 
diff --git a/build/m4/banshee/libwebkit.m4 b/build/m4/banshee/libwebkit.m4
index 656762f..3100376 100644
--- a/build/m4/banshee/libwebkit.m4
+++ b/build/m4/banshee/libwebkit.m4
@@ -1,27 +1,8 @@
 AC_DEFUN([BANSHEE_CHECK_LIBWEBKIT],
 [
-	WEBKIT_MIN_VERSION=1.2.2
-	SOUP_MIN_VERSION=2.26
-	SOUP_GNOME_MIN_VERSION=2.26
-
-	have_libwebkit=no
-	PKG_CHECK_MODULES(LIBWEBKIT,
-		webkit-1.0 >= $WEBKIT_MIN_VERSION
-		libsoup-2.4 >= $SOUP_MIN_VERSION,
-		have_libwebkit=yes, have_libwebkit=no)
-	AC_SUBST(LIBWEBKIT_LIBS)
-	AC_SUBST(LIBWEBKIT_CFLAGS)
-	AM_CONDITIONAL(HAVE_LIBWEBKIT, [test x$have_libwebkit = xyes])
-
-	have_libsoup_gnome=no
-	PKG_CHECK_MODULES(LIBSOUP_GNOME,
-		libsoup-gnome-2.4 >= $SOUP_GNOME_MIN_VERSION,
-		have_libsoup_gnome=$have_libwebkit, have_libsoup_gnome=no)
-	AC_SUBST(LIBSOUP_GNOME_LIBS)
-	AC_SUBST(LIBSOUP_GNOME_CFLAGS)
-	AM_CONDITIONAL(HAVE_LIBSOUP_GNOME, [test x$have_libsoup_gnome = xyes])
-	if test x$have_libsoup_gnome = xyes; then
-		AC_DEFINE(HAVE_LIBSOUP_GNOME, 1, [libsoup-gnome-2.4 detected])
-	fi
+	PKG_CHECK_MODULES(WEBKITSHARP,
+		webkit-sharp-1.0 >= 0.3,
+		have_webkit_sharp=yes, have_webkit_sharp=no)
+	AC_SUBST(WEBKITSHARP_LIBS)
+	AM_CONDITIONAL(HAVE_LIBWEBKIT, [test x$have_webkit_sharp = xyes])
 ])
-
diff --git a/configure.ac b/configure.ac
index 23dfc95..847f3d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -284,7 +284,6 @@ src/Core/Banshee.Services/Makefile
 src/Core/Banshee.ThickClient/Makefile
 src/Core/Banshee.Widgets/Makefile
 src/Core/Banshee.WebBrowser/Makefile
-src/Core/Banshee.WebBrowser/libossifer/Makefile
 
 src/Backends/Makefile
 src/Backends/Banshee.Gio/Makefile
@@ -383,8 +382,8 @@ ${PACKAGE}-${VERSION}
     MTP:                   ${enable_libmtp}
 
   Extra Features:
-    Web Browser:           ${have_libwebkit} (webkit-1.0 >= $WEBKIT_MIN_VERSION, libsoup-2.4 >= $SOUP_MIN_VERSION)
-      + GNOME Proxy        ${have_libsoup_gnome} (libsoup-gnome-2.4 >= $SOUP_GNOME_MIN_VERSION)
+    Web Browser:           ${have_webkit_sharp} (webkit-sharp >= 0.3)
+      + GNOME Proxy        no (not yet ported to webkit#/soup#)
     Boo Scripting:         ${enable_boo}
     DAAP:                  ${enable_daap}
     GIO Backend:           ${enable_gio} (glib >= 2.22, gtk-sharp-beans, and gio-sharp)
diff --git a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser.csproj b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser.csproj
index 7eb2448..d4dca60 100644
--- a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser.csproj
+++ b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser.csproj
@@ -55,6 +55,10 @@
     </Reference>
     <Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
     <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
+    <Reference Include="webkit-sharp, Version=1.1.15.0, Culture=neutral, PublicKeyToken=eaa1d335d2e19745">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\bin\webkit-sharp.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
@@ -111,11 +115,7 @@
     <Folder Include="JavaScriptCore.Bridge\Tests\" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Banshee.WebBrowser\OssiferWebView.cs" />
-    <Compile Include="Banshee.WebBrowser\OssiferNavigationResponse.cs" />
-    <Compile Include="Banshee.WebBrowser\OssiferDownloadStatus.cs" />
     <Compile Include="Banshee.WebBrowser\NavigationControl.cs" />
-    <Compile Include="Banshee.WebBrowser\OssiferLoadStatus.cs" />
     <Compile Include="Banshee.WebBrowser\OssiferCookie.cs" />
     <Compile Include="Banshee.WebBrowser\OssiferSession.cs" />
     <Compile Include="Banshee.WebSource\WebBrowserShell.cs" />
diff --git a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/NavigationControl.cs b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/NavigationControl.cs
index 9ad7e03..55eefc3 100644
--- a/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/NavigationControl.cs
+++ b/src/Core/Banshee.WebBrowser/Banshee.WebBrowser/NavigationControl.cs
@@ -28,6 +28,7 @@
 using System;
 
 using Gtk;
+using WebKit;
 using Hyena.Gui;
 using Hyena.Widgets;
 
@@ -60,7 +61,11 @@ namespace Banshee.WebBrowser
 
             reload_button.Clicked += (o, e) => {
                 if (web_view != null) {
-                    web_view.Reload (!GtkUtilities.NoImportantModifiersAreSet ());
+                    if (GtkUtilities.NoImportantModifiersAreSet ()) {
+                        web_view.Reload ();
+                    } else {
+                        web_view.ReloadBypassCache ();
+                    }
                 }
             };
 
@@ -106,8 +111,8 @@ namespace Banshee.WebBrowser
             return link;
         }
 
-        private OssiferWebView web_view;
-        public OssiferWebView WebView {
+        private Banshee.WebSource.WebView web_view;
+        public Banshee.WebSource.WebView WebView {
             get { return web_view; }
             set {
                 if (web_view == value) {
@@ -143,8 +148,8 @@ namespace Banshee.WebBrowser
 
         private void OnOssiferWebViewLoadStatusChanged (object o, EventArgs args)
         {
-            if (web_view.LoadStatus == OssiferLoadStatus.Committed ||
-                web_view.LoadStatus == OssiferLoadStatus.Failed) {
+            if (web_view.LoadStatus == LoadStatus.Committed ||
+                web_view.LoadStatus == LoadStatus.Failed) {
                 UpdateNavigation ();
             }
         }
diff --git a/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebBrowserShell.cs b/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebBrowserShell.cs
index b7c5bed..ebe6cc8 100644
--- a/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebBrowserShell.cs
+++ b/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebBrowserShell.cs
@@ -28,6 +28,7 @@
 using System;
 
 using Gtk;
+using WebKit;
 using Mono.Unix;
 
 using Banshee.Widgets;
@@ -59,7 +60,7 @@ namespace Banshee.WebSource
             RowSpacing = 5;
 
             view.LoadStatusChanged += (o, e) => {
-                if (view.LoadStatus == OssiferLoadStatus.FirstVisuallyNonEmptyLayout) {
+                if (view.LoadStatus == LoadStatus.FirstVisuallyNonEmptyLayout) {
                     UpdateTitle (view.Title);
 
                     switch (search_clear_on_navigate_state) {
diff --git a/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebSource.cs b/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebSource.cs
index 59a0f2f..1048edf 100644
--- a/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebSource.cs
+++ b/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebSource.cs
@@ -54,7 +54,7 @@ namespace Banshee.WebSource
             actions.Add (
                 new ActionEntry ("ZoomIn"  + id, Stock.ZoomIn,  null, "<control>plus", null, (o, a) => view.ZoomIn ()),
                 new ActionEntry ("ZoomOut" + id, Stock.ZoomOut, null, "<control>minus", null, (o, a) => view.ZoomOut ()),
-                new ActionEntry ("Zoom100" + id, Stock.Zoom100, null, "<control>0", null, (o, a) => view.Zoom = 1f)
+                new ActionEntry ("Zoom100" + id, Stock.Zoom100, null, "<control>0", null, (o, a) => view.ZoomLevel = 1f)
             );
 
             Properties.Set<string> ("ActiveSourceUIString", String.Format (@"
@@ -83,7 +83,7 @@ namespace Banshee.WebSource
 
                 // float isn't supported by gconf apparently
                 var zoom_conf = CreateSchema<double> ("webview_zoom", 1f, null, null);
-                shell.View.Zoom = (float)zoom_conf.Get ();
+                shell.View.ZoomLevel = (float)zoom_conf.Get ();
                 shell.View.ZoomChanged += z => zoom_conf.Set (z);
                 view = shell.View;
 
diff --git a/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebView.cs b/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebView.cs
index ae63e06..1332cb1 100644
--- a/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebView.cs
+++ b/src/Core/Banshee.WebBrowser/Banshee.WebSource/WebView.cs
@@ -28,6 +28,7 @@
 using System;
 
 using Gtk;
+using WebKit;
 
 using Hyena;
 using Hyena.Downloader;
@@ -38,7 +39,7 @@ using Banshee.WebBrowser;
 
 namespace Banshee.WebSource
 {
-    public abstract class WebView : OssiferWebView
+    public abstract class WebView : WebKit.WebView
     {
         protected string FixupJavascriptUrl { get; set; }
         private string fixup_javascript;
@@ -47,55 +48,111 @@ namespace Banshee.WebSource
         public bool IsReady { get; private set; }
         public bool CanSearch { get; protected set; }
 
+        const float ZOOM_STEP = 0.05f;
+
         public event EventHandler Ready;
+        public event Action<float> ZoomChanged;
 
         public WebView ()
         {
+            Settings.EnablePlugins = false;
+            Settings.EnablePageCache = true;
+            Settings.EnableDefaultContextMenu = false;
+            Settings.JavascriptCanOpenWindowsAutomatically = false;
+            //Settings.UserAgent = ..
+
+            FullContentZoom = true;
+
             CanSearch = false;
-        }
 
-        const float ZOOM_STEP = 0.05f;
+            LoadStatusChanged += HandleLoadStatusChanged;
 
-        public void ZoomIn ()
-        {
-            Zoom += ZOOM_STEP;
+            //CreateWebView += (o, a) => { Console.WriteLine ("{0} CreateWebView", this); a.Frame = MainFrame; };
+            ResourceRequestStarting += (o, a) => Console.WriteLine ("{0} ResourceRequestStarting uri={1}", this, a.Request.Uri);
+            LoadError += (o, a) => Console.WriteLine ("{0} LoadError uri={1}", this, a.Uri);
+            ScriptAlert += (o, a) => Console.WriteLine ("{0} ScriptAlert msg={1}", this, a.Message);
+            PopulatePopup += (o, a) => Console.WriteLine ("{0} PopulatePopup", this);
+            ConsoleMessage += (o, a) => Console.WriteLine ("{0} ConsoleMessage msg={1}", this, a.Message);
         }
 
-        public void ZoomOut ()
+        protected override WebKit.WebView OnCreateWebView (WebKit.WebFrame frame)
         {
-            Zoom -= ZOOM_STEP;
+            Console.WriteLine ("{0} CreateWebView", this);
+            return this;
+        }
+
+        public new float ZoomLevel {
+            get { return base.ZoomLevel; }
+            set {
+                if (value != ZoomLevel) {
+                    ZoomLevel = value;
+                    var handler = ZoomChanged;
+                    if (handler != null) {
+                        handler (value);
+                    }
+                }
+            }
         }
 
         protected override bool OnScrollEvent (Gdk.EventScroll scroll)
         {
             if ((scroll.State & Gdk.ModifierType.ControlMask) != 0) {
-                Zoom += (scroll.Direction == Gdk.ScrollDirection.Up) ? ZOOM_STEP : -ZOOM_STEP;
+                ZoomLevel += (scroll.Direction == Gdk.ScrollDirection.Up) ? ZOOM_STEP : -ZOOM_STEP;
                 return true;
             }
 
             return base.OnScrollEvent (scroll);
         }
 
-        protected override void OnLoadStatusChanged (OssiferLoadStatus status)
+        protected override bool OnDownloadRequested (Download download)
         {
-            if ((status == OssiferLoadStatus.FirstVisuallyNonEmptyLayout ||
-                status == OssiferLoadStatus.Finished) && Uri != "about:blank") {
+            var dest_uri = OnDownloadRequested (
+                download,
+                download.GetContentType (),
+                download.Uri,
+                download.SuggestedFilename
+            );
+
+            if (dest_uri != null) {
+                download.DestinationUri = dest_uri;
+                return true;
+            }
+
+            return false;
+        }
+
+        protected virtual string OnDownloadRequested (Download download, string mimetype, string uri, string suggestedFilename)
+        {
+            return null;
+        }
+
+        private void HandleLoadStatusChanged (object o, EventArgs args)
+        {
+            OnLoadStatusChanged ();
+        }
+
+        protected virtual void OnLoadStatusChanged ()
+        {
+            Console.WriteLine ("{0} LoadStatusChanged to {1}", this, LoadStatus);
+            if ((LoadStatus == LoadStatus.FirstVisuallyNonEmptyLayout ||
+                LoadStatus == LoadStatus.Finished) && Uri != "about:blank") {
                 if (fixup_javascript != null) {
                     ExecuteScript (fixup_javascript);
                 }
             }
-
-            base.OnLoadStatusChanged (status);
         }
 
-        protected override OssiferNavigationResponse OnMimeTypePolicyDecisionRequested (string mimetype)
+        protected override bool OnMimeTypePolicyDecisionRequested (WebKit.WebFrame frame, WebKit.NetworkRequest request, string mimetype, WebKit.WebPolicyDecision policy_decision)
         {
             // We only explicitly accept (render) text/html -- everything else is ignored.
             switch (mimetype) {
-                case "text/html": return OssiferNavigationResponse.Accept;
+                case "text/html":
+                    policy_decision.Use ();
+                    return true;
                 default:
                     Log.Debug ("OssiferWebView: ignoring mime type", mimetype);
-                    return OssiferNavigationResponse.Ignore;
+                    policy_decision.Ignore ();
+                    return true;
             }
         }
 
@@ -155,4 +212,12 @@ namespace Banshee.WebSource
             });
         }
     }
+
+    public static class WebKitExtensions
+    {
+        public static string GetContentType (this Download download)
+        {
+            return download.NetworkResponse.Message.ResponseHeaders.GetContentType (IntPtr.Zero);
+        }
+    }
 }
diff --git a/src/Core/Banshee.WebBrowser/Makefile.am b/src/Core/Banshee.WebBrowser/Makefile.am
index b1c0006..dc5c159 100644
--- a/src/Core/Banshee.WebBrowser/Makefile.am
+++ b/src/Core/Banshee.WebBrowser/Makefile.am
@@ -1,5 +1,3 @@
-SUBDIRS = libossifer
-
 ASSEMBLY = Banshee.WebBrowser
 TARGET = library
 LINK = $(REF_BANSHEE_WEBBROWSER)
@@ -7,12 +5,6 @@ INSTALL_DIR = $(DEFAULT_INSTALL_DIR)
 
 SOURCES =  \
 	Banshee.WebBrowser/NavigationControl.cs \
-	Banshee.WebBrowser/OssiferCookie.cs \
-	Banshee.WebBrowser/OssiferDownloadStatus.cs \
-	Banshee.WebBrowser/OssiferLoadStatus.cs \
-	Banshee.WebBrowser/OssiferNavigationResponse.cs \
-	Banshee.WebBrowser/OssiferSession.cs \
-	Banshee.WebBrowser/OssiferWebView.cs \
 	Banshee.WebSource/WebBrowserShell.cs \
 	Banshee.WebSource/WebSource.cs \
 	Banshee.WebSource/WebView.cs \
diff --git a/src/Extensions/Banshee.AmazonMp3.Store/Banshee.AmazonMp3.Store/StoreView.cs b/src/Extensions/Banshee.AmazonMp3.Store/Banshee.AmazonMp3.Store/StoreView.cs
index d2ee92c..e6079bb 100644
--- a/src/Extensions/Banshee.AmazonMp3.Store/Banshee.AmazonMp3.Store/StoreView.cs
+++ b/src/Extensions/Banshee.AmazonMp3.Store/Banshee.AmazonMp3.Store/StoreView.cs
@@ -28,6 +28,7 @@
 using System;
 
 using Gtk;
+using WebKit;
 
 using Hyena;
 using Hyena.Downloader;
@@ -40,7 +41,7 @@ using Banshee.AmazonMp3;
 
 namespace Banshee.AmazonMp3.Store
 {
-    public class StoreView : WebView
+    public class StoreView : Banshee.WebSource.WebView
     {
         // We ask that no one change this redirect URL. ALL (100%) revenue
         // generated by this Banshee Amazon integration is sent directly to the
@@ -58,6 +59,8 @@ namespace Banshee.AmazonMp3.Store
             "it"
         };
 
+        //private Soup.CookieJar cookie_jar;
+
         private static bool IsAmzContentType (string contentType)
         {
             switch (contentType) {
@@ -83,18 +86,29 @@ namespace Banshee.AmazonMp3.Store
 
         public StoreView ()
         {
+            /*var session = WebKit.Global.DefaultSession;
+
+            var path = String.Format ("{0}.txt", "banshee-cookies");
+            cookie_jar = new Soup.CookieJarText (path, false);
+            session.AddFeature (cookie_jar);
+            //cookie_jar.Changed += OnCookieJarChanged;
+
+            cookie_jar = (Soup.CookieJar) WebKit.Global.DefaultSession.GetFeature (Soup.CookieJar.GType);
+            Console.WriteLine ("Cookie jar null? {0}", cookie_jar == null);*/
+
             CanSearch = true;
             FixupJavascriptUrl = "http://integrated-services.banshee.fm/amz/amz-fixups.js";;
 
-            OssiferSession.CookieChanged += (o, n) => CheckSignIn ();
+            //OssiferSession.CookieChanged += (o, n) => CheckSignIn ();
 
             // Ensure that Amazon knows a valid downloader is available,
             // otherwise the purchase experience is interrupted with a
             // confusing message about downloading and installing software.
             foreach (var domain in domains) {
-                OssiferSession.SetCookie ("dmusic_download_manager_enabled",
+                Console.WriteLine (domain);
+                /*cookie_jar.SetCookie ("dmusic_download_manager_enabled",
                     AmzMp3Downloader.AmazonMp3DownloaderCompatVersion,
-                    ".amazon." + domain, "/", TimeSpan.FromDays (365.2422));
+                    ".amazon." + domain, "/", TimeSpan.FromDays (365.2422));*/
             }
 
             Country = StoreSourcePreferences.StoreCountry.Get ();
@@ -103,24 +117,26 @@ namespace Banshee.AmazonMp3.Store
             FullReload ();
         }
 
-        protected override OssiferNavigationResponse OnMimeTypePolicyDecisionRequested (string mimetype)
+        protected override bool OnMimeTypePolicyDecisionRequested (WebKit.WebFrame frame, WebKit.NetworkRequest request, string mimetype, WebKit.WebPolicyDecision policy_decision)
         {
             // We only explicitly accept (render) text/html types, and only
             // download what we can import or preview.
             if (IsAmzContentType (mimetype) || mimetype == "audio/x-mpegurl") {
-                return OssiferNavigationResponse.Download;
+                policy_decision.Download ();
+                return true;
             }
 
-            return base.OnMimeTypePolicyDecisionRequested (mimetype);
+            return base.OnMimeTypePolicyDecisionRequested (frame, request, mimetype, policy_decision);
         }
 
-        protected override string OnDownloadRequested (string mimetype, string uri, string suggestedFilename)
+        protected override string OnDownloadRequested (Download download, string mimetype, string uri, string suggestedFilename)
         {
             if (IsAmzContentType (mimetype)) {
                 var dest_uri_base = "file://" + Paths.Combine (Paths.TempDir, suggestedFilename);
                 var dest_uri = new SafeUri (dest_uri_base);
                 for (int i = 1; File.Exists (dest_uri);
                     dest_uri = new SafeUri (String.Format ("{0} ({1})", dest_uri_base, ++i)));
+                download.StatusChanged += OnDownloadStatusChanged;
                 return dest_uri.AbsoluteUri;
             } else if (mimetype == "audio/x-mpegurl") {
                 Banshee.Streaming.RadioTrackInfo.OpenPlay (uri);
@@ -131,17 +147,21 @@ namespace Banshee.AmazonMp3.Store
             return null;
         }
 
-        protected override void OnDownloadStatusChanged (OssiferDownloadStatus status, string mimetype, string destinationUri)
+        private void OnDownloadStatusChanged (object o, EventArgs args)
         {
+            var download = o as Download;
+
             // FIXME: handle the error case
-            if (status != OssiferDownloadStatus.Finished) {
+            if (download.Status != DownloadStatus.Finished) {
                 return;
+            } else {
+                download.StatusChanged -= OnDownloadStatusChanged;
             }
 
-            if (IsAmzContentType (mimetype)) {
-                Log.Debug ("OssiferWebView: downloaded purchase list", destinationUri);
+            if (IsAmzContentType (download.GetContentType ())) {
+                Log.Debug ("OssiferWebView: downloaded purchase list", download.DestinationUri);
                 Banshee.ServiceStack.ServiceManager.Get<AmazonMp3DownloaderService> ()
-                    .DownloadAmz (new SafeUri (destinationUri).LocalPath);
+                    .DownloadAmz (new SafeUri (download.DestinationUri).LocalPath);
             }
         }
 
@@ -160,12 +180,13 @@ namespace Banshee.AmazonMp3.Store
         {
             // Shouldn't just clear these cookies; going to Amazon's signout page is more secure,
             // since it will invalidate the session itself.
-            /*foreach (var name in new [] { "at-main", "x-main", "session-id",
+            foreach (var name in new [] { "at-main", "x-main", "session-id",
                 "session-id-time", "session-token", "uidb-main", "pf"}) {
                 foreach (var domain in domains) {
-                    OssiferSession.DeleteCookie (name, ".amazon." + domain, "/");
+                    Console.WriteLine (domain, name);
+                    //Session.DeleteCookie (name, ".amazon." + domain, "/");
                 }
-            }*/
+            }
 
             LoadUri (GetActionUrl ("sign_out/"));
         }
@@ -174,8 +195,9 @@ namespace Banshee.AmazonMp3.Store
         {
             var signed_in = false;
             foreach (var domain in domains) {
-                signed_in |= OssiferSession.GetCookie ("at-main", ".amazon." + domain, "/") != null;
-                signed_in |= OssiferSession.GetCookie ("at-acbuk", ".amazon." + domain, "/") != null;
+                //signed_in |= Session.GetCookie ("at-main", ".amazon." + domain, "/") != null;
+                //signed_in |= Session.GetCookie ("at-acbuk", ".amazon." + domain, "/") != null;
+                Console.WriteLine (domain);
             }
 
             if (IsSignedIn != signed_in) {
diff --git a/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs
index 064cf63..270103e 100644
--- a/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs
+++ b/src/Extensions/Banshee.Emusic.Store/Banshee.Emusic.Store/StoreView.cs
@@ -30,6 +30,7 @@
 using System;
 
 using Gtk;
+using WebKit;
 
 using Hyena;
 using Hyena.Downloader;
@@ -42,7 +43,7 @@ using Banshee.Emusic;
 
 namespace Banshee.Emusic.Store
 {
-    public class StoreView : WebView
+    public class StoreView : Banshee.WebSource.WebView
     {
         private static bool IsEmusicContentType (string contentType)
         {
@@ -53,23 +54,24 @@ namespace Banshee.Emusic.Store
         {
             CanSearch = true;
             IsSignedIn = false;
-            OssiferSession.CookieChanged += (o, n) => CheckSignIn ();
+            //Session.CookieChanged += (o, n) => CheckSignIn ();
             CheckSignIn ();
             FullReload ();
         }
 
-        protected override OssiferNavigationResponse OnMimeTypePolicyDecisionRequested (string mimetype)
+        protected override bool OnMimeTypePolicyDecisionRequested (WebKit.WebFrame frame, WebKit.NetworkRequest request, string mimetype, WebKit.WebPolicyDecision policy_decision)
         {
             // We only explicitly accept (render) text/html types, and only
             // download what we can import or preview.
             if (IsEmusicContentType (mimetype) || mimetype == "audio/x-mpegurl") {
-                return OssiferNavigationResponse.Download;
+                policy_decision.Download ();
+                return true;
             }
 
-            return base.OnMimeTypePolicyDecisionRequested (mimetype);
+            return base.OnMimeTypePolicyDecisionRequested (frame, request, mimetype, policy_decision);
         }
 
-        protected override string OnDownloadRequested (string mimetype, string uri, string suggestedFilename)
+        protected override string OnDownloadRequested (Download download, string mimetype, string uri, string suggestedFilename)
         {
             if (IsEmusicContentType (mimetype)) {
                 // BZZT BZZT! Secret "insecure temporary file" code detected.
@@ -77,6 +79,7 @@ namespace Banshee.Emusic.Store
                 var dest_uri = new SafeUri (dest_uri_base);
                 for (int i = 1; File.Exists (dest_uri);
                     dest_uri = new SafeUri (String.Format ("{0} ({1})", dest_uri_base, ++i)));
+                download.StatusChanged += OnDownloadStatusChanged;
                 return dest_uri.AbsoluteUri;
             } else if (mimetype == "audio/x-mpegurl") {
                 Banshee.Streaming.RadioTrackInfo.OpenPlay (uri);
@@ -87,17 +90,21 @@ namespace Banshee.Emusic.Store
             return null;
         }
 
-        protected override void OnDownloadStatusChanged (OssiferDownloadStatus status, string mimetype, string destinationUri)
+        private void OnDownloadStatusChanged (object o, EventArgs args)
         {
+            var download = o as Download;
+
             // FIXME: handle the error case
-            if (status != OssiferDownloadStatus.Finished) {
+            if (download.Status != DownloadStatus.Finished) {
                 return;
+            } else {
+                download.StatusChanged -= OnDownloadStatusChanged;
             }
 
-            if (IsEmusicContentType (mimetype)) {
-                Log.Debug ("OssiferWebView: downloaded purchase list", destinationUri);
+            if (IsEmusicContentType (download.GetContentType ())) {
+                Log.Debug ("OssiferWebView: downloaded purchase list", download.DestinationUri);
                 Banshee.ServiceStack.ServiceManager.Get<EmusicService> ()
-                    .ImportEmx (new SafeUri (destinationUri).LocalPath);
+                    .ImportEmx (new SafeUri (download.DestinationUri).LocalPath);
                 Reload ();
             }
         }
@@ -122,7 +129,7 @@ namespace Banshee.Emusic.Store
 
         private void CheckSignIn ()
         {
-            bool signed_in = OssiferSession.GetCookie ("EMUSIC_REMEMBER_ME_COOKIE", "www.emusic.com", "/") != null;
+            bool signed_in = false;//OssiferSession.GetCookie ("EMUSIC_REMEMBER_ME_COOKIE", "www.emusic.com", "/") != null;
 
             if (IsSignedIn != signed_in) {
                 IsSignedIn = signed_in;
diff --git a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/View.cs b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/View.cs
index ac9a2d1..7f6fd86 100644
--- a/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/View.cs
+++ b/src/Extensions/Banshee.MiroGuide/Banshee.MiroGuide/View.cs
@@ -30,6 +30,7 @@ using System.Web;
 using Mono.Unix;
 
 using Gtk;
+using WebKit;
 
 using Hyena;
 using Hyena.Json;
@@ -39,6 +40,7 @@ using Banshee.Base;
 using Banshee.IO;
 using Banshee.ServiceStack;
 using Banshee.WebBrowser;
+using Banshee.WebSource;
 
 namespace Banshee.MiroGuide
 {
@@ -58,25 +60,28 @@ namespace Banshee.MiroGuide
                 : Catalog.GetString ("Search for video podcasts");
         }
 
-        protected override void OnLoadStatusChanged (OssiferLoadStatus status)
+        protected override void OnLoadStatusChanged ()
         {
-            if (status == OssiferLoadStatus.Finished && Uri != null && Uri.StartsWith ("http://miroguide.com";)) {
+            if (LoadStatus == LoadStatus.Finished && Uri != null && Uri.StartsWith ("http://miroguide.com";)) {
                 LastPageWasAudio = Uri.Contains ("miroguide.com/audio/");
                 UpdateSearchText ();
             }
 
-            base.OnLoadStatusChanged (status);
+            base.OnLoadStatusChanged ();
         }
 
-        protected override OssiferNavigationResponse OnMimeTypePolicyDecisionRequested (string mimetype)
+        protected override bool OnMimeTypePolicyDecisionRequested (WebKit.WebFrame frame, WebKit.NetworkRequest request, string mimetype, WebKit.WebPolicyDecision policy_decision)
         {
             switch (mimetype) {
-                case "application/x-miro": return OssiferNavigationResponse.Download;
-                default:                   return base.OnMimeTypePolicyDecisionRequested (mimetype);
+                case "application/x-miro":
+                    policy_decision.Download ();
+                    return true;
+                default:
+                    return base.OnMimeTypePolicyDecisionRequested (frame, request, mimetype, policy_decision);
             }
         }
 
-        protected override string OnDownloadRequested (string mimetype, string uri, string suggestedFilename)
+        protected override string OnDownloadRequested (Download download, string mimetype, string uri, string suggestedFilename)
         {
             switch (mimetype) {
                 case "application/x-miro":
@@ -84,37 +89,40 @@ namespace Banshee.MiroGuide
                     var dest_uri = new SafeUri (dest_uri_base);
                     for (int i = 1; File.Exists (dest_uri);
                         dest_uri = new SafeUri (String.Format ("{0} ({1})", dest_uri_base, ++i)));
+                    download.StatusChanged += OnDownloadStatusChanged;
                     return dest_uri.AbsoluteUri;
             }
 
             return null;
         }
 
-        protected override OssiferNavigationResponse OnNavigationPolicyDecisionRequested (string uri)
+        protected override bool OnNavigationPolicyDecisionRequested (WebKit.WebFrame frame, WebKit.NetworkRequest request, WebKit.WebNavigationAction navigation_action, WebKit.WebPolicyDecision policy_decision)
         {
             try {
-                if (TryBypassRedirect (uri) || TryInterceptListenWatch (uri)) {
-                    return OssiferNavigationResponse.Ignore;
+                if (TryBypassRedirect (request.Uri) || TryInterceptListenWatch (request.Uri)) {
+                    policy_decision.Ignore ();
+                    return true;
                 }
             } catch (Exception e) {
                 Log.Exception ("MiroGuide caught error trying to shortcut navigation", e);
             }
 
-            return OssiferNavigationResponse.Unhandled;
+            return false;
         }
 
-
-        protected override void OnDownloadStatusChanged (OssiferDownloadStatus status, string mimetype, string destinationUri)
+        private void OnDownloadStatusChanged (object o, EventArgs args)
         {
+            var download = (Download) o;
+
             // FIXME: handle the error case
-            if (status != OssiferDownloadStatus.Finished) {
+            if (download.Status != DownloadStatus.Finished) {
                 return;
             }
 
-            switch (mimetype) {
+            switch (download.GetContentType ()) {
                 case "application/x-miro":
-                    Log.Debug ("MiroGuide: downloaded Miro subscription file", destinationUri);
-                    ServiceManager.Get<DBusCommandService> ().PushFile (destinationUri);
+                    Log.Debug ("MiroGuide: downloaded Miro subscription file", download.DestinationUri);
+                    ServiceManager.Get<DBusCommandService> ().PushFile (download.DestinationUri);
                     break;
             }
         }
diff --git a/src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia/WikipediaView.cs b/src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia/WikipediaView.cs
index 0a5eb09..9d68514 100644
--- a/src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia/WikipediaView.cs
+++ b/src/Extensions/Banshee.Wikipedia/Banshee.Wikipedia/WikipediaView.cs
@@ -48,7 +48,7 @@ namespace Banshee.Wikipedia
         // Translators: this is used for looking up artist pages on Wikipedia; change to your wikipedia language if you want
         private string url_format = Catalog.GetString ("http://en.wikipedia.org/wiki/{0}";);
 
-        private OssiferWebView view;
+        private WebKit.WebView view;
         private ContextPage page;
 
         public WikipediaView (ContextPage page)
@@ -77,9 +77,9 @@ namespace Banshee.Wikipedia
             Hyena.Log.DebugFormat ("Opening {0}", uri);
 
             if (view == null) {
-                view = new OssiferWebView ();
+                view = new WebKit.WebView ();
                 view.LoadStatusChanged += delegate {
-                    if (view.LoadStatus == Banshee.WebBrowser.OssiferLoadStatus.FirstVisuallyNonEmptyLayout) {
+                    if (view.LoadStatus == WebKit.LoadStatus.FirstVisuallyNonEmptyLayout) {
                         page.SetLoaded ();
                     }
                 };



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]