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

📄 hxhypnv.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** 
 * Version: RCSL 1.0/RPSL 1.0 
 *  
 * Portions Copyright (c) 1995-2002 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 
 * Version 1.0 (the "RPSL") available at 
 * http://www.helixcommunity.org/content/rpsl unless you have licensed 
 * the file under the RealNetworks Community Source License Version 1.0 
 * (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.  
 *  
 * 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 <stdio.h>

#include "hxtypes.h"
#include "hxresult.h"
#include "hxcom.h"
#include "hxprefs.h"
#include "hxhyper.h"
#include "hxtick.h"
#include "hxstrutl.h"
#include "ihxpckts.h"

#include "hxhypnv.h"
#include "hxurlwrp.h"
#include "hxurl.h"

#if defined (_WIN16)
#include <stdlib.h>
#include <windows.h>
#include <shellapi.h>
#endif

#if defined (_WINDOWS) || defined (_WIN32)
#include <ddeml.h>
#include "platform/win/sdidde.h"

BOOL CALLBACK FindAOLWindowProc(HWND hwnd, LPARAM lParam);

#endif /*defined (_WINDOWS) || defined (_WIN32)*/

#include "dbcs.h" // needed for DBCS-relative string-processing functions

#if defined(_UNIX) && !defined(_VXWORKS) && !defined(_MAC_UNIX)
#include "unix_hurl.h"
#endif

#if defined(_MACINTOSH) || defined(_MAC_UNIX)
#include "platform/mac/hurl.h"
#endif

#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif


// amount of time to wait before trying to launch a browser with the same URL as
// the previous launch. Used in GoToURL to prevent the case where double-clicking
// calls GoToURL() twice, with the 2nd call launching a browser to the same URL while
// the first is still launching
#define MILLISEC_BETWEEN_BROWSER_LAUNCH 2000

#define _MAX_AOL_HURL_URL_SIZE	124

/****************************************************************************
 *
 *  Interface:
 *
 *	HXHyperNavigate
 *
 *  Purpose:
 *
 *	TBD
 *
 *  IID_IHXHyperNavigate:
 *
 *	{00000900-61DF-11d0-9CEE-080017035B43}
 *
 */


HXHyperNavigate::HXHyperNavigate() :
      m_lRefCount(0)
    , m_pPreferences(0)
    , m_bInitialized(FALSE)
    , m_pLastURL(NULL)
    , m_nLastLaunchTime(0)
    , m_bKeepTargetBehind(FALSE)
{
#if defined (_WINDOWS) || defined (_WIN32)
    DDEStartup();
#endif /*defined (_WINDOWS) || defined (_WIN32)*/
}

HXHyperNavigate::~HXHyperNavigate()
{
#if defined (_WINDOWS) || defined (_WIN32)
    DDEShutdown();
#endif /*defined (_WINDOWS) || defined (_WIN32)*/

    HX_RELEASE(m_pPreferences);
    HX_VECTOR_DELETE(m_pLastURL);
}

/////////////////////////////////////////////////////////////////////////
//	Method:
//		IUnknown::QueryInterface
//	Purpose:
//		Implement this to export the interfaces supported by your
//		object.
//
STDMETHODIMP HXHyperNavigate::QueryInterface(REFIID riid, void** ppvObj)
{
    QInterfaceList qiList[] =
        {
            { GET_IIDHANDLE(IID_IHXHyperNavigate), (IHXHyperNavigate*)this },
            { GET_IIDHANDLE(IID_IHXHyperNavigate2), (IHXHyperNavigate2*)this },
            { GET_IIDHANDLE(IID_IUnknown), (IUnknown*)(IHXHyperNavigate*)this },
        };
    
    return ::QIFind(qiList, QILISTSIZE(qiList), riid, ppvObj);
}

/////////////////////////////////////////////////////////////////////////
//	Method:
//		IUnknown::AddRef
//	Purpose:
//		Everyone usually implements this the same... feel free to use
//		this implementation.
//
STDMETHODIMP_(ULONG32) HXHyperNavigate::AddRef()
{
    return InterlockedIncrement(&m_lRefCount);
}

/////////////////////////////////////////////////////////////////////////
//	Method:
//		IUnknown::Release
//	Purpose:
//		Everyone usually implements this the same... feel free to use
//		this implementation.
//
STDMETHODIMP_(ULONG32) HXHyperNavigate::Release()
{
    if (InterlockedDecrement(&m_lRefCount) > 0)
    {
	return m_lRefCount;
    }
    
    delete this;
    return 0;
}



STDMETHODIMP HXHyperNavigate::Init(IUnknown* pContext)
{
    if (!pContext)
    {
	return HXR_UNEXPECTED;
    }

    IHXPreferences* pPreferences = 0;
    if (pContext->QueryInterface(IID_IHXPreferences, (void**) &pPreferences) != HXR_OK)
    {
	return HXR_UNEXPECTED;
    }

    if (m_pPreferences)
    {
	m_pPreferences->Release();
	m_pPreferences = 0;
    }

    m_pPreferences = pPreferences;

#if defined (_WINDOWS) || defined (_WIN32)
    DDEInit(m_pPreferences);
#endif /*defined (_WINDOWS) || defined (_WIN32)*/


#if defined(_UNIX) && !defined(_VXWORKS) && !defined(_MAC_UNIX)
    StartHurlListener();
#endif /* _UNIX */

    m_bInitialized = TRUE;
    return HXR_OK;
}


/*
 *	IHXHyperNavigate methods
 */


/************************************************************************
 *	Method:
 *	    IHXHyperNavigate::GoToURL
 *	Purpose:
 *	    Performs a simple Go To URL operation.
 */
STDMETHODIMP HXHyperNavigate::GoToURL( const char* pURL,
					const char* pTarget)
{    
    if (!m_bInitialized)
    {
	return HXR_NOT_INITIALIZED;
    }

    if ((pURL == NULL) ||
	(pTarget && (stricmp(pTarget, "_player") == 0)) ||
	(strnicmp(pURL, URL_COMMAND, sizeof(URL_COMMAND) - 1) == 0))
    {
	return HXR_NOTIMPL;
    }

    UINT32 nCurrentTime = HX_GET_TICKCOUNT();

    // if user recently launched browser with same URL, then don't launch browser again..
    // Prevents case of double-clicking causing 2 browser launches, when second
    // click happens before first browser is up.
    if  ( m_pLastURL!=NULL && strcmp(pURL,m_pLastURL)==0 &&
    	  CALCULATE_ELAPSED_TICKS(m_nLastLaunchTime,nCurrentTime)<MILLISEC_BETWEEN_BROWSER_LAUNCH)
	return HXR_OK;

    CHXString encodedURL;
    if (strncasecmp(pURL, "http:", 5) == 0)
    {
	CHXURL::encodeURL(pURL, encodedURL);

	pURL = (const char*) encodedURL;
    }

    // note when we last attempted a browser launch (no puns please)
    m_nLastLaunchTime = nCurrentTime;

    HX_VECTOR_DELETE(m_pLastURL);

    // save the URL we are going to launch..
    m_pLastURL = new char[strlen(pURL)+1];
    strcpy(m_pLastURL,pURL); /* Flawfinder: ignore */

    CHXURL url(pURL);
    pURL = url.GetURL();   // will do compression of ../../, if so required

#ifndef _MACINTOSH
    // GR 7/13/01 -  We don't need to wrap on the Mac since the URL length
    // limition for hurling doesn't apply, and we don't want to wrap since 
    // local file URLs under Mac OS X do not begin file:///Hard Drive/...
    
    CHXString strHtmlFile;

    if (strlen(pURL) > _MAX_AOL_HURL_URL_SIZE)
    {
	if (SUCCEEDED(CHXUrlWrapper::Wrap(pURL, &strHtmlFile )))
	{
#ifdef _MACINTOSH
	    strHtmlFile = "file:///" + strHtmlFile;
#else
	    strHtmlFile = "file://" + strHtmlFile;
#endif	    
	    pURL = (const char*)strHtmlFile;
	}
    }
#endif // !_MACINTOSH
    
#if defined (_WINDOWS) || defined (_WIN32)
    CHXString strPreferredBrowser;

    if(m_pPreferences)
    {
	IHXBuffer* pPreferredBrowser = NULL;

	if(m_pPreferences->ReadPref("PreferredBrowser", pPreferredBrowser) == HXR_OK)

⌨️ 快捷键说明

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