49 CHarvesterClientAO::~CHarvesterClientAO() // destruct |
49 CHarvesterClientAO::~CHarvesterClientAO() // destruct |
50 { |
50 { |
51 OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::~CHarvesterClientAO" ); |
51 OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::~CHarvesterClientAO" ); |
52 |
52 |
53 WRITELOG( "CHarvesterClientAO::~CHarvesterClientAO()" ); |
53 WRITELOG( "CHarvesterClientAO::~CHarvesterClientAO()" ); |
54 CancelRequest(); |
54 Cancel(); |
55 } |
55 } |
56 |
56 |
57 // --------------------------------------------------------------------------- |
57 // --------------------------------------------------------------------------- |
58 // CHarvesterClientAO |
58 // CHarvesterClientAO |
59 // First-phase C++ constructor |
59 // First-phase C++ constructor |
60 // --------------------------------------------------------------------------- |
60 // --------------------------------------------------------------------------- |
61 // |
61 // |
62 CHarvesterClientAO::CHarvesterClientAO( RHarvesterClient& aHarvesterClient ) |
62 CHarvesterClientAO::CHarvesterClientAO( RHarvesterClient& aHarvesterClient ) |
63 : CActive( CActive::EPriorityUserInput ), |
63 : CActive( CActive::EPriorityStandard ), |
64 iObserver( NULL ), |
64 iObserver( NULL ), |
65 iHarvesterClient( aHarvesterClient ), |
65 iHarvesterClient( aHarvesterClient ) |
66 iCancelled( EFalse ) |
|
67 { |
66 { |
68 OstTrace0( TRACE_NORMAL, DUP1_CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::CHarvesterClientAO" ); |
67 OstTrace0( TRACE_NORMAL, DUP1_CHARVESTERCLIENTAO_CHARVESTERCLIENTAO, "CHarvesterClientAO::CHarvesterClientAO" ); |
69 |
68 |
70 WRITELOG( "CHarvesterClientAO::CHarvesterClientAO()" ); |
69 WRITELOG( "CHarvesterClientAO::CHarvesterClientAO()" ); |
71 } |
70 } |
99 // --------------------------------------------------------------------------- |
98 // --------------------------------------------------------------------------- |
100 // |
99 // |
101 void CHarvesterClientAO::RemoveObserver( MHarvestObserver* /*aObserver*/ ) |
100 void CHarvesterClientAO::RemoveObserver( MHarvestObserver* /*aObserver*/ ) |
102 { |
101 { |
103 WRITELOG( "CHarvesterClientAO::RemoveObserver()" ); |
102 WRITELOG( "CHarvesterClientAO::RemoveObserver()" ); |
104 OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_REMOVEOBSERVER, "CHarvesterClientAO::RemoveObserver" ); |
|
105 if ( iObserver ) |
103 if ( iObserver ) |
106 { |
104 { |
107 WRITELOG( "CHarvesterClientAO::RemoveObserver() - deleting observer" ); |
105 WRITELOG( "CHarvesterClientAO::RemoveObserver() - deleting observer" ); |
108 iObserver = NULL; |
106 iObserver = NULL; |
109 } |
107 } |
110 |
108 |
111 CancelRequest(); |
109 Cancel(); |
112 } |
110 } |
113 |
111 |
114 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
115 // DoCancel |
113 // DoCancel |
116 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
118 void CHarvesterClientAO::DoCancel() |
116 void CHarvesterClientAO::DoCancel() |
119 { |
117 { |
120 WRITELOG( "CHarvesterClientAO::DoCancel()" ); |
118 WRITELOG( "CHarvesterClientAO::DoCancel()" ); |
121 OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_DOCANCEL, "CHarvesterClientAO::DoCancel" ); |
119 OstTrace0( TRACE_NORMAL, CHARVESTERCLIENTAO_DOCANCEL, "CHarvesterClientAO::DoCancel" ); |
122 iHarvesterClient.UnregisterHarvestComplete(); |
120 iHarvesterClient.UnregisterHarvestComplete(); |
123 WRITELOG( "CHarvesterClientAO::DoCancel() - end" ); |
|
124 } |
121 } |
125 |
122 |
126 // --------------------------------------------------------------------------- |
123 // --------------------------------------------------------------------------- |
127 // Active |
124 // Active |
128 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
129 // |
126 // |
130 void CHarvesterClientAO::Active() |
127 void CHarvesterClientAO::Active() |
131 { |
128 { |
132 WRITELOG( "CHarvesterClientAO::Active" ); |
|
133 if ( iObserver && !IsActive()) |
129 if ( iObserver && !IsActive()) |
134 { |
130 { |
135 WRITELOG( "CHarvesterClientAO::Active - calling RegisterHarvestComplete" ); |
|
136 iHarvesterClient.RegisterHarvestComplete(iURI, iStatus); |
131 iHarvesterClient.RegisterHarvestComplete(iURI, iStatus); |
137 iCancelled = EFalse; |
|
138 SetActive(); |
132 SetActive(); |
139 } |
133 } |
140 } |
134 } |
141 |
135 |
142 // --------------------------------------------------------------------------- |
136 // --------------------------------------------------------------------------- |
161 WRITELOG( "CHarvesterClientAO::RunL() - ECompleteRequest - calling callback" ); |
155 WRITELOG( "CHarvesterClientAO::RunL() - ECompleteRequest - calling callback" ); |
162 iObserver->HarvestingComplete( iURI, status ); |
156 iObserver->HarvestingComplete( iURI, status ); |
163 } |
157 } |
164 |
158 |
165 // if the request was not canceled or server is not terminated, Activating AO again |
159 // if the request was not canceled or server is not terminated, Activating AO again |
166 if ( status != KErrCancel && status != KErrServerTerminated && iObserver && !iCancelled ) |
160 if ( status != KErrCancel && status != KErrServerTerminated && iObserver ) |
167 { |
161 { |
168 WRITELOG( "CHarvesterClientAO::RunL() - not cancelled or terminated, calling Active" ); |
|
169 Active(); |
162 Active(); |
170 } |
163 } |
171 WRITELOG( "CHarvesterClientAO::RunL() - end" ); |
|
172 } |
164 } |
173 |
165 |
174 // --------------------------------------------------------------------------- |
166 // --------------------------------------------------------------------------- |
175 // RunError |
167 // RunError |
176 // --------------------------------------------------------------------------- |
168 // --------------------------------------------------------------------------- |
183 { |
175 { |
184 WRITELOG1( "CHarvesterClientAO::RunError(), errorcode: %d", aError ); |
176 WRITELOG1( "CHarvesterClientAO::RunError(), errorcode: %d", aError ); |
185 |
177 |
186 return KErrNone; |
178 return KErrNone; |
187 } |
179 } |
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // Active |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CHarvesterClientAO::CancelRequest() |
|
194 { |
|
195 WRITELOG( "CHarvesterClientAO::CancelRequest" ); |
|
196 if( !iCancelled ) |
|
197 { |
|
198 WRITELOG( "CHarvesterClientAO::CancelRequest - not cancelled, calling Cancel" ); |
|
199 iCancelled = ETrue; |
|
200 Cancel(); |
|
201 } |
|
202 if( !IsActive() ) |
|
203 { |
|
204 WRITELOG( "CHarvesterClientAO::CancelRequest - setting priority to High" ); |
|
205 SetPriority( CActive::EPriorityHigh ); |
|
206 } |
|
207 } |
|
208 |
|