29 #include <Pbk2CommonUi.rsg> |
29 #include <Pbk2CommonUi.rsg> |
30 #include <MPbk2CommandObserver.h> |
30 #include <MPbk2CommandObserver.h> |
31 #include <RPbk2LocalizedResourceFile.h> |
31 #include <RPbk2LocalizedResourceFile.h> |
32 #include <CPbk2DriveSpaceCheck.h> |
32 #include <CPbk2DriveSpaceCheck.h> |
33 #include <CPbk2AppUiBase.h> |
33 #include <CPbk2AppUiBase.h> |
|
34 #include <Pbk2CmdExtRes.rsg> |
34 |
35 |
35 // Virtual Phonebook |
36 // Virtual Phonebook |
36 #include <MVPbkStoreContact.h> |
37 #include <MVPbkStoreContact.h> |
37 #include <MVPbkFieldType.h> |
38 #include <MVPbkFieldType.h> |
38 #include <MVPbkContactFieldTextData.h> |
39 #include <MVPbkContactFieldTextData.h> |
129 // -------------------------------------------------------------------------- |
130 // -------------------------------------------------------------------------- |
130 // |
131 // |
131 TBool CPbk2SetImageCmd::ExecuteCommandL() |
132 TBool CPbk2SetImageCmd::ExecuteCommandL() |
132 { |
133 { |
133 TBool result = EFalse; |
134 TBool result = EFalse; |
|
135 iImageSetFailed = EFalse; |
134 Cancel(); |
136 Cancel(); |
135 |
137 |
136 // fetch image from media gallery |
138 // fetch image from media gallery |
137 CDesCArray* selectedFile = new(ELeave) CDesCArrayFlat( 1 ); |
139 CDesCArray* selectedFile = new(ELeave) CDesCArrayFlat( 1 ); |
138 CleanupStack::PushL( selectedFile ); |
140 CleanupStack::PushL( selectedFile ); |
139 TBool res( EFalse ); |
141 TBool res( EFalse ); |
|
142 |
140 res = MGFetchL( *selectedFile, EImageFile, EFalse, this ); |
143 res = MGFetchL( *selectedFile, EImageFile, EFalse, this ); |
141 |
144 |
142 if ( res && selectedFile->Count() > 0 ) |
145 if ( !iVerificationFailed && res && selectedFile->Count() > 0 ) |
143 { |
146 { |
144 iWaitNote = new(ELeave) CAknWaitDialog( |
147 iWaitNote = new(ELeave) CAknWaitDialog( |
145 reinterpret_cast<CEikDialog**>( &iWaitNote ), ETrue ); |
148 reinterpret_cast<CEikDialog**>( &iWaitNote ), ETrue ); |
|
149 |
|
150 iWaitNote->SetCallback( this ); |
146 iWaitNote->ExecuteLD( R_QTN_GEN_NOTE_FETCHING ); |
151 iWaitNote->ExecuteLD( R_QTN_GEN_NOTE_FETCHING ); |
147 |
152 |
148 TPtrC fileName = (*selectedFile)[0]; |
153 TPtrC fileName = (*selectedFile)[0]; |
149 |
154 |
150 // store reference to image field |
155 // store reference to image field |
191 void CPbk2SetImageCmd::Pbk2ImageSetFailed |
196 void CPbk2SetImageCmd::Pbk2ImageSetFailed |
192 ( MPbk2ImageOperation& PBK2_DEBUG_ONLY( aOperation ), TInt aError ) |
197 ( MPbk2ImageOperation& PBK2_DEBUG_ONLY( aOperation ), TInt aError ) |
193 { |
198 { |
194 __ASSERT_DEBUG( &aOperation == iImageOperation, |
199 __ASSERT_DEBUG( &aOperation == iImageOperation, |
195 Panic( EPanicPreCond_Pbk2ImageSetFailed ) ); |
200 Panic( EPanicPreCond_Pbk2ImageSetFailed ) ); |
196 |
201 |
197 delete iImageOperation; |
202 delete iImageOperation; |
198 iImageOperation = NULL; |
203 iImageOperation = NULL; |
199 |
204 |
200 DismissWaitNote(); |
205 iImageSetFailed = ETrue; |
201 |
206 iImageSetError = aError; |
202 ProcessDismissed( aError ); |
207 DismissWaitNote(); |
203 } |
208 } |
204 |
209 |
205 // -------------------------------------------------------------------------- |
210 // -------------------------------------------------------------------------- |
206 // CPbk2SetImageCmd::DismissWaitNote |
211 // CPbk2SetImageCmd::DismissWaitNote |
207 // -------------------------------------------------------------------------- |
212 // -------------------------------------------------------------------------- |
214 TRAPD( err, iWaitNote->ProcessFinishedL() ); |
219 TRAPD( err, iWaitNote->ProcessFinishedL() ); |
215 if ( err != KErrNone ) |
220 if ( err != KErrNone ) |
216 { |
221 { |
217 delete iWaitNote; |
222 delete iWaitNote; |
218 iWaitNote = NULL; |
223 iWaitNote = NULL; |
|
224 |
|
225 if( iImageSetFailed ) |
|
226 { |
|
227 ShowErrorNoteL(); |
|
228 } |
219 } |
229 } |
220 } |
230 } |
221 } |
231 } |
222 |
232 |
223 // -------------------------------------------------------------------------- |
233 // -------------------------------------------------------------------------- |
|
234 // CPbk2SetImageCmd::DialogDismissedL |
|
235 // -------------------------------------------------------------------------- |
|
236 // |
|
237 void CPbk2SetImageCmd::DialogDismissedL( TInt /*aButtonId*/ ) |
|
238 { |
|
239 if( iImageSetFailed ) |
|
240 { |
|
241 ShowErrorNoteL(); |
|
242 } |
|
243 } |
|
244 |
|
245 // -------------------------------------------------------------------------- |
224 // CPbk2SetImageCmd::VerifySelectionL |
246 // CPbk2SetImageCmd::VerifySelectionL |
225 // -------------------------------------------------------------------------- |
247 // -------------------------------------------------------------------------- |
226 // |
248 // |
227 TBool CPbk2SetImageCmd::VerifySelectionL |
249 TBool CPbk2SetImageCmd::VerifySelectionL |
228 (const MDesCArray* aSelectedFiles) |
250 (const MDesCArray* aSelectedFiles) |
229 { |
251 { |
230 TBool result = EFalse; |
252 iVerificationFailed = EFalse; |
|
253 TBool ret = ETrue; |
|
254 |
|
255 TRAPD( err, ret = DoVerifySelectionL( aSelectedFiles ) ); |
|
256 |
|
257 if( err != KErrNone ) |
|
258 { |
|
259 iVerificationFailed = ETrue; |
|
260 ShowErrorNoteL(); |
|
261 } |
|
262 |
|
263 // Selection is always accepted if the image is not drm protected. |
|
264 // Image fetch dialog functionality is always same in spite of error |
|
265 // type (DRM check, ImageDecoder, etc. errors) Dialog is always closed. |
|
266 return ret; |
|
267 } |
|
268 |
|
269 // -------------------------------------------------------------------------- |
|
270 // CPbk2SetImageCmd::DoVerifySelectionL |
|
271 // -------------------------------------------------------------------------- |
|
272 // |
|
273 TBool CPbk2SetImageCmd::DoVerifySelectionL |
|
274 (const MDesCArray* aSelectedFiles) |
|
275 { |
|
276 TBool ret = ETrue; |
|
277 |
231 if ( aSelectedFiles && aSelectedFiles->MdcaCount() > 0 ) |
278 if ( aSelectedFiles && aSelectedFiles->MdcaCount() > 0 ) |
232 { |
279 { |
233 // DRM for phonebook image fetch |
280 // DRM for phonebook image fetch |
234 TPtrC fileName = aSelectedFiles->MdcaPoint( 0 ); |
281 TPtrC fileName = aSelectedFiles->MdcaPoint( 0 ); |
235 TBool isProtected( ETrue ); |
282 TBool isProtected( ETrue ); |
236 User::LeaveIfError( |
283 User::LeaveIfError( |
237 iDrmManager->IsProtectedFile( fileName, isProtected ) ); |
284 iDrmManager->IsProtectedFile( fileName, isProtected ) ); |
|
285 |
238 if ( isProtected ) |
286 if ( isProtected ) |
239 { |
287 { |
240 RPbk2LocalizedResourceFile resFile( *CCoeEnv::Static() ); |
288 ret = EFalse; |
241 resFile.OpenLC( |
289 RPbk2LocalizedResourceFile resFile( *CCoeEnv::Static() ); |
242 KPbk2RomFileDrive, |
290 resFile.OpenLC( |
243 KDC_RESOURCE_FILES_DIR, |
291 KPbk2RomFileDrive, |
244 Pbk2PresentationUtils::PresentationResourceFile() ); |
292 KDC_RESOURCE_FILES_DIR, |
|
293 Pbk2PresentationUtils::PresentationResourceFile() ); |
245 // show user copyright note |
294 // show user copyright note |
246 HBufC* prompt = |
295 HBufC* prompt = |
247 CCoeEnv::Static()->AllocReadResourceLC( R_PBK2_QTN_DRM_NOT_ALLOWED ); |
296 CCoeEnv::Static()->AllocReadResourceLC( R_PBK2_QTN_DRM_NOT_ALLOWED ); |
248 CAknInformationNote* dlg = new(ELeave) CAknInformationNote( ETrue ); |
297 CAknInformationNote* dlg = new(ELeave) CAknInformationNote( ETrue ); |
249 dlg->ExecuteLD( *prompt ); |
298 dlg->ExecuteLD( *prompt ); |
250 CleanupStack::PopAndDestroy( 2 ); // resFile, prompt |
299 CleanupStack::PopAndDestroy( 2 ); // resFile, prompt |
251 } |
300 } |
252 else |
301 } |
253 { |
302 |
254 result = ETrue; |
303 return ret; |
255 } |
304 } |
256 } |
305 |
257 |
306 // -------------------------------------------------------------------------- |
258 return result; |
307 // CPbk2SetImageCmd::ShowErrorNoteL |
|
308 // -------------------------------------------------------------------------- |
|
309 // |
|
310 void CPbk2SetImageCmd::ShowErrorNoteL() |
|
311 { |
|
312 HBufC* prompt = StringLoader::LoadLC( R_QTN_ALBUM_ERR_FORMAT_UNKNOWN ); |
|
313 CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue ); |
|
314 dlg->ExecuteLD( *prompt ); |
|
315 CleanupStack::PopAndDestroy( prompt ); |
|
316 |
|
317 if( iImageSetFailed ) |
|
318 { |
|
319 ProcessDismissed( iImageSetError ); |
|
320 iImageSetFailed = EFalse; |
|
321 iImageSetError = KErrNone; |
|
322 } |
259 } |
323 } |
260 |
324 |
261 // -------------------------------------------------------------------------- |
325 // -------------------------------------------------------------------------- |
262 // CPbk2SetImageCmd::Cancel |
326 // CPbk2SetImageCmd::Cancel |
263 // -------------------------------------------------------------------------- |
327 // -------------------------------------------------------------------------- |