|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: active object, that monitors the real connection starting |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL HEADERS |
|
20 #include "vpnconnection.h" |
|
21 |
|
22 // CLASS HEADER |
|
23 #include "connectionstarter.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // Two-phased constructor. |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CConnectionStarter* CConnectionStarter::NewL( CVpnConnection& aConnection, |
|
32 MConnectionStarterCallback& aCallback ) |
|
33 { |
|
34 CConnectionStarter* self = new ( ELeave ) CConnectionStarter( aConnection, |
|
35 aCallback ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Destructor. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CConnectionStarter::~CConnectionStarter() |
|
44 { |
|
45 Cancel(); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Constructor. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CConnectionStarter::CConnectionStarter( CVpnConnection& aConnection, |
|
53 MConnectionStarterCallback& aCallback ) |
|
54 : CActive( EPriorityStandard ), |
|
55 iConnection( aConnection ), |
|
56 iCallback( aCallback ) |
|
57 { |
|
58 CActiveScheduler::Add( this ); |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // Starts connection asynchronously. |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CConnectionStarter::StartRealConnection() |
|
66 { |
|
67 iConnection.StartRealConnection( iStatus ); |
|
68 SetActive(); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // From class CActive |
|
73 // Handles completion of asynchronous connection starting. |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CConnectionStarter::RunL() |
|
77 { |
|
78 TInt realIapId = 0; |
|
79 TInt realNetworkId = 0; |
|
80 |
|
81 if ( iStatus.Int() == KErrNone ) |
|
82 { |
|
83 realIapId = iConnection.RealIapId(); |
|
84 realNetworkId = iConnection.RealNetId(); |
|
85 } |
|
86 |
|
87 iCallback.RealConnectionStarted( iStatus.Int(), |
|
88 realIapId, |
|
89 realNetworkId ); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // From class CActive |
|
94 // Handles cancellation of asynchronous connection starting. |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CConnectionStarter::DoCancel() |
|
98 { |
|
99 iConnection.CancelStartRealConnection(); |
|
100 } |
|
101 |
|
102 |