19 #include "mmsconformancecheck.h" |
19 #include "mmsconformancecheck.h" |
20 |
20 |
21 #include <MmsConformance.h> |
21 #include <MmsConformance.h> |
22 #include <centralrepository.h> |
22 #include <centralrepository.h> |
23 #include <mmsconst.h> |
23 #include <mmsconst.h> |
24 #include <msgmediainfo.h> |
24 #include <MsgMediaInfo.h> |
25 #include <fileprotectionresolver.h> |
25 #include <fileprotectionresolver.h> |
26 |
26 |
27 #include <MsgMediaResolver.h> |
27 #include <MsgMediaResolver.h> |
28 #include <DRMHelper.h> |
28 #include <DRMHelper.h> |
29 #include <MmsEngineInternalCRKeys.h> |
29 #include <MmsEngineInternalCRKeys.h> |
30 #include <hbmessagebox.h> |
30 #include <hbmessagebox.h> |
31 #include <hbnotificationdialog> |
31 #include <HbNotificationDialog> |
32 #include <hbaction.h> |
32 #include <hbaction.h> |
33 |
33 |
34 #include "unidatamodelloader.h" |
34 #include "unidatamodelloader.h" |
35 #include "unidatamodelplugininterface.h" |
35 #include "unidatamodelplugininterface.h" |
36 #include "unieditorgenutils.h" // This is needed for KDefaultMaxSize |
36 #include "UniEditorGenUtils.h" // This is needed for KDefaultMaxSize |
37 #include "s60qconversions.h" |
37 #include <xqconversions.h> |
38 #include "debugtraces.h" |
38 #include "debugtraces.h" |
39 |
39 |
40 //DEFINES |
40 //DEFINES |
41 #define RMODE_INSERT_ERROR hbTrId("Unable to insert. Object format not supported in restricted creation mode.") |
41 #define RMODE_INSERT_ERROR hbTrId("Unable to insert. Object format not supported in restricted creation mode.") |
42 #define INSERT_ERROR hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_file") |
42 #define INSERT_ERROR hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_file") |
|
43 #define INSERT_PROTECTED_ERROR hbTrId("txt_messaging_dpopinfo_unable_to_attach_protected") |
43 #define INSERT_QUERY_CONFRM hbTrId("The receiving phone may not support this object. Continue?") |
44 #define INSERT_QUERY_CONFRM hbTrId("The receiving phone may not support this object. Continue?") |
44 // ----------------------------------------------------------------------------- |
45 // ----------------------------------------------------------------------------- |
45 // MmsConformanceCheck::MmsConformanceCheck |
46 // MmsConformanceCheck::MmsConformanceCheck |
46 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
47 // |
48 // |
48 MmsConformanceCheck::MmsConformanceCheck() |
49 MmsConformanceCheck::MmsConformanceCheck() |
49 { |
50 { |
50 QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck start"); |
51 QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck start"); |
51 |
52 |
52 TRAP_IGNORE( |
53 TRAP_IGNORE( |
53 CRepository* repository = CRepository::NewL(KCRUidMmsEngine); |
54 CRepository* repository = CRepository::NewL(KCRUidMmsEngine); |
54 CleanupStack::PushL(repository); |
55 CleanupStack::PushL(repository); |
55 |
56 |
56 //Fetch and set creation mode |
57 //Fetch and set creation mode |
57 TInt creationMode = EMmsCreationModeRestricted; |
58 TInt creationMode = EMmsCreationModeRestricted; |
61 //Fetch and set max mms composition size |
62 //Fetch and set max mms composition size |
62 TInt maxSize = KDefaultMaxSize; |
63 TInt maxSize = KDefaultMaxSize; |
63 repository->Get( KMmsEngineMaximumSendSize, maxSize ); |
64 repository->Get( KMmsEngineMaximumSendSize, maxSize ); |
64 iMaxMmsSize = maxSize; |
65 iMaxMmsSize = maxSize; |
65 |
66 |
66 CleanupStack::PopAndDestroy(repository); |
67 CleanupStack::PopAndDestroy(repository); |
67 ); |
68 ); |
68 |
69 |
69 QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck end"); |
70 QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck end"); |
70 } |
71 } |
71 |
72 |
84 // |
85 // |
85 int MmsConformanceCheck::checkModeForInsert(const QString& file, |
86 int MmsConformanceCheck::checkModeForInsert(const QString& file, |
86 bool showNote) |
87 bool showNote) |
87 { |
88 { |
88 QDEBUG_WRITE("MmsConformanceCheck::CheckModeForInsert start"); |
89 QDEBUG_WRITE("MmsConformanceCheck::CheckModeForInsert start"); |
89 HBufC* filePath = S60QConversions::qStringToS60Desc(file); |
90 HBufC* filePath = XQConversions::qStringToS60Desc(file); |
90 if (filePath) |
91 if (filePath) |
91 { |
92 { |
92 CleanupStack::PushL(filePath); |
93 CleanupStack::PushL(filePath); |
93 |
94 |
94 CMmsConformance* mmsConformance = CMmsConformance::NewL(); |
95 CMmsConformance* mmsConformance = CMmsConformance::NewL(); |
95 mmsConformance->CheckCharacterSet(EFalse); |
96 mmsConformance->CheckCharacterSet(EFalse); |
96 |
97 |
97 CleanupStack::PushL(mmsConformance); |
98 CleanupStack::PushL(mmsConformance); |
98 |
99 |
99 CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL(); |
100 CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL(); |
100 mediaResolver->SetCharacterSetRecognition(EFalse); |
101 mediaResolver->SetCharacterSetRecognition(EFalse); |
101 |
102 |
102 CleanupStack::PushL(mediaResolver); |
103 CleanupStack::PushL(mediaResolver); |
103 |
104 |
104 RFile fileHandle = mediaResolver->FileHandleL(*filePath); |
105 RFile fileHandle = mediaResolver->FileHandleL(*filePath); |
105 CleanupClosePushL(fileHandle); |
106 CleanupClosePushL(fileHandle); |
106 |
107 |
107 CMsgMediaInfo* info = mediaResolver->CreateMediaInfoL(fileHandle); |
108 CMsgMediaInfo* info = mediaResolver->CreateMediaInfoL(fileHandle); |
108 mediaResolver->ParseInfoDetailsL(info,fileHandle); |
109 mediaResolver->ParseInfoDetailsL(info,fileHandle); |
109 |
110 |
110 TMmsConformance conformance = mmsConformance->MediaConformance(*info); |
111 TMmsConformance conformance = mmsConformance->MediaConformance(*info); |
111 iConfStatus = conformance.iConfStatus; |
112 iConfStatus = conformance.iConfStatus; |
112 |
113 |
113 CleanupStack::PopAndDestroy(4); |
114 CleanupStack::PopAndDestroy(4); |
114 |
115 |
115 |
116 |
116 // In "free" mode user can insert images that are larger by dimensions than allowed by conformance |
117 // In "free" mode user can insert images that are larger by dimensions than allowed by conformance |
117 if (iCreationMode != EMmsCreationModeRestricted) |
118 if (iCreationMode != EMmsCreationModeRestricted) |
118 { |
119 { |
119 TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded |
120 TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded |
120 | EMmsConfNokTooBig; |
121 | EMmsConfNokTooBig; |
132 iConfStatus &= ~EMmsConfNokFreeModeOnly; |
133 iConfStatus &= ~EMmsConfNokFreeModeOnly; |
133 iConfStatus &= ~EMmsConfNokScalingNeeded; |
134 iConfStatus &= ~EMmsConfNokScalingNeeded; |
134 } |
135 } |
135 else if (showNote) |
136 else if (showNote) |
136 { |
137 { |
137 HbMessageBox::question(INSERT_QUERY_CONFRM, this, SLOT(onDialogInsertMedia(HbAction*))); |
138 HbMessageBox::question(INSERT_QUERY_CONFRM, this, |
|
139 SLOT(onDialogInsertMedia(HbAction*)), |
|
140 HbMessageBox::Yes | HbMessageBox::No); |
138 } |
141 } |
139 else |
142 else |
140 { |
143 { |
141 //query not accepted. Stop insertion. |
144 //query not accepted. Stop insertion. |
142 return EInsertQueryAbort; |
145 return EInsertQueryAbort; |
170 bool MmsConformanceCheck::validateMsgForForward(int messageId) |
181 bool MmsConformanceCheck::validateMsgForForward(int messageId) |
171 { |
182 { |
172 UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
183 UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
173 UniDataModelPluginInterface* pluginInterface = |
184 UniDataModelPluginInterface* pluginInterface = |
174 pluginLoader->getDataModelPlugin(ConvergedMessage::Mms); |
185 pluginLoader->getDataModelPlugin(ConvergedMessage::Mms); |
175 pluginInterface->setMessageId(messageId); |
186 int error = pluginInterface->setMessageId(messageId); |
176 |
187 |
177 //Check if slide count is greater than 1 |
188 //Check if invalid id and slide count is greater than 1 |
178 if (pluginInterface->slideCount() > 1) |
189 if ( (error != KErrNone) || pluginInterface->slideCount() > 1) |
179 { |
190 { |
180 delete pluginLoader; |
191 delete pluginLoader; |
181 return false; |
192 return false; |
182 } |
193 } |
183 |
194 |
184 //Check if message size is inside max mms composition limits |
195 //Check if message size is inside max mms composition limits |
185 if (pluginInterface->messageSize() > iMaxMmsSize) |
196 if (pluginInterface->messageSize() > iMaxMmsSize) |
186 { |
197 { |
|
198 delete pluginLoader; |
187 return false; |
199 return false; |
188 } |
200 } |
189 |
201 |
190 //If there is restricted content then return false |
202 //If there is restricted content then return false |
191 UniMessageInfoList slideContentList = pluginInterface->slideContent(0); |
203 UniMessageInfoList slideContentList = pluginInterface->slideContent(0); |