diff -r a249528449c3 -r 87d139e87731 localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp --- a/localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp Mon Mar 15 12:43:27 2010 +0200 +++ b/localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp Wed Mar 31 23:02:31 2010 +0300 @@ -86,91 +86,102 @@ CMsvAttachment* attachInfo = store->AttachmentManagerL().GetAttachmentInfoL(0); CleanupStack::PushL(attachInfo); // 3rd push - + TDataType dataType = attachInfo->MimeType(); - - TInt error = KErrNone; - TBool isCompleteSelf = EFalse; + TFileName filePath; + filePath = attachInfo->FilePath(); - RFile attachFile; - TRAP( error, attachFile = store->AttachmentManagerL().GetAttachmentFileL(0)); - TFileName fullName; - attachFile.FullName(fullName); - attachFile.Close(); + TInt error = KErrNone; + TBool isCompleteSelf = EFalse; + CEikonEnv* eikEnv = CEikonEnv::Static(); + + if ( attachInfo->Type() == CMsvAttachment::EMsvFile ) + { + RFile attachFile; + TRAP( error, attachFile = store->AttachmentManagerL().GetAttachmentFileL(0)); + if ( error == KErrNone ) + { + CleanupClosePushL(attachFile); // 4th push + CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); // 5th push + TAiwGenericParam paramSave(EGenericParamAllowSave, ETrue); + paramList->AppendL( paramSave ); + + if ( eikEnv ) + { + iDocumentHandler = CDocumentHandler::NewL( eikEnv->Process() ); + iDocumentHandler->SetExitObserver( this ); + TRAP( error, iDocumentHandler->OpenFileEmbeddedL(attachFile, dataType, *paramList)); + }// eikEnv + CleanupStack::PopAndDestroy(2); // paramList, attachFile + } + }// EMsvFile - if ( KErrNone == error ) + if ( attachInfo->Type() == CMsvAttachment::EMsvLinkedFile ) { - CleanupClosePushL(attachFile); // 4th push - CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); // 5th push + CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); // 4th push TAiwGenericParam paramSave(EGenericParamFileSaved, ETrue); paramList->AppendL( paramSave ); - - if ( CEikonEnv::Static() ) + + if ( eikEnv ) { - // Launches an application in embedded mode - iDocumentHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() ); + + iDocumentHandler = CDocumentHandler::NewL( eikEnv->Process() ); iDocumentHandler->SetExitObserver( this ); RFile64 shareableFile; - TRAP( error, iDocumentHandler->OpenTempFileL(fullName,shareableFile)); + TRAP( error, iDocumentHandler->OpenTempFileL(filePath,shareableFile)); if ( error == KErrNone) { - TRAP( error, iDocumentHandler->OpenFileEmbeddedL( shareableFile, dataType, *paramList )); + TRAP( error, iDocumentHandler->OpenFileEmbeddedL( shareableFile, dataType, *paramList)); } shareableFile.Close(); - } - - - if ( error == KErrNotSupported ) - // If file is not supported, we open the file manager at file location. - { - // Launchs file manager at default folder - delete iDocumentHandler; - iDocumentHandler = NULL; - - TInt sortMethod = 2; // 0 = 'By name', 1 = 'By type', - // 2 = 'Most recent first' and 3 = 'Largest first' - TRAP (error, TObexUtilsUiLayer::LaunchFileManagerL( fullName, - sortMethod, - ETrue )); // ETrue -> launch file manager in embedded mode. - isCompleteSelf = ETrue; - } // KErrNotSupported - - // Set message to READ - // - TMsvEntry entry = aMessage->Entry(); - entry.SetUnread( EFalse ); - aMessage->ChangeL( entry ); - CleanupStack::PopAndDestroy(2); // paramList, attachFile - - } // KErrNone + if ( error == KErrNotFound ) + { + error = KErrNone; + TFileName fileName; + if (LocateFileL(fileName, filePath)) + { + // Update the entry + TRAP(error, TObexUtilsMessageHandler::UpdateEntryAttachmentL(fileName,aMessage)); + if ( error == KErrNone ) + { + // Show a confirmation note + CAknGlobalNote* note = CAknGlobalNote::NewLC(); + HBufC* stringholder = StringLoader::LoadLC( R_BT_SAVED_LINK_UPDATED ); + note->ShowNoteL(EAknGlobalConfirmationNote, *stringholder); + CleanupStack::PopAndDestroy(2); //note and stringholder + } + } + isCompleteSelf = ETrue; + } // KErrNotFound + } // eikEnv + + else if ( error == KErrNotSupported ) + { + delete iDocumentHandler; + iDocumentHandler = NULL; + + const TInt sortMethod = 2; // 0 = 'By name', 1 = 'By type', + // 2 = 'Most recent first' and 3 = 'Largest first' + TRAP (error, TObexUtilsUiLayer::LaunchFileManagerL( filePath, + sortMethod, + ETrue )); // ETrue -> launch file manager in embedded mode. + isCompleteSelf = ETrue; + } // KErrNotSupported + + CleanupStack::PopAndDestroy(); // paramList + } // EMsvLinkedFile - else // Error != KErrNone, broken link found. - // Lets fix it by selecting the right file. - { - error = KErrNone; - TFileName fileName; - TFileName oldFileName = attachInfo->FilePath(); - // select file - // - if (LocateFileL(fileName, oldFileName)) - { - // Update the entry - TRAP(error, TObexUtilsMessageHandler::UpdateEntryAttachmentL(fileName,aMessage)); - if ( error == KErrNone ) - { - // Show a confirmation note - CAknGlobalNote* note = CAknGlobalNote::NewLC(); - HBufC* stringholder = StringLoader::LoadLC( R_BT_SAVED_LINK_UPDATED ); - note->ShowNoteL(EAknGlobalConfirmationNote, *stringholder); - CleanupStack::PopAndDestroy(2); //note and stringholder - } - } - isCompleteSelf = ETrue; - } // !KErrNone - + + // Set message to READ + TMsvEntry entry = aMessage->Entry(); + entry.SetUnread( EFalse ); + aMessage->ChangeL( entry ); + User::LeaveIfError ( error ); CleanupStack::PopAndDestroy(3); // attachInfo, store, attachEntry + + iObserverRequestStatus = KRequestPending; // CMsvOperation (observer) iStatus = KRequestPending; // CMsvOperation SetActive(); @@ -180,6 +191,7 @@ HandleServerAppExit( error ); } } + // ----------------------------------------------------------------------------- // Destructor // -----------------------------------------------------------------------------