|
1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef STUBCLIENT_H |
|
19 #define STUBCLIENT_H |
|
20 |
|
21 #include <e32std.h> |
|
22 #include <stubsrvconst.h> |
|
23 #include <apibehavior.h> |
|
24 |
|
25 class RStubClient : public RSessionBase |
|
26 { |
|
27 |
|
28 public: |
|
29 |
|
30 /** |
|
31 * Queues an API behavior specification to Stub server. |
|
32 * |
|
33 * This method is called by API behavior controllers, e.g. a module test, to specify the next expected |
|
34 * behavior of an API. When InvokeApi() is called, the first queued behavior matching |
|
35 * the lib identifier and API identifier will be extracted and returned. |
|
36 * |
|
37 * @param aApi an API behavior. |
|
38 * @param aExeDuration, specifies the execution time of InvokeApi() in microseconds. |
|
39 * value less than 0 means never completing InvokeApi(); |
|
40 * value 0 means completing InvokeApi() asap; |
|
41 * value 1000000 means InvokeApi() takes 1 sec execution time; |
|
42 * and so on. |
|
43 */ |
|
44 void EnqueBehavior(const TApiBehavior& aBeh, TInt aExeDuration = 0); |
|
45 |
|
46 /** |
|
47 * Deletes all queued behaviors of the specified API. |
|
48 * |
|
49 * @param aLib the identifier of a stub |
|
50 * @param aApi the identifier of the API |
|
51 */ |
|
52 void DeleteBehaviors(TUint aLib, TUint aApi); |
|
53 |
|
54 /** |
|
55 * Invokes an API. |
|
56 * |
|
57 * If there is a queued behavior for this API, stub server will perform according to the execution setting; |
|
58 * otherwise stub server will act according to the specified mode. |
|
59 * |
|
60 * @param aBehPckg contains the lib and API identifiers when passed in; |
|
61 * will contain the behavior at complete. |
|
62 * @param aMode the mode to be used if no queued behavior is found for the specified API; |
|
63 * In case of ECompleteIfNoBehaviorSet mode, stub server will complete this function |
|
64 * immediately and return a default TApiBehavior(TUint, TUint); |
|
65 * stub server will keep this function call pending until a behavior is queued if the mode |
|
66 * is ESuspendIfBehaviorSet. |
|
67 */ |
|
68 void InvokeApi(TApiBehaviorPckg& aBehPckg, TApiInvokeMode aMode); |
|
69 |
|
70 /** |
|
71 * asynchronous version of InvokeAPI(). |
|
72 * |
|
73 * Leaves if the completion code in the behavior is not KErrNone |
|
74 */ |
|
75 void InvokeApiL(TApiBehaviorPckg& aBehPckg, TRequestStatus& aStatus, TApiInvokeMode aMode); |
|
76 |
|
77 /** |
|
78 * Cancels InvokeApi() |
|
79 * @param aLib the identifier of library which provides the API |
|
80 * @param aApi the identifier of the API |
|
81 */ |
|
82 void InvokeApiCancel(TUint aLib, TUint aApi); |
|
83 |
|
84 public: |
|
85 |
|
86 /** |
|
87 * @return Version information about the server |
|
88 */ |
|
89 TVersion Version() const; |
|
90 |
|
91 /** |
|
92 * Establishes a session with stub server. |
|
93 * @return error code |
|
94 */ |
|
95 TInt Connect(); |
|
96 |
|
97 private: |
|
98 |
|
99 void CheckSession(); |
|
100 |
|
101 }; |
|
102 |
|
103 #endif // STUBCLIENT_H |