|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: mms creation mode checks |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "mmsconformancecheck.h" |
|
20 |
|
21 #include <MmsConformance.h> |
|
22 #include <centralrepository.h> |
|
23 #include <mmsconst.h> |
|
24 #include <MsgMediaInfo.h> |
|
25 #include <fileprotectionresolver.h> |
|
26 |
|
27 #include <MsgMediaResolver.h> |
|
28 #include <DRMHelper.h> |
|
29 #include <MmsEngineInternalCRKeys.h> |
|
30 #include <hbmessagebox.h> |
|
31 #include <HbNotificationDialog> |
|
32 #include <hbaction.h> |
|
33 |
|
34 #include "unidatamodelloader.h" |
|
35 #include "unidatamodelplugininterface.h" |
|
36 #include "UniEditorGenUtils.h" // This is needed for KDefaultMaxSize |
|
37 #include <xqconversions.h> |
|
38 #include "debugtraces.h" |
|
39 |
|
40 //DEFINES |
|
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") |
|
43 #define INSERT_PROTECTED_ERROR hbTrId("txt_messaging_dpopinfo_unable_to_attach_protected") |
|
44 #define INSERT_QUERY_CONFRM hbTrId("The receiving phone may not support this object. Continue?") |
|
45 // ----------------------------------------------------------------------------- |
|
46 // MmsConformanceCheck::MmsConformanceCheck |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 MmsConformanceCheck::MmsConformanceCheck() |
|
50 { |
|
51 QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck start"); |
|
52 |
|
53 TRAP_IGNORE( |
|
54 CRepository* repository = CRepository::NewL(KCRUidMmsEngine); |
|
55 CleanupStack::PushL(repository); |
|
56 |
|
57 //Fetch and set creation mode |
|
58 TInt creationMode = EMmsCreationModeRestricted; |
|
59 repository->Get(KMmsEngineCreationMode, creationMode); |
|
60 iCreationMode = creationMode; |
|
61 |
|
62 //Fetch and set max mms composition size |
|
63 TInt maxSize = KDefaultMaxSize; |
|
64 repository->Get( KMmsEngineMaximumSendSize, maxSize ); |
|
65 iMaxMmsSize = maxSize; |
|
66 |
|
67 CleanupStack::PopAndDestroy(repository); |
|
68 ); |
|
69 |
|
70 QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck end"); |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // MmsConformanceCheck::~MmsConformanceCheck |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 MmsConformanceCheck::~MmsConformanceCheck() |
|
78 { |
|
79 |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // MmsConformanceCheck::CheckModeForInsert |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 int MmsConformanceCheck::checkModeForInsert(const QString& file, |
|
87 bool showNote) |
|
88 { |
|
89 QDEBUG_WRITE("MmsConformanceCheck::CheckModeForInsert start"); |
|
90 HBufC* filePath = XQConversions::qStringToS60Desc(file); |
|
91 if (filePath) |
|
92 { |
|
93 TMsgMediaType mediaType = EMsgMediaUnknown; |
|
94 TUint32 mediaProtection = EFileProtNoProtection; |
|
95 |
|
96 QT_TRAP_THROWING(CleanupStack::PushL(filePath); |
|
97 |
|
98 CMmsConformance* mmsConformance = CMmsConformance::NewL(); |
|
99 mmsConformance->CheckCharacterSet(EFalse); |
|
100 |
|
101 CleanupStack::PushL(mmsConformance); |
|
102 |
|
103 CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL(); |
|
104 mediaResolver->SetCharacterSetRecognition(EFalse); |
|
105 |
|
106 CleanupStack::PushL(mediaResolver); |
|
107 |
|
108 RFile fileHandle = mediaResolver->FileHandleL(*filePath); |
|
109 CleanupClosePushL(fileHandle); |
|
110 |
|
111 CMsgMediaInfo* info = mediaResolver->CreateMediaInfoL(fileHandle); |
|
112 mediaResolver->ParseInfoDetailsL(info,fileHandle); |
|
113 |
|
114 TMmsConformance conformance = mmsConformance->MediaConformance(*info); |
|
115 iConfStatus = conformance.iConfStatus; |
|
116 |
|
117 mediaType = info->MediaType(); |
|
118 mediaProtection = info->Protection(); |
|
119 delete info; |
|
120 |
|
121 CleanupStack::PopAndDestroy(4)); |
|
122 |
|
123 // TODO: Remove this check once Video support is provided in UniEditor. |
|
124 if (mediaType == EMsgMediaVideo) |
|
125 { |
|
126 return EInsertNotSupported; |
|
127 } |
|
128 |
|
129 // In "free" mode user can insert images that are larger by dimensions than allowed by conformance |
|
130 if (iCreationMode != EMmsCreationModeRestricted) |
|
131 { |
|
132 TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded |
|
133 | EMmsConfNokTooBig; |
|
134 TInt j = ~ (EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded |
|
135 | EMmsConfNokTooBig); |
|
136 |
|
137 // If user answers yes to Guided mode confirmation query he/she moves to free mode |
|
138 if ( (iConfStatus & i) && ! (iConfStatus & j)) |
|
139 { |
|
140 if (iCreationMode == EMmsCreationModeFree || |
|
141 mediaProtection & EFileProtSuperDistributable) |
|
142 { |
|
143 // SuperDistribution not checked here |
|
144 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode |
|
145 iConfStatus &= ~EMmsConfNokFreeModeOnly; |
|
146 iConfStatus &= ~EMmsConfNokScalingNeeded; |
|
147 } |
|
148 else if (showNote) |
|
149 { |
|
150 HbMessageBox::question(INSERT_QUERY_CONFRM, this, |
|
151 SLOT(onDialogInsertMedia(HbAction*)), |
|
152 HbMessageBox::Yes | HbMessageBox::No); |
|
153 } |
|
154 else |
|
155 { |
|
156 //query not accepted. Stop insertion. |
|
157 return EInsertQueryAbort; |
|
158 } |
|
159 } |
|
160 } |
|
161 else if (iConfStatus & EMmsConfNokDRM || iConfStatus |
|
162 & EMmsConfNokNotEnoughInfo || iConfStatus |
|
163 & EMmsConfNokNotSupported || iConfStatus |
|
164 & EMmsConfNokFreeModeOnly || iConfStatus & EMmsConfNokCorrupt) |
|
165 { |
|
166 // Sanity check |
|
167 // "Not conformant" assumed if check fails. |
|
168 if(showNote) |
|
169 { |
|
170 // For protected objects. |
|
171 if (EFileProtNoProtection != mediaProtection) |
|
172 { |
|
173 showPopup(INSERT_PROTECTED_ERROR); |
|
174 } |
|
175 else |
|
176 { |
|
177 showPopup(INSERT_ERROR); |
|
178 } |
|
179 } |
|
180 return EInsertNotSupported; |
|
181 } |
|
182 } |
|
183 QDEBUG_WRITE("MmsConformanceCheck::CheckModeForInsert end"); |
|
184 return EInsertSuccess; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // MmsConformanceCheck::validateMsgForForward |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 bool MmsConformanceCheck::validateMsgForForward(int messageId) |
|
192 { |
|
193 UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
|
194 UniDataModelPluginInterface* pluginInterface = |
|
195 pluginLoader->getDataModelPlugin(ConvergedMessage::Mms); |
|
196 int error = pluginInterface->setMessageId(messageId); |
|
197 |
|
198 //Check if invalid id and slide count is greater than 1 |
|
199 if ( (error != KErrNone) || pluginInterface->slideCount() > 1) |
|
200 { |
|
201 delete pluginLoader; |
|
202 return false; |
|
203 } |
|
204 |
|
205 //Check if message size is inside max mms composition limits |
|
206 if (pluginInterface->messageSize() > iMaxMmsSize) |
|
207 { |
|
208 delete pluginLoader; |
|
209 return false; |
|
210 } |
|
211 |
|
212 //If there is restricted content then return false |
|
213 UniMessageInfoList slideContentList = pluginInterface->slideContent(0); |
|
214 bool retValue = true; |
|
215 |
|
216 for (int i = 0; i < slideContentList.size(); ++i) |
|
217 { |
|
218 if (checkModeForInsert(slideContentList.at(i)->path(), false) |
|
219 != EInsertSuccess) |
|
220 { |
|
221 retValue = false; |
|
222 break; |
|
223 } |
|
224 } |
|
225 |
|
226 foreach(UniMessageInfo *slide,slideContentList) |
|
227 { |
|
228 delete slide; |
|
229 } |
|
230 |
|
231 if (!retValue) |
|
232 { |
|
233 delete pluginLoader; |
|
234 return false; |
|
235 } |
|
236 |
|
237 UniMessageInfoList modelAttachmentList = pluginInterface->attachmentList(); |
|
238 |
|
239 for (int i = 0; i < modelAttachmentList.count(); ++i) |
|
240 { |
|
241 if (checkModeForInsert(modelAttachmentList.at(i)->path(), false) |
|
242 != EInsertSuccess) |
|
243 { |
|
244 retValue = false; |
|
245 break; |
|
246 } |
|
247 } |
|
248 |
|
249 foreach(UniMessageInfo *attachment,modelAttachmentList) |
|
250 { |
|
251 delete attachment; |
|
252 } |
|
253 |
|
254 delete pluginLoader; |
|
255 return retValue; |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // MmsConformanceCheck::onDialogInsertMedia |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void MmsConformanceCheck::onDialogInsertMedia(HbAction* action) |
|
263 { |
|
264 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
265 if (action == dlg->actions().at(0)) { |
|
266 // Query accepted. |
|
267 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode |
|
268 iConfStatus &= ~EMmsConfNokFreeModeOnly; |
|
269 iConfStatus &= ~EMmsConfNokScalingNeeded; |
|
270 } |
|
271 |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // MmsConformanceCheck::showPopup |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void MmsConformanceCheck::showPopup(const QString& text) |
|
279 { |
|
280 HbMessageBox::information(text, 0, 0, HbMessageBox::Ok); |
|
281 } |
|
282 |