include commdb.h
添加commdb.lib到mmp文件library列表
1.枚举所有接入点,包括grps,蓝牙,WIFI
参考代码如下:
...
CCommsDatabase* db;
CCommsDbTableView* view;
TBuf<KCommsDbSvrMaxColumnNameLength> iapName;
TUint32 iapId;
TInt result;
//open database
db = CCommsDatabase::NewL( EDatabaseTypeIAP );
CleanupStack::PushL(db);
view = db->OpenTableLC(TPtrC(IAP)); //IAP is the table name
result = view->GotoFirstRecord();
TInt nCount = 0;
while((result == KErrNone) &&(nCount<30))
{
view->ReadTextL(TPtrC( COMMDB_NAME),iapName );
view->ReadUintL(TPtrC( COMMDB_ID),iapId );
AddItem( iapName );
nCount++;
result = view->GotoNextRecord();
}
CleanupStack::PopAndDestroy(2);
...
2.用户选择接入点后查询连接信息,包括区分grps和wifi,代理信息
参考代码:
...
m_bIsGRPS = ETrue;
proxy.Zero();
port = 0;
TInt result = KErrNone;
TBool bok = EFalse;
//1.Is GRPS ?
CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
TUint32 id = 0;
TBuf<KCommsDbSvrMaxColumnNameLength> iapName;
TUint32 iapService;
TBuf<KCommsDbSvrMaxColumnNameLength> serviceType;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(IAP)); //IAP is the table name
result = view->GotoFirstRecord();
while ( result == KErrNone )
{
view->ReadUintL(TPtrC(COMMDB_ID), id);
view->ReadTextL(TPtrC(COMMDB_NAME), iapName);
view->ReadUintL(TPtrC(IAP_SERVICE), iapService);
view->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
if ( iap == id )
{
if ( 0 == serviceType.Compare(TPtrC(OUTGOING_GPRS)) )
{
m_bIsGRPS = ETrue;
}
else
{
m_bIsGRPS = EFalse;
}
bok = ETrue;
break;
}
result = view->GotoNextRecord();
}
CleanupStack::PopAndDestroy();
if (!bok)
{
return KErrNotFound;
}
//2.Get Proxy
CCommsDatabase* commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CCommsDbTableView* commsView = commsDb->OpenViewOnProxyRecordLC( iapService, serviceType );
result = commsView->GotoFirstRecord();
if ( KErrNone != result )
{
CleanupStack::PopAndDestroy();
return KErrNotFound;
}
TBool proxyEnabled( EFalse );
commsView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), proxyEnabled);
if ( !proxyEnabled )
{
CleanupStack::PopAndDestroy();
return KErrNotFound;
}
proxy.Copy( *commsView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)));
commsView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), port );
CleanupStack::PopAndDestroy(2);
...
添加commdb.lib到mmp文件library列表
1.枚举所有接入点,包括grps,蓝牙,WIFI
参考代码如下:
...
CCommsDatabase* db;
CCommsDbTableView* view;
TBuf<KCommsDbSvrMaxColumnNameLength> iapName;
TUint32 iapId;
TInt result;
//open database
db = CCommsDatabase::NewL( EDatabaseTypeIAP );
CleanupStack::PushL(db);
view = db->OpenTableLC(TPtrC(IAP)); //IAP is the table name
result = view->GotoFirstRecord();
TInt nCount = 0;
while((result == KErrNone) &&(nCount<30))
{
view->ReadTextL(TPtrC( COMMDB_NAME),iapName );
view->ReadUintL(TPtrC( COMMDB_ID),iapId );
AddItem( iapName );
nCount++;
result = view->GotoNextRecord();
}
CleanupStack::PopAndDestroy(2);
...
2.用户选择接入点后查询连接信息,包括区分grps和wifi,代理信息
参考代码:
...
m_bIsGRPS = ETrue;
proxy.Zero();
port = 0;
TInt result = KErrNone;
TBool bok = EFalse;
//1.Is GRPS ?
CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
TUint32 id = 0;
TBuf<KCommsDbSvrMaxColumnNameLength> iapName;
TUint32 iapService;
TBuf<KCommsDbSvrMaxColumnNameLength> serviceType;
CCommsDbTableView* view = db->OpenTableLC(TPtrC(IAP)); //IAP is the table name
result = view->GotoFirstRecord();
while ( result == KErrNone )
{
view->ReadUintL(TPtrC(COMMDB_ID), id);
view->ReadTextL(TPtrC(COMMDB_NAME), iapName);
view->ReadUintL(TPtrC(IAP_SERVICE), iapService);
view->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
if ( iap == id )
{
if ( 0 == serviceType.Compare(TPtrC(OUTGOING_GPRS)) )
{
m_bIsGRPS = ETrue;
}
else
{
m_bIsGRPS = EFalse;
}
bok = ETrue;
break;
}
result = view->GotoNextRecord();
}
CleanupStack::PopAndDestroy();
if (!bok)
{
return KErrNotFound;
}
//2.Get Proxy
CCommsDatabase* commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CCommsDbTableView* commsView = commsDb->OpenViewOnProxyRecordLC( iapService, serviceType );
result = commsView->GotoFirstRecord();
if ( KErrNone != result )
{
CleanupStack::PopAndDestroy();
return KErrNotFound;
}
TBool proxyEnabled( EFalse );
commsView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), proxyEnabled);
if ( !proxyEnabled )
{
CleanupStack::PopAndDestroy();
return KErrNotFound;
}
proxy.Copy( *commsView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)));
commsView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), port );
CleanupStack::PopAndDestroy(2);
...