31
|
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 "s60qconversions.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_QUERY_CONFRM hbTrId("The receiving phone may not support this object. Continue?")
|
|
44 |
// -----------------------------------------------------------------------------
|
|
45 |
// MmsConformanceCheck::MmsConformanceCheck
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
MmsConformanceCheck::MmsConformanceCheck()
|
|
49 |
{
|
|
50 |
QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck start");
|
|
51 |
|
|
52 |
TRAP_IGNORE(
|
|
53 |
CRepository* repository = CRepository::NewL(KCRUidMmsEngine);
|
|
54 |
CleanupStack::PushL(repository);
|
|
55 |
|
|
56 |
//Fetch and set creation mode
|
|
57 |
TInt creationMode = EMmsCreationModeRestricted;
|
|
58 |
repository->Get(KMmsEngineCreationMode, creationMode);
|
|
59 |
iCreationMode = creationMode;
|
|
60 |
|
|
61 |
//Fetch and set max mms composition size
|
|
62 |
TInt maxSize = KDefaultMaxSize;
|
|
63 |
repository->Get( KMmsEngineMaximumSendSize, maxSize );
|
|
64 |
iMaxMmsSize = maxSize;
|
|
65 |
|
|
66 |
CleanupStack::PopAndDestroy(repository);
|
|
67 |
);
|
|
68 |
|
|
69 |
QDEBUG_WRITE("MmsConformanceCheck::MmsConformanceCheck end");
|
|
70 |
}
|
|
71 |
|
|
72 |
// -----------------------------------------------------------------------------
|
|
73 |
// MmsConformanceCheck::~MmsConformanceCheck
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
MmsConformanceCheck::~MmsConformanceCheck()
|
|
77 |
{
|
|
78 |
|
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------
|
|
82 |
// MmsConformanceCheck::CheckModeForInsert
|
|
83 |
// ---------------------------------------------------------
|
|
84 |
//
|
|
85 |
int MmsConformanceCheck::checkModeForInsert(const QString& file,
|
|
86 |
bool showNote)
|
|
87 |
{
|
|
88 |
QDEBUG_WRITE("MmsConformanceCheck::CheckModeForInsert start");
|
|
89 |
HBufC* filePath = S60QConversions::qStringToS60Desc(file);
|
|
90 |
if (filePath)
|
|
91 |
{
|
|
92 |
CleanupStack::PushL(filePath);
|
|
93 |
|
|
94 |
CMmsConformance* mmsConformance = CMmsConformance::NewL();
|
|
95 |
mmsConformance->CheckCharacterSet(EFalse);
|
|
96 |
|
|
97 |
CleanupStack::PushL(mmsConformance);
|
|
98 |
|
|
99 |
CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL();
|
|
100 |
mediaResolver->SetCharacterSetRecognition(EFalse);
|
|
101 |
|
|
102 |
CleanupStack::PushL(mediaResolver);
|
|
103 |
|
|
104 |
RFile fileHandle = mediaResolver->FileHandleL(*filePath);
|
|
105 |
CleanupClosePushL(fileHandle);
|
|
106 |
|
|
107 |
CMsgMediaInfo* info = mediaResolver->CreateMediaInfoL(fileHandle);
|
|
108 |
mediaResolver->ParseInfoDetailsL(info,fileHandle);
|
|
109 |
|
|
110 |
TMmsConformance conformance = mmsConformance->MediaConformance(*info);
|
|
111 |
iConfStatus = conformance.iConfStatus;
|
|
112 |
|
|
113 |
CleanupStack::PopAndDestroy(4);
|
|
114 |
|
|
115 |
|
|
116 |
// In "free" mode user can insert images that are larger by dimensions than allowed by conformance
|
|
117 |
if (iCreationMode != EMmsCreationModeRestricted)
|
|
118 |
{
|
|
119 |
TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded
|
|
120 |
| EMmsConfNokTooBig;
|
|
121 |
TInt j = ~ (EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded
|
|
122 |
| EMmsConfNokTooBig);
|
|
123 |
|
|
124 |
// If user answers yes to Guided mode confirmation query he/she moves to free mode
|
|
125 |
if ( (iConfStatus & i) && ! (iConfStatus & j))
|
|
126 |
{
|
|
127 |
if (iCreationMode == EMmsCreationModeFree || info->Protection()
|
|
128 |
& EFileProtSuperDistributable)
|
|
129 |
{
|
|
130 |
// SuperDistribution not checked here
|
|
131 |
// Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
|
|
132 |
iConfStatus &= ~EMmsConfNokFreeModeOnly;
|
|
133 |
iConfStatus &= ~EMmsConfNokScalingNeeded;
|
|
134 |
}
|
|
135 |
else if (showNote)
|
|
136 |
{
|
|
137 |
HbMessageBox::question(INSERT_QUERY_CONFRM, this, SLOT(onDialogInsertMedia(HbAction*)));
|
|
138 |
}
|
|
139 |
else
|
|
140 |
{
|
|
141 |
//query not accepted. Stop insertion.
|
|
142 |
return EInsertQueryAbort;
|
|
143 |
}
|
|
144 |
}
|
|
145 |
}
|
|
146 |
else if (iConfStatus & EMmsConfNokDRM || iConfStatus
|
|
147 |
& EMmsConfNokNotEnoughInfo || iConfStatus
|
|
148 |
& EMmsConfNokNotSupported || iConfStatus
|
|
149 |
& EMmsConfNokFreeModeOnly || iConfStatus & EMmsConfNokCorrupt)
|
|
150 |
{
|
|
151 |
// Sanity check
|
|
152 |
// "Not conformant" assumed if check fails.
|
|
153 |
if(showNote)
|
|
154 |
{
|
|
155 |
showPopup(INSERT_ERROR);
|
|
156 |
}
|
|
157 |
|
|
158 |
return EInsertNotSupported;
|
|
159 |
}
|
|
160 |
delete info;
|
|
161 |
}
|
|
162 |
QDEBUG_WRITE("MmsConformanceCheck::CheckModeForInsert end");
|
|
163 |
return EInsertSuccess;
|
|
164 |
}
|
|
165 |
|
|
166 |
// ---------------------------------------------------------
|
|
167 |
// MmsConformanceCheck::validateMsgForForward
|
|
168 |
// ---------------------------------------------------------
|
|
169 |
//
|
|
170 |
bool MmsConformanceCheck::validateMsgForForward(int messageId)
|
|
171 |
{
|
|
172 |
UniDataModelLoader* pluginLoader = new UniDataModelLoader();
|
|
173 |
UniDataModelPluginInterface* pluginInterface =
|
|
174 |
pluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
|
|
175 |
pluginInterface->setMessageId(messageId);
|
|
176 |
|
|
177 |
//Check if slide count is greater than 1
|
|
178 |
if (pluginInterface->slideCount() > 1)
|
|
179 |
{
|
|
180 |
delete pluginLoader;
|
|
181 |
return false;
|
|
182 |
}
|
|
183 |
|
|
184 |
//Check if message size is inside max mms composition limits
|
|
185 |
if (pluginInterface->messageSize() > iMaxMmsSize)
|
|
186 |
{
|
|
187 |
return false;
|
|
188 |
}
|
|
189 |
|
|
190 |
//If there is restricted content then return false
|
|
191 |
UniMessageInfoList slideContentList = pluginInterface->slideContent(0);
|
|
192 |
bool retValue = true;
|
|
193 |
|
|
194 |
for (int i = 0; i < slideContentList.size(); ++i)
|
|
195 |
{
|
|
196 |
if (checkModeForInsert(slideContentList.at(i)->path(), false)
|
|
197 |
!= EInsertSuccess)
|
|
198 |
{
|
|
199 |
retValue = false;
|
|
200 |
break;
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
foreach(UniMessageInfo *slide,slideContentList)
|
|
205 |
{
|
|
206 |
delete slide;
|
|
207 |
}
|
|
208 |
|
|
209 |
if (!retValue)
|
|
210 |
{
|
|
211 |
delete pluginLoader;
|
|
212 |
|
|
213 |
return false;
|
|
214 |
}
|
|
215 |
|
|
216 |
UniMessageInfoList modelAttachmentList = pluginInterface->attachmentList();
|
|
217 |
|
|
218 |
for (int i = 0; i < modelAttachmentList.count(); ++i)
|
|
219 |
{
|
|
220 |
if (checkModeForInsert(modelAttachmentList.at(i)->path(), false)
|
|
221 |
!= EInsertSuccess)
|
|
222 |
{
|
|
223 |
retValue = false;
|
|
224 |
break;
|
|
225 |
}
|
|
226 |
}
|
|
227 |
|
|
228 |
foreach(UniMessageInfo *attachment,modelAttachmentList)
|
|
229 |
{
|
|
230 |
delete attachment;
|
|
231 |
}
|
|
232 |
|
|
233 |
delete pluginLoader;
|
|
234 |
|
|
235 |
return retValue;
|
|
236 |
}
|
|
237 |
|
|
238 |
// -----------------------------------------------------------------------------
|
|
239 |
// MmsConformanceCheck::onDialogInsertMedia
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
void MmsConformanceCheck::onDialogInsertMedia(HbAction* action)
|
|
243 |
{
|
|
244 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
|
|
245 |
if (action == dlg->actions().at(0)) {
|
|
246 |
// Query accepted.
|
|
247 |
// Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
|
|
248 |
iConfStatus &= ~EMmsConfNokFreeModeOnly;
|
|
249 |
iConfStatus &= ~EMmsConfNokScalingNeeded;
|
|
250 |
}
|
|
251 |
|
|
252 |
}
|
|
253 |
|
|
254 |
// -----------------------------------------------------------------------------
|
|
255 |
// MmsConformanceCheck::showPopup
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
//
|
|
258 |
void MmsConformanceCheck::showPopup(const QString& text)
|
|
259 |
{
|
|
260 |
HbNotificationDialog* dlg = new HbNotificationDialog();
|
|
261 |
dlg->setFocusPolicy(Qt::NoFocus);
|
|
262 |
dlg->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
263 |
dlg->setText(text);
|
|
264 |
dlg->show();
|
|
265 |
}
|
|
266 |
|