⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hurl.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: hurl.cpp,v 1.5.32.3 2004/07/09 01:47:27 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */#include <string.h>#include <stdio.h>#ifndef _MAC_MACHO#include <InternetConfig.h>#endif#include "hxtypes.h"#include "hxcom.h"     /* IUnknown */#include "ihxpckts.h"  /* IHXBuffer */#include "platform/mac/hurl.h"#include "hxwintyp.h"#if defined(_CARBON) || defined(_MAC_UNIX)	#include "platform/mac/mac_pref_cf.h"#ifndef _MAC_UNIX	#include "filespecutils.h"	#include "MoreFilesX.h"#endif	static BOOL LaunchMacBrowserCarbon(const char* pURL, IHXPreferences* pPrefs, BOOL bBringToFront, BOOL bNewWindow);	static BOOL GetPreferredBrowser(IHXPreferences* pPrefs, FSRef *outBrowserFSRef, OSType *outBrowserSignature);	static void MakeHurlJavascriptURL(const char * pszURL, const char * pszWindowName, 		BOOL bSetPosition, const HXxPoint& ptWindowPos, const HXxSize& sizeWindow, CHXString& outStrURL, BOOL bUseNewJavascriptWindow);#else	#include "mac_pref.h"#endif // _CARBON// Stuff for using ODOCs instead of OpenURL for Unicode UTF-8 URLs because IE 5.2 and Netscape can't// deal with UTF8 in URLs; we'll send ODOCs instead of OpenURL events in those casesBoolean IsLocalFileURLAPotentialProblemBecauseOfPercentEncodedUTF8Chars(const char *pURL);BOOL	MakeOpenDocumentsEventFromURL(OSType appSignature, const char* pURL, AEDesc *theAppleEventPtr, Boolean bNewWindow);#include "platform/mac/hx_moreprocesses.h"#ifndef _MAC_UNIX#include "hx_morefiles.h"#include "fullpathname.h"#include "hxinternetconfigutils.h"#endif#include "hxresult.h"#include "hxprefs.h"const	DescType		kWebBrowserSuite			=	'WWW!';const	DescType		kOpenUrlEventID				=	'OURL';const	DescType		kOpenUrlWindowID			=	'WIND';const	DescType		kCloseAllWindowsEventID			=	'CLSA';const 	OSType			MSIE_CREATOR				=  'MSIE';const 	OSType			NETSCAPE_CREATOR			=  'MOSS';const 	OSType			MOZILLA_CREATOR				=  'MOZZ';const 	OSType			AOL_CREATOR				=  'AOp3';const 	OSType			OMNIWEB_CREATOR				=  'OWEB';const	OSType			ICAB_CREATOR				=  'iCAB';const	OSType			CHIMERA_CREATOR				=  'CHIM';const	OSType			OPERA_CREATOR				=  'OPRA';const	OSType			SAFARI_CREATOR				=  'sfri'; 	const	OSType			MOSAIC_CREATOR				=  'MOS!';const   OSType			MOSAIC_BrowserSuite			=  'mos!';const	OSType			MOSAIC_OpenUrlEventID			=  'ourl';// if there's no default browser signature that we can determine from HX prefs or from InternetConfig,// we'll look for one in this list, in this orderstatic OSType BrowserCreators[] 	= { SAFARI_CREATOR, MSIE_CREATOR, NETSCAPE_CREATOR, MOZILLA_CREATOR, AOL_CREATOR,		OMNIWEB_CREATOR, ICAB_CREATOR, CHIMERA_CREATOR, OPERA_CREATOR, 0 }; // what's Opera?  Any others?/********************************************************************	LaunchMacBrowserWithURL	********************************************************************/BOOL LaunchMacBrowserWithURL(const char* pURL, IHXPreferences* pPrefs){		const BOOL bBringToFront = TRUE;		return LaunchMacBrowserWithURLOrdered(pURL, pPrefs, bBringToFront);}BOOL LaunchMacBrowserWithURLOrdered(const char* pURL, IHXPreferences* pPrefs, BOOL bBringToFront){		const BOOL bExistingWindow = FALSE;		return LaunchMacBrowserWithURLWindowParam(pURL, pPrefs, bBringToFront, bExistingWindow);}BOOL LaunchMacBrowserTargetingWindow(const char* pURL, IHXPreferences* pPrefs, BOOL bBringToFront, 	const char* pTargetWindowName, BOOL bUseNewJavascriptWindow){	// if bUseNewJavascriptWindow is false, then we won't make a new window for the javascript to execute in;	// on some browsers, this will make the javascript fail to execute if no windows are open.		const BOOL kDontSetPosition = FALSE;	HXxPoint ptUnset = { 0, 0 };	HXxSize szUnset = { 0, 0 };	CHXString strNewURL;		MakeHurlJavascriptURL(pURL, pTargetWindowName, kDontSetPosition, ptUnset, szUnset, strNewURL, bUseNewJavascriptWindow);	if (strNewURL.IsEmpty())	{		check(!"LaunchMacBrowserTargetingWindow could not make Javascript URL");		strNewURL = pURL;	}		// we make a new window since the Javascript will blow away the existing window		return LaunchMacBrowserWithURLWindowParam(strNewURL, pPrefs, bBringToFront, bUseNewJavascriptWindow);}BOOL LaunchMacBrowserWithURLWindowParam(const char* pURL, IHXPreferences* pPrefs, BOOL bBringToFront, BOOL bNewWindow){	#if defined(_CARBON) || defined(_MAC_UNIX)	return LaunchMacBrowserCarbon(pURL, pPrefs, bBringToFront, bNewWindow);#else	    OSErr theErr = noErr;    CPBusyCursor busyCursor;        Size urlLen = ::strlen(pURL);    Boolean launched = FALSE;	    // Check to see if the default browser is running, otherwise launch it.    // Then send it an openURL event.    OSType    defaultBrowser = 'PNst';    IHXBuffer* pBuffer = NULL;    Boolean bICStarted = HXInternetConfigMac::StartUsingIC();	if (pPrefs)	{	    if (HXR_OK == pPrefs->ReadPref("PreferredBrowser", pBuffer))	    {	    	const char* theBrowserFilePath = (const char*) pBuffer->GetBuffer();	    	if (theBrowserFilePath)	    	{				FInfo 	applFinderInfo;				FSSpec 	spec;				if (noErr == FSSpecFromPathName(theBrowserFilePath, &spec))				{					if (noErr == FSpGetFInfo(&spec, &applFinderInfo))					{						defaultBrowser = applFinderInfo.fdCreator;					}				}			}	    	pBuffer->Release();	    }	}    	    /* get Preferred Browser from InternetConfig unless either       InternetConfig isn't linked in, System 8.1, OR       Preferences dictate a specific browser. */    if (defaultBrowser == 'PNst')    {	    if (ICStart) // not linked with IC for some reason - pre Sys 8.1?	    {	    	unsigned char *kDontCareBrowserName = NULL;	    		    	OSStatus err = HXInternetConfigMac::GetHTTPHelper(&defaultBrowser, kDontCareBrowserName);	    }		else		{			defaultBrowser = NETSCAPE_CREATOR;		}	}        OSType    openBrowser = 0;    FSSpec cachedDefaultBrowserSpec;    {				// check if any browser is already running		if (CheckForApplicationRunning(NETSCAPE_CREATOR))		    openBrowser = NETSCAPE_CREATOR;		else if (CheckForApplicationRunning(MSIE_CREATOR))		    openBrowser = MSIE_CREATOR;		else if (CheckForApplicationRunning(AOL_CREATOR))		    openBrowser = AOL_CREATOR;		if (!openBrowser)		{		    short	volindex=1;		    short	vRefNum=0;		    		    // Look through all volumes for the default browser application.		    while (GetVRefnumFromIndex(volindex,&vRefNum)) 		    {				short	fileindex=0;				while (noErr==HX_FSpGetAppSpecFromDesktop(defaultBrowser,fileindex,						vRefNum,&cachedDefaultBrowserSpec))				{				    FInfo	finfo;				    FSpGetFInfo(&cachedDefaultBrowserSpec,&finfo);				    if (finfo.fdType=='APPL') 				    {						AppleEvent theEvent;												//do this at idle time! don't want to launch app at interrupt time						if (MakeOpenURLEvent(defaultBrowser, pURL, &theEvent, bNewWindow))						{							ProcessSerialNumber* kDontCareAboutPSN = NULL;							short launchFlags;														if (bBringToFront) 							{								launchFlags = (launchContinue | launchNoFileFlags);							}							else							{								launchFlags = (launchContinue | launchNoFileFlags | launchDontSwitch);							}							theErr = FSpLaunchApplicationWithParamsAndFlags(&cachedDefaultBrowserSpec, &theEvent, 								kDontCareAboutPSN, launchFlags);							if (theErr == noErr)							{								launched = TRUE;							}														(void) AEDisposeDesc(&theEvent);						}										    }//if				    else 				    {						fileindex++;						continue;				    }//else					break;				}//while								if (launched) break;				volindex++;		    }//while		}//if				if( !launched && openBrowser)		{		 	const BOOL bAsync = TRUE;		    launched = SendOpenURLOrdered(openBrowser,pURL, bAsync, bBringToFront, bNewWindow);		}						if ( bICStarted && !launched )		{			theErr = HXInternetConfigMac::LaunchURL(pURL);						launched = (theErr == noErr);		}		goto CleanUp;    }//ifCleanUp:	if (bICStarted)	{		HXInternetConfigMac::StopUsingIC();	}		return (launched);	#endif // !defined _CARBON}BOOL	SendOpenURL(OSType	appSignature, const char* pURL, BOOL async) {	const BOOL bBringToFront = TRUE;		return SendOpenURLOrdered(appSignature, pURL, async, bBringToFront);}BOOL	SendOpenURLOrdered(OSType	appSignature, const char* pURL, BOOL async, BOOL bBringToFront, BOOL bNewWindow) {	AEDesc				theAppleEvent;	AEDesc				outAEReply;	OSErr				err;		if (MakeOpenURLEvent(appSignature, pURL, &theAppleEvent, bNewWindow))	{		if (async)		{			err = AESend (&theAppleEvent, &outAEReply, 					 kAENoReply + kAEDontRecord, kAEHighPriority, kNoTimeOut, nil, nil);		}		else		{			err = AESend (&theAppleEvent, &outAEReply,					kAEWaitReply+kAEDontRecord, kAEHighPriority, kNoTimeOut,nil,nil);			AEDisposeDesc(&outAEReply);		}				if (bBringToFront)		{			ActivateApplication(appSignature);		}				(void) AEDisposeDesc(&theAppleEvent);	}	else	{		err = -1;	}	return (err == noErr);}BOOL	SendOpenURLSync(OSType	appSignature, const char* pURL) {	return SendOpenURL(appSignature,pURL,false);}//SendOpenURLSyncBOOL	SendOpenURLAsync(OSType	appSignature, const char* pURL) {	return SendOpenURL(appSignature,pURL,true);}//SendOpenURLASync// MakeOpenURLEvent//// The caller is responsible for disposing of theAppleEventPtr allocated by this routineBOOL	MakeOpenURLEvent(OSType	appSignature, const char* pURL, AEDesc *theAppleEventPtr, Boolean bNewWindow) {	if (IsLocalFileURLAPotentialProblemBecauseOfPercentEncodedUTF8Chars(pURL))	{		// for local file URLs which have UTF8 characters in them encoded as % hex,		// we use an ODOC event instead of the OpenURL event since IE 5.2 and Netscape 6.?		// can't handle the UTF8 URLs		return MakeOpenDocumentsEventFromURL(appSignature, pURL, theAppleEventPtr, bNewWindow);	}		AEDesc				target;	OSErr				err;	AEEventClass		eventClass;	AEEventID			eventID;		if (MOSAIC_CREATOR == appSignature)	{		eventClass = MOSAIC_BrowserSuite;		eventID = MOSAIC_OpenUrlEventID;	} 	else	{		eventClass = kWebBrowserSuite;		eventID = kOpenUrlEventID;	} 	// Create an application signature address.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -