1 /* |
|
2 * Copyright (c) 2006 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 the License "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: Class to handle connection creation.* |
|
15 */ |
|
16 |
|
17 |
|
18 #ifndef __VCX_CONNUTIL_H_ |
|
19 #define __VCX_CONNUTIL_H_ |
|
20 |
|
21 // Deprecation warning |
|
22 #warning This header file has been deprecated. Will be removed in one of the next SDK releases. |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CVcxConnUtilImpl; |
|
29 class MConnUtilEngineObserver; |
|
30 |
|
31 |
|
32 // CLASS DECLARATION |
|
33 /** |
|
34 * Class is the main interface class for the vcxconnectionutility.dll. |
|
35 * By using this class, client can fetch iap ID and maintain an active connection |
|
36 * for that iap. |
|
37 * Usage: |
|
38 * @code |
|
39 * #include <vcxconnectionutility.h> |
|
40 * #include <vcxconnutilengineobserver.h> // for receiving events from ALR and iap changes |
|
41 * |
|
42 * // Instantiation of connectionutility is done by Instance() |
|
43 * // every Instance call increments internal reference count by |
|
44 * // one. When reference count is decremented to 0 deallocation |
|
45 * // occurs. Client should make sure that it calls as many |
|
46 * // DecreaseReferenceCount() as it calls InstanceL() |
|
47 * |
|
48 * CVcxConnectionUtility* conUtil = CVcxConnectionUtility::InstanceL(); |
|
49 * |
|
50 * // in case client is interested in events from ALR or from iap changes, |
|
51 * // client must implement MConnUtilEngineObserver interface and register |
|
52 * // as observer. See MConnUtilEngineObserver documentation for details |
|
53 * conUtil->RegisterObserverL( this ); |
|
54 * |
|
55 * // getting the best possible iap is handled by the GetIap |
|
56 * TInt err( KErrNone ); |
|
57 * TUint32 iapId( 0 ); |
|
58 * err = conUtil->GetIap( iapId, EFalse ); |
|
59 * // in case client does not want the "connecting" dialog // shown, aSilent |
|
60 * // parameter should be ETrue |
|
61 * |
|
62 * // client can try to explicitly disconnect connection, but if there are other references |
|
63 * // connection is not closed. |
|
64 * // suggestion is to maintain connection at all time as long as vcxconnectionutility |
|
65 * // is being used and just react to notifications |
|
66 * conUtil->Disconnect(); |
|
67 * |
|
68 * // when connectionutility is no longer needed, client must call DecreaseReferenceCount() |
|
69 * // if there are no more references left, memory allocated for the library is deallocated |
|
70 * // and possible active connection is closed |
|
71 * // if client has registered as observer, it should deregister first |
|
72 * conUtil->RemoveObserver(); |
|
73 * conUtil->DecreaseReferenceCount(); |
|
74 * conutil = NULL; |
|
75 * |
|
76 * @endcode |
|
77 * |
|
78 * |
|
79 * @lib vcxconnectionutility.dll |
|
80 */ |
|
81 NONSHARABLE_CLASS( CVcxConnectionUtility) : public CActive |
|
82 { |
|
83 |
|
84 public: // Constructors and destructor |
|
85 |
|
86 /** |
|
87 * returns instance of the singleton object. This increases |
|
88 * local reference count by one, so utility members should |
|
89 * not be called through this. |
|
90 * |
|
91 * @return Pointer to CVcxConnectionUtility object. |
|
92 */ |
|
93 IMPORT_C static CVcxConnectionUtility* InstanceL(); |
|
94 |
|
95 /** |
|
96 * Remove the reference to this connectionutility instance. |
|
97 * |
|
98 * This should be called when client does not need |
|
99 * utility anymore. |
|
100 * |
|
101 * Decreases the reference count by one. When |
|
102 * all references are removed, the ui engine is destructed. |
|
103 */ |
|
104 IMPORT_C void DecreaseReferenceCount(); |
|
105 |
|
106 private: |
|
107 /** |
|
108 * Destructor. |
|
109 */ |
|
110 virtual ~CVcxConnectionUtility(); |
|
111 |
|
112 /** |
|
113 * constructor. |
|
114 * |
|
115 */ |
|
116 CVcxConnectionUtility( ); |
|
117 |
|
118 /** |
|
119 * Private 2nd phase construction. |
|
120 */ |
|
121 void ConstructL(); |
|
122 |
|
123 /** |
|
124 * From CActive, handles an active object’s request completion event |
|
125 */ |
|
126 void RunL(); |
|
127 |
|
128 /** |
|
129 * From CActive, implements cancellation of an outstanding request. |
|
130 * This function is called as part of the active object’s Cancel(). |
|
131 */ |
|
132 void DoCancel(); |
|
133 |
|
134 public: // New functions |
|
135 |
|
136 |
|
137 /** |
|
138 * Returns open IAP, if connection is not opened it is created |
|
139 * |
|
140 * @param aIapId On return, IAP ID. |
|
141 * @param aSilent If ETrue, tries to open connection silently (without dialogs) |
|
142 * In the 'Always ask' mode query dialog is always shown. |
|
143 * |
|
144 * @return KErrNone or one of the system wide error codes. |
|
145 */ |
|
146 IMPORT_C TInt GetIap( TUint32& aIapId, TBool aSilent ); |
|
147 |
|
148 /** |
|
149 * Gets WAP id from IAP id. Leaves with KErrNotFound if no record with given |
|
150 * IAP id is found. |
|
151 * |
|
152 * @param aIapId IAP id to match. |
|
153 * @return WAP id matching the given IAP id. |
|
154 */ |
|
155 IMPORT_C TUint32 WapIdFromIapIdL( TUint32 aIapId ); |
|
156 |
|
157 /** |
|
158 * Closes open connection. |
|
159 */ |
|
160 IMPORT_C void DisconnectL(); |
|
161 |
|
162 /** |
|
163 * Registers observer |
|
164 * |
|
165 * @param MConnUtilEngineObserver |
|
166 */ |
|
167 IMPORT_C void RegisterObserverL( MConnUtilEngineObserver* aObserver ); |
|
168 |
|
169 /** |
|
170 * Removes observer from the array of observers |
|
171 * |
|
172 * @param MConnUtilEngineObserver |
|
173 */ |
|
174 IMPORT_C void RemoveObserver( MConnUtilEngineObserver* aObserver ); |
|
175 |
|
176 /** |
|
177 * Displays a wait note. Method calls notifier to show |
|
178 * dialog and sets this active object active. If user cancels |
|
179 * dialog by pressing cancel, RunL is being called with KErrCancel. |
|
180 * |
|
181 * @param aConnectionName name of connection to show on the dialog |
|
182 */ |
|
183 void DisplayWaitNote( const TDesC& aConnectionName = KNullDesC ); |
|
184 |
|
185 /** |
|
186 * closes a wait note |
|
187 * |
|
188 */ |
|
189 void CloseWaitNote(); |
|
190 |
|
191 |
|
192 private: // Data |
|
193 |
|
194 /** |
|
195 * Count of references to this object. |
|
196 */ |
|
197 TInt iReferenceCount; |
|
198 |
|
199 /** |
|
200 * Utility implementation object |
|
201 */ |
|
202 CVcxConnUtilImpl* iUtilImpl; |
|
203 |
|
204 /** |
|
205 * Notifier used for showing connecting dialogs |
|
206 */ |
|
207 RNotifier iNotifier; |
|
208 |
|
209 }; |
|
210 #endif // __VCXNS_CONNUTIL_H_ |
|
211 // End of File |
|