|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of the CImConnection interface (imconnection.h) |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef IMCONNECTIONIMPL_H |
|
21 #define IMCONNECTIONIMPL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <imconnection.h> |
|
26 #include <ImpsAccessCli.h> |
|
27 |
|
28 |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CContactDBReader; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * Implementation of the MImConnection interface |
|
37 * |
|
38 * @lib imclient.lib |
|
39 * @since 3.0 |
|
40 */ |
|
41 class CImConnectionImpl : public CImConnection, |
|
42 public MImpsAccessHandler2, |
|
43 public MImpsErrorHandler2, |
|
44 public MImpsStatusHandler2 |
|
45 { |
|
46 public: // Constructors and destructor |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 */ |
|
51 static CImConnectionImpl* NewL( TDesC& aApplicationId ); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 virtual ~CImConnectionImpl(); |
|
57 |
|
58 public: // New functions |
|
59 |
|
60 /** |
|
61 * Return the IMPS engine |
|
62 * @since 3.0 |
|
63 * @return the IMPS engine |
|
64 */ |
|
65 RImpsEng& ImpsEngine(); |
|
66 |
|
67 /** |
|
68 * Return the Contact DB reader |
|
69 * @since 3.0 |
|
70 * @return the reader |
|
71 */ |
|
72 CContactDBReader& ContactDBReader(); |
|
73 |
|
74 /** |
|
75 * Returns the Application ID with which the client connected |
|
76 * @since 3.0 |
|
77 * @return ClientId |
|
78 */ |
|
79 const TDesC& ApplicationId(); |
|
80 |
|
81 /** |
|
82 * Converts the error code returned by the IMPS engine to API error code. |
|
83 * @since 3.0 |
|
84 * @param aErroCode ImpsEngine error code |
|
85 * @return API error code |
|
86 */ |
|
87 TInt ConvertImpsEngineErrorCode( TInt aErrorCode ); |
|
88 |
|
89 |
|
90 public: // Functions from base classes |
|
91 /** |
|
92 * From MImConnection |
|
93 */ |
|
94 MImClient* CreateImClientL(); |
|
95 |
|
96 /** |
|
97 * From MImConnection |
|
98 */ |
|
99 void RegisterObserverL( |
|
100 MImConnectionObserver* aObserver ); |
|
101 |
|
102 /** |
|
103 * From MImConnection |
|
104 */ |
|
105 void UnregisterObserver(); |
|
106 |
|
107 /** |
|
108 * From MImConnection |
|
109 */ |
|
110 TImConnectionStatus ImConnectionStatus(); |
|
111 |
|
112 /** |
|
113 * From MImConnection |
|
114 */ |
|
115 void LoginL( |
|
116 const TDesC& aServer, |
|
117 const TDesC& aUserID, |
|
118 const TDesC& aPassword, |
|
119 const TUint32 aAP ); |
|
120 |
|
121 /** |
|
122 * From MImConnection |
|
123 */ |
|
124 void CancelLoginL( ); |
|
125 |
|
126 /** |
|
127 * From MImConnection |
|
128 */ |
|
129 void LogoutL( ); |
|
130 |
|
131 public: // from MImpsAccessHandler2 |
|
132 |
|
133 void HandleLoginL( |
|
134 TInt aId, |
|
135 TImpsCspIdentifier& aCspId ); |
|
136 |
|
137 void HandleLoginCancelL( |
|
138 TInt aCancelledOpId, |
|
139 TImpsCspIdentifier& aCspId ); |
|
140 |
|
141 void HandleLogoutL( |
|
142 TInt aId, |
|
143 TImpsCspIdentifier& aCspId ); |
|
144 |
|
145 |
|
146 void HandleNbrSessionsL( |
|
147 TInt aId, |
|
148 TInt aNbr, |
|
149 TImpsCspIdentifier& aCspId |
|
150 ); |
|
151 |
|
152 void HandleErrorL( |
|
153 TInt aStatus, |
|
154 TInt aOpId, |
|
155 const TDesC* aDescription, |
|
156 const CImpsDetailed* aDetailedRes, |
|
157 TImpsCspIdentifier& aCspId ); |
|
158 |
|
159 public: // from MImpsStatusHandler |
|
160 void HandleStatusChangeL( |
|
161 TImpsServiceStatus aStatus, |
|
162 TImpsCspIdentifier& aCspId ); |
|
163 |
|
164 |
|
165 private: |
|
166 |
|
167 enum TConnectionState |
|
168 { |
|
169 EImNotLogged = 0, |
|
170 EImLoggingIn, |
|
171 EImCancelingLogin, |
|
172 EImLoggingOut, |
|
173 EImLoggedIn |
|
174 }; |
|
175 /** |
|
176 * C++ default constructor. |
|
177 */ |
|
178 CImConnectionImpl(); |
|
179 |
|
180 /** |
|
181 * By default Symbian 2nd phase constructor is private. |
|
182 */ |
|
183 void ConstructL( TDesC& aApplicationId ); |
|
184 |
|
185 /** |
|
186 * Changes the current state |
|
187 */ |
|
188 void SetState( TConnectionState aNewState ); |
|
189 |
|
190 private: // Data |
|
191 RImpsEng iEngine; // IMP engine |
|
192 RImpsAccessClient2 iAccessClient; // IMPS access client |
|
193 MImConnectionObserver* iClientObserver; // Client observer |
|
194 CContactDBReader* iContactReader; // Contact DB reader |
|
195 HBufC* iApplicationId;// Application ID of the |
|
196 // 3rd party app (owned) |
|
197 TReal iCspVersion; // the CSP version |
|
198 TInt iCurrentOpId; |
|
199 TConnectionState iState; |
|
200 |
|
201 }; |
|
202 |
|
203 #endif // IMCONNECTIONIMPL_H |
|
204 |
|
205 // End of File |