|
1 /* |
|
2 * Copyright (c) 2002-2007 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: mmsconninit declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __MMSCONNINIT_H |
|
21 #define __MMSCONNINIT_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include "MmsConnInitLogging.h" |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <es_sock.h> |
|
29 #include <commdbconnpref.h> |
|
30 #include <commdb.h> |
|
31 |
|
32 // CONSTANTS |
|
33 // MACROS |
|
34 // DATA TYPES |
|
35 // FUNCTION PROTOTYPES |
|
36 // FORWARD DECLARATIONS |
|
37 class RConnection; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 /** |
|
41 * This class provides an interface for clients wishing to initiate an |
|
42 * Internet connection. Also function solving parameters needed in HTTP transport |
|
43 * is offered. |
|
44 */ |
|
45 class CMmsConnectionInitiator : public CActive |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 IMPORT_C static CMmsConnectionInitiator* NewL(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CMmsConnectionInitiator(); |
|
58 |
|
59 public: // New functions |
|
60 |
|
61 /** |
|
62 * Starts the connection procedure based on the Accesspoint link/refence |
|
63 * |
|
64 * @param RConnection conn (in) |
|
65 * @param CArrayFixFlat<TUint32>& aAccessPointArray (in) |
|
66 * @param aStatus (out) |
|
67 * aStatus is set to an error value in case of error. |
|
68 * In successful case aStatus is set to point to index of |
|
69 * aAccessPointArray (actually index+1). The index specifies the AP |
|
70 * that has been used for connection. |
|
71 * |
|
72 * Usage: |
|
73 * Client opens RConnection session and passes |
|
74 * a refernce parameter to MmsConnInit. Client |
|
75 * allocates an array containing WAP AP(s). The |
|
76 * client is responsible for allocation and |
|
77 * deallocation of memory |
|
78 */ |
|
79 IMPORT_C void ConnectL( |
|
80 RConnection& aConnection, |
|
81 CArrayFixFlat<TUint32>& aAccessPointArray, |
|
82 TRequestStatus& aStatus ); |
|
83 |
|
84 /** |
|
85 * Finds parameters needed for client using |
|
86 * HTTP Client API. Used also for access point validation |
|
87 * |
|
88 * @param TUint32 aAccessPointLink (in) |
|
89 * @param TUint32& aAccessPoint (out) |
|
90 * @param HBufC*& aServerUri (out) |
|
91 * @param TBool& aProxyUsed (out) |
|
92 * @param HBufC8*& aProxyAddress (out) |
|
93 * |
|
94 * Usage: |
|
95 * Link/reference to accesspoint is given as an input parameter. |
|
96 * The function resolves the other parameters based on the accesspoint |
|
97 * reference. |
|
98 * aUri and aProxyAddress are references to heap buffers. They should |
|
99 * not be allocated by client. Client is, however, responsible for |
|
100 * deallocating them when no longer needed. |
|
101 * Note that the buffer parameters may not be members of the client |
|
102 * because MmsConnInit puts them into CleanupStack temporarily |
|
103 * The function tries to solve the parameters even if there is something |
|
104 * wrong with the CommDb. |
|
105 * If the operation returns 0 as the value of aAccessPoint, something |
|
106 * has failed. |
|
107 */ |
|
108 IMPORT_C static void GetParametersL( |
|
109 TUint32 aAccessPointLink, |
|
110 TUint32& aAccessPoint, |
|
111 HBufC*& aServerUri, |
|
112 TBool& aProxyUsed, |
|
113 HBufC8*& aProxyAddress ); |
|
114 |
|
115 public: // Functions from base classes |
|
116 |
|
117 protected: // New functions |
|
118 |
|
119 protected: // Functions from base classes |
|
120 |
|
121 /** |
|
122 * From CActive |
|
123 * Handles the event generated when the request completes |
|
124 * @return void |
|
125 */ |
|
126 void RunL(); |
|
127 |
|
128 /** |
|
129 * From CActive |
|
130 * Cancels any outstanding request |
|
131 * @return void |
|
132 */ |
|
133 void DoCancel(); |
|
134 |
|
135 /** |
|
136 * From From CActive |
|
137 * This function is called if RunL leaves |
|
138 */ |
|
139 TInt RunError( TInt aError ); |
|
140 |
|
141 private: |
|
142 |
|
143 /** |
|
144 * Constructor |
|
145 */ |
|
146 void ConstructL(); |
|
147 |
|
148 /** |
|
149 * Checks if network is available. |
|
150 * @return TRUE, if network available, FALSE, if no network |
|
151 */ |
|
152 TBool CheckNetworkL(); |
|
153 |
|
154 |
|
155 /** |
|
156 * |
|
157 * @param TUint32 aWapAP (in) |
|
158 * @param TUint32& aIap (out) |
|
159 * @return TBool which informs if the IAP finding was successful |
|
160 */ |
|
161 TBool FindIapL( TUint32 aWapAP, TUint32& aIap ); |
|
162 |
|
163 /** |
|
164 * Checks that the WAP Start Page in CommsDB contains the scheme |
|
165 * (HTTP://). If not, it will be added. |
|
166 * @param HBufC* aUri is the WAP Start Page |
|
167 * @return void |
|
168 */ |
|
169 static void CheckWapStartPageL( HBufC*& aUri ); |
|
170 |
|
171 /** |
|
172 * Checks if there is already connections open and checks if the |
|
173 * connection could be reused or not. |
|
174 * @param aIap, IAP to connect or not to connect |
|
175 * @return void |
|
176 */ |
|
177 void StartConnectionL( TUint32 aIap ); |
|
178 |
|
179 /** |
|
180 * Searches for PDP Type and GPRS Access Point Name for an IAP given as |
|
181 * parameter. Memory for aGprsApn is allocated inside the function and |
|
182 * deallocation should be made by caller. The pointer is not in cleanup |
|
183 * stack. |
|
184 * @return TBool. ETrue if the connection is GPRS, otherwise EFalse |
|
185 */ |
|
186 TBool FindGprsParametersL( TUint32 aIap, TUint32& aPdpType, HBufC*& aGprsApn ); |
|
187 |
|
188 /** |
|
189 * C++ default constructor. |
|
190 */ |
|
191 CMmsConnectionInitiator(); |
|
192 |
|
193 public: // Data |
|
194 protected: // Data |
|
195 |
|
196 private: // Data |
|
197 RConnection* iConnection; |
|
198 TRequestStatus* iClientStatus; // status of the client |
|
199 TCommDbConnPref iPrefs; |
|
200 CArrayFixFlat<TUint32>* iArray; |
|
201 TInt iIndex; // Index of the table when looping it through |
|
202 TNifProgress iProgress; // instance of TNifProgressBuf |
|
203 // Timer to do a quick retry if case of immediate timeout |
|
204 RTimer iTimer; |
|
205 // Tells if timer is running and must be cancelled |
|
206 TBool iTimerRunning; |
|
207 // Time the connection is started |
|
208 TTime iStartTime; |
|
209 TInt iRetryCount; |
|
210 }; |
|
211 |
|
212 #endif // __MMSCONNINIT_H |
|
213 |
|
214 // End of File |