|
1 /* |
|
2 * Copyright (c) 2002-2004 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: This file contains the header file of the CSWInstRequestObject |
|
15 * class. |
|
16 * |
|
17 * This class is a base class for request handler objects. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef SWINSTREQUESTOBJECT_H |
|
23 #define SWINSTREQUESTOBJECT_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 |
|
28 namespace SwiUI |
|
29 { |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CSWInstUIPluginAPI; |
|
33 class CStartupItem; |
|
34 class CTaskManager; |
|
35 |
|
36 /** |
|
37 * Callback interface for observing request completion. |
|
38 * |
|
39 * @since 3.0 |
|
40 */ |
|
41 class MRequestCallback |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Called when request is completed. |
|
47 * @param aResult - Result of the request. |
|
48 */ |
|
49 virtual void RequestCompleted( TInt aResult ) = 0; |
|
50 }; |
|
51 |
|
52 // CLASS DECLARATION |
|
53 |
|
54 /** |
|
55 * This class is a base class for request handler objects. |
|
56 * |
|
57 * @since 3.0 |
|
58 */ |
|
59 class CSWInstRequestObject : public CActive |
|
60 { |
|
61 public: // Constructors and destructor |
|
62 |
|
63 /** |
|
64 * C++ default constructor. |
|
65 * @param aMessage - Message object having this request. The ipc code of the message |
|
66 * will be used as the object's id. |
|
67 */ |
|
68 CSWInstRequestObject( const RMessage2& aMessage ); |
|
69 |
|
70 /** |
|
71 * C++ default constructor. |
|
72 * @param aObjectId - Id of the request. |
|
73 */ |
|
74 CSWInstRequestObject( TInt aObjectId ); |
|
75 |
|
76 /** |
|
77 * Destructor. |
|
78 */ |
|
79 virtual ~CSWInstRequestObject(); |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
84 * Returns the message object having this request. |
|
85 * @since 3.0 |
|
86 * @return Message object. If no message object has been set, the value is NULL. |
|
87 */ |
|
88 RMessage2* Message(); |
|
89 |
|
90 /** |
|
91 * Returns the request id of this object. |
|
92 * @since 3.0 |
|
93 * @return Handle of the object. |
|
94 */ |
|
95 TInt ObjectId() const; |
|
96 |
|
97 /** |
|
98 * Completes the request. |
|
99 * If callback has been set, the callback function will be called. |
|
100 * If the ipc message object has been set, the message will be completed. |
|
101 * @since 3.0 |
|
102 * @param aResult - Result of the request. |
|
103 */ |
|
104 void Complete( TInt aResult ); |
|
105 |
|
106 /** |
|
107 * Sets the request callback handler. |
|
108 * @since 3.0 |
|
109 * @param aCallback - Callback handler. |
|
110 */ |
|
111 void SetCallback( MRequestCallback* aCallback ); |
|
112 |
|
113 /** |
|
114 * Cancel current operation. Asynchronous. |
|
115 * @since 3.0 |
|
116 */ |
|
117 void Cancel(); |
|
118 |
|
119 /** |
|
120 * Cancel current operation. Asynchronous. |
|
121 * @since 3.0 |
|
122 * @param aMessage - Cancel message. Will be completed after the cancel |
|
123 * is completed. |
|
124 */ |
|
125 void Cancel( const RMessage2& aMessage ); |
|
126 |
|
127 protected: // New functions |
|
128 |
|
129 /** |
|
130 * 2nd phase constructor. |
|
131 */ |
|
132 void BaseConstructL(); |
|
133 |
|
134 /** |
|
135 * Creates a UI plugin based on the given mime time. Deriving objects must call this |
|
136 * function before accessing the UI plugin! |
|
137 * @since 3.0 |
|
138 * @param aMime - Mime type. |
|
139 */ |
|
140 void CreatePluginL( const TDesC8& aMime ); |
|
141 |
|
142 /** |
|
143 * Checks if there is another request object in use globally. Leaves with |
|
144 * KSWInstErrBusy if there is. |
|
145 * @since 3.0 |
|
146 */ |
|
147 void LeaveIfInUseL(); |
|
148 |
|
149 /** |
|
150 * Cancel current request to be implemented by derived classes. |
|
151 * @since 3.0 |
|
152 */ |
|
153 virtual void CancelRequest() = 0; |
|
154 |
|
155 /** |
|
156 * Gets called when the request is completed. |
|
157 * @since 3.0 |
|
158 * @param aResult - Result of the request. |
|
159 */ |
|
160 virtual void RequestCompleteL( TInt aResult ) = 0; |
|
161 |
|
162 /** |
|
163 * Completes this active object. |
|
164 * @since 3.0 |
|
165 * @param aResult - Result of the request. |
|
166 */ |
|
167 void CompleteSelf( TInt aResult ); |
|
168 |
|
169 private: // Functions from base classes |
|
170 |
|
171 /** |
|
172 * From CActive, Called by framework when request is finished. |
|
173 * @since 3.0 |
|
174 */ |
|
175 void RunL(); |
|
176 |
|
177 /** |
|
178 * From CActive, Called by framework when request is cancelled. |
|
179 * @since 3.0 |
|
180 */ |
|
181 void DoCancel(); |
|
182 |
|
183 /** |
|
184 * From CActive, Handles a leave occurring in the request completion |
|
185 * event handler RunL(). |
|
186 * @since 3.0 |
|
187 */ |
|
188 TInt RunError( TInt aError ); |
|
189 |
|
190 protected: // Data |
|
191 |
|
192 CSWInstUIPluginAPI* iUIPlugin; // UI plugin, see CreatePluginL |
|
193 TBool iCancelling; |
|
194 TBool iIsSilent; |
|
195 CTaskManager* iTaskManager; |
|
196 |
|
197 private: // Data |
|
198 |
|
199 RMessage2 iMessage; // Message object |
|
200 TBool iMessageSet; |
|
201 |
|
202 TInt iObjectId; |
|
203 MRequestCallback* iCallback; |
|
204 |
|
205 RMutex iSingleInstanceMutex; |
|
206 |
|
207 RMessage2 iCancelMessage; // Cancel message object |
|
208 TBool iCancelMessageSet; |
|
209 }; |
|
210 } |
|
211 |
|
212 #endif // SWINSTREQUESTOBJECT_H |
|
213 |
|
214 // End of File |