codhandler/codeng/src/Connection.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:28:30 +0100
branchRCL_3
changeset 49 919f36ff910f
parent 48 79859ed3eea9
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201034 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     1
/*
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     8
*
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    11
*
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    12
* Contributors:
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    13
*
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    14
* Description: 
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    15
*      Implementation of class CConnection.   
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    16
*      
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    17
*
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    18
*/
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    19
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    20
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    21
// INCLUDE FILES
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    22
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    23
#include "Connection.h"
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    24
#include "CodPanic.h"
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    25
#include "CodUtil.h"
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    26
#include "CodError.h"
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    27
#include "CodLogger.h"
49
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    28
#include <CommDbConnPref.h>
0
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    29
#include <cdblen.h>
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    30
#include <es_enum.h>
49
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    31
#include <platform/mw/browser_platform_variant.hrh>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    32
#ifdef BRDO_OCC_ENABLED_FF
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    33
#include <extendedconnpref.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    34
#include <FeatMgr.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    35
#include <CentralRepository.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    36
#include <CoreApplicationUIsSDKCRKeys.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    37
#include <cmgenconnsettings.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    38
#include <cmmanagerkeys.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    39
#include <etelmm.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    40
#include <rconnmon.h>
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
    41
#endif
0
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    42
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    43
// ================= MEMBER FUNCTIONS =======================
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    44
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    45
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    46
// CConnection::NewL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    47
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    48
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    49
CConnection* CConnection::NewL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    50
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    51
    CConnection* conn = new (ELeave) CConnection();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    52
    CleanupStack::PushL( conn );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    53
    conn->ConstructL();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    54
    CleanupStack::Pop( conn );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    55
    return conn;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    56
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    57
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    58
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    59
// CConnection::~CConnection()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    60
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    61
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    62
CConnection::~CConnection()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    63
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    64
    Cancel();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    65
    DoClose();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    66
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    67
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    68
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    69
// CConnection::ConnectL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    70
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    71
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    72
void CConnection::ConnectL( TUint32 aIap, TRequestStatus* aStatus )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    73
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    74
    CLOG(( EConn, 2, _L("-> CConnection::ConnectL iap(%d)"), aIap ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    75
    // Misuse asserts.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    76
    __ASSERT_ALWAYS( aStatus, CodPanic( ECodInvalidArguments ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    77
    // Internal asserts.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    78
    __ASSERT_DEBUG( !iParentStatus, CodPanic( ECodInternal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    79
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    80
    iStatus = KErrCodCannotConnect;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    81
    if ( iState == EConnected )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    82
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    83
        // Already connected; do nothing.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    84
        CLOG(( EConn, 4, _L("  already connected") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    85
        iStatus = KErrNone;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    86
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    87
    else if ( iState == EInit )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    88
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    89
        // Not connected. Create connection.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    90
        CLOG(( EConn, 4, _L("  starting connection") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    91
        // Make this part atomic by pushing closes on the stack.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    92
        User::LeaveIfError( iSockServ.Connect() );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    93
        CleanupClosePushL<RSocketServ>( iSockServ );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    94
        User::LeaveIfError( iConn.Open( iSockServ ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    95
        CleanupClosePushL<RConnection>( iConn );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    96
        iConnPref.SetDirection( ECommDbConnectionDirectionOutgoing );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    97
        if ( aIap )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    98
            {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
    99
            // Use specified IAP.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   100
            iConnPref.SetIapId( aIap );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   101
            iConnPref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   102
            }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   103
        else
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   104
            {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   105
            // aIap == 0 -> user select.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   106
            iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   107
            }
49
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   108
        #ifdef BRDO_OCC_ENABLED_FF
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   109
           TExtendedConnPref extPref;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   110
           CLOG(( EConn, 4, _L("CodHalder Setting OCC parameters") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   111
           
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   112
           CLOG(( EConn, 4, _L("Iap: %d"), aIap ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   113
           if (aIap)
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   114
           {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   115
              CLOG(( EConn, 4, _L("Iap is found") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   116
              extPref.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   117
              extPref.SetIapId(aIap);
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   118
           }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   119
           else
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   120
           {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   121
              CLOG(( EConn, 4, _L("Using Internet Snap") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   122
              extPref.SetSnapPurpose(CMManager::ESnapPurposeInternet);
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   123
		   }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   124
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   125
           //Default dialog behaviour
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   126
           extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   127
                  
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   128
           if ( !IsPhoneOfflineL() )
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   129
           {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   130
              TInt currentmode = KErrNone;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   131
              CRepository* rep = CRepository::NewLC( KCRUidCmManager );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   132
              rep->Get(KCurrentCellularDataUsage, currentmode );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   133
              CleanupStack::PopAndDestroy(); //rep
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   134
              if(ECmCellularDataUsageConfirm == currentmode)
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   135
              {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   136
                 if ( IsRoamingL() || (aIap == 0) )
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   137
                 {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   138
                    CLOG(( EConn, 4, _L("Setting note behaviour as Default") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   139
                    extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   140
                 }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   141
              }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   142
           }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   143
           
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   144
           TConnPrefList prefList;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   145
           prefList.AppendL(&extPref);
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   146
           iConn.Start( prefList, iStatus );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   147
        #else
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   148
            iConn.Start( iConnPref, iStatus );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   149
        #endif //BRDO_OCC_ENABLED_FF
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   150
        
0
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   151
        iState = EConnecting;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   152
        SetActive();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   153
        CleanupStack::Pop( 2 ); // closing iConn and iSockServ
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   154
        // End of atomic part.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   155
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   156
    else
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   157
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   158
        // Not expecting this to be called in other states.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   159
        CLOG(( EConn, 0, _L("CConnection::ConnectL: unexpected state (%d)"), \
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   160
                                                                    iState ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   161
        __ASSERT_ALWAYS( EFalse, CodPanic( ECodInternal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   162
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   163
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   164
    iParentStatus = aStatus;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   165
    *iParentStatus = KRequestPending;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   166
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   167
    if ( !IsActive() )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   168
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   169
        // Unless we have an outstanding connect request (iConn.Start),
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   170
        // we are done.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   171
        Done();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   172
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   173
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   174
    CLOG(( EConn, 2, _L("<- CConnection::ConnectL") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   175
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   176
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   177
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   178
// CConnection::AttachL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   179
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   180
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   181
void CConnection::AttachL( TUint32 aIap )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   182
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   183
    CLOG(( EConn, 2, _L("-> CConnection::AttachL iap(%d)"), aIap ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   184
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   185
    iStatus = KErrCodCannotConnect;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   186
    if ( iState == EConnected )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   187
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   188
        // Already connected; do nothing.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   189
        CLOG(( EConn, 4, _L("  already connected") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   190
        iStatus = KErrNone;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   191
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   192
    else if ( iState == EInit )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   193
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   194
        // Not connected. Create connection, or attach to existing.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   195
        CLOG(( EConn, 4, _L("  not connected") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   196
        if ( aIap )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   197
            {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   198
            // Make this part atomic by pushing closes on the stack.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   199
            User::LeaveIfError( iSockServ.Connect() );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   200
            CleanupClosePushL<RSocketServ>( iSockServ );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   201
            User::LeaveIfError( iConn.Open( iSockServ ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   202
            CleanupClosePushL<RConnection>( iConn );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   203
            TConnectionInfoBuf connInfo;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   204
            TUint count;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   205
            User::LeaveIfError( iConn.EnumerateConnections( count ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   206
            CLOG(( EConn, 4, _L("  %d existing connections"), count ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   207
            TUint i;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   208
            for ( i = count; i; i-- )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   209
                {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   210
                // Note: GetConnectionInfo expects 1-based index.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   211
                User::LeaveIfError( iConn.GetConnectionInfo( i, connInfo ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   212
                CLOG(( EConn, 4, _L("  conn(%d) iap(%d)"), \
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   213
                                                i, connInfo().iIapId ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   214
                if ( connInfo().iIapId == aIap )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   215
                    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   216
                    CLOG(( EConn, 4, _L("  attach"), i, count ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   217
                    User::LeaveIfError( iConn.Attach
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   218
                        ( connInfo, RConnection::EAttachTypeNormal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   219
                    iState = EConnected;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   220
                    iStatus = KErrNone;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   221
                    break;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   222
                    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   223
                }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   224
            CleanupStack::Pop( 2 ); // closing iConn and iSockServ
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   225
            // End of atomic part.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   226
            }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   227
        if ( iState == EInit )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   228
            {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   229
            CLOG(( EConn, 4, _L("  ended unconnected") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   230
            iConn.Close();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   231
            iSockServ.Close();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   232
            }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   233
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   234
    else
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   235
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   236
        // Not expecting this to be called in other states.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   237
        CLOG(( EConn, 0, _L("CConnection::AttachL: unexpected state (%d)"), \
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   238
                                                                    iState ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   239
        __ASSERT_ALWAYS( EFalse, CodPanic( ECodInternal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   240
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   241
    User::LeaveIfError( iStatus.Int() );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   242
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   243
    CLOG(( EConn, 2, _L("<- CConnection::AttachL") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   244
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   245
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   246
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   247
// CConnection::Close()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   248
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   249
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   250
void CConnection::Close()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   251
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   252
    CLOG(( EConn, 2, _L("-> CConnection::Close") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   253
    Cancel();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   254
    DoClose();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   255
    CLOG(( EConn, 2, _L("<- CConnection::Close") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   256
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   257
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   258
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   259
// CConnection::IsConnected()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   260
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   261
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   262
TBool CConnection::IsConnected( TUint32& aIap )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   263
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   264
    TBool connected( EFalse );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   265
    if( iState == EConnected )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   266
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   267
        TBuf<KCommsDbSvrMaxColumnNameLength * 2 + 1> iapId;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   268
        _LIT( KFormatIapId, "%S\\%S" );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   269
        TPtrC iap( IAP );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   270
        TPtrC id( COMMDB_ID );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   271
        iapId.Format( KFormatIapId, &iap, &id );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   272
        TInt err = iConn.GetIntSetting( iapId, aIap );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   273
        connected = err ? EFalse : ETrue;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   274
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   275
    return connected;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   276
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   277
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   278
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   279
// CConnection::CConnection()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   280
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   281
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   282
CConnection::CConnection()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   283
: CActive( CActive::EPriorityStandard ),
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   284
  iState( EInit )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   285
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   286
    CActiveScheduler::Add( this );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   287
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   288
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   289
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   290
// CConnection::ConstructL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   291
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   292
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   293
void CConnection::ConstructL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   294
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   295
    if ( !CodUtil::ApCountL() )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   296
        {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   297
        // It's futile to try making a connection without an AP, so leave if
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   298
        // we don't have any.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   299
        User::Leave( KErrCodNoAccessPoint );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   300
        }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   301
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   302
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   303
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   304
// CConnection::DoCancel()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   305
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   306
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   307
void CConnection::DoCancel()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   308
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   309
    CLOG(( EConn, 2, _L("-> CConnection::DoCancel") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   310
    __ASSERT_DEBUG( iState == EConnecting, CodPanic( ECodInternal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   311
    // RConnection has no cancel method matching the async RConnection::Start.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   312
    // The only way to cancel is to close the RConnection.
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   313
    // (Our request will complete with KErrCancel, as expected.)
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   314
    DoClose();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   315
    Done();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   316
    CLOG(( EConn, 2, _L("<- CConnection::DoCancel") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   317
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   318
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   319
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   320
// CConnection::RunL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   321
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   322
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   323
void CConnection::RunL()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   324
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   325
    CLOG(( EConn, 2, _L("-> CConnection::RunL iStatus(%d)"), \
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   326
        iStatus.Int() ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   327
    __ASSERT_DEBUG( iState == EConnecting, CodPanic( ECodInternal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   328
    User::LeaveIfError( iStatus.Int() );    // Handle errors in RunError().
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   329
    iState = EConnected;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   330
    Done();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   331
    CLOG(( EConn, 2, _L("<- CConnection::RunL") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   332
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   333
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   334
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   335
// CConnection::RunError()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   336
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   337
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   338
TInt CConnection::RunError( TInt LOG_ONLY( aError ) )
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   339
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   340
    CLOG(( EConn, 2, _L("-> CConnection::RunError aError(%d)"), aError ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   341
    __ASSERT_DEBUG( iState == EConnecting, CodPanic( ECodInternal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   342
    DoClose();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   343
    Done();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   344
    CLOG(( EConn, 2, _L("<- CConnection::RunError") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   345
    return KErrNone;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   346
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   347
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   348
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   349
// CConnection::DoClose()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   350
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   351
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   352
void CConnection::DoClose()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   353
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   354
    CLOG(( EConn, 2, _L("CConnection::DoClose") ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   355
    iConn.Close();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   356
    iSockServ.Close();
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   357
    iState = EInit;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   358
    }
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   359
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   360
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   361
// CConnection::Done()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   362
// ---------------------------------------------------------
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   363
//
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   364
void CConnection::Done()
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   365
    {
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   366
    CLOG(( EConn, 2, _L("CConnection::Done iStatus(%d)"), iStatus.Int() ));
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   367
    __ASSERT_DEBUG( iParentStatus, CodPanic( ECodInternal ) );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   368
    User::RequestComplete( iParentStatus, iStatus.Int() );
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   369
    iParentStatus = NULL;
dd21522fd290 Revision: 200911
Kiiskinen Klaus (Nokia-D-MSW/Tampere) <klaus.kiiskinen@nokia.com>
parents:
diff changeset
   370
    }
49
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   371
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   372
#ifdef BRDO_OCC_ENABLED_FF
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   373
// ---------------------------------------------------------
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   374
// CConnection::IsPhoneOfflineL
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   375
//
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   376
// Checks if phone is in offline mode or not.
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   377
// Return ETrue if phone is in offline mode.
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   378
// Return EFalse if phone is not in offline mode.
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   379
// ---------------------------------------------------------
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   380
//
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   381
TBool CConnection::IsPhoneOfflineL() const
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   382
     {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   383
      if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   384
         {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   385
         CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   386
         TInt connAllowed = 1;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   387
         repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   388
         CleanupStack::PopAndDestroy();  // repository
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   389
         if ( !connAllowed )
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   390
             {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   391
             CLOG(( EConn, 2, _L("Yes, Phone is in Offline mode") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   392
             return ETrue;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   393
             }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   394
         }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   395
     
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   396
     CLOG(( EConn, 2, _L("Phone is in Online mode") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   397
     return EFalse;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   398
     }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   399
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   400
// ---------------------------------------------------------
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   401
// CConnection::IsRoamingL
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   402
//
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   403
// Checks if phone is in home network or in roam network.
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   404
// Return ETrue if phone is in foriegn network.
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   405
// Return EFalse if phone is in home network.
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   406
// ---------------------------------------------------------
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   407
//
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   408
TBool CConnection::IsRoamingL()
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   409
    {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   410
        RTelServer telServer;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   411
        User::LeaveIfError( telServer.Connect());
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   412
        
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   413
        RTelServer::TPhoneInfo teleinfo;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   414
        User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   415
        
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   416
        RMobilePhone phone;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   417
        User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   418
        User::LeaveIfError(phone.Initialise()); 
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   419
        
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   420
        RMobilePhone::TMobilePhoneNetworkMode mode;                     
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   421
        TInt err = phone.GetCurrentMode( mode );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   422
        phone.Close();
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   423
        telServer.Close();
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   424
        TInt Bearer = EBearerIdGSM ;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   425
        if( KErrNone == err )
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   426
        {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   427
           switch(mode)
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   428
           {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   429
                case RMobilePhone::ENetworkModeGsm:     
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   430
                {           
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   431
                Bearer = EBearerIdGSM ;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   432
                    break;      
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   433
                }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   434
                case RMobilePhone::ENetworkModeWcdma:
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   435
                {                                   
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   436
                    Bearer = EBearerIdWCDMA  ;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   437
                    break;  
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   438
                }   
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   439
                default: 
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   440
                {                   
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   441
                
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   442
                }                       
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   443
            }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   444
        }   
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   445
        RConnectionMonitor monitor;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   446
        TRequestStatus status;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   447
        // open RConnectionMonitor object
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   448
        monitor.ConnectL();
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   449
        CleanupClosePushL( monitor );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   450
        TInt netwStatus ;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   451
        monitor.GetIntAttribute( Bearer, 0, KNetworkRegistration, netwStatus, status );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   452
        User::WaitForRequest( status );
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   453
        CleanupStack::PopAndDestroy(); // Destroying monitor
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   454
        if ( status.Int() == KErrNone && netwStatus == ENetworkRegistrationRoaming )
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   455
        {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   456
            CLOG(( EConn, 2, _L("Yes, Phone is in Forign network") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   457
            return ETrue;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   458
        }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   459
        else //home n/w or some other state in n/w
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   460
        {
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   461
            CLOG(( EConn, 2, _L("Phone is in Home network") ));
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   462
            return EFalse;
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   463
        }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   464
   }
919f36ff910f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 48
diff changeset
   465
#endif