1 /* |
|
2 * Copyright (c) 2006-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: Processor object for running harvester requests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "harvesternotificationqueue.h" |
|
20 #include "harvesterclientao.h" |
|
21 #include "harvesterlog.h" |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // CHarvesterNotificationQueue::NewL() |
|
27 // Two-phased constructor. |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CHarvesterNotificationQueue* CHarvesterNotificationQueue::NewL() |
|
31 { |
|
32 CHarvesterNotificationQueue* self = new( ELeave )CHarvesterNotificationQueue(); |
|
33 CleanupStack::PushL( self ); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CHarvesterNotificationQueue::CHarvesterNotificationQueue() |
|
42 // C++ default constructor can NOT contain any code, that might leave. |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CHarvesterNotificationQueue::CHarvesterNotificationQueue() |
|
46 { |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CHarvesterNotificationQueue::ConstructL() |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void CHarvesterNotificationQueue::ConstructL() |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CHarvesterNotificationQueue::~CHarvesterNotificationQueue() |
|
62 // Destructor. |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CHarvesterNotificationQueue::~CHarvesterNotificationQueue() |
|
66 { |
|
67 WRITELOG( "CHarvesterNotificationQueue::~CHarvesterNotificationQueue()"); |
|
68 |
|
69 Cleanup( ETrue ); |
|
70 iRequests.ResetAndDestroy(); |
|
71 |
|
72 WRITELOG( "CHarvesterNotificationQueue::~CHarvesterNotificationQueue() - All requests deleted"); |
|
73 } |
|
74 |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CHarvesterNotificationQueue::AddRequestL() |
|
78 // Adds new request to the queue. |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CHarvesterNotificationQueue::AddRequestL( CHarvesterClientAO* aRequest ) |
|
82 { |
|
83 WRITELOG( "CHarvesterNotificationQueue::AddRequestL()"); |
|
84 |
|
85 iRequests.AppendL( aRequest ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CHarvesterNotificationQueue::RequestComplete() |
|
90 // Completes the request |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CHarvesterNotificationQueue::Cleanup( TBool aShutdown ) |
|
94 { |
|
95 WRITELOG( "CHarvesterNotificationQueue::RequestComplete()"); |
|
96 |
|
97 for( TInt i = iRequests.Count() - 1; i >=0; i-- ) |
|
98 { |
|
99 if( aShutdown ) |
|
100 { |
|
101 iRequests[i]->Cancel(); |
|
102 } |
|
103 |
|
104 if( iRequests[i]->RequestComplete() && !iRequests[i]->IsActive() ) |
|
105 { |
|
106 delete iRequests[i]; |
|
107 iRequests[i] = NULL; |
|
108 iRequests.Remove( i ); |
|
109 |
|
110 // correct the index so that no items are skipped |
|
111 i--; |
|
112 if(i <= -1) |
|
113 { |
|
114 i = -1; |
|
115 } |
|
116 } |
|
117 } |
|
118 |
|
119 if( iRequests.Count() == 0 && !aShutdown ) |
|
120 { |
|
121 iRequests.Compress(); |
|
122 } |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // SetObserver |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CHarvesterNotificationQueue::SetObserver( MHarvestObserver* aObserver ) |
|
130 { |
|
131 WRITELOG( "CHarvesterNotificationQueue::SetObserver()" ); |
|
132 |
|
133 for( TInt i = iRequests.Count() - 1; i >=0; i-- ) |
|
134 { |
|
135 iRequests[i]->SetObserver( aObserver ); |
|
136 } |
|
137 } |
|
138 |
|
139 // End of file |
|
140 |
|