From 4e8c33e7252d38d00b5606e1960aa520c75e0227 Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Tue, 10 Aug 2010 13:04:01 -0700
Subject: Added support for targeted links opening new windows to
 llmediaplugintest.

---
 indra/test_apps/llplugintest/llmediaplugintest.cpp | 76 +++++++++++++++++++---
 indra/test_apps/llplugintest/llmediaplugintest.h   |  6 +-
 2 files changed, 72 insertions(+), 10 deletions(-)

(limited to 'indra/test_apps')

diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp
index 7a544debb2..166905c37c 100644
--- a/indra/test_apps/llplugintest/llmediaplugintest.cpp
+++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp
@@ -959,6 +959,23 @@ mediaPanel*  LLMediaPluginTest::findMediaPanel( LLPluginClassMedia* source )
 	return result;
 }
 
+////////////////////////////////////////////////////////////////////////////////
+//
+mediaPanel* LLMediaPluginTest::findMediaPanel( const std::string &target_name )
+{
+	mediaPanel *result = NULL;
+
+	for( int panel = 0; panel < (int)mMediaPanels.size(); ++panel )
+	{
+		if ( mMediaPanels[ panel ]->mTarget == target_name )
+		{
+			result = mMediaPanels[ panel ];
+		}
+	}
+
+	return result;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 //
 void LLMediaPluginTest::navigateToNewURI( std::string uri )
@@ -1571,7 +1588,7 @@ std::string LLMediaPluginTest::pluginNameFromMimeType( std::string& mime_type )
 
 ////////////////////////////////////////////////////////////////////////////////
 //
-void LLMediaPluginTest::addMediaPanel( std::string url )
+mediaPanel* LLMediaPluginTest::addMediaPanel( std::string url )
 {
 	// Get the plugin filename using the URL
 	std::string mime_type = mimeTypeFromUrl( url );
@@ -1603,7 +1620,7 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
 	if (NULL == getcwd( cwd, FILENAME_MAX - 1 ))
 	{
 		std::cerr << "Couldn't get cwd - probably too long - failing to init." << std::endl;
-		return;
+		return NULL;
 	}
 	std::string user_data_path = std::string( cwd ) + "/";
 #endif
@@ -1673,6 +1690,8 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
 
 		std::cout << "Adding new media panel for " << url << "(" << media_width << "x" << media_height << ") with index " << panel->mId << " - total panels = " << mMediaPanels.size() << std::endl;
 	}
+	
+	return panel;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1778,15 +1797,15 @@ void LLMediaPluginTest::updateMediaPanel( mediaPanel* panel )
 
 ////////////////////////////////////////////////////////////////////////////////
 //
-void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
+mediaPanel* LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
 {
 	// no media panels so we can't change anything - have to add
 	if ( mMediaPanels.size() == 0 )
-		return;
+		return NULL;
 
 	// sanity check
 	if ( ! panel )
-		return;
+		return NULL;
 
 	int index;
 	for(index = 0; index < (int)mMediaPanels.size(); index++)
@@ -1798,7 +1817,7 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
 	if(index >= (int)mMediaPanels.size())
 	{
 		// panel isn't in mMediaPanels
-		return;
+		return NULL;
 	}
 
 	std::cout << "Replacing media panel with index " << panel->mId << std::endl;
@@ -1840,7 +1859,7 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
 	if (NULL == getcwd( cwd, FILENAME_MAX - 1 ))
 	{
 		std::cerr << "Couldn't get cwd - probably too long - failing to init." << std::endl;
-		return;
+		return NULL;
 	}
 	std::string user_data_path = std::string( cwd ) + "/";
 #endif
@@ -1880,6 +1899,8 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
 	// load and start the URL
 	panel->mMediaSource->loadURI( url );
 	panel->mMediaSource->start();
+	
+	return panel;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2139,7 +2160,46 @@ void LLMediaPluginTest::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e
 		break;
 
 		case MEDIA_EVENT_CLICK_LINK_HREF:
-			std::cerr <<  "Media event:  MEDIA_EVENT_CLICK_LINK_HREF, uri is " << self->getClickURL() << std::endl;
+		{
+			std::cerr <<  "Media event:  MEDIA_EVENT_CLICK_LINK_HREF, uri is " << self->getClickURL() << ", target is " << self->getClickTarget() << std::endl;
+			// retrieve the event parameters
+			std::string url = self->getClickURL();
+			std::string target = self->getClickTarget();
+			U32 target_type = self->getClickTargetType();
+
+			switch (target_type)
+			{
+				case LLPluginClassMedia::TARGET_NONE:
+					// ignore this click
+				break;
+				
+				case LLPluginClassMedia::TARGET_EXTERNAL:
+					// this should open in an external browser, but since this is a test app we don't care.
+				break;
+				
+				case LLPluginClassMedia::TARGET_BLANK:
+					// Create a new panel with the specified URL.
+					addMediaPanel(url);
+				break;
+
+				case LLPluginClassMedia::TARGET_OTHER:
+					mediaPanel *target_panel = findMediaPanel(target);
+					if(target_panel)
+					{
+						target_panel = replaceMediaPanel(target_panel, url);
+					}
+					else
+					{
+						target_panel = addMediaPanel(url);
+					}
+
+					if(target_panel)
+					{
+						target_panel->mTarget = target;
+					}
+				break;
+			}
+		}
 		break;
 
 		case MEDIA_EVENT_CLICK_LINK_NOFOLLOW:
diff --git a/indra/test_apps/llplugintest/llmediaplugintest.h b/indra/test_apps/llplugintest/llmediaplugintest.h
index 5d08e42148..ecd6cbfc4f 100644
--- a/indra/test_apps/llplugintest/llmediaplugintest.h
+++ b/indra/test_apps/llplugintest/llmediaplugintest.h
@@ -56,6 +56,7 @@ struct mediaPanel
 		int mId;
 		std::string mStartUrl;
 		std::string mMimeType;
+		std::string mTarget;
 		LLPluginClassMedia *mMediaSource;
 		int mMediaWidth;
 		int mMediaHeight;
@@ -96,16 +97,17 @@ class LLMediaPluginTest : public LLPluginClassMediaOwner
 		void draw( int draw_type );
 		void windowPosToTexturePos( int window_x, int window_y, int& media_x, int& media_y, int& id );
 
-		void addMediaPanel( std::string url );
+		mediaPanel* addMediaPanel( std::string url );
 		void updateMediaPanel( mediaPanel* panel );
 		void remMediaPanel( mediaPanel* panel );
-		void replaceMediaPanel( mediaPanel* panel, std::string url );
+		mediaPanel* replaceMediaPanel( mediaPanel* panel, std::string url );
 		void getRandomMediaSize( int& width, int& height, std::string mime_type );
 		void navigateToNewURI( std::string uri );
         void initUrlHistory( std::string uri );
 		void selectPanelById( int id );
 		void selectPanel( mediaPanel* panel );
 		mediaPanel* findMediaPanel( LLPluginClassMedia* panel );
+		mediaPanel* findMediaPanel( const std::string &target_name );
 		void makePickTexture( int id, GLuint* texture_handle, unsigned char** texture_pixels );
 		void makeChrome();
 		void resetView();
-- 
cgit v1.2.3


From a2657be5782f20c3cbab542b5a3775d78e21cdfa Mon Sep 17 00:00:00 2001
From: Monroe Linden <monroe@lindenlab.com>
Date: Tue, 17 Aug 2010 17:56:54 -0700
Subject: Viewer side changes to support javascript window.close handling.

---
 indra/test_apps/llplugintest/llmediaplugintest.cpp | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'indra/test_apps')

diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp
index 166905c37c..4e39f1ccd1 100644
--- a/indra/test_apps/llplugintest/llmediaplugintest.cpp
+++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp
@@ -2213,6 +2213,10 @@ void LLMediaPluginTest::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e
 		case MEDIA_EVENT_PLUGIN_FAILED_LAUNCH:
 			std::cerr <<  "Media event:  MEDIA_EVENT_PLUGIN_FAILED_LAUNCH" << std::endl;
 		break;
+
+		case MEDIA_EVENT_CLOSE_REQUEST:
+			std::cerr <<  "Media event:  MEDIA_EVENT_CLOSE_REQUEST" << std::endl;
+		break;
 	}
 }
 
-- 
cgit v1.2.3