|
1 /* |
|
2 * Copyright (c) 2008 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: Main class for client side request handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "FeedsServerMsg.h" |
|
20 #include "Transaction.h" |
|
21 #include "FeedsEntity.h" |
|
22 #include "FeedsInterface.h" |
|
23 #include <S32Mem.h> |
|
24 #include <es_sock.h> |
|
25 #include "FeedsMap.h" |
|
26 #include "Packed.h" |
|
27 #include "PackedFeed.h" |
|
28 #include "PackedFolder.h" |
|
29 #include "Logger.h" |
|
30 |
|
31 const TInt KSettingsBufSize = 50; |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CFeedsMap::NewL |
|
35 // |
|
36 // Two-phased constructor. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CTransaction* CTransaction::NewL(MTransactionObserver& aObserver, TInt aUniqueId, |
|
40 TInt aFolderListId) |
|
41 { |
|
42 CTransaction * self = NewLC(aObserver,aUniqueId,aFolderListId); |
|
43 CleanupStack::Pop(self); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CTransaction::NewLC |
|
49 // |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CTransaction* CTransaction::NewLC(MTransactionObserver& aObserver, TInt aUniqueId, |
|
54 TInt aFolderListId) |
|
55 { |
|
56 CTransaction * self = new (ELeave) CTransaction(aObserver,aUniqueId,aFolderListId); |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CTransaction::CTransaction |
|
64 // |
|
65 // C++ default constructor can NOT contain any code, that |
|
66 // might leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CTransaction::CTransaction(MTransactionObserver& aObserver,TInt aUniqueId,TInt aFolderListId): |
|
70 CActive(EPriorityStandard), iObserver(aObserver), iRequestBuffPtr(NULL, 0), |
|
71 iFolderListId(aFolderListId),iNotifyOnCancel(ETrue),iId(aUniqueId),iServerResponseTypePkg(iServerResponseType), |
|
72 iResponsePtr(NULL, 0),iResponseEntryIdPkg(iResponseEntryId) |
|
73 { |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CTransaction::ConstructL |
|
78 // |
|
79 // Symbian 2nd phase constructor can leave. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CTransaction::ConstructL() |
|
83 { |
|
84 CActiveScheduler::Add (this); |
|
85 |
|
86 iRequestBuff = CBufFlat::NewL (128); |
|
87 iSettingsResponseBuffer = CBufFlat::NewL (128); |
|
88 iAutoDelete = CIdle::NewL (CActive::EPriorityIdle); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CTransaction::~CTransaction |
|
93 // |
|
94 // Deconstructor. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CTransaction::~CTransaction() |
|
98 { |
|
99 delete iFeedsEntity; |
|
100 delete iResponseBuffer; |
|
101 delete iPacked; |
|
102 |
|
103 iNotifyOnCancel = EFalse; |
|
104 Cancel (); |
|
105 |
|
106 delete iRequestBuff; |
|
107 delete iAutoDelete; |
|
108 delete iFeedsEntity; |
|
109 delete iSettingsResponseBuffer; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CTransaction::DoCancel |
|
114 // |
|
115 // Implements cancellation of an outstanding request. |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CTransaction::DoCancel() |
|
119 { |
|
120 // iNotifyOnCancel is set to false in the destructor. |
|
121 // A virtual method, RequestCompletedL(), |
|
122 // that is implemented in a subclass can't be called through the destructor of the parent class. |
|
123 if ( iNotifyOnCancel) |
|
124 { |
|
125 TRAPD( err, RequestCompletedL(KErrCancel) ) |
|
126 ; |
|
127 if ( err != KErrNone) |
|
128 { |
|
129 } |
|
130 } |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CTransaction::RunL |
|
135 // |
|
136 // Handles an active object's request completion event. |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CTransaction::RunL() |
|
140 { |
|
141 RequestCompletedL (iStatus.Int ()); |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CTransaction::RunError |
|
146 // |
|
147 // Handles an active object's errors. |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 TInt CTransaction::RunError(TInt aError) |
|
151 { |
|
152 TRAPD( err, RequestCompletedL(aError) ); |
|
153 return err; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CTransaction::Start |
|
158 // |
|
159 // Starts the handler. |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CTransaction::Start() |
|
163 { |
|
164 SetActive (); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CTransaction::AutoDelete |
|
169 // |
|
170 // Starts an CIdle to delete the instance after the callstack has unrolled. |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 EXPORT_C void CTransaction::AutoDelete() |
|
174 { |
|
175 iAutoDelete->Start (TCallBack (DelayedDelete, this)); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CTransaction::DelayedDelete |
|
180 // |
|
181 // Deletes the instance after the callstack has unrolled. |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 TInt CTransaction::DelayedDelete(TAny* aPtr) |
|
185 { |
|
186 CTransaction* self = static_cast<CTransaction*>(aPtr); |
|
187 |
|
188 delete self; |
|
189 return EFalse; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CTransaction::Type |
|
194 // |
|
195 // Returns the handler's type. |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C CTransaction::TTransactionType CTransaction::Type() |
|
199 { |
|
200 return iType; |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CTransaction::DebugPrintTables |
|
205 // |
|
206 // Print tables of database. |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void CTransaction::DebugPrintTables() |
|
210 { |
|
211 // Set the request type. |
|
212 iType = EPrintDBTables; |
|
213 |
|
214 iObserver.SendAsyncCommand(EFeedsServerPrintDBTables, |
|
215 TIpcArgs(), iStatus); |
|
216 |
|
217 Start(); |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CTransaction::DisconnectManualUpdateConnection |
|
222 // |
|
223 // Disconnect connection provided by client for manual update. |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CTransaction::DisconnectManualUpdateConnection() |
|
227 { |
|
228 // Set the request type. |
|
229 iType = EDisconnectManualUpdateConnection; |
|
230 |
|
231 iObserver.SendAsyncCommand (EFeedsServerDisconnectManualUpdateConnection, |
|
232 TIpcArgs (), iStatus); |
|
233 |
|
234 Start (); |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CTransaction::ChangeServerSettingsL |
|
239 // |
|
240 // Handles the upating of a the feeds server settings. |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void CTransaction::ChangeServerSettingsL(const TFeedsServerSetting& aNewSetting) |
|
244 { |
|
245 // Set the request type. |
|
246 iType = EChangeSettings; |
|
247 |
|
248 RBufWriteStream stream; |
|
249 |
|
250 // Package the request. |
|
251 stream.Open(*iRequestBuff); |
|
252 CleanupClosePushL(stream); |
|
253 |
|
254 // Write out the settings. |
|
255 // NOTE: Be sure to adjust KSettingsBufSize if more settings are added. |
|
256 // TODO: Also write out a version number -- do this with all R-Class messages. |
|
257 stream.WriteInt32L( iFolderListId ); |
|
258 stream.WriteUint8L(aNewSetting.iAutoUpdate); |
|
259 stream.WriteUint16L(aNewSetting.iAutoUpdateFreq); |
|
260 stream.WriteUint32L(aNewSetting.iAutoUpdateAP); |
|
261 stream.WriteUint8L(aNewSetting.iAutoUpdateWhileRoaming); |
|
262 |
|
263 iRequestBuff->Compress(); |
|
264 CleanupStack::PopAndDestroy(/*stream*/); |
|
265 |
|
266 // Make the request. |
|
267 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
268 |
|
269 iObserver.SendAsyncCommand (EFeedsServerChangeSettings, |
|
270 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
271 |
|
272 Start (); |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CTransaction::WatchSettingsL |
|
277 // |
|
278 // Sets up a notifier to execute when the settings change. |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CTransaction::WatchSettingsL() |
|
282 { |
|
283 RBufWriteStream stream; |
|
284 |
|
285 // Set the request type. |
|
286 iType = EWatchForSettingChanges; |
|
287 |
|
288 // Package the request. |
|
289 stream.Open (*iRequestBuff); |
|
290 CleanupClosePushL (stream); |
|
291 |
|
292 // Write out the folder list id. |
|
293 stream.WriteInt32L (iFolderListId); |
|
294 |
|
295 iRequestBuff->Compress (); |
|
296 CleanupStack::PopAndDestroy (/*stream*/); |
|
297 |
|
298 // Make the request. |
|
299 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
300 |
|
301 iObserver.SendAsyncCommand (EFeedsServerWatchSettings, |
|
302 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
303 |
|
304 Start (); |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // CTransaction::FetchServerSettingsL |
|
309 // |
|
310 // Handles the fetching of the feeds server settings. |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 void CTransaction::FetchServerSettingsL() |
|
314 { |
|
315 RBufWriteStream stream; |
|
316 |
|
317 // Set the request type. |
|
318 iType = EFetchSettings; |
|
319 |
|
320 // Package the request. |
|
321 stream.Open (*iRequestBuff); |
|
322 CleanupClosePushL (stream); |
|
323 |
|
324 stream.WriteInt32L ( iFolderListId); |
|
325 |
|
326 iRequestBuff->Compress (); |
|
327 CleanupStack::PopAndDestroy (/*stream*/); |
|
328 |
|
329 iRequestBuffPtr.Set ( iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
330 |
|
331 iSettingsResponseBuffer->ExpandL(0, KSettingsBufSize); |
|
332 iResponsePtr.Set((TUint8 *) iSettingsResponseBuffer->Ptr(0).Ptr(), KSettingsBufSize, |
|
333 KSettingsBufSize); |
|
334 |
|
335 // Make the request. |
|
336 iObserver.SendAsyncCommand (EFeedsServerGetSettings, TIpcArgs ( |
|
337 &iRequestBuffPtr, &iResponsePtr), iStatus); |
|
338 |
|
339 Start (); |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CTransaction::FetchServerSettingsSyncL |
|
344 // |
|
345 // Handles the fetching of the feeds server settings synchronously. |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 void CTransaction::FetchServerSettingsSyncL() |
|
349 { |
|
350 TInt status(0); |
|
351 CBufFlat* requestBuff = NULL; |
|
352 TPtr8 requestBuffPtr(NULL, 0); |
|
353 CBufFlat* responseBuff = NULL; |
|
354 TPtr8 responsePtr(NULL, 0); |
|
355 RBufWriteStream stream; |
|
356 |
|
357 requestBuff = CBufFlat::NewL(128); |
|
358 CleanupStack::PushL(requestBuff); |
|
359 |
|
360 // Package the request. |
|
361 stream.Open(*requestBuff); |
|
362 CleanupClosePushL(stream); |
|
363 |
|
364 stream.WriteInt32L( iFolderListId ); |
|
365 |
|
366 requestBuff->Compress(); |
|
367 requestBuffPtr.Set( requestBuff->Ptr(0) ); |
|
368 CleanupStack::PopAndDestroy(/*stream*/); |
|
369 |
|
370 responseBuff = CBufFlat::NewL(128); |
|
371 CleanupStack::PushL(responseBuff); |
|
372 |
|
373 // Make the request. |
|
374 responseBuff->ExpandL(0, KSettingsBufSize); |
|
375 responsePtr.Set((TUint8 *) responseBuff->Ptr(0).Ptr(), KSettingsBufSize, |
|
376 KSettingsBufSize); |
|
377 |
|
378 status = iFeedInterface->SendReceiveSync(EFeedsServerGetSettings, TIpcArgs(&requestBuffPtr, &responsePtr)); |
|
379 |
|
380 // Extract the settings if everything went ok. |
|
381 if (status == KErrNone) |
|
382 { |
|
383 iSetting = SettingsFromResponseBuffPtrL(*responseBuff); |
|
384 } |
|
385 |
|
386 CleanupStack::PopAndDestroy(responseBuff); |
|
387 CleanupStack::PopAndDestroy(requestBuff); |
|
388 } |
|
389 |
|
390 // ----------------------------------------------------------------------------- |
|
391 // CTransaction::Settings |
|
392 // |
|
393 // return pointer to setting map,Caller takes ownership |
|
394 // ----------------------------------------------------------------------------- |
|
395 // |
|
396 EXPORT_C TFeedsServerSetting CTransaction::Settings() |
|
397 { |
|
398 return iSetting; |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CTransaction::CancelAllL |
|
403 // |
|
404 // Request the FeedsServer to cancel all activities that can be cancelled. |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 void CTransaction::CancelAllL() |
|
408 { |
|
409 // Set the request type. |
|
410 iType = ECancelAll; |
|
411 |
|
412 // Make the request. |
|
413 iObserver.SendAsyncCommand (EFeedsServerCancelAll, TIpcArgs (), iStatus); |
|
414 |
|
415 Start (); |
|
416 } |
|
417 |
|
418 // ----------------------------------------------------------------------------- |
|
419 // CTransaction::SettingsFromResponseBufferL |
|
420 // |
|
421 // Reads server response buffer and intialises iSetting; |
|
422 // ----------------------------------------------------------------------------- |
|
423 // |
|
424 void CTransaction::SettingsFromResponseBufferL() |
|
425 { |
|
426 RBufReadStream stream; |
|
427 |
|
428 stream.Open(*iSettingsResponseBuffer, 0); |
|
429 CleanupClosePushL(stream); |
|
430 |
|
431 // Read the settings. |
|
432 // NOTE: Be sure to adjust KSettingsBufSize if more settings are added. |
|
433 iSetting.iAutoUpdate = stream.ReadUint8L(); |
|
434 iSetting.iAutoUpdateFreq = stream.ReadUint16L(); |
|
435 iSetting.iAutoUpdateAP = stream.ReadUint32L(); |
|
436 iSetting.iAutoUpdateWhileRoaming = stream.ReadUint8L(); |
|
437 |
|
438 CleanupStack::PopAndDestroy(/*stream*/); |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CTransaction::RequestCompletedL |
|
443 // |
|
444 // Called to handle the response. |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 void CTransaction::RequestCompletedL(TInt aStatusCode) |
|
448 { |
|
449 // Notify the observer if an error occurred. |
|
450 this->iTranStatus = aStatusCode; |
|
451 if ( aStatusCode != KErrNone) |
|
452 { |
|
453 iObserver.RequestHandlerCompleted (*this, aStatusCode); |
|
454 return; |
|
455 } |
|
456 |
|
457 switch (iType) |
|
458 { |
|
459 case EFetchSettings: |
|
460 { |
|
461 TRAPD(err,SettingsFromResponseBufferL()); |
|
462 iObserver.RequestHandlerCompleted (*this, err); |
|
463 return; |
|
464 } |
|
465 case EFetchFeed: |
|
466 { |
|
467 if ( iServerResponseType != EFeedsServerConnectionNeeded &&iServerResponseType != EFeedsServerManualUpdateDone) |
|
468 { |
|
469 // Append the response chunk to the packed folder. |
|
470 if ( iServerResponseType == EFeedsServerTokensPayload) |
|
471 { |
|
472 iPacked->AppendTokenChunkL (iResponsePtr); |
|
473 } |
|
474 else |
|
475 { |
|
476 iPacked->AppendStringTableChunkL (iResponsePtr); |
|
477 } |
|
478 |
|
479 // If there is more data coming request the next chunk. |
|
480 if ( iServerResponseType != EFeedsServerPayloadDone) |
|
481 { |
|
482 // Reset the response. |
|
483 iResponsePtr.Zero (); |
|
484 |
|
485 // Clear the request buffer too. |
|
486 iRequestBuffPtr.Set (NULL, 0); |
|
487 |
|
488 // Get the next chunk asynchronously. |
|
489 iObserver.SendAsyncCommand (EFeedsServerGetFeed, TIpcArgs ( |
|
490 &iRequestBuffPtr, &iServerResponseTypePkg, |
|
491 &iResponsePtr), iStatus); |
|
492 |
|
493 Start (); |
|
494 } |
|
495 |
|
496 // Otherwise process the completed folder. |
|
497 else |
|
498 { |
|
499 // Create the new folder and notify the observer. |
|
500 iFeedsEntity = CFeedsEntity::NewL ((CPackedFeed*)iPacked,iFeedInterface); |
|
501 delete iPacked; |
|
502 iPacked = NULL; |
|
503 iObserver.RequestHandlerCompleted (*this, KErrNone); |
|
504 } |
|
505 } |
|
506 else |
|
507 if ( iServerResponseType == EFeedsServerConnectionNeeded) |
|
508 { |
|
509 // Ask client for connection |
|
510 TInt connectionPtr; |
|
511 TInt sockSvrHandle; |
|
512 TBool newConn; |
|
513 TApBearerType bearerType; |
|
514 TRAPD( err, iObserver.NetworkConnectionNeededL( &connectionPtr, sockSvrHandle, newConn, bearerType ) ); |
|
515 |
|
516 if ( err == KErrNone) |
|
517 { |
|
518 // Prepare RConnection name |
|
519 RConnection* connPtr= REINTERPRET_CAST( RConnection*, connectionPtr ); |
|
520 TName name; |
|
521 connPtr->Name ( name); |
|
522 |
|
523 // Package the request. |
|
524 RBufWriteStream stream; |
|
525 // |
|
526 stream.Open (*iRequestBuff); |
|
527 CleanupClosePushL (stream); |
|
528 // |
|
529 stream.WriteUint16L ( name.Length ()); |
|
530 stream.WriteL ( name); |
|
531 // |
|
532 stream.WriteUint16L ( bearerType); |
|
533 // |
|
534 iRequestBuff->Compress (); |
|
535 CleanupStack::PopAndDestroy (/*stream*/); |
|
536 // Make the request. |
|
537 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
538 |
|
539 // Reset the response. |
|
540 iResponsePtr.Zero (); |
|
541 |
|
542 // Send the request |
|
543 iObserver.SendAsyncCommand ( |
|
544 EFeedsServerSetConnection, |
|
545 TIpcArgs (&iRequestBuffPtr, |
|
546 &iServerResponseTypePkg, &iResponsePtr), |
|
547 iStatus); |
|
548 // |
|
549 Start (); |
|
550 } |
|
551 else |
|
552 { |
|
553 iObserver.CancelAllCommandsL (); |
|
554 User::Leave ( err); |
|
555 } |
|
556 } |
|
557 // EFeedsServerManualUpdateDone |
|
558 else |
|
559 { |
|
560 iObserver.RequestHandlerCompleted (*this, KErrNone); |
|
561 } |
|
562 } |
|
563 break; |
|
564 case EFetchRootFolderItem: |
|
565 { |
|
566 // Append the response chunk to the packed folder. |
|
567 if ( iServerResponseType == EFeedsServerTokensPayload) |
|
568 { |
|
569 iPacked->AppendTokenChunkL (iResponsePtr); |
|
570 } |
|
571 else |
|
572 { |
|
573 iPacked->AppendStringTableChunkL (iResponsePtr); |
|
574 } |
|
575 |
|
576 // If there is more data coming request the next chunk. |
|
577 if ( iServerResponseType != EFeedsServerPayloadDone) |
|
578 { |
|
579 // Reset the response. |
|
580 iResponsePtr.Zero (); |
|
581 |
|
582 // Clear the request buffer too. |
|
583 iRequestBuffPtr.Set (NULL, 0); |
|
584 |
|
585 // Get the next chunk asynchronously. |
|
586 iObserver.SendAsyncCommand (EFeedsServerGetRootFolder, |
|
587 TIpcArgs (&iRequestBuffPtr, &iServerResponseTypePkg, |
|
588 &iResponsePtr), iStatus); |
|
589 |
|
590 Start (); |
|
591 } |
|
592 |
|
593 // Otherwise process the completed folder. |
|
594 else |
|
595 { |
|
596 // Create the new folder and notify the observer. |
|
597 iFeedsEntity = CFeedsEntity::NewL ((CPackedFolder*)iPacked,iFeedInterface); |
|
598 delete iPacked; |
|
599 iPacked = NULL; |
|
600 |
|
601 iObserver.RequestHandlerCompleted (*this, KErrNone); |
|
602 } |
|
603 |
|
604 break; |
|
605 } |
|
606 |
|
607 case EUpdateFolderItem: |
|
608 { |
|
609 if ( iServerResponseType == EFeedsServerConnectionNeeded) |
|
610 { |
|
611 // Ask client for connection |
|
612 TInt connectionPtr; |
|
613 TInt sockSvrHandle; |
|
614 TBool newConn; |
|
615 TApBearerType bearerType; |
|
616 TRAPD( err, iObserver.NetworkConnectionNeededL( &connectionPtr, sockSvrHandle, newConn, bearerType ) ); |
|
617 |
|
618 if ( err == KErrNone) |
|
619 { |
|
620 // Prepare RConnection name |
|
621 RConnection* connPtr= REINTERPRET_CAST( RConnection*, connectionPtr ); |
|
622 TName name; |
|
623 connPtr->Name ( name); |
|
624 |
|
625 // Package the request. |
|
626 RBufWriteStream stream; |
|
627 // |
|
628 stream.Open (*iRequestBuff); |
|
629 CleanupClosePushL (stream); |
|
630 // |
|
631 stream.WriteUint16L ( name.Length ()); |
|
632 stream.WriteL ( name); |
|
633 // |
|
634 stream.WriteUint16L ( bearerType); |
|
635 // |
|
636 iRequestBuff->Compress (); |
|
637 CleanupStack::PopAndDestroy (/*stream*/); |
|
638 // Make the request. |
|
639 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
640 |
|
641 // Reset the response. |
|
642 iResponsePtr.Zero (); |
|
643 |
|
644 // Send the request |
|
645 iObserver.SendAsyncCommand (EFeedsServerSetConnection, |
|
646 TIpcArgs (&iRequestBuffPtr, |
|
647 &iServerResponseTypePkg, &iResponsePtr), |
|
648 iStatus); |
|
649 // |
|
650 Start (); |
|
651 } |
|
652 else |
|
653 { |
|
654 iObserver.CancelAllCommandsL (); |
|
655 User::Leave ( err); |
|
656 } |
|
657 } |
|
658 // EFeedsServerManualUpdateDone |
|
659 else |
|
660 { |
|
661 iObserver.RequestHandlerCompleted (*this, KErrNone); |
|
662 } |
|
663 |
|
664 break; |
|
665 } |
|
666 |
|
667 case EImportOPML: |
|
668 { |
|
669 iObserver.RequestHandlerCompleted (*this, KErrNone); |
|
670 break; |
|
671 } |
|
672 |
|
673 case EExportOPML: |
|
674 { |
|
675 iObserver.RequestHandlerCompleted (*this, KErrNone); |
|
676 break; |
|
677 } |
|
678 |
|
679 default: |
|
680 iObserver.RequestHandlerCompleted (*this, KErrNone); |
|
681 break; |
|
682 } |
|
683 |
|
684 } |
|
685 |
|
686 // ----------------------------------------------------------------------------- |
|
687 // CTransaction::GetId |
|
688 // |
|
689 // Returns the id of the id of the transaction. |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 EXPORT_C TInt CTransaction::GetId() |
|
693 { |
|
694 return iId; |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // CTransaction::GetStatusCode |
|
699 // |
|
700 // Returns the status code of the transaction. |
|
701 // ----------------------------------------------------------------------------- |
|
702 // |
|
703 EXPORT_C TInt CTransaction::GetStatusCode() |
|
704 { |
|
705 return iTranStatus; |
|
706 } |
|
707 |
|
708 // ----------------------------------------------------------------------------- |
|
709 // CTransaction::Cancel |
|
710 // |
|
711 // Cancels the transaction. |
|
712 // ----------------------------------------------------------------------------- |
|
713 // |
|
714 EXPORT_C void CTransaction::CancelRequest() |
|
715 { |
|
716 //TODO |
|
717 } |
|
718 |
|
719 // ----------------------------------------------------------------------------- |
|
720 // CTransaction::FetchFeedL |
|
721 // |
|
722 // Fetch the given feed. |
|
723 // ----------------------------------------------------------------------------- |
|
724 // |
|
725 void CTransaction::FetchFeedL(const TDesC& aUrl, TBool aForceUpdate, |
|
726 TBool aNoCache) |
|
727 { |
|
728 FetchFeedHelperL (aUrl, 0, aForceUpdate, aNoCache); |
|
729 } |
|
730 |
|
731 // ----------------------------------------------------------------------------- |
|
732 // CTransaction::FetchFeedL |
|
733 // |
|
734 // Fetch the given feed. |
|
735 // ----------------------------------------------------------------------------- |
|
736 // |
|
737 void CTransaction::FetchFeedL(TInt aFeedId, TBool aForceUpdate, |
|
738 TBool aNoCache) |
|
739 { |
|
740 FetchFeedHelperL (KNullDesC, aFeedId, aForceUpdate, aNoCache); |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CTransaction::FetchFeedHelperL |
|
745 // |
|
746 // Fetch the given feed. |
|
747 // ----------------------------------------------------------------------------- |
|
748 // |
|
749 void CTransaction::FetchFeedHelperL(const TDesC& aUrl, TInt aFeedId, |
|
750 TBool aForceUpdate, TBool aNoCache) |
|
751 { |
|
752 RBufWriteStream stream; |
|
753 |
|
754 // Set the request type. |
|
755 iType = EFetchFeed; |
|
756 |
|
757 // Create the buffer to hold the response. |
|
758 iResponseBuffer = HBufC8::NewL (KMaxFeedsServerMessage); |
|
759 iResponsePtr.Set ((TUint8 *) iResponseBuffer->Ptr(), KMaxFeedsServerMessage, KMaxFeedsServerMessage); |
|
760 |
|
761 // Do some other init. |
|
762 iServerResponseType = EFeedsServerInitPayload; |
|
763 iPacked = CPackedFeed::NewL (); |
|
764 |
|
765 // Package the request. |
|
766 stream.Open (*iRequestBuff); |
|
767 CleanupClosePushL (stream); |
|
768 |
|
769 // If the url was provided then write it out. |
|
770 if ( aUrl.Length ()> 0) |
|
771 { |
|
772 // What follows is a url. |
|
773 stream.WriteUint8L (ETrue); |
|
774 |
|
775 stream.WriteUint16L (aUrl.Length ()); |
|
776 stream.WriteL (aUrl); |
|
777 |
|
778 stream.WriteInt32L ( iFolderListId); |
|
779 } |
|
780 |
|
781 // Otherwise write out the feed's id. |
|
782 else |
|
783 { |
|
784 // What follows is a feed id. |
|
785 stream.WriteUint8L (EFalse); |
|
786 |
|
787 stream.WriteUint16L (aFeedId); |
|
788 } |
|
789 |
|
790 // Write the load flags. |
|
791 stream.WriteUint8L (aForceUpdate); |
|
792 stream.WriteUint8L (aNoCache); |
|
793 |
|
794 iRequestBuff->Compress (); |
|
795 CleanupStack::PopAndDestroy (/*stream*/); |
|
796 |
|
797 // Wrap the request buffer. |
|
798 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
799 |
|
800 // Get the first chunk asynchronously. |
|
801 iObserver.SendAsyncCommand (EFeedsServerGetFeed, TIpcArgs ( |
|
802 &iRequestBuffPtr, &iServerResponseTypePkg, &iResponsePtr), iStatus); |
|
803 |
|
804 Start (); |
|
805 } |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CTransaction::UpdateItemStatusL |
|
809 // |
|
810 // Handles the upating of a the feed's item-status. |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 void CTransaction::UpdateItemStatusL(TInt aFeedId, |
|
814 const RArray<TInt>& aItemIds, const RArray<TFeedItemStatus>& aItemStatus, |
|
815 TInt aUnreadCount) |
|
816 { |
|
817 RBufWriteStream stream; |
|
818 |
|
819 // Set the request type. |
|
820 iType = EUpdateItemStatus; |
|
821 |
|
822 // Package the request. |
|
823 stream.Open (*iRequestBuff); |
|
824 CleanupClosePushL (stream); |
|
825 |
|
826 stream.WriteUint16L (aFeedId); |
|
827 |
|
828 // Write the entries. |
|
829 stream.WriteUint16L (aItemStatus.Count ()); |
|
830 for (TInt i = 0; i < aItemStatus.Count (); i++) |
|
831 { |
|
832 stream.WriteUint16L (aItemIds[i]); |
|
833 stream.WriteUint16L (aItemStatus[i]); |
|
834 } |
|
835 |
|
836 stream.WriteUint16L (aUnreadCount); |
|
837 |
|
838 iRequestBuff->Compress (); |
|
839 CleanupStack::PopAndDestroy (); |
|
840 |
|
841 // Make the request. |
|
842 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
843 |
|
844 iObserver.SendAsyncCommand (EFeedsServerChangeFeedItemStatus, |
|
845 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
846 |
|
847 Start (); |
|
848 } |
|
849 |
|
850 // ----------------------------------------------------------------------------- |
|
851 // CTransaction::FetchFolderItemL |
|
852 // |
|
853 // Fetch the root folder associated with the given folder list id. |
|
854 // ----------------------------------------------------------------------------- |
|
855 // |
|
856 void CTransaction::FetchFolderItemL(TBool aItemTitleNeed) |
|
857 { |
|
858 FEED_LOG(_L("Feeds"), _L("Feeds_Api.log"), |
|
859 EFileLoggingModeAppend, _L("CTransaction::FetchFolderItemL")); |
|
860 |
|
861 RBufWriteStream stream; |
|
862 |
|
863 // Set the request type. |
|
864 iType = EFetchRootFolderItem; |
|
865 |
|
866 // Create the buffer to hold the response. |
|
867 iResponseBuffer = HBufC8::NewL (KMaxFeedsServerMessage); |
|
868 iResponsePtr.Set ((TUint8 *) iResponseBuffer->Ptr(), KMaxFeedsServerMessage, KMaxFeedsServerMessage); |
|
869 |
|
870 // Do some other init. |
|
871 iServerResponseType = EFeedsServerInitPayload; |
|
872 iPacked = CPackedFolder::NewL (); |
|
873 |
|
874 // Package the request. |
|
875 stream.Open (*iRequestBuff); |
|
876 CleanupClosePushL (stream); |
|
877 |
|
878 // Write the folder list id. |
|
879 stream.WriteInt32L (iFolderListId); |
|
880 stream.WriteUint8L ( aItemTitleNeed); |
|
881 |
|
882 iRequestBuff->Compress (); |
|
883 CleanupStack::PopAndDestroy (/*stream*/); |
|
884 |
|
885 // Wrap the request buffer. |
|
886 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
887 |
|
888 // Get the first chunk asynchronously. |
|
889 iObserver.SendAsyncCommand (EFeedsServerGetRootFolder, TIpcArgs ( |
|
890 &iRequestBuffPtr, &iServerResponseTypePkg, &iResponsePtr), iStatus); |
|
891 |
|
892 Start (); |
|
893 FEED_LOG(_L("Feeds"), _L("Feeds_Api.log"), |
|
894 EFileLoggingModeAppend, _L("//CTransaction::FetchFolderItemL")); |
|
895 |
|
896 } |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // CTransaction::AddFolderItemL |
|
900 // |
|
901 // Add a new folder item. |
|
902 // ----------------------------------------------------------------------------- |
|
903 // |
|
904 void CTransaction::AddFolderItemL(const TDesC& aTitle,const TDesC& aUrl, TBool aIsFolder, const CFeedsEntity& aParent, TInt aFreq) |
|
905 { |
|
906 RBufWriteStream stream; |
|
907 |
|
908 // Set the request type. |
|
909 iType = EAddFolderItem; |
|
910 |
|
911 // Package the request. |
|
912 stream.Open (*iRequestBuff); |
|
913 CleanupClosePushL (stream); |
|
914 |
|
915 stream.WriteInt32L (iFolderListId); |
|
916 stream.WriteUint16L (aParent.GetId ()); |
|
917 stream.WriteUint16L (aIsFolder); |
|
918 |
|
919 stream.WriteUint16L (aTitle.Length ()); |
|
920 stream.WriteL (aTitle); |
|
921 |
|
922 stream.WriteUint16L (aUrl.Length ()); |
|
923 stream.WriteL (aUrl); |
|
924 stream.WriteUint32L (aFreq); |
|
925 |
|
926 iRequestBuff->Compress (); |
|
927 CleanupStack::PopAndDestroy (/*stream*/); |
|
928 |
|
929 // Make the request. |
|
930 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
931 |
|
932 iObserver.SendAsyncCommand (EFeedsServerAddFolderItem, TIpcArgs ( |
|
933 &iRequestBuffPtr, &iResponseEntryIdPkg), iStatus); |
|
934 |
|
935 Start (); |
|
936 } |
|
937 |
|
938 // ----------------------------------------------------------------------------- |
|
939 // CTransaction::ChangeFolderItemL |
|
940 // |
|
941 // Change a new folder item. |
|
942 // ----------------------------------------------------------------------------- |
|
943 // |
|
944 void CTransaction::ChangeFolderItemL(const CFeedsEntity& aFeedsEntity, |
|
945 const TDesC& aTitle, const TDesC& aUrl, TInt aFreq) |
|
946 { |
|
947 RBufWriteStream stream; |
|
948 |
|
949 // Set the request type. |
|
950 iType = EChangeFolderItem; |
|
951 |
|
952 // Package the request. |
|
953 stream.Open (*iRequestBuff); |
|
954 CleanupClosePushL (stream); |
|
955 |
|
956 stream.WriteInt32L (iFolderListId); |
|
957 stream.WriteUint16L (aFeedsEntity.GetId ()); |
|
958 |
|
959 stream.WriteUint16L (aTitle.Length ()); |
|
960 stream.WriteL (aTitle); |
|
961 |
|
962 stream.WriteUint16L (aUrl.Length ()); |
|
963 stream.WriteL (aUrl); |
|
964 stream.WriteUint32L (aFreq); |
|
965 |
|
966 iRequestBuff->Compress (); |
|
967 CleanupStack::PopAndDestroy (/*stream*/); |
|
968 |
|
969 // Make the request. |
|
970 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
971 |
|
972 iObserver.SendAsyncCommand (EFeedsServerChangeFolderItem, |
|
973 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
974 |
|
975 Start (); |
|
976 } |
|
977 |
|
978 // ----------------------------------------------------------------------------- |
|
979 // CTransaction::DeleteFolderItemL |
|
980 // |
|
981 // Delete one or more folder items. |
|
982 // ----------------------------------------------------------------------------- |
|
983 // |
|
984 void CTransaction::DeleteFolderItemL( |
|
985 const RPointerArray<const CFeedsEntity>& aFeedsEntities) |
|
986 { |
|
987 RBufWriteStream stream; |
|
988 |
|
989 // Set the request type. |
|
990 iType = EDeleteFolderItem; |
|
991 |
|
992 // Package the request. |
|
993 stream.Open (*iRequestBuff); |
|
994 CleanupClosePushL (stream); |
|
995 |
|
996 stream.WriteInt32L (iFolderListId); |
|
997 |
|
998 // Write the entries. |
|
999 stream.WriteUint16L (aFeedsEntities.Count ()); |
|
1000 for (TInt i = 0; i < aFeedsEntities.Count (); i++) |
|
1001 { |
|
1002 stream.WriteUint16L (aFeedsEntities[i]->GetId ()); |
|
1003 } |
|
1004 |
|
1005 iRequestBuff->Compress (); |
|
1006 CleanupStack::PopAndDestroy (/*stream*/); |
|
1007 |
|
1008 // Make the request. |
|
1009 iRequestBuffPtr.Set(iRequestBuff->Ptr(0).Ptr(), iRequestBuff->Size()); |
|
1010 |
|
1011 iObserver.SendAsyncCommand(EFeedsServerDeleteFolderItems, |
|
1012 TIpcArgs(&iRequestBuffPtr), iStatus); |
|
1013 |
|
1014 Start(); |
|
1015 } |
|
1016 |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // CTransaction::ExportFolderItemL |
|
1019 // |
|
1020 // Export one or more folder items. |
|
1021 // ----------------------------------------------------------------------------- |
|
1022 // |
|
1023 void CTransaction::ExportFolderItemL( |
|
1024 const RPointerArray<const CFeedsEntity>& aFeedsEntities, |
|
1025 const TDesC &aExportFileName) |
|
1026 { |
|
1027 |
|
1028 if ( aExportFileName.Length ()<=0) |
|
1029 { |
|
1030 User::Leave (KErrArgument); |
|
1031 } |
|
1032 |
|
1033 if ( aFeedsEntities.Count ()<=0) |
|
1034 { |
|
1035 User::Leave (KErrArgument); |
|
1036 } |
|
1037 |
|
1038 // Set the request type. |
|
1039 iType = EExportOPML; |
|
1040 |
|
1041 // Package the request. |
|
1042 RBufWriteStream stream; |
|
1043 stream.Open (*iRequestBuff); |
|
1044 CleanupClosePushL (stream); |
|
1045 |
|
1046 stream.WriteUint16L (aExportFileName.Length ()); |
|
1047 stream.WriteL (aExportFileName); |
|
1048 |
|
1049 stream.WriteInt32L (iFolderListId); |
|
1050 |
|
1051 // Write the entries. |
|
1052 stream.WriteUint16L (aFeedsEntities.Count ()); |
|
1053 for (TInt i = 0; i < aFeedsEntities.Count (); i++) |
|
1054 { |
|
1055 stream.WriteUint16L (aFeedsEntities[i]->GetId ()); |
|
1056 } |
|
1057 |
|
1058 iRequestBuff->Compress (); |
|
1059 CleanupStack::PopAndDestroy (/*stream*/); |
|
1060 |
|
1061 // Make the request. |
|
1062 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
1063 |
|
1064 iObserver.SendAsyncCommand (EFeedsServerExportOPML, |
|
1065 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
1066 |
|
1067 Start (); |
|
1068 } |
|
1069 |
|
1070 // ----------------------------------------------------------------------------- |
|
1071 // CTransaction::MoveFolderItemsToL |
|
1072 // |
|
1073 // Move one or more folder items to a different parent folder. |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // |
|
1076 void CTransaction::MoveFolderItemsToL( |
|
1077 const RPointerArray<const CFeedsEntity>& aFeedsEntities, |
|
1078 const CFeedsEntity& aParent) |
|
1079 { |
|
1080 RBufWriteStream stream; |
|
1081 |
|
1082 // Set the request type. |
|
1083 iType = EMoveFolderItemTo; |
|
1084 |
|
1085 // Package the request. |
|
1086 stream.Open (*iRequestBuff); |
|
1087 CleanupClosePushL (stream); |
|
1088 |
|
1089 stream.WriteInt32L (iFolderListId); |
|
1090 |
|
1091 // Write the entries. |
|
1092 stream.WriteUint16L (aParent.GetId ()); |
|
1093 |
|
1094 stream.WriteUint16L (aFeedsEntities.Count ()); |
|
1095 for (TInt i = 0; i < aFeedsEntities.Count (); i++) |
|
1096 { |
|
1097 stream.WriteUint16L (aFeedsEntities[i]->GetId ()); |
|
1098 } |
|
1099 |
|
1100 iRequestBuff->Compress (); |
|
1101 CleanupStack::PopAndDestroy (/*stream*/); |
|
1102 |
|
1103 // Make the request. |
|
1104 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
1105 |
|
1106 iObserver.SendAsyncCommand (EFeedsServerMoveFolderItemsTo, |
|
1107 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
1108 |
|
1109 Start (); |
|
1110 } |
|
1111 |
|
1112 // ----------------------------------------------------------------------------- |
|
1113 // CTransaction::MoveFolderItemsL |
|
1114 // |
|
1115 // Move one or more folder items to a new position. |
|
1116 // ----------------------------------------------------------------------------- |
|
1117 // |
|
1118 void CTransaction::MoveFolderItemsL( |
|
1119 const RPointerArray<const CFeedsEntity>& aFeedsEntities, TInt aIndex) |
|
1120 { |
|
1121 RBufWriteStream stream; |
|
1122 |
|
1123 // Set the request type. |
|
1124 iType = EMoveFolderItem; |
|
1125 |
|
1126 // Package the request. |
|
1127 stream.Open (*iRequestBuff); |
|
1128 CleanupClosePushL (stream); |
|
1129 |
|
1130 stream.WriteInt32L ( iFolderListId ); |
|
1131 |
|
1132 // Write the entries. |
|
1133 stream.WriteUint16L (aIndex); |
|
1134 |
|
1135 stream.WriteUint16L (aFeedsEntities.Count ()); |
|
1136 for (TInt i = 0; i < aFeedsEntities.Count (); i++) |
|
1137 { |
|
1138 stream.WriteUint16L (aFeedsEntities[i]->GetId ()); |
|
1139 } |
|
1140 |
|
1141 iRequestBuff->Compress (); |
|
1142 CleanupStack::PopAndDestroy (/*stream*/); |
|
1143 |
|
1144 // Make the request. |
|
1145 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
1146 |
|
1147 iObserver.SendAsyncCommand (EFeedsServerMoveFolderItems, |
|
1148 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
1149 |
|
1150 Start (); |
|
1151 } |
|
1152 |
|
1153 // ----------------------------------------------------------------------------- |
|
1154 // CTransaction::UpdateFolderItemsL |
|
1155 // |
|
1156 // Update one or more feed. |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // |
|
1159 void CTransaction::UpdateFolderItemsL( |
|
1160 const RPointerArray<const CFeedsEntity>& aFeedsEntities) |
|
1161 { |
|
1162 RBufWriteStream stream; |
|
1163 |
|
1164 // Set the request type. |
|
1165 iType = EUpdateFolderItem; |
|
1166 |
|
1167 // Create the buffer to hold the response. |
|
1168 iResponseBuffer = HBufC8::NewL (KMaxFeedsServerMessage); |
|
1169 iResponsePtr.Set ((TUint8 *) iResponseBuffer->Ptr(), KMaxFeedsServerMessage, KMaxFeedsServerMessage); |
|
1170 |
|
1171 // Package the request. |
|
1172 stream.Open (*iRequestBuff); |
|
1173 CleanupClosePushL (stream); |
|
1174 |
|
1175 // Write out the folder list id. |
|
1176 stream.WriteInt32L (iFolderListId); |
|
1177 |
|
1178 // Write out the update all flag. |
|
1179 stream.WriteUint8L (EFalse); |
|
1180 |
|
1181 // Write the entries. |
|
1182 stream.WriteUint16L (aFeedsEntities.Count ()); |
|
1183 for (TInt i = 0; i < aFeedsEntities.Count (); i++) |
|
1184 { |
|
1185 stream.WriteUint16L (aFeedsEntities[i]->iFeedId); |
|
1186 } |
|
1187 |
|
1188 iRequestBuff->Compress (); |
|
1189 CleanupStack::PopAndDestroy (/*stream*/); |
|
1190 |
|
1191 // Make the request. |
|
1192 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
1193 |
|
1194 iObserver.SendAsyncCommand (EFeedsServerUpdateFolderItems, TIpcArgs ( |
|
1195 &iRequestBuffPtr, &iServerResponseTypePkg, &iResponsePtr), iStatus); |
|
1196 |
|
1197 Start (); |
|
1198 } |
|
1199 |
|
1200 // ----------------------------------------------------------------------------- |
|
1201 // CTransaction::UpdateFolderItemsL |
|
1202 // |
|
1203 // Update all of the feeds associated with the given folder list id. |
|
1204 // ----------------------------------------------------------------------------- |
|
1205 // |
|
1206 void CTransaction::UpdateFolderItemsL() |
|
1207 { |
|
1208 RBufWriteStream stream; |
|
1209 |
|
1210 // Set the request type. |
|
1211 iType = EUpdateFolderItem; |
|
1212 |
|
1213 // Create the buffer to hold the response. |
|
1214 iResponseBuffer = HBufC8::NewL (KMaxFeedsServerMessage); |
|
1215 iResponsePtr.Set ((TUint8 *) iResponseBuffer->Ptr(), KMaxFeedsServerMessage, KMaxFeedsServerMessage); |
|
1216 |
|
1217 // Package the request. |
|
1218 stream.Open (*iRequestBuff); |
|
1219 CleanupClosePushL (stream); |
|
1220 |
|
1221 // Write out the folder list id. |
|
1222 stream.WriteInt32L (iFolderListId); |
|
1223 |
|
1224 // Write out the update all flag. |
|
1225 stream.WriteUint8L (ETrue); |
|
1226 |
|
1227 iRequestBuff->Compress (); |
|
1228 CleanupStack::PopAndDestroy (/*stream*/); |
|
1229 |
|
1230 // Make the request. |
|
1231 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
1232 |
|
1233 iObserver.SendAsyncCommand (EFeedsServerUpdateFolderItems, TIpcArgs ( |
|
1234 &iRequestBuffPtr, &iServerResponseTypePkg, &iResponsePtr), iStatus); |
|
1235 |
|
1236 Start (); |
|
1237 } |
|
1238 |
|
1239 // ----------------------------------------------------------------------------- |
|
1240 // CTransaction::WatchFolderListL |
|
1241 // |
|
1242 // Sets up a notifier to execute when the folder list changes. |
|
1243 // ----------------------------------------------------------------------------- |
|
1244 // |
|
1245 void CTransaction::WatchFolderListL() |
|
1246 { |
|
1247 RBufWriteStream stream; |
|
1248 |
|
1249 // Set the request type. |
|
1250 iType = EWatchForChanges; |
|
1251 |
|
1252 // Package the request. |
|
1253 stream.Open (*iRequestBuff); |
|
1254 CleanupClosePushL (stream); |
|
1255 |
|
1256 // Write out the folder list id. |
|
1257 stream.WriteInt32L (iFolderListId); |
|
1258 |
|
1259 iRequestBuff->Compress (); |
|
1260 CleanupStack::PopAndDestroy (/*stream*/); |
|
1261 |
|
1262 // Make the request. |
|
1263 iRequestBuffPtr.Set (iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
1264 |
|
1265 iObserver.SendAsyncCommand (EFeedsServerWatchFolderList, |
|
1266 TIpcArgs (&iRequestBuffPtr), iStatus); |
|
1267 |
|
1268 Start (); |
|
1269 } |
|
1270 |
|
1271 // ----------------------------------------------------------------------------- |
|
1272 // CTransaction::ImportOPMLL |
|
1273 // |
|
1274 // Import OPML file passed from the client. |
|
1275 // ----------------------------------------------------------------------------- |
|
1276 // |
|
1277 void CTransaction::ImportOPMLL( const TDesC& aPath, |
|
1278 TBool aClearFolderList) |
|
1279 { |
|
1280 |
|
1281 TIpcArgs ipcArgs; |
|
1282 RBufWriteStream stream; |
|
1283 |
|
1284 if ( aPath.Length ()<= 0) |
|
1285 User::Leave (KErrArgument); |
|
1286 |
|
1287 // Set the request type. |
|
1288 iType = EImportOPML; |
|
1289 |
|
1290 // Create the buffer to hold the response. |
|
1291 iResponseBuffer = HBufC8::NewL (KMaxFeedsServerMessage); |
|
1292 iResponsePtr.Set ((TUint8 *) iResponseBuffer->Ptr(), KMaxFeedsServerMessage, KMaxFeedsServerMessage); |
|
1293 |
|
1294 // correct the path seperator |
|
1295 TBuf<KMaxFileName> path( aPath); |
|
1296 for (TInt i = 0; i < aPath.Length (); i++) |
|
1297 { |
|
1298 if ( path[i] == '/') |
|
1299 { |
|
1300 path[i] = '\\'; |
|
1301 } |
|
1302 } |
|
1303 // Package the request. |
|
1304 |
|
1305 stream.Open ( *iRequestBuff); |
|
1306 CleanupClosePushL ( stream); |
|
1307 |
|
1308 stream.WriteInt32L ( iFolderListId); |
|
1309 stream.WriteUint8L ( aClearFolderList); |
|
1310 |
|
1311 stream.WriteUint16L (aPath.Length ()); |
|
1312 stream.WriteL (path); |
|
1313 |
|
1314 iRequestBuff->Compress (); |
|
1315 CleanupStack::PopAndDestroy (/*stream*/); |
|
1316 |
|
1317 // Make the request. |
|
1318 iRequestBuffPtr.Set ( iRequestBuff->Ptr(0).Ptr (), iRequestBuff->Size ()); |
|
1319 |
|
1320 ipcArgs.Set (KFeedsServerPackedRequestArg, &iRequestBuffPtr); |
|
1321 |
|
1322 iObserver.SendAsyncCommand ( EFeedsServerImportOPML, ipcArgs, iStatus); |
|
1323 |
|
1324 Start (); |
|
1325 } |
|
1326 |
|
1327 |
|
1328 // ----------------------------------------------------------------------------- |
|
1329 // CTransaction::OrphanFeedsEntity |
|
1330 // |
|
1331 // Returns the feedsEntity -- the caller takes ownership. Only returns a valid |
|
1332 // folder item after a sucessful call to FetchFeed/FeedFolderItemL |
|
1333 // ----------------------------------------------------------------------------- |
|
1334 // |
|
1335 CFeedsEntity* CTransaction::OrphanFeedsEntity() |
|
1336 { |
|
1337 CFeedsEntity* item = NULL; |
|
1338 |
|
1339 item = iFeedsEntity; |
|
1340 iFeedsEntity = NULL; |
|
1341 |
|
1342 return item; |
|
1343 } |
|
1344 |
|
1345 // ----------------------------------------------------------------------------- |
|
1346 // CTransaction::GetType |
|
1347 // |
|
1348 // Returns transaction type |
|
1349 // ----------------------------------------------------------------------------- |
|
1350 // |
|
1351 EXPORT_C CTransaction::TTransactionType CTransaction::GetType() |
|
1352 { |
|
1353 return iType; |
|
1354 } |
|
1355 |
|
1356 // ----------------------------------------------------------------------------- |
|
1357 // CTransaction::SettingsFromResponseBuffPtrL |
|
1358 // |
|
1359 // Extract the current settings from the servers response. |
|
1360 // ----------------------------------------------------------------------------- |
|
1361 // |
|
1362 TFeedsServerSetting CTransaction::SettingsFromResponseBuffPtrL( |
|
1363 CBufFlat& aResponseBuffer) |
|
1364 { |
|
1365 RBufReadStream stream; |
|
1366 TFeedsServerSetting setting; |
|
1367 |
|
1368 // Unpack the response. |
|
1369 stream.Open(aResponseBuffer, 0); |
|
1370 CleanupClosePushL(stream); |
|
1371 |
|
1372 // Read the settings. |
|
1373 // NOTE: Be sure to adjust KSettingsBufSize if more settings are added. |
|
1374 setting.iAutoUpdate = stream.ReadUint8L(); |
|
1375 setting.iAutoUpdateFreq = stream.ReadUint16L(); |
|
1376 setting.iAutoUpdateAP = stream.ReadUint32L(); |
|
1377 setting.iAutoUpdateWhileRoaming = stream.ReadUint8L(); |
|
1378 |
|
1379 CleanupStack::PopAndDestroy(/*stream*/); |
|
1380 |
|
1381 return setting; |
|
1382 } |
|
1383 |
|
1384 // ----------------------------------------------------------------------------- |
|
1385 // CTransaction::GetSetting |
|
1386 // |
|
1387 // Extract the current settings from the local variable. |
|
1388 // ----------------------------------------------------------------------------- |
|
1389 // |
|
1390 void CTransaction::GetSetting(TFeedsServerSetting& aSetting) |
|
1391 { |
|
1392 aSetting = iSetting; |
|
1393 } |