18 |
18 |
19 |
19 |
20 #ifndef IA_UPDATE_CLIENT_H |
20 #ifndef IA_UPDATE_CLIENT_H |
21 #define IA_UPDATE_CLIENT_H |
21 #define IA_UPDATE_CLIENT_H |
22 |
22 |
23 #include <AknServerApp.h> |
23 |
24 #include <e32std.h> |
24 #include <e32std.h> |
25 #include <e32cmn.h> |
25 #include <e32cmn.h> |
|
26 #include <iaupdateobserver.h> |
|
27 #include <QObject> |
26 |
28 |
27 class CIAUpdateParameters; |
29 class CIAUpdateParameters; |
28 |
30 class MIAUpdateObserver; |
29 /** |
31 class XQServiceRequest; |
30 * RIAUpdateClient object provides methods to delegate update actions |
|
31 * to the server side. Updating will be targeted to the update items that |
|
32 * qualify the requirements of CIAUpdateParameters objects. In asynchronous |
|
33 * actions, observers will be informed about the completion of update action. |
|
34 * |
|
35 * Because this object is R-class, it does not provide constructor or destructor. |
|
36 * Usage: |
|
37 * - First, call Open-function. |
|
38 * - Second, use update functions to start update. |
|
39 * - Finally, user has to call Close-function to terminate object. |
|
40 * Otherwise, memory leaks may occur. |
|
41 * |
|
42 * @see CIAUpdateParameters |
|
43 * @see CIAUpdate |
|
44 * |
|
45 * @since S60 v3.2 |
|
46 */ |
|
47 NONSHARABLE_CLASS( RIAUpdateClient ) : public RAknAppServiceBase |
|
48 { |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Constructor. |
|
54 */ |
|
55 |
|
56 RIAUpdateClient(); |
|
57 |
|
58 /** |
|
59 * This function will open the update action. |
|
60 * |
|
61 * @note This has to be called before calling operation functions. |
|
62 * |
|
63 * @return System wide error code. |
|
64 * |
|
65 * @since S60 v3.2 |
|
66 */ |
|
67 TInt Open(); |
|
68 |
|
69 /** |
|
70 * Close releases the resources allocated by this class object. |
|
71 * After Close is called, this R-class object may go out of scope. |
|
72 * |
|
73 * @note If Close is called before asynchronous operation has finished, |
|
74 * the operation will continue but callback functions of the observer |
|
75 * will not be called when operation progresses. |
|
76 * |
|
77 * @since S60 v3.2 |
|
78 */ |
|
79 TInt OpenToBackroundAsync( TRequestStatus& aStatus ); |
|
80 |
|
81 TInt ConnectToApp(); |
|
82 |
|
83 void Close(); |
|
84 |
32 |
85 |
33 |
86 /** |
34 class IAUpdateClient : public QObject |
87 * @see CIAUpdate::CheckUpdates |
35 //NONSHARABLE_CLASS( IAUpdateClient ) : public QObject |
88 * |
36 { |
89 * @note The client server connection has to be opened by calling |
37 Q_OBJECT |
90 * Open function before this function can be called. |
38 public: |
91 * |
|
92 * @param aAvailableUpdates Number of the updates that were found available. |
|
93 * @param aStatus The status will be updated when the operation |
|
94 * has been completed. |
|
95 * @return Informs if the initialization of server request failed. |
|
96 * System wide error code. |
|
97 * |
|
98 * @since S60 v3.2 |
|
99 */ |
|
100 TInt CheckUpdates( const CIAUpdateParameters& aUpdateParameters, |
|
101 TInt& aAvailableUpdates, |
|
102 TRequestStatus& aStatus ); |
|
103 |
39 |
|
40 enum RequestType |
|
41 { |
|
42 /** |
|
43 * No operation is going on. |
|
44 */ |
|
45 NoOperation, |
|
46 |
|
47 /** |
|
48 * Update check has been requested. |
|
49 */ |
|
50 CheckUpdates, |
|
51 |
|
52 /** |
|
53 * Show Update operation has been requested. |
|
54 */ |
|
55 ShowUpdates, |
|
56 |
|
57 /** |
|
58 * Update query has been requested. |
|
59 */ |
|
60 UpdateQuery, |
|
61 /** |
|
62 * Bring to foreground has been requested. |
|
63 */ |
|
64 BroughtToForeground |
|
65 }; |
|
66 |
|
67 IAUpdateClient(MIAUpdateObserver& aObserver); |
|
68 |
|
69 |
|
70 ~IAUpdateClient(); |
|
71 |
|
72 int initRequest(const CIAUpdateParameters* updateParameters, const QString& message, bool toBackground); |
|
73 |
|
74 void checkUpdates(const CIAUpdateParameters& updateParameters); |
|
75 |
|
76 void showUpdates(const CIAUpdateParameters& updateParameters); |
|
77 |
|
78 void updateQuery(); |
|
79 |
|
80 void update(); |
104 |
81 |
105 /** |
82 void broughtToForeground(); |
106 * @see CIAUpdate::ShowUpdates |
83 |
107 * |
84 protected slots: |
108 * @note The client server connection has to be opened by calling |
85 |
109 * Open function before this function can be called. |
86 void requestCompleted(const QVariant& value); |
110 * |
|
111 * @param aNumberOfSuccessfullUpdates Number of the successfull updates |
|
112 * that were done during the update. |
|
113 * @param aNumberOfFailedUpdates Number of the failed updates |
|
114 * that were done during the update. |
|
115 * @param aNumberOfCancelledUpdates Number of the cancelled updates |
|
116 * during the update. |
|
117 * @param aStatus The status will be updated when the operation |
|
118 * has been completed. |
|
119 * @return Informs if the initialization of server request failed. |
|
120 * System wide error code. |
|
121 * |
|
122 * @since S60 v3.2 |
|
123 */ |
|
124 TInt ShowUpdates( const CIAUpdateParameters& aUpdateParameters, |
|
125 TInt& aNumberOfSuccessfullUpdates, |
|
126 TInt& aNumberOfFailedUpdates, |
|
127 TInt& aNumberOfCancelledUpdates, |
|
128 TRequestStatus& aStatus ); |
|
129 |
87 |
130 |
88 void requestError(int err); |
131 |
|
132 |
|
133 /** |
|
134 * @see CIAUpdate::Update |
|
135 * |
|
136 * @note The client server connection has to be opened by calling |
|
137 * Open function before this function can be called. |
|
138 * |
|
139 * @param aUpdateNow Value depending on a user's choice |
|
140 * @param aStatus The status will be updated when the operation |
|
141 * has been completed. |
|
142 * @return Informs if the initialization of server request failed. |
|
143 * System wide error code. |
|
144 * |
|
145 * @since S60 v3.2 |
|
146 */ |
|
147 TInt UpdateQuery( TBool& aUpdateNow, TRequestStatus& aStatus ); |
|
148 |
|
149 |
|
150 void BroughtToForeground(); |
|
151 |
|
152 |
|
153 /** |
|
154 * Cancels the ongoing asynchronous operation. |
|
155 * The active object that has started the update operation |
|
156 * will be informed when the requested update operation |
|
157 * has been cancelled. |
|
158 * |
|
159 * @since S60 v3.2 |
|
160 */ |
|
161 void CancelAsyncRequest(); |
|
162 |
|
163 |
|
164 public: // RAknAppServiceBase |
|
165 |
|
166 /** |
|
167 * @see RAknAppServiceBase::ServiceUid |
|
168 * |
|
169 * @since S60 v3.2 |
|
170 */ |
|
171 TUid ServiceUid() const; |
|
172 |
89 |
173 |
90 |
174 private: |
91 private: |
175 |
92 |
176 // These functions send the operation requests to the server. |
93 QString qStringFromTDesC16( const TDesC16& aDes16 ); |
177 |
94 |
178 TInt SendCheckUpdatesRequest( TInt aUpdateFunction, |
95 QString qStringFromTDesC8( const TDesC8& aDes8 ); |
179 const CIAUpdateParameters& aUpdateParameters, |
96 |
180 TInt& aCount, |
97 QString qStringFromTDesC( const TDesC& aDes ); |
181 TRequestStatus& aStatus ); |
|
182 |
98 |
183 TInt SendUpdateRequest( TInt aUpdateFunction, |
|
184 const CIAUpdateParameters& aUpdateParameters, |
|
185 TInt& aNumberOfSuccessfullUpdates, |
|
186 TInt& aNumberOfFailedUdpdates, |
|
187 TInt& aNumberOfCancelledUpdates, |
|
188 TRequestStatus& aStatus ); |
|
189 |
|
190 void ConnectNewAppToBackgroundL( TUid aAppUid ); |
|
191 |
|
192 void StartNewAppToBackgroundL( TUid aAppUid, TRequestStatus& aStatus ); |
|
193 |
|
194 void ServerName(TName& aServerName, TUid aAppServerUid, TUint aServerDifferentiator); |
|
195 |
|
196 TUint GenerateServerDifferentiatorAndName(TName& aServerName, TUid aAppServerUid); |
|
197 |
|
198 |
99 |
199 private: //data |
100 private: //data |
200 |
|
201 HBufC8* iData; |
|
202 |
101 |
203 TBool iConnected; |
102 XQServiceRequest* mServiceRequest; |
204 |
103 |
205 TInt iOwnWgId; |
104 // Informs what kind of operation is going on. |
|
105 RequestType mCurrentRequestType; |
206 |
106 |
207 TUint iDifferentiator; |
107 // Observer who will be informed about the completion of the operations. |
208 |
108 MIAUpdateObserver& mObserver; |
209 TPtr8 iPtr1; |
109 |
210 TPtr8 iPtr2; |
|
211 TPtr8 iPtr3; |
|
212 }; |
110 }; |
213 |
111 |
214 #endif // IA_UPDATE_CLIENT_H |
112 #endif // IA_UPDATE_CLIENT_H |