|
1 /* |
|
2 * Copyright (c) 2005 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 CPostcardDocument class 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 |
|
32 #include <bautils.h> |
|
33 |
|
34 #include <mmsclient.h> // Client Mtm API |
|
35 #include <MuiuMsvUiServiceUtilities.h> //Disk space check |
|
36 #include <MsgAttachmentInfo.h> |
|
37 #include <mmsmsventry.h> |
|
38 |
|
39 #include <centralrepository.h> // link against centralrepository.lib |
|
40 #include <MmsEngineInternalCRKeys.h> // for Central Repository keys |
|
41 |
|
42 #include <mtmuibas.h> |
|
43 |
|
44 // Features |
|
45 #include <featmgr.h> |
|
46 #include <bldvariant.hrh> |
|
47 #include <messagingvariant.hrh> |
|
48 |
|
49 #include <MsgMediaResolver.h> |
|
50 #include <msgtextutils.h> |
|
51 #include <MsgMimeTypes.h> |
|
52 |
|
53 #include <MuiuMsgEditorLauncher.h> |
|
54 |
|
55 #include "PostcardDocument.h" |
|
56 #include "PostcardAppUi.h" |
|
57 |
|
58 const TInt KPostcardIndexEntryExtra = 2000; // space reserved for the index entry |
|
59 const TInt KMaxPostcardWidth = 1600; |
|
60 const TInt KMaxPostcardHeight = 1200; |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 CPostcardDocument::CPostcardDocument( CEikApplication& aApp ) : |
|
68 CMsgEditorDocument( aApp ), |
|
69 iMsgChanged( 0 ), |
|
70 iMsgType( EPostcardSent ), |
|
71 iMaxMessageSize( 300 ) |
|
72 { |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CPostcardDocument::CreateAppUiL |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CEikAppUi* CPostcardDocument::CreateAppUiL() |
|
80 { |
|
81 CEikAppUi* appui = new ( ELeave ) CPostcardAppUi(); |
|
82 return appui; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CPostcardDocument::ConstructL |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 void CPostcardDocument::ConstructL() |
|
90 { |
|
91 CMsgEditorDocument::ConstructL(); |
|
92 |
|
93 CRepository* repository = CRepository::NewL( KCRUidMmsEngine ); |
|
94 TInt maxSendSize = 0; |
|
95 // value is returned as bytes now |
|
96 TInt err = repository->Get( KMmsEngineMaximumSendSize, maxSendSize ); |
|
97 if ( !err ) |
|
98 { |
|
99 iMaxMessageSize = maxSendSize; |
|
100 } |
|
101 delete repository; |
|
102 |
|
103 PrepareMtmL( KUidMsgTypeMultimedia ); |
|
104 } |
|
105 |
|
106 // ---------------------------------------------------- |
|
107 // CPostcardDocument::NewL |
|
108 // ---------------------------------------------------- |
|
109 CPostcardDocument* CPostcardDocument::NewL(CEikApplication& aApp) |
|
110 { |
|
111 CPostcardDocument* self = new ( ELeave ) CPostcardDocument( aApp ); |
|
112 CleanupStack::PushL( self ); |
|
113 self->ConstructL(); |
|
114 CleanupStack::Pop( self ); |
|
115 return self; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // CPostcardDocument::~CPostcardDocument |
|
120 // --------------------------------------------------------- |
|
121 CPostcardDocument::~CPostcardDocument() |
|
122 { |
|
123 delete iMediaResolver; |
|
124 delete iTextUtils; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CPostcardDocument::DefaultMsgFolder |
|
129 // --------------------------------------------------------- |
|
130 TMsvId CPostcardDocument::DefaultMsgFolder() const |
|
131 { |
|
132 return KMsvDraftEntryIdValue; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // CPostcardDocument::DefaultMsgService |
|
137 // --------------------------------------------------------- |
|
138 TMsvId CPostcardDocument::DefaultMsgService() const |
|
139 { |
|
140 return KMsvLocalServiceIndexEntryId; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CPostcardDocument::CreateNewL |
|
145 // --------------------------------------------------------- |
|
146 TMsvId CPostcardDocument::CreateNewL( TMsvId /* aServiceId */, TMsvId aDestFolder ) |
|
147 { |
|
148 // Can only create to draft |
|
149 if ( aDestFolder != KMsvDraftEntryIdValue ) |
|
150 { |
|
151 User::Leave( KErrNotSupported ); |
|
152 } |
|
153 |
|
154 // Don't allow creation if will go under CL |
|
155 if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
156 Session(), |
|
157 KPostcardIndexEntryExtra ) ) |
|
158 { |
|
159 User::Leave( KErrDiskFull ); |
|
160 } |
|
161 |
|
162 CMmsClientMtm& clientMtm = Mtm(); |
|
163 |
|
164 // CREATE TO aDestFolder (DRAFT) |
|
165 CMsvOperation* createOperation = NULL; |
|
166 CMsvOperationWait* wait = CMsvOperationWait::NewLC(); |
|
167 wait->Start(); |
|
168 createOperation = clientMtm.CreateNewEntryL( aDestFolder, wait->iStatus ); |
|
169 CleanupStack::PushL( createOperation ); |
|
170 CActiveScheduler::Start(); |
|
171 |
|
172 if ( wait->iStatus.Int() != KErrNone ) |
|
173 { |
|
174 User::Leave( wait->iStatus.Int() ); |
|
175 } |
|
176 |
|
177 // Get the message id |
|
178 TPckgBuf<TMsvId> pkg; |
|
179 pkg.Copy( createOperation->ProgressL() ); |
|
180 TMsvId progress = 0; |
|
181 progress = pkg(); |
|
182 CleanupStack::PopAndDestroy( 2, wait ); // wait, createOperation |
|
183 |
|
184 return progress; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // CPostcardDocument::Mtm |
|
189 // --------------------------------------------------------- |
|
190 CMmsClientMtm& CPostcardDocument::Mtm() |
|
191 { |
|
192 return static_cast <CMmsClientMtm&> ( CMsgEditorDocument::Mtm() ); |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------- |
|
196 // CPostcardDocument::MtmUi |
|
197 // --------------------------------------------------------- |
|
198 CBaseMtmUi& CPostcardDocument::MtmUi() |
|
199 { |
|
200 return CMsgEditorDocument::MtmUi(); |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------- |
|
204 // CPostcardDocument::EntryChangedL |
|
205 // Intentionally empty implementation. |
|
206 // --------------------------------------------------------- |
|
207 void CPostcardDocument::EntryChangedL() |
|
208 { |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------- |
|
212 // CPostcardDocument::InitializeL |
|
213 // --------------------------------------------------------- |
|
214 void CPostcardDocument::InitializeL( RFs& aFs ) |
|
215 { |
|
216 iFs = aFs; |
|
217 |
|
218 iMediaResolver = CMsgMediaResolver::NewL(); |
|
219 iMediaResolver->SetCharacterSetRecognition( iMsgType == EPostcardSendAs ); |
|
220 |
|
221 iTextUtils = CMsgTextUtils::NewL( iFs ); |
|
222 } |
|
223 |
|
224 // ---------------------------------------------------- |
|
225 // CMmsEditorDocument::SetMessageType |
|
226 // ---------------------------------------------------- |
|
227 void CPostcardDocument::SetMessageType() |
|
228 { |
|
229 const TInt flags = LaunchFlags(); |
|
230 TMmsMsvEntry tEntry = static_cast<TMmsMsvEntry>( Entry() ); |
|
231 |
|
232 if ( tEntry.Parent( ) == KMsvSentEntryId ) |
|
233 { |
|
234 iMsgType = EPostcardSent; |
|
235 return; |
|
236 } |
|
237 |
|
238 if ( flags & EMsgCreateNewMessage ) |
|
239 { |
|
240 iMsgType = EPostcardNew; |
|
241 return; |
|
242 } |
|
243 else if ( flags & EMsgForwardMessage ) |
|
244 { |
|
245 iMsgType = EPostcardForward; |
|
246 return; |
|
247 } |
|
248 else if ( flags & EMsgCreateDuplicate ) |
|
249 { |
|
250 iMsgType = EPostcardEdit; |
|
251 return; |
|
252 } |
|
253 else if ( flags & EMsgEditNewMessage ) |
|
254 { |
|
255 iMsgType = EPostcardSendAs; |
|
256 return; |
|
257 } |
|
258 |
|
259 // Either sent or sendas or open from draft |
|
260 if ( tEntry.ReadOnly( ) ) |
|
261 { |
|
262 iMsgType = EPostcardSent; |
|
263 } |
|
264 else |
|
265 { |
|
266 if( tEntry.EditorOriented( ) ) |
|
267 { |
|
268 iMsgType = EPostcardDraft; |
|
269 } |
|
270 else |
|
271 { |
|
272 iMsgType = EPostcardSendAs; |
|
273 } |
|
274 } |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------- |
|
278 // SetChanged |
|
279 // ---------------------------------------------------- |
|
280 void CPostcardDocument::SetChanged( TPostcardPart aPart ) |
|
281 { |
|
282 iMsgChanged |= aPart; |
|
283 } |
|
284 |
|
285 // ---------------------------------------------------- |
|
286 // Changed |
|
287 // ---------------------------------------------------- |
|
288 TBool CPostcardDocument::Changed( TPostcardPart aPart ) const |
|
289 { |
|
290 return iMsgChanged & aPart; |
|
291 } |
|
292 |
|
293 // ---------------------------------------------------- |
|
294 // Modified |
|
295 // ---------------------------------------------------- |
|
296 TBool CPostcardDocument::Modified( ) const |
|
297 { |
|
298 return iMsgChanged; |
|
299 } |
|
300 |
|
301 // ---------------------------------------------------- |
|
302 // MaxMessageSize |
|
303 // ---------------------------------------------------- |
|
304 TInt CPostcardDocument::MaxMessageSize( ) const |
|
305 { |
|
306 return iMaxMessageSize; |
|
307 } |
|
308 |
|
309 // ---------------------------------------------------- |
|
310 // MaxImageSize |
|
311 // ---------------------------------------------------- |
|
312 TInt CPostcardDocument::MaxImageSize( ) const |
|
313 { |
|
314 return iMaxMessageSize - KPostcardAddressGreetingOverhead; |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------- |
|
318 // AppFullName |
|
319 // --------------------------------------------------------- |
|
320 TFileName CPostcardDocument::AppFullName( ) |
|
321 { |
|
322 return Application( )->AppFullName( ); |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------- |
|
326 // IsImage |
|
327 // --------------------------------------------------------- |
|
328 TBool CPostcardDocument::IsImage( const TDataType& aMimeType ) |
|
329 { |
|
330 if ( aMimeType.Des8( ).CompareF( KMsgMimeImageJpeg ) == 0 ) |
|
331 { |
|
332 return ETrue; |
|
333 } |
|
334 else if ( aMimeType.Des8( ).CompareF( KMsgMimeImageGif ) == 0 ) |
|
335 { |
|
336 return ETrue; |
|
337 } |
|
338 else if ( aMimeType.Des8( ).CompareF( KMsgMimeImagePng ) == 0 ) |
|
339 { |
|
340 return ETrue; |
|
341 } |
|
342 return EFalse; |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------- |
|
346 // MaxImageDimensions |
|
347 // --------------------------------------------------------- |
|
348 TSize CPostcardDocument::MaxImageDimensions( ) |
|
349 { |
|
350 return TSize( KMaxPostcardWidth, KMaxPostcardHeight ); |
|
351 } |
|
352 |
|
353 |
|
354 // End of File |