|
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: Base class for SAT commands |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CSATCOMMANDHANDLER_H |
|
21 #define CSATCOMMANDHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <etelsat.h> |
|
26 #include <SecondaryDisplay/secondarydisplaysatapi.h> |
|
27 #include "MSatUtils.h" |
|
28 #include "MSatEventObserver.h" |
|
29 #include "MSatCommand.h" |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * Base class for SAT commands. |
|
35 * |
|
36 * @lib SatServer |
|
37 * @since Series 60 3.0 |
|
38 */ |
|
39 class CSatCommandHandler : public CActive, public MSatEventObserver, |
|
40 public MSatCommand |
|
41 { |
|
42 public: // Constructors and destructor |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 * @param aImplUid Uid for derived class's plugin |
|
47 * @param aUtils Utils interface |
|
48 */ |
|
49 static CSatCommandHandler* NewL( |
|
50 const TUid& aImplUid, |
|
51 MSatUtils* aUtils ); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 IMPORT_C virtual ~CSatCommandHandler(); |
|
57 |
|
58 public: // New fucntions |
|
59 |
|
60 /** |
|
61 * Start the waiting of SAT command from USAT API. |
|
62 */ |
|
63 IMPORT_C void Start(); |
|
64 |
|
65 /** |
|
66 * Gives a panic. |
|
67 * @param aCategory A category for this panic |
|
68 * @param aReason Reason for this panic |
|
69 */ |
|
70 IMPORT_C void Panic( const TDesC& aCategory, TInt aReason ) const; |
|
71 |
|
72 /** |
|
73 * Indicates is this command handler currently executing a command. |
|
74 * @return ETrue if executing. |
|
75 */ |
|
76 IMPORT_C TBool IsCommandExecuting() const ; |
|
77 |
|
78 public: // Functions from base classes |
|
79 |
|
80 /** |
|
81 * From MSatEventObserver Notification of event. |
|
82 * @param aEvent An event that has been notified |
|
83 */ |
|
84 IMPORT_C void Event( TInt aEvent ); |
|
85 |
|
86 /** |
|
87 * From MSatCommand Response from client. |
|
88 * Default implementation will cause panic. |
|
89 */ |
|
90 IMPORT_C virtual void ClientResponse(); |
|
91 |
|
92 protected: // New functions |
|
93 |
|
94 /** |
|
95 * Start of the command handling. Asks from derived class whether the |
|
96 * command is allowed to execute by calling AllowCommand. |
|
97 * If command is allowed to execute then the need of ui session |
|
98 * is queried by calling NeedUiSession. If ui session is needed and |
|
99 * its not available, ui is launcehd and this class registers itself |
|
100 * to listen the event of ui launch. After the ui is launched, |
|
101 * HandleCommand is called. If the derived class does not need the ui |
|
102 * session or ui session is available, HandleCommand is called |
|
103 * immediatly. |
|
104 */ |
|
105 IMPORT_C virtual void DoHandleCommand(); |
|
106 |
|
107 /** |
|
108 * Derived class needs to make the request from USatApi. |
|
109 * @param aStatus Status of request. |
|
110 */ |
|
111 virtual void IssueUSATRequest( TRequestStatus& aStatus ) = 0; |
|
112 |
|
113 /** |
|
114 * Command has to check the state of the system and make the |
|
115 * desision of allowing the command to perform. If desision |
|
116 * is not to allow the command, then the terminal response has to |
|
117 * sent from this method. |
|
118 * @return TBool indicating is this command allowed or not |
|
119 */ |
|
120 virtual TBool CommandAllowed() = 0; |
|
121 |
|
122 /** |
|
123 * Queries need of ui session in order to |
|
124 * execute the command. If ui session is needed, the ui client |
|
125 * launched and this class will register it self for the notification |
|
126 * of ui request. |
|
127 * @return ETrue if ui session is needed. |
|
128 */ |
|
129 virtual TBool NeedUiSession() = 0; |
|
130 |
|
131 /** |
|
132 * Called when USAT API notifies that command |
|
133 * data is available. |
|
134 */ |
|
135 virtual void HandleCommand() = 0; |
|
136 |
|
137 /** |
|
138 * Called if launch of a Sat Ui application failed. |
|
139 * Every derived class, which needs a ui session in order to |
|
140 * execute command, needs to send a terminal |
|
141 * response from this method. |
|
142 */ |
|
143 virtual void UiLaunchFailed() = 0; |
|
144 |
|
145 protected: |
|
146 |
|
147 /** |
|
148 * Sends terminal response and renews the usat request of the command. |
|
149 * @param aPCmd Identifies the command, which is sending |
|
150 * terminal response. |
|
151 * @param aRsp Terminal response data package. |
|
152 */ |
|
153 IMPORT_C void TerminalRsp( RSat::TPCmd aPCmd, const TDesC8& aRsp ); |
|
154 |
|
155 /** |
|
156 * Calls SatSystemState's IsPhoneInIdleState if not using Dummy TSY, |
|
157 * otherwise returns ETrue |
|
158 * @return ETrue if using Dymmy TSY, otherwise asks status |
|
159 * from SatSystemState and returns it. |
|
160 */ |
|
161 IMPORT_C TBool IsPhoneInIdleState(); |
|
162 |
|
163 protected: // From CActive |
|
164 |
|
165 /** |
|
166 * From CActive base class |
|
167 */ |
|
168 IMPORT_C void RunL(); |
|
169 |
|
170 protected: |
|
171 |
|
172 /** |
|
173 * C++ default constructor. |
|
174 */ |
|
175 IMPORT_C CSatCommandHandler(); |
|
176 |
|
177 /** |
|
178 * By default Symbian 2nd phase constructor is private. |
|
179 * @param aPtr Pointer to Utils interface |
|
180 */ |
|
181 IMPORT_C void BaseConstructL( MSatUtils* aPtr ); |
|
182 |
|
183 protected: // Data |
|
184 |
|
185 // Utils interface |
|
186 MSatUtils* iUtils; |
|
187 |
|
188 private: // Data |
|
189 |
|
190 // Requiered attribute for the ECOM framework. |
|
191 TUid iDtorIDKey; |
|
192 |
|
193 // Indicates is this command handler executing |
|
194 TBool iIsExecuting; |
|
195 |
|
196 // Timer to get UI Launch notification released before |
|
197 // starting to handle pending proactive command. |
|
198 RTimer iDelayTimer; |
|
199 |
|
200 // Indicates that command is pending for UI to launch |
|
201 TBool iWaitingUiLaunch; |
|
202 }; |
|
203 |
|
204 #endif // CSATCOMMANDHANDLER_H |
|
205 |
|
206 // End of File |