|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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 * This file contains the class definition of CPushAsyncOpRunner. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef PUSHASYNCOPRUNNER_H |
|
23 #define PUSHASYNCOPRUNNER_H |
|
24 |
|
25 // INCLUDES |
|
26 |
|
27 #include "PushMtmOperation.h" |
|
28 #include <e32std.h> |
|
29 #include <msvstd.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 |
|
33 class CMsvSession; |
|
34 class CMsvOperation; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * This class is intended as a base class of asynchronous ui operations. |
|
40 * It provides the syntax, and the semantics should be implemented by derived classes: |
|
41 * default implementations are provided, and derived classes may override this. |
|
42 * The main goal was to make those Push Mtm Ui's functions asynchronous, that are |
|
43 * really asynchronous, and avoid making them synchronous with using |
|
44 * CActiveScheduler::Start() and CActiveScheduler::Stop(). This makes the |
|
45 * design clearer and may prevent some problems raised by the usage of Start()'s and |
|
46 * Stop()'s. |
|
47 */ |
|
48 class CPushAsyncOpRunner : public CPushMtmOperation |
|
49 { |
|
50 public: // Functions from base classes |
|
51 |
|
52 /** |
|
53 * Start or restart the operation. OnStartupL is called. See OnStartupL. |
|
54 * @return None. |
|
55 */ |
|
56 IMPORT_C void StartL(); |
|
57 |
|
58 /** |
|
59 * Get progress information. |
|
60 * @return A package buffer (of type TPushMtmProgressBuf), containing |
|
61 * progress information. |
|
62 */ |
|
63 IMPORT_C const TDesC8& ProgressL(); |
|
64 |
|
65 protected: // Constructors and destructor |
|
66 |
|
67 /** |
|
68 * Constructor. CActiveScheduler::Add( this ) is called. Derived |
|
69 * classes shouldn't call CActiveScheduler::Add( this ) in their constructor. |
|
70 * @param aSession Msv session to use. |
|
71 * @param aEntryId Id of the context to operate on. |
|
72 * @param aObserverStatus Observer status. |
|
73 * @return None. |
|
74 */ |
|
75 IMPORT_C CPushAsyncOpRunner( CMsvSession& aSession, |
|
76 const TMsvId aEntryId, |
|
77 TRequestStatus& aObserverStatus ); |
|
78 |
|
79 /** |
|
80 * Destructor. |
|
81 */ |
|
82 IMPORT_C virtual ~CPushAsyncOpRunner(); |
|
83 |
|
84 protected: // New functions |
|
85 |
|
86 /** |
|
87 * This method is called from StartL. Default implementation returns ETrue |
|
88 * and sets aIsObserving to EFalse. |
|
89 * @param aIsObserving Used only if the function returns EFalse. |
|
90 * In this case |
|
91 * indicate in this variable if this operation observes |
|
92 * an other one. If so, then it is set to active, but |
|
93 * not completed - this will be made by the observed |
|
94 * operation. |
|
95 * Derived classes may override this. |
|
96 * @return Return ETrue if the operation has completed. Return EFalse |
|
97 * if the operation has not completed yet. In the latter case |
|
98 * parameter aIsObserving is also used. |
|
99 */ |
|
100 IMPORT_C virtual TBool OnStartupL( TBool& aIsObserving ); |
|
101 |
|
102 /** |
|
103 * This method is called from RunL. Default implementation returns ETrue |
|
104 * and sets aIsObserving to EFalse. |
|
105 * @param aIsObserving Used only if the function returns EFalse. |
|
106 * In this case |
|
107 * indicate in this variable if this operation observes |
|
108 * an other one. If so, then it is set to active, but |
|
109 * not completed - this will be made by the observed |
|
110 * operation. |
|
111 * Derived classes may override this. |
|
112 * @return Return ETrue if the operation has completed. Return EFalse |
|
113 * if the operation has not completed yet. In the latter case |
|
114 * parameter aIsObserving is also used. |
|
115 */ |
|
116 IMPORT_C virtual TBool OnRunLActionL( TBool& aIsObserving ); |
|
117 |
|
118 /** |
|
119 * Set observed operation and take ownership. |
|
120 * @param aOp The operation. |
|
121 * @return None. |
|
122 */ |
|
123 IMPORT_C void SetOperation( CMsvOperation* aOp ); |
|
124 |
|
125 /** |
|
126 * Delete the observed operation. |
|
127 * @return None. |
|
128 */ |
|
129 IMPORT_C void DeleteOperation(); |
|
130 |
|
131 /** |
|
132 * Return the observed operation. |
|
133 * @return The operation. |
|
134 */ |
|
135 IMPORT_C CMsvOperation& Operation(); |
|
136 |
|
137 protected: // Functions from base classes |
|
138 |
|
139 /** |
|
140 * RunL protocol implementation. See OnRunLActionL. |
|
141 * @return None. |
|
142 */ |
|
143 IMPORT_C void RunL(); |
|
144 |
|
145 /** |
|
146 * Default implementation cancels the observed operation, and |
|
147 * completes the observer with KErrCancel. |
|
148 * Derived classes may override this. |
|
149 * @return None. |
|
150 */ |
|
151 IMPORT_C void DoCancel(); |
|
152 |
|
153 /** |
|
154 * Default implementation cancels the observed operation, |
|
155 * completes the observer with aError and forwards the |
|
156 * error to the scheduler. |
|
157 * Derived classes may override this. |
|
158 * @param aError Leave code. |
|
159 * @return aError. |
|
160 */ |
|
161 IMPORT_C TInt RunError( TInt aError ); |
|
162 |
|
163 private: // Data members |
|
164 |
|
165 TBool iReady; ///< ETrue, if the operation is ready. |
|
166 CMsvOperation* iOperation; ///< The observed operation. Has. |
|
167 TBufC8<1> iDummyProgressBuf; ///< Dummy progress buffer. Ignored. |
|
168 }; |
|
169 |
|
170 #endif // PUSHASYNCOPRUNNER_H |
|
171 |
|
172 // End of file. |