📄 iapconnectengine.cpp
字号:
case KErrWrongValueInPrefs:
PrintErrorL(TPtrC(KTextWrongValueInPrefs), statusCode);
iState = EIAPConnectStateNotConnected;
break;
case KErrAccessDenied: // Changing an IAP may fail on the first try
{
if (iState != EIAPConnectStateRetry)
{
iState = EIAPConnectStateRetry;
ConnectL(ETrue);
}
else
{
TBuf<KErrorResolverMaxTextLength> errorText;
errorText = iTextResolver->ResolveError(statusCode);
PrintErrorL(errorText, statusCode);
iState = EIAPConnectStateNotConnected;
}
break;
}
case KErrCouldNotConnect:
{
TBuf<KErrorResolverMaxTextLength> errorText;
errorText = iTextResolver->ResolveError(statusCode);
PrintErrorL(errorText, statusCode);
iState = EIAPConnectStateNotConnected;
// CIntConnectionInitiator must be recreated to reset
iConnect->Cancel();
delete iConnect;
iConnect = NULL;
iConnect = CIntConnectionInitiator::NewL();
break;
}
default:
{
// For low-level ETEL error codes
TBuf<KErrorResolverMaxTextLength> errorText;
errorText = iTextResolver->ResolveError(statusCode);
PrintErrorL(errorText, statusCode);
iState = EIAPConnectStateNotConnected;
break;
}
}
}
else
{
// statusCode as a panic number for debugging purposes
User::Panic(_L("Internal"), statusCode);
}
iObserver->IAPStateChangedL(iState);
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::PrintErrorL(const TDesC& aErrorText, TInt aErrorCode)
//
// Shows error notification
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::PrintErrorL(const TDesC& aErrorText, TInt aErrorCode)
{
TBuf<KErrorResolverMaxTextLength+30> buf;
buf.Append(aErrorText);
buf.Append(KTextErrorCodePrompt);
buf.AppendNum(aErrorCode);
CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
globalNote->ShowNoteL(EAknGlobalErrorNote, buf);
CleanupStack::PopAndDestroy();
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::PrintNoteL(const TDesC& aNoteText)
//
// Shows information notification
// ---------------------------------------------------------------------------
//
/*
void CIAPConnectEngine::PrintNoteL(const TDesC& aNoteText)
{
CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
globalNote->ShowNoteL(EAknGlobalInformationNote, aNoteText);
CleanupStack::PopAndDestroy();
}
*/
// ---------------------------------------------------------------------------
// CIAPConnectEngine::DoCancel()
//
// Cancels ongoing request.
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::DoCancel()
{
iConnect->Cancel();
iWaitDialog->DismissDialogL();
iState = EIAPConnectStateNotConnected;
iObserver->IAPStateChangedL(iState);
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::ReleaseL()
//
// Releases the connection by calling RNif::DisableTimers(EFalse).
// After that the connection is closed if it's not used (e.g. by sockets).
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::ReleaseL()
{
// Check if there is an active connection
TUint32 iap; // not used
if (!IsDisconnected(iap))
{
Cancel();
if (iNifTimerState == ETimerDisabled)
{
// Release the connection
iNif.DisableTimers(EFalse);
iNifTimerState = ETimerEnabled;
iState = EIAPConnectStateNotConnected;
iObserver->IAPStateChangedL(iState);
//PrintNoteL(KTextConnectionReleased);
}
else
{
//PrintNoteL(KTextAlreadyReleased);
}
}
else
{
//PrintNoteL(KTextNotConnected);
}
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::TerminateConnectionL()
//
// This function should not be used in normal situation, since it terminates
// the active connection, even if there are other application using
// the connection. Use the ReleaseL() function instead.
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::TerminateConnectionL()
{
// Check if there is an active connection
TUint32 iap; // not used
if (!IsDisconnected(iap))
{
// Show confirmation dialog first
if (ShowQueryDialogL())
{
iNif.DisableTimers(EFalse);
iNifTimerState = ETimerEnabled;
// RNif::Stop() terminates connection by force even if there are other
// application using the same connection. Thus it is not recommended to
// use it if there is no really good reason.
User::LeaveIfError(iNif.Stop());
iState = EIAPConnectStateNotConnected;
iObserver->IAPStateChangedL(iState);
}
}
else
{
//PrintNoteL(KTextNotConnected);
}
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::IsDisconnected(TUint32& aIap)
//
// This function checks if there is an active connection. Returns KErrNone
// if there is a connection.
// ---------------------------------------------------------------------------
//
TInt CIAPConnectEngine::IsDisconnected(TUint32& aIap)
{
// Check if there is an active connection
return iConnect->GetActiveIap(aIap);
}
// ---------------------------------------------------------------------------
// CIAPConnectEngine::ShowQueryDialogL()
//
// This function shown 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(TCommDbBearer aBearer,
// TBool aDialog)
//
// This function set connection preferences. This example uses single
// preference, but there can be second preference if first one fails.
// Preference can also use specific IAP id and if it is known.
// ---------------------------------------------------------------------------
//
void CIAPConnectEngine::SetConnectionPreferences(TInt aBearer,
TBool aDialog, TUint32 aIapId)
{
//CApSelect ap;
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
pref.iRanking = 1;
pref.iDirection = ECommDbConnectionDirectionOutgoing;
aDialog ? pref.iDialogPref = ECommDbDialogPrefPrompt : pref.iDialogPref = ECommDbDialogPrefDoNotPrompt;
CCommsDbConnectionPrefTableView::TCommDbIapBearer bearer;
bearer.iBearerSet = aBearer;
bearer.iIapId = aIapId;
pref.iBearer = bearer;
iPref = pref;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -