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

📄 hxsymbianapman.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
 *	Purpose: *      Returns information about the access point we want to connect to. */STDMETHODIMPHXSymbianAccessPointManager::GetPreferredAccessPointInfo(THIS_ REF(IHXValues*) pInfo){    HX_RESULT res = HXR_FAILED;    pInfo = m_pPreferredInfo;    if (pInfo)    {	res = HXR_OK;    }    DPRINTF(D_AP_MANAGER, 	    ("HXSymbianAccessPointManager::GetPreferredAccessPointInfo() : %08x\n",	     res));    return res;}/************************************************************************ *	Method: *	    IHXAccessPointManager::SetPreferredAccessPointInfo *	Purpose: *      Tells the access point manager about the access  *      point we would like it to connect to. */STDMETHODIMPHXSymbianAccessPointManager::SetPreferredAccessPointInfo(THIS_ IHXValues* pInfo){    HX_RESULT res = HXR_FAILED;    ULONG32 ulAccessPointID = 0;    if (pInfo && (HXR_OK == pInfo->GetPropertyULONG32("ID", ulAccessPointID)))    {	HX_RELEASE(m_pPreferredInfo);	m_pPreferredInfo = pInfo;	m_pPreferredInfo->AddRef();	res = HXR_OK;    }    else    {	HX_RELEASE(m_pPreferredInfo);    }    return res;}/* * IHXAccessPointSelectorResponse methods *//************************************************************************ *	Method: *	    IHXAccessPointSelectorResponse::SelectAccessPointDone *	Purpose: *      Returns the selected access point info */STDMETHODIMPHXSymbianAccessPointManager::SelectAccessPointDone(THIS_ HX_RESULT status, 						   IHXValues* pInfo){    HX_RESULT res = HXR_UNEXPECTED;    if (m_bSelectAPPending)    {	m_bSelectAPPending = FALSE;	if ((HXR_OK == status) &&	    (HXR_OK == SetPreferredAccessPointInfo(pInfo)))	{	    status = DoConnect(0);	}	if (HXR_OK != status)	{	    if (HXR_OUTOFMEMORY != status)	    {		status = HXR_NET_CONNECT;	    }	    DispatchConnectDones(status);	}	res = HXR_OK;    }    return res;}void HXSymbianAccessPointManager::SetContext(IUnknown* pContext){    if (pContext)    {	pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&m_pCCF);    }}HX_RESULT HXSymbianAccessPointManager::DoConnect(IHXAccessPointConnectResponse* pResp){    DPRINTF(D_AP_MANAGER, ("HXSymbianAccessPointManager::DoConnect(%p)\n", 			   pResp));    HX_RESULT res = HXR_FAILED;    ULONG32 ulActiveId = 0;    ULONG32 ulPreferredId = 0;    BOOL bQueueResponse = (pResp) ? TRUE : FALSE;    if (HXR_OK == GetPreferredID(ulPreferredId))    {	// We have a preferred access point set	if (HXR_OK != GetActiveID(ulActiveId))	{	    // We don't have an active access point	    if (apConnected == m_state)	    {		// The access point disconnected without		// our knowledge. Update our state.		m_state = apIdle;	    }	    // Start to connect	    res = StartConnection();	}	else if (ulActiveId == ulPreferredId)	{	    // We have a preferred access point and we are connected	    // to it.	    // Dispatch the callbacks now.	    if (pResp)	    {		pResp->ConnectDone(HXR_OK);		bQueueResponse = FALSE;	    }		    if (apIdle == m_state)	    {		m_state = apConnected;		// Dispatch any other pending callbacks		DispatchConnectDones(HXR_OK);	    }	    	    res = HXR_OK;	}	else	{	    // We need to disconnect from the current access	    // point	    	    res = StartDisconnect();	}    }    else    {	// We don't have a preferred access point	if (m_pAPSelector)	{	    if (!m_bSelectAPPending)	    {		// Use the Selector to get the preferred access point		m_bSelectAPPending = TRUE;		res = m_pAPSelector->SelectAccessPoint(this);		if (HXR_OK != res)		{		    m_bSelectAPPending = FALSE;		}	    }	    else	    {		// A SelectAccessPoint() request is currently		// pending		res = HXR_OK;	    }	}	else	{	    // We have no way to get access point information.	    res = HXR_NET_CONNECT;	}    }    if ((HXR_OK == res) && bQueueResponse)    {	pResp->AddRef();	m_respList.AddTail(pResp);    }    return res;}HX_RESULT HXSymbianAccessPointManager::StartConnection(){    DPRINTF(D_AP_MANAGER, ("HXSymbianAccessPointManager::StartConnection()\n"));    HX_RESULT res = HXR_UNEXPECTED;    BOOL bConnect = TRUE;    if (apIdle == m_state)    {	m_ulRetryCount = DefaultNumOfRetries;    }    else if (apConnecting != m_state)    {	bConnect = FALSE;    }    if (bConnect && m_pPreferredInfo)    {	ULONG32 ulAccessPointID = 0;	res = m_pPreferredInfo->GetPropertyULONG32("ID", ulAccessPointID);	if (HXR_OK == res)	{	    res = m_pConnector->Connect(ulAccessPointID);	    if (HXR_OK == res)	    {		m_state = apConnecting;	    }	}    }    DPRINTF(D_AP_MANAGER, 	    ("HXSymbianAccessPointManager::StartConnection() : res %08x\n",	     res));    return res;}void HXSymbianAccessPointManager::ConnectDone(HX_RESULT status){    DPRINTF(D_AP_MANAGER, 	    ("HXSymbianAccessPointManager::ConnectDone(%08x)\n",	     status));    HX_ASSERT(apConnecting == m_state);    BOOL bReportStatus = TRUE;    if (HXR_OK == status)    {	m_state = apConnected;    }    else if (m_ulRetryCount)    {	// Sometimes the first connect fails if we	// disconnect from an access point and then	// connect to a different one. This is a	// documented Symbian bug.	// Try to connect again	m_ulRetryCount--;	status = StartConnection();	if (HXR_OK == status)	{	    bReportStatus = FALSE;	}    }    else    {	// Connect and all retries failed.	// Transition back to the idle state	m_state = apIdle;    }    if (bReportStatus)    {	DispatchConnectDones(status);    }}HX_RESULT HXSymbianAccessPointManager::StartDisconnect(){    DPRINTF(D_AP_MANAGER, ("HXSymbianAccessPointManager::StartDisconnect()\n"));    HX_RESULT res = HXR_FAILED;        if (HXR_OK == m_pConnector->Disconnect())    {	m_state = apDisconnecting;	res = HXR_OK;    }    DPRINTF(D_AP_MANAGER, 	    ("HXSymbianAccessPointManager::StartDisconnect() : res %08x\n",	     res));    return res;}void HXSymbianAccessPointManager::DisconnectDone(HX_RESULT status){    DPRINTF(D_AP_MANAGER, 	    ("HXSymbianAccessPointManager::DisconnectDone(%08x)\n",	     status));    HX_ASSERT(apDisconnecting == m_state);    m_state = apIdle;    if (HXR_OK == status)    {	// Try to connect now	status = DoConnect(0);    }        if (HXR_OK != status)    {	// We failed to reconnect. Send the	// failure code to the response objects	DispatchConnectDones(status);    }}void HXSymbianAccessPointManager::DispatchConnectDones(HX_RESULT status){    DPRINTF(D_AP_MANAGER, 	    ("HXSymbianAccessPointManager::DispatchConnectDones(%08x)\n",	     status));    // Handle any pending connect requests    while(!m_respList.IsEmpty())    {	IHXAccessPointConnectResponse* pResp = 	    (IHXAccessPointConnectResponse*)m_respList.RemoveHead();	pResp->ConnectDone(status);	HX_RELEASE(pResp);    }}HX_RESULT HXSymbianAccessPointManager::GetPreferredID(REF(ULONG32) ulID){    HX_RESULT res = HXR_FAILED;    if (m_pPreferredInfo)    {	res = m_pPreferredInfo->GetPropertyULONG32("ID", ulID);    }    return res;}HX_RESULT HXSymbianAccessPointManager::GetActiveID(REF(ULONG32) ulID){    HX_RESULT res = HXR_FAILED;    TUint32 aIAPId = 0;    if (m_pConnInit && (KErrNone == m_pConnInit->GetActiveIap(aIAPId)))    {	ulID = aIAPId;	res = HXR_OK;    }    return res;}

⌨️ 快捷键说明

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