1 /* |
|
2 * s_cch.cpp : Copyright (c) 2009 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: s_cch.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 // EXTERNAL INCLUDES |
|
19 #include <CEUnitTestSuiteClass.h> |
|
20 #include <cch.h> |
|
21 |
|
22 #include "s_cch.h" |
|
23 |
|
24 MyCchService* myService = NULL; |
|
25 TBool createService = EFalse; |
|
26 TBool tryAllSubserviceAvailable = EFalse; |
|
27 TBool tryVoipSubServiceAvailable = EFalse; |
|
28 TBool tryPresenceSubServiceAvailable = EFalse; |
|
29 TBool tryIMSubServiceAvailable = EFalse; |
|
30 TBool tryConnParamLeaveWithNotSupported = EFalse; |
|
31 TBool tryConnParamWithSuccess = EFalse; |
|
32 TBool sendObserverEvent = EFalse; |
|
33 TBool getUserName = EFalse; |
|
34 TBool getPassword = EFalse; |
|
35 TBool tryParamTomatchOwnId =EFalse; |
|
36 TBool tryConnParamWithFailure = EFalse; |
|
37 |
|
38 |
|
39 |
|
40 /*************** Stubs ****************/ |
|
41 CCchService* CCch::GetService( TInt /*aServiceId*/ ) |
|
42 { |
|
43 if( createService && !myService ) |
|
44 { |
|
45 myService = new ( ELeave ) MyCchService(); |
|
46 return myService; |
|
47 } |
|
48 |
|
49 return myService; |
|
50 } |
|
51 |
|
52 |
|
53 /************* End of Stubs ************/ |
|
54 |
|
55 |
|
56 |
|
57 TInt MyCchService::Enable( TCCHSubserviceType aType ) |
|
58 { |
|
59 |
|
60 if (sendObserverEvent) |
|
61 { |
|
62 if (iObserver) |
|
63 { |
|
64 TCchServiceStatus aStatus; |
|
65 |
|
66 aStatus.SetState(ECCHEnabled); |
|
67 aStatus.SetError(KErrNone); |
|
68 |
|
69 if (tryPresenceSubServiceAvailable) |
|
70 { |
|
71 iObserver->ServiceStatusChanged( 10, ECCHPresenceSub, aStatus ); |
|
72 } |
|
73 else |
|
74 { |
|
75 iObserver->ServiceStatusChanged( 10, aType, aStatus ); |
|
76 } |
|
77 } |
|
78 } |
|
79 |
|
80 return KErrNone; |
|
81 } |
|
82 |
|
83 /** |
|
84 * Launches service disable. See MCchServiceObserver for status changes. |
|
85 * |
|
86 * @param aType Type of service |
|
87 * @return Symbian error |
|
88 */ |
|
89 TInt MyCchService::Disable( TCCHSubserviceType /*aType*/ ){ return KErrNone; } |
|
90 |
|
91 /** |
|
92 * Returns the current service state |
|
93 * |
|
94 * @param aType Type of service |
|
95 * @param aStatus Status of the service, return value |
|
96 * @return Symbian error code |
|
97 */ |
|
98 TInt MyCchService::GetStatus( TCCHSubserviceType aType, |
|
99 TCchServiceStatus& aStatus ) const |
|
100 |
|
101 { |
|
102 |
|
103 if ( (ECCHVoIPSub == aType) && (tryVoipSubServiceAvailable || tryAllSubserviceAvailable) ) |
|
104 { |
|
105 aStatus.SetState(ECCHUninitialized); |
|
106 aStatus.SetError(KErrNone); |
|
107 return KErrNone; |
|
108 } |
|
109 |
|
110 else if ( (ECCHPresenceSub == aType) && (tryPresenceSubServiceAvailable || tryAllSubserviceAvailable) ) |
|
111 { |
|
112 aStatus.SetState(ECCHUninitialized); |
|
113 aStatus.SetError(KErrNone); |
|
114 return KErrNone; |
|
115 } |
|
116 |
|
117 else if ( (ECCHIMSub == aType) && (tryIMSubServiceAvailable || tryAllSubserviceAvailable) ) |
|
118 { |
|
119 aStatus.SetState(ECCHUninitialized); |
|
120 aStatus.SetError(KErrNone); |
|
121 return KErrNone; |
|
122 } |
|
123 |
|
124 return KErrNotFound ; |
|
125 |
|
126 } |
|
127 |
|
128 /** |
|
129 * Returns the connection parameters |
|
130 * |
|
131 * @param aType Type of service |
|
132 * @param aParameter Connection parameter of the service |
|
133 * @param aValue Value of the parameter |
|
134 * @return Symbian error code |
|
135 */ |
|
136 TInt MyCchService::GetConnectionParameter( TCCHSubserviceType /*aType*/, |
|
137 TCchConnectionParameter /*aParameter*/, TInt& /*aValue*/ ) const{ return KErrNone;} |
|
138 |
|
139 /** |
|
140 * Returns the connection parameters |
|
141 * |
|
142 * @param aType Type of service |
|
143 * @param aParameter Connection parameter of the service |
|
144 * @param aValue Value of the parameter |
|
145 * @return Symbian error code |
|
146 */ |
|
147 TInt MyCchService::GetConnectionParameter( TCCHSubserviceType /*aType*/, |
|
148 TCchConnectionParameter /*aParameter*/, RBuf& aValue ) const |
|
149 |
|
150 { |
|
151 if (tryConnParamLeaveWithNotSupported) |
|
152 { |
|
153 return KErrNotSupported; |
|
154 } |
|
155 |
|
156 if (tryConnParamWithSuccess) |
|
157 { |
|
158 aValue.Copy(KTestUserName); |
|
159 } |
|
160 if (tryParamTomatchOwnId) |
|
161 { |
|
162 aValue.Copy(KOwnUserNameMatch); |
|
163 } |
|
164 if ( getUserName ) |
|
165 { |
|
166 aValue.Copy(KTestUserName); |
|
167 } |
|
168 if ( getPassword ) |
|
169 { |
|
170 aValue.Copy(KTestPassword); |
|
171 } |
|
172 if(tryConnParamWithFailure) |
|
173 { |
|
174 return KErrNotFound; |
|
175 } |
|
176 |
|
177 return KErrNone; |
|
178 } |
|
179 |
|
180 /** |
|
181 * Sets the connection parameters |
|
182 * |
|
183 * @param aType The type of service |
|
184 * @param aParameter Connection parameter of the service |
|
185 * @param aValue Value of the parameter |
|
186 * @return Symbian error code |
|
187 */ |
|
188 TInt MyCchService::SetConnectionParameter( TCCHSubserviceType /*aType*/, |
|
189 TCchConnectionParameter /*aParameter*/, TInt /*aValue*/ ) |
|
190 |
|
191 { |
|
192 return KErrNone; |
|
193 } |
|
194 |
|
195 /** |
|
196 * Sets the connection parameters |
|
197 * |
|
198 * @param aType The type of service |
|
199 * @param aParameter Connection parameter of the service |
|
200 * @param aValue Value of the parameter |
|
201 * @return Symbian error code |
|
202 */ |
|
203 TInt MyCchService::SetConnectionParameter( TCCHSubserviceType /*aType*/, |
|
204 TCchConnectionParameter /*aParameter*/, const TDesC& /*aValue*/ ) |
|
205 { |
|
206 if (tryConnParamLeaveWithNotSupported) |
|
207 { |
|
208 return KErrNotSupported; |
|
209 } |
|
210 |
|
211 return KErrNone; |
|
212 } |
|
213 |
|
214 /** |
|
215 * Reserves the service for exclusive usage |
|
216 * |
|
217 * @param aType Type of service |
|
218 * @return Symbian error code |
|
219 */ |
|
220 TInt MyCchService::Reserve( TCCHSubserviceType /*aType*/ ){ return KErrNone; } |
|
221 |
|
222 /** |
|
223 * Frees the service of exclusive usage |
|
224 * |
|
225 * @param aType Type of service |
|
226 * @return Symbian error code |
|
227 */ |
|
228 TInt MyCchService::Free( TCCHSubserviceType /*aType*/ ){ return KErrNone; } |
|
229 |
|
230 /** |
|
231 * Is the service reserved |
|
232 * |
|
233 * @param aType Type of service |
|
234 * @param aReserved True if the service is reserved |
|
235 * @return Symbian error code |
|
236 */ |
|
237 TInt MyCchService::IsReserved( TCCHSubserviceType /*aType*/, TBool& /*aReserved*/ ) const{ return KErrNone; } |
|
238 |
|
239 /** |
|
240 * Returns the service id |
|
241 * |
|
242 * @return The id of the service |
|
243 */ |
|
244 TInt MyCchService::ServiceId() const{ return KErrNone; } |
|
245 |
|
246 /** |
|
247 * @deprecated Do not use this anymore, change to AddObserver! |
|
248 * |
|
249 * Adds observer for listening service events |
|
250 * |
|
251 * @param aObserver Event observing class |
|
252 */ |
|
253 void MyCchService::SetObserver( MCchServiceStatusObserver& aObserver ) |
|
254 { |
|
255 iObserver = &aObserver; |
|
256 } |
|
257 |
|
258 /** |
|
259 * @deprecated Do not use this anymore, change to |
|
260 * RemoveObserver method with paramater |
|
261 * |
|
262 * Removes the observer of service events |
|
263 */ |
|
264 void MyCchService::RemoveObserver( ) |
|
265 { |
|
266 iObserver = NULL; |
|
267 } |
|
268 |
|
269 |
|
270 /** |
|
271 * Adds observer for listening service events |
|
272 * |
|
273 * @param aObserver Event observing class |
|
274 * @return KErrAlreadyExist Observer already added |
|
275 * KErrNone Observer was added |
|
276 */ |
|
277 TInt MyCchService::AddObserver( MCchServiceStatusObserver& /*aObserver*/ ){ return KErrNone; } |
|
278 |
|
279 /** |
|
280 * Removes the observer of service events |
|
281 * |
|
282 * @param aObserver Event observing class |
|
283 * @return KErrNotFound Observer was not found |
|
284 * KErrNone Observer was removed |
|
285 */ |
|
286 TInt MyCchService::RemoveObserver( MCchServiceStatusObserver& /*aObserver*/ ){ return KErrNone; } |
|
287 |
|
288 /** |
|
289 * Checks if the type is supported |
|
290 * |
|
291 * @param aType Type of service |
|
292 * @param aSupported True if the service type is supported |
|
293 * @return Symbian error code |
|
294 */ |
|
295 TInt MyCchService::IsSupported( TCCHSubserviceType /*aType*/, TBool& /*aSupported*/ ) const{ return KErrNone; } |
|
296 |
|
297 |
|
298 //end of file |
|
299 |
|
300 |
|
301 |
|