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

📄 hxsymbianapman.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: hxsymbianapman.cpp,v 1.2.2.2 2004/07/09 02:08:48 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 "platform/symbian/hxsymbianapman.h"#include "ihxpckts.h"#include "debug.h"#define D_AP_MANAGER 0x20000000const UINT32 DefaultNumOfRetries = 1; /* Number of connect retries before				       * reporting the error. The retry				       * mechanism is needed because switching				       * access points can cause the first				       * connect to fail. This is a documented				       * Symbian bug.				       */class HXSymbianAPManAO : public CActive{public:    HXSymbianAPManAO(HXSymbianAccessPointManager* pParent,		     CIntConnectionInitiator* pConnInit);    ~HXSymbianAPManAO();    HX_RESULT Connect(UINT32 ulAccessPointId);    HX_RESULT Disconnect();    void RunL();    void DoCancel();private:    HXSymbianAccessPointManager* m_pParent;    CIntConnectionInitiator* m_pConnInit;    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref m_connPref;    BOOL m_bConnecting;};HXSymbianAPManAO::HXSymbianAPManAO(HXSymbianAccessPointManager* pParent,				   CIntConnectionInitiator* pConnInit) :    CActive(EPriorityStandard),    m_pParent(pParent),    m_pConnInit(pConnInit),    m_bConnecting(FALSE){    CActiveScheduler::Add(this);}HXSymbianAPManAO::~HXSymbianAPManAO(){    if (IsActive())    {	Cancel();    }        m_pParent = 0;    m_pConnInit = 0;}HX_RESULT HXSymbianAPManAO::Connect(UINT32 ulAccessPointId){    HX_RESULT res = HXR_UNEXPECTED;    if (m_pConnInit && !IsActive())    {	TInt theErr = KErrNone;	m_bConnecting = TRUE;	iStatus = KRequestPending;	m_connPref.iRanking = 1; // Means always try this pref	m_connPref.iDirection = ECommDbConnectionDirectionOutgoing;	m_connPref.iDialogPref = ECommDbDialogPrefDoNotPrompt;	m_connPref.iBearer.iBearerSet = (ECommDbBearerGPRS | ECommDbBearerCSD);	m_connPref.iBearer.iIapId = ulAccessPointId;		TRAP(theErr, m_pConnInit->ConnectL(m_connPref, iStatus));		if (KErrNone == theErr)	{	    SetActive();	    res = HXR_OK;	}	else	{	    res = HXR_NET_CONNECT;	}    }    return res;}HX_RESULT HXSymbianAPManAO::Disconnect(){    HX_RESULT res = HXR_FAILED;    if (m_pConnInit && !IsActive())    {	m_bConnecting = FALSE;	iStatus = KRequestPending;	if (KErrNone == m_pConnInit->TerminateActiveConnection(iStatus))	{	    SetActive();	    res = HXR_OK;	}    }    return res;}void HXSymbianAPManAO::RunL(){    if (m_pParent)    {	HX_RESULT status = HXR_NET_CONNECT;		if (m_bConnecting)	{	    if ((iStatus == KErrNone) ||		(iStatus == KConnectionPref1Exists) ||		(iStatus == KConnectionExists) ||		(iStatus == KConnectionPref1Created) ||		(iStatus == KConnectionCreated) ||		(iStatus == KErrOutstandingRequest))	    {		status = HXR_OK;	    }	    m_pParent->ConnectDone(status);	}	else 	{	    if ((iStatus == KErrNone) ||		(iStatus == KConnectionTerminated) ||		(iStatus == KErrOutstandingRequest))	    {		status = HXR_OK;	    }	    m_pParent->DisconnectDone(status);	}    }}void HXSymbianAPManAO::DoCancel(){    // Cancel possible outstanding request     if(m_pConnInit && m_pConnInit->IsActive())    {        m_pConnInit->Cancel();    }}BEGIN_INTERFACE_LIST(HXSymbianAccessPointManager)    INTERFACE_LIST_ENTRY_SIMPLE(IHXAccessPointManager)    INTERFACE_LIST_ENTRY_SIMPLE(IHXAccessPointSelectorResponse)END_INTERFACE_LISTHXSymbianAccessPointManager::HXSymbianAccessPointManager():    m_state(apError),    m_pConnInit(0),    m_pConnector(0),    m_pPreferredInfo(NULL),    m_pCCF(NULL),    m_pAPSelector(NULL),    m_bSelectAPPending(FALSE){#ifdef _DEBUG    debug_level() |= D_AP_MANAGER;#endif /* _DEBUG */    DPRINTF(D_AP_MANAGER, ("HXSymbianAccessPointManager::HXSymbianAccessPointManager()\n"));    TRAPD(theErr, m_pConnInit = CIntConnectionInitiator::NewL());    m_pConnector = new HXSymbianAPManAO(this, m_pConnInit);    if (m_pConnInit && m_pConnector &&	(KErrNone == m_sockServ.Connect()) &&	(KErrNone == theErr))    {	m_state = apIdle;    }}HXSymbianAccessPointManager::~HXSymbianAccessPointManager(){    DPRINTF(D_AP_MANAGER, ("HXSymbianAccessPointManager::~HXSymbianAccessPointManager()\n"));    HX_DELETE(m_pConnector);    HX_DELETE(m_pConnInit);    HX_RELEASE(m_pPreferredInfo);    HX_RELEASE(m_pCCF);    HX_RELEASE(m_pAPSelector);    m_sockServ.Close();    DispatchConnectDones(HXR_FAILED);}/* * IHXAccessPointManager methods *//************************************************************************ *	Method: *	    IHXAccessPointManager::Connect *	Purpose: *	    Notifies the access point manager that an object wants the access *      point to connect to it's ISP. * */STDMETHODIMPHXSymbianAccessPointManager::Connect(THIS_ IHXAccessPointConnectResponse* pResp){    DPRINTF(D_AP_MANAGER, ("HXSymbianAccessPointManager::Connect()\n"));     HX_RESULT res = HXR_FAILED;    if (pResp)    {	res = DoConnect(pResp);    }        return res;}/************************************************************************ *	Method: *	    IHXAccessPointManager::RegisterSelector *	Purpose: *      Provides the IHXAccessPointManager with an IHXAccessPointSelector  *      to use when it needs information about the desired access point. * */STDMETHODIMP HXSymbianAccessPointManager::RegisterSelector(THIS_ IHXAccessPointSelector* pSelector){    HX_RESULT res = HXR_FAILED;    // Currently we only support 1 registered selector so    // we only allow this call to succeed if m_pAPSelector    // is not set.    if (pSelector && !m_pAPSelector)    {	m_pAPSelector = pSelector;	m_pAPSelector->AddRef();	res = HXR_OK;    }    return res;}    /************************************************************************ *	Method: *	    IHXAccessPointManager::UnregisterSelector *	Purpose: *      Unregisters a previously registered IHXAccessPointSelector * */STDMETHODIMPHXSymbianAccessPointManager::UnregisterSelector(THIS_ IHXAccessPointSelector* pSelector) {    HX_RESULT res = HXR_FAILED;    // We only allow one registered selector so this call    // will only succeed if the pSelector is a valid pointer    // and matches the selector that was registered.    if (pSelector && (pSelector == m_pAPSelector))    {	HX_RELEASE(m_pAPSelector);    }    return res;}    /************************************************************************ *	Method: *	    IHXAccessPointManager::GetActiveAccessPointInfo *	Purpose: *      Returns information about the access point we are currently  *      connected to. This function returns an error if we are  *      not connected to an access point. * */STDMETHODIMPHXSymbianAccessPointManager::GetActiveAccessPointInfo(THIS_ REF(IHXValues*) pInfo){    HX_RESULT res = HXR_UNEXPECTED;    pInfo = NULL;    if (m_pCCF)    {	ULONG32 ulActiveID = 0;		res = GetActiveID(ulActiveID);	if (HXR_OK == res)	{	    res = m_pCCF->CreateInstance(CLSID_IHXValues, (void**)&pInfo);	    	    if (HXR_OK == res)	    {		res = pInfo->SetPropertyULONG32("ID", ulActiveID);				if (HXR_OK != res)		{		    HX_RELEASE(pInfo);		}	    }	}    }    DPRINTF(D_AP_MANAGER, 	    ("HXSymbianAccessPointManager::GetActiveAccessPointInfo() : %08x\n",	     res));        return res;}/************************************************************************ *	Method: *	    IHXAccessPointManager::GetPreferredAccessPointInfo

⌨️ 快捷键说明

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