|
1 /* |
|
2 * Copyright (c) 2002-2006 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: |
|
15 * Provides CMmsViewerDocument methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // ========== INCLUDE FILES ================================ |
|
23 |
|
24 #include <eikenv.h> |
|
25 #include <eikdoc.h> |
|
26 |
|
27 #include <msvstd.h> // TMsvEntry |
|
28 #include <msvapi.h> |
|
29 #include <msvuids.h> // Msgs Uids |
|
30 #include <mtclbase.h> // CBaseMtm |
|
31 #include <mmsvattachmentmanager.h> |
|
32 #include <cmsvattachment.h> |
|
33 #include <cmsvmimeheaders.h> |
|
34 #include <mmsvattachmentmanagersync.h> |
|
35 |
|
36 #include <bautils.h> |
|
37 |
|
38 #include <mmsclient.h> // Client Mtm API |
|
39 #include <MuiuMsvUiServiceUtilities.h> //Disk space check |
|
40 #include <MsgAttachmentInfo.h> |
|
41 |
|
42 #include <gmxmldocument.h> |
|
43 #include <gmxmlnode.h> |
|
44 #include <gmxmlelement.h> |
|
45 |
|
46 // Features |
|
47 #include <featmgr.h> |
|
48 #include <bldvariant.hrh> |
|
49 #include <messagingvariant.hrh> |
|
50 |
|
51 #include <MsgMimeTypes.h> |
|
52 #include <MsgMediaResolver.h> |
|
53 #include <MsgMediaInfo.h> |
|
54 #include <MsgTextInfo.h> |
|
55 #include <MmsConformance.h> |
|
56 |
|
57 #include <centralrepository.h> // link against centralrepository.lib |
|
58 #include <MmsEngineInternalCRKeys.h> |
|
59 #include <messaginginternalcrkeys.h> // for Central Repository keys |
|
60 |
|
61 #include "UniMmsViewerDocument.h" // CMmsViewerDocument |
|
62 #include "UniMmsViewerAppUi.h" // CMmsViewerAppUi |
|
63 |
|
64 #include "MmsMtmUi.h" |
|
65 #include "MmsMtmConst.h" // File logger |
|
66 |
|
67 #include "MmsViewer.hrh" // panics |
|
68 |
|
69 // UniModel stuff |
|
70 #include <unidatamodel.h> |
|
71 #include <unismilmodel.h> |
|
72 #include <unidatautils.h> |
|
73 #include <uniobjectsinfo.h> |
|
74 #include <uniobjectsmodel.h> |
|
75 #include <uniobjectlist.h> |
|
76 #include <unismillist.h> |
|
77 #include <uniobject.h> |
|
78 #include <unitextobject.h> |
|
79 #include <unimimeinfo.h> |
|
80 #include <unismilutils.h> |
|
81 #include <unidrminfo.h> |
|
82 |
|
83 // ========== CONSTANTS ==================================== |
|
84 |
|
85 const TInt KDefaultMaxSize = 300 * 1024; |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // Two-phased constructor. |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 CMmsViewerDocument* CMmsViewerDocument::NewL( CEikApplication& aApp ) |
|
92 { |
|
93 CMmsViewerDocument* self = new ( ELeave ) CMmsViewerDocument( aApp ); |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop( self ); |
|
97 return self; |
|
98 } |
|
99 |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // C++ default constructor can NOT contain any code, that |
|
103 // might leave. |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 CMmsViewerDocument::CMmsViewerDocument( CEikApplication& aApp ) : |
|
107 CMsgEditorDocument( aApp ), |
|
108 iCurrentSlide( 0 ), |
|
109 iMaxMessageSize( KDefaultMaxSize ), |
|
110 iCreationMode( EMmsCreationModeWarning ) |
|
111 { |
|
112 LOGTIMESTAMP("CMmsViewerDocument::CMmsViewerDocument "); |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CMmsViewerDocument::ConstructL |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 void CMmsViewerDocument::ConstructL() |
|
121 { |
|
122 CMsgEditorDocument::ConstructL(); |
|
123 |
|
124 TInt maxSize = KDefaultMaxSize; |
|
125 TInt creationMode = EMmsCreationModeWarning; |
|
126 |
|
127 CRepository* repository = CRepository::NewL( KCRUidMmsEngine ); |
|
128 TInt err = repository->Get( KMmsEngineMaximumSendSize, maxSize ); |
|
129 if ( !err ) |
|
130 { |
|
131 iMaxMessageSize = maxSize; |
|
132 } |
|
133 err = repository->Get( KMmsEngineCreationMode, creationMode ); |
|
134 if ( !err ) |
|
135 { |
|
136 iCreationMode = creationMode; |
|
137 } |
|
138 delete repository; |
|
139 repository = NULL; |
|
140 |
|
141 if ( !iMaxMessageSize ) |
|
142 { |
|
143 //MaximumSendSize == 0 means "anything goes" |
|
144 iMaxMessageSize = KMaxTUint32; |
|
145 } |
|
146 |
|
147 PrepareMtmL( KUidMsgTypeMultimedia ); |
|
148 iFs = CEikonEnv::Static()->FsSession( ); |
|
149 iDataModel = CUniDataModel::NewL( iFs, Mtm( ) ); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CMmsViewerDocument::~CMmsViewerDocument |
|
154 // |
|
155 // Destructor. |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 CMmsViewerDocument::~CMmsViewerDocument() |
|
159 { |
|
160 delete iDataModel; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------- |
|
164 // CMmsViewerDocument::DefaultMsgFolder |
|
165 // --------------------------------------------------------- |
|
166 // |
|
167 TMsvId CMmsViewerDocument::DefaultMsgFolder() const |
|
168 { |
|
169 return KMsvGlobalOutBoxIndexEntryIdValue; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CMmsViewerDocument::DefaultMsgService |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 TMsvId CMmsViewerDocument::DefaultMsgService() const |
|
177 { |
|
178 return KMsvLocalServiceIndexEntryId; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CMmsViewerDocument::Mtm |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 CMmsClientMtm& CMmsViewerDocument::Mtm() |
|
186 { |
|
187 return static_cast <CMmsClientMtm&> ( CMsgEditorDocument::Mtm() ); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------- |
|
191 // CMmsViewerDocument::MtmUiL |
|
192 // --------------------------------------------------------- |
|
193 // |
|
194 CMmsMtmUi& CMmsViewerDocument::MtmUiL() |
|
195 { |
|
196 return static_cast <CMmsMtmUi&> ( CMsgEditorDocument::MtmUiL() ); |
|
197 } |
|
198 |
|
199 |
|
200 // --------------------------------------------------------- |
|
201 // CMmsViewerDocument::EntryChangedL |
|
202 // Intentionally empty implementation. |
|
203 // --------------------------------------------------------- |
|
204 // |
|
205 void CMmsViewerDocument::EntryChangedL() // empty implementation |
|
206 { |
|
207 } |
|
208 |
|
209 |
|
210 // --------------------------------------------------------- |
|
211 // CMmsViewerDocument::CreateNewAttachmentModelL |
|
212 // |
|
213 // Creates new objects model object (virtual from CMsgEditorDocument). |
|
214 // --------------------------------------------------------- |
|
215 // |
|
216 CMsgAttachmentModel* CMmsViewerDocument::CreateNewAttachmentModelL( |
|
217 TBool aReadOnly) |
|
218 { |
|
219 return CUniObjectsModel::NewL( aReadOnly ); |
|
220 } |
|
221 |
|
222 |
|
223 // --------------------------------------------------------- |
|
224 // CMmsViewerDocument::InitializeL |
|
225 // |
|
226 // Initialise the model. |
|
227 // --------------------------------------------------------- |
|
228 // |
|
229 void CMmsViewerDocument::InitializeL( MMmsDocumentObserver& aObserver ) |
|
230 { |
|
231 iObserver = &aObserver; |
|
232 iSmilType = ENoSmil; |
|
233 iDataModel->RestoreL( *this ); |
|
234 |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------- |
|
238 // CMmsViewerDocument::RestoreReady |
|
239 // --------------------------------------------------------- |
|
240 // |
|
241 void CMmsViewerDocument::RestoreReady( TInt aParseResult, TInt aError ) |
|
242 { |
|
243 // Map NoSmil and MultipleSmil to MmsSmil |
|
244 iSmilType = iDataModel->SmilType( ); |
|
245 if ( iSmilType == ENoSmil || |
|
246 iSmilType == EMultipleSmil ) |
|
247 { |
|
248 iSmilType = EMmsSmil; |
|
249 } |
|
250 iParseResult = aParseResult; |
|
251 |
|
252 iOrigAttachmentCount = iDataModel->OriginalAttachmentCount(); |
|
253 iObserver->InitializeReady( iParseResult, aError ); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------- |
|
257 // MessageSize |
|
258 // |
|
259 // --------------------------------------------------------- |
|
260 TInt CMmsViewerDocument::MessageSize( ) |
|
261 { |
|
262 // If this function is modified, CMmsMtmUi::MessageSizeL() must be kept in sync. |
|
263 TInt msgSizeBytes( 0 ); |
|
264 TInt count = iDataModel->ObjectList().Count(); |
|
265 while ( count-- ) |
|
266 { |
|
267 msgSizeBytes += iDataModel->ObjectList().GetByIndex( count )->Size(); |
|
268 } |
|
269 |
|
270 msgSizeBytes += iDataModel->SmilList().SmilByteSize(); |
|
271 |
|
272 count = iDataModel->AttachmentList().Count(); |
|
273 while ( count-- ) |
|
274 { |
|
275 msgSizeBytes += iDataModel->AttachmentList().GetByIndex( count )->Size(); |
|
276 } |
|
277 |
|
278 // subject size |
|
279 TPtrC subject; |
|
280 TRAP_IGNORE( subject.Set( Mtm().SubjectL() ) ); |
|
281 msgSizeBytes += CUniDataUtils::UTF8Size( subject ); |
|
282 |
|
283 return msgSizeBytes; |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------- |
|
287 // CMmsViewerDocument::CreateAppUiL |
|
288 // --------------------------------------------------------- |
|
289 // |
|
290 CEikAppUi* CMmsViewerDocument::CreateAppUiL() |
|
291 { |
|
292 CMsgEditorAppUi* appui = new ( ELeave ) CMmsViewerAppUi(); |
|
293 return appui; |
|
294 } |
|
295 |
|
296 // --------------------------------------------------------- |
|
297 // CMmsViewerDocument::ErrorResponseMessage |
|
298 // --------------------------------------------------------- |
|
299 // |
|
300 TBool CMmsViewerDocument::ErrorResponseMessage() |
|
301 { |
|
302 TBool retVal( EFalse ); |
|
303 if ( iOrigAttachmentCount == 0 |
|
304 && static_cast<CMmsClientMtm&>( Mtm() ).ResponseStatus() > KMmsResponseStatusOK |
|
305 && static_cast<CMmsClientMtm&>( Mtm() ).ResponseText().Length() ) |
|
306 { |
|
307 retVal = ETrue; |
|
308 } |
|
309 return retVal; |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------- |
|
313 // CMmsViewerDocument::CreateNewL |
|
314 // --------------------------------------------------------- |
|
315 // |
|
316 TMsvId CMmsViewerDocument::CreateNewL(TMsvId /*aService*/, TMsvId /*aDestFolder*/ ) |
|
317 { |
|
318 __ASSERT_ALWAYS( !Mtm().Entry().Entry().ReadOnly(), Panic( EMmsNotSupportedInReadOnly ) ); |
|
319 return 0; |
|
320 } |
|
321 |
|
322 // ---------------------------------------------------- |
|
323 // GetAttachmentFileL |
|
324 // ---------------------------------------------------- |
|
325 // |
|
326 RFile CMmsViewerDocument::GetAttachmentFileL( TMsvAttachmentId aId ) |
|
327 { |
|
328 RFile file; |
|
329 CMsvStore* store = Mtm().Entry().ReadStoreL(); |
|
330 CleanupStack::PushL( store ); |
|
331 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
332 file = manager.GetAttachmentFileL( aId ); |
|
333 CleanupStack::PopAndDestroy( store ); |
|
334 return file; |
|
335 } |
|
336 |
|
337 |
|
338 // End of File |