// ***************************************************************************
/// \brief Mixin class observing state of connection.
///
class MIAPConnectionObserver
{
public:
virtual void IAP_Error( TInt aError ) = 0;
virtual void IAP_TimeOut() = 0;
virtual void IAP_Connected() = 0;
virtual void IAP_Canceled() = 0;
};
// ***************************************************************************
/// \brief Engine class for network connection using IAP and displaying
/// wait dialog.
///
class CIAPConnection : public CActive, MProgressDialogCallback
{
public:
/// state of connecting
enum TState
{
ENotConnected,
EConnected,
EConnecting
};
// ---------------------------------------------------------------------------
// Connect to network via IAP.
// ---------------------------------------------------------------------------
void CIAPConnection::ConnectL()
{
if (!IsActive())
{
if ( ( iState != EConnected ) && ( iState != EConnecting ) )
{
// Set connection preferences. Preference can use specific IAP
// id and if it is known. Withoust setting preference it falls
// on device on emulator it works fine
iPref.iRanking = 1;
iPref.iDirection = ECommDbConnectionDirectionOutgoing;
iPref.iDialogPref = ECommDbDialogPrefPrompt;
// set bearer ( IAP or 'H'CSD )
CCommsDbConnectionPrefTableView::TCommDbIapBearer bearer;
bearer.iBearerSet = ECommDbBearerUnknown;
bearer.iIapId = KUndefinedIAPid;
iPref.iBearer = bearer;
// ---------------------------------------------------------------------------
// From CActive. Asynchronous event completed.
// ---------------------------------------------------------------------------
void CIAPConnection::RunL()
{
if (iState == EConnecting)
{
switch ( iStatus.Int() )
{
case KConnectionPref1Exists:
case KConnectionPref2Exists:
case KConnectionExists:
case KConnectionPref1Created:
case KConnectionPref2Created:
case KConnectionCreated:
{
iState = EConnected;
if ( iWaitDialog )
{
iWaitDialog->ProcessFinishedL();
iWaitDialog = NULL;
}