Index: browser-plugin/totemPlugin.h
===================================================================
RCS file: /cvs/gnome/totem/browser-plugin/totemPlugin.h,v
retrieving revision 1.10
diff -p -u -B -r1.10 totemPlugin.h
--- browser-plugin/totemPlugin.h	15 Nov 2006 17:21:16 -0000	1.10
+++ browser-plugin/totemPlugin.h	15 Nov 2006 21:07:49 -0000
@@ -245,6 +245,15 @@ class totemPlugin {
 
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
+#ifdef TOTEM_MULLY_PLUGIN
+  private:
+    nsresult SetPreviewImage (const nsACString &aURL);
+    void RequestPreviewImage ();
+
+    nsIURI *mPreviewImageURI;
+
+#endif /* TOTEM_MULLY_PLUGIN */
+
   private:
 
     PRUint32 mAutostart : 1;
Index: browser-plugin/totemPlugin.cpp
===================================================================
RCS file: /cvs/gnome/totem/browser-plugin/totemPlugin.cpp,v
retrieving revision 1.43
diff -p -u -B -r1.43 totemPlugin.cpp
--- browser-plugin/totemPlugin.cpp	15 Nov 2006 17:21:16 -0000	1.43
+++ browser-plugin/totemPlugin.cpp	15 Nov 2006 21:07:50 -0000
@@ -196,6 +196,10 @@ totemPlugin::~totemPlugin ()
 	NS_IF_RELEASE (mPluginOwnerDocument);
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
+#ifdef TOTEM_MULLY_PLUGIN
+	NS_IF_RELEASE (mPreviewImageURI);
+#endif /* TOTEM_MULLY_PLUGIN */
+
 	D ("totemPlugin dtor [%p]", (void*) this);
 }
 
@@ -524,6 +528,12 @@ totemPlugin::ViewerReady ()
 
 	mViewerReady = PR_TRUE;
 
+#ifdef TOTEM_MULLY_PLUGIN
+	if (mPreviewImageURI) {
+		RequestPreviewImage ();
+	}
+	else
+#endif /* TOTEM_MULLY_PLUGIN */
 	if (mAutostart) {
 		RequestStream ();
 	} else {
@@ -694,6 +705,13 @@ totemPlugin::RequestStream ()
 #endif
 #endif
 
+#ifdef TOTEM_MULLY_PLUGIN
+	if (mPreviewImageURI) {
+		requestURI = mPreviewImageURI;
+		baseURI = mBaseURI;
+	}
+#endif /* TOTEM_MULLY_PLUGIN */
+
 	/* Fallback */
 	if (!requestURI)
 		requestURI = mSrcURI;
@@ -946,13 +964,13 @@ totemPlugin::IsMimeTypeSupported (const 
 {
 	NS_ENSURE_TRUE (mimetype, PR_FALSE);
 
-#if defined(TOTEM_MULLY_PLUGIN) || defined(TOTEM_GMP_PLUGIN)
+#if defined(TOTEM_NARROWSPACE_PLUGIN) || defined(TOTEM_GMP_PLUGIN) || defined(TOTEM_MULLY_PLUGIN)
 	/* We can always play those image types */
 	if (strcmp (mimetype, "image/jpeg") == 0)
 		return PR_TRUE;
 	if (strcmp (mimetype, "image/gif") == 0)
 		return PR_TRUE;
-#endif /* TOTEM_MULLY_PLUGIN || TOTEM_GMP_PLUGIN */
+#endif /* TOTEM_NARROWSPACE_PLUGIN || TOTEM_GMP_PLUGIN || TOTEM_MULLY_PLUGIN */
 
 	/* Stupid web servers will do that */
 	if (strcmp (mimetype, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0)
@@ -1470,6 +1488,57 @@ totemPlugin::UnownedViewerUnsetWindow ()
 
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
+#ifdef TOTEM_MULLY_PLUGIN
+
+nsresult
+totemPlugin::SetPreviewImage (const nsACString& aURL)
+{
+	if (mPreviewImageURI) {
+		NS_RELEASE (mPreviewImageURI);
+		mPreviewImageURI = nsnull;
+	}
+
+	/* Don't allow empty previewimage */
+	if (aURL.IsEmpty ())
+		return NS_OK;
+
+	/* FIXME: what is the correct base URI for previewimage? */
+	nsresult rv;
+	nsIURI *baseURI;
+	if (mSrcURI) {
+		baseURI = mSrcURI;
+	} else {
+		baseURI = mBaseURI;
+	}
+
+	rv = mIOService->NewURI (aURL, nsnull /* FIXME document charset? */,
+				 baseURI, &mPreviewImageURI);
+	if (NS_FAILED (rv)) {
+		D ("Failed to create PreviewImage URI (rv=%x)", rv);
+	}
+
+	/* FIXME: security checks? */
+
+	return rv;
+}
+
+void
+totemPlugin::RequestPreviewImage ()
+{
+	if (mPreviewImageURI) {
+		mAutostart = PR_FALSE;
+		mWaitingForButtonPress = PR_TRUE;
+
+		RequestStream ();
+		DoCommand (TOTEM_COMMAND_PLAY); /* FIXME */
+
+		NS_RELEASE (mPreviewImageURI);
+		mPreviewImageURI = nsnull;
+	}
+}
+
+#endif /* TOTEM_MULLY_PLUGIN */
+
 /* Plugin glue functions */
 
 NPError
@@ -1708,12 +1777,12 @@ totemPlugin::Init (NPMIMEType mimetype,
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
-/* FIXME */
-#if 0 //def TOTEM_MULLY_PLUGIN
+#ifdef TOTEM_MULLY_PLUGIN
 	/* Click to play behaviour of the DivX plugin */
-	char *previewimage = (const char *) g_hash_table_lookup (args, "previewimage");
-	if (value != NULL)
-		mHref = g_strdup (mSrc);
+	value = (const char *) g_hash_table_lookup (args, "previewimage");
+	if (value != NULL) {
+		SetPreviewImage (nsDependentCString (value));
+	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
 	/* If we're set to start automatically, we'll use the src stream */
@@ -1821,6 +1890,14 @@ totemPlugin::Init (NPMIMEType mimetype,
 	D ("mConsole: %s", mConsole.get ());
 	D ("mControls: %s", mControls.get ());
 #endif /* TOTEM_COMPLEX_PLUGIN */
+#ifdef TOTEM_MULLY_PLUGIN
+	if (mPreviewImageURI) {
+		nsCString spec;
+		mPreviewImageURI->GetSpec (spec);
+
+		D ("mPreviewImageURI: %s", spec.get ());
+	}
+#endif /* TOTEM_MULLY_PLUGIN */
 
 	g_hash_table_destroy (args);
 
