messagingapp/msgutils/unieditorutils/unieditorplugins/unieditorsmsplugin/src/unieditorsmsplugin_p.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 43 35b64624a9e7
equal deleted inserted replaced
35:a32b19fb291e 47:5b14749788d7
    55 #include "msgbiouids.h"
    55 #include "msgbiouids.h"
    56 #include "unieditorsmsplugin_p.h"
    56 #include "unieditorsmsplugin_p.h"
    57 #include "convergedmessage.h"
    57 #include "convergedmessage.h"
    58 #include "convergedmessageid.h"
    58 #include "convergedmessageid.h"
    59 #include "convergedmessageattachment.h"
    59 #include "convergedmessageattachment.h"
    60 #include "s60qconversions.h"
    60 
    61 #include "MuiuOperationWait.h"
    61 #include "MuiuOperationWait.h"
    62 #include "UniEditorGenUtils.h"
    62 #include "UniEditorGenUtils.h"
    63 #include "unidatamodelloader.h"
    63 #include "unidatamodelloader.h"
    64 #include "unidatamodelplugininterface.h"
    64 #include "unidatamodelplugininterface.h"
    65 #include <hbglobal.h> // for translation support
    65 #include <hbglobal.h> // for translation support
    66 
    66 #include <xqconversions.h>
    67 // resources
    67 // resources
    68 
    68 
    69 // CONSTANTS
    69 // CONSTANTS
    70 
    70 
    71 // Used to set msg in unparsed state
    71 // Used to set msg in unparsed state
   434 
   434 
   435     ConvergedMessageAddressList addrList = message->toAddressList();
   435     ConvergedMessageAddressList addrList = message->toAddressList();
   436     int addrCount = addrList.count();
   436     int addrCount = addrList.count();
   437     for(int i=0; i<addrCount; i++)
   437     for(int i=0; i<addrCount; i++)
   438     {
   438     {
   439         HBufC* addr = S60QConversions::qStringToS60Desc( addrList.at(i)->address() );
   439         HBufC* addr = XQConversions::qStringToS60Desc( addrList.at(i)->address() );
   440         HBufC* alt_alias = S60QConversions::qStringToS60Desc( addrList.at(i)->alias() );
   440         HBufC* alt_alias = XQConversions::qStringToS60Desc( addrList.at(i)->alias() );
   441         if(addr->Length() > 0)
   441         if(addr->Length() > 0)
   442         {
   442         {
   443             CleanupStack::PushL(addr);
   443             CleanupStack::PushL(addr);
   444             if(alt_alias->Length() > 0)
   444             if(alt_alias->Length() > 0)
   445                 CleanupStack::PushL(alt_alias);
   445                 CleanupStack::PushL(alt_alias);
   503     {
   503     {
   504         // set iDetails
   504         // set iDetails
   505         CMsvEntry& entry = SmsMtmL()->Entry();
   505         CMsvEntry& entry = SmsMtmL()->Entry();
   506         TMsvEntry msvEntry( entry.Entry() );
   506         TMsvEntry msvEntry( entry.Entry() );
   507         msvEntry.iDetails.Set( idetailsBuf );
   507         msvEntry.iDetails.Set( idetailsBuf );
       
   508         entry.ChangeL( msvEntry );
   508         SmsMtmL()->SaveMessageL();
   509         SmsMtmL()->SaveMessageL();
   509         entry.ChangeL( msvEntry );
       
   510     }
   510     }
   511 
   511 
   512     // set subject
   512     // set subject
   513     if ( !message->subject().isEmpty() )
   513     if ( !message->subject().isEmpty() )
   514     {
   514     {
   515         HBufC* subj = S60QConversions::qStringToS60Desc( message->subject() );
   515         HBufC* subj = XQConversions::qStringToS60Desc( message->subject() );
   516         if( subj )
   516         if( subj )
   517         {
   517         {
   518             CleanupStack::PushL( subj );
   518             CleanupStack::PushL( subj );
   519             emailFields->SetSubjectL( *subj );
   519             emailFields->SetSubjectL( *subj );
   520             CleanupStack::PopAndDestroy( subj );
   520             CleanupStack::PopAndDestroy( subj );
   529 // SetSmsBodyL
   529 // SetSmsBodyL
   530 // @see header
   530 // @see header
   531 // -----------------------------------------------------------------------------
   531 // -----------------------------------------------------------------------------
   532 void UniEditorSmsPluginPrivate::SetSmsBodyL(ConvergedMessage* message)
   532 void UniEditorSmsPluginPrivate::SetSmsBodyL(ConvergedMessage* message)
   533 {
   533 {
   534     HBufC8* bodytext = S60QConversions::qStringToS60Desc8( message->bodyText() );
   534     HBufC8* bodytext = XQConversions::qStringToS60Desc8( message->bodyText() );
   535     if( bodytext->Length() > 0)
   535     if( bodytext->Length() > 0)
   536     {
   536     {
   537         CleanupStack::PushL( bodytext );
   537         CleanupStack::PushL( bodytext );
   538         RDesReadStream stream(*bodytext);
   538         RDesReadStream stream(*bodytext);
   539         CleanupClosePushL( stream );
   539         CleanupClosePushL( stream );
   583     QString descr;
   583     QString descr;
   584     if ( attachment )
   584     if ( attachment )
   585         {
   585         {
   586          // create msv attachment in store
   586          // create msv attachment in store
   587         CreateAttachmentL(store,
   587         CreateAttachmentL(store,
   588                 *S60QConversions::qStringToS60Desc(attachment->filePath()));
   588                 *XQConversions::qStringToS60Desc(attachment->filePath()));
   589         
   589         
   590         // check for mimetype of the attachment
   590         // check for mimetype of the attachment
   591         TPtrC8 mimetype;
   591         TPtrC8 mimetype;
   592         int attSize;
   592         int attSize;
   593         QString attMimeType;
   593         QString attMimeType;
   594         TMsgMediaType attMediaType = EMsgMediaUnknown;
   594         TMsgMediaType attMediaType = EMsgMediaUnknown;
   595         iGenUtils->getFileInfoL(attachment->filePath(),
   595         iGenUtils->getFileInfoL(attachment->filePath(),
   596                 attSize, attMimeType, attMediaType);
   596                 attSize, attMimeType, attMediaType);
   597         mimetype.Set( *S60QConversions::qStringToS60Desc8(attMimeType) );
   597         mimetype.Set( *XQConversions::qStringToS60Desc8(attMimeType) );
   598         
   598         
   599         if ( mimetype.CompareF( KMsgMimeTextPlain ) == 0 )
   599         if ( mimetype.CompareF( KMsgMimeTextPlain ) == 0 )
   600             {
   600             {
   601             iBioMsg=EFalse;
   601             iBioMsg=EFalse;
   602             }
   602             }
   632                 buf,
   632                 buf,
   633                 KSmsMessageEntryDescriptionAmountOfChars );    
   633                 KSmsMessageEntryDescriptionAmountOfChars );    
   634     }
   634     }
   635     else if(!descr.isNull())
   635     else if(!descr.isNull())
   636     {
   636     {
   637         buf.Copy( *S60QConversions::qStringToS60Desc(descr) );
   637         buf.Copy( *XQConversions::qStringToS60Desc(descr) );
   638     }
   638     }
   639     tEntry.iDescription.Set( buf );
   639     tEntry.iDescription.Set( buf );
   640 
   640 
   641     // save/commit all changes
   641     // save/commit all changes
   642     SmsMtmL()->SaveMessageL( *store, tEntry );
   642     SmsMtmL()->SaveMessageL( *store, tEntry );
   656     CleanupStack::PushL( attachment );
   656     CleanupStack::PushL( attachment );
   657 
   657 
   658     int attSize;
   658     int attSize;
   659     QString mimeType;
   659     QString mimeType;
   660     TMsgMediaType mediaType = EMsgMediaUnknown;
   660     TMsgMediaType mediaType = EMsgMediaUnknown;
   661     QString filepath = S60QConversions::s60DescToQString( aFilePath );
   661     QString filepath = XQConversions::s60DescToQString( aFilePath );
   662     iGenUtils->getFileInfoL(filepath, attSize, mimeType, mediaType);
   662     iGenUtils->getFileInfoL(filepath, attSize, mimeType, mediaType);
   663     
   663     
   664     attachment->SetSize( attSize );
   664     attachment->SetSize( attSize );
   665     attachment->SetMimeTypeL( *S60QConversions::qStringToS60Desc8(mimeType) );
   665     attachment->SetMimeTypeL( *XQConversions::qStringToS60Desc8(mimeType) );
   666     
   666     
   667     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
   667     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
   668     attachmentManager->AddAttachmentL( aFilePath, attachment, wait->iStatus );
   668     attachmentManager->AddAttachmentL( aFilePath, attachment, wait->iStatus );
   669     wait->Start();
   669     wait->Start();
   670     CleanupStack::PopAndDestroy( wait );
   670     CleanupStack::PopAndDestroy( wait );
   888             }
   888             }
   889         else if (mimetype.CompareF(KMsgMimeVCard) == 0)
   889         else if (mimetype.CompareF(KMsgMimeVCard) == 0)
   890             {
   890             {
   891             CreateVCardSMSL(filehandle);
   891             CreateVCardSMSL(filehandle);
   892             CleanupStack::Pop(&filehandle);
   892             CleanupStack::Pop(&filehandle);
   893             filehandle.Close();
   893             filehandle.Close();         
   894             managerSync.RemoveAttachmentL(0);
       
   895             }
   894             }
   896         else if (mimetype.CompareF(KMsgMimeVCal) == 0 || 
   895         else if (mimetype.CompareF(KMsgMimeVCal) == 0 || 
   897                  mimetype.CompareF(KMsgMimeICal) == 0)
   896                  mimetype.CompareF(KMsgMimeICal) == 0)
   898             {
   897             {
   899             CreateVCalSMSL(filehandle);
   898             CreateVCalSMSL(filehandle);
  1764         for( TInt id = 0; id < emailRecipients.MdcaCount( ); id++ )
  1763         for( TInt id = 0; id < emailRecipients.MdcaCount( ); id++ )
  1765             {
  1764             {
  1766             HBufC* pureAddr = TMmsGenUtils::PureAddress( emailRecipients.MdcaPoint( id ) ).AllocLC();
  1765             HBufC* pureAddr = TMmsGenUtils::PureAddress( emailRecipients.MdcaPoint( id ) ).AllocLC();
  1767             HBufC* aliasAddr = TMmsGenUtils::Alias( emailRecipients.MdcaPoint( id ) ).AllocLC();
  1766             HBufC* aliasAddr = TMmsGenUtils::Alias( emailRecipients.MdcaPoint( id ) ).AllocLC();
  1768             ConvergedMessageAddress messageAddress(
  1767             ConvergedMessageAddress messageAddress(
  1769                     S60QConversions::s60DescToQString(*pureAddr), 
  1768                     XQConversions::s60DescToQString(*pureAddr), 
  1770                     S60QConversions::s60DescToQString(*aliasAddr));
  1769                     XQConversions::s60DescToQString(*aliasAddr));
  1771             CleanupStack::PopAndDestroy(2, pureAddr );
  1770             CleanupStack::PopAndDestroy(2, pureAddr );
  1772             aMessage->addToRecipient(messageAddress);
  1771             aMessage->addToRecipient(messageAddress);
  1773             }
  1772             }
  1774         }
  1773         }
  1775 
  1774 
  1783             HBufC* pureAddr =
  1782             HBufC* pureAddr =
  1784                     TMmsGenUtils::PureAddress(smsRecipients[i]).AllocLC();
  1783                     TMmsGenUtils::PureAddress(smsRecipients[i]).AllocLC();
  1785             HBufC* aliasAddr =
  1784             HBufC* aliasAddr =
  1786                     TMmsGenUtils::Alias(smsRecipients[i]).AllocLC();
  1785                     TMmsGenUtils::Alias(smsRecipients[i]).AllocLC();
  1787             ConvergedMessageAddress messageAddress(
  1786             ConvergedMessageAddress messageAddress(
  1788                     S60QConversions::s60DescToQString(*pureAddr), 
  1787                     XQConversions::s60DescToQString(*pureAddr), 
  1789                     S60QConversions::s60DescToQString(*aliasAddr));
  1788                     XQConversions::s60DescToQString(*aliasAddr));
  1790             CleanupStack::PopAndDestroy(2, pureAddr );
  1789             CleanupStack::PopAndDestroy(2, pureAddr );
  1791             aMessage->addToRecipient(messageAddress);
  1790             aMessage->addToRecipient(messageAddress);
  1792             }
  1791             }
  1793         }
  1792         }
  1794 
  1793 
  1795     if( emailFields.Subject( ).Length( ) )
  1794     if( emailFields.Subject( ).Length( ) )
  1796         { // If email subject exists -> copy it
  1795         { // If email subject exists -> copy it
  1797         aMessage->setSubject(S60QConversions::s60DescToQString(
  1796         aMessage->setSubject(XQConversions::s60DescToQString(
  1798                 emailFields.Subject()));
  1797                 emailFields.Subject()));
  1799         }
  1798         }
  1800 
  1799 
  1801 }
  1800 }
  1802 
  1801 
  1819             //so we can directly extract it
  1818             //so we can directly extract it
  1820             CMsvStore* store = SmsMtmL()->Entry().EditStoreL();
  1819             CMsvStore* store = SmsMtmL()->Entry().EditStoreL();
  1821             CleanupStack::PushL( store );
  1820             CleanupStack::PushL( store );
  1822             MMsvAttachmentManager& manager = store->AttachmentManagerL();
  1821             MMsvAttachmentManager& manager = store->AttachmentManagerL();
  1823             CMsvAttachment *attachment = manager.GetAttachmentInfoL(0);
  1822             CMsvAttachment *attachment = manager.GetAttachmentInfoL(0);
  1824             QString filepath = S60QConversions::s60DescToQString(attachment->FilePath());
  1823             QString filepath = XQConversions::s60DescToQString(attachment->FilePath());
  1825             ConvergedMessageAttachment* conv_attachment = 
  1824             ConvergedMessageAttachment* conv_attachment = 
  1826                 new ConvergedMessageAttachment(filepath, ConvergedMessageAttachment::EAttachment);
  1825                 new ConvergedMessageAttachment(filepath, ConvergedMessageAttachment::EAttachment);
  1827             ConvergedMessageAttachmentList conv_attList;
  1826             ConvergedMessageAttachmentList conv_attList;
  1828             conv_attList << conv_attachment;
  1827             conv_attList << conv_attachment;
  1829             aMessage->addAttachments(conv_attList);
  1828             aMessage->addAttachments(conv_attList);
  1860         if ( totalLength > 0 )
  1859         if ( totalLength > 0 )
  1861         {
  1860         {
  1862             HBufC* bodyText = HBufC::NewLC ( totalLength ); 
  1861             HBufC* bodyText = HBufC::NewLC ( totalLength ); 
  1863             TPtr bodyTextPtr ( bodyText->Des() ); 
  1862             TPtr bodyTextPtr ( bodyText->Des() ); 
  1864             SmsMtmL()->Body().Extract( bodyTextPtr, 0, totalLength );
  1863             SmsMtmL()->Body().Extract( bodyTextPtr, 0, totalLength );
  1865             aMessage->setBodyText(S60QConversions::s60DescToQString(
  1864             aMessage->setBodyText(XQConversions::s60DescToQString(
  1866                 bodyTextPtr));
  1865                 bodyTextPtr));
  1867             CleanupStack::PopAndDestroy( bodyText );            
  1866             CleanupStack::PopAndDestroy( bodyText );            
  1868         }
  1867         }
  1869     }
  1868     }
  1870 }
  1869 }