欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

symbian 网络连接网络 IAP(Internet Access Point)缺省选择及Com

程序员文章站 2024-01-28 12:54:16
...

屏蔽对话框 RConnection gConnection; gConnection.Open(iSocketServ); TCommDbConnPref pref; pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); // 联网时不出现对话框 TUint32 iapId; // 该值应该是确实对应的查询结果 iapId = GetAPNL(_L("cmnet

屏蔽对话框

RConnection gConnection;

gConnection.Open(iSocketServ);

TCommDbConnPref pref;

pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); // 联网时不出现对话框

TUint32 iapId; // 该值应该是确实对应的查询结果

iapId = GetAPNL(_L("cmnet"), NULL);

RDebug::Print(_L("## %d : "), iapId);

pref.SetIapId(iapId);

pref.SetBearerSet(ECommDbBearerUnknown);

pref.SetDirection(ECommDbConnectionDirectionOutgoing);

gConnection.Start(pref); // 同步创建隐藏 IAP 选择框的网络连接

……

TUint32 CSocketsEngine::GetAPNL(const TDesC& aApn, RFileLogger* iLogger)

{

__UHEAP_MARK;

CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP);

CleanupStack::PushL(db);

//get apn's name

TBuf name;

TUint32 id = 0;

{

CCommsDbTableView* view = db->OpenTableLC(TPtrC(OUTGOING_WCDMA));

TInt err = view->GotoFirstRecord();

while (err == KErrNone)

{

TBuf apn;

view->ReadUintL(TPtrC(COMMDB_ID), id); //接入点ID

view->ReadTextL(TPtrC(COMMDB_NAME), name);//连接名称

view->ReadTextL(TPtrC(GPRS_APN), apn); //接入点名称,可以通过这个字段判断接入点是CMWAP还是CMNET

apn.LowerCase();

if (apn.Compare(aApn) == 0)

{

// LOG_FORMAT((_L("Finded APN id = %d, name = %S"), id, &name));

break;

}

err = view->GotoNextRecord();

}

if (err != KErrNone)

{

CleanupStack::PopAndDestroy(view);

CleanupStack::PopAndDestroy(db);

User::Leave(KErrNotFound);

}

CleanupStack::PopAndDestroy(view);

}

{

CCommsDbTableView* view = db->OpenTableLC(TPtrC(IAP));

TInt err = view->GotoFirstRecord();

while (err == KErrNone)

{

TBuf name2;

view->ReadUintL(TPtrC(COMMDB_ID), id); //接入点ID

view->ReadTextL(TPtrC(COMMDB_NAME), name2);//连接名称

// LOG_FORMAT((_L("id = %d name = %S "), id, &name2));

if (!name.Compare(name2))

{

// LOG_FORMAT((_L("Finded APN id = %d, name = %S"), id, &name));

break;

}

err = view->GotoNextRecord();

}

CleanupStack::PopAndDestroy(view);

}

CleanupStack::PopAndDestroy(db);

__UHEAP_MARKEND;

return id;

}