79
|
1 |
/*
|
|
2 |
* Copyright (c) 2006,2007 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: Provides CUniEditorSaveOperation methods.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// ========== INCLUDE FILES ================================
|
|
21 |
|
|
22 |
#include <cmsvattachment.h>
|
|
23 |
|
|
24 |
#include <txtrich.h>
|
|
25 |
#include <eikrted.h>
|
|
26 |
|
|
27 |
#include <MuiuMsvUiServiceUtilities.h>
|
|
28 |
#include <StringLoader.h>
|
|
29 |
|
|
30 |
#include <MsgEditorView.h>
|
|
31 |
#include <MsgBodyControl.h>
|
|
32 |
#include <MsgExpandableControl.h>
|
|
33 |
#include <MsgBaseControl.h>
|
|
34 |
#include <msgimagecontrol.h>
|
|
35 |
|
|
36 |
#include <unimsventry.h>
|
|
37 |
|
|
38 |
// MsgMedia stuff
|
|
39 |
#include <MsgMimeTypes.h>
|
|
40 |
#include <MsgMediaInfo.h>
|
|
41 |
#include <MsgTextInfo.h>
|
|
42 |
#include <MsgImageInfo.h>
|
|
43 |
|
|
44 |
// UniModel + UniUtils
|
|
45 |
#include <unidatautils.h>
|
|
46 |
#include <unidatamodel.h>
|
|
47 |
#include <unismilmodel.h>
|
|
48 |
#include <unismillist.h>
|
|
49 |
#include <uniobjectlist.h>
|
|
50 |
#include <uniaddresshandler.h>
|
|
51 |
|
|
52 |
#include <UniEditor.rsg>
|
|
53 |
|
|
54 |
#include "UniPluginApi.h"
|
|
55 |
#include "UniClientMtm.h"
|
|
56 |
|
|
57 |
#include "UniSendingSettings.h"
|
|
58 |
#include "UniEditorHeader.h"
|
|
59 |
#include "UniEditorDocument.h"
|
|
60 |
#include "UniEditorSaveOperation.h"
|
|
61 |
#include "UniEditorAppUi.h"
|
|
62 |
// ========== EXTERNAL DATA STRUCTURES =====================
|
|
63 |
|
|
64 |
// ========== EXTERNAL FUNCTION PROTOTYPES =================
|
|
65 |
|
|
66 |
// ========== CONSTANTS ====================================
|
|
67 |
|
|
68 |
const TInt KMaxDetailsLength = 64; // Copy max this many chars to TMsvEntry iDetails
|
|
69 |
const TInt KUniMaxDescription = 64;
|
|
70 |
|
|
71 |
// ========== MACROS =======================================
|
|
72 |
|
|
73 |
// ========== LOCAL CONSTANTS AND MACROS ===================
|
|
74 |
|
|
75 |
// ========== MODULE DATA STRUCTURES =======================
|
|
76 |
|
|
77 |
// ========== LOCAL FUNCTION PROTOTYPES ====================
|
|
78 |
|
|
79 |
// ========== LOCAL FUNCTIONS ==============================
|
|
80 |
|
|
81 |
// ========== MEMBER FUNCTIONS =============================
|
|
82 |
|
|
83 |
// ---------------------------------------------------------
|
|
84 |
// CUniEditorSaveOperation::NewL
|
|
85 |
//
|
|
86 |
// Factory method.
|
|
87 |
// ---------------------------------------------------------
|
|
88 |
//
|
|
89 |
CUniEditorSaveOperation* CUniEditorSaveOperation::NewL(
|
|
90 |
MUniEditorOperationObserver& aObserver,
|
|
91 |
CUniEditorDocument& aDocument,
|
|
92 |
CUniEditorHeader& aHeader,
|
|
93 |
CMsgEditorView& aView,
|
|
94 |
RFs& aFs )
|
|
95 |
{
|
|
96 |
CUniEditorSaveOperation* self =
|
|
97 |
new ( ELeave ) CUniEditorSaveOperation( aObserver, aDocument, aHeader, aView, aFs );
|
|
98 |
|
|
99 |
CleanupStack::PushL( self );
|
|
100 |
self->ConstructL();
|
|
101 |
CleanupStack::Pop( self );
|
|
102 |
|
|
103 |
return self;
|
|
104 |
}
|
|
105 |
|
|
106 |
// ---------------------------------------------------------
|
|
107 |
// CUniEditorSaveOperation::CUniEditorSaveOperation
|
|
108 |
//
|
|
109 |
// Constructor.
|
|
110 |
// ---------------------------------------------------------
|
|
111 |
//
|
|
112 |
CUniEditorSaveOperation::CUniEditorSaveOperation(
|
|
113 |
MUniEditorOperationObserver& aObserver,
|
|
114 |
CUniEditorDocument& aDocument,
|
|
115 |
CUniEditorHeader& aHeader,
|
|
116 |
CMsgEditorView& aView,
|
|
117 |
RFs& aFs ) :
|
|
118 |
CUniEditorOperation( aObserver, aDocument, aFs, EUniEditorOperationSave ),
|
|
119 |
iHeader( aHeader ),
|
|
120 |
iView( aView )
|
|
121 |
{
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------
|
|
125 |
// CUniEditorSaveOperation::ConstructL
|
|
126 |
//
|
|
127 |
// 2nd phase constructor.
|
|
128 |
// ---------------------------------------------------------
|
|
129 |
//
|
|
130 |
void CUniEditorSaveOperation::ConstructL()
|
|
131 |
{
|
|
132 |
BaseConstructL();
|
|
133 |
}
|
|
134 |
|
|
135 |
// ---------------------------------------------------------
|
|
136 |
// CUniEditorSaveOperation::~CUniEditorSaveOperation
|
|
137 |
//
|
|
138 |
// Destructor.
|
|
139 |
// ---------------------------------------------------------
|
|
140 |
//
|
|
141 |
CUniEditorSaveOperation::~CUniEditorSaveOperation()
|
|
142 |
{
|
|
143 |
Cancel();
|
|
144 |
delete iDom;
|
|
145 |
delete iEditStore;
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------
|
|
149 |
// CUniEditorSaveOperation::Save
|
|
150 |
//
|
|
151 |
// SaveL
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CUniEditorSaveOperation::Save( TUniSaveType aSaveType )
|
|
155 |
{
|
|
156 |
ResetErrors();
|
|
157 |
|
|
158 |
iSavedObject = NULL;
|
|
159 |
iSaveType = aSaveType;
|
|
160 |
|
|
161 |
iOperationState = EUniEditorSaveCheck;
|
|
162 |
|
|
163 |
CompleteSelf( KErrNone );
|
|
164 |
}
|
|
165 |
|
|
166 |
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
// CUniEditorSaveOperation::SaveL
|
|
169 |
//
|
|
170 |
// SaveL
|
|
171 |
// ---------------------------------------------------------
|
|
172 |
//
|
|
173 |
void CUniEditorSaveOperation::SaveL( CUniObject& aObject )
|
|
174 |
{
|
|
175 |
if ( !MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( iDocument.Session(),
|
|
176 |
aObject.Size( ETrue ) ) )
|
|
177 |
{
|
|
178 |
iSavedObject = &aObject;
|
|
179 |
iSavedObject->Save( *this, CMsvAttachment::EMsvFile );
|
|
180 |
SetPending();
|
|
181 |
}
|
|
182 |
else
|
|
183 |
{
|
|
184 |
User::Leave( KErrDiskFull );
|
|
185 |
}
|
|
186 |
}
|
|
187 |
|
|
188 |
// ---------------------------------------------------------
|
|
189 |
// CUniEditorSaveOperation::CheckDiskSpaceL
|
|
190 |
// ---------------------------------------------------------
|
|
191 |
//
|
|
192 |
TBool CUniEditorSaveOperation::CheckDiskSpaceL()
|
|
193 |
{
|
|
194 |
// First calculate disk space needed for new attas
|
|
195 |
TInt spaceNeeded = iDocument.DataModel()->ObjectList().SpaceNeededForSaveAll();
|
|
196 |
spaceNeeded += iDocument.DataModel()->AttachmentList().SpaceNeededForSaveAll();
|
|
197 |
|
|
198 |
if ( iComposeSmil )
|
|
199 |
{
|
|
200 |
spaceNeeded += iDocument.DataModel()->SmilModel().SmilComposeSize();
|
|
201 |
}
|
|
202 |
|
|
203 |
// Disk space check
|
|
204 |
return !( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL(
|
|
205 |
iDocument.Session(),
|
|
206 |
spaceNeeded ) );
|
|
207 |
}
|
|
208 |
|
|
209 |
// ---------------------------------------------------------
|
|
210 |
// CUniEditorSaveOperation::DoSaveStepL
|
|
211 |
// ---------------------------------------------------------
|
|
212 |
//
|
|
213 |
void CUniEditorSaveOperation::DoSaveStepL()
|
|
214 |
{
|
|
215 |
switch ( iOperationState )
|
|
216 |
{
|
|
217 |
case EUniEditorSaveCheck:
|
|
218 |
{
|
|
219 |
DoSaveChecksL();
|
|
220 |
break;
|
|
221 |
}
|
|
222 |
case EUniEditorSaveObjects:
|
|
223 |
{
|
|
224 |
DoSaveObjectL();
|
|
225 |
break;
|
|
226 |
}
|
|
227 |
case EUniEditorSaveAttachment:
|
|
228 |
{
|
|
229 |
DoSaveAttachments();
|
|
230 |
break;
|
|
231 |
}
|
|
232 |
case EUniEditorSaveSmilCompose:
|
|
233 |
{
|
|
234 |
DoComposeSmilL();
|
|
235 |
break;
|
|
236 |
}
|
|
237 |
case EUniEditorSaveFinalize:
|
|
238 |
{
|
|
239 |
DoFinalizeSaveL();
|
|
240 |
break;
|
|
241 |
}
|
|
242 |
case EUniEditorSavePlugins:
|
|
243 |
{
|
|
244 |
DoSavePluginsL();
|
|
245 |
break;
|
|
246 |
}
|
|
247 |
case EUniEditorSaveEnd:
|
|
248 |
{
|
|
249 |
if ( iEditStore )
|
|
250 |
{
|
|
251 |
iEditStore->CommitL();
|
|
252 |
delete iEditStore;
|
|
253 |
iEditStore = NULL;
|
|
254 |
}
|
|
255 |
iObserver.EditorOperationEvent(
|
|
256 |
EUniEditorOperationSave,
|
|
257 |
EUniEditorOperationComplete );
|
|
258 |
break;
|
|
259 |
}
|
|
260 |
case EUniEditorSaveError:
|
|
261 |
{
|
|
262 |
if(iEditStore)
|
|
263 |
{
|
|
264 |
delete iEditStore;
|
|
265 |
iEditStore = NULL;
|
|
266 |
}
|
|
267 |
static_cast<CUniEditorAppUi*>(CEikonEnv::Static()->AppUi())->ExitWithoutSave();
|
|
268 |
}
|
|
269 |
default:
|
|
270 |
{
|
|
271 |
// Shouldn't be here!
|
|
272 |
delete iEditStore;
|
|
273 |
iEditStore = NULL;
|
|
274 |
iObserver.EditorOperationEvent(
|
|
275 |
EUniEditorOperationSave,
|
|
276 |
EUniEditorOperationError );
|
|
277 |
break;
|
|
278 |
}
|
|
279 |
}
|
|
280 |
}
|
|
281 |
|
|
282 |
// ---------------------------------------------------------
|
|
283 |
// CUniEditorSaveOperation::DoSaveChecksL
|
|
284 |
// ---------------------------------------------------------
|
|
285 |
//
|
|
286 |
void CUniEditorSaveOperation::DoSaveChecksL()
|
|
287 |
{
|
|
288 |
if ( !iDocument.Modified() &&
|
|
289 |
iSaveType <= iDocument.PrevSaveType() )
|
|
290 |
{
|
|
291 |
iOperationState = EUniEditorSaveEnd;
|
|
292 |
CompleteSelf( KErrNone );
|
|
293 |
//nothing to do!
|
|
294 |
return;
|
|
295 |
}
|
|
296 |
|
|
297 |
iOperationState = EUniEditorSaveEnd; // initialize state in case CheckDiskSpaceL leaves
|
|
298 |
if ( CheckDiskSpaceL() )
|
|
299 |
{
|
|
300 |
iOperationState = EUniEditorSaveObjects;
|
|
301 |
// TODO: Open edit store already here
|
|
302 |
//iEditStore = iDocument.Mtm().Entry().EditStoreL();
|
|
303 |
|
|
304 |
iHeader.CopyHeadersToMtmL( iDocument.HeaderModified(),
|
|
305 |
EFalse );
|
|
306 |
|
|
307 |
iComposeSmil = EFalse;
|
|
308 |
if ( iDocument.DataModel()->SmilType() == EMmsSmil )
|
|
309 |
{
|
|
310 |
//ReleaseImage( ETrue );
|
|
311 |
if ( /* iDocument.BodyModified() */
|
|
312 |
!iDocument.DataModel( )->ObjectList().Count() <= 0 ||
|
|
313 |
( !IsForward() && iSaveType == ESendingSave ) )
|
|
314 |
{
|
|
315 |
iComposeSmil = ETrue;
|
|
316 |
}
|
|
317 |
if ( iComposeSmil ||
|
|
318 |
iSaveType > iDocument.PrevSaveType() )
|
|
319 |
{
|
|
320 |
if ( IsForward() )
|
|
321 |
{
|
|
322 |
iDocument.DataModel()->ObjectList().EnsureAllObjectsHaveContentLocationL();
|
|
323 |
// TODO: Pass edit store as a parameter to objectlist
|
|
324 |
//iDocument.DataModel()->ObjectList().EnsureAllObjectsHaveContentLocationL( *iEditStore );
|
|
325 |
}
|
|
326 |
}
|
|
327 |
}
|
|
328 |
}
|
|
329 |
else
|
|
330 |
{
|
|
331 |
SetError( KErrDiskFull );
|
|
332 |
iOperationState = EUniEditorSaveEnd;
|
|
333 |
}
|
|
334 |
|
|
335 |
CompleteSelf( KErrNone );
|
|
336 |
}
|
|
337 |
|
|
338 |
// ---------------------------------------------------------
|
|
339 |
// CUniEditorSaveOperation::DoSaveObjectL
|
|
340 |
// ---------------------------------------------------------
|
|
341 |
//
|
|
342 |
void CUniEditorSaveOperation::DoSaveObjectL()
|
|
343 |
{
|
|
344 |
// User can delete or modify the linked file object( refer golbal path) later,
|
|
345 |
// in that case sent or outbox will not be able to open the entry.
|
|
346 |
// so convert all linked file objects into msv file.
|
|
347 |
// Processing will continue from CUniEditorSaveOperation::ObjectSaveReady when
|
|
348 |
// save has been performed
|
|
349 |
iDocument.DataModel()->ObjectList().SaveAll( *this, CMsvAttachment::EMsvFile );
|
|
350 |
SetPending();
|
|
351 |
}
|
|
352 |
|
|
353 |
// ---------------------------------------------------------
|
|
354 |
// CUniEditorSaveOperation::DoSaveAttachments
|
|
355 |
// ---------------------------------------------------------
|
|
356 |
//
|
|
357 |
void CUniEditorSaveOperation::DoSaveAttachments()
|
|
358 |
{
|
|
359 |
// Processing will continue from CUniEditorSaveOperation::ObjectSaveReady when
|
|
360 |
// save has been performed
|
|
361 |
iDocument.DataModel()->AttachmentList().SaveAll( *this, CMsvAttachment::EMsvFile );
|
|
362 |
// TODO: Pass edit store as a parameter to objectlist
|
|
363 |
//iDocument.DataModel()->AttachmentList().SaveAll( *this, *iEditStore, CMsvAttachment::EMsvFile );
|
|
364 |
SetPending();
|
|
365 |
}
|
|
366 |
|
|
367 |
// ---------------------------------------------------------
|
|
368 |
// CMmsDocument::DoSaveStepL
|
|
369 |
// ---------------------------------------------------------
|
|
370 |
//
|
|
371 |
void CUniEditorSaveOperation::DoComposeSmilL()
|
|
372 |
{
|
|
373 |
// TODO: Open edit store already in "save checks"
|
|
374 |
// Open store even if we didn't need it here.
|
|
375 |
// -> We don't need to check later whether the store is open or not.
|
|
376 |
iEditStore = iDocument.Mtm().Entry().EditStoreL();
|
|
377 |
if ( iComposeSmil )
|
|
378 |
{
|
|
379 |
if( !(iSaveType == ESendingSave && iDocument.UniState() == EUniSms) )
|
|
380 |
{
|
|
381 |
iDocument.DataModel()->SmilList().RemoveSmilL( *iEditStore );
|
|
382 |
if ( iSaveType == ESendingSave )
|
|
383 |
{
|
|
384 |
iDocument.DataModel()->SmilModel().RemoveEmptySlides();
|
|
385 |
}
|
|
386 |
|
|
387 |
if ( iDocument.DataModel()->SmilModel().SlideCount() != 0 )
|
|
388 |
{
|
|
389 |
// Model is not empty -> Compose new SMIL
|
|
390 |
iDom = iDocument.DataModel()->SmilModel().ComposeL();
|
|
391 |
iDocument.DataModel()->SmilList().CreateSmilAttachmentL( *this, *iEditStore, iDom );
|
|
392 |
SetPending();
|
|
393 |
return;
|
|
394 |
}
|
|
395 |
}
|
|
396 |
}
|
|
397 |
|
|
398 |
iOperationState = EUniEditorSaveFinalize;
|
|
399 |
CompleteSelf( KErrNone );
|
|
400 |
}
|
|
401 |
|
|
402 |
// ---------------------------------------------------------
|
|
403 |
// CMmsDocument::DoFinalizeSaveL
|
|
404 |
// ---------------------------------------------------------
|
|
405 |
//
|
|
406 |
void CUniEditorSaveOperation::DoFinalizeSaveL()
|
|
407 |
{
|
|
408 |
// Set new state immediately in case some function leaves.
|
|
409 |
iOperationState = EUniEditorSavePlugins;
|
|
410 |
|
|
411 |
// Set message root after composing SMIL but before calling SaveMessageL
|
|
412 |
TMsvAttachmentId root( 0 );
|
|
413 |
if ( iDocument.DataModel()->SmilList().Count() )
|
|
414 |
{
|
|
415 |
root = iDocument.DataModel()->SmilList().GetSmilAttachmentByIndex( 0 );
|
|
416 |
}
|
|
417 |
iDocument.Mtm().SetMessageRoot( root );
|
|
418 |
|
|
419 |
|
|
420 |
TMsvEntry tEntry = iDocument.Entry();
|
|
421 |
iDocument.Mtm().SaveMessageL( *iEditStore, tEntry );
|
|
422 |
|
|
423 |
HBufC* description = CreateDescriptionL();
|
|
424 |
if ( description )
|
|
425 |
{
|
|
426 |
tEntry.iDescription.Set( *description );
|
|
427 |
CleanupStack::PushL( description );
|
|
428 |
}
|
|
429 |
|
|
430 |
// Set details
|
|
431 |
TBuf<KMaxDetailsLength> detailsBuf;
|
|
432 |
iHeader.MakeDetailsL( detailsBuf );
|
|
433 |
tEntry.iDetails.Set( detailsBuf );
|
|
434 |
|
|
435 |
if ( iComposeSmil && IsForward() )
|
|
436 |
{
|
|
437 |
//New SMIL composed. This is a normal message from now on.
|
|
438 |
TUniMsvEntry::SetForwardedMessage( tEntry, EFalse );
|
|
439 |
}
|
|
440 |
|
|
441 |
TUniMsvEntry::SetEditorOriented( tEntry, ETrue );
|
|
442 |
TUniMsvEntry::SetCharSetSupport( tEntry, iDocument.CharSetSupport() );
|
|
443 |
|
|
444 |
TUniMessageCurrentType curType = EUniMessageCurrentTypeSms;
|
|
445 |
|
|
446 |
if( iDocument.UniState() == EUniMms )
|
|
447 |
{
|
|
448 |
curType = EUniMessageCurrentTypeMms;
|
|
449 |
|
|
450 |
TUniSendingSettings settings;
|
|
451 |
|
|
452 |
if( iDocument.UniState() == EUniMms )
|
|
453 |
{
|
|
454 |
CUniEditorPlugin* mmsPlugin = iDocument.MmsPlugin();
|
|
455 |
|
|
456 |
if ( mmsPlugin )
|
|
457 |
{
|
|
458 |
mmsPlugin->GetSendingSettingsL( settings );
|
|
459 |
switch ( settings.iPriority )
|
|
460 |
{
|
|
461 |
case TUniSendingSettings::EUniPriorityHigh:
|
|
462 |
{
|
|
463 |
tEntry.SetPriority( EMsvHighPriority );
|
|
464 |
break;
|
|
465 |
}
|
|
466 |
case TUniSendingSettings::EUniPriorityLow:
|
|
467 |
{
|
|
468 |
tEntry.SetPriority( EMsvLowPriority );
|
|
469 |
break;
|
|
470 |
}
|
|
471 |
default:
|
|
472 |
{
|
|
473 |
tEntry.SetPriority( EMsvMediumPriority );
|
|
474 |
break;
|
|
475 |
}
|
|
476 |
}
|
|
477 |
}
|
|
478 |
else
|
|
479 |
{
|
|
480 |
// Should not happen but better to handle anyway.
|
|
481 |
tEntry.SetPriority( EMsvMediumPriority );
|
|
482 |
}
|
|
483 |
}
|
|
484 |
}
|
|
485 |
else
|
|
486 |
{
|
|
487 |
// Message is sms -> remove priority
|
|
488 |
tEntry.SetPriority( EMsvMediumPriority );
|
|
489 |
}
|
|
490 |
|
|
491 |
TUniMsvEntry::SetCurrentMessageType( tEntry, curType );
|
|
492 |
|
|
493 |
tEntry.SetAttachment( EFalse );
|
|
494 |
|
|
495 |
if ( iSaveType >= EClosingSave )
|
|
496 |
{
|
|
497 |
// Update timestamp
|
|
498 |
tEntry.iDate.UniversalTime();
|
|
499 |
|
|
500 |
if ( !tEntry.Visible() )
|
|
501 |
{
|
|
502 |
// Save from close or exit save.
|
|
503 |
// Message should be visible after save
|
|
504 |
tEntry.SetVisible( ETrue );
|
|
505 |
tEntry.SetInPreparation( EFalse );
|
|
506 |
}
|
|
507 |
}
|
|
508 |
else
|
|
509 |
{
|
|
510 |
// Save made because user launched Message Info, Preview or Objects view
|
|
511 |
// Message should stay invisible and in preparation if it was.
|
|
512 |
if ( !tEntry.Visible() )
|
|
513 |
{
|
|
514 |
// Guarantee that when Visible is ETrue InPreparation is EFalse
|
|
515 |
tEntry.SetInPreparation( ETrue );
|
|
516 |
}
|
|
517 |
}
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
iDocument.CurrentEntry().ChangeL( tEntry );
|
|
522 |
|
|
523 |
if ( description )
|
|
524 |
{
|
|
525 |
// This must not be popped before ChangeL
|
|
526 |
CleanupStack::PopAndDestroy( description );
|
|
527 |
}
|
|
528 |
|
|
529 |
iDocument.SetHeaderModified( EFalse );
|
|
530 |
iDocument.SetBodyModified( EFalse );
|
|
531 |
iDocument.SetPrevSaveType( iSaveType );
|
|
532 |
|
|
533 |
CompleteSelf( KErrNone );
|
|
534 |
}
|
|
535 |
|
|
536 |
// ---------------------------------------------------------
|
|
537 |
// CUniEditorSaveOperation::CreateDescriptionL
|
|
538 |
//
|
|
539 |
// Creates description buffer. Returns NULL if description is not
|
|
540 |
// wanted to be updated.
|
|
541 |
// ---------------------------------------------------------
|
|
542 |
//
|
|
543 |
HBufC* CUniEditorSaveOperation::CreateDescriptionL()
|
|
544 |
{
|
|
545 |
CUniDataModel* model = iDocument.DataModel();
|
|
546 |
|
|
547 |
if( iDocument.UniState() == EUniSms )
|
|
548 |
{
|
|
549 |
if( model->ObjectList().Count() == 0 &&
|
|
550 |
model->AttachmentList().Count() == 1 )
|
|
551 |
{
|
|
552 |
// No objects and one attachment
|
|
553 |
CUniObject* obj = model->AttachmentList().GetByIndex( 0 );
|
|
554 |
if ( obj && obj->MimeType().Length() > 0 )
|
|
555 |
{
|
|
556 |
TInt res = 0;
|
|
557 |
if( obj->MimeType().CompareF( KMsgMimeVCard ) == 0 )
|
|
558 |
{
|
|
559 |
// There's only one VCard
|
|
560 |
res = R_UNIEDITOR_BIOTYPE_VCARD;
|
|
561 |
}
|
|
562 |
else if( obj->MimeType().CompareF( KMsgMimeVCal ) == 0 ||
|
|
563 |
obj->MimeType().CompareF( KMsgMimeICal ) == 0 )
|
|
564 |
{
|
|
565 |
// There's only one VCal
|
|
566 |
res = R_UNIEDITOR_BIOTYPE_VCAL;
|
|
567 |
}
|
|
568 |
if( res )
|
|
569 |
{
|
|
570 |
return StringLoader::LoadL( res, iView.ControlEnv() );
|
|
571 |
}
|
|
572 |
}
|
|
573 |
}
|
|
574 |
}
|
|
575 |
|
|
576 |
TPtrC subject = iDocument.Mtm().SubjectL();
|
|
577 |
TInt firstTextSlide = -1;
|
|
578 |
for ( TInt i = 0; i < model->SmilModel().SlideCount() && firstTextSlide == -1; i++ )
|
|
579 |
{
|
|
580 |
CUniObject* obj = model->SmilModel().GetObject( i, EUniRegionText );
|
|
581 |
if ( obj && obj->MediaType() == EMsgMediaText )
|
|
582 |
{
|
|
583 |
firstTextSlide = i;
|
|
584 |
}
|
|
585 |
}
|
|
586 |
|
|
587 |
if ( subject.Length() <= 0 &&
|
|
588 |
firstTextSlide != -1 &&
|
|
589 |
iDocument.CurrentSlide() != firstTextSlide )
|
|
590 |
{
|
|
591 |
return NULL;
|
|
592 |
}
|
|
593 |
|
|
594 |
TInt length = 0;
|
|
595 |
if ( subject.Length() <= 0 )
|
|
596 |
{
|
|
597 |
if ( model->SmilType() == EMmsSmil )
|
|
598 |
{
|
|
599 |
CMsgBodyControl* body = static_cast<CMsgBodyControl*>( iView.ControlById( EMsgComponentIdBody ) );
|
|
600 |
if ( body )
|
|
601 |
{
|
|
602 |
length = body->TextContent().DocumentLength();
|
|
603 |
|
|
604 |
// No subject. Change description.
|
|
605 |
if ( !length )
|
|
606 |
{
|
|
607 |
return KNullDesC().AllocL();
|
|
608 |
}
|
|
609 |
else
|
|
610 |
{
|
|
611 |
TBuf<KUniMaxDescription> description;
|
|
612 |
description.Zero();
|
|
613 |
length = ( length < KUniMaxDescription ? length : KUniMaxDescription );
|
|
614 |
|
|
615 |
// 107-24185 : Emoticon support for SMS and MMS
|
|
616 |
|
|
617 |
HBufC *text = body->Editor().GetTextInHBufL();
|
|
618 |
CleanupStack::PushL( text );
|
|
619 |
description.Copy( text->Ptr(), length );
|
|
620 |
CleanupStack::PopAndDestroy( text );
|
|
621 |
while( length-- )
|
|
622 |
{
|
|
623 |
if ( description[length] == CEditableText::ETabCharacter
|
|
624 |
|| description[length] == CEditableText::EPageBreak
|
|
625 |
|| description[length] == CEditableText::ENonBreakingSpace
|
|
626 |
|| description[length] == CEditableText::EHyphen
|
|
627 |
|| description[length] == CEditableText::ENonBreakingHyphen
|
|
628 |
|| description[length] == CEditableText::ELeftSingleQuote
|
|
629 |
|| description[length] == CEditableText::ERightSingleQuote
|
|
630 |
|| description[length] == CEditableText::ELeftDoubleQuote
|
|
631 |
|| description[length] == CEditableText::ERightDoubleQuote
|
|
632 |
|| description[length] == CEditableText::EBullet
|
|
633 |
|| description[length] == CEditableText::EEllipsis
|
|
634 |
|| description[length] == CEditableText::ELineBreak
|
|
635 |
|| description[length] == CEditableText::EParagraphDelimiter
|
|
636 |
|| description[length] == CEditableText::EPictureCharacter
|
|
637 |
|| description[length] == CEditableText::EZeroWidthNoBreakSpace
|
|
638 |
|| description[length] == CEditableText::EByteOrderMark
|
|
639 |
|| description[length] == CEditableText::EReversedByteOrderMark
|
|
640 |
|| description[length] == '\n' )
|
|
641 |
{
|
|
642 |
description[length] = ' ';
|
|
643 |
}
|
|
644 |
}
|
|
645 |
description.Trim();
|
|
646 |
return description.AllocL();
|
|
647 |
}
|
|
648 |
}
|
|
649 |
}
|
|
650 |
}
|
|
651 |
else
|
|
652 |
{
|
|
653 |
|
|
654 |
TBuf<KUniMaxDescription> description;
|
|
655 |
description.Zero();
|
|
656 |
length = subject.Length();
|
|
657 |
// Saving as pure text from the editor which may contain emoticons.
|
|
658 |
HBufC *text = iHeader.SubjectControl()->Editor().GetTextInHBufL();
|
|
659 |
if(text)
|
|
660 |
{
|
|
661 |
CleanupStack::PushL( text );
|
|
662 |
description.Copy( text->Ptr(), length );
|
|
663 |
CleanupStack::PopAndDestroy( text );
|
|
664 |
|
|
665 |
|
|
666 |
|
|
667 |
while( length-- )
|
|
668 |
{
|
|
669 |
if ( description[length] == CEditableText::EParagraphDelimiter ||
|
|
670 |
description[length] == '\n' )
|
|
671 |
description[length] = ' ';
|
|
672 |
}
|
|
673 |
description.Trim();
|
|
674 |
return description.AllocL();
|
|
675 |
}
|
|
676 |
else
|
|
677 |
{
|
|
678 |
return KNullDesC().AllocL();
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
return NULL;
|
|
683 |
}
|
|
684 |
|
|
685 |
// ---------------------------------------------------------
|
|
686 |
// CUniEditorSaveOperation::DoSavePluginsL
|
|
687 |
//
|
|
688 |
// 2nd phase constructor.
|
|
689 |
// ---------------------------------------------------------
|
|
690 |
void CUniEditorSaveOperation::DoSavePluginsL()
|
|
691 |
{
|
|
692 |
iOperationState = EUniEditorSaveEnd;
|
|
693 |
|
|
694 |
if( iDocument.SmsPlugin() )
|
|
695 |
{
|
|
696 |
iDocument.SmsPlugin()->SaveHeadersL( *iEditStore );
|
|
697 |
}
|
|
698 |
|
|
699 |
if( iDocument.MmsPlugin() )
|
|
700 |
{
|
|
701 |
iDocument.MmsPlugin()->SaveHeadersL( *iEditStore );
|
|
702 |
}
|
|
703 |
|
|
704 |
CompleteSelf( KErrNone );
|
|
705 |
}
|
|
706 |
|
|
707 |
// ---------------------------------------------------------
|
|
708 |
// CUniEditorSaveOperation::DoCancelCleanup
|
|
709 |
//
|
|
710 |
// ---------------------------------------------------------
|
|
711 |
//
|
|
712 |
void CUniEditorSaveOperation::DoCancelCleanup()
|
|
713 |
{
|
|
714 |
if ( iSavedObject )
|
|
715 |
{
|
|
716 |
iSavedObject->Cancel();
|
|
717 |
}
|
|
718 |
|
|
719 |
iDocument.DataModel()->SmilList().Cancel();
|
|
720 |
|
|
721 |
delete iEditStore;
|
|
722 |
iEditStore = NULL;
|
|
723 |
}
|
|
724 |
|
|
725 |
// ---------------------------------------------------------
|
|
726 |
// CUniEditorSaveOperation::RunL
|
|
727 |
//
|
|
728 |
// ---------------------------------------------------------
|
|
729 |
//
|
|
730 |
void CUniEditorSaveOperation::RunL()
|
|
731 |
{
|
|
732 |
PrintOperationAndState();
|
|
733 |
|
|
734 |
if ( !SetErrorAndReport( iStatus.Int() ) )
|
|
735 |
{
|
|
736 |
DoSaveStepL();
|
|
737 |
}
|
|
738 |
}
|
|
739 |
// ---------------------------------------------------------
|
|
740 |
// CUniEditorSaveOperation::RunError
|
|
741 |
// ---------------------------------------------------------
|
|
742 |
//
|
|
743 |
TInt CUniEditorSaveOperation::RunError( TInt aError )
|
|
744 |
{
|
|
745 |
|
|
746 |
if(aError == KErrDiskFull)
|
|
747 |
{
|
|
748 |
iOperationState = EUniEditorSaveError;
|
|
749 |
CompleteSelf( KErrNone );
|
|
750 |
return KErrNone;
|
|
751 |
}
|
|
752 |
if ( aError == KLeaveExit )
|
|
753 |
{
|
|
754 |
return KLeaveExit;
|
|
755 |
}
|
|
756 |
else
|
|
757 |
{
|
|
758 |
CompleteSelf( aError );
|
|
759 |
return KErrNone;
|
|
760 |
}
|
|
761 |
}
|
|
762 |
|
|
763 |
// ---------------------------------------------------------
|
|
764 |
// CUniEditorSaveOperation::ObjectSaveReady
|
|
765 |
// ---------------------------------------------------------
|
|
766 |
//
|
|
767 |
void CUniEditorSaveOperation::ObjectSaveReady( TInt aError )
|
|
768 |
{
|
|
769 |
if ( iSavedObject )
|
|
770 |
{
|
|
771 |
iSavedObject = NULL;
|
|
772 |
iOperationState = EUniEditorSaveEnd;
|
|
773 |
}
|
|
774 |
else if ( iOperationState == EUniEditorSaveAttachment )
|
|
775 |
{
|
|
776 |
iOperationState = EUniEditorSaveSmilCompose;
|
|
777 |
}
|
|
778 |
else if ( iOperationState == EUniEditorSaveObjects )
|
|
779 |
{
|
|
780 |
iOperationState = EUniEditorSaveAttachment;
|
|
781 |
}
|
|
782 |
|
|
783 |
CompleteOperation( aError );
|
|
784 |
}
|
|
785 |
|
|
786 |
// ---------------------------------------------------------
|
|
787 |
// CUniEditorSaveOperation::SmilComposeEvent
|
|
788 |
// ---------------------------------------------------------
|
|
789 |
//
|
|
790 |
void CUniEditorSaveOperation::SmilComposeEvent( TInt aError )
|
|
791 |
{
|
|
792 |
iOperationState = EUniEditorSaveFinalize;
|
|
793 |
CompleteOperation( aError );
|
|
794 |
}
|
|
795 |
|
|
796 |
// EOF
|