Retrieving currently active access point(转)

本文介绍在Symbian系统中如何通过MConnectionMonitorObserver接口重用当前活动的接入点(IAP),避免多次弹出接入点选择对话框。适用于S60平台的多个版本。
IDTSS000467Creation dateNovember 22, 2006
PlatformS60 2nd Edition, S60 2nd Edition FP1, FP2, and FP3
S60 3rd Edition, S60 3rd Edition FP1
Devices
CategorySymbian C++Subcategory

Keywords (APIs, classes, methods, functions):

Overview

Retrieving currently active access point

Description

There are several instances where the system will prompt the user with an access point selection dialog. For example,    - Initiating an HTTP connection
    - Downloading a file with Download Manager API
    - Opening a URL in Browser Control API
It is possible to reuse the active access point. A common use case would be opening an HTTP connection and starting a file download with Download Manager API. Reusing the access point prevents the AP selection dialog from being shown twice.

Solution

MConnectionMonitorObserver is an observer class that is provided to receive any event notifications like creation or deletion of a connection, IAP availability change etc. The client application must implement this interface in order to receive notifications.The steps involved are:
1) Derive the MConnectionMonitorObserver mixin class and implement the callback function EventL():

class CMyHTTPEngine : public MConnectionMonitorObserver
    {
    ...
 public:
    // from MConnectionObserver
    void EventL(const CConMonEvenBase& aConnEvent);
    ...
 private:
    RConnectionMonitor iConnMon;
    };
2) Register to get notifications on events before allowing the user to make an HTTP connection
    TInt err = iConnMon.ConnectL();
    iConnMon.NotifyEventL( *this );
    // … proceed to open HTTP connection

3) Handle received events and detect the ID of the active IAP
 CMyHTTPEngine::EventL(const CConMonEvenBase& aConnEvent)
    {
    TInt event = aConnEvent.EventType();
    TUint connId = aConnEvent.ConnectionId();  
    TUint iapId;
    TRequestStatus status;
     switch ( event )
        {
        case EConnMonCreateConnection: // New connection created
            {
            // Cast aConnEvent to CConnMonCreateConnection if needed
            iConnMon.GetUintAttribute(connId, 0, KIAPId, iapId, status);
       
            // Name of AP can be retrieved with
            // GetStringAttribute(connId, 0, KIAPName, ...)
            User::WaitForRequest( status );
            break;
            }
        case EConnMonCreateSubConnection: // Subconnection to an existing AP
            {
            TUint subConnId;
            // Cast aConnEvent to CConnMonCreateSubConnection if needed       
            const CConnMonCreateSubConnection
                subConnEvent = (CConnMonCreateSubConnection)aConnEvent;
            subConnId = subConnEvent.SubConnectionId();
            iConnMon.GetUintAttribute(connId, subConnId, KIAPId, iapId, status);
            // Name of AP can be retrieved with
            // GetStringAttribute(connId, subConnId, KIAPName, ...)
            User::WaitForRequest( status );
            break;
            }
        default:
            break;
        }
    // Close the monitor when event notifications are no longer required
    // iConnMon.Close();
    }
The observer can also be used for notifications on events like change in accessibility of an access point, deletion of an existing connection and changes in connection status.

转载于:https://www.cnblogs.com/yaoliang11/archive/2010/10/11/1848015.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值