calendarui/controller/src/calenviewattachmentsdialog.cpp
branchRCL_3
changeset 10 38571fd2a704
parent 0 f979ecb2b13e
child 14 21239b3bcd78
equal deleted inserted replaced
5:42814f902fe6 10:38571fd2a704
   249                 CCalenAttachmentInfo& attInfo =
   249                 CCalenAttachmentInfo& attInfo =
   250                     iAttachmentModel.AttachmentInfoAt( index );
   250                     iAttachmentModel.AttachmentInfoAt( index );
   251 
   251 
   252                 TDataType datatype( attInfo.DataType() );
   252                 TDataType datatype( attInfo.DataType() );
   253                 RFile file = iAttachmentModel.GetAttachmentFileL( index );
   253                 RFile file = iAttachmentModel.GetAttachmentFileL( index );
   254                 OpenAttachmentViewerL(file, *this);                
   254                 CleanupClosePushL(file);
       
   255                 OpenAttachmentViewerL(file, *this);
       
   256                 CleanupStack::PopAndDestroy(&file);
   255                 }                                
   257                 }                                
   256             }
   258             }
   257         break;
   259         break;
   258       
   260       
   259         case ECalenViewAttachmentCmdSave:
   261         case ECalenViewAttachmentCmdSave:
  1082 // -----------------------------------------------------------------------------
  1084 // -----------------------------------------------------------------------------
  1083 // CCalenViewAttachmentsDialog::OpenAttachmentL
  1085 // CCalenViewAttachmentsDialog::OpenAttachmentL
  1084 // Opens a particular attachment
  1086 // Opens a particular attachment
  1085 // -----------------------------------------------------------------------------
  1087 // -----------------------------------------------------------------------------
  1086 //
  1088 //
  1087 void CCalenViewAttachmentsDialog::OpenAttachmentViewerL(RFile& file, MAknServerAppExitObserver& /*aExitObserver*/)
  1089 void CCalenViewAttachmentsDialog::OpenAttachmentViewerL(RFile& aFile, MAknServerAppExitObserver& /*aExitObserver*/)
  1088     {
  1090     {
  1089     TRACE_ENTRY_POINT;
  1091     TRACE_ENTRY_POINT;
  1090     
  1092     
  1091     TBuf<250> fileName;
  1093     TBuf<250> fileName;
  1092     file.FullName(fileName);
  1094     aFile.FullName(fileName);
  1093     TDataType datatype( CCalenAttachmentUtils::GetMimeTypeL(fileName) );
  1095     TDataType datatype( CCalenAttachmentUtils::GetMimeType(aFile) );
  1094     
  1096     
  1095     TInt ret = KErrNone;
  1097     TInt ret = KErrNone;
  1096     
  1098     
  1097     file.Close();
       
  1098     RFs& fs = CEikonEnv::Static()->FsSession();
       
  1099                     
       
  1100     //open the file, before giving it to Notepad.
       
  1101     TInt err1 = file.Open( fs, fileName, EFileRead | EFileShareReadersOnly );
       
  1102     CleanupClosePushL( file );        
       
  1103     
       
  1104     if(datatype == KNotePadTextDataType())
  1099     if(datatype == KNotePadTextDataType())
  1105         {
  1100         {
  1106         const TDesC& notepadTitle = _L("NotePad");	
  1101         const TDesC& notepadTitle = _L("NotePad");
  1107         // file handle ownership transferred.
  1102         ret = CNotepadApi::ExecFileViewerL( aFile, 
  1108         
       
  1109         // 1.File handle from arg has problem for notes since junk chars are reported in file.
       
  1110         // so we use another file handle exclusively open with filename an pass to note viewer.   
       
  1111         // 
       
  1112         // 2.Pass ETrue to 4th param  ExecFileViewerL , to guess encoding.
       
  1113         RFile fileForNotes;
       
  1114         TInt err = fileForNotes.Open( fs, fileName, EFileRead | EFileShareReadersOnly );
       
  1115         CleanupClosePushL( fileForNotes );
       
  1116         ret = CNotepadApi::ExecFileViewerL( fileForNotes, 
       
  1117                                            &notepadTitle,
  1103                                            &notepadTitle,
  1118                                            ETrue,
  1104                                            ETrue,
  1119                                            ETrue,
  1105                                            ETrue,
  1120                                            KCharacterSetIdentifierIso88591 );
  1106                                            KCharacterSetIdentifierIso88591 );
  1121         
  1107         
  1122         CleanupStack::PopAndDestroy(&fileForNotes);
       
  1123         }
  1108         }
  1124     else
  1109     else
  1125         {
  1110         {
  1126         //doc handler will open the other files (other than text file).
  1111         //doc handler will open the other files (other than text file).
  1127         TRAP( ret, iDocHandler->OpenFileEmbeddedL( file, datatype ) );
  1112         TRAP( ret, iDocHandler->OpenFileEmbeddedL( aFile, datatype ) );
  1128         }
  1113         }
  1129     CleanupStack::PopAndDestroy(&file);
  1114 
  1130     
       
  1131     switch(ret)
  1115     switch(ret)
  1132         {
  1116         {
  1133         case KErrNone:
  1117         case KErrNone:
  1134             break;
  1118             break;
  1135         default:
  1119         default: