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