summaryrefslogtreecommitdiff
path: root/indra/test_apps/llplugintest/llmediaplugintest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/test_apps/llplugintest/llmediaplugintest.cpp')
-rw-r--r--indra/test_apps/llplugintest/llmediaplugintest.cpp129
1 files changed, 98 insertions, 31 deletions
diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp
index 7a544debb2..873fa23db8 100644
--- a/indra/test_apps/llplugintest/llmediaplugintest.cpp
+++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp
@@ -2,30 +2,25 @@
* @file LLMediaPluginTest.cpp
* @brief Primary test application for LLMedia (Separate Process) Plugin system
*
- * $LicenseInfo:firstyear=2008&license=viewergpl$
- *
- * Copyright (c) 2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -961,6 +956,23 @@ mediaPanel* LLMediaPluginTest::findMediaPanel( LLPluginClassMedia* source )
////////////////////////////////////////////////////////////////////////////////
//
+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 )
{
if ( uri.length() )
@@ -1571,7 +1583,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 +1615,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 +1685,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 +1792,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 +1812,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 +1854,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 +1894,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 +2155,39 @@ 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();
+
+ if(target == "_external")
+ {
+ // this should open in an external browser, but since this is a test app we don't care.
+ }
+ else if(target == "_blank")
+ {
+ // Create a new panel with the specified URL.
+ addMediaPanel(url);
+ }
+ else // other named target
+ {
+ 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;
case MEDIA_EVENT_CLICK_LINK_NOFOLLOW:
@@ -2153,6 +2201,25 @@ 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;
+
+ case MEDIA_EVENT_PICK_FILE_REQUEST:
+ std::cerr << "Media event: MEDIA_EVENT_PICK_FILE_REQUEST" << std::endl;
+ // TODO: display an actual file picker
+ self->sendPickFileResponse("cake");
+ break;
+
+ case MEDIA_EVENT_GEOMETRY_CHANGE:
+ std::cerr << "Media event: MEDIA_EVENT_GEOMETRY_CHANGE, uuid is " << self->getClickUUID()
+ << ", x = " << self->getGeometryX()
+ << ", y = " << self->getGeometryY()
+ << ", width = " << self->getGeometryWidth()
+ << ", height = " << self->getGeometryHeight()
+ << std::endl;
+ break;
}
}