标题:获取当前激活状态的接入点(转)


TSS000467
开发伙伴平台:
S60 2nd Edition, S60 2nd Edition FP1, FP2, and FP3
S60 3rd Edition, S60 3rd Edition FP1
详细描述
下列几种情况下,系统会弹出对话框提示用户选择一个接入点的,例如:

Code:

    - Initiating an HTTP connection 

    - Downloading a file with Download Manager API 

    - Opening a URL in Browser Control API

重复使用当前的访问接入点是可以的。当你打开一个HTTP链接,然后又利用Download Manager API开始下载一个文件时就会看到这样的情况。重复使用可以防止接入点提示对话框出现两次。
解决方案
MConnectionMonitorObserver是一个监控类可以监控连接事件如生成或删除一个连接,或IAP变化事件等。客户端程序必须要完成它的接口,以便接收处理通知。
包括如下步骤:
1)从MConnectionMonitorObserver继承并完成EventL()回调方法:

Code:

class CMyHTTPEngine : public MConnectionMonitorObserver

    {

    ...

 public:

    // from MConnectionObserver

    void EventL(const CConMonEvenBase& aConnEvent);

    ...

 private:

    RConnectionMonitor iConnMon; 

    };

2)在允许用户使用一个HTTP连接前注册以获取事件通知:

Code:

    TInt err = iConnMon.ConnectL();

    iConnMon.NotifyEventL( *this ); 

    // … proceed to open HTTP connection

3)处理接收到的事件,并检查活动IAP的ID值

Code:

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; 
//这句话有错误,暂时还不知道怎么解决
// function call '[CConnMonCreateSubConnection].
// CConnMonCreateSubConnection({lval} const CConnMonEventBase)' does not match

            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(); 

    }

我们可以用来监测接入点是否可以访问,以及是否被删除,还有其状态是否被改变等。

CConMonEvenBase是有错误的,应该是CConnMonEvenBase 

原文地址:https://www.cnblogs.com/yaoliang11/p/1809953.html