localconnectivityservice/obexserviceman/utils/src/obexutilsmessagehandler.cpp
branchRCL_3
changeset 38 3dcb815346df
parent 15 c47ebe2ac36c
equal deleted inserted replaced
37:7e0ecb5b116a 38:3dcb815346df
   331         // Don't trust on sender's MIME type here. Just set to empty.
   331         // Don't trust on sender's MIME type here. Just set to empty.
   332         mimeType.Set(KNullDesC8);
   332         mimeType.Set(KNullDesC8);
   333         FLOG(_L("[OBEXUTILS]\t RecogniseObjectsL() MIME check failed"));
   333         FLOG(_L("[OBEXUTILS]\t RecogniseObjectsL() MIME check failed"));
   334         }
   334         }
   335     CleanupStack::PopAndDestroy();  // lsSess
   335     CleanupStack::PopAndDestroy();  // lsSess
       
   336     
   336     HBufC* buf16 = HBufC::NewLC(mimeType.Length());
   337     HBufC* buf16 = HBufC::NewLC(mimeType.Length());
   337     buf16->Des().Copy(mimeType);
   338     buf16->Des().Copy(mimeType);
   338     TPtrC mimeType16(buf16->Des());
   339     TPtrC mimeType16(buf16->Des());
   339     CleanupStack::PopAndDestroy();   //   buf16
   340     CleanupStack::PopAndDestroy();   //   buf16
   340     
   341     
   341     CUpdateMusicCollection* updateMusicCollection = CUpdateMusicCollection::NewL() ;
   342     CUpdateMusicCollection* updateMusicCollection = CUpdateMusicCollection::NewL();
       
   343     CleanupStack::PushL(updateMusicCollection);    
   342     if (updateMusicCollection->isSupported(mimeType16))
   344     if (updateMusicCollection->isSupported(mimeType16))
   343         {
   345         {
   344         updateMusicCollection->addToCollectionL(aFileName);
   346         updateMusicCollection->addToCollectionL(aFileName);
   345         }
   347         }
       
   348     CleanupStack::PopAndDestroy();  // updateMusicCollection
   346     
   349     
   347     aAttachInfo->SetMimeTypeL( mimeType );
   350     aAttachInfo->SetMimeTypeL( mimeType );
       
   351     
   348     
   352     
   349     FLOG(_L("[OBEXUTILS]\t RecogniseObjectsL() completed"));
   353     FLOG(_L("[OBEXUTILS]\t RecogniseObjectsL() completed"));
   350     }
   354     }
   351 
   355 
   352 // -----------------------------------------------------------------------------
   356 // -----------------------------------------------------------------------------
   925     //
   929     //
   926     // Set file back to visible
   930     // Set file back to visible
   927     //
   931     //
   928     TUint setAttMask(0);
   932     TUint setAttMask(0);
   929     TUint clearAttMask(0);
   933     TUint clearAttMask(0);
   930     User::LeaveIfError(aFile.Open(fsSess,tempFullName,EFileWrite));
   934     User::LeaveIfError(aFile.Open(fsSess,tempFullName,EFileWrite|EFileShareReadersOrWriters));
   931     User::LeaveIfError(aFile.SetAtt(setAttMask , clearAttMask | KEntryAttHidden));
   935     User::LeaveIfError(aFile.SetAtt(setAttMask , clearAttMask | KEntryAttHidden));
   932     aFile.Close();
   936     aFile.Close();
   933     
   937     
   934     
   938     
   935     // Move file to the actual drive and directory
   939     // Move file to the actual drive and directory
   998     if (bioDB)  // bio message
  1002     if (bioDB)  // bio message
   999         {
  1003         {
  1000         FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO"));
  1004         FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO"));
  1001     
  1005     
  1002         RFile file;
  1006         RFile file;
  1003         User::LeaveIfError(file.Open(fsSess,aFullName,EFileRead));
  1007         User::LeaveIfError(file.Open(fsSess,aFullName,EFileRead|EFileShareReadersOrWriters));
  1004         TReceivedData receivedData;
  1008         TReceivedData receivedData;
  1005         receivedData.bytesReceived = fileEntry.iSize;
  1009         receivedData.bytesReceived = fileEntry.iSize;
  1006         receivedData.recTime = fileEntry.iModified;
  1010         receivedData.recTime = fileEntry.iModified;
  1007         receivedData.msgName = fileNameParser.Name();     
  1011         receivedData.msgName = fileNameParser.Name();     
  1008                     
  1012                     
  1054 //
  1058 //
  1055 EXPORT_C void TObexUtilsMessageHandler::UpdateEntryAttachmentL ( 
  1059 EXPORT_C void TObexUtilsMessageHandler::UpdateEntryAttachmentL ( 
  1056     TFileName& aFullName,
  1060     TFileName& aFullName,
  1057     CMsvEntry* aParentEntry)
  1061     CMsvEntry* aParentEntry)
  1058     {
  1062     {
       
  1063     
  1059     FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::UpdateEntryAttachmentL() "));
  1064     FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::UpdateEntryAttachmentL() "));
  1060     CDummySessionObserver* sessionObs;
  1065     CDummySessionObserver* sessionObs;
  1061     CMsvSession* msvSession;
  1066     CMsvSession* msvSession;
  1062     CreateMsvSessionLC(sessionObs, msvSession);
  1067     CreateMsvSessionLC(sessionObs, msvSession);
  1063     // 1st, 2nd push
  1068     // 1st, 2nd push
  1064       
  1069     
  1065     CMsvEntry* attachEntry = msvSession->GetEntryL(((*aParentEntry)[0]).Id());
  1070     CMsvEntry* attachEntry = msvSession->GetEntryL(((*aParentEntry)[0]).Id());
  1066     CleanupStack::PushL(attachEntry); // 3th push
  1071     CleanupStack::PushL(attachEntry); // 3th push
  1067             
  1072           
  1068     CMsvStore* store = attachEntry->EditStoreL();
  1073     CMsvStore* store = attachEntry->EditStoreL();
  1069     CleanupStack::PushL( store );  // 4th push
  1074     CleanupStack::PushL( store );  // 4th push
  1070   
  1075    
  1071     CObexutilsEntryhandler* entryHandler = CObexutilsEntryhandler::NewL();
  1076     CObexutilsEntryhandler* entryHandler = CObexutilsEntryhandler::NewL();
  1072     CleanupStack::PushL(entryHandler);  // 5th push  
  1077     CleanupStack::PushL(entryHandler);  // 5th push  
  1073     
  1078     
  1074     // Note:
  1079     // Note:
  1075     // Because setFilePath() in CMsvAttachment is not implementated by Symbian yet, 
  1080     // Because setFilePath() in CMsvAttachment is not implementated by Symbian yet, 
  1076     // we have to delete the original attachment and add another new one to fix the broken link.
  1081     // we have to delete the original attachment and add another new one to fix the broken link.
  1077     //
  1082     //    
  1078     
       
  1079     // remove the old attachment first.
  1083     // remove the old attachment first.
  1080     //
  1084     //
  1081     store->AttachmentManagerExtensionsL().RemoveAttachmentL(0);
  1085     store->AttachmentManagerExtensionsL().RemoveAttachmentL(0);
       
  1086 
  1082     // Create a new attachment.
  1087     // Create a new attachment.
  1083     //
  1088     //
       
  1089     
  1084     CMsvAttachment* attachInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
  1090     CMsvAttachment* attachInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
  1085     CleanupStack::PushL(attachInfo);  // 6th  push
  1091     CleanupStack::PushL(attachInfo);  // 6th  push
  1086     
  1092     
  1087     // Get mime type
  1093     // Get mime type
  1088     //
  1094     //
  1089     RecogniseObjectsL(aFullName, attachInfo);
  1095     RecogniseObjectsL(aFullName, attachInfo);
       
  1096    
  1090     RFs& fsSess = msvSession->FileSession();
  1097     RFs& fsSess = msvSession->FileSession();
  1091     
  1098     
  1092     TParse fileNameParser;
  1099     TParse fileNameParser;
  1093     User::LeaveIfError(fileNameParser.Set(aFullName, NULL, NULL));
  1100     User::LeaveIfError(fileNameParser.Set(aFullName, NULL, NULL));
  1094     attachInfo->SetAttachmentNameL(fileNameParser.NameAndExt());
  1101     attachInfo->SetAttachmentNameL(fileNameParser.NameAndExt());
  1097     attachInfo->SetSize(fileEntry.iSize);
  1104     attachInfo->SetSize(fileEntry.iSize);
  1098 
  1105 
  1099     entryHandler->AddEntryAttachment(aFullName,attachInfo, store);
  1106     entryHandler->AddEntryAttachment(aFullName,attachInfo, store);
  1100     CleanupStack::Pop(attachInfo);   // attachInfo, Pass ownership to store
  1107     CleanupStack::Pop(attachInfo);   // attachInfo, Pass ownership to store
  1101     CleanupStack::PopAndDestroy(entryHandler);  // entryHandler
  1108     CleanupStack::PopAndDestroy(entryHandler);  // entryHandler
  1102     FinaliseMessageL(aParentEntry, store,fileEntry, fileNameParser);
  1109     FinaliseMessageL(aParentEntry, store,fileEntry, fileNameParser);    
  1103     CleanupStack::PopAndDestroy(4);   // store, 
  1110     CleanupStack::PopAndDestroy(4);   // store, 
  1104                                       // attachEntry, msvSession, sessionObs
  1111                                       // attachEntry, msvSession, sessionObs                                                                                    
  1105     FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::UpdateEntryAttachmentL() completed "));
  1112     FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::UpdateEntryAttachmentL() completed "));
       
  1113     
  1106     }
  1114     }
  1107 
  1115 
  1108 
  1116 
  1109 // Common methods
  1117 // Common methods
  1110 
  1118