85 { |
85 { |
86 const CMdEObject* object = &iQuery->Result(0); |
86 const CMdEObject* object = &iQuery->Result(0); |
87 |
87 |
88 TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - URI = %S", &object->Uri() ); |
88 TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - URI = %S", &object->Uri() ); |
89 |
89 |
90 if( iUpdateToDb) |
90 // return path to client side |
|
91 if( iDelete ) |
91 { |
92 { |
92 //update IDs to database by Path |
93 TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() delete %S", &iUri ); |
93 if (ClientThreadAlive(EFalse)) |
94 TRAP_IGNORE( iServer.DeleteThumbnailsL( iUri ) ); |
94 { |
95 } |
95 TInt err = iMessage.Read( 0, iRequestParams ); |
96 else |
96 if( err == KErrNone) |
|
97 { |
|
98 TThumbnailRequestParams& params = iRequestParams(); |
|
99 TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), params.iThumbnailId)); |
|
100 } |
|
101 } |
|
102 } |
|
103 |
|
104 // return path to client side |
|
105 ReturnPath(object->Uri()); |
|
106 } |
|
107 else if (iQueryType == EId ) |
|
108 { |
|
109 const CMdEObject* object = &iQuery->Result(0); |
|
110 |
|
111 TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Id = %d", object->Id()); |
|
112 |
|
113 if( object->Id() != KNoId) |
|
114 { |
97 { |
115 if( iUpdateToDb) |
98 ReturnPath(object->Uri()); |
116 { |
|
117 TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), object->Id() )); |
|
118 } |
|
119 else |
|
120 { |
|
121 // add Id to message |
|
122 if (ClientThreadAlive(EFalse)) |
|
123 { |
|
124 TInt ret = iMessage.Read( 0, iRequestParams ); |
|
125 if( ret == KErrNone) |
|
126 { |
|
127 TThumbnailRequestParams& params = iRequestParams(); |
|
128 params.iThumbnailId = object->Id(); |
|
129 ret = iMessage.Write( 0, iRequestParams ); |
|
130 } |
|
131 } |
|
132 } |
|
133 } |
|
134 |
|
135 // complete the message with a code from which client side |
|
136 // knows to make a new request using the path |
|
137 if (ClientThreadAlive(EFalse)) |
|
138 { |
|
139 Complete( KThumbnailErrThumbnailNotFound ); |
|
140 ResetMessageData(); |
|
141 } |
99 } |
142 } |
100 } |
143 else |
101 else |
144 { |
102 { |
145 TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here" ); |
103 TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here!" ); |
146 if (ClientThreadAlive(EFalse)) |
104 if (ClientThreadAlive(EFalse)) |
147 { |
105 { |
148 Complete( KErrNotFound ); |
106 Complete( KErrNotFound ); |
149 ResetMessageData(); |
107 ResetMessageData(); |
150 } |
108 } |
|
109 __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbnailMDSQueryTask::HandleQueryCompleted()"), KErrNotSupported)); |
151 } |
110 } |
152 } |
111 } |
153 else |
112 else |
154 { |
113 { |
155 TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." ); |
114 TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." ); |
156 |
115 if(!iDelete) |
157 if( iQueryType == EId ) |
|
158 { |
|
159 if( iUpdateToDb) |
|
160 { |
|
161 TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() delete %S", &iUri ); |
|
162 TRAP_IGNORE( iServer.DeleteThumbnailsL( iUri ) ); |
|
163 } |
|
164 |
|
165 if (ClientThreadAlive(EFalse)) |
|
166 { |
|
167 Complete( KThumbnailErrThumbnailNotFound ); |
|
168 ResetMessageData(); |
|
169 } |
|
170 } |
|
171 else |
|
172 { |
116 { |
173 if (ClientThreadAlive(EFalse)) |
117 if (ClientThreadAlive(EFalse)) |
174 { |
118 { |
175 Complete( KErrNotFound ); |
119 Complete( KErrNotFound ); |
176 ResetMessageData(); |
120 ResetMessageData(); |
228 |
172 |
229 // --------------------------------------------------------------------------- |
173 // --------------------------------------------------------------------------- |
230 // CThumbnailMDSQueryTask::QueryPathByIdL() |
174 // CThumbnailMDSQueryTask::QueryPathByIdL() |
231 // --------------------------------------------------------------------------- |
175 // --------------------------------------------------------------------------- |
232 // |
176 // |
233 void CThumbnailMDSQueryTask::QueryPathByIdL(TThumbnailId aId) |
177 void CThumbnailMDSQueryTask::QueryPathByIdL(TThumbnailId aId, TBool aDelete) |
234 { |
178 { |
235 TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryPathByIdL()"); |
179 TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryPathByIdL()"); |
236 iQueryType = EURI; |
180 iQueryType = EURI; |
|
181 iDelete = aDelete; |
237 CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL(); |
182 CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL(); |
238 CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
183 CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
239 |
184 |
240 iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this ); |
185 iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this ); |
241 iQuery->SetResultMode( EQueryResultModeItem ); |
186 iQuery->SetResultMode( EQueryResultModeItem ); |
270 ResetMessageData(); |
215 ResetMessageData(); |
271 } |
216 } |
272 } |
217 } |
273 |
218 |
274 // --------------------------------------------------------------------------- |
219 // --------------------------------------------------------------------------- |
275 // CThumbnailMDSQueryTask::QueryIdByPathL() |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void CThumbnailMDSQueryTask::QueryIdByPathL(const TDesC& aUri) |
|
279 { |
|
280 TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryIdByPathL()"); |
|
281 iQueryType = EId; |
|
282 iUri = aUri; |
|
283 CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL(); |
|
284 CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
285 |
|
286 iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this ); |
|
287 iQuery->SetResultMode( EQueryResultModeItem ); |
|
288 |
|
289 CMdELogicCondition& rootCondition = iQuery->Conditions(); |
|
290 rootCondition.SetOperator( ELogicConditionOperatorOr ); |
|
291 |
|
292 rootCondition.AddObjectConditionL(EObjectConditionCompareUri, aUri); |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CThumbnailMDSQueryTask::SetUpdateToDb() |
220 // CThumbnailMDSQueryTask::SetUpdateToDb() |
297 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
298 // |
222 // |
299 void CThumbnailMDSQueryTask::SetUpdateToDb(const TBool& aUpdateToDb ) |
223 void CThumbnailMDSQueryTask::SetUpdateToDb(const TBool& aUpdateToDb ) |
300 { |
224 { |