📄 iapconnectengine.cpp
字号:
commsOgGprs->WriteBoolL( TPtrC(GPRS_DATA_COMPRESSION), EFalse);
commsOgGprs->WriteBoolL( TPtrC(GPRS_HEADER_COMPRESSION), EFalse);
commsOgGprs->WriteBoolL( TPtrC(GPRS_ANONYMOUS_ACCESS), EFalse);
commsOgGprs->WriteTextL( TPtrC(GPRS_IF_NETWORKS), KIpLit);
commsOgGprs->WriteBoolL( TPtrC(GPRS_IF_PROMPT_FOR_AUTH), EFalse);
commsOgGprs->WriteUintL( TPtrC(GPRS_IF_AUTH_RETRIES), 0);
commsOgGprs->WriteTextL( TPtrC(GPRS_IP_GATEWAY), KNullIp);
commsOgGprs->WriteBoolL( TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER), EFalse);
commsOgGprs->WriteTextL( TPtrC(GPRS_IP_NAME_SERVER1), KNullIp);
commsOgGprs->WriteTextL( TPtrC(GPRS_IP_NAME_SERVER2), KNullIp);
commsOgGprs->WriteBoolL( TPtrC(GPRS_ENABLE_LCP_EXTENSIONS), EFalse);
commsOgGprs->WriteBoolL( TPtrC(GPRS_DISABLE_PLAIN_TEXT_AUTH), ETrue);
commsOgGprs->WriteBoolL( TPtrC(GPRS_IP_ADDR_FROM_SERVER), ETrue);
commsOgGprs->WriteUintL( TPtrC(GPRS_AP_TYPE), 2);
commsOgGprs->WriteUintL( TPtrC(GPRS_QOS_WARNING_TIMEOUT), 0xffffffff);
commsOgGprs->PutRecordChanges();
CleanupStack::PopAndDestroy(commsOgGprs);
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::CreateNewAccessPointL(...)
//
// This function creates a new wap access point.
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::CreateNewAccessPointL(CCommsDatabase& aCommsDb,
const TDesC& aCommsdb_name_val, TUint32& aApId)
{
CCommsDbTableView* commsAp = aCommsDb.OpenTableLC(TPtrC(WAP_ACCESS_POINT));
commsAp->InsertRecord(aApId);
commsAp->WriteTextL(TPtrC(COMMDB_NAME), aCommsdb_name_val);
commsAp->WriteTextL(TPtrC(WAP_CURRENT_BEARER), TPtrC(WAP_IP_BEARER));
commsAp->PutRecordChanges();
CleanupStack::PopAndDestroy(commsAp);
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::ShowQueryDialogL()
//
// This function shows a query dialog to make sure that user wants to terminate
// the active connection.
// ---------------------------------------------------------------------------
//
TInt CIAPConnectEngine::ShowQueryDialogL()
{
CAknQueryDialog* dlg =
new(ELeave) CAknQueryDialog(CAknQueryDialog::ENoTone);
return dlg->ExecuteLD(R_IAPCONNECT_TERMINATION_QUERY_DIALOG);
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::SetConnectionPreferences(TUint aBearer,
// TBool aDialog,
// TUint32 aIapId)
//
// This function sets connection preferences.
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::SetConnectionPreferences(
TUint aBearer,
TBool aDialog,
TUint32 aIapId)
{
iPref.SetDirection(ECommDbConnectionDirectionOutgoing);
if (aDialog)
{
iPref.SetDialogPreference(ECommDbDialogPrefPrompt);
}
else
{
iPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
}
iPref.SetIapId(aIapId);
iPref.SetBearerSet(aBearer);
iPref.SetDirection(ECommDbConnectionDirectionOutgoing);
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::SelectAccessPointL(TUint32& aSelectedIap)
//
// This function launches an access point selection list
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::SelectAccessPointL(TUint32& aIap)
{
CApSettingsHandler* settingsHandler = CApSettingsHandler::NewLC(
ETrue,
EApSettingsSelListIsPopUp,
EApSettingsSelMenuSelectNormal,
KEApIspTypeAll,
EApBearerTypeAll,
KEApSortNameAscending);
TUint32 originallyFocused(0);
// 0 is not valid IAP id. Failed if 0 after RunSettingsL().
TUint32 selectedIap(0);
// Show the dialog
settingsHandler->RunSettingsL(originallyFocused, selectedIap);
// The CApUtils API is deprecated/removed, the following code can be used
// to convert the WapAP Id to IAP Id
if (selectedIap)
{
CCommsDatabase* db = CCommsDatabase::NewL();
CleanupStack::PushL(db);
CCommsDbTableView* wapTable;
wapTable = db->OpenViewMatchingUintLC( TPtrC(WAP_ACCESS_POINT),
TPtrC(COMMDB_ID), selectedIap );
User::LeaveIfError( wapTable->GotoFirstRecord() );
TBuf<KMaxWapBearerLength> wapBearer;
wapTable->ReadTextL(TPtrC(WAP_CURRENT_BEARER), wapBearer);
if ( wapBearer == TPtrC(WAP_IP_BEARER) )
{
CCommsDbTableView* bearerTable;
bearerTable = db->OpenViewMatchingUintLC( TPtrC(wapBearer),
TPtrC(WAP_ACCESS_POINT_ID),
selectedIap );
User::LeaveIfError( bearerTable->GotoFirstRecord() );
bearerTable->ReadUintL(TPtrC(WAP_IAP), aIap );
CleanupStack::PopAndDestroy( bearerTable ); // bearerTable
}
else
{
User::Leave( KErrInvalidBearerType );
}
CleanupStack::PopAndDestroy(2); // db, wapTable,
}
else
{
aIap = 0;
}
CleanupStack::PopAndDestroy(settingsHandler);
}
// ---------------------------------------------------------------------------
// HBufC* CIAPConnectEngine::GetConnectionInfoL()
//
// This function collects information about active connections
// ---------------------------------------------------------------------------
//
HBufC* CIAPConnectEngine::GetConnectionInfoL()
{
TBuf<KMaxInfoBufferLength> infoBuf;
TUint connCount = 0;
// Count active connections
iConnect.EnumerateConnections(connCount);
if (connCount)
{
infoBuf.Append(KTextConnectionInfoHeader);
infoBuf.Append(CEditableText::ELineBreak);
for(TUint i = 1; i <= connCount; i++)
{
infoBuf.AppendFormat(KTextConnectionInfoTitle, i);
infoBuf.Append(CEditableText::ELineBreak);
TPckgBuf<TConnectionInfo> connInfo;
// Get connection info
User::LeaveIfError(iConnect.GetConnectionInfo(i, connInfo));
infoBuf.AppendFormat(KTextConnectionInfoIapId, connInfo().iIapId);
infoBuf.Append(CEditableText::ELineBreak);
infoBuf.AppendFormat(KTextConnectionInfoNetId, connInfo().iNetId);
infoBuf.Append(CEditableText::ELineBreak);
// In S60 3rd Edition the following operations
// require the NetworkControl capability. If you have this
// capability set, please uncomment the definition of
// __S60_3X_NET_CTRL__ at the beginning of this file.
// For more information, please see release_notes.txt.
#if !defined(__SERIES60_3X__) || defined(__S60_3X_NET_CTRL__)
// Get info about clients using this connection
TConnectionEnumArg args;
args.iIndex = i;
TConnEnumArgBuf enumBuf(args);
TConnectionGetClientInfoArg clientInfoArg;
clientInfoArg.iIndex = 1;
TConnGetClientInfoArgBuf clientInfoBuf(clientInfoArg);
TConnectionClientInfo clientInfo;
// Query number of clients using the connection
User::LeaveIfError(iConnect.Control
(KCOLConnection, KCoEnumerateConnectionClients, enumBuf));
infoBuf.AppendFormat(KTextConnectionInfoClients,
enumBuf().iCount);
infoBuf.Append(CEditableText::ELineBreak);
for(TUint j = 1; j <= enumBuf().iCount; j++)
{
clientInfoBuf().iIndex = j;
// Get client info
User::LeaveIfError(iConnect.Control(
KCOLConnection, KCoGetConnectionClientInfo,
clientInfoBuf));
clientInfo = clientInfoBuf().iClientInfo;
infoBuf.AppendFormat(KTextConnectionInfoProcessId,
clientInfo.iProcessId);
infoBuf.Append(CEditableText::ELineBreak);
}
#endif // !defined(__SERIES60_3X__) || defined(__S60_3X_NET_CTRL__)
}
}
else
{
infoBuf.Append(KTextConnectionInfoNoConnections);
infoBuf.Append(CEditableText::ELineBreak);
}
HBufC* buf = HBufC::NewL(infoBuf.Length());
*buf = infoBuf; // Copy the contents to a heap descriptor
return buf;
}
// ---------------------------------------------------------------------------
// CIAPConnectDemoEngine* CIAPConnectEngine::DemoEngine()
//
// This function returns a pointer to the demo engine
// ---------------------------------------------------------------------------
//
CIAPConnectDemoEngine* CIAPConnectEngine::DemoEngine()
{
return iDemoEngine;
}
// ---------------------------------------------------------------------------
// CIAPConnectDemoEngine* CIAPConnectEngine::
// GetConnectionIndex(TUint& aConnIndex)
//
// Finds the index of the connection we are currently using
// ---------------------------------------------------------------------------
//
TInt CIAPConnectEngine::GetConnectionIndex(TUint& aConnIndex)
{
TBuf<KNameLength> temp(KIapAndId);
TUint32 iapId;
if (iConnect.GetIntSetting(temp, iapId) == KErrNone)
{
TUint connCount = 0;
// Count active connections
iConnect.EnumerateConnections(connCount);
if (connCount)
{
for(TUint i = 1; i <= connCount; i++)
{
TPckgBuf<TConnectionInfo> connInfo;
// Get connection info
TInt err = iConnect.GetConnectionInfo(i, connInfo);
if (err)
return err;
if (connInfo().iIapId == iapId)
{
aConnIndex = i;
return KErrNone;
}
}
}
}
return KErrNotFound;
}
// End of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -