|
1 /* |
|
2 * Copyright (c) 2007-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 "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: CIAUpdateNormalContentOperation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <ncdoperation.h> |
|
21 #include <ncdquery.h> |
|
22 #include <ncdprogress.h> |
|
23 |
|
24 #include "iaupdatenormalcontentoperation.h" |
|
25 #include "iaupdatenodeimpl.h" |
|
26 #include "iaupdatedebug.h" |
|
27 |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CIAUpdateNormalContentOperation::CIAUpdateNormalContentOperation |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CIAUpdateNormalContentOperation::CIAUpdateNormalContentOperation( |
|
35 CIAUpdateBaseNode& aNode, |
|
36 MIAUpdateContentOperationObserver& aObserver ) |
|
37 : CIAUpdateContentOperation( aNode, aObserver ) |
|
38 { |
|
39 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::CIAUpdateNormalContentOperation"); |
|
40 } |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CIAUpdateNormalContentOperation::ConstructL |
|
45 // |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 void CIAUpdateNormalContentOperation::ConstructL() |
|
49 { |
|
50 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::ConstructL() begin"); |
|
51 |
|
52 CIAUpdateContentOperation::ConstructL(); |
|
53 |
|
54 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::ConstructL() end"); |
|
55 } |
|
56 |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CIAUpdateNormalContentOperation::~CIAUpdateNormalContentOperation |
|
60 // |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CIAUpdateNormalContentOperation::~CIAUpdateNormalContentOperation() |
|
64 { |
|
65 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::~CIAUpdateNormalContentOperation begin"); |
|
66 |
|
67 // Do not call CancelOperation here because its implementation depends on |
|
68 // child class implementations. So, this object is deleted, the child classes |
|
69 // are already deleted and their implementation is not available. |
|
70 // So, call CancelOperation in child classes. |
|
71 |
|
72 // Operation is created by using the HandleContentL function. |
|
73 // If operation is created, it will be released when child class calls |
|
74 // CancelOperation. |
|
75 |
|
76 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::~CIAUpdateNormalContentOperation end"); |
|
77 } |
|
78 |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CIAUpdateNormalContentOperation::StartOperationL |
|
82 // |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 TBool CIAUpdateNormalContentOperation::StartOperationL() |
|
86 { |
|
87 // Init variables by using the parent. |
|
88 CIAUpdateContentOperation::StartOperationL(); |
|
89 |
|
90 // Start new active object round. |
|
91 TBool started( EFalse ); |
|
92 |
|
93 // Start the operation and set the pointer to it. |
|
94 // Operation pointer needs to be set for the possible cancellation. |
|
95 SetOperation( HandleContentL() ); |
|
96 |
|
97 if ( iOperation ) |
|
98 { |
|
99 // Operation exists. So, start it. |
|
100 iOperation->StartOperationL(); |
|
101 SetOperationInUse( ETrue ); |
|
102 started = ETrue; |
|
103 } |
|
104 |
|
105 return started; |
|
106 } |
|
107 |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CIAUpdateNormalContentOperation::CancelOperation |
|
111 // |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CIAUpdateNormalContentOperation::CancelOperation() |
|
115 { |
|
116 if ( iOperation ) |
|
117 { |
|
118 // Cancel the operation and release the current operation. |
|
119 // Notice, that this will result to call to ContentOperationComplete |
|
120 iOperation->CancelOperation(); |
|
121 } |
|
122 } |
|
123 |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CIAUpdateNormalContentOperation::ContentQueryReceived |
|
127 // |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CIAUpdateNormalContentOperation::ContentQueryReceived( |
|
131 MNcdOperation& aOperation, |
|
132 MNcdQuery* aQuery ) |
|
133 { |
|
134 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::ContentQueryReceived() begin"); |
|
135 |
|
136 // Operation query received. Always accept queries. |
|
137 // Queries should not be requested from this client. |
|
138 TInt trapError( KErrNone ); |
|
139 if ( aQuery ) |
|
140 { |
|
141 TRAP ( trapError, |
|
142 aQuery->SetResponseL( MNcdQuery::EAccepted ); |
|
143 aOperation.CompleteQueryL( *aQuery ); ); |
|
144 // Release needs to be called to the query after it is not used. |
|
145 aQuery->Release(); |
|
146 } |
|
147 |
|
148 if ( ( trapError != KErrNone ) || ( !aQuery ) ) |
|
149 { |
|
150 // Error occurred when query was handled. |
|
151 // So, operation can not continue. |
|
152 // Cancel operation. Notice, that OperationComplete will be called |
|
153 // by the operation when cancel is called. |
|
154 aOperation.CancelOperation(); |
|
155 } |
|
156 |
|
157 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::ContentQueryReceived() end"); |
|
158 } |
|
159 |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // CIAUpdateContentOperation::ContentOperationComplete |
|
163 // |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CIAUpdateNormalContentOperation::ContentOperationComplete( |
|
167 MNcdOperation& /*aOperation*/, |
|
168 TInt aError ) |
|
169 { |
|
170 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::ContentOperationComplete() begin"); |
|
171 |
|
172 // Notice, that this releases the old operation. |
|
173 SetOperation( NULL ); |
|
174 OperationComplete( aError ); |
|
175 |
|
176 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::ContentOperationComplete() end"); |
|
177 } |
|
178 |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // CIAUpdateNormalContentOperation::SetOperation |
|
182 // |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 void CIAUpdateNormalContentOperation::SetOperation( |
|
186 MNcdOperation* aOperation ) |
|
187 { |
|
188 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::SetOperation() begin"); |
|
189 |
|
190 if ( iOperation ) |
|
191 { |
|
192 IAUPDATE_TRACE("[IAUPDATE] Release old operation before setting new one"); |
|
193 iOperation->Release(); |
|
194 } |
|
195 |
|
196 iOperation = aOperation; |
|
197 |
|
198 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNormalContentOperation::SetOperation() end"); |
|
199 } |