|
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: Provides IAP IDs for emergency |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "svpemergencyiapprovider.h" |
|
20 #include "svplogger.h" // For logging |
|
21 |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Default constructor |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CSVPEmergencyIapProvider::CSVPEmergencyIapProvider( TPriority aPriority ) |
|
30 : CActive( aPriority ) |
|
31 { |
|
32 CActiveScheduler::Add( this ); |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // ConstructL |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 void CSVPEmergencyIapProvider::ConstructL() |
|
40 { |
|
41 SVPDEBUG1("CSVPEmergencyIapProvider::ConstructL()") |
|
42 |
|
43 User::LeaveIfError( iConnectionMonitor.ConnectL() ); |
|
44 iWait = new ( ELeave ) CActiveSchedulerWait(); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // NewL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CSVPEmergencyIapProvider* CSVPEmergencyIapProvider::NewL( |
|
52 TPriority aPriority ) |
|
53 { |
|
54 CSVPEmergencyIapProvider* self = CSVPEmergencyIapProvider::NewLC( |
|
55 aPriority ); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // NewLC |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CSVPEmergencyIapProvider* CSVPEmergencyIapProvider::NewLC( |
|
65 TPriority aPriority ) |
|
66 { |
|
67 CSVPEmergencyIapProvider* self = new( ELeave ) CSVPEmergencyIapProvider( |
|
68 aPriority ); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Destructor |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 CSVPEmergencyIapProvider::~CSVPEmergencyIapProvider() |
|
79 { |
|
80 SVPDEBUG1("CSVPEmergencyIapProvider::~CSVPEmergencyIapProvider() In") |
|
81 |
|
82 Cancel(); |
|
83 |
|
84 iConnectionMonitor.Close(); |
|
85 |
|
86 delete iWait; |
|
87 |
|
88 SVPDEBUG1("CSVPEmergencyIapProvider::~CSVPEmergencyIapProvider() Out") |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Requests all IAP IDs |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 TInt CSVPEmergencyIapProvider::RequestIapIds( RArray<TUint>& aIapIds ) |
|
96 { |
|
97 SVPDEBUG1("CSVPEmergencyIapProvider::RequestIapIds()") |
|
98 |
|
99 if ( IsActive() ) |
|
100 { |
|
101 return KErrInUse; |
|
102 } |
|
103 |
|
104 // Make request for IAP IDs |
|
105 iConnectionMonitor.GetPckgAttribute( |
|
106 EBearerIdWLAN, 0, KIapAvailability, iIapInfoBuf, iStatus ); |
|
107 SetActive(); |
|
108 |
|
109 // Wait until request completes |
|
110 iWait->Start(); |
|
111 // Continues here after RunL completed |
|
112 |
|
113 // Copy IAP IDs to array |
|
114 if ( KErrNone == iError ) |
|
115 { |
|
116 TUint count = iIapInfoBuf().iCount; |
|
117 for ( TInt i = 0; i < count; i++ ) |
|
118 { |
|
119 aIapIds.Append( iIapInfoBuf().iIap[i].iIapId ); |
|
120 } |
|
121 } |
|
122 |
|
123 return iError; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // From class CActive. |
|
128 // DoCancel |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CSVPEmergencyIapProvider::DoCancel() |
|
132 { |
|
133 SVPDEBUG1("CSVPEmergencyIapProvider::DoCancel()") |
|
134 |
|
135 iConnectionMonitor.CancelAsyncRequest( EConnMonGetPckgAttribute ); |
|
136 |
|
137 if ( iWait->IsStarted() ) |
|
138 { |
|
139 iWait->AsyncStop(); |
|
140 } |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // From class CActive. |
|
145 // RunL |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CSVPEmergencyIapProvider::RunL() |
|
149 { |
|
150 iError = iStatus.Int(); |
|
151 SVPDEBUG2("CSVPEmergencyIapProvider::RunL(), error: %d", iError) |
|
152 |
|
153 if ( iWait->IsStarted() ) |
|
154 { |
|
155 iWait->AsyncStop(); |
|
156 // Returns right after iWait.Start() call |
|
157 } |
|
158 } |