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

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 1714
Date       : Wed Aug 23 15:52:54 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/menuops.cpp
   M /Trunk/XaraLX/Kernel/menuops.h
   M /Trunk/XaraLX/wxOil/camelot.cpp
   M /Trunk/XaraLX/wxOil/camelot.h
   M /Trunk/XaraLX/wxOil/menucmds.cpp
   M /Trunk/XaraLX/wxOil/menucmds.h
   M /Trunk/XaraLX/wxOil/xrc/EN/justin-strings.xrc
   M /Trunk/XaraLX/wxOil/xrc/EN/ollie-strings.xrc
   M /Trunk/XaraLX/wxOil/xrc/SHARED_MENU.res

Re-organise media replay code to improve code sharing and use this to allow user to change app selection. Also fix a stupid map usage mistake which could cause memory corruption on any machine except mine


Diff:
Index: Trunk/XaraLX/Kernel/menuops.h
===================================================================
--- Trunk/XaraLX/Kernel/menuops.h	(revision 1713)
+++ Trunk/XaraLX/Kernel/menuops.h	(revision 1714)
@@ -135,6 +135,7 @@
 #define OPTOKEN_HELPTOOLS		_T("HelpTools")
 #define OPTOKEN_HELPGALLERIES	_T("HelpGalleries")
 #define OPTOKEN_HELPDEMOS		_T("HelpDemos")
+#define OPTOKEN_HELPPLAYER		_T("HelpPlayer")
 #define OPTOKEN_HELPDEMOS_NATIVE _T("HelpDemosNative")
 #define OPTOKEN_HELPTECHSUPPORT	_T("HelpTechSupport")
 
Index: Trunk/XaraLX/Kernel/menuops.cpp
===================================================================
--- Trunk/XaraLX/Kernel/menuops.cpp	(revision 1713)
+++ Trunk/XaraLX/Kernel/menuops.cpp	(revision 1714)
@@ -1282,6 +1282,10 @@
 		WebsterDemos();
 	#endif //webster
 	}
+	else if (WhichOp->Token == String(OPTOKEN_HELPPLAYER))
+	{
+		HelpPlayerAction();
+	}
 	else if (WhichOp->Token == String(OPTOKEN_HELPTECHSUPPORT))
 		HelpTechSupportAction();
 //Webster_Ranbir_12	\96
@@ -1376,6 +1380,7 @@
 #define HID_HELP_TOOLS                          (0)
 #define HID_HELP_GALLERIES                      (0)
 #define HID_HELP_DEMOS                          (0)
+#define HID_HELP_PLAYER                         (0)
 #define HID_HELP_TECHSUPPORT            (0)
 
 BOOL HelpOps::Init()
@@ -1418,7 +1423,20 @@
 												0 );
 
 	ERRORIF(!DemosOp, _R(IDE_NOMORE_MEMORY), FALSE);
+	
+	// REGOP(HELP, PLAYER, HelpPlayer);
+	OpDescriptor* PlayerOp = new OpDescriptor(
+												0, 
+												_R(IDS_HELP_PLAYER),
+												CC_RUNTIME_CLASS(HelpOps), 
+												OPTOKEN_HELPPLAYER,
+												HelpOps::GetState,
+												HID_HELP_PLAYER,
+												_R(IDBBL_HELPPLAYEROP),
+												0 );
 
+	ERRORIF(!PlayerOp, _R(IDE_NOMORE_MEMORY), FALSE);
+
 	//Webster_Ranbir_12	\96
 #ifdef INC_WEB_MENU_ITEMS
 
Index: Trunk/XaraLX/wxOil/menucmds.cpp
===================================================================
--- Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1713)
+++ Trunk/XaraLX/wxOil/menucmds.cpp	(revision 1714)
@@ -834,6 +834,10 @@
 //	HelpOnlineDemos();
 }
 
+void HelpPlayerAction()
+{
+	CCamApp::SelectMediaApp();
+}
 
 void HelpTechSupportAction()
 {
Index: Trunk/XaraLX/wxOil/camelot.h
===================================================================
--- Trunk/XaraLX/wxOil/camelot.h	(revision 1713)
+++ Trunk/XaraLX/wxOil/camelot.h	(revision 1714)
@@ -155,6 +155,7 @@
 	static BOOL LaunchWebBrowser(const wxString& strUrl);
 
 	static bool LaunchMediaApp( const wxString& strUrl );
+	static bool SelectMediaApp();
 	
 	// Get the path to the root of the resource directory structure
 	static StringBase& GetResourceDirectory();
Index: Trunk/XaraLX/wxOil/camelot.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camelot.cpp	(revision 1713)
+++ Trunk/XaraLX/wxOil/camelot.cpp	(revision 1714)
@@ -2728,6 +2728,12 @@
 	wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
 }
 
+
+/**
+ * CMediaReplayDetect - Class which checks to see if a command is available 
+ * on the path
+ **/
+
 class CMediaReplayDetect
 {
 private:
@@ -2772,51 +2778,93 @@
 	}
 };
 
-bool CCamApp::LaunchMediaApp( const wxString& strUrl )
-{
-	CMediaReplayDetect	Detect;
-	static PCTSTR		apszApps[] = {  _T("mplayer"),
-									    _T("gmplayer"),
+/*********************************************************************************************
+>	static void FillMediaAppMap( SelMediaDlgParam::CMediaAppList* pMapMediaApp )
+
+	Author:		Luke_Hart <luke.hartΩxara.com>
+	Created:	23/08/06
+	Inputs:		pMapMediaApp - A map to contain all the media apps avaiable on system
+	Outputs:	-
+	Returns:	-
+	Purpose:	Retrieve a map of media replay applications
+	Errors:		-
+	Scope:	    Public
+	SeeAlso:	-
+
+ **********************************************************************************************/
+
+static PCTSTR			g_apszApps[] = {_T("mplayer"),
+										_T("gmplayer"),
 										PCTSTR(1),				// Everyting above this line supports mplayer control protocol
+										_T("gxine"),
 										_T("xine"),
 										_T("totem"),
 										_T("xfmedia"),
 										_T("codeine"),
 										NULL };
 
-	// Move array into a helpful structure
-	SelMediaDlgParam::CMediaAppList	mapMediaApp;
+static void FillMediaAppMap( SelMediaDlgParam::CMediaAppList* pMapMediaApp )
+{
+	// Add the basic list of applications
 	bool				fControlable = true;
 	UINT32				ord = 0;
-	while( NULL != apszApps[ord] )
+	while( NULL != g_apszApps[ord] )
 	{
 		// Skip controlable marker
-		if( PCTSTR(1) == apszApps[ord] )
+		if( PCTSTR(1) == g_apszApps[ord] )
 		{
 			++ord;
 			fControlable = false;
 			continue;
 		}
 
-		mapMediaApp.insert( std::make_pair( apszApps[ord], fControlable ) );
+		pMapMediaApp->insert( std::make_pair( g_apszApps[ord], fControlable ) );
 		++ord;
 	}
 
-	// First we see if the replay app. is present
-	if( !Detect.IsAppPresent( m_strMediaApplication ) )
+	// Remove any non-present apps
+	CMediaReplayDetect	Detect;
+	SelMediaDlgParam::CMediaAppListIter	end( pMapMediaApp->end() );
+	SelMediaDlgParam::CMediaAppListIter	iter( pMapMediaApp->begin() );
+	for( ; iter != end; )
 	{
-		// Remove any non-present apps
-		SelMediaDlgParam::CMediaAppListIter	end( mapMediaApp.end() );
-		SelMediaDlgParam::CMediaAppListIter	iter( mapMediaApp.begin() );
-		for( ; iter != end; ++iter )
+		SelMediaDlgParam::CMediaAppListIter	iterCur( iter++ ); 
+		if( !Detect.IsAppPresent( iterCur->first ) )
 		{
-			if( !Detect.IsAppPresent( iter->first ) )
-			{
-				mapMediaApp.erase( iter->first );
-				TRACEUSER( "jlh92", _T("%s is not present"), iter->first );
-			}
+			TRACEUSER( "luke", _T("%s is not present"), iterCur->first );
+			 pMapMediaApp->erase( iterCur->first );
 		}
+	}
+}
 
+
+/*********************************************************************************************
+>	bool CCamApp::LaunchMediaApp( const wxString& strUrl )
+
+	Author:		Luke_Hart <luke.hartΩxara.com>
+	Created:	23/08/06
+	Inputs:		strUrl - The path to the file conbtaining the movie to play (could even be 
+							web address)
+	Outputs:	-
+	Returns:	true if player launched successfully
+	Purpose:	This function attempts to replay a movie using configured player (or ask user 
+				to specify one if not already setup)
+	Errors:		-
+	Scope:	    Public
+	SeeAlso:	-
+
+ **********************************************************************************************/
+
+bool CCamApp::LaunchMediaApp( const wxString& strUrl )
+{
+	// Move array into a helpful structure
+	SelMediaDlgParam::CMediaAppList	mapMediaApp;
+	FillMediaAppMap( &mapMediaApp );
+
+	// First we see if the replay app. is present
+	CMediaReplayDetect	Detect;
+	if( !Detect.IsAppPresent( m_strMediaApplication ) )
+	{
 		// Setup param and open replay app selection dialog
 		SelMediaDlgParam	Param;
 		Param.m_pAppList = &mapMediaApp;
@@ -2833,16 +2881,13 @@
 		if( !Param.m_fValid )
 			return true;
 	}
-	else
-	{
-		// Pre-selected app, check to see if we can control it
-		SelMediaDlgParam::CMediaAppListIter iter = mapMediaApp.find( apszApps[ord] );
-		if( mapMediaApp.end() == iter )
-			fControlable = false;
-		else
-			fControlable = iter->second;
-	}
 
+	// Check to see if we can control the selected app. (maybe one day....)
+	SelMediaDlgParam::CMediaAppListIter iter = mapMediaApp.find( m_strMediaApplication );
+	bool				fControlable = false;
+	if( mapMediaApp.end() != iter )
+		fControlable = iter->second;
+
 	// Build the command line and execute it
 	wxString			strCommand;
 	strCommand = PCTSTR(m_strMediaApplication);
@@ -2859,16 +2904,56 @@
 	{
 		// Let this process run free!
 		plp->Disconnect();
-//		delete plp;								// This object will allegedly delete itself when the process dies
 	}
 	else
 	{
 		// Make sure we don't leave any zombie processes lying around
 		wxKillError e = plp->Terminate();		// This should result in a call to OnTerminate
 		TRACEUSER("Phil", _T("Terminating bad process returned %d
"), e);
-//		delete plp;								// This object will allegedly delete itself when the process dies
 	}
 
 	return ok;
 }
 
+/*********************************************************************************************
+>	bool CCamApp::SelectMediaApp()
+
+	Author:		Luke_Hart <luke.hartΩxara.com>
+	Created:	23/08/06
+	Inputs:		-
+	Outputs:	-
+	Returns:	true if user accepts new choice
+	Purpose:	This function allows a user to select which media replay app. they'd like
+				to use to replay the help movies
+	Errors:		-
+	Scope:	    Public
+	SeeAlso:	-
+
+ **********************************************************************************************/ 
+
+bool CCamApp::SelectMediaApp()
+{
+	// Move array into a helpful structure
+	SelMediaDlgParam::CMediaAppList	mapMediaApp;
+	FillMediaAppMap( &mapMediaApp );
+
+	// First we see if the replay app. is present
+	CMediaReplayDetect	Detect;
+
+	// Setup param and open replay app selection dialog
+	SelMediaDlgParam	Param;
+	Param.m_pAppList = &mapMediaApp;
+	Param.m_strSel	 = m_strMediaApplication;
+	OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor( CC_RUNTIME_CLASS(SelMediaDlg) ); 
+	if( NULL != pOpDesc )
+	{
+		pOpDesc->Invoke( &Param );
+	
+		if( Param.m_fValid )
+			m_strMediaApplication = Param.m_strSel;
+	}
+
+	// User canceled, bomb out
+	return Param.m_fValid;
+}
+
Index: Trunk/XaraLX/wxOil/xrc/EN/ollie-strings.xrc
===================================================================
--- Trunk/XaraLX/wxOil/xrc/EN/ollie-strings.xrc	(revision 1713)
+++ Trunk/XaraLX/wxOil/xrc/EN/ollie-strings.xrc	(revision 1714)
@@ -42,6 +42,12 @@
 			</object>
 			<object class="sizeritem">
 				<flag>wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE</flag>
+				<object class="wxStaticText" name="IDS_HELP_PLAYER">
+					<label>Select movie app.;Show a list of applications to use for help movie replay</label>
+				</object>
+			</object>
+			<object class="sizeritem">
+				<flag>wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE</flag>
 				<object class="wxStaticText" name="IDS_HELP_MOVIES_NATIVE">
 					<label>Movies test 2 (wxMediaCtrl);Show a list of movies you can watch</label>
 				</object>
Index: Trunk/XaraLX/wxOil/xrc/EN/justin-strings.xrc
===================================================================
--- Trunk/XaraLX/wxOil/xrc/EN/justin-strings.xrc	(revision 1713)
+++ Trunk/XaraLX/wxOil/xrc/EN/justin-strings.xrc	(revision 1714)
@@ -48,6 +48,12 @@
 			</object>
 			<object class="sizeritem">
 				<flag>wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE</flag>
+				<object class="wxStaticText" name="IDBBL_HELPPLAYEROP">
+					<label>Help on selecting movie replay app.</label>
+				</object>
+			</object>
+			<object class="sizeritem">
+				<flag>wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE</flag>
 				<object class="wxStaticText" name="IDBBL_HELPGALLERIESOP">
 					<label>Help on galleries</label>
 				</object>
Index: Trunk/XaraLX/wxOil/xrc/SHARED_MENU.res
===================================================================
--- Trunk/XaraLX/wxOil/xrc/SHARED_MENU.res	(revision 1713)
+++ Trunk/XaraLX/wxOil/xrc/SHARED_MENU.res	(revision 1714)
@@ -171,6 +171,7 @@
 		END
 		
 		MENUITEM "HelpDemos"
+		MENUITEM "HelpPlayer"
 		MENUITEM "HelpDemosNative"
 		MENUITEM "TipsDlg"			SEPARATOR
 		MENUITEM "Update"				SEPARATOR
Index: Trunk/XaraLX/wxOil/menucmds.h
===================================================================
--- Trunk/XaraLX/wxOil/menucmds.h	(revision 1713)
+++ Trunk/XaraLX/wxOil/menucmds.h	(revision 1714)
@@ -157,6 +157,7 @@
 void HelpToolsAction();
 void HelpGalleriesAction();
 void HelpDemosAction();
+void HelpPlayerAction();
 void HelpDemosNativeAction();
 void HelpTechSupportAction();
 void HelpXaraPurchasePage();


Xara