25
|
1 |
/*
|
|
2 |
* Copyright (c) 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 : Compose view class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include "emailtrace.h"
|
|
20 |
#include <aknnotewrappers.h>
|
|
21 |
#include <NpdApi.h>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <txtrich.h>
|
|
24 |
#include <AknWaitDialog.h>
|
|
25 |
#include <MsgAttachmentUtils.h>
|
|
26 |
#include <featmgr.h>
|
|
27 |
#include "cfsmailbox.h"
|
|
28 |
#include "cfsmailmessage.h"
|
|
29 |
#include "cfsmailaddress.h"
|
|
30 |
#include "cfsmailclient.h"
|
|
31 |
#include "cfsmailcommon.h"
|
|
32 |
#include <csxhelp/cmail.hlp.hrh>
|
|
33 |
#include <akntoolbar.h>
|
|
34 |
#include <akntoolbarextension.h>
|
|
35 |
#include <AknUtils.h>
|
|
36 |
#include <FreestyleEmailUi.rsg>
|
|
37 |
#include <freestyleemailui.mbg>
|
|
38 |
#include <aknstyluspopupmenu.h>
|
|
39 |
|
|
40 |
#include <wlaninternalpskeys.h>
|
|
41 |
#include "ncscomposeview.h"
|
|
42 |
#include "ncscomposeviewcontainer.h"
|
|
43 |
#include "ncsconstants.h"
|
|
44 |
#include "ncsutility.h"
|
|
45 |
#include "ncsemailaddressobject.h"
|
|
46 |
#include "freestyleemailcenrephandler.h"
|
|
47 |
#include "FreestyleEmailUi.hrh"
|
|
48 |
#include "FreestyleEmailUiConstants.h"
|
|
49 |
#include "FreestyleEmailUiSendAttachmentsListControl.h"
|
|
50 |
#include "FreestyleEmailUiSendAttachmentsListVisualiser.h"
|
|
51 |
#include "FreestyleEmailUiSendAttachmentsListModel.h"
|
|
52 |
#include "FreestyleEmailUiUtilities.h"
|
|
53 |
#include "FreestyleEmailUiConstants.h"
|
|
54 |
#include "FSAutoSaver.h"
|
|
55 |
#include "FSEmail.pan"
|
|
56 |
#include "cmailmessageext.h"
|
|
57 |
|
|
58 |
|
|
59 |
// line separators that should not appear in Subject
|
|
60 |
_LIT(KLineSeparators, "\u2029");
|
|
61 |
const TChar KReplacementChar = ' ';
|
|
62 |
|
|
63 |
|
|
64 |
#pragma mark +++COMPOSE VIEW - CONSTRUCTORS AND DESTRUCTORS
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
// Safe pointer deletion
|
|
68 |
//
|
|
69 |
// -----------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
template <class T> void SafeDelete( T*& aPtr )
|
|
72 |
{
|
|
73 |
delete aPtr;
|
|
74 |
aPtr = NULL;
|
|
75 |
}
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
// CNcsComposeView::CNcsComposeView()
|
|
79 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
CNcsComposeView::CNcsComposeView( CFreestyleEmailUiAppUi& aAppUi,
|
|
83 |
CAlfEnv& aEnv, CAlfControlGroup& aSendAttachmentControlGroup,
|
|
84 |
CFSMailClient& aMailClient, CMsvSession& aMsvSession )
|
|
85 |
: CFsEmailUiViewBase( aSendAttachmentControlGroup, aAppUi ),
|
|
86 |
iMailClient( aMailClient ), iOrigMessage( NULL ), iNewMessage( NULL ),
|
|
87 |
iMsvSession( aMsvSession ), iEnv( aEnv ),
|
|
88 |
iFakeSyncGoingOn(EFalse), iFetchDialogCancelled(EFalse),
|
|
89 |
iExecutingDoExitL( EFalse ),
|
|
90 |
iMessageTextPartModified( EFalse ), iMessageModified( EFalse )
|
|
91 |
{
|
|
92 |
FUNC_LOG;
|
|
93 |
|
|
94 |
iAttachmentListSaveDraft = EFalse;
|
|
95 |
|
|
96 |
}
|
|
97 |
|
|
98 |
// -----------------------------------------------------------------------------
|
|
99 |
// CNcsComposeView::NewL()
|
|
100 |
// Two-phased constructor.
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
CNcsComposeView* CNcsComposeView::NewL(
|
|
104 |
CFSMailClient& aMailClient, CAlfEnv& aEnv,
|
|
105 |
CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup,
|
|
106 |
CMsvSession& aMsvSession )
|
|
107 |
{
|
|
108 |
FUNC_LOG;
|
|
109 |
|
|
110 |
CNcsComposeView* self =
|
|
111 |
CNcsComposeView::NewLC( aMailClient, aEnv, aAppUi,
|
|
112 |
aControlGroup, aMsvSession );
|
|
113 |
CleanupStack::Pop( self );
|
|
114 |
|
|
115 |
return self;
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
// CNcsComposeView::NewLC()
|
|
120 |
// Two-phased constructor.
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
CNcsComposeView* CNcsComposeView::NewLC(
|
|
124 |
CFSMailClient& aMailClient,
|
|
125 |
CAlfEnv& aEnv,
|
|
126 |
CFreestyleEmailUiAppUi* aAppUi,
|
|
127 |
CAlfControlGroup& aControlGroup,
|
|
128 |
CMsvSession& aMsvSession )
|
|
129 |
{
|
|
130 |
FUNC_LOG;
|
|
131 |
|
|
132 |
CNcsComposeView* self = new ( ELeave ) CNcsComposeView(
|
|
133 |
*aAppUi, aEnv, aControlGroup, aMailClient, aMsvSession );
|
|
134 |
CleanupStack::PushL( self );
|
|
135 |
self->ConstructL();
|
|
136 |
|
|
137 |
return self;
|
|
138 |
}
|
|
139 |
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
// CNcsComposeView::ConstructL()
|
|
142 |
// Symbian 2nd phase constructor can leave.
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CNcsComposeView::ConstructL()
|
|
146 |
{
|
|
147 |
FUNC_LOG;
|
|
148 |
|
|
149 |
BaseConstructL( R_NCS_COMPOSE_VIEW );
|
|
150 |
iFirstStartCompleted = EFalse;
|
|
151 |
}
|
|
152 |
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
// CNcsComposeView::DoFirstStartL()
|
|
155 |
// Purpose of this function is to do first start only when msg details is
|
|
156 |
// really needed to be shown. Implemented to make app startuo faster.
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
void CNcsComposeView::DoFirstStartL()
|
|
160 |
{
|
|
161 |
FUNC_LOG;
|
|
162 |
// Attachment list for compose screen, owned by AlfEnv
|
|
163 |
CAlfControlGroup& attListControlGroup =
|
|
164 |
iEnv.NewControlGroupL( KSendAttachmentManagerDisplayGroup );
|
|
165 |
CFSEmailUiSendAttachmentsListVisualiser* sendAttachmentVisualiser =
|
|
166 |
CFSEmailUiSendAttachmentsListVisualiser::NewLC(
|
|
167 |
iEnv, &iAppUi, attListControlGroup );
|
|
168 |
iAppUi.AddViewL( sendAttachmentVisualiser );
|
|
169 |
CleanupStack::Pop( sendAttachmentVisualiser );
|
|
170 |
|
|
171 |
iCrHandler = CFSEmailCRHandler::InstanceL(); // singleton, not owned
|
|
172 |
|
|
173 |
iEnv.AddActionObserverL( this );
|
|
174 |
|
|
175 |
iAutoSaver = CFsAutoSaver::NewL( iEnv, KAutoSaveTimeDelayMs );
|
|
176 |
iAutoSaver->Enable( EFalse );
|
|
177 |
iFirstStartCompleted = ETrue;
|
|
178 |
iCheckQuery = EFalse;
|
|
179 |
iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
|
|
180 |
// msk context menu added into composer
|
|
181 |
MenuBar()->SetContextMenuTitleResourceId( R_NCS_COMPOSE_BODY_MSK_MENUBAR );
|
|
182 |
iActiveHelper = CActiveHelper::NewL( this );
|
|
183 |
|
|
184 |
iAsyncAttachmentAdd =
|
|
185 |
new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
|
|
186 |
|
|
187 |
// Initializing the default stylus long tap popup menu
|
|
188 |
if( !iStylusPopUpMenu )
|
|
189 |
{
|
|
190 |
TPoint point( 0, 0 );
|
|
191 |
iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this, point );
|
|
192 |
TResourceReader reader;
|
|
193 |
iCoeEnv->CreateResourceReaderLC( reader,
|
|
194 |
R_STYLUS_POPUP_MENU_COMPOSE_VIEW_ATTACHMENT );
|
|
195 |
iStylusPopUpMenu->ConstructFromResourceL( reader );
|
|
196 |
CleanupStack::PopAndDestroy(); // reader
|
|
197 |
}
|
|
198 |
}
|
|
199 |
|
|
200 |
// -----------------------------------------------------------------------------
|
|
201 |
// CNcsComposeView::~CNcsComposeView()
|
|
202 |
// Destructor.
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
CNcsComposeView::~CNcsComposeView()
|
|
206 |
{
|
|
207 |
FUNC_LOG;
|
|
208 |
delete iAutoSaver;
|
|
209 |
if ( iAsyncCallback )
|
|
210 |
{
|
|
211 |
iAsyncCallback->Cancel();
|
|
212 |
delete iAsyncCallback;
|
|
213 |
}
|
|
214 |
delete iFetchLogic;
|
|
215 |
if( iActiveHelper )
|
|
216 |
{
|
|
217 |
iActiveHelper->Cancel();
|
|
218 |
delete iActiveHelper;
|
|
219 |
}
|
|
220 |
if ( iAsyncAttachmentAdd )
|
|
221 |
{
|
|
222 |
iAsyncAttachmentAdd->Cancel();
|
|
223 |
delete iAsyncAttachmentAdd;
|
|
224 |
}
|
|
225 |
delete iStylusPopUpMenu;
|
|
226 |
}
|
|
227 |
|
|
228 |
void CNcsComposeView::PrepareForExit()
|
|
229 |
{
|
|
230 |
FUNC_LOG;
|
|
231 |
if ( iCheckQuery && iDlg )
|
|
232 |
{
|
|
233 |
TKeyEvent check = { EKeyEscape, EStdKeyNull, 0, 0 };
|
|
234 |
TRAP_IGNORE( iDlg->OfferKeyEventL( check, EEventKey ) );
|
|
235 |
iDlg = NULL;
|
|
236 |
|
|
237 |
iAsyncCallback->Cancel(); // cancel any outstanding callback
|
|
238 |
iAsyncCallback->Set( TCallBack( AsyncExit, this ) );
|
|
239 |
iAsyncCallback->CallBack();
|
|
240 |
}
|
|
241 |
else if( iFakeSyncGoingOn || iExecutingDoExitL )
|
|
242 |
{
|
|
243 |
// low priority active obj so that iwait in plugins finish
|
|
244 |
iActiveHelper->Cancel();
|
|
245 |
iActiveHelper->Start();
|
|
246 |
}
|
|
247 |
else if ( iIncludeMessageTextAsync )
|
|
248 |
{
|
|
249 |
if ( iContainer )
|
|
250 |
{
|
|
251 |
iContainer->StopAsyncTextFormatter();
|
|
252 |
}
|
|
253 |
ResetComposer();
|
|
254 |
iAsyncCallback->Cancel(); // cancel any outstanding callback
|
|
255 |
iAsyncCallback->Set( TCallBack( AsyncExit, this ) );
|
|
256 |
iAsyncCallback->CallBack();
|
|
257 |
}
|
|
258 |
else
|
|
259 |
{
|
|
260 |
DoSafeExit( ESaveDraft );
|
|
261 |
|
|
262 |
// cleaning - usefull when application is closed from task switcher
|
|
263 |
HideToolbar();
|
|
264 |
}
|
|
265 |
|
|
266 |
if( iFetchLogic )
|
|
267 |
{
|
|
268 |
iFetchLogic->CancelFetchings();
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
// -----------------------------------------------------------------------------
|
|
273 |
// CNcsComposeView::Id()
|
|
274 |
// Returns View's ID.
|
|
275 |
// -----------------------------------------------------------------------------
|
|
276 |
//
|
|
277 |
TUid CNcsComposeView::Id() const
|
|
278 |
{
|
|
279 |
FUNC_LOG;
|
|
280 |
return MailEditorId;
|
|
281 |
}
|
|
282 |
|
|
283 |
// -----------------------------------------------------------------------------
|
|
284 |
// CNcsComposeView::ChildDoActivateL()
|
|
285 |
// Activate the Compose view
|
|
286 |
// -----------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId,
|
|
289 |
TUid aCustomMessageId, const TDesC8& aCustomMessage )
|
|
290 |
{
|
|
291 |
FUNC_LOG;
|
|
292 |
|
|
293 |
// needed when "Opening" (replying/forwarding)note is shown and
|
|
294 |
// we receive incoming call- Email application goes to background.
|
|
295 |
// When coming back to application the view is activated and reseted.
|
|
296 |
// That's why we prevent activation and the same is done in ChildDoDeactivate
|
|
297 |
if ( iIncludeMessageTextAsync )
|
|
298 |
{
|
|
299 |
return;
|
|
300 |
}
|
|
301 |
|
|
302 |
if ( !iFirstStartCompleted )
|
|
303 |
{
|
|
304 |
DoFirstStartL();
|
|
305 |
}
|
|
306 |
Toolbar()->SetDimmed( ETrue );
|
|
307 |
// Set status pane indicators
|
|
308 |
iStatusPaneIndicators = iAppUi.GetStatusPaneIndicatorContainer();
|
|
309 |
iStatusPaneIndicators->ShowStatusPaneIndicators();
|
|
310 |
|
|
311 |
// Notify base class about view being entered unless
|
|
312 |
// returned from another view
|
|
313 |
if ( aCustomMessageId.iUid != KEditorCmdReturnToPrevious )
|
|
314 |
{
|
|
315 |
ViewEntered( aPrevViewId );
|
|
316 |
}
|
|
317 |
|
|
318 |
// Cleanup the previous message before opening a new one
|
|
319 |
SaveAndCleanPreviousMessage();
|
|
320 |
|
|
321 |
// Get the launch parameters
|
|
322 |
if ( aCustomMessageId.iUid == KEditorCmdReturnToPrevious )
|
|
323 |
{
|
|
324 |
// Use previous launch parameters when returning to previously
|
|
325 |
// opened message
|
|
326 |
iMailBox = iMailClient.GetMailBoxByUidL( iLaunchParams.iMailboxId );
|
|
327 |
}
|
|
328 |
else if ( aCustomMessage.Length() > 0 )
|
|
329 |
{
|
|
330 |
|
|
331 |
TPckgBuf<TEditorLaunchParams> buf( iLaunchParams );
|
|
332 |
buf.Copy( aCustomMessage );
|
|
333 |
iLaunchParams = buf();
|
|
334 |
iMailBox = iMailClient.GetMailBoxByUidL( iLaunchParams.iMailboxId );
|
|
335 |
|
|
336 |
}
|
|
337 |
else
|
|
338 |
{
|
|
339 |
iLaunchParams.iActivatedExternally = ETrue;
|
|
340 |
}
|
|
341 |
|
|
342 |
// Inform the AppUi about external view activation to fix the view stack.
|
|
343 |
// Normally this happens based on the previous view AppUid in the BaseView
|
|
344 |
// but in case contacts action menu was used within FsEmail, this doesn'
|
|
345 |
// work. It doesn't hurt to call this again even if it was already called
|
|
346 |
// once from BaseView.
|
|
347 |
if ( iLaunchParams.iActivatedExternally )
|
|
348 |
{
|
|
349 |
iAppUi.ViewActivatedExternallyL( Id() );
|
|
350 |
}
|
|
351 |
|
|
352 |
// Try to get the mailbox by other means if using launch parameters failed
|
|
353 |
if ( !iMailBox )
|
|
354 |
{
|
|
355 |
TInt error( KErrNone );
|
|
356 |
|
|
357 |
// can we get it from MSV Id
|
|
358 |
// MSV id is passed to us when account is defined email key settings
|
|
359 |
if ( aCustomMessageId != TUid::Null() )
|
|
360 |
{
|
|
361 |
TRAP( error, iMailBox = TFsEmailUiUtility::GetMailboxForMtmIdL(
|
|
362 |
iMailClient, iMsvSession, aCustomMessageId.iUid ) );
|
|
363 |
}
|
|
364 |
|
|
365 |
error = KErrNone;
|
|
366 |
|
|
367 |
// try to use mailbox set as default in MCE
|
|
368 |
if ( !iMailBox )
|
|
369 |
{
|
|
370 |
TRAP( error, iMailBox = TFsEmailUiUtility::GetMceDefaultMailboxL(
|
|
371 |
iMailClient, iMsvSession ) );
|
|
372 |
}
|
|
373 |
|
|
374 |
// use first mail account from the list
|
|
375 |
if ( !iMailBox )
|
|
376 |
{
|
|
377 |
TFSMailMsgId id;
|
|
378 |
RPointerArray<CFSMailBox> mailboxes;
|
|
379 |
CleanupResetAndDestroyClosePushL( mailboxes );
|
|
380 |
iMailClient.ListMailBoxes( id, mailboxes );
|
|
381 |
if ( mailboxes.Count() > 0 )
|
|
382 |
{
|
|
383 |
iMailBox =
|
|
384 |
iMailClient.GetMailBoxByUidL( mailboxes[0]->GetId() );
|
|
385 |
}
|
|
386 |
CleanupStack::PopAndDestroy( &mailboxes );
|
|
387 |
}
|
|
388 |
|
|
389 |
// could not get mailbox so leave
|
|
390 |
if ( !iMailBox )
|
|
391 |
{
|
|
392 |
User::Leave( KErrGeneral );
|
|
393 |
}
|
|
394 |
|
|
395 |
aCustomMessageId = TUid::Uid( KEditorCmdCreateNew );
|
|
396 |
}
|
|
397 |
|
|
398 |
|
|
399 |
iMailSent = EFalse;
|
|
400 |
iMailSendFailed = EFalse;
|
|
401 |
iCustomMessageId = aCustomMessageId;
|
|
402 |
|
|
403 |
CreateContainerL();
|
|
404 |
|
|
405 |
TRAPD( err, HandleActivationCommandL( aCustomMessageId ) );
|
|
406 |
if ( !err )
|
|
407 |
{
|
|
408 |
err = iMailFetchingErrCode;
|
|
409 |
}
|
|
410 |
|
|
411 |
if ( err == KErrCancel ||
|
|
412 |
err == KErrCouldNotConnect ||
|
|
413 |
err == KErrConnectionTerminated )
|
|
414 |
{
|
|
415 |
// Just close composer without any notes if operation was cancelled.
|
|
416 |
// For connection errors, DownloadInfoMediator already shows error
|
|
417 |
// message, so no need to show another one.
|
|
418 |
ExitComposer();
|
|
419 |
}
|
|
420 |
else if ( err )
|
|
421 |
{
|
|
422 |
// some other error => show generic error note and close composer
|
|
423 |
if( !iAppUi.AppUiExitOngoing() )
|
|
424 |
TFsEmailUiUtility::ShowErrorNoteL(
|
|
425 |
R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
|
|
426 |
ExitComposer();
|
|
427 |
}
|
|
428 |
else
|
|
429 |
{
|
|
430 |
// everything went fine => do rest of the generic initialization
|
|
431 |
InitUiGeneralL();
|
|
432 |
iAppUi.StartEndKeyCapture();
|
|
433 |
iContainer->SetMskL();
|
|
434 |
iViewReady = ETrue;
|
|
435 |
Toolbar()->SetDimmed( EFalse );
|
|
436 |
RefreshToolbar();
|
|
437 |
iContainer->ActivateL();
|
|
438 |
}
|
|
439 |
|
|
440 |
// if there is a embedded app in FSEmail.
|
|
441 |
if( iAppUi.EmbeddedApp() )
|
|
442 |
{
|
|
443 |
// Set email editor started from embedded app flag to true
|
|
444 |
// so that we can switch view correct when sent email.
|
|
445 |
iAppUi.SetEditorStartedFromEmbeddedApp( ETrue );
|
|
446 |
|
|
447 |
RWsSession rwsSession;
|
|
448 |
User::LeaveIfError( rwsSession.Connect() );
|
|
449 |
CleanupClosePushL( rwsSession );
|
|
450 |
|
|
451 |
// Simulate a back key to exit embedded app
|
|
452 |
// so that email editor could show on the top level.
|
|
453 |
TKeyEvent KeyEvent = TKeyEvent();
|
|
454 |
// this is neccesary for photogalery image viewer (don't remove)
|
|
455 |
KeyEvent.iScanCode = EStdKeyUpArrow;
|
|
456 |
rwsSession.SimulateKeyEvent( KeyEvent );
|
|
457 |
KeyEvent.iCode = EKeyCBA2;
|
|
458 |
rwsSession.SimulateKeyEvent( KeyEvent );
|
|
459 |
|
|
460 |
rwsSession.Close();
|
|
461 |
CleanupStack::PopAndDestroy( &rwsSession );
|
|
462 |
}
|
|
463 |
|
|
464 |
if ( iIncludeMessageTextAsync )
|
|
465 |
{
|
|
466 |
// including message body in async way
|
|
467 |
IncludeMessageTextAsyncL( ETrue );
|
|
468 |
}
|
|
469 |
|
|
470 |
iViewFullyActivated = ETrue;
|
|
471 |
|
|
472 |
TIMESTAMP( "Editor launched" );
|
|
473 |
}
|
|
474 |
|
|
475 |
// -----------------------------------------------------------------------------
|
|
476 |
// Initialises toolbar items.
|
|
477 |
// -----------------------------------------------------------------------------
|
|
478 |
//
|
|
479 |
void CNcsComposeView::DynInitToolbarL( TInt aResourceId,
|
|
480 |
CAknToolbar* aToolbar )
|
|
481 |
{
|
|
482 |
FUNC_LOG;
|
|
483 |
if ( aResourceId == EFsEmailUiTbCmdExpandActions && aToolbar )
|
|
484 |
{
|
|
485 |
CAknToolbarExtension* ext = aToolbar->ToolbarExtension();
|
|
486 |
if ( iContainer )
|
|
487 |
{
|
|
488 |
// Set correct state for show/hide cc field button.
|
|
489 |
CAknButton* ccButton = Button( EFsEmailUiTbCmdCcField, ext );
|
|
490 |
if ( ccButton )
|
|
491 |
{
|
|
492 |
TInt index = iContainer->IsCcFieldVisible() ? 1 : 0;
|
|
493 |
ccButton->SetCurrentState( index, EFalse );
|
|
494 |
|
|
495 |
// Command is dimmed, if there is content in the field.
|
|
496 |
ccButton->SetDimmed( iContainer->GetCcFieldLength() > 0 );
|
|
497 |
}
|
|
498 |
|
|
499 |
// Set correct state for show/hide bcc field button.
|
|
500 |
CAknButton* bccButton = Button( EFsEmailUiTbCmdBccField, ext );
|
|
501 |
if ( bccButton )
|
|
502 |
{
|
|
503 |
TInt index = iContainer->IsBccFieldVisible() ? 1 : 0;
|
|
504 |
bccButton->SetCurrentState( index, EFalse );
|
|
505 |
|
|
506 |
// Command is dimmed, if there is content in the field.
|
|
507 |
bccButton->SetDimmed( iContainer->GetBccFieldLength() > 0 );
|
|
508 |
}
|
|
509 |
}
|
|
510 |
else
|
|
511 |
{
|
|
512 |
ext->HideItemL( EFsEmailUiTbCmdCcField, ETrue );
|
|
513 |
ext->HideItemL( EFsEmailUiTbCmdBccField, ETrue );
|
|
514 |
}
|
|
515 |
|
|
516 |
if ( iNewMessage )
|
|
517 |
{
|
|
518 |
// Set correct state for low priority button.
|
|
519 |
TBool lowPriority = iNewMessage->IsFlagSet( EFSMsgFlag_Low );
|
|
520 |
CAknButton* lowPriorityButton = static_cast<CAknButton*>(
|
|
521 |
ext->ControlOrNull( EFsEmailUiTbCmdLowPriority ) );
|
|
522 |
if ( lowPriorityButton )
|
|
523 |
{
|
|
524 |
TInt index = lowPriority ? 1 : 0;
|
|
525 |
lowPriorityButton->SetCurrentState( index, EFalse );
|
|
526 |
}
|
|
527 |
|
|
528 |
// Set correct state for high priority button.
|
|
529 |
TBool highPriority = iNewMessage->IsFlagSet( EFSMsgFlag_Important );
|
|
530 |
CAknButton* highPriorityButton = static_cast<CAknButton*>(
|
|
531 |
ext->ControlOrNull( EFsEmailUiTbCmdHighPriority ) );
|
|
532 |
if ( highPriorityButton )
|
|
533 |
{
|
|
534 |
TInt index = highPriority ? 1 : 0;
|
|
535 |
highPriorityButton->SetCurrentState( index, EFalse );
|
|
536 |
}
|
|
537 |
|
|
538 |
// Set correct state for follow up button.
|
|
539 |
TBool followUp = iNewMessage->IsFlagSet( EFSMsgFlag_FollowUp );
|
|
540 |
CAknButton* followUpButton = static_cast<CAknButton*>(
|
|
541 |
ext->ControlOrNull( EFsEmailUiTbCmdFollowUp ) );
|
|
542 |
if ( followUpButton )
|
|
543 |
{
|
|
544 |
TInt index = followUp ? 1 : 0;
|
|
545 |
followUpButton->SetCurrentState( index, EFalse );
|
|
546 |
|
|
547 |
// Hide follow up button, if follow up is not supported.
|
|
548 |
ext->HideItemL( EFsEmailUiTbCmdFollowUp,
|
|
549 |
!TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) );
|
|
550 |
}
|
|
551 |
}
|
|
552 |
else
|
|
553 |
{
|
|
554 |
ext->HideItemL( EFsEmailUiTbCmdLowPriority, ETrue );
|
|
555 |
ext->HideItemL( EFsEmailUiTbCmdHighPriority, ETrue );
|
|
556 |
ext->HideItemL( EFsEmailUiTbCmdFollowUp, ETrue );
|
|
557 |
}
|
|
558 |
}
|
|
559 |
}
|
|
560 |
|
|
561 |
// -----------------------------------------------------------------------------
|
|
562 |
// CNcsComposeView::OfferToolbarEventL
|
|
563 |
// -----------------------------------------------------------------------------
|
|
564 |
void CNcsComposeView::OfferToolbarEventL( TInt aCommand )
|
|
565 |
{
|
|
566 |
FUNC_LOG;
|
|
567 |
TBool attachmentAddition = EFalse;
|
|
568 |
switch ( aCommand )
|
|
569 |
{
|
|
570 |
case EFsEmailUiTbCmdSend:
|
|
571 |
if ( iContainer && iContainer->AreAddressFieldsEmpty() )
|
|
572 |
{
|
|
573 |
RefreshToolbar();
|
|
574 |
}
|
|
575 |
else
|
|
576 |
{
|
|
577 |
HandleCommandL( ENcsCmdSend );
|
|
578 |
}
|
|
579 |
break;
|
|
580 |
case EFsEmailUiTbCmdCcField:
|
|
581 |
{
|
|
582 |
CAknButton* ccFieldButton = Button( EFsEmailUiTbCmdCcField );
|
|
583 |
if ( ccFieldButton )
|
|
584 |
{
|
|
585 |
if ( ccFieldButton->StateIndex() )
|
|
586 |
{
|
|
587 |
HandleCommandL( ENcsCmdShowCc );
|
|
588 |
}
|
|
589 |
else
|
|
590 |
{
|
|
591 |
HandleCommandL( ENcsCmdHideCc );
|
|
592 |
}
|
|
593 |
}
|
|
594 |
break;
|
|
595 |
}
|
|
596 |
case EFsEmailUiTbCmdBccField:
|
|
597 |
{
|
|
598 |
CAknButton* bccFieldButton = Button( EFsEmailUiTbCmdBccField );
|
|
599 |
if ( bccFieldButton )
|
|
600 |
{
|
|
601 |
if ( bccFieldButton->StateIndex() )
|
|
602 |
{
|
|
603 |
HandleCommandL( ENcsCmdShowBcc );
|
|
604 |
}
|
|
605 |
else
|
|
606 |
{
|
|
607 |
HandleCommandL( ENcsCmdHideBcc );
|
|
608 |
}
|
|
609 |
}
|
|
610 |
break;
|
|
611 |
}
|
|
612 |
case EFsEmailUiTbCmdLowPriority:
|
|
613 |
{
|
|
614 |
CAknButton* lowPriorityButton = Button( EFsEmailUiTbCmdLowPriority );
|
|
615 |
if ( lowPriorityButton )
|
|
616 |
{
|
|
617 |
if ( lowPriorityButton->StateIndex() )
|
|
618 |
{
|
|
619 |
CAknButton* highPriorityButton = Button(
|
|
620 |
EFsEmailUiTbCmdHighPriority );
|
|
621 |
if ( highPriorityButton )
|
|
622 |
{
|
|
623 |
highPriorityButton->SetCurrentState( 0, ETrue );
|
|
624 |
}
|
|
625 |
HandleCommandL( ENcsCmdPriorityLow );
|
|
626 |
}
|
|
627 |
else
|
|
628 |
{
|
|
629 |
HandleCommandL( ENcsCmdPriorityNormal );
|
|
630 |
}
|
|
631 |
}
|
|
632 |
break;
|
|
633 |
}
|
|
634 |
case EFsEmailUiTbCmdHighPriority:
|
|
635 |
{
|
|
636 |
CAknButton* highPriorityButton = Button( EFsEmailUiTbCmdHighPriority );
|
|
637 |
if ( highPriorityButton )
|
|
638 |
{
|
|
639 |
if ( highPriorityButton->StateIndex() )
|
|
640 |
{
|
|
641 |
CAknButton* lowPriorityButton = Button(
|
|
642 |
EFsEmailUiTbCmdLowPriority );
|
|
643 |
if ( lowPriorityButton )
|
|
644 |
{
|
|
645 |
lowPriorityButton->SetCurrentState( 0, ETrue );
|
|
646 |
}
|
|
647 |
HandleCommandL( ENcsCmdPriorityHigh );
|
|
648 |
}
|
|
649 |
else
|
|
650 |
{
|
|
651 |
HandleCommandL( ENcsCmdPriorityNormal );
|
|
652 |
}
|
|
653 |
}
|
|
654 |
break;
|
|
655 |
}
|
|
656 |
case EFsEmailUiTbCmdFollowUp:
|
|
657 |
{
|
|
658 |
CAknButton* button = Button( EFsEmailUiTbCmdFollowUp );
|
|
659 |
if ( button && iNewMessage )
|
|
660 |
{
|
|
661 |
if ( button->StateIndex() )
|
|
662 |
{
|
|
663 |
iNewMessage->SetFlag( EFSMsgFlag_FollowUp );
|
|
664 |
iNewMessage->ResetFlag( EFSMsgFlag_FollowUpComplete );
|
|
665 |
iStatusPaneIndicators->SetFollowUpFlag(
|
|
666 |
CCustomStatuspaneIndicators::EFollowUp );
|
|
667 |
}
|
|
668 |
else
|
|
669 |
{
|
|
670 |
iNewMessage->ResetFlag( EFSMsgFlag_FollowUp
|
|
671 |
| EFSMsgFlag_FollowUpComplete );
|
|
672 |
iStatusPaneIndicators->SetFollowUpFlag(
|
|
673 |
CCustomStatuspaneIndicators::EFollowUpNone );
|
|
674 |
}
|
|
675 |
}
|
|
676 |
break;
|
|
677 |
}
|
|
678 |
case EFsEmailUiTbCmdInsertAudio:
|
|
679 |
iAttachmentAddType = MsgAttachmentUtils::EAudio;
|
|
680 |
attachmentAddition = ETrue;
|
|
681 |
break;
|
|
682 |
case EFsEmailUiTbCmdInsertImage:
|
|
683 |
iAttachmentAddType = MsgAttachmentUtils::EImage;
|
|
684 |
attachmentAddition = ETrue;
|
|
685 |
break;
|
|
686 |
case EFsEmailUiTbCmdInsertVideo:
|
|
687 |
iAttachmentAddType = MsgAttachmentUtils::EVideo;
|
|
688 |
attachmentAddition = ETrue;
|
|
689 |
break;
|
|
690 |
case EFsEmailUiTbCmdInsertNote:
|
|
691 |
iAttachmentAddType = MsgAttachmentUtils::ENote;
|
|
692 |
attachmentAddition = ETrue;
|
|
693 |
break;
|
|
694 |
case EFsEmailUiTbCmdInsertPresentation:
|
|
695 |
iAttachmentAddType = MsgAttachmentUtils::ESVG;
|
|
696 |
attachmentAddition = ETrue;
|
|
697 |
break;
|
|
698 |
case EFsEmailUiTbCmdInsertOther:
|
|
699 |
iAttachmentAddType = MsgAttachmentUtils::EUnknown;
|
|
700 |
attachmentAddition = ETrue;
|
|
701 |
break;
|
|
702 |
default:
|
|
703 |
break;
|
|
704 |
}
|
|
705 |
if ( attachmentAddition )
|
|
706 |
{
|
|
707 |
iAsyncAttachmentAdd->Cancel(); // cancel any outstanding callback
|
|
708 |
iAsyncAttachmentAdd->Set( TCallBack( AsyncAddAttachment, this ) );
|
|
709 |
iAsyncAttachmentAdd->CallBack();
|
|
710 |
}
|
|
711 |
}
|
|
712 |
|
|
713 |
// -----------------------------------------------------------------------------
|
|
714 |
// CNcsComposeView::ToolbarResourceId()
|
|
715 |
// -----------------------------------------------------------------------------
|
|
716 |
//
|
|
717 |
TInt CNcsComposeView::ToolbarResourceId() const
|
|
718 |
{
|
|
719 |
FUNC_LOG;
|
|
720 |
return R_FREESTYLE_EMAIL_UI_TOOLBAR_MESSAGE_EDITOR;
|
|
721 |
}
|
|
722 |
|
|
723 |
// -----------------------------------------------------------------------------
|
|
724 |
// CNcsComposeView::GetInitiallyDimmedItemsL()
|
|
725 |
// -----------------------------------------------------------------------------
|
|
726 |
//
|
|
727 |
void CNcsComposeView::GetInitiallyDimmedItemsL( const TInt aResourceId,
|
|
728 |
RArray<TInt>& aDimmedItems ) const
|
|
729 |
{
|
|
730 |
FUNC_LOG;
|
|
731 |
aDimmedItems.Reset();
|
|
732 |
switch ( aResourceId )
|
|
733 |
{
|
|
734 |
case R_FREESTYLE_EMAIL_UI_TOOLBAR_MESSAGE_EDITOR:
|
|
735 |
aDimmedItems.AppendL( EFsEmailUiTbCmdSend );
|
|
736 |
break;
|
|
737 |
default:
|
|
738 |
break;
|
|
739 |
}
|
|
740 |
}
|
|
741 |
|
|
742 |
// -----------------------------------------------------------------------------
|
|
743 |
// CNcsComposeView::RefreshToolbar()
|
|
744 |
// -----------------------------------------------------------------------------
|
|
745 |
//
|
|
746 |
void CNcsComposeView::RefreshToolbar()
|
|
747 |
{
|
|
748 |
FUNC_LOG;
|
|
749 |
if ( iContainer )
|
|
750 |
{
|
|
751 |
// Hide toolbar if remotesearch is in progress,
|
|
752 |
// because it takes you into a different view
|
|
753 |
TBool hideToolbar = ( iContainer->IsRemoteSearchInprogress()
|
|
754 |
|| iAddingAttachmentDialogOpened );
|
|
755 |
SetToolbarItemDimmed( EFsEmailUiTbCmdSend, iContainer->AreAddressFieldsEmpty() );
|
|
756 |
|
|
757 |
CAknToolbar* toolbar(Toolbar());
|
|
758 |
if (toolbar)
|
|
759 |
{
|
|
760 |
toolbar->SetToolbarVisibility(!hideToolbar);
|
|
761 |
// If toolbar is not hidden, redraw it (otherwise only dimmed/undimmed button will be redrawn)
|
|
762 |
if(!hideToolbar)
|
|
763 |
{
|
|
764 |
toolbar->DrawDeferred();
|
|
765 |
}
|
|
766 |
}
|
|
767 |
}
|
|
768 |
}
|
|
769 |
|
|
770 |
// -----------------------------------------------------------------------------
|
|
771 |
// CNcsComposeView::ChildDoDeactivate()
|
|
772 |
// Deactivate the Compose view
|
|
773 |
// -----------------------------------------------------------------------------
|
|
774 |
//
|
|
775 |
void CNcsComposeView::ChildDoDeactivate()
|
|
776 |
{
|
|
777 |
FUNC_LOG;
|
|
778 |
|
|
779 |
// see comment in ChildDoActivate
|
|
780 |
if ( iIncludeMessageTextAsync && !iAppUi.AppUiExitOngoing() )
|
|
781 |
{
|
|
782 |
return;
|
|
783 |
}
|
|
784 |
|
|
785 |
iViewFullyActivated = EFalse;
|
|
786 |
|
|
787 |
iAppUi.StopEndKeyCapture();
|
|
788 |
|
|
789 |
SafeDelete( iFetchLogic );
|
|
790 |
|
|
791 |
// Normally Comopser state has been already cleaned by now but in special
|
|
792 |
// cases (like external view activation while in Composer) this may not be
|
|
793 |
// the case. In those cases the message needs to be saved before the view
|
|
794 |
// is deactivated.
|
|
795 |
if ( !iAppUi.AppUiExitOngoing() )
|
|
796 |
{
|
|
797 |
SaveAndCleanPreviousMessage();
|
|
798 |
}
|
|
799 |
|
|
800 |
}
|
|
801 |
|
|
802 |
// -----------------------------------------------------------------------------
|
|
803 |
// CNcsComposeView::DynInitMenuPaneL()
|
|
804 |
// -----------------------------------------------------------------------------
|
|
805 |
//
|
|
806 |
void CNcsComposeView::DynInitMenuPaneL( TInt aResourceId,
|
|
807 |
CEikMenuPane* aMenuPane )
|
|
808 |
{
|
|
809 |
FUNC_LOG;
|
|
810 |
|
|
811 |
if ( !iViewReady )
|
|
812 |
{
|
|
813 |
User::Leave( KErrNcsComposeViewNotReady );
|
|
814 |
}
|
|
815 |
|
|
816 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
817 |
__ASSERT_DEBUG( iMailBox, Panic( ENcsBasicUi ) );
|
|
818 |
__ASSERT_DEBUG( iNewMessage, Panic( ENcsBasicUi ) );
|
|
819 |
|
|
820 |
//we are forbiding to change MSK label, because popup will be opened
|
|
821 |
iContainer->SwitchChangeMskOff( ETrue );
|
|
822 |
|
|
823 |
if ( aResourceId == R_NCS_COMPOSE_MENU )
|
|
824 |
{
|
|
825 |
if ( FeatureManager::FeatureSupported(
|
|
826 |
KFeatureIdFfCmailIntegration ) )
|
|
827 |
{
|
|
828 |
// remove help support in pf5250
|
|
829 |
aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);
|
|
830 |
}
|
|
831 |
|
|
832 |
// Disable send if there are no addresses in any of the AIF fields,
|
|
833 |
if ( iContainer->AreAddressFieldsEmpty() )
|
|
834 |
{
|
|
835 |
aMenuPane->DeleteMenuItem( ENcsCmdSend );
|
|
836 |
}
|
|
837 |
|
|
838 |
// If no attachments, delete the remove attachments menu item
|
|
839 |
CFreestyleEmailUiSendAttachmentsListControl* attachmentControl;
|
|
840 |
attachmentControl = AttachmentsListControl();
|
|
841 |
TInt count = attachmentControl->Model()->Count();
|
|
842 |
|
|
843 |
// if mail has remote attachments then attachments can't be
|
|
844 |
// removed via options menu
|
|
845 |
if ( count <= 0 ||
|
|
846 |
AttachmentsListControl()->Model()->HasReadOnlyAttachments() )
|
|
847 |
{
|
|
848 |
aMenuPane->DeleteMenuItem( ENcsCmdRemoveAttachment );
|
|
849 |
aMenuPane->DeleteMenuItem( ENcsCmdRemoveAllAttachments );
|
|
850 |
}
|
|
851 |
else if ( count == 1 )
|
|
852 |
{
|
|
853 |
aMenuPane->DeleteMenuItem( ENcsCmdRemoveAllAttachments );
|
|
854 |
}
|
|
855 |
else
|
|
856 |
{
|
|
857 |
aMenuPane->DeleteMenuItem( ENcsCmdRemoveAttachment );
|
|
858 |
}
|
|
859 |
|
|
860 |
if ( iContainer->GetCcFieldLength() > 0 &&
|
|
861 |
iContainer->GetBccFieldLength() > 0 )
|
|
862 |
{
|
|
863 |
aMenuPane->DeleteMenuItem( ENcsCmdMore );
|
|
864 |
}
|
|
865 |
|
|
866 |
if ( !TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) )
|
|
867 |
{
|
|
868 |
aMenuPane->DeleteMenuItem( ENcsCmdFlag );
|
|
869 |
}
|
|
870 |
}
|
|
871 |
|
|
872 |
if ( aResourceId == R_NCS_EXTRA_RECEPIENT_FIELDS_MENU )
|
|
873 |
{
|
|
874 |
// Select which View->CC menu items to show
|
|
875 |
if ( iContainer->IsCcFieldVisible() )
|
|
876 |
{
|
|
877 |
aMenuPane->DeleteMenuItem( ENcsCmdShowCc );
|
|
878 |
// if there is text in Cc field do not show "hide Cc" menu item
|
|
879 |
if ( iContainer->GetCcFieldLength() > 0 )
|
|
880 |
{
|
|
881 |
aMenuPane->DeleteMenuItem( ENcsCmdHideCc );
|
|
882 |
}
|
|
883 |
}
|
|
884 |
else
|
|
885 |
{
|
|
886 |
aMenuPane->DeleteMenuItem( ENcsCmdHideCc );
|
|
887 |
}
|
|
888 |
|
|
889 |
// Select which View->BCC menu items to show
|
|
890 |
if ( iContainer->IsBccFieldVisible() )
|
|
891 |
{
|
|
892 |
aMenuPane->DeleteMenuItem( ENcsCmdShowBcc );
|
|
893 |
// if there is text in Bcc field do not show "hide Bcc" menu item
|
|
894 |
if ( iContainer->GetBccFieldLength() > 0 )
|
|
895 |
{
|
|
896 |
aMenuPane->DeleteMenuItem( ENcsCmdHideBcc );
|
|
897 |
}
|
|
898 |
}
|
|
899 |
else
|
|
900 |
{
|
|
901 |
aMenuPane->DeleteMenuItem( ENcsCmdHideBcc );
|
|
902 |
}
|
|
903 |
}
|
|
904 |
|
|
905 |
if ( aResourceId == R_NCS_PRIORITY_MENU )
|
|
906 |
{
|
|
907 |
|
|
908 |
if ( iNewMessage->IsFlagSet( EFSMsgFlag_Important ) )
|
|
909 |
{
|
|
910 |
aMenuPane->DeleteMenuItem( ENcsCmdPriorityHigh );
|
|
911 |
}
|
|
912 |
else if ( iNewMessage->IsFlagSet( EFSMsgFlag_Low ) )
|
|
913 |
{
|
|
914 |
aMenuPane->DeleteMenuItem( ENcsCmdPriorityLow );
|
|
915 |
}
|
|
916 |
else
|
|
917 |
{
|
|
918 |
aMenuPane->DeleteMenuItem( ENcsCmdPriorityNormal );
|
|
919 |
}
|
|
920 |
}
|
|
921 |
|
|
922 |
}
|
|
923 |
|
|
924 |
// -----------------------------------------------------------------------------
|
|
925 |
// CNcsComposeView::HandleCommandL()
|
|
926 |
// Takes care of Command handling.
|
|
927 |
// -----------------------------------------------------------------------------
|
|
928 |
//
|
|
929 |
void CNcsComposeView::HandleCommandL( TInt aCommand )
|
|
930 |
{
|
|
931 |
FUNC_LOG;
|
|
932 |
|
|
933 |
// Attempt to handle commands only after view is fully activated and exit
|
|
934 |
// has not yet been initiated.
|
|
935 |
if ( iViewReady && !iAppUi.ViewSwitchingOngoing() )
|
|
936 |
{
|
|
937 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
938 |
__ASSERT_DEBUG( iNewMessage, Panic( ENcsBasicUi ) );
|
|
939 |
__ASSERT_DEBUG( iCrHandler, Panic( ENcsBasicUi ) );
|
|
940 |
|
|
941 |
switch( aCommand )
|
|
942 |
{
|
|
943 |
case ENcsCmdSend:
|
|
944 |
{
|
|
945 |
// Show query if the Subject field is empty
|
|
946 |
if ( iContainer->IsSubjectFieldEmpty() )
|
|
947 |
{
|
|
948 |
TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
|
|
949 |
R_FREESTYLE_EMAIL_QUERY_NO_SUBJECT );
|
|
950 |
if ( !answer )
|
|
951 |
{
|
|
952 |
// user didn't want to send yet
|
|
953 |
// -> go back to the message
|
|
954 |
return;
|
|
955 |
}
|
|
956 |
}
|
|
957 |
|
|
958 |
TRAPD( error, DoSendL() );
|
|
959 |
if ( !error )
|
|
960 |
{
|
|
961 |
// Sending successful
|
|
962 |
HBufC* confMessage = NULL;
|
|
963 |
if ( !TFsEmailUiUtility::IsOfflineModeL() || WLANConnectionActive() )
|
|
964 |
{
|
|
965 |
// when sync status is currently ONLINE
|
|
966 |
confMessage = StringLoader::LoadLC(
|
|
967 |
R_FREESTYLE_EMAIL_CONFIRM_NOTE_SENDING_QUEUED );
|
|
968 |
}
|
|
969 |
else
|
|
970 |
{
|
|
971 |
// when sync status is currently OFFLINE
|
|
972 |
confMessage = StringLoader::LoadLC(
|
|
973 |
R_FREESTYLE_EMAIL_CONFIRM_NOTE_QUEUED_UNTIL_ONLINE );
|
|
974 |
}
|
|
975 |
CAknConfirmationNote* note =
|
|
976 |
new (ELeave) CAknConfirmationNote( ETrue ); //waiting
|
|
977 |
note->SetTimeout( CAknNoteDialog::ELongTimeout );
|
|
978 |
note->SetTone( CAknNoteDialog::ENoTone );
|
|
979 |
note->ExecuteLD( *confMessage );
|
|
980 |
CleanupStack::PopAndDestroy( confMessage );
|
|
981 |
DoSafeExit(); // Exit after successful sending
|
|
982 |
}
|
|
983 |
else if ( error == KErrBadName )
|
|
984 |
{
|
|
985 |
// sending failed because recipient address was invalid
|
|
986 |
TFsEmailUiUtility::ShowErrorNoteL(
|
|
987 |
R_FREESTYLE_EMAIL_CONFIRM_NOTE_INVALID_EMAIL_ADDRESS,
|
|
988 |
ETrue );
|
|
989 |
}
|
|
990 |
else
|
|
991 |
{
|
|
992 |
// sending failed for some other reason
|
|
993 |
TFsEmailUiUtility::ShowErrorNoteL(
|
|
994 |
R_FREESTYLE_EMAIL_CONFIRM_NOTE_MESSAGE_NOT_SENT,
|
|
995 |
ETrue );
|
|
996 |
// Exit after sending failed for other reason for other
|
|
997 |
// reason than KErrBadName
|
|
998 |
DoSafeExit();
|
|
999 |
}
|
|
1000 |
}
|
|
1001 |
break;
|
|
1002 |
case ENcsCmdAddAttachment:
|
|
1003 |
{
|
|
1004 |
if ( AknLayoutUtils::PenEnabled() )
|
|
1005 |
{
|
|
1006 |
// show the toolbar
|
|
1007 |
UpdateToolbarL();
|
|
1008 |
CAknToolbar* toolbar = Toolbar();
|
|
1009 |
if ( toolbar )
|
|
1010 |
{
|
|
1011 |
CAknToolbarExtension* extension =
|
|
1012 |
static_cast<CAknToolbarExtension*>(
|
|
1013 |
toolbar->ControlOrNull( EFsEmailUiTbCmdExpandInsert ) );
|
|
1014 |
if ( extension )
|
|
1015 |
{
|
|
1016 |
extension->SetShown( ETrue );
|
|
1017 |
}
|
|
1018 |
}
|
|
1019 |
}
|
|
1020 |
else
|
|
1021 |
{
|
|
1022 |
iAttachmentAddType = MsgAttachmentUtils::EUnknown;
|
|
1023 |
iAsyncAttachmentAdd->Cancel();
|
|
1024 |
iAsyncAttachmentAdd->Set(
|
|
1025 |
TCallBack( AsyncAddAttachment, this ) );
|
|
1026 |
iAsyncAttachmentAdd->CallBack();
|
|
1027 |
iContainer->SetMskL();
|
|
1028 |
}
|
|
1029 |
}
|
|
1030 |
break;
|
|
1031 |
case EFsEmailUiCmdOpenAttachment:
|
|
1032 |
case EFsEmailUiCmdOpenAttachmentList:
|
|
1033 |
{
|
|
1034 |
DoOpenAttachmentListL();
|
|
1035 |
}
|
|
1036 |
break;
|
|
1037 |
case ENcsCmdRemoveAttachment:
|
|
1038 |
case EFsEmailUiCmdRemoveAttachment:
|
|
1039 |
{
|
|
1040 |
TInt index( iContainer->FocusedAttachmentLabelIndex() );
|
|
1041 |
CFreestyleEmailUiSendAttachmentsListControl* ctrl =
|
|
1042 |
AttachmentsListControl();
|
|
1043 |
if ( ctrl && KNoAttachmentLabelFocused != index )
|
|
1044 |
{
|
|
1045 |
ctrl->RemoveAttachmentFromListL( index );
|
|
1046 |
}
|
|
1047 |
SetAttachmentLabelContentL();
|
|
1048 |
}
|
|
1049 |
break;
|
|
1050 |
case ENcsCmdRemoveAllAttachments:
|
|
1051 |
{
|
|
1052 |
CFreestyleEmailUiSendAttachmentsListControl* ctrl =
|
|
1053 |
AttachmentsListControl();
|
|
1054 |
if ( ctrl )
|
|
1055 |
{
|
|
1056 |
ctrl->RemoveAllAttachmentsL();
|
|
1057 |
}
|
|
1058 |
SetAttachmentLabelContentL();
|
|
1059 |
}
|
|
1060 |
break;
|
|
1061 |
case ENcsCmdPriorityHigh:
|
|
1062 |
{
|
|
1063 |
iNewMessage->ResetFlag( EFSMsgFlag_Low );
|
|
1064 |
iNewMessage->SetFlag( EFSMsgFlag_Important );
|
|
1065 |
iNewMessage->SaveMessageL();
|
|
1066 |
iMessageModified = EFalse;
|
|
1067 |
iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityHigh );
|
|
1068 |
}
|
|
1069 |
break;
|
|
1070 |
case ENcsCmdPriorityNormal:
|
|
1071 |
{
|
|
1072 |
iNewMessage->ResetFlag( EFSMsgFlag_Low );
|
|
1073 |
iNewMessage->ResetFlag( EFSMsgFlag_Important );
|
|
1074 |
iNewMessage->SaveMessageL();
|
|
1075 |
iMessageModified = EFalse;
|
|
1076 |
iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityNormal );
|
|
1077 |
}
|
|
1078 |
break;
|
|
1079 |
case ENcsCmdPriorityLow:
|
|
1080 |
{
|
|
1081 |
iNewMessage->ResetFlag( EFSMsgFlag_Important );
|
|
1082 |
iNewMessage->SetFlag( EFSMsgFlag_Low );
|
|
1083 |
iNewMessage->SaveMessageL();
|
|
1084 |
iMessageModified = EFalse;
|
|
1085 |
iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityLow );
|
|
1086 |
}
|
|
1087 |
break;
|
|
1088 |
case ENcsCmdShowCc:
|
|
1089 |
{
|
|
1090 |
iContainer->SetCcFieldVisibleL( ETrue );
|
|
1091 |
iCrHandler->SetEditorCCVisible( 1 );
|
|
1092 |
}
|
|
1093 |
break;
|
|
1094 |
case ENcsCmdHideCc:
|
|
1095 |
{
|
|
1096 |
iContainer->SetCcFieldVisibleL( EFalse );
|
|
1097 |
iCrHandler->SetEditorCCVisible( 0 );
|
|
1098 |
}
|
|
1099 |
break;
|
|
1100 |
case ENcsCmdShowBcc:
|
|
1101 |
{
|
|
1102 |
iContainer->SetBccFieldVisibleL( ETrue );
|
|
1103 |
iCrHandler->SetEditorBCVisible( 1 );
|
|
1104 |
}
|
|
1105 |
break;
|
|
1106 |
case ENcsCmdHideBcc:
|
|
1107 |
{
|
|
1108 |
iContainer->SetBccFieldVisibleL( EFalse );
|
|
1109 |
iCrHandler->SetEditorBCVisible( 0 );
|
|
1110 |
}
|
|
1111 |
break;
|
|
1112 |
case ENcsCmdFlag:
|
|
1113 |
{
|
|
1114 |
RunFollowUpFlagDlgL();
|
|
1115 |
}
|
|
1116 |
break;
|
|
1117 |
case ENcsCmdQuickText:
|
|
1118 |
{
|
|
1119 |
DoQuickTextL();
|
|
1120 |
}
|
|
1121 |
break;
|
|
1122 |
case ENcsCmdInsertContact:
|
|
1123 |
case ENcsInsertContact:
|
|
1124 |
{
|
|
1125 |
iContainer->AppendAddressesL();
|
|
1126 |
}
|
|
1127 |
break;
|
|
1128 |
case ENcsCmdSaveDraft:
|
|
1129 |
{
|
|
1130 |
|
|
1131 |
iContainer->FixSemicolonL();
|
|
1132 |
|
|
1133 |
|
|
1134 |
TRAPD( saveDraftError, DoSaveDraftL( EFalse ) );
|
|
1135 |
if ( saveDraftError == KErrNone )
|
|
1136 |
{
|
|
1137 |
// Saving successful
|
|
1138 |
if( !iAppUi.AppUiExitOngoing() )
|
|
1139 |
TFsEmailUiUtility::ShowInfoNoteL(
|
|
1140 |
R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS,
|
|
1141 |
ETrue );
|
|
1142 |
}
|
|
1143 |
else
|
|
1144 |
{
|
|
1145 |
// error occured in saving -> show an error message
|
|
1146 |
if( !iAppUi.AppUiExitOngoing() )
|
|
1147 |
TFsEmailUiUtility::ShowErrorNoteL(
|
|
1148 |
R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE,
|
|
1149 |
ETrue );
|
|
1150 |
}
|
|
1151 |
|
|
1152 |
DoSafeExit( ENoSave );
|
|
1153 |
}
|
|
1154 |
break;
|
|
1155 |
case EAknCmdHelp:
|
|
1156 |
{
|
|
1157 |
TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
|
|
1158 |
}
|
|
1159 |
break;
|
|
1160 |
case EAknSoftkeySelect:
|
|
1161 |
{
|
|
1162 |
iContainer->DoPopupSelectL();
|
|
1163 |
}
|
|
1164 |
break;
|
|
1165 |
case EAknSoftkeyCancel:
|
|
1166 |
{
|
|
1167 |
iContainer->ClosePopupContactListL();
|
|
1168 |
}
|
|
1169 |
break;
|
|
1170 |
case EAknSoftkeyClose:
|
|
1171 |
{
|
|
1172 |
DoSafeExit();
|
|
1173 |
}
|
|
1174 |
break;
|
|
1175 |
case ENcsCmdExit:
|
|
1176 |
{
|
|
1177 |
TIMESTAMP( "Exit selected from editor" );
|
|
1178 |
iAppUi.Exit();
|
|
1179 |
}
|
|
1180 |
break;
|
|
1181 |
default:
|
|
1182 |
{
|
|
1183 |
// empty implementation
|
|
1184 |
// these commands are passed next to FEP for processing
|
|
1185 |
}
|
|
1186 |
break;
|
|
1187 |
}
|
|
1188 |
}
|
|
1189 |
|
|
1190 |
}
|
|
1191 |
|
|
1192 |
// -----------------------------------------------------------------------------
|
|
1193 |
// CNcsComposeView::DoSendL()
|
|
1194 |
// Send message
|
|
1195 |
// -----------------------------------------------------------------------------
|
|
1196 |
//
|
|
1197 |
void CNcsComposeView::DoSendL()
|
|
1198 |
{
|
|
1199 |
FUNC_LOG;
|
|
1200 |
|
|
1201 |
// check that addresses exist
|
|
1202 |
if ( iContainer->AreAddressFieldsEmpty() )
|
|
1203 |
{
|
|
1204 |
User::Leave( KErrNotFound );
|
|
1205 |
}
|
|
1206 |
|
|
1207 |
CommitL( ETrue, EAllFields, ETrue );
|
|
1208 |
|
|
1209 |
TRAPD(r, iMailBox->SendMessageL( *iNewMessage ) );
|
|
1210 |
if ( KErrNone != r )
|
|
1211 |
{
|
|
1212 |
iMailSendFailed = ETrue;
|
|
1213 |
User::Leave( r );
|
|
1214 |
}
|
|
1215 |
|
|
1216 |
// prevent sending failure if original message is
|
|
1217 |
// removed from server while replying/forwarding
|
|
1218 |
TRAPD( flagError, SetReplyForwardFlagL() );
|
|
1219 |
|
|
1220 |
if ( KErrNone != flagError && KErrNotFound != flagError )
|
|
1221 |
{
|
|
1222 |
iMailSendFailed = ETrue;
|
|
1223 |
User::Leave( flagError );
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
iMailSent = ETrue;
|
|
1227 |
|
|
1228 |
}
|
|
1229 |
|
|
1230 |
|
|
1231 |
// -----------------------------------------------------------------------------
|
|
1232 |
// CNcsComposeView::DoSaveDraftL()
|
|
1233 |
// Saves message to Drafts
|
|
1234 |
// Displays dialog asking user choice if preferred
|
|
1235 |
// Pressing cancel in the query dialog causes Leave with code KErrCancel
|
|
1236 |
// -----------------------------------------------------------------------------
|
|
1237 |
//
|
|
1238 |
TBool CNcsComposeView::DoSaveDraftL( TBool aAskUser )
|
|
1239 |
{
|
|
1240 |
FUNC_LOG;
|
|
1241 |
|
|
1242 |
__ASSERT_DEBUG( iNewMessage, Panic( ENcsBasicUi ) );
|
|
1243 |
|
|
1244 |
TBool result( ETrue );
|
|
1245 |
|
|
1246 |
if ( aAskUser )
|
|
1247 |
{
|
|
1248 |
TInt selectedOption( -1 );
|
|
1249 |
CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat( 2 );
|
|
1250 |
CleanupStack::PushL( array );
|
|
1251 |
|
|
1252 |
HBufC* saveItem = StringLoader::LoadLC( R_NCS_DRAFT_SAVE );
|
|
1253 |
array->AppendL( *saveItem );
|
|
1254 |
CleanupStack::PopAndDestroy( saveItem );
|
|
1255 |
|
|
1256 |
HBufC* deleteItem = StringLoader::LoadLC( R_NCS_DRAFT_DISCARD );
|
|
1257 |
array->AppendL( *deleteItem );
|
|
1258 |
CleanupStack::PopAndDestroy( deleteItem );
|
|
1259 |
|
|
1260 |
iDlg = new (ELeave) CAknListQueryDialog( &selectedOption );
|
|
1261 |
iDlg->PrepareLC( R_DRAFT_QUERY_DIALOG );
|
|
1262 |
iDlg->SetItemTextArray( array );
|
|
1263 |
iDlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
1264 |
|
|
1265 |
iCheckQuery = ETrue;
|
|
1266 |
//we are forbiding to change MSK label, cause popup will be opend
|
|
1267 |
iContainer->SwitchChangeMskOff( ETrue );
|
|
1268 |
TInt ret = iDlg->RunLD();
|
|
1269 |
iDlg = NULL;
|
|
1270 |
|
|
1271 |
iCheckQuery = EFalse;
|
|
1272 |
iContainer->SwitchChangeMskOff( EFalse );
|
|
1273 |
|
|
1274 |
if ( !ret )
|
|
1275 |
{
|
|
1276 |
selectedOption = KErrCancel;
|
|
1277 |
}
|
|
1278 |
|
|
1279 |
switch ( selectedOption )
|
|
1280 |
{
|
|
1281 |
case 0:
|
|
1282 |
{
|
|
1283 |
TRAPD( saveError, SaveToDraftsL( ETrue ) );
|
|
1284 |
|
|
1285 |
if ( saveError == KErrNone )
|
|
1286 |
{
|
|
1287 |
// User wanted to save to Drafts and saving was successful
|
|
1288 |
if( !iAppUi.AppUiExitOngoing() )
|
|
1289 |
TFsEmailUiUtility::ShowInfoNoteL(
|
|
1290 |
R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS,
|
|
1291 |
ETrue );
|
|
1292 |
}
|
|
1293 |
else
|
|
1294 |
{
|
|
1295 |
|
|
1296 |
// error occured in saving -> show an error message
|
|
1297 |
if( !iAppUi.AppUiExitOngoing() )
|
|
1298 |
TFsEmailUiUtility::ShowErrorNoteL(
|
|
1299 |
R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE,
|
|
1300 |
ETrue );
|
|
1301 |
|
|
1302 |
// let's return EFalse so after completing this query
|
|
1303 |
// so the focus would stay in compose view (same behaviour
|
|
1304 |
// as if Cancel was pressed )
|
|
1305 |
result = EFalse;
|
|
1306 |
}
|
|
1307 |
}
|
|
1308 |
break;
|
|
1309 |
case 1:
|
|
1310 |
{
|
|
1311 |
TIMESTAMP( "Delete draft message selected in editor" );
|
|
1312 |
TRAPD( error, SaveToDraftsL( ETrue ) );
|
|
1313 |
if ( KErrNone != error )
|
|
1314 |
{
|
|
1315 |
}
|
|
1316 |
// for delete messages fake sync calls
|
|
1317 |
iFakeSyncGoingOn = ETrue;
|
|
1318 |
error = NcsUtility::DeleteMessage( iMailClient,
|
|
1319 |
iMailBox->GetId(),
|
|
1320 |
iNewMessage->GetFolderId(),
|
|
1321 |
iNewMessage->GetMessageId() );
|
|
1322 |
|
|
1323 |
if ( KErrNone == error &&
|
|
1324 |
iMailBox->HasCapability(
|
|
1325 |
EFSMBoxCapaSupportsDeletedItemsFolder ) )
|
|
1326 |
{
|
|
1327 |
error = NcsUtility::DeleteMessage( iMailClient,
|
|
1328 |
iMailBox->GetId(),
|
|
1329 |
iMailBox->GetStandardFolderId( EFSDeleted ),
|
|
1330 |
iNewMessage->GetMessageId() );
|
|
1331 |
}
|
|
1332 |
iFakeSyncGoingOn = EFalse;
|
|
1333 |
|
|
1334 |
if( !iAppUi.AppUiExitOngoing() )
|
|
1335 |
{
|
|
1336 |
if ( KErrNone != error )
|
|
1337 |
{
|
|
1338 |
// error occured in saving -> show an error message
|
|
1339 |
TFsEmailUiUtility::ShowErrorNoteL(
|
|
1340 |
R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE,
|
|
1341 |
ETrue );
|
|
1342 |
}
|
|
1343 |
else
|
|
1344 |
{
|
|
1345 |
// Simulate delete event so that drafts folder is
|
|
1346 |
// updated correctly.
|
|
1347 |
RArray<TFSMailMsgId> messageIds;
|
|
1348 |
CleanupClosePushL( messageIds );
|
|
1349 |
messageIds.AppendL( iNewMessage->GetMessageId() );
|
|
1350 |
TFSMailMsgId folderId = iNewMessage->GetFolderId();
|
|
1351 |
TFSMailMsgId mailboxId = iNewMessage->GetMailBoxId();
|
|
1352 |
iAppUi.EventL( TFSEventMailDeleted,
|
|
1353 |
mailboxId, &messageIds, &folderId, NULL );
|
|
1354 |
CleanupStack::PopAndDestroy( &messageIds );
|
|
1355 |
}
|
|
1356 |
}
|
|
1357 |
}
|
|
1358 |
break;
|
|
1359 |
default:
|
|
1360 |
{
|
|
1361 |
result = EFalse;
|
|
1362 |
}
|
|
1363 |
break;
|
|
1364 |
}
|
|
1365 |
CleanupStack::PopAndDestroy( array );
|
|
1366 |
}
|
|
1367 |
else // no question from user
|
|
1368 |
{
|
|
1369 |
SaveToDraftsL( ETrue );
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
return result;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
// -----------------------------------------------------------------------------
|
|
1376 |
// CNcsComposeView::NewMessage()
|
|
1377 |
// Returns pointer to currently composed mail message
|
|
1378 |
// -----------------------------------------------------------------------------
|
|
1379 |
//
|
|
1380 |
CFSMailMessage* CNcsComposeView::NewMessage()
|
|
1381 |
{
|
|
1382 |
FUNC_LOG;
|
|
1383 |
return iNewMessage;
|
|
1384 |
}
|
|
1385 |
|
|
1386 |
// -----------------------------------------------------------------------------
|
|
1387 |
// CNcsComposeView::AsyncAddAttachmentL()
|
|
1388 |
// Open file dialog and add selected file as an attachment
|
|
1389 |
// -----------------------------------------------------------------------------
|
|
1390 |
//
|
|
1391 |
TInt CNcsComposeView::AsyncAddAttachment( TAny* aSelfPtr )
|
|
1392 |
{
|
|
1393 |
FUNC_LOG;
|
|
1394 |
|
|
1395 |
CNcsComposeView* self = static_cast<CNcsComposeView*>( aSelfPtr );
|
|
1396 |
|
|
1397 |
// get pointer to attachment list view
|
|
1398 |
CFreestyleEmailUiSendAttachmentsListControl* attachmentControl;
|
|
1399 |
attachmentControl = self->AttachmentsListControl();
|
|
1400 |
|
|
1401 |
// show file dialog and get file name
|
|
1402 |
TBool ok = EFalse;
|
|
1403 |
TInt error = KErrNone;
|
|
1404 |
CAknToolbar* toolbar = self->Toolbar();
|
|
1405 |
if ( !toolbar->IsDimmed() )
|
|
1406 |
{
|
|
1407 |
toolbar->SetDimmed(ETrue);
|
|
1408 |
}
|
|
1409 |
|
|
1410 |
self->iAddingAttachmentDialogOpened = ETrue;
|
|
1411 |
self->iContainer->SwitchChangeMskOff( ETrue );
|
|
1412 |
TRAP( error, ok = attachmentControl->AppendAttachmentToListL(
|
|
1413 |
self->iAttachmentAddType) );
|
|
1414 |
|
|
1415 |
if( error == KErrNoMemory )
|
|
1416 |
{
|
|
1417 |
TRAP_IGNORE( TFsEmailUiUtility::ShowErrorNoteL(
|
|
1418 |
R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE,
|
|
1419 |
ETrue ) );
|
|
1420 |
}
|
|
1421 |
self->iContainer->SwitchChangeMskOff( EFalse );
|
|
1422 |
self->iAddingAttachmentDialogOpened = EFalse;
|
|
1423 |
|
|
1424 |
if ( ok && error == KErrNone )
|
|
1425 |
{
|
|
1426 |
TRAP( error, self->SetAttachmentLabelContentL() );
|
|
1427 |
}
|
|
1428 |
|
|
1429 |
if ( !attachmentControl->IsAttachmentAddingLocked() )
|
|
1430 |
{
|
|
1431 |
toolbar->SetDimmed(EFalse);
|
|
1432 |
self->RefreshToolbar();
|
|
1433 |
toolbar->DrawDeferred();
|
|
1434 |
}
|
|
1435 |
return error;
|
|
1436 |
}
|
|
1437 |
|
|
1438 |
// -----------------------------------------------------------------------------
|
|
1439 |
// RunFollowUpFlagDlgL()
|
|
1440 |
// Query user for followup flag
|
|
1441 |
// -----------------------------------------------------------------------------
|
|
1442 |
//
|
|
1443 |
void CNcsComposeView::RunFollowUpFlagDlgL()
|
|
1444 |
{
|
|
1445 |
FUNC_LOG;
|
|
1446 |
if ( iNewMessage && TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) )
|
|
1447 |
{
|
|
1448 |
TFollowUpNewState newState =
|
|
1449 |
TFsEmailUiUtility::SetMessageFollowupFlagL(
|
|
1450 |
*iNewMessage, EFalse );
|
|
1451 |
|
|
1452 |
switch ( newState )
|
|
1453 |
{
|
|
1454 |
case EFollowUp:
|
|
1455 |
{
|
|
1456 |
iStatusPaneIndicators->SetFollowUpFlag(
|
|
1457 |
CCustomStatuspaneIndicators::EFollowUp );
|
|
1458 |
}
|
|
1459 |
break;
|
|
1460 |
case EFollowUpComplete:
|
|
1461 |
{
|
|
1462 |
iStatusPaneIndicators->SetFollowUpFlag(
|
|
1463 |
CCustomStatuspaneIndicators::EFollowUpComplete );
|
|
1464 |
}
|
|
1465 |
break;
|
|
1466 |
case EFollowUpClear:
|
|
1467 |
{
|
|
1468 |
iStatusPaneIndicators->SetFollowUpFlag(
|
|
1469 |
CCustomStatuspaneIndicators::EFollowUpNone );
|
|
1470 |
}
|
|
1471 |
break;
|
|
1472 |
default:
|
|
1473 |
{
|
|
1474 |
// do nothing.
|
|
1475 |
}
|
|
1476 |
break;
|
|
1477 |
}
|
|
1478 |
}
|
|
1479 |
}
|
|
1480 |
|
|
1481 |
// -----------------------------------------------------------------------------
|
|
1482 |
// CNcsComposeView::SetAttachmentLabelContentL()
|
|
1483 |
// Open file dialog and add selected file as an attachment
|
|
1484 |
// -----------------------------------------------------------------------------
|
|
1485 |
//
|
|
1486 |
void CNcsComposeView::SetAttachmentLabelContentL()
|
|
1487 |
{
|
|
1488 |
FUNC_LOG;
|
|
1489 |
if ( iFirstStartCompleted && iContainer )
|
|
1490 |
{
|
|
1491 |
CFreestyleEmailUiSendAttachmentsListControl*
|
|
1492 |
attachmentControl = AttachmentsListControl();
|
|
1493 |
if ( !( attachmentControl && attachmentControl->Model() ) )
|
|
1494 |
{
|
|
1495 |
return;
|
|
1496 |
}
|
|
1497 |
|
|
1498 |
// read number of attachments
|
|
1499 |
TInt count = attachmentControl->Model()->Count();
|
|
1500 |
if ( count > 0 )
|
|
1501 |
{
|
|
1502 |
// Fill in the name and size descriptor arrays
|
|
1503 |
CDesCArrayFlat* nameArray = new (ELeave) CDesCArrayFlat( count );
|
|
1504 |
CleanupStack::PushL( nameArray );
|
|
1505 |
CDesCArrayFlat* sizeArray = new (ELeave) CDesCArrayFlat( count );
|
|
1506 |
CleanupStack::PushL( sizeArray );
|
|
1507 |
|
|
1508 |
for ( TInt i(0); i<count; ++i )
|
|
1509 |
{
|
|
1510 |
CFSEmailUiSendAttachmentsListModelItem* item =
|
|
1511 |
static_cast<CFSEmailUiSendAttachmentsListModelItem*>
|
|
1512 |
( attachmentControl->Model()->Item( i ) );
|
|
1513 |
if ( item )
|
|
1514 |
{
|
|
1515 |
nameArray->AppendL( item->FileName() );
|
|
1516 |
HBufC* sizeDesc =
|
|
1517 |
TFsEmailUiUtility::CreateSizeDescLC(
|
|
1518 |
item->FileSize() );
|
|
1519 |
sizeArray->AppendL( *sizeDesc );
|
|
1520 |
CleanupStack::PopAndDestroy( sizeDesc );
|
|
1521 |
}
|
|
1522 |
}
|
|
1523 |
iContainer->SetAttachmentLabelTextsLD( nameArray, sizeArray );
|
|
1524 |
iContainer->SetFocusToAttachmentField();
|
|
1525 |
|
|
1526 |
CleanupStack::Pop( sizeArray );
|
|
1527 |
CleanupStack::Pop( nameArray );
|
|
1528 |
}
|
|
1529 |
else
|
|
1530 |
{
|
|
1531 |
iContainer->SetAttachmentLabelTextsLD( NULL, NULL );
|
|
1532 |
iContainer->HideAttachmentLabel();
|
|
1533 |
}
|
|
1534 |
}
|
|
1535 |
}
|
|
1536 |
|
|
1537 |
|
|
1538 |
// -----------------------------------------------------------------------------
|
|
1539 |
// CNcsComposeView::AttachmentsListControl()
|
|
1540 |
//
|
|
1541 |
// -----------------------------------------------------------------------------
|
|
1542 |
//
|
|
1543 |
CFreestyleEmailUiSendAttachmentsListControl*
|
|
1544 |
CNcsComposeView::AttachmentsListControl()
|
|
1545 |
{
|
|
1546 |
FUNC_LOG;
|
|
1547 |
CFreestyleEmailUiSendAttachmentsListControl* attachmentControl( NULL );
|
|
1548 |
if ( iFirstStartCompleted ) // Safety
|
|
1549 |
{
|
|
1550 |
CFSEmailUiSendAttachmentsListVisualiser* attachmentView =
|
|
1551 |
static_cast<CFSEmailUiSendAttachmentsListVisualiser*>(
|
|
1552 |
iAvkonViewAppUi->View( SendAttachmentMngrViewId ) );
|
|
1553 |
if ( attachmentView )
|
|
1554 |
{
|
|
1555 |
attachmentControl =
|
|
1556 |
static_cast<CFreestyleEmailUiSendAttachmentsListControl*>(
|
|
1557 |
attachmentView->ViewerControl() );
|
|
1558 |
}
|
|
1559 |
}
|
|
1560 |
return attachmentControl;
|
|
1561 |
}
|
|
1562 |
|
|
1563 |
// -----------------------------------------------------------------------------
|
|
1564 |
// CNcsComposeView::ProcessCommandL()
|
|
1565 |
// -----------------------------------------------------------------------------
|
|
1566 |
//
|
|
1567 |
void CNcsComposeView::ProcessCommandL( TInt aCommand )
|
|
1568 |
{
|
|
1569 |
FUNC_LOG;
|
|
1570 |
|
|
1571 |
// Block all the commands while we are exiting
|
|
1572 |
if ( !iExecutingDoExitL )
|
|
1573 |
{
|
|
1574 |
CFsEmailUiViewBase::ProcessCommandL( aCommand );
|
|
1575 |
}
|
|
1576 |
}
|
|
1577 |
|
|
1578 |
// -----------------------------------------------------------------------------
|
|
1579 |
// CNcsComposeView::HandleActivationCommandL()
|
|
1580 |
//
|
|
1581 |
// -----------------------------------------------------------------------------
|
|
1582 |
//
|
|
1583 |
void CNcsComposeView::HandleActivationCommandL( TUid aCustomMessageId )
|
|
1584 |
{
|
|
1585 |
FUNC_LOG;
|
|
1586 |
// Called from doactivate in which case first start is completed
|
|
1587 |
iMailFetchingErrCode = KErrNone;
|
|
1588 |
|
|
1589 |
if ( aCustomMessageId == TUid::Uid( KEditorCmdCreateNew ) )
|
|
1590 |
{
|
|
1591 |
iOrigMessage = NULL;
|
|
1592 |
iFakeSyncGoingOn = ETrue;
|
|
1593 |
iNewMessage = iMailBox->CreateMessageToSend();
|
|
1594 |
iFakeSyncGoingOn = EFalse;
|
|
1595 |
if ( !iNewMessage )
|
|
1596 |
{
|
|
1597 |
User::Leave( KErrGeneral );
|
|
1598 |
}
|
|
1599 |
iFakeSyncGoingOn = ETrue;
|
|
1600 |
TFsEmailUiUtility::MoveMessageToDraftsL( *iMailBox, *iNewMessage );
|
|
1601 |
iFakeSyncGoingOn = EFalse;
|
|
1602 |
|
|
1603 |
if ( iNewMessage->GetContentType() !=
|
|
1604 |
KFSMailContentTypeMultipartMixed )
|
|
1605 |
{
|
|
1606 |
iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
|
|
1607 |
iNewMessage->SaveMessageL();
|
|
1608 |
iMessageModified = EFalse;
|
|
1609 |
}
|
|
1610 |
|
|
1611 |
TFsEmailUiUtility::CreatePlainTextPartL(
|
|
1612 |
*iNewMessage, iNewMessageTextPart );
|
|
1613 |
IncludeMessageTextL( ETrue );
|
|
1614 |
AttachmentsListControl()->Model()->Clear();
|
|
1615 |
iContainer->SelectAllToFieldTextL();
|
|
1616 |
}
|
|
1617 |
else if ( aCustomMessageId == TUid::Uid( KEditorCmdReply ) ||
|
|
1618 |
aCustomMessageId == TUid::Uid( KEditorCmdReplyAll ) )
|
|
1619 |
{
|
|
1620 |
|
|
1621 |
iOrigMessage = iMailClient.GetMessageByUidL(
|
|
1622 |
iLaunchParams.iMailboxId, iLaunchParams.iFolderId,
|
|
1623 |
iLaunchParams.iMsgId, EFSMsgDataStructure );
|
|
1624 |
if ( !iOrigMessage )
|
|
1625 |
{
|
|
1626 |
User::Leave( KErrNotFound );
|
|
1627 |
}
|
|
1628 |
|
|
1629 |
SafeDelete( iFetchLogic );
|
|
1630 |
iFetchLogic = CFsComposerFetchLogic::NewL(
|
|
1631 |
iMailClient, iLaunchParams.iMailboxId,
|
|
1632 |
iOrigMessage->GetFolderId(), iLaunchParams.iMsgId,
|
|
1633 |
*this, iAppUi );
|
|
1634 |
ShowFetchingWaitNoteL();
|
|
1635 |
iFetchLogic->RunReplyLogicL();
|
|
1636 |
|
|
1637 |
// now fetch logic object runs its tasks and gives callback
|
|
1638 |
// to CNcsComposeView::FetchLogicComplete when it is finished
|
|
1639 |
}
|
|
1640 |
else if ( aCustomMessageId == TUid::Uid( KEditorCmdForward ) )
|
|
1641 |
{
|
|
1642 |
|
|
1643 |
iOrigMessage = iMailClient.GetMessageByUidL(
|
|
1644 |
iLaunchParams.iMailboxId, iLaunchParams.iFolderId,
|
|
1645 |
iLaunchParams.iMsgId, EFSMsgDataStructure );
|
|
1646 |
if ( !iOrigMessage )
|
|
1647 |
{
|
|
1648 |
User::Leave( KErrNotFound );
|
|
1649 |
}
|
|
1650 |
|
|
1651 |
SafeDelete( iFetchLogic );
|
|
1652 |
iFetchLogic = CFsComposerFetchLogic::NewL(
|
|
1653 |
iMailClient, iLaunchParams.iMailboxId,
|
|
1654 |
iOrigMessage->GetFolderId(), iLaunchParams.iMsgId,
|
|
1655 |
*this, iAppUi );
|
|
1656 |
ShowFetchingWaitNoteL();
|
|
1657 |
iFetchLogic->RunForwardLogicL();
|
|
1658 |
|
|
1659 |
// now fetch logic object runs its tasks and gives callback
|
|
1660 |
// to CNcsComposeView::FetchLogicComplete when it is finished
|
|
1661 |
}
|
|
1662 |
else if ( aCustomMessageId == TUid::Uid( KEditorCmdOpen ) ||
|
|
1663 |
aCustomMessageId == TUid::Uid( KEditorCmdReturnToPrevious ) )
|
|
1664 |
{
|
|
1665 |
// for now, we handle returning from attachments list just like
|
|
1666 |
// any message opening
|
|
1667 |
iNewMessage = iMailClient.GetMessageByUidL(
|
|
1668 |
iLaunchParams.iMailboxId, iLaunchParams.iFolderId,
|
|
1669 |
iLaunchParams.iMsgId, EFSMsgDataStructure );
|
|
1670 |
if ( !iNewMessage )
|
|
1671 |
{
|
|
1672 |
User::Leave( KErrNotFound );
|
|
1673 |
}
|
|
1674 |
|
|
1675 |
// Show "Opening" wait note if the message body is large
|
|
1676 |
TInt waitNoteId = KErrNotFound;
|
|
1677 |
if ( TFsEmailUiUtility::IsMessageBodyLargeL(iNewMessage) )
|
|
1678 |
{
|
|
1679 |
waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC(
|
|
1680 |
R_FSE_WAIT_OPENING_TEXT );
|
|
1681 |
}
|
|
1682 |
|
|
1683 |
iOrigMessage = NULL;
|
|
1684 |
iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
|
|
1685 |
iNewMessage->SaveMessageL();
|
|
1686 |
iMessageModified = EFalse;
|
|
1687 |
TFsEmailUiUtility::CreatePlainTextPartL(
|
|
1688 |
*iNewMessage, iNewMessageTextPart );
|
|
1689 |
InitFieldsL();
|
|
1690 |
TBool spaceInBegin = ETrue;
|
|
1691 |
IncludeMessageTextL(spaceInBegin);
|
|
1692 |
AttachmentsListControl()->Model()->Clear();
|
|
1693 |
GetAttachmentsFromMailL();
|
|
1694 |
SetAttachmentLabelContentL();
|
|
1695 |
iAttachmentListSaveDraft = ETrue;
|
|
1696 |
|
|
1697 |
// Close the "Opening" wait note if it was shown
|
|
1698 |
if ( waitNoteId != KErrNotFound )
|
|
1699 |
{
|
|
1700 |
CleanupStack::PopAndDestroy( (TAny*)waitNoteId );
|
|
1701 |
}
|
|
1702 |
}
|
|
1703 |
else if ( aCustomMessageId == TUid::Uid( KEditorCmdInternalMailto ) )
|
|
1704 |
{
|
|
1705 |
FUNC_LOG;
|
|
1706 |
|
|
1707 |
iOrigMessage = NULL;
|
|
1708 |
iFakeSyncGoingOn = ETrue;
|
|
1709 |
iNewMessage = iMailBox->CreateMessageToSend();
|
|
1710 |
iFakeSyncGoingOn = EFalse;
|
|
1711 |
if ( !iNewMessage )
|
|
1712 |
{
|
|
1713 |
User::Leave( KErrGeneral );
|
|
1714 |
}
|
|
1715 |
iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
|
|
1716 |
iNewMessage->SaveMessageL();
|
|
1717 |
iMessageModified = EFalse;
|
|
1718 |
|
|
1719 |
TFsEmailUiUtility::CreatePlainTextPartL(
|
|
1720 |
*iNewMessage, iNewMessageTextPart );
|
|
1721 |
|
|
1722 |
IncludeMessageTextL( ETrue );
|
|
1723 |
|
|
1724 |
CFSMailAddress* toAddress =
|
|
1725 |
static_cast<CFSMailAddress*>( iLaunchParams.iExtra ); // not owned
|
|
1726 |
RPointerArray<CNcsEmailAddressObject> toRecipients;
|
|
1727 |
CleanupResetAndDestroyClosePushL( toRecipients );
|
|
1728 |
CNcsEmailAddressObject* ncsToAddress =
|
|
1729 |
NcsUtility::CreateNcsAddressL( *toAddress );
|
|
1730 |
CleanupStack::PushL( ncsToAddress );
|
|
1731 |
toRecipients.AppendL( ncsToAddress );
|
|
1732 |
CleanupStack::Pop( ncsToAddress ); // owned by toRecipients now
|
|
1733 |
iContainer->SetToFieldAddressesL( toRecipients );
|
|
1734 |
CleanupStack::PopAndDestroy( &toRecipients );
|
|
1735 |
|
|
1736 |
iContainer->SetFocusToMessageFieldL();
|
|
1737 |
}
|
|
1738 |
}
|
|
1739 |
|
|
1740 |
// -----------------------------------------------------------------------------
|
|
1741 |
// CNcsComposeView::DoQuickTextL()
|
|
1742 |
//
|
|
1743 |
// -----------------------------------------------------------------------------
|
|
1744 |
//
|
|
1745 |
void CNcsComposeView::DoQuickTextL()
|
|
1746 |
{
|
|
1747 |
FUNC_LOG;
|
|
1748 |
|
|
1749 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
1750 |
|
|
1751 |
HBufC* title =
|
|
1752 |
iEikonEnv->AllocReadResourceLC( R_NCS_QUICK_TEXT_TITLE_TEXT );
|
|
1753 |
HBufC* buf( 0 );
|
|
1754 |
TRAPD( err, buf = CNotepadApi::FetchTemplateL( title ) );
|
|
1755 |
if ( err == KLeaveExit )
|
|
1756 |
{
|
|
1757 |
// If end key was pressed the dialog leaves with the above error code.
|
|
1758 |
// In that case we must leave as well or the application will become
|
|
1759 |
// stuck as the exit will be incomplete.
|
|
1760 |
User::Leave( err );
|
|
1761 |
}
|
|
1762 |
|
|
1763 |
if ( buf && err == KErrNone ) // Safety check, 0 if user cancel
|
|
1764 |
{
|
|
1765 |
CleanupStack::PushL( buf );
|
|
1766 |
iContainer->AddQuickTextL( *buf );
|
|
1767 |
CleanupStack::PopAndDestroy( buf );
|
|
1768 |
}
|
|
1769 |
CleanupStack::PopAndDestroy( title );
|
|
1770 |
|
|
1771 |
}
|
|
1772 |
|
|
1773 |
// -----------------------------------------------------------------------------
|
|
1774 |
// CNcsComposeView::HandleDynamicVariantSwitchL()
|
|
1775 |
//
|
|
1776 |
// -----------------------------------------------------------------------------
|
|
1777 |
//
|
|
1778 |
void CNcsComposeView::HandleDynamicVariantSwitchL(
|
|
1779 |
CFsEmailUiViewBase::TDynamicSwitchType aType )
|
|
1780 |
{
|
|
1781 |
FUNC_LOG;
|
|
1782 |
|
|
1783 |
if ( iFirstStartCompleted && iContainer )
|
|
1784 |
{
|
|
1785 |
if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged )
|
|
1786 |
{
|
|
1787 |
iContainer->HandleLayoutChangeL();
|
|
1788 |
}
|
|
1789 |
else if ( aType == CFsEmailUiViewBase::ESkinChanged )
|
|
1790 |
{
|
|
1791 |
iContainer->HandleSkinChangeL();
|
|
1792 |
}
|
|
1793 |
else
|
|
1794 |
{
|
|
1795 |
}
|
|
1796 |
}
|
|
1797 |
|
|
1798 |
}
|
|
1799 |
|
|
1800 |
// ---------------------------------------------------------------------------
|
|
1801 |
// CNcsComposeView::FadeOut()
|
|
1802 |
// enables hiding toolbar on different view -> DoActivate()
|
|
1803 |
// which is earlier than -> CFsEmailUiViewBase::DoDeactivate()
|
|
1804 |
// -----------------------------------------------------------------------------
|
|
1805 |
//
|
|
1806 |
void CNcsComposeView::FadeOut( TBool aDirectionOut )
|
|
1807 |
{
|
|
1808 |
if ( aDirectionOut && Toolbar()->IsShown() )
|
|
1809 |
{
|
|
1810 |
HideToolbar();
|
|
1811 |
}
|
|
1812 |
else if ( ! ( aDirectionOut || Toolbar()->IsShown() ) )
|
|
1813 |
{
|
|
1814 |
ShowToolbar();
|
|
1815 |
}
|
|
1816 |
}
|
|
1817 |
// -----------------------------------------------------------------------------
|
|
1818 |
// CNcsComposeView::InitReplyFieldsL()
|
|
1819 |
// Initialises the reply fields from the reply message created by the plug-in.
|
|
1820 |
// -----------------------------------------------------------------------------
|
|
1821 |
//
|
|
1822 |
void CNcsComposeView::InitReplyFieldsL( TBool /*aReplyAll*/ )
|
|
1823 |
{
|
|
1824 |
FUNC_LOG;
|
|
1825 |
|
|
1826 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
1827 |
|
|
1828 |
// Get TO recipients
|
|
1829 |
RPointerArray<CFSMailAddress>& toRecipients =
|
|
1830 |
iNewMessage->GetToRecipients();
|
|
1831 |
RPointerArray<CNcsEmailAddressObject> recipients;
|
|
1832 |
CleanupResetAndDestroyClosePushL( recipients );
|
|
1833 |
NcsUtility::ConvertAddressArrayL( toRecipients, recipients );
|
|
1834 |
iContainer->SetToFieldAddressesL( recipients );
|
|
1835 |
CleanupStack::PopAndDestroy( &recipients );
|
|
1836 |
|
|
1837 |
// Get CC recipients
|
|
1838 |
RPointerArray<CFSMailAddress>& ccRecipients =
|
|
1839 |
iNewMessage->GetCCRecipients();
|
|
1840 |
NcsUtility::ConvertAddressArrayL( ccRecipients, recipients );
|
|
1841 |
iContainer->SetCcFieldAddressesL( recipients );
|
|
1842 |
recipients.ResetAndDestroy();
|
|
1843 |
|
|
1844 |
// Get BCC recipients
|
|
1845 |
RPointerArray<CFSMailAddress>& bccRecipients =
|
|
1846 |
iNewMessage->GetBCCRecipients();
|
|
1847 |
NcsUtility::ConvertAddressArrayL( bccRecipients, recipients );
|
|
1848 |
iContainer->SetBccFieldAddressesL( recipients );
|
|
1849 |
recipients.ResetAndDestroy();
|
|
1850 |
|
|
1851 |
// Get subject line from original message
|
|
1852 |
HBufC* prefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_REPLY_PREFIX );
|
|
1853 |
HBufC* formattedSubject = NcsUtility::FormatSubjectLineL(
|
|
1854 |
iOrigMessage->GetSubject(), *prefix );
|
|
1855 |
CleanupStack::PushL( formattedSubject );
|
|
1856 |
iContainer->SetSubjectL( *formattedSubject );
|
|
1857 |
CleanupStack::PopAndDestroy( formattedSubject );
|
|
1858 |
CleanupStack::PopAndDestroy( prefix );
|
|
1859 |
|
|
1860 |
// clear attachments
|
|
1861 |
AttachmentsListControl()->Model()->Clear();
|
|
1862 |
|
|
1863 |
}
|
|
1864 |
|
|
1865 |
// -----------------------------------------------------------------------------
|
|
1866 |
// CNcsComposeView::RemoveOwnAddress()
|
|
1867 |
//
|
|
1868 |
// -----------------------------------------------------------------------------
|
|
1869 |
//
|
|
1870 |
void CNcsComposeView::RemoveOwnAddress(
|
|
1871 |
RPointerArray<CNcsEmailAddressObject>& aAddressList )
|
|
1872 |
{
|
|
1873 |
FUNC_LOG;
|
|
1874 |
TInt index = 0;
|
|
1875 |
TDesC& ownAddress( iMailBox->OwnMailAddress().GetEmailAddress() );
|
|
1876 |
while ( index < aAddressList.Count() )
|
|
1877 |
{
|
|
1878 |
if ( !aAddressList[index]->EmailAddress().CompareC(ownAddress) )
|
|
1879 |
{
|
|
1880 |
// The entry will be removed from the arry.
|
|
1881 |
aAddressList.Remove(index);
|
|
1882 |
break;
|
|
1883 |
}
|
|
1884 |
index++;
|
|
1885 |
}
|
|
1886 |
}
|
|
1887 |
|
|
1888 |
// -----------------------------------------------------------------------------
|
|
1889 |
// CNcsComposeView::IncludeMessageTextL()
|
|
1890 |
//
|
|
1891 |
// -----------------------------------------------------------------------------
|
|
1892 |
//
|
|
1893 |
void CNcsComposeView::IncludeMessageTextL(
|
|
1894 |
TBool aEnsureSpaceInBegin /*= EFalse*/ )
|
|
1895 |
{
|
|
1896 |
FUNC_LOG;
|
|
1897 |
|
|
1898 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
1899 |
|
|
1900 |
HBufC* body = NULL;
|
|
1901 |
HBufC* rawBody = GetMessageBodyL();
|
|
1902 |
CleanupStack::PushL( rawBody );
|
|
1903 |
|
|
1904 |
// Ensure there's free space in the beginning of the message if required
|
|
1905 |
if ( aEnsureSpaceInBegin && rawBody->Length() )
|
|
1906 |
{
|
|
1907 |
TText firstChar = (*rawBody)[0];
|
|
1908 |
_LIT( KNewLines, "\r\n\x2028\x2029" );
|
|
1909 |
if ( KNewLines().Locate( firstChar ) == KErrNotFound )
|
|
1910 |
{
|
|
1911 |
// First character is not a new line character. Insert one.
|
|
1912 |
body = HBufC::NewL( rawBody->Length() + KIMSLineFeed().Length() );
|
|
1913 |
TPtr ptr = body->Des();
|
|
1914 |
ptr.Append( KIMSLineFeed );
|
|
1915 |
ptr.Append( *rawBody );
|
|
1916 |
CleanupStack::PopAndDestroy( rawBody );
|
|
1917 |
rawBody = NULL;
|
|
1918 |
CleanupStack::PushL( body );
|
|
1919 |
}
|
|
1920 |
}
|
|
1921 |
// If no modifications were needed, then just set body pointer to point
|
|
1922 |
// the rawBody
|
|
1923 |
if ( !body )
|
|
1924 |
{
|
|
1925 |
body = rawBody;
|
|
1926 |
rawBody = NULL;
|
|
1927 |
}
|
|
1928 |
// Now we have possibly decorated message text in body pointer and
|
|
1929 |
// in cleanup stack
|
|
1930 |
|
|
1931 |
// Divide the contents into normal body and the read-only quote fields
|
|
1932 |
// Convert bytes length to words length
|
|
1933 |
TInt readOnlyLength = iNewMessageTextPart->ReadOnlyPartSize() / 2;
|
|
1934 |
if ( body )
|
|
1935 |
{
|
|
1936 |
TInt modifiableLength = body->Length() - readOnlyLength;
|
|
1937 |
|
|
1938 |
// Remove one newline from the end of the modifiable body if there's
|
|
1939 |
// read-only quote present. This is because the field boundary appears
|
|
1940 |
// as newline on the screen. This newline is added back when saving
|
|
1941 |
// the message.
|
|
1942 |
TInt lfLength = KIMSLineFeed().Length();
|
|
1943 |
if ( readOnlyLength && modifiableLength >= lfLength &&
|
|
1944 |
body->Mid( modifiableLength-lfLength, lfLength ) ==
|
|
1945 |
KIMSLineFeed )
|
|
1946 |
{
|
|
1947 |
modifiableLength -= lfLength;
|
|
1948 |
}
|
|
1949 |
|
|
1950 |
iContainer->SetBodyContentL( body->Left( modifiableLength ),
|
|
1951 |
body->Right( readOnlyLength ) );
|
|
1952 |
}
|
|
1953 |
|
|
1954 |
CleanupStack::PopAndDestroy( body );
|
|
1955 |
}
|
|
1956 |
|
|
1957 |
// -----------------------------------------------------------------------------
|
|
1958 |
// CNcsComposeView::IncludeMessageTextAsyncL()
|
|
1959 |
//
|
|
1960 |
// -----------------------------------------------------------------------------
|
|
1961 |
//
|
|
1962 |
void CNcsComposeView::IncludeMessageTextAsyncL( TBool aEnsureSpaceInBegin /*= EFalse*/ )
|
|
1963 |
{
|
|
1964 |
FUNC_LOG;
|
|
1965 |
|
|
1966 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
1967 |
|
|
1968 |
delete iBody;
|
|
1969 |
iBody = NULL;
|
|
1970 |
HBufC* rawBody = GetMessageBodyL();
|
|
1971 |
|
|
1972 |
// Ensure there's free space in the beginning of the message if required
|
|
1973 |
if ( aEnsureSpaceInBegin && rawBody->Length() )
|
|
1974 |
{
|
|
1975 |
TText firstChar = (*rawBody)[0];
|
|
1976 |
_LIT( KNewLines, "\r\n\x2028\x2029" );
|
|
1977 |
if ( KNewLines().Locate( firstChar ) == KErrNotFound )
|
|
1978 |
{
|
|
1979 |
CleanupStack::PushL( rawBody );
|
|
1980 |
// First character is not a new line character. Insert one.
|
|
1981 |
iBody = HBufC::NewL( rawBody->Length() + KIMSLineFeed().Length() );
|
|
1982 |
TPtr ptr = iBody->Des();
|
|
1983 |
ptr.Append( KIMSLineFeed );
|
|
1984 |
ptr.Append( *rawBody );
|
|
1985 |
CleanupStack::PopAndDestroy( rawBody );
|
|
1986 |
rawBody = NULL;
|
|
1987 |
}
|
|
1988 |
}
|
|
1989 |
// If no modifications were needed, then just set body pointer to point
|
|
1990 |
// the rawBody
|
|
1991 |
if ( !iBody )
|
|
1992 |
{
|
|
1993 |
iBody = rawBody;
|
|
1994 |
rawBody = NULL;
|
|
1995 |
}
|
|
1996 |
// Now we have possibly decorated message text in body pointer and
|
|
1997 |
// in cleanup stack
|
|
1998 |
|
|
1999 |
// Divide the contents into normal body and the read-only quote fields
|
|
2000 |
// Convert bytes length to words length
|
|
2001 |
TInt readOnlyLength = iNewMessageTextPart->ReadOnlyPartSize() / 2;
|
|
2002 |
//This check is unnecessary, but without that coverity complains
|
|
2003 |
if ( iBody )
|
|
2004 |
{
|
|
2005 |
TInt modifiableLength = iBody->Length() - readOnlyLength;
|
|
2006 |
|
|
2007 |
// Remove one newline from the end of the modifiable body if there's
|
|
2008 |
// read-only quote present. This is because the field boundary appears
|
|
2009 |
// as newline on the screen. This newline is added back when saving
|
|
2010 |
// the message.
|
|
2011 |
TInt lfLength = KIMSLineFeed().Length();
|
|
2012 |
if ( readOnlyLength && modifiableLength >= lfLength &&
|
|
2013 |
iBody->Mid( modifiableLength-lfLength, lfLength ) == KIMSLineFeed )
|
|
2014 |
{
|
|
2015 |
modifiableLength -= lfLength;
|
|
2016 |
}
|
|
2017 |
|
|
2018 |
iContainer->SetBodyContentAsyncL( iBody->Left( modifiableLength ),
|
|
2019 |
iBody->Right( readOnlyLength ) );
|
|
2020 |
|
|
2021 |
// callback: SetBodyContentCompleteL
|
|
2022 |
}
|
|
2023 |
}
|
|
2024 |
|
|
2025 |
// -----------------------------------------------------------------------------
|
|
2026 |
// CNcsComposeView::SetBodyContentComplete()
|
|
2027 |
//
|
|
2028 |
// -----------------------------------------------------------------------------
|
|
2029 |
//
|
|
2030 |
void CNcsComposeView::SetBodyContentComplete()
|
|
2031 |
{
|
|
2032 |
delete iBody;
|
|
2033 |
iBody = NULL;
|
|
2034 |
|
|
2035 |
if ( iOpeningWaitDialog )
|
|
2036 |
{
|
|
2037 |
TRAP_IGNORE( iOpeningWaitDialog->ProcessFinishedL() );
|
|
2038 |
iOpeningWaitDialog = NULL;
|
|
2039 |
}
|
|
2040 |
|
|
2041 |
iOpeningWaitNoteVisible = EFalse;
|
|
2042 |
iIncludeMessageTextAsync = EFalse;
|
|
2043 |
}
|
|
2044 |
|
|
2045 |
// -----------------------------------------------------------------------------
|
|
2046 |
// CNcsComposeView::IsOpeningWaitNoteVisible()
|
|
2047 |
//
|
|
2048 |
// -----------------------------------------------------------------------------
|
|
2049 |
//
|
|
2050 |
TBool CNcsComposeView::IsOpeningWaitNoteVisible()
|
|
2051 |
{
|
|
2052 |
return iOpeningWaitNoteVisible;
|
|
2053 |
}
|
|
2054 |
|
|
2055 |
// -----------------------------------------------------------------------------
|
|
2056 |
// CNcsComposeView::InitForwardFieldsL()
|
|
2057 |
//
|
|
2058 |
// -----------------------------------------------------------------------------
|
|
2059 |
//
|
|
2060 |
void CNcsComposeView::InitForwardFieldsL()
|
|
2061 |
{
|
|
2062 |
FUNC_LOG;
|
|
2063 |
|
|
2064 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
2065 |
|
|
2066 |
// set subject
|
|
2067 |
HBufC* prefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_FORWARD_PREFIX );
|
|
2068 |
HBufC* formattedSubject = NcsUtility::FormatSubjectLineL(
|
|
2069 |
iOrigMessage->GetSubject(), *prefix );
|
|
2070 |
CleanupStack::PushL( formattedSubject );
|
|
2071 |
iContainer->SetSubjectL( *formattedSubject );
|
|
2072 |
CleanupStack::PopAndDestroy( formattedSubject );
|
|
2073 |
CleanupStack::PopAndDestroy( prefix );
|
|
2074 |
|
|
2075 |
// attachments
|
|
2076 |
AttachmentsListControl()->Model()->Clear();
|
|
2077 |
// <cmail>
|
|
2078 |
TInt error = KErrNone;
|
|
2079 |
TRAP( error, GetAttachmentsFromMailL() );
|
|
2080 |
// </cmail>
|
|
2081 |
SetAttachmentLabelContentL();
|
|
2082 |
|
|
2083 |
}
|
|
2084 |
|
|
2085 |
// -----------------------------------------------------------------------------
|
|
2086 |
// CNcsComposeView::SetPriority()
|
|
2087 |
//
|
|
2088 |
// -----------------------------------------------------------------------------
|
|
2089 |
//
|
|
2090 |
void CNcsComposeView::SetPriority()
|
|
2091 |
{
|
|
2092 |
FUNC_LOG;
|
|
2093 |
|
|
2094 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
2095 |
|
|
2096 |
if ( iNewMessage && iNewMessage->IsFlagSet( EFSMsgFlag_Important ) )
|
|
2097 |
{
|
|
2098 |
iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityHigh );
|
|
2099 |
}
|
|
2100 |
else if ( iNewMessage && iNewMessage->IsFlagSet( EFSMsgFlag_Low ) )
|
|
2101 |
{
|
|
2102 |
iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityLow );
|
|
2103 |
}
|
|
2104 |
}
|
|
2105 |
|
|
2106 |
// -----------------------------------------------------------------------------
|
|
2107 |
// Sets follow-up flags to status pane indicators
|
|
2108 |
// -----------------------------------------------------------------------------
|
|
2109 |
//
|
|
2110 |
void CNcsComposeView::SetFollowUp()
|
|
2111 |
{
|
|
2112 |
if ( iNewMessage && iStatusPaneIndicators )
|
|
2113 |
{
|
|
2114 |
if ( iNewMessage->IsFlagSet( EFSMsgFlag_FollowUp ) )
|
|
2115 |
{
|
|
2116 |
iStatusPaneIndicators->SetFollowUpFlag(
|
|
2117 |
CCustomStatuspaneIndicators::EFollowUp );
|
|
2118 |
}
|
|
2119 |
else if ( iNewMessage->IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
|
|
2120 |
{
|
|
2121 |
iStatusPaneIndicators->SetFollowUpFlag(
|
|
2122 |
CCustomStatuspaneIndicators::EFollowUpComplete );
|
|
2123 |
}
|
|
2124 |
}
|
|
2125 |
}
|
|
2126 |
|
|
2127 |
// -----------------------------------------------------------------------------
|
|
2128 |
// CNcsComposeView::InitFieldsL()
|
|
2129 |
//
|
|
2130 |
// -----------------------------------------------------------------------------
|
|
2131 |
//
|
|
2132 |
void CNcsComposeView::InitFieldsL()
|
|
2133 |
{
|
|
2134 |
FUNC_LOG;
|
|
2135 |
|
|
2136 |
__ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
|
|
2137 |
|
|
2138 |
// to
|
|
2139 |
RPointerArray<CFSMailAddress>& toRecipients =
|
|
2140 |
iNewMessage->GetToRecipients();
|
|
2141 |
RPointerArray<CNcsEmailAddressObject> ncsToRecipients;
|
|
2142 |
CleanupResetAndDestroyClosePushL( ncsToRecipients );
|
|
2143 |
NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients );
|
|
2144 |
iContainer->SetToFieldAddressesL( ncsToRecipients );
|
|
2145 |
CleanupStack::PopAndDestroy( &ncsToRecipients );
|
|
2146 |
|
|
2147 |
// cc
|
|
2148 |
RPointerArray<CFSMailAddress>& ccRecipients =
|
|
2149 |
iNewMessage->GetCCRecipients();
|
|
2150 |
RPointerArray<CNcsEmailAddressObject> ncsCcRecipients;
|
|
2151 |
CleanupResetAndDestroyClosePushL( ncsCcRecipients );
|
|
2152 |
NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients );
|
|
2153 |
iContainer->SetCcFieldAddressesL( ncsCcRecipients );
|
|
2154 |
CleanupStack::PopAndDestroy( &ncsCcRecipients );
|
|
2155 |
|
|
2156 |
// bcc
|
|
2157 |
RPointerArray<CFSMailAddress>& bccRecipients =
|
|
2158 |
iNewMessage->GetBCCRecipients();
|
|
2159 |
RPointerArray<CNcsEmailAddressObject> ncsBccRecipients;
|
|
2160 |
CleanupResetAndDestroyClosePushL( ncsBccRecipients );
|
|
2161 |
NcsUtility::ConvertAddressArrayL( bccRecipients, ncsBccRecipients );
|
|
2162 |
iContainer->SetBccFieldAddressesL( ncsBccRecipients );
|
|
2163 |
CleanupStack::PopAndDestroy( &ncsBccRecipients );
|
|
2164 |
|
|
2165 |
// set subject line
|
|
2166 |
iContainer->SetSubjectL( iNewMessage->GetSubject() );
|
|
2167 |
|
|
2168 |
}
|
|
2169 |
|
|
2170 |
// -----------------------------------------------------------------------------
|
|
2171 |
// CNcsComposeView::GetMessageBodyL()
|
|
2172 |
//
|
|
2173 |
// -----------------------------------------------------------------------------
|
|
2174 |
//
|
|
2175 |
HBufC* CNcsComposeView::GetMessageBodyL()
|
|
2176 |
{
|
|
2177 |
FUNC_LOG;
|
|
2178 |
|
|
2179 |
__ASSERT_DEBUG( iNewMessageTextPart, Panic( ENcsBasicUi ) );
|
|
2180 |
|
|
2181 |
TInt messageSize = iNewMessageTextPart->FetchedContentSize();
|
|
2182 |
|
|
2183 |
HBufC* data = NULL;
|
|
2184 |
|
|
2185 |
if ( messageSize > 0 )
|
|
2186 |
{
|
|
2187 |
// fetch message body if there is something to fetch
|
|
2188 |
data = HBufC::NewLC( messageSize );
|
|
2189 |
TPtr dataPtr = data->Des();
|
|
2190 |
iNewMessageTextPart->GetContentToBufferL( dataPtr, 0 );
|
|
2191 |
CleanupStack::Pop( data );
|
|
2192 |
}
|
|
2193 |
else
|
|
2194 |
{
|
|
2195 |
data = KNullDesC().AllocL();
|
|
2196 |
}
|
|
2197 |
|
|
2198 |
return data;
|
|
2199 |
}
|
|
2200 |
|
|
2201 |
// -----------------------------------------------------------------------------
|
|
2202 |
// CNcsComposeView::CommitL()
|
|
2203 |
//
|
|
2204 |
// -----------------------------------------------------------------------------
|
|
2205 |
//
|
|
2206 |
void CNcsComposeView::CommitL( TBool aParseAddresses,
|
|
2207 |
TFieldToCommit aFieldToCommit, TBool aSaveNow, TCommitType aType )
|
|
2208 |
{
|
|
2209 |
FUNC_LOG;
|
|
2210 |
__ASSERT_DEBUG( iNewMessage, Panic( ENcsBasicUi ) );
|
|
2211 |
__ASSERT_DEBUG( iNewMessageTextPart, Panic( ENcsBasicUi ) );
|
|
2212 |
|
|
2213 |
TBool commitToField = EFalse;
|
|
2214 |
TBool commitCcField = EFalse;
|
|
2215 |
TBool commitBccField = EFalse;
|
|
2216 |
TBool commitSubjectField = EFalse;
|
|
2217 |
TBool commitBodyField = EFalse;
|
|
2218 |
|
|
2219 |
switch ( aFieldToCommit )
|
|
2220 |
{
|
|
2221 |
case EAllFields:
|
|
2222 |
commitToField = ETrue;
|
|
2223 |
commitCcField = ETrue;
|
|
2224 |
commitBccField = ETrue;
|
|
2225 |
commitSubjectField = ETrue;
|
|
2226 |
commitBodyField = ETrue;
|
|
2227 |
break;
|
|
2228 |
case EToField:
|
|
2229 |
commitToField = ETrue;
|
|
2230 |
break;
|
|
2231 |
case ECcField:
|
|
2232 |
commitCcField = ETrue;
|
|
2233 |
break;
|
|
2234 |
case EBccField:
|
|
2235 |
commitBccField = ETrue;
|
|
2236 |
break;
|
|
2237 |
case EBodyField:
|
|
2238 |
commitBodyField = ETrue;
|
|
2239 |
break;
|
|
2240 |
case ESubjectField:
|
|
2241 |
commitSubjectField = ETrue;
|
|
2242 |
break;
|
|
2243 |
default:
|
|
2244 |
break;
|
|
2245 |
}
|
|
2246 |
|
|
2247 |
if ( commitToField )
|
|
2248 |
{
|
|
2249 |
RPointerArray<CFSMailAddress>& recipients =
|
|
2250 |
iNewMessage->GetToRecipients();
|
|
2251 |
recipients.ResetAndDestroy();
|
|
2252 |
NcsUtility::ConvertAddressArrayL(
|
|
2253 |
iContainer->GetToFieldAddressesL( aParseAddresses ), recipients );
|
|
2254 |
}
|
|
2255 |
|
|
2256 |
if ( commitCcField )
|
|
2257 |
{
|
|
2258 |
RPointerArray<CFSMailAddress>& recipients =
|
|
2259 |
iNewMessage->GetCCRecipients();
|
|
2260 |
recipients.ResetAndDestroy();
|
|
2261 |
NcsUtility::ConvertAddressArrayL(
|
|
2262 |
iContainer->GetCcFieldAddressesL( aParseAddresses ), recipients );
|
|
2263 |
}
|
|
2264 |
|
|
2265 |
if ( commitBccField )
|
|
2266 |
{
|
|
2267 |
RPointerArray<CFSMailAddress>& recipients =
|
|
2268 |
iNewMessage->GetBCCRecipients();
|
|
2269 |
recipients.ResetAndDestroy();
|
|
2270 |
NcsUtility::ConvertAddressArrayL(
|
|
2271 |
iContainer->GetBccFieldAddressesL( aParseAddresses ), recipients );
|
|
2272 |
}
|
|
2273 |
|
|
2274 |
if ( commitSubjectField )
|
|
2275 |
{
|
|
2276 |
// get subject from UI to MSG object
|
|
2277 |
HBufC* subject = iContainer->GetSubjectLC();
|
|
2278 |
TPtr ptr = subject->Des();
|
|
2279 |
// replace new line characters with spaces as Subject is normally
|
|
2280 |
// one line only
|
|
2281 |
AknTextUtils::ReplaceCharacters(
|
|
2282 |
ptr, KLineSeparators, KReplacementChar );
|
|
2283 |
iNewMessage->SetSubject( *subject );
|
|
2284 |
CleanupStack::PopAndDestroy( subject );
|
|
2285 |
}
|
|
2286 |
|
|
2287 |
if ( commitBodyField )
|
|
2288 |
{
|
|
2289 |
HBufC* body = iContainer->GetBodyContentLC();
|
|
2290 |
TPtr bodyPtr = body->Des(); // this TPtr is needed only because of
|
|
2291 |
// incorrect argument type in FW API, can be removed when API fixed
|
|
2292 |
iNewMessageTextPart->SetContent( bodyPtr );
|
|
2293 |
CleanupStack::PopAndDestroy( body );
|
|
2294 |
iMessageTextPartModified = ETrue;
|
|
2295 |
}
|
|
2296 |
|
|
2297 |
iMessageModified = ETrue;
|
|
2298 |
RefreshToolbar();
|
|
2299 |
|
|
2300 |
if ( aSaveNow )
|
|
2301 |
{
|
|
2302 |
SaveMessageL();
|
|
2303 |
|
|
2304 |
// If this is final commit, then inform it via extension
|
|
2305 |
if ( aType == EFinal )
|
|
2306 |
{
|
|
2307 |
CMailMessageExtension* messageExtension =
|
|
2308 |
static_cast<CMailMessageExtension*>
|
|
2309 |
( iNewMessage->ExtensionL( KEmailMessageExtensionUid ) );
|
|
2310 |
if ( messageExtension )
|
|
2311 |
{
|
|
2312 |
messageExtension->CommitL( *iNewMessage ) ;
|
|
2313 |
iNewMessage->ReleaseExtension( messageExtension );
|
|
2314 |
}
|
|
2315 |
}
|
|
2316 |
}
|
|
2317 |
}
|
|
2318 |
|
|
2319 |
TInt CNcsComposeView::SaveMessage()
|
|
2320 |
{
|
|
2321 |
FUNC_LOG;
|
|
2322 |
TInt error = KErrNone;
|
|
2323 |
TRAP( error, SaveMessageL() );
|
|
2324 |
return error;
|
|
2325 |
}
|
|
2326 |
|
|
2327 |
// -----------------------------------------------------------------------------
|
|
2328 |
// Saves the new message if it has been modifed since the last save.
|
|
2329 |
// -----------------------------------------------------------------------------
|
|
2330 |
void CNcsComposeView::SaveMessageL()
|
|
2331 |
{
|
|
2332 |
FUNC_LOG;
|
|
2333 |
if ( iNewMessageTextPart && iMessageTextPartModified )
|
|
2334 |
{
|
|
2335 |
iNewMessageTextPart->SaveL();
|
|
2336 |
iMessageTextPartModified = EFalse;
|
|
2337 |
}
|
|
2338 |
|
|
2339 |
if ( iNewMessage && iMessageModified )
|
|
2340 |
{
|
|
2341 |
iNewMessage->SaveMessageL();
|
|
2342 |
iMessageModified = EFalse;
|
|
2343 |
}
|
|
2344 |
}
|
|
2345 |
|
|
2346 |
// -----------------------------------------------------------------------------
|
|
2347 |
// CNcsComposeView::DoSafeExit
|
|
2348 |
// -----------------------------------------------------------------------------
|
|
2349 |
void CNcsComposeView::DoSafeExit( TExitMode aMode )
|
|
2350 |
{
|
|
2351 |
FUNC_LOG;
|
|
2352 |
if ( !iExecutingDoExitL )
|
|
2353 |
{
|
|
2354 |
iExecutingDoExitL = ETrue;
|
|
2355 |
TRAP_IGNORE( DoExitL( aMode ) );
|
|
2356 |
iExecutingDoExitL = EFalse;
|
|
2357 |
}
|
|
2358 |
}
|
|
2359 |
|
|
2360 |
|
|
2361 |
// -----------------------------------------------------------------------------
|
|
2362 |
// CNcsComposeView::DoExitL
|
|
2363 |
// -----------------------------------------------------------------------------
|
|
2364 |
void CNcsComposeView::DoExitL( TExitMode aMode )
|
|
2365 |
{
|
|
2366 |
FUNC_LOG;
|
|
2367 |
|
|
2368 |
TBool emptyMessage = ETrue;
|
|
2369 |
|
|
2370 |
if ( iAutoSaver && iContainer )
|
|
2371 |
{
|
|
2372 |
iAutoSaver->Enable( EFalse );
|
|
2373 |
|
|
2374 |
// check for some user input in some header field or in message body
|
|
2375 |
TInt attaCount = AttachmentsListControl()->Model()->Count();
|
|
2376 |
emptyMessage = iContainer->AreAddressFieldsEmpty() &&
|
|
2377 |
iContainer->IsSubjectFieldEmpty() &&
|
|
2378 |
iContainer->GetMessageFieldLength() < 1 &&
|
|
2379 |
attaCount <= 0;
|
|
2380 |
}
|
|
2381 |
|
|
2382 |
// Consider saving the draft if the message is not completely empty
|
|
2383 |
if ( !emptyMessage )
|
|
2384 |
{
|
|
2385 |
if ( aMode == ESaveDraftQuery && !iMailSent && !iMailSendFailed )
|
|
2386 |
{
|
|
2387 |
TBool actionSucceeded = EFalse;
|
|
2388 |
|
|
2389 |
// DoSaveDraftL returns EFalse if the user query was cancelled
|
|
2390 |
// or saving to Drafts failed
|
|
2391 |
TRAPD( saveDraftError, actionSucceeded = DoSaveDraftL( ETrue ) );
|
|
2392 |
if ( saveDraftError == KErrNone )
|
|
2393 |
{
|
|
2394 |
if ( !actionSucceeded )
|
|
2395 |
{
|
|
2396 |
// return to normal action
|
|
2397 |
// (cancel was pressed in the query)
|
|
2398 |
iAutoSaver->Enable( ETrue );
|
|
2399 |
return;
|
|
2400 |
}
|
|
2401 |
}
|
|
2402 |
else
|
|
2403 |
{
|
|
2404 |
}
|
|
2405 |
}
|
|
2406 |
else if ( aMode == ESaveDraft )
|
|
2407 |
{
|
|
2408 |
DoSaveDraftL( EFalse );
|
|
2409 |
}
|
|
2410 |
}
|
|
2411 |
else if ( iNewMessage ) // message is empty
|
|
2412 |
{
|
|
2413 |
// delete the draft if it has been already saved earlier
|
|
2414 |
TInt err = NcsUtility::DeleteMessage( iMailClient, iMailBox->GetId(),
|
|
2415 |
iNewMessage->GetFolderId(), iNewMessage->GetMessageId() );
|
|
2416 |
if ( !err && iMailBox->HasCapability(
|
|
2417 |
EFSMBoxCapaSupportsDeletedItemsFolder ) )
|
|
2418 |
{
|
|
2419 |
err = NcsUtility::DeleteMessage( iMailClient, iMailBox->GetId(),
|
|
2420 |
iMailBox->GetStandardFolderId( EFSDeleted ),
|
|
2421 |
iNewMessage->GetMessageId() );
|
|
2422 |
}
|
|
2423 |
|
|
2424 |
if ( !err && !iAppUi.AppUiExitOngoing() )
|
|
2425 |
{
|
|
2426 |
// Simulate delete event so that drafts folder is
|
|
2427 |
// updated correctly.
|
|
2428 |
RArray<TFSMailMsgId> messageIds;
|
|
2429 |
CleanupClosePushL( messageIds );
|
|
2430 |
messageIds.AppendL( iNewMessage->GetMessageId() );
|
|
2431 |
TFSMailMsgId folderId = iNewMessage->GetFolderId();
|
|
2432 |
TFSMailMsgId mailboxId = iNewMessage->GetMailBoxId();
|
|
2433 |
iAppUi.EventL( TFSEventMailDeleted,
|
|
2434 |
mailboxId, &messageIds, &folderId, NULL );
|
|
2435 |
CleanupStack::PopAndDestroy( &messageIds );
|
|
2436 |
}
|
|
2437 |
}
|
|
2438 |
|
|
2439 |
// Clear attachment control now that message has been sent
|
|
2440 |
// othewise this will kind of leak memory by leaving attachments
|
|
2441 |
// in the list, even if they have been sent.
|
|
2442 |
CFreestyleEmailUiSendAttachmentsListControl* attachmentControl;
|
|
2443 |
attachmentControl = AttachmentsListControl();
|
|
2444 |
if ( attachmentControl && attachmentControl->Model() )
|
|
2445 |
{
|
|
2446 |
attachmentControl->Model()->Clear();
|
|
2447 |
}
|
|
2448 |
ExitComposer();
|
|
2449 |
TIMESTAMP( "Editor exited" );
|
|
2450 |
}
|
|
2451 |
|
|
2452 |
// -----------------------------------------------------------------------------
|
|
2453 |
// CNcsComposeView::DoOpenAttachmentList
|
|
2454 |
// Opens the currently focused attachment
|
|
2455 |
// -----------------------------------------------------------------------------
|
|
2456 |
void CNcsComposeView::DoOpenAttachmentListL()
|
|
2457 |
{
|
|
2458 |
FUNC_LOG;
|
|
2459 |
|
|
2460 |
CFreestyleEmailUiSendAttachmentsListControl* attachmentControl
|
|
2461 |
= AttachmentsListControl();
|
|
2462 |
|
|
2463 |
TInt index( iContainer ? iContainer->FocusedAttachmentLabelIndex()
|
|
2464 |
: KNoAttachmentLabelFocused );
|
|
2465 |
if ( KNoAttachmentLabelFocused != index &&
|
|
2466 |
attachmentControl && attachmentControl->Model() )
|
|
2467 |
{
|
|
2468 |
CFSEmailUiSendAttachmentsListModelItem* item =
|
|
2469 |
static_cast<CFSEmailUiSendAttachmentsListModelItem*>(
|
|
2470 |
attachmentControl->Model()->Item( index ) );
|
|
2471 |
|
|
2472 |
if ( item && !item->IsRemote() ) // cannot open remote attachments
|
|
2473 |
{
|
|
2474 |
CFSMailMessagePart* msgPart =
|
|
2475 |
iNewMessage->ChildPartL( item->MailMsgPartId() );
|
|
2476 |
CleanupStack::PushL( msgPart );
|
|
2477 |
TFsEmailUiUtility::OpenAttachmentL( *msgPart );
|
|
2478 |
CleanupStack::PopAndDestroy( msgPart );
|
|
2479 |
}
|
|
2480 |
}
|
|
2481 |
}
|
|
2482 |
|
|
2483 |
// -----------------------------------------------------------------------------
|
|
2484 |
// CNcsComposeView::LaunchStylusPopupMenu
|
|
2485 |
// Show stylus popup menu for the attachments line
|
|
2486 |
// -----------------------------------------------------------------------------
|
|
2487 |
//
|
|
2488 |
void CNcsComposeView::LaunchStylusPopupMenu( const TPoint& aPenEventScreenLocation )
|
|
2489 |
{
|
|
2490 |
FUNC_LOG;
|
|
2491 |
|
|
2492 |
CFSEmailUiSendAttachmentsListModel* attachmentModel =
|
|
2493 |
( AttachmentsListControl() ?
|
|
2494 |
AttachmentsListControl()->Model() : NULL );
|
|
2495 |
TInt count( attachmentModel ? attachmentModel->Count() : 0 );
|
|
2496 |
TBool attachmentsInModel( count > 0 );
|
|
2497 |
CFSEmailUiSendAttachmentsListModelItem* item( NULL );
|
|
2498 |
|
|
2499 |
if ( attachmentsInModel )
|
|
2500 |
{
|
|
2501 |
item = static_cast<CFSEmailUiSendAttachmentsListModelItem*>(
|
|
2502 |
attachmentModel->Item(
|
|
2503 |
iContainer->FocusedAttachmentLabelIndex() ) );
|
|
2504 |
// Only non-remote attachments can be opened
|
|
2505 |
TBool dimOpenMenuItem = !item || item->IsRemote();
|
|
2506 |
iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdOpenAttachment, dimOpenMenuItem );
|
|
2507 |
|
|
2508 |
// Read-only attachments cannot be removed
|
|
2509 |
TBool dimRemoveMenuItem = !item || item->IsReadOnly();
|
|
2510 |
iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdRemoveAttachment, dimRemoveMenuItem );
|
|
2511 |
}
|
|
2512 |
|
|
2513 |
// Set the position for the popup
|
|
2514 |
iStylusPopUpMenu->SetPosition( aPenEventScreenLocation );
|
|
2515 |
|
|
2516 |
// Display the popup.
|
|
2517 |
iStylusPopUpMenu->ShowMenu();
|
|
2518 |
}
|
|
2519 |
|
|
2520 |
// -----------------------------------------------------------------------------
|
|
2521 |
// CNcsComposeView::GetAttachmentsFromMail
|
|
2522 |
// -----------------------------------------------------------------------------
|
|
2523 |
void CNcsComposeView::GetAttachmentsFromMailL()
|
|
2524 |
{
|
|
2525 |
FUNC_LOG;
|
|
2526 |
|
|
2527 |
TInt error( KErrNone );
|
|
2528 |
|
|
2529 |
RPointerArray<CFSMailMessagePart> attachments;
|
|
2530 |
CleanupResetAndDestroyClosePushL( attachments );
|
|
2531 |
TRAP( error, iNewMessage->AttachmentListL( attachments ) );
|
|
2532 |
User::LeaveIfError( error );
|
|
2533 |
|
|
2534 |
for ( TInt i=0; i<attachments.Count(); ++i )
|
|
2535 |
{
|
|
2536 |
TFileType fileType = TFsEmailUiUtility::GetFileType(
|
|
2537 |
attachments[i]->AttachmentNameL(),
|
|
2538 |
attachments[i]->GetContentType() );
|
|
2539 |
|
|
2540 |
TBool isReadOnly = ( attachments[i]->ReadOnlyPartSize() > 0 );
|
|
2541 |
TBool isRemote = EFalse;
|
|
2542 |
|
|
2543 |
if ( attachments[i]->FetchedContentSize() <
|
|
2544 |
attachments[i]->ContentSize() )
|
|
2545 |
{
|
|
2546 |
if ( iMailBox->HasCapability( EFSMBoxCapaSmartForward ) )
|
|
2547 |
{
|
|
2548 |
isRemote = ETrue;
|
|
2549 |
}
|
|
2550 |
else
|
|
2551 |
{
|
|
2552 |
__ASSERT_DEBUG( EFalse, Panic(EFSEmailUiUnexpectedValue) );
|
|
2553 |
User::Leave( KErrNotFound );
|
|
2554 |
continue;
|
|
2555 |
}
|
|
2556 |
}
|
|
2557 |
|
|
2558 |
AttachmentsListControl()->AppendFileToModelL(
|
|
2559 |
attachments[i]->GetPartId(),
|
|
2560 |
attachments[i]->AttachmentNameL(),
|
|
2561 |
attachments[i]->ContentSize(),
|
|
2562 |
fileType,
|
|
2563 |
isReadOnly,
|
|
2564 |
isRemote );
|
|
2565 |
}
|
|
2566 |
|
|
2567 |
CleanupStack::PopAndDestroy( &attachments );
|
|
2568 |
|
|
2569 |
}
|
|
2570 |
|
|
2571 |
// -----------------------------------------------------------------------------
|
|
2572 |
// CNcsComposeView::FileExistsInModel
|
|
2573 |
// -----------------------------------------------------------------------------
|
|
2574 |
TBool CNcsComposeView::FileExistsInModel( TFSMailMsgId aAttachmentId )
|
|
2575 |
{
|
|
2576 |
FUNC_LOG;
|
|
2577 |
|
|
2578 |
TInt count( AttachmentsListControl()->Model()->Count() );
|
|
2579 |
|
|
2580 |
for ( TInt i=0; i < count; ++i )
|
|
2581 |
{
|
|
2582 |
CFSEmailUiSendAttachmentsListModelItem* item =
|
|
2583 |
static_cast<CFSEmailUiSendAttachmentsListModelItem*>(
|
|
2584 |
AttachmentsListControl()->Model()->Item(i) );
|
|
2585 |
if ( aAttachmentId.Id() == item->MailMsgPartId().Id() )
|
|
2586 |
{
|
|
2587 |
return ETrue;
|
|
2588 |
}
|
|
2589 |
}
|
|
2590 |
|
|
2591 |
return EFalse;
|
|
2592 |
}
|
|
2593 |
|
|
2594 |
// -----------------------------------------------------------------------------
|
|
2595 |
// CNcsComposeView::GenerateReplyHeaderLC
|
|
2596 |
// -----------------------------------------------------------------------------
|
|
2597 |
HBufC* CNcsComposeView::GenerateReplyHeaderLC()
|
|
2598 |
{
|
|
2599 |
FUNC_LOG;
|
|
2600 |
|
|
2601 |
__ASSERT_DEBUG( iOrigMessage, Panic( ENcsBasicUi ) );
|
|
2602 |
|
|
2603 |
// separator line
|
|
2604 |
HBufC* separator =
|
|
2605 |
StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_MESSAGE_LINE_SEPARATOR ); //1
|
|
2606 |
|
|
2607 |
// from line
|
|
2608 |
RPointerArray<CNcsEmailAddressObject> senderArray;
|
|
2609 |
CleanupResetAndDestroyClosePushL( senderArray );
|
|
2610 |
CFSMailAddress* sender = iOrigMessage->GetSender();
|
|
2611 |
if ( sender )
|
|
2612 |
{
|
|
2613 |
CNcsEmailAddressObject* ncsSender =
|
|
2614 |
NcsUtility::CreateNcsAddressL( *sender );
|
|
2615 |
CleanupStack::PushL( ncsSender );
|
|
2616 |
senderArray.AppendL( ncsSender );
|
|
2617 |
CleanupStack::Pop( ncsSender ); // now owned by senderArray
|
|
2618 |
}
|
|
2619 |
HBufC* fromLine =
|
|
2620 |
NcsUtility::GenerateFromLineToMessageBodyL( senderArray );
|
|
2621 |
CleanupStack::PopAndDestroy( &senderArray );
|
|
2622 |
CleanupStack::PushL( fromLine ); //2
|
|
2623 |
|
|
2624 |
// sent line
|
|
2625 |
HBufC* sentLine =
|
|
2626 |
NcsUtility::GenerateSentLineToMessageBodyL( *iOrigMessage );
|
|
2627 |
CleanupStack::PushL( sentLine ); //3
|
|
2628 |
|
|
2629 |
// to line
|
|
2630 |
RPointerArray<CNcsEmailAddressObject> ncsToRecipients;
|
|
2631 |
CleanupResetAndDestroyClosePushL( ncsToRecipients );
|
|
2632 |
RPointerArray<CFSMailAddress>& toRecipients =
|
|
2633 |
iOrigMessage->GetToRecipients();
|
|
2634 |
NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients );
|
|
2635 |
HBufC* toLine = NcsUtility::GenerateAddressLineToMessageBodyL(
|
|
2636 |
ncsToRecipients, NcsUtility::ERecipientTypeTo );
|
|
2637 |
CleanupStack::PopAndDestroy( &ncsToRecipients );
|
|
2638 |
CleanupStack::PushL( toLine ); //4
|
|
2639 |
|
|
2640 |
// cc line
|
|
2641 |
RPointerArray<CFSMailAddress>& ccRecipients =
|
|
2642 |
iOrigMessage->GetCCRecipients();
|
|
2643 |
TBool hasCcLine = ( ccRecipients.Count() > 0 );
|
|
2644 |
HBufC* ccLine = NULL;
|
|
2645 |
if ( hasCcLine )
|
|
2646 |
{
|
|
2647 |
RPointerArray<CNcsEmailAddressObject> ncsCcRecipients;
|
|
2648 |
CleanupResetAndDestroyClosePushL( ncsCcRecipients );
|
|
2649 |
NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients );
|
|
2650 |
ccLine = NcsUtility::GenerateAddressLineToMessageBodyL(
|
|
2651 |
ncsCcRecipients, NcsUtility::ERecipientTypeCc );
|
|
2652 |
CleanupStack::PopAndDestroy( &ncsCcRecipients );
|
|
2653 |
CleanupStack::PushL( ccLine ); //5
|
|
2654 |
}
|
|
2655 |
|
|
2656 |
// subject line
|
|
2657 |
HBufC* subjectLine = NcsUtility::GenerateSubjectLineToMessageBodyL(
|
|
2658 |
iOrigMessage->GetSubject() );
|
|
2659 |
CleanupStack::PushL( subjectLine ); //6
|
|
2660 |
|
|
2661 |
// Body
|
|
2662 |
HBufC* body = NULL;
|
|
2663 |
TBool hasBody = EFalse;
|
|
2664 |
CFSMailMessagePart* textBodyPart = iOrigMessage->PlainTextBodyPartL();
|
|
2665 |
if ( textBodyPart )
|
|
2666 |
{
|
|
2667 |
// Plain text body part present, no need
|
|
2668 |
// to generate it from HTML body part
|
|
2669 |
delete textBodyPart;
|
|
2670 |
}
|
|
2671 |
else
|
|
2672 |
{
|
|
2673 |
// Generate body part for reply
|
|
2674 |
CFSMailMessagePart* htmlBodyPart = iOrigMessage->HtmlBodyPartL();
|
|
2675 |
if ( htmlBodyPart )
|
|
2676 |
{
|
|
2677 |
CleanupStack::PushL( htmlBodyPart );
|
|
2678 |
|
|
2679 |
HBufC* htmlData =
|
|
2680 |
HBufC::NewLC( htmlBodyPart->FetchedContentSize() );
|
|
2681 |
TPtr pointer = htmlData->Des();
|
|
2682 |
htmlBodyPart->GetContentToBufferL( pointer, 0 );
|
|
2683 |
|
|
2684 |
body = TFsEmailUiUtility::ConvertHtmlToTxtL( *htmlData );
|
|
2685 |
|
|
2686 |
CleanupStack::PopAndDestroy( htmlData );
|
|
2687 |
CleanupStack::PopAndDestroy( htmlBodyPart );
|
|
2688 |
|
|
2689 |
CleanupStack::PushL( body ); //7
|
|
2690 |
|
|
2691 |
hasBody = ETrue;
|
|
2692 |
}
|
|
2693 |
}
|
|
2694 |
// calculate total length
|
|
2695 |
TInt length = 0;
|
|
2696 |
length += separator->Length();
|
|
2697 |
length += KIMSLineFeed().Length();
|
|
2698 |
length += fromLine->Length();
|
|
2699 |
length += KIMSLineFeed().Length();
|
|
2700 |
length += sentLine->Length();
|
|
2701 |
length += KIMSLineFeed().Length();
|
|
2702 |
length += toLine->Length();
|
|
2703 |
if ( hasCcLine )
|
|
2704 |
{
|
|
2705 |
length += KIMSLineFeed().Length();
|
|
2706 |
length += ccLine->Length();
|
|
2707 |
}
|
|
2708 |
length += KIMSLineFeed().Length();
|
|
2709 |
length += subjectLine->Length();
|
|
2710 |
length += KIMSLineFeed().Length();
|
|
2711 |
if ( hasBody )
|
|
2712 |
{
|
|
2713 |
length += body->Length();
|
|
2714 |
}
|
|
2715 |
length += KIMSLineFeed().Length();
|
|
2716 |
length += KIMSLineFeed().Length();
|
|
2717 |
|
|
2718 |
// create buffer and write contents
|
|
2719 |
HBufC* header = HBufC::NewL( length );
|
|
2720 |
TPtr ptr = header->Des();
|
|
2721 |
ptr.Append( *separator );
|
|
2722 |
ptr.Append( KIMSLineFeed );
|
|
2723 |
ptr.Append( *fromLine );
|
|
2724 |
ptr.Append( KIMSLineFeed );
|
|
2725 |
ptr.Append( *sentLine );
|
|
2726 |
ptr.Append( KIMSLineFeed );
|
|
2727 |
ptr.Append( *toLine );
|
|
2728 |
if ( hasCcLine )
|
|
2729 |
{
|
|
2730 |
ptr.Append( KIMSLineFeed );
|
|
2731 |
ptr.Append( *ccLine );
|
|
2732 |
}
|
|
2733 |
ptr.Append( KIMSLineFeed );
|
|
2734 |
ptr.Append( *subjectLine );
|
|
2735 |
ptr.Append( KIMSLineFeed );
|
|
2736 |
if ( hasBody )
|
|
2737 |
{
|
|
2738 |
ptr.Append( *body );
|
|
2739 |
}
|
|
2740 |
ptr.Append( KIMSLineFeed );
|
|
2741 |
ptr.Append( KIMSLineFeed );
|
|
2742 |
|
|
2743 |
// leave header on the cleanup stack
|
|
2744 |
if ( hasBody )
|
|
2745 |
{
|
|
2746 |
CleanupStack::PopAndDestroy( body ); //-7
|
|
2747 |
}
|
|
2748 |
CleanupStack::PopAndDestroy( subjectLine ); //-6
|
|
2749 |
if ( hasCcLine )
|
|
2750 |
{
|
|
2751 |
CleanupStack::PopAndDestroy( ccLine ); //-5
|
|
2752 |
}
|
|
2753 |
CleanupStack::PopAndDestroy( toLine ); //-4
|
|
2754 |
CleanupStack::PopAndDestroy( sentLine ); //-3
|
|
2755 |
CleanupStack::PopAndDestroy( fromLine ); //-2
|
|
2756 |
CleanupStack::PopAndDestroy( separator ); //-1
|
|
2757 |
|
|
2758 |
CleanupStack::PushL( header );
|
|
2759 |
|
|
2760 |
return header;
|
|
2761 |
}
|
|
2762 |
|
|
2763 |
// -----------------------------------------------------------------------------
|
|
2764 |
// CNcsComposeView::GenerateSmartTagLC
|
|
2765 |
// -----------------------------------------------------------------------------
|
|
2766 |
HBufC* CNcsComposeView::GenerateSmartTagLC()
|
|
2767 |
{
|
|
2768 |
FUNC_LOG;
|
|
2769 |
|
|
2770 |
HBufC* tag = StringLoader::LoadLC( R_FSE_EDITOR_SMART_TAG );
|
|
2771 |
|
|
2772 |
return tag;
|
|
2773 |
}
|
|
2774 |
|
|
2775 |
// -----------------------------------------------------------------------------
|
|
2776 |
// CNcsComposeView::InitReplyOrForwardUiL
|
|
2777 |
// -----------------------------------------------------------------------------
|
|
2778 |
//
|
|
2779 |
void CNcsComposeView::InitReplyOrForwardUiL()
|
|
2780 |
{
|
|
2781 |
FUNC_LOG;
|
|
2782 |
// Show "Opening" wait note if the message body is large
|
|
2783 |
iOpeningWaitNoteVisible = EFalse;
|
|
2784 |
if ( TFsEmailUiUtility::IsMessageBodyLargeL(iOrigMessage) )
|
|
2785 |
{
|
|
2786 |
TFsEmailUiUtility::ShowWaitNoteL( iOpeningWaitDialog,
|
|
2787 |
R_FSE_WAIT_OPENING_TEXT, EFalse, ETrue );
|
|
2788 |
iOpeningWaitNoteVisible = ETrue;
|
|
2789 |
}
|
|
2790 |
|
|
2791 |
// disable this flag if "old style" sync mode is needed
|
|
2792 |
// for including body of text
|
|
2793 |
iIncludeMessageTextAsync = ETrue;
|
|
2794 |
|
|
2795 |
if ( iCustomMessageId == TUid::Uid( KEditorCmdReply ) )
|
|
2796 |
{
|
|
2797 |
GenerateReplyMessageL( EFalse );
|
|
2798 |
InitReplyUiL( EFalse );
|
|
2799 |
}
|
|
2800 |
else if ( iCustomMessageId == TUid::Uid( KEditorCmdReplyAll ) )
|
|
2801 |
{
|
|
2802 |
GenerateReplyMessageL( ETrue );
|
|
2803 |
InitReplyUiL( ETrue );
|
|
2804 |
}
|
|
2805 |
else if ( iCustomMessageId == TUid::Uid( KEditorCmdForward ) )
|
|
2806 |
{
|
|
2807 |
GenerateForwardMessageL();
|
|
2808 |
InitForwardUiL();
|
|
2809 |
}
|
|
2810 |
else
|
|
2811 |
{
|
|
2812 |
// This shouldn't ever happen. Panic in debug builds.
|
|
2813 |
ASSERT( EFalse );
|
|
2814 |
}
|
|
2815 |
|
|
2816 |
// Close the "Opening" wait note if it was shown
|
|
2817 |
// and include message text was done synchronously
|
|
2818 |
if ( !iIncludeMessageTextAsync && iOpeningWaitDialog )
|
|
2819 |
{
|
|
2820 |
iOpeningWaitDialog->ProcessFinishedL();
|
|
2821 |
iOpeningWaitDialog = NULL;
|
|
2822 |
}
|
|
2823 |
}
|
|
2824 |
|
|
2825 |
// -----------------------------------------------------------------------------
|
|
2826 |
// CNcsComposeView::GenerateReplyMessageL
|
|
2827 |
// -----------------------------------------------------------------------------
|
|
2828 |
//
|
|
2829 |
void CNcsComposeView::GenerateReplyMessageL( TBool aReplyAll )
|
|
2830 |
{
|
|
2831 |
FUNC_LOG;
|
|
2832 |
|
|
2833 |
__ASSERT_DEBUG( iMailBox, Panic( ENcsBasicUi ) );
|
|
2834 |
|
|
2835 |
TReplyForwardParams params;
|
|
2836 |
params.iHeader = GenerateReplyHeaderLC();
|
|
2837 |
params.iSmartTag = GenerateSmartTagLC();
|
|
2838 |
TPckgBuf<TReplyForwardParams> buf( params );
|
|
2839 |
HBufC* temp = HBufC::NewLC( buf.Length() );
|
|
2840 |
temp->Des().Copy( buf );
|
|
2841 |
|
|
2842 |
//<cmail> this is actually a waited async method
|
|
2843 |
iFakeSyncGoingOn = ETrue;
|
|
2844 |
iNewMessage = iMailBox->CreateReplyMessage(
|
|
2845 |
iLaunchParams.iMsgId, aReplyAll, *temp );
|
|
2846 |
iFakeSyncGoingOn = EFalse;
|
|
2847 |
//</cmail>
|
|
2848 |
// Compose screen does not send cal messages, make sure
|
|
2849 |
// that cal event flag is not left active by some protocol
|
|
2850 |
if ( iNewMessage )
|
|
2851 |
{
|
|
2852 |
iNewMessage->ResetFlag( EFSMsgFlag_CalendarMsg );
|
|
2853 |
}
|
|
2854 |
CleanupStack::PopAndDestroy( temp );
|
|
2855 |
CleanupStack::PopAndDestroy( params.iSmartTag );
|
|
2856 |
CleanupStack::PopAndDestroy( params.iHeader );
|
|
2857 |
if ( !iNewMessage )
|
|
2858 |
{
|
|
2859 |
User::Leave( KErrGeneral );
|
|
2860 |
}
|
|
2861 |
iFakeSyncGoingOn = ETrue; //<cmail>
|
|
2862 |
TRAPD( error, TFsEmailUiUtility::MoveMessageToDraftsL(
|
|
2863 |
*iMailBox, *iNewMessage ) );
|
|
2864 |
iFakeSyncGoingOn = EFalse; //</cmail>
|
|
2865 |
User::LeaveIfError( error );
|
|
2866 |
|
|
2867 |
if ( iNewMessage->GetContentType() != KFSMailContentTypeMultipartMixed )
|
|
2868 |
{
|
|
2869 |
iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
|
|
2870 |
iNewMessage->SaveMessageL();
|
|
2871 |
iMessageModified = EFalse;
|
|
2872 |
}
|
|
2873 |
|
|
2874 |
TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart );
|
|
2875 |
}
|
|
2876 |
|
|
2877 |
// -----------------------------------------------------------------------------
|
|
2878 |
// CNcsComposeView::GenerateForwardMessageL
|
|
2879 |
// -----------------------------------------------------------------------------
|
|
2880 |
//
|
|
2881 |
void CNcsComposeView::GenerateForwardMessageL()
|
|
2882 |
{
|
|
2883 |
FUNC_LOG;
|
|
2884 |
|
|
2885 |
__ASSERT_DEBUG( iMailBox, Panic( ENcsBasicUi ) );
|
|
2886 |
|
|
2887 |
TReplyForwardParams params;
|
|
2888 |
params.iHeader = GenerateReplyHeaderLC();
|
|
2889 |
params.iSmartTag = GenerateSmartTagLC();
|
|
2890 |
TPckgBuf<TReplyForwardParams> buf( params );
|
|
2891 |
HBufC* temp = HBufC::NewLC( buf.Length() );
|
|
2892 |
temp->Des().Copy( buf );
|
|
2893 |
|
|
2894 |
//<cmail> this is actually a waited async call
|
|
2895 |
iFakeSyncGoingOn = ETrue;
|
|
2896 |
iNewMessage = iMailBox->CreateForwardMessage( iLaunchParams.iMsgId, *temp );
|
|
2897 |
iFakeSyncGoingOn = EFalse;
|
|
2898 |
//</cmail>
|
|
2899 |
// Compose screen does not send cal messages, make sure
|
|
2900 |
// that cal event flag is not left active by some protocol
|
|
2901 |
if ( iNewMessage )
|
|
2902 |
{
|
|
2903 |
iNewMessage->ResetFlag( EFSMsgFlag_CalendarMsg );
|
|
2904 |
}
|
|
2905 |
CleanupStack::PopAndDestroy( temp );
|
|
2906 |
CleanupStack::PopAndDestroy( params.iSmartTag );
|
|
2907 |
CleanupStack::PopAndDestroy( params.iHeader );
|
|
2908 |
if ( !iNewMessage )
|
|
2909 |
{
|
|
2910 |
User::Leave( KErrGeneral );
|
|
2911 |
}
|
|
2912 |
iFakeSyncGoingOn = ETrue; //<cmail>
|
|
2913 |
TRAPD( error, TFsEmailUiUtility::MoveMessageToDraftsL(
|
|
2914 |
*iMailBox, *iNewMessage ) );
|
|
2915 |
iFakeSyncGoingOn = EFalse; //<cmail>
|
|
2916 |
User::LeaveIfError( error );
|
|
2917 |
|
|
2918 |
if ( iNewMessage->GetContentType() != KFSMailContentTypeMultipartMixed )
|
|
2919 |
{
|
|
2920 |
iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
|
|
2921 |
iNewMessage->SaveMessageL();
|
|
2922 |
}
|
|
2923 |
|
|
2924 |
TFsEmailUiUtility::CreatePlainTextPartL(
|
|
2925 |
*iNewMessage, iNewMessageTextPart );
|
|
2926 |
|
|
2927 |
}
|
|
2928 |
|
|
2929 |
// -----------------------------------------------------------------------------
|
|
2930 |
// CNcsComposeView::InitReplyUiL
|
|
2931 |
// -----------------------------------------------------------------------------
|
|
2932 |
//
|
|
2933 |
void CNcsComposeView::InitReplyUiL( TBool aReplyAll )
|
|
2934 |
{
|
|
2935 |
FUNC_LOG;
|
|
2936 |
if ( iFirstStartCompleted ) // Safety check
|
|
2937 |
{
|
|
2938 |
InitReplyFieldsL( aReplyAll );
|
|
2939 |
// if flag is set -
|
|
2940 |
// message text will be included asynchronously by calling method
|
|
2941 |
// IncludeMessageTextAsyncL() at the end of view activation or when
|
|
2942 |
// all attachments are downloaded - this is done because formatting
|
|
2943 |
// text in CTextView with method FormatTextL() causes phone
|
|
2944 |
// irresponsive.
|
|
2945 |
if ( !iIncludeMessageTextAsync )
|
|
2946 |
{
|
|
2947 |
IncludeMessageTextL( ETrue );
|
|
2948 |
}
|
|
2949 |
iContainer->SetFocusToMessageFieldL();
|
|
2950 |
}
|
|
2951 |
}
|
|
2952 |
|
|
2953 |
// -----------------------------------------------------------------------------
|
|
2954 |
// CNcsComposeView::InitUiGeneralL
|
|
2955 |
// -----------------------------------------------------------------------------
|
|
2956 |
//
|
|
2957 |
void CNcsComposeView::InitUiGeneralL()
|
|
2958 |
{
|
|
2959 |
FUNC_LOG;
|
|
2960 |
if ( iFirstStartCompleted ) // Safety check
|
|
2961 |
{
|
|
2962 |
AppUi()->AddToStackL( iContainer );
|
|
2963 |
iContainer->SetMenuBar( Cba() );
|
|
2964 |
iContainer->UpdateScrollBar();
|
|
2965 |
|
|
2966 |
// Set title pane text
|
|
2967 |
const TDesC& mbName = iMailBox->GetName();
|
|
2968 |
iAppUi.SetTitlePaneTextL( mbName );
|
|
2969 |
|
|
2970 |
// Set priority flag
|
|
2971 |
SetPriority();
|
|
2972 |
|
|
2973 |
// Set follow-up flag
|
|
2974 |
SetFollowUp();
|
|
2975 |
}
|
|
2976 |
}
|
|
2977 |
|
|
2978 |
// -----------------------------------------------------------------------------
|
|
2979 |
// CNcsComposeView::InitForwardUiL
|
|
2980 |
// -----------------------------------------------------------------------------
|
|
2981 |
//
|
|
2982 |
void CNcsComposeView::InitForwardUiL()
|
|
2983 |
{
|
|
2984 |
FUNC_LOG;
|
|
2985 |
if ( iFirstStartCompleted ) // Safety check
|
|
2986 |
{
|
|
2987 |
InitForwardFieldsL();
|
|
2988 |
// if flag is set -
|
|
2989 |
// message text will be included asynchronously by calling method
|
|
2990 |
// IncludeMessageTextAsyncL() at the end of view activation or when
|
|
2991 |
// all attachments are downloaded - this is done because formatting
|
|
2992 |
// text in CTextView with method FormatTextL() causes phone
|
|
2993 |
// irresponsive.
|
|
2994 |
if ( !iIncludeMessageTextAsync )
|
|
2995 |
{
|
|
2996 |
IncludeMessageTextL( ETrue );
|
|
2997 |
}
|
|
2998 |
iContainer->SetFocusToToField();
|
|
2999 |
iContainer->SelectAllToFieldTextL();
|
|
3000 |
}
|
|
3001 |
}
|
|
3002 |
|
|
3003 |
// -----------------------------------------------------------------------------
|
|
3004 |
// CNcsComposeView::SetReplyForwardFlag
|
|
3005 |
// -----------------------------------------------------------------------------
|
|
3006 |
//
|
|
3007 |
void CNcsComposeView::SetReplyForwardFlagL()
|
|
3008 |
{
|
|
3009 |
FUNC_LOG;
|
|
3010 |
|
|
3011 |
if ( iFirstStartCompleted && iOrigMessage )
|
|
3012 |
{
|
|
3013 |
if ( iCustomMessageId == TUid::Uid( KEditorCmdReply ) ||
|
|
3014 |
iCustomMessageId == TUid::Uid( KEditorCmdReplyAll ) )
|
|
3015 |
{
|
|
3016 |
iOrigMessage->SetFlag( EFSMsgFlag_Answered );
|
|
3017 |
iOrigMessage->SaveMessageL();
|
|
3018 |
}
|
|
3019 |
else if ( iCustomMessageId == TUid::Uid( KEditorCmdForward ) )
|
|
3020 |
{
|
|
3021 |
iOrigMessage->SetFlag( EFSMsgFlag_Forwarded );
|
|
3022 |
iOrigMessage->SaveMessageL();
|
|
3023 |
}
|
|
3024 |
}
|
|
3025 |
|
|
3026 |
}
|
|
3027 |
|
|
3028 |
// -----------------------------------------------------------------------------
|
|
3029 |
// CNcsComposeView::MailBoxSupportsSmartReply
|
|
3030 |
// -----------------------------------------------------------------------------
|
|
3031 |
//
|
|
3032 |
TBool CNcsComposeView::MailBoxSupportsSmartReply()
|
|
3033 |
{
|
|
3034 |
FUNC_LOG;
|
|
3035 |
|
|
3036 |
__ASSERT_DEBUG( iMailBox, Panic( ENcsBasicUi ) );
|
|
3037 |
|
|
3038 |
return iMailBox->HasCapability( EFSMBoxCapaSmartReply );
|
|
3039 |
}
|
|
3040 |
|
|
3041 |
// -----------------------------------------------------------------------------
|
|
3042 |
// CNcsComposeView::MailBoxSupportsSmartForward
|
|
3043 |
// -----------------------------------------------------------------------------
|
|
3044 |
//
|
|
3045 |
TBool CNcsComposeView::MailBoxSupportsSmartForward()
|
|
3046 |
{
|
|
3047 |
FUNC_LOG;
|
|
3048 |
__ASSERT_DEBUG( iMailBox, Panic( ENcsBasicUi ) );
|
|
3049 |
|
|
3050 |
return iMailBox->HasCapability( EFSMBoxCapaSmartForward );
|
|
3051 |
}
|
|
3052 |
|
|
3053 |
// -----------------------------------------------------------------------------
|
|
3054 |
// CNcsComposeView::HasUnfetchedAttachmentsL
|
|
3055 |
// -----------------------------------------------------------------------------
|
|
3056 |
//
|
|
3057 |
TBool CNcsComposeView::HasUnfetchedAttachmentsL( CFSMailMessage& aMsg )
|
|
3058 |
{
|
|
3059 |
FUNC_LOG;
|
|
3060 |
|
|
3061 |
__ASSERT_DEBUG( &aMsg, Panic( ENcsBasicUi ) );
|
|
3062 |
|
|
3063 |
TBool ret = EFalse;
|
|
3064 |
|
|
3065 |
RPointerArray<CFSMailMessagePart> attachments;
|
|
3066 |
CleanupResetAndDestroyClosePushL( attachments );
|
|
3067 |
aMsg.AttachmentListL( attachments );
|
|
3068 |
for ( TInt i=0; i<attachments.Count(); i++ )
|
|
3069 |
{
|
|
3070 |
if ( EFSFull != attachments[i]->FetchLoadState() )
|
|
3071 |
{
|
|
3072 |
ret = ETrue;
|
|
3073 |
break;
|
|
3074 |
}
|
|
3075 |
}
|
|
3076 |
CleanupStack::PopAndDestroy( &attachments );
|
|
3077 |
|
|
3078 |
return ret;
|
|
3079 |
}
|
|
3080 |
|
|
3081 |
// -----------------------------------------------------------------------------
|
|
3082 |
// CNcsComposeView::HandleActionL
|
|
3083 |
// -----------------------------------------------------------------------------
|
|
3084 |
//
|
|
3085 |
void CNcsComposeView::HandleActionL( const TAlfActionCommand& aActionCommand )
|
|
3086 |
{
|
|
3087 |
FUNC_LOG;
|
|
3088 |
if ( iFirstStartCompleted && iNewMessage && iMailBox
|
|
3089 |
&& aActionCommand.Id() == KCmdEditorAutoSave )
|
|
3090 |
{
|
|
3091 |
CommitL( EFalse, EAllFields, ETrue );
|
|
3092 |
}
|
|
3093 |
}
|
|
3094 |
|
|
3095 |
// -----------------------------------------------------------------------------
|
|
3096 |
// CNcsComposeView::SaveToDraftsL
|
|
3097 |
// -----------------------------------------------------------------------------
|
|
3098 |
//
|
|
3099 |
void CNcsComposeView::SaveToDraftsL( TBool aParseAddresses )
|
|
3100 |
{
|
|
3101 |
FUNC_LOG;
|
|
3102 |
if ( iFirstStartCompleted ) // Safety
|
|
3103 |
{
|
|
3104 |
__ASSERT_DEBUG( iMailBox, Panic( ENcsBasicUi ) );
|
|
3105 |
__ASSERT_DEBUG( iNewMessage, Panic( ENcsBasicUi ) );
|
|
3106 |
|
|
3107 |
iFakeSyncGoingOn = ETrue;
|
|
3108 |
TRAPD( error, CommitL( aParseAddresses, EAllFields, ETrue, EFinal ) );
|
|
3109 |
iFakeSyncGoingOn = EFalse;
|
|
3110 |
User::LeaveIfError( error );
|
|
3111 |
|
|
3112 |
iFakeSyncGoingOn = ETrue;
|
|
3113 |
TRAP( error, TFsEmailUiUtility::MoveMessageToDraftsL(
|
|
3114 |
*iMailBox, *iNewMessage ) );
|
|
3115 |
iFakeSyncGoingOn = EFalse;
|
|
3116 |
User::LeaveIfError( error );
|
|
3117 |
|
|
3118 |
if ( !iAppUi.AppUiExitOngoing() )
|
|
3119 |
{
|
|
3120 |
// Simulate a new mail event to ensure that saved message becomes
|
|
3121 |
// visible in the mail list.
|
|
3122 |
// All protocols do not send event automatically in this case.
|
|
3123 |
RArray<TFSMailMsgId> messageIdArray;
|
|
3124 |
CleanupClosePushL( messageIdArray );
|
|
3125 |
messageIdArray.Append( iNewMessage->GetMessageId() );
|
|
3126 |
TFSMailMsgId folderId = iNewMessage->GetFolderId();
|
|
3127 |
TFSMailMsgId mailboxId = iNewMessage->GetMailBoxId();
|
|
3128 |
iAppUi.EventL(
|
|
3129 |
TFSEventNewMail, mailboxId, &messageIdArray, &folderId, NULL );
|
|
3130 |
// Update displayed mail info if the mail was created previously
|
|
3131 |
iAppUi.EventL(
|
|
3132 |
TFSEventMailChanged, mailboxId, &messageIdArray,
|
|
3133 |
&folderId, NULL );
|
|
3134 |
CleanupStack::PopAndDestroy( &messageIdArray );
|
|
3135 |
}
|
|
3136 |
}
|
|
3137 |
}
|
|
3138 |
|
|
3139 |
// -----------------------------------------------------------------------------
|
|
3140 |
// CNcsComposeView::FetchLogicComplete
|
|
3141 |
// -----------------------------------------------------------------------------
|
|
3142 |
//
|
|
3143 |
TBool CNcsComposeView::FetchLogicComplete(
|
|
3144 |
TComposerFetchState /*aState*/, TInt aError )
|
|
3145 |
{
|
|
3146 |
FUNC_LOG;
|
|
3147 |
TBool result = EFalse;
|
|
3148 |
if ( iFirstStartCompleted ) // Safety
|
|
3149 |
{
|
|
3150 |
if ( !aError )
|
|
3151 |
{
|
|
3152 |
TRAP( aError, InitReplyOrForwardUiL() );
|
|
3153 |
iAutoSaver->Enable( ETrue );
|
|
3154 |
}
|
|
3155 |
else
|
|
3156 |
{
|
|
3157 |
// something went wrong
|
|
3158 |
DoSafeExit( ENoSave );
|
|
3159 |
iMailFetchingErrCode = aError;
|
|
3160 |
result = ETrue;
|
|
3161 |
}
|
|
3162 |
}
|
|
3163 |
if ( iFetchWaitDialog && !iFetchDialogCancelled )
|
|
3164 |
{
|
|
3165 |
TRAP_IGNORE( iFetchWaitDialog->ProcessFinishedL() );
|
|
3166 |
iFetchWaitDialog = NULL;
|
|
3167 |
}
|
|
3168 |
|
|
3169 |
if ( iMailFetchingErrCode == KErrNone )
|
|
3170 |
{
|
|
3171 |
if ( iIncludeMessageTextAsync )
|
|
3172 |
{
|
|
3173 |
// in case the "Opening" wait note was closed by
|
|
3174 |
// wait note "Retrieving"
|
|
3175 |
if ( !iOpeningWaitDialog && iOpeningWaitNoteVisible )
|
|
3176 |
{
|
|
3177 |
TRAP_IGNORE( TFsEmailUiUtility::ShowWaitNoteL( iOpeningWaitDialog,
|
|
3178 |
R_FSE_WAIT_OPENING_TEXT, EFalse, ETrue ) );
|
|
3179 |
}
|
|
3180 |
}
|
|
3181 |
|
|
3182 |
if ( iViewFullyActivated && iIncludeMessageTextAsync )
|
|
3183 |
{
|
|
3184 |
// include message body in async way.
|
|
3185 |
// it is done here only if view was already activated
|
|
3186 |
// this mean that attachments were added in async way
|
|
3187 |
// and we couldn't start async including body text
|
|
3188 |
TRAP_IGNORE( IncludeMessageTextAsyncL( ETrue ) );
|
|
3189 |
}
|
|
3190 |
}
|
|
3191 |
return result;
|
|
3192 |
}
|
|
3193 |
|
|
3194 |
// -----------------------------------------------------------------------------
|
|
3195 |
// CNcsComposeView::ExitComposer
|
|
3196 |
// -----------------------------------------------------------------------------
|
|
3197 |
//
|
|
3198 |
void CNcsComposeView::ExitComposer()
|
|
3199 |
{
|
|
3200 |
FUNC_LOG;
|
|
3201 |
|
|
3202 |
if ( iStatusPaneIndicators )
|
|
3203 |
{
|
|
3204 |
iStatusPaneIndicators->HideStatusPaneIndicators();
|
|
3205 |
}
|
|
3206 |
|
|
3207 |
// lower flag to indicate that view is no longer
|
|
3208 |
// able to handle user commands
|
|
3209 |
iViewReady = EFalse;
|
|
3210 |
|
|
3211 |
// view switching and alfred operations should be avoided
|
|
3212 |
// when Appui exit has been initialised
|
|
3213 |
if ( !iAppUi.AppUiExitOngoing() )
|
|
3214 |
{
|
|
3215 |
// change to previous view
|
|
3216 |
TRAP_IGNORE( NavigateBackL() );
|
|
3217 |
}
|
|
3218 |
|
|
3219 |
// Cleanup message contents to prevent ChildDoDeactivate()
|
|
3220 |
// from saving the message to drafts again
|
|
3221 |
ResetComposer();
|
|
3222 |
|
|
3223 |
SafeDelete( iFetchLogic );
|
|
3224 |
}
|
|
3225 |
|
|
3226 |
// -----------------------------------------------------------------------------
|
|
3227 |
// CNcsComposeView::CreateContainerL
|
|
3228 |
// -----------------------------------------------------------------------------
|
|
3229 |
//
|
|
3230 |
void CNcsComposeView::CreateContainerL()
|
|
3231 |
{
|
|
3232 |
FUNC_LOG;
|
|
3233 |
TInt flags = NULL;
|
|
3234 |
if ( iCrHandler->EditorCCVisible() )
|
|
3235 |
{
|
|
3236 |
flags |= CNcsComposeViewContainer::ECcFieldVisible;
|
|
3237 |
}
|
|
3238 |
if ( iCrHandler->EditorBCVisible() )
|
|
3239 |
{
|
|
3240 |
flags |= CNcsComposeViewContainer::EBccFieldVisible;
|
|
3241 |
}
|
|
3242 |
TRect rect = ClientRect();
|
|
3243 |
iContainer = CNcsComposeViewContainer::NewL( *this, rect, *iMailBox,
|
|
3244 |
*iAutoSaver, flags );
|
|
3245 |
}
|
|
3246 |
|
|
3247 |
// -----------------------------------------------------------------------------
|
|
3248 |
// CNcsComposeView::ResetComposer
|
|
3249 |
// -----------------------------------------------------------------------------
|
|
3250 |
//
|
|
3251 |
void CNcsComposeView::ResetComposer()
|
|
3252 |
{
|
|
3253 |
FUNC_LOG;
|
|
3254 |
|
|
3255 |
delete iMailBox;
|
|
3256 |
iMailBox = NULL;
|
|
3257 |
delete iOrigMessage;
|
|
3258 |
iOrigMessage = NULL;
|
|
3259 |
delete iNewMessageTextPart;
|
|
3260 |
iNewMessageTextPart = NULL;
|
|
3261 |
delete iNewMessage;
|
|
3262 |
iNewMessage = NULL;
|
|
3263 |
iDlg = NULL;
|
|
3264 |
|
|
3265 |
if ( iContainer )
|
|
3266 |
{
|
|
3267 |
AppUi()->RemoveFromStack( iContainer );
|
|
3268 |
delete iContainer;
|
|
3269 |
iContainer = NULL;
|
|
3270 |
}
|
|
3271 |
|
|
3272 |
}
|
|
3273 |
|
|
3274 |
// -----------------------------------------------------------------------------
|
|
3275 |
// CNcsComposeView::SaveAndCleanPreviousMessage
|
|
3276 |
// -----------------------------------------------------------------------------
|
|
3277 |
//
|
|
3278 |
void CNcsComposeView::SaveAndCleanPreviousMessage()
|
|
3279 |
{
|
|
3280 |
FUNC_LOG;
|
|
3281 |
|
|
3282 |
if ( iFirstStartCompleted && iContainer && iNewMessage && iMailBox )
|
|
3283 |
{
|
|
3284 |
|
|
3285 |
TBool noAddrOrNoMesBody = iContainer->AreAddressFieldsEmpty() &&
|
|
3286 |
iContainer->IsSubjectFieldEmpty() &&
|
|
3287 |
(iContainer->GetMessageFieldLength() < 1);
|
|
3288 |
|
|
3289 |
// save to Drafts if there's some user input in some header field
|
|
3290 |
// or in message body
|
|
3291 |
if ( !noAddrOrNoMesBody )
|
|
3292 |
{
|
|
3293 |
TRAPD( error, DoSaveDraftL( EFalse ) );
|
|
3294 |
if ( error )
|
|
3295 |
{
|
|
3296 |
}
|
|
3297 |
}
|
|
3298 |
|
|
3299 |
// store the message IDs to launch parameters to be able to return
|
|
3300 |
// to same message if desired
|
|
3301 |
iLaunchParams.iMsgId = iNewMessage->GetMessageId();
|
|
3302 |
iLaunchParams.iFolderId = iNewMessage->GetFolderId();
|
|
3303 |
iLaunchParams.iMailboxId = iMailBox->GetId();
|
|
3304 |
}
|
|
3305 |
ResetComposer();
|
|
3306 |
}
|
|
3307 |
|
|
3308 |
// -----------------------------------------------------------------------------
|
|
3309 |
// CNcsComposeView::AsyncExit
|
|
3310 |
// -----------------------------------------------------------------------------
|
|
3311 |
//
|
|
3312 |
TInt CNcsComposeView::AsyncExit( TAny* aSelfPtr )
|
|
3313 |
{
|
|
3314 |
FUNC_LOG;
|
|
3315 |
CNcsComposeView* self =
|
|
3316 |
static_cast<CNcsComposeView*>( aSelfPtr );
|
|
3317 |
|
|
3318 |
TRAPD( err,self->AsyncExitL() );
|
|
3319 |
return err;
|
|
3320 |
}
|
|
3321 |
|
|
3322 |
// -----------------------------------------------------------------------------
|
|
3323 |
// CNcsComposeView::AsyncExitL
|
|
3324 |
// -----------------------------------------------------------------------------
|
|
3325 |
//
|
|
3326 |
void CNcsComposeView::AsyncExitL()
|
|
3327 |
{
|
|
3328 |
FUNC_LOG;
|
|
3329 |
if ( iFakeSyncGoingOn || iExecutingDoExitL )
|
|
3330 |
{
|
|
3331 |
// if some sync method is still going on, we continue waiting
|
|
3332 |
iActiveHelper->Cancel();
|
|
3333 |
iActiveHelper->Start();
|
|
3334 |
}
|
|
3335 |
else
|
|
3336 |
{
|
|
3337 |
ExitComposer();
|
|
3338 |
// for some strange reason composer view is stuck and only option
|
|
3339 |
// was to call ProcessCommandL with EAknCmdExit
|
|
3340 |
ProcessCommandL( EAknCmdExit );
|
|
3341 |
}
|
|
3342 |
}
|
|
3343 |
|
|
3344 |
// -----------------------------------------------------------------------------
|
|
3345 |
// CNcsComposeView::HandleContainerChangeRequiringToolbarRefresh
|
|
3346 |
// -----------------------------------------------------------------------------
|
|
3347 |
//
|
|
3348 |
void CNcsComposeView::HandleContainerChangeRequiringToolbarRefresh()
|
|
3349 |
{
|
|
3350 |
RefreshToolbar();
|
|
3351 |
}
|
|
3352 |
|
|
3353 |
// -----------------------------------------------------------------------------
|
|
3354 |
// CNcsComposeView::ShowFetchingWaitNoteL
|
|
3355 |
// -----------------------------------------------------------------------------
|
|
3356 |
//
|
|
3357 |
void CNcsComposeView::ShowFetchingWaitNoteL()
|
|
3358 |
{
|
|
3359 |
FUNC_LOG;
|
|
3360 |
if ( !iAppUi.AppUiExitOngoing() )
|
|
3361 |
{
|
|
3362 |
if ( !iFetchWaitDialog )
|
|
3363 |
{
|
|
3364 |
iFetchWaitDialog = new (ELeave) CAknWaitDialog(
|
|
3365 |
reinterpret_cast<CEikDialog**>( &iFetchWaitDialog ), EFalse);
|
|
3366 |
iFetchWaitDialog->SetCallback( this );
|
|
3367 |
iFetchDialogCancelled = EFalse;
|
|
3368 |
iFetchWaitDialog->ExecuteLD( R_FSE_FETCHING_WAIT_DIALOG );
|
|
3369 |
}
|
|
3370 |
}
|
|
3371 |
}
|
|
3372 |
|
|
3373 |
// -----------------------------------------------------------------------------
|
|
3374 |
// CNcsComposeView::DialogDismissedL
|
|
3375 |
// -----------------------------------------------------------------------------
|
|
3376 |
//
|
|
3377 |
void CNcsComposeView::DialogDismissedL( TInt aButtonId )
|
|
3378 |
{
|
|
3379 |
FUNC_LOG;
|
|
3380 |
if ( aButtonId == EAknSoftkeyCancel && iFetchLogic )
|
|
3381 |
{
|
|
3382 |
iFetchDialogCancelled = ETrue;
|
|
3383 |
iFetchLogic->CancelFetchings();
|
|
3384 |
}
|
|
3385 |
}
|
|
3386 |
|
|
3387 |
TBool CNcsComposeView::IsPreparedForExit()
|
|
3388 |
{
|
|
3389 |
return !( iFakeSyncGoingOn ||iExecutingDoExitL );
|
|
3390 |
}
|
|
3391 |
|
|
3392 |
// ---------------------------------------------------------------------------
|
|
3393 |
// Returns the speficied button from the toolbar extension, or NULL,
|
|
3394 |
// if the button is not found.
|
|
3395 |
// ---------------------------------------------------------------------------
|
|
3396 |
//
|
|
3397 |
CAknButton* CNcsComposeView::Button( TInt aCmdId,
|
|
3398 |
CAknToolbarExtension* aExtension )
|
|
3399 |
{
|
|
3400 |
CAknButton* button = NULL;
|
|
3401 |
|
|
3402 |
// Get toolbar extension.
|
|
3403 |
CAknToolbarExtension* extension = aExtension;
|
|
3404 |
if ( !aExtension )
|
|
3405 |
{
|
|
3406 |
CAknToolbar* toolbar = Toolbar();
|
|
3407 |
if ( toolbar )
|
|
3408 |
{
|
|
3409 |
extension = toolbar->ToolbarExtension();
|
|
3410 |
}
|
|
3411 |
}
|
|
3412 |
|
|
3413 |
// Get specified button from the extension.
|
|
3414 |
if ( extension )
|
|
3415 |
{
|
|
3416 |
button = static_cast<CAknButton*>( extension->ControlOrNull( aCmdId ) );
|
|
3417 |
}
|
|
3418 |
|
|
3419 |
return button;
|
|
3420 |
}
|
|
3421 |
|
|
3422 |
// ---------------------------------------------------------------------------
|
|
3423 |
// Returns ETrue if WLAN connection is active.
|
|
3424 |
// ---------------------------------------------------------------------------
|
|
3425 |
//
|
|
3426 |
TBool CNcsComposeView::WLANConnectionActive()
|
|
3427 |
{
|
|
3428 |
TBool ret = EFalse;
|
|
3429 |
|
|
3430 |
TInt wlanState;
|
|
3431 |
TInt err = RProperty::Get( KPSUidWlan, KPSWlanIndicator, wlanState );
|
|
3432 |
|
|
3433 |
if ( err == KErrNone )
|
|
3434 |
{
|
|
3435 |
if ( wlanState == EPSWlanIndicatorActive ||
|
|
3436 |
wlanState == EPSWlanIndicatorActiveSecure )
|
|
3437 |
{
|
|
3438 |
ret = ETrue;
|
|
3439 |
}
|
|
3440 |
}
|
|
3441 |
|
|
3442 |
return ret;
|
|
3443 |
}
|
|
3444 |
|
|
3445 |
|
|
3446 |
// ---------------------------------------------------------------------------
|
|
3447 |
// CActiveHelper::NewL()
|
|
3448 |
// ---------------------------------------------------------------------------
|
|
3449 |
//
|
|
3450 |
CActiveHelper* CActiveHelper::NewL( CNcsComposeView* aSession )
|
|
3451 |
{
|
|
3452 |
CActiveHelper* self = new(ELeave) CActiveHelper( aSession );
|
|
3453 |
CleanupStack::PushL( self );
|
|
3454 |
self->ConstructL( );
|
|
3455 |
CleanupStack::Pop( self );
|
|
3456 |
return self;
|
|
3457 |
}
|
|
3458 |
|
|
3459 |
// ---------------------------------------------------------------------------
|
|
3460 |
// CActiveHelper::~CActiveHelper()
|
|
3461 |
// ---------------------------------------------------------------------------
|
|
3462 |
//
|
|
3463 |
CActiveHelper::~CActiveHelper( )
|
|
3464 |
{
|
|
3465 |
Cancel();
|
|
3466 |
}
|
|
3467 |
|
|
3468 |
// ---------------------------------------------------------------------------
|
|
3469 |
// CActiveHelper::Start()
|
|
3470 |
// ---------------------------------------------------------------------------
|
|
3471 |
//
|
|
3472 |
void CActiveHelper::Start()
|
|
3473 |
{
|
|
3474 |
TRequestStatus* status = &iStatus;
|
|
3475 |
User::RequestComplete( status, KErrNone );
|
|
3476 |
SetActive();
|
|
3477 |
}
|
|
3478 |
|
|
3479 |
// ---------------------------------------------------------------------------
|
|
3480 |
// CActiveHelper::CActiveHelper()
|
|
3481 |
// ---------------------------------------------------------------------------
|
|
3482 |
//
|
|
3483 |
CActiveHelper::CActiveHelper( CNcsComposeView* aSession )
|
|
3484 |
: CActive( EPriorityLow )
|
|
3485 |
{
|
|
3486 |
iComposeView = aSession;
|
|
3487 |
}
|
|
3488 |
|
|
3489 |
// ---------------------------------------------------------------------------
|
|
3490 |
// CActiveHelper::RunL()
|
|
3491 |
// ---------------------------------------------------------------------------
|
|
3492 |
//
|
|
3493 |
void CActiveHelper::RunL()
|
|
3494 |
{
|
|
3495 |
if( iComposeView )
|
|
3496 |
iComposeView->AsyncExitL();
|
|
3497 |
}
|
|
3498 |
|
|
3499 |
// ---------------------------------------------------------------------------
|
|
3500 |
// CActiveHelper::DoCancel()
|
|
3501 |
// ---------------------------------------------------------------------------
|
|
3502 |
//
|
|
3503 |
void CActiveHelper::DoCancel()
|
|
3504 |
{
|
|
3505 |
// Empty
|
|
3506 |
}
|
|
3507 |
|
|
3508 |
// ---------------------------------------------------------------------------
|
|
3509 |
// CActiveHelper::ConstructL()
|
|
3510 |
// ---------------------------------------------------------------------------
|
|
3511 |
//
|
|
3512 |
void CActiveHelper::ConstructL()
|
|
3513 |
{
|
|
3514 |
CActiveScheduler::Add( this );
|
|
3515 |
}
|
|
3516 |
|