45 #include <glxattributeretriever.h> // for GlxAttributeRetriever |
44 #include <glxattributeretriever.h> // for GlxAttributeRetriever |
46 #include <glxuiutilities.rsg> // for R_GLX_TOOLTIP_SEND |
45 #include <glxuiutilities.rsg> // for R_GLX_TOOLTIP_SEND |
47 #include <glxfetchcontextremover.h> // for TGlxFetchContextRemover |
46 #include <glxfetchcontextremover.h> // for TGlxFetchContextRemover |
48 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
47 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
49 #include <glxicons.mbg> |
48 #include <glxicons.mbg> |
|
49 #include <glximageviewermanager.h> // for CGlxImageViewerManager |
50 |
50 |
51 // LOCAL FUNCTIONS AND CONSTANTS |
51 // LOCAL FUNCTIONS AND CONSTANTS |
52 namespace |
52 namespace |
53 { |
53 { |
54 const TInt KSendMsgBodySz = 0; |
54 const TInt KSendMsgBodySz = 0; |
241 CMessageData* messageData = CMessageData::NewLC(); |
241 CMessageData* messageData = CMessageData::NewLC(); |
242 |
242 |
243 // retrieve the file name and path |
243 // retrieve the file name and path |
244 CGlxDefaultAttributeContext* attributeContext = |
244 CGlxDefaultAttributeContext* attributeContext = |
245 CGlxDefaultAttributeContext::NewL(); |
245 CGlxDefaultAttributeContext::NewL(); |
246 CleanupStack::PushL(attributeContext); |
246 CleanupStack::PushL( attributeContext ); |
247 attributeContext->AddAttributeL(TMPXAttribute(KMPXMediaGeneralUri)); |
247 attributeContext->AddAttributeL( TMPXAttribute( KMPXMediaGeneralUri ) ); |
248 mediaList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
248 mediaList.AddContextL( attributeContext, KGlxFetchContextPriorityBlocking ); |
249 |
249 |
250 // TGlxContextRemover will remove the context when it goes out of scope |
250 // TGlxContextRemover will remove the context when it goes out of scope |
251 // Used here to avoid a trap and still have safe cleanup |
251 // Used here to avoid a trap and still have safe cleanup |
252 TGlxFetchContextRemover contextRemover (attributeContext, mediaList); |
252 TGlxFetchContextRemover contextRemover( attributeContext, mediaList ); |
253 CleanupClosePushL( contextRemover ); |
253 CleanupClosePushL( contextRemover ); |
254 |
254 |
255 User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, |
255 User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, |
256 mediaList, ETrue)); |
256 mediaList, ETrue)); |
257 // context off the list |
257 // context off the list |
258 CleanupStack::PopAndDestroy( &contextRemover ); |
258 CleanupStack::PopAndDestroy( &contextRemover ); |
259 |
259 |
260 // if there are multiple media items, filter the postcard plugin |
260 // if there are multiple media items, filter the postcard plugin |
261 iFilterOutPlugin = (mediaList.SelectionCount() > 1); |
261 iFilterOutPlugin = (mediaList.SelectionCount() > 1); |
262 |
262 |
263 // extract the filename from selected items in the media list and add it |
263 // extract the filename from selected items in the media list and add it |
264 // to the messageData to be returned |
264 // to the messageData to be returned |
265 TGlxSelectionIterator iterator; |
265 TGlxSelectionIterator iterator; |
266 iterator.SetToFirst(&mediaList); |
266 iterator.SetToFirst( &mediaList ); |
267 TInt index = KErrNotFound; |
267 TInt index = KErrNotFound; |
268 |
268 |
269 while ((index = iterator++) != KErrNotFound) |
269 while ( (index = iterator++) != KErrNotFound ) |
270 { |
270 { |
271 // does not return ownership. |
271 // does not return ownership. |
272 const CGlxMedia* media = mediaList.Item(index).Properties(); |
272 const CGlxMedia* media = mediaList.Item( index ).Properties(); |
273 if(media) |
273 if (media) |
274 { |
274 { |
275 if(media->IsSupported(KMPXMediaGeneralUri) && IsValidTypeL(*media)) |
275 if ( media->IsSupported( KMPXMediaGeneralUri ) && |
276 { |
276 IsValidTypeL( *media ) ) |
277 messageData->AppendAttachmentL( |
277 { |
278 media->ValueText(KMPXMediaGeneralUri)); |
278 CGlxImageViewerManager* viewerInst = |
279 } |
279 CGlxImageViewerManager::InstanceL(); |
280 } |
280 if ( viewerInst && viewerInst->IsPrivate() ) |
281 else |
281 { |
282 { |
282 messageData->AppendAttachmentHandleL( |
283 User::Leave(KErrNotReady); |
283 viewerInst->ImageFileHandle() ); |
284 } |
284 } |
285 } |
285 else |
286 |
286 { |
287 CleanupStack::PopAndDestroy(attributeContext); |
287 messageData->AppendAttachmentL( |
|
288 media->ValueText( KMPXMediaGeneralUri ) ); |
|
289 } |
|
290 viewerInst->DeleteInstance(); |
|
291 } |
|
292 } |
|
293 else |
|
294 { |
|
295 User::Leave( KErrNotReady ); |
|
296 } |
|
297 } |
|
298 |
|
299 CleanupStack::PopAndDestroy( attributeContext ); |
288 return messageData; |
300 return messageData; |
289 }// contextRemover goes out of scope and removes the context from media list |
301 } |
290 |
|
291 |
302 |
292 // ---------------------------------------------------------------------------- |
303 // ---------------------------------------------------------------------------- |
293 // IsValidTypeL |
304 // IsValidTypeL |
294 // ---------------------------------------------------------------------------- |
305 // ---------------------------------------------------------------------------- |
295 TBool CGlxCommandHandlerSend::IsValidTypeL(const CGlxMedia& aMedia) |
306 TBool CGlxCommandHandlerSend::IsValidTypeL(const CGlxMedia& aMedia) |