messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp
equal
deleted
inserted
replaced
41 #include <MsgMediaResolver.h> |
41 #include <MsgMediaResolver.h> |
42 |
42 |
43 #include "UniSendingSettings.h" |
43 #include "UniSendingSettings.h" |
44 #include "unidatamodelloader.h" |
44 #include "unidatamodelloader.h" |
45 #include "unidatamodelplugininterface.h" |
45 #include "unidatamodelplugininterface.h" |
46 #include "s60qconversions.h" |
46 #include <xqconversions.h> |
47 #include "debugtraces.h" |
47 #include "debugtraces.h" |
48 #include "UniEditorGenUtils.h" |
48 #include "UniEditorGenUtils.h" |
49 |
49 |
50 // Possible values for mms validity period in seconds |
50 // Possible values for mms validity period in seconds |
51 const TInt32 KUniMmsValidityPeriod1h = 3600; |
51 const TInt32 KUniMmsValidityPeriod1h = 3600; |
87 delete iEditor; |
87 delete iEditor; |
88 delete iDom; |
88 delete iDom; |
89 delete iUniDataModel; |
89 delete iUniDataModel; |
90 ifsSession.Close(); |
90 ifsSession.Close(); |
91 |
91 |
92 delete iMmsMtm; |
92 if(iMmsMtm) |
|
93 { |
|
94 delete iMmsMtm; |
|
95 } |
|
96 |
93 delete iMtmRegistry; |
97 delete iMtmRegistry; |
94 delete iDataModelPluginLoader; |
98 delete iDataModelPluginLoader; |
95 delete iSession; |
99 |
|
100 if(iSession) |
|
101 { |
|
102 delete iSession; |
|
103 } |
96 } |
104 } |
97 |
105 |
98 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
99 // C++ default constructor |
107 // C++ default constructor |
100 // @see Header |
108 // @see Header |
101 // ----------------------------------------------------------------------------- |
109 // ----------------------------------------------------------------------------- |
102 // |
110 // |
103 CUniEditorMmsPluginPrivate::CUniEditorMmsPluginPrivate( ) |
111 CUniEditorMmsPluginPrivate::CUniEditorMmsPluginPrivate( ) |
104 { |
112 { |
105 iSession = CMsvSession::OpenSyncL(*this); |
113 TRAP_IGNORE(iSession = CMsvSession::OpenSyncL(*this)); |
106 } |
114 } |
107 |
115 |
108 // ----------------------------------------------------------------------------- |
116 // ----------------------------------------------------------------------------- |
109 // convertFromL |
117 // convertFromL |
110 // @see Header |
118 // @see Header |
157 |
165 |
158 //Populate recipients |
166 //Populate recipients |
159 populateRecipientsL(aMessage); |
167 populateRecipientsL(aMessage); |
160 |
168 |
161 //populate convergedmessage with the subject |
169 //populate convergedmessage with the subject |
162 aMessage.setSubject(S60QConversions::s60DescToQString( |
170 aMessage.setSubject(XQConversions::s60DescToQString( |
163 MmsMtmL()->SubjectL())); |
171 MmsMtmL()->SubjectL())); |
164 |
172 |
165 // Priority |
173 // Priority |
166 TMsvPriority priority = entry.Priority(); |
174 TMsvPriority priority = entry.Priority(); |
167 if( EMsvHighPriority == priority ) |
175 if( EMsvHighPriority == priority ) |
194 // |
202 // |
195 void CUniEditorMmsPluginPrivate::convertFromForwardHandlerL( |
203 void CUniEditorMmsPluginPrivate::convertFromForwardHandlerL( |
196 ConvergedMessage &aMessage) |
204 ConvergedMessage &aMessage) |
197 { |
205 { |
198 QDEBUG_WRITE("Enter convertFromForwardHandlerL"); |
206 QDEBUG_WRITE("Enter convertFromForwardHandlerL"); |
199 |
207 iMessageForwarded = EFalse; |
200 TMsvEntry entry =MmsMtmL()->Entry().Entry(); |
208 TMsvEntry entry = MmsMtmL()->Entry().Entry(); |
201 |
209 |
202 //populate convergedmessage with the subject prepended with FW: |
210 //populate convergedmessage with the subject prepended with FW: |
203 QString subject = LOC_FWD + S60QConversions::s60DescToQString( |
211 QString subject = |
204 MmsMtmL()->SubjectL()); |
212 XQConversions::s60DescToQString(MmsMtmL()->SubjectL()); |
|
213 |
|
214 if (!(entry.Forwarded() || subject.startsWith(LOC_FWD, |
|
215 Qt::CaseInsensitive))) |
|
216 { |
|
217 subject.insert(0, LOC_FWD); |
|
218 iMessageForwarded = ETrue; |
|
219 } |
|
220 |
205 aMessage.setSubject(subject); |
221 aMessage.setSubject(subject); |
206 |
222 |
207 // Priority |
223 // Priority |
208 TMsvPriority priority = entry.Priority(); |
224 TMsvPriority priority = entry.Priority(); |
209 if( EMsvHighPriority == priority ) |
225 if( EMsvHighPriority == priority ) |
258 { |
274 { |
259 if( slideContentList.at(i)->mimetype().contains("text") ) |
275 if( slideContentList.at(i)->mimetype().contains("text") ) |
260 { |
276 { |
261 QString textContent; |
277 QString textContent; |
262 QFile file(slideContentList.at(i)->path()); |
278 QFile file(slideContentList.at(i)->path()); |
263 file.open(QIODevice::ReadOnly); |
279 if (file.open(QIODevice::ReadOnly)) { |
264 textContent = file.readAll(); |
280 textContent = file.readAll(); |
265 aMessage.setBodyText(textContent); |
281 aMessage.setBodyText(textContent); |
266 file.close(); |
282 file.close(); |
|
283 } |
|
284 else { |
|
285 return; |
|
286 } |
267 } |
287 } |
268 else |
288 else |
269 { |
289 { |
270 ConvergedMessageAttachment* attachment = |
290 ConvergedMessageAttachment* attachment = |
271 new ConvergedMessageAttachment( |
291 new ConvergedMessageAttachment( |
372 //Add recipients |
392 //Add recipients |
373 addRecipientsL(aMessage); |
393 addRecipientsL(aMessage); |
374 |
394 |
375 //There is no size check inside plugin as it assumes |
395 //There is no size check inside plugin as it assumes |
376 //we get proper data from editor |
396 //we get proper data from editor |
377 HBufC* sub = S60QConversions::qStringToS60Desc(aMessage->subject()); |
397 entry = MmsMtmL()->Entry().Entry(); |
|
398 if (iMessageForwarded) |
|
399 { |
|
400 entry.SetForwarded(ETrue); |
|
401 iMessageForwarded = EFalse; |
|
402 } |
|
403 HBufC* sub = XQConversions::qStringToS60Desc(aMessage->subject()); |
378 if( sub ) |
404 if( sub ) |
379 { |
405 { |
380 CleanupStack::PushL(sub); |
406 CleanupStack::PushL(sub); |
381 MmsMtmL()->SetSubjectL( *sub ); |
407 MmsMtmL()->SetSubjectL( *sub ); |
382 CleanupStack::PopAndDestroy(sub); |
408 CleanupStack::PopAndDestroy(sub); |
497 } |
523 } |
498 |
524 |
499 //Saving the changes |
525 //Saving the changes |
500 MmsMtmL()->SaveMessageL(); |
526 MmsMtmL()->SaveMessageL(); |
501 |
527 |
|
528 |
502 entry = MmsMtmL()->Entry().Entry(); |
529 entry = MmsMtmL()->Entry().Entry(); |
503 |
|
504 TBuf<KMaxDetailsLength> detailsBuf; |
530 TBuf<KMaxDetailsLength> detailsBuf; |
505 MakeDetailsL( detailsBuf ); |
531 MakeDetailsL( detailsBuf ); |
506 entry.iDetails.Set( detailsBuf ); |
532 entry.iDetails.Set( detailsBuf ); |
507 |
533 |
508 MmsMtmL()->Entry().ChangeL(entry); // commit changes |
534 MmsMtmL()->Entry().ChangeL(entry); // commit changes |
568 // @see Header |
594 // @see Header |
569 // ----------------------------------------------------------------------------- |
595 // ----------------------------------------------------------------------------- |
570 // |
596 // |
571 CMmsClientMtm* CUniEditorMmsPluginPrivate::MmsMtmL() |
597 CMmsClientMtm* CUniEditorMmsPluginPrivate::MmsMtmL() |
572 { |
598 { |
573 if ( !iMmsMtm ) |
599 if ( !iMmsMtm && iSession ) |
574 { |
600 { |
575 if ( !iMtmRegistry ) |
601 if ( !iMtmRegistry ) |
576 { |
602 { |
577 iMtmRegistry = CClientMtmRegistry::NewL( *iSession ); |
603 iMtmRegistry = CClientMtmRegistry::NewL( *iSession ); |
578 } |
604 } |
698 if(array[i]->address().isEmpty()) |
724 if(array[i]->address().isEmpty()) |
699 { |
725 { |
700 continue; |
726 continue; |
701 } |
727 } |
702 // convert from QString to HBufC |
728 // convert from QString to HBufC |
703 HBufC* addr = S60QConversions::qStringToS60Desc(array[i]->address()); |
729 HBufC* addr = XQConversions::qStringToS60Desc(array[i]->address()); |
704 |
730 |
705 CleanupStack::PushL(addr); |
731 CleanupStack::PushL(addr); |
706 |
732 |
707 if(TMmsGenUtils::Alias(*addr).Length() > 0) |
733 if(TMmsGenUtils::Alias(*addr).Length() > 0) |
708 { |
734 { |
709 MmsMtmL()->AddAddresseeL(recpType, TMmsGenUtils::PureAddress(*addr), |
735 MmsMtmL()->AddAddresseeL(recpType, TMmsGenUtils::PureAddress(*addr), |
710 TMmsGenUtils::Alias(*addr)); |
736 TMmsGenUtils::Alias(*addr)); |
711 } |
737 } |
712 else |
738 else |
713 { |
739 { |
714 HBufC* displayName = S60QConversions::qStringToS60Desc(array[i]->alias()); |
740 HBufC* displayName = XQConversions::qStringToS60Desc(array[i]->alias()); |
715 if(displayName) |
741 if(displayName) |
716 { |
742 { |
717 CleanupStack::PushL(displayName); |
743 CleanupStack::PushL(displayName); |
718 |
744 |
719 MmsMtmL()->AddAddresseeL(recpType, TMmsGenUtils::PureAddress(*addr), |
745 MmsMtmL()->AddAddresseeL(recpType, TMmsGenUtils::PureAddress(*addr), |
747 |
773 |
748 // extract each address and populate into ConvergedMessageAddress |
774 // extract each address and populate into ConvergedMessageAddress |
749 for (TInt i = 0; i < count; ++i) |
775 for (TInt i = 0; i < count; ++i) |
750 { |
776 { |
751 //Address |
777 //Address |
752 QString address = S60QConversions::s60DescToQString( |
778 QString address = XQConversions::s60DescToQString( |
753 TMmsGenUtils::PureAddress(addresses[i])); |
779 TMmsGenUtils::PureAddress(addresses[i])); |
754 //Alias |
780 //Alias |
755 QString alias = S60QConversions::s60DescToQString( |
781 QString alias = XQConversions::s60DescToQString( |
756 TMmsGenUtils::Alias(addresses[i])); |
782 TMmsGenUtils::Alias(addresses[i])); |
757 |
783 |
758 //add recipient to convergedMessage |
784 //add recipient to convergedMessage |
759 ConvergedMessageAddress messageAddress(address, alias); |
785 ConvergedMessageAddress messageAddress(address, alias); |
760 if (addresses.Type(i) == EMsvRecipientTo) |
786 if (addresses.Type(i) == EMsvRecipientTo) |
780 // @see header |
806 // @see header |
781 // ---------------------------------------------------------------------------- |
807 // ---------------------------------------------------------------------------- |
782 // |
808 // |
783 void CUniEditorMmsPluginPrivate::deleteDraftsEntryL( TMsvId aId ) |
809 void CUniEditorMmsPluginPrivate::deleteDraftsEntryL( TMsvId aId ) |
784 { |
810 { |
785 CMsvEntry* pEntry = iSession->GetEntryL(KMsvDraftEntryIdValue); |
811 if(iSession) |
786 CleanupStack::PushL(pEntry); |
812 { |
787 pEntry->DeleteL( aId ); |
813 CMsvEntry* pEntry = iSession->GetEntryL(KMsvDraftEntryIdValue); |
788 CleanupStack::PopAndDestroy(pEntry); |
814 CleanupStack::PushL(pEntry); |
|
815 pEntry->DeleteL( aId ); |
|
816 CleanupStack::PopAndDestroy(pEntry); |
|
817 } |
789 } |
818 } |
790 |
819 |
791 |
820 |
792 // ----------------------------------------------------------------------------- |
821 // ----------------------------------------------------------------------------- |
793 // addObjectL |
822 // addObjectL |
795 // ----------------------------------------------------------------------------- |
824 // ----------------------------------------------------------------------------- |
796 // |
825 // |
797 void CUniEditorMmsPluginPrivate::addObjectL(int aSlideNum, const QString& aFilePath) |
826 void CUniEditorMmsPluginPrivate::addObjectL(int aSlideNum, const QString& aFilePath) |
798 { |
827 { |
799 |
828 |
800 HBufC* filePath = S60QConversions::qStringToS60Desc(aFilePath); |
829 HBufC* filePath = XQConversions::qStringToS60Desc(aFilePath); |
801 |
830 |
802 if (filePath) |
831 if (filePath) |
803 { |
832 { |
804 CleanupStack::PushL(filePath); |
833 CleanupStack::PushL(filePath); |
805 RFile file = iUniDataModel->MediaResolver().FileHandleL(*filePath); |
834 RFile file = iUniDataModel->MediaResolver().FileHandleL(*filePath); |
824 // @see Header |
853 // @see Header |
825 // ----------------------------------------------------------------------------- |
854 // ----------------------------------------------------------------------------- |
826 // |
855 // |
827 void CUniEditorMmsPluginPrivate::addAttachmentL(const QString& aFilePath) |
856 void CUniEditorMmsPluginPrivate::addAttachmentL(const QString& aFilePath) |
828 { |
857 { |
829 HBufC * filePath = S60QConversions::qStringToS60Desc(aFilePath); |
858 HBufC * filePath = XQConversions::qStringToS60Desc(aFilePath); |
830 if (filePath) |
859 if (filePath) |
831 { |
860 { |
832 CleanupStack::PushL(filePath); |
861 CleanupStack::PushL(filePath); |
833 |
862 |
834 RFile file = iUniDataModel->MediaResolver().FileHandleL(*filePath); |
863 RFile file = iUniDataModel->MediaResolver().FileHandleL(*filePath); |
859 void CUniEditorMmsPluginPrivate::addTextObjectL(int aSlideNum, const QString& aBodyText) |
888 void CUniEditorMmsPluginPrivate::addTextObjectL(int aSlideNum, const QString& aBodyText) |
860 { |
889 { |
861 delete iEditor; |
890 delete iEditor; |
862 iEditor = NULL; |
891 iEditor = NULL; |
863 |
892 |
864 HBufC* textContent = S60QConversions::qStringToS60Desc(aBodyText); |
893 HBufC* textContent = XQConversions::qStringToS60Desc(aBodyText); |
865 if (textContent) |
894 if (textContent) |
866 { |
895 { |
867 CleanupStack::PushL(textContent); |
896 CleanupStack::PushL(textContent); |
868 |
897 |
869 iEditor = new CEikRichTextEditor; |
898 iEditor = new CEikRichTextEditor; |