symbian 中自动寻找cmwap连接点,通杀uiq 2nd 3nd和s60 2nd 3nd 5nd

本文详细介绍了手机型号多样时自动查找并匹配可用连接点的过程,包括UIQ与Symbian系统的区别处理,以及如何在二级查找中比较连接点名称以确保正确连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

全测试过了,鉴于手机型号太多,没有一一的测试。 找不到连接点,应该自动创建一个的,但这个需要证书,就没写了。

今天发现刷了机的一个5800连不上,在二级查找上,还需比较一下名字。

//寻找可用的连接点, UIQ与Symbian不同

TBool NewCClientEngine::FindIapId(TUint32& iapId)
    {
    iapId = 0;
#ifdef __WINS__
    iapId = 1;
#elif  UIQ30
    jstring cmwapname;
    //先找出APN
    CCommsDatabase* const comm_db = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(comm_db);
    CCommsDbTableView *iap_table_view = comm_db->OpenTableLC(TPtrC(OUTGOING_WCDMA));
    TBuf<50> iap_name_buf;
    TBuf<50> cmwap_str; 

    TBuf<32> apn;
    TUint32 iap_id = -1;
    TBuf<100> log;
    // switch pointer to the first iap record 
    if(iap_table_view->GotoFirstRecord() == KErrNone)
        {
        // search comm_db for cmnet iap 
        do
            {
            // get the iap name from comm_db
            iap_name_buf.SetLength(0);
            iap_table_view->ReadTextL(TPtrC(COMMDB_NAME), iap_name_buf);
            iap_table_view->ReadTextL(TPtrC(GPRS_APN), apn); 

            // test the cmnet iap name             
            DEBUGING(iap_name_buf);
            DEBUGING(apn);
            if( apn == _L("cmwap") )
                {
                cmwapname = iap_name_buf;
                iap_table_view->ReadUintL(TPtrC(COMMDB_ID), iap_id);
                log.Format(_L("id = %d"),iap_id);
                DEBUGING(log);
                break;
                }
            }while (KErrNone == iap_table_view->GotoNextRecord());
        }
    CleanupStack::PopAndDestroy(2, comm_db); // iap_table_view, comm_db 

    if(cmwapname != _L(""))
        {
        CCommsDatabase* database = CCommsDatabase::NewL(EDatabaseTypeIAP);
        CleanupStack::PushL(database );
        CCommsDbTableView* view = database->OpenTableLC(TPtrC(IAP));
        if( view->GotoFirstRecord() == KErrNone )
            {
            do
                {
                TBuf<50> accessPointName;
                view->ReadTextL(TPtrC(COMMDB_NAME),accessPointName);
                DEBUGING(accessPointName);
                if(cmwapname == accessPointName)
                    {
                    TUint32 id;
                    view->ReadUintL(TPtrC(COMMDB_ID),id);
                    log.Format(_L("iapid = %d"),id);
                    iapId = id;
                    DEBUGING(log);
                    break;
                    }
                }while(view->GotoNextRecord()==KErrNone);
            }
        CleanupStack::PopAndDestroy(view);
        CleanupStack::PopAndDestroy(database );
        } 

#else
    CCommsDatabase* const comm_db = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(comm_db);
    CCommsDbTableView *iap_table_view = comm_db->OpenTableLC(TPtrC(OUTGOING_WCDMA));
    TBuf<20> iap_name_buf;
    TBuf<20> iap_name_buf1;
    TBuf<20> cmwap_str;
    TBuf<100> cmwap_username;
    TBuf<100> cmwap_userpass;
    TBuf<32> apn;
    TUint32 iap_id = -1;
    TBuf<100> log;
    // switch pointer to the first iap record 
    if(iap_table_view->GotoFirstRecord() == KErrNone)
        {
        // search comm_db for cmnet iap 
        do
            {
            // get the iap name from comm_db
            iap_name_buf.SetLength(0);
            iap_table_view->ReadTextL(TPtrC(COMMDB_NAME), iap_name_buf);
            iap_table_view->ReadTextL(TPtrC(GPRS_APN), apn);
            iap_table_view->ReadTextL(TPtrC(GPRS_IF_AUTH_PASS), cmwap_userpass);
            iap_table_view->ReadTextL(TPtrC(GPRS_IF_AUTH_NAME), cmwap_username);
            // test the cmnet iap name             
            DEBUGING(iap_name_buf);
            DEBUGING(cmwap_userpass);
            DEBUGING(cmwap_username);
            DEBUGING(apn);
            if( apn == _L("cmwap") && cmwap_userpass.Length()==0 && cmwap_username.Length()==0 )
                {
                iap_table_view->ReadUintL(TPtrC(COMMDB_ID), iap_id);
                CCommsDbTableView* pIAPView = comm_db->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(IAP_SERVICE), iap_id);
                TInt nErr = pIAPView->GotoFirstRecord();
                while(nErr == KErrNone)
                    {
                    pIAPView->ReadTextL(TPtrC(COMMDB_NAME), iap_name_buf1);
                    DEBUGING(iap_name_buf1);
                    if(iap_name_buf1 == iap_name_buf)
                        {
                        pIAPView->ReadUintL(TPtrC(COMMDB_ID), iap_id);
                        iapId= iap_id;
                        DEBUGING(_L("find iap..."));
                        }
                    nErr = pIAPView->GotoNextRecord();
                    }
                CleanupStack::PopAndDestroy(); //pIAPView
                }
            }while (KErrNone == iap_table_view->GotoNextRecord());
        }
    CleanupStack::PopAndDestroy(2, comm_db); // iap_table_view, comm_db
    if( iap_id < 0)
        {
        ERRORING(_L("can't find iap"));
        }
#endif
    return (iapId > 0);
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值