author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 13:35:48 +0300 | |
changeset 34 | 84197e66a4bd |
parent 31 | ebfee66fde93 |
child 43 | 35b64624a9e7 |
permissions | -rw-r--r-- |
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> |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
24 |
#include <MsgMediaInfo.h> |
31 | 25 |
#include <fileprotectionresolver.h> |
26 |
||
27 |
#include <MsgMediaResolver.h> |
|
28 |
#include <DRMHelper.h> |
|
29 |
#include <MmsEngineInternalCRKeys.h> |
|
30 |
#include <hbmessagebox.h> |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
31 |
#include <HbNotificationDialog> |
31 | 32 |
#include <hbaction.h> |
33 |
||
34 |
#include "unidatamodelloader.h" |
|
35 |
#include "unidatamodelplugininterface.h" |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
36 |
#include "UniEditorGenUtils.h" // This is needed for KDefaultMaxSize |
31 | 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::onDialogInsertMedia |
|
168 |
// ----------------------------------------------------------------------------- |
|
169 |
// |
|
170 |
void MmsConformanceCheck::onDialogInsertMedia(HbAction* action) |
|
171 |
{ |
|
172 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
173 |
if (action == dlg->actions().at(0)) { |
|
174 |
// Query accepted. |
|
175 |
// Mask "FreeModeOnly" and "ScalingNeeded" away in free mode |
|
176 |
iConfStatus &= ~EMmsConfNokFreeModeOnly; |
|
177 |
iConfStatus &= ~EMmsConfNokScalingNeeded; |
|
178 |
} |
|
179 |
||
180 |
} |
|
181 |
||
182 |
// ----------------------------------------------------------------------------- |
|
183 |
// MmsConformanceCheck::showPopup |
|
184 |
// ----------------------------------------------------------------------------- |
|
185 |
// |
|
186 |
void MmsConformanceCheck::showPopup(const QString& text) |
|
187 |
{ |
|
188 |
HbNotificationDialog* dlg = new HbNotificationDialog(); |
|
189 |
dlg->setFocusPolicy(Qt::NoFocus); |
|
190 |
dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
191 |
dlg->setText(text); |
|
192 |
dlg->show(); |
|
193 |
} |
|
194 |