79
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: MsgViewAttachmentsDialog implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// ========== INCLUDE FILES ================================
|
|
21 |
#include <msvapi.h>
|
|
22 |
#include <eikspane.h>
|
|
23 |
#include <eikmenup.h>
|
|
24 |
#include <AknDef.h>
|
|
25 |
#include <aknappui.h>
|
|
26 |
#include <akntitle.h>
|
|
27 |
#include <aknnavi.h>
|
|
28 |
#include <aknlists.h>
|
|
29 |
#include <gulicon.h>
|
|
30 |
#include <coeutils.h> // for ConeUtils::FileExists
|
|
31 |
#include <bautils.h>
|
|
32 |
#include <aknnotewrappers.h>
|
|
33 |
#include <AknWaitDialog.h> // CAknWaitDialog
|
|
34 |
#include <DocumentHandler.h>
|
|
35 |
#include <StringLoader.h> // StringLoader
|
|
36 |
#include <AiwCommon.h>
|
|
37 |
#include <NpdApi.h>
|
|
38 |
|
|
39 |
#include <mmsvattachmentmanager.h>
|
|
40 |
|
|
41 |
#include <avkon.hrh>
|
|
42 |
|
|
43 |
#include <aknlayout.cdl.h>
|
|
44 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
45 |
|
|
46 |
#include <AknUtils.h>
|
|
47 |
#include <AknsUtils.h> // skinned icons
|
|
48 |
#include <AknsConstants.h> // skinned icon ids
|
|
49 |
|
|
50 |
#include "MsgEditorCommon.h" // for KMsgEditorMbm
|
|
51 |
#include "MsgEditorDocument.h"
|
|
52 |
#include "MsgAttachmentInfo.h"
|
|
53 |
#include "MsgAttachmentModel.h"
|
|
54 |
#include "MsgViewAttachmentsDialog.h"
|
|
55 |
#include "MsgAttachmentUtils.h"
|
|
56 |
|
|
57 |
#include <msgeditor.mbg>
|
|
58 |
#include "MsgEditorAppUi.hrh"
|
|
59 |
#include <MsgEditorAppUi.rsg> // resouce identifiers
|
|
60 |
|
|
61 |
#include <aknlistloadertfx.h>
|
|
62 |
#include <aknlistboxtfxinternal.h>
|
|
63 |
|
|
64 |
// ========== EXTERNAL DATA STRUCTURES =====================
|
|
65 |
|
|
66 |
// ========== EXTERNAL FUNCTION PROTOTYPES =================
|
|
67 |
|
|
68 |
// ========== CONSTANTS ====================================
|
|
69 |
|
|
70 |
_LIT8( KTextDataType, "text/plain" );
|
|
71 |
const TUid KNotepadUID3 = { 0x1000599d };
|
|
72 |
|
|
73 |
// ========== MACROS =======================================
|
|
74 |
|
|
75 |
// ========== LOCAL CONSTANTS AND MACROS ===================
|
|
76 |
|
|
77 |
// ========== MODULE DATA STRUCTURES =======================
|
|
78 |
|
|
79 |
// ========== LOCAL FUNCTION PROTOTYPES ====================
|
|
80 |
|
|
81 |
// ========== LOCAL FUNCTIONS ==============================
|
|
82 |
|
|
83 |
// ========== MEMBER FUNCTIONS =============================
|
|
84 |
|
|
85 |
// ---------------------------------------------------------
|
|
86 |
// CMsgViewAttachmentsDialog::CMsgViewAttachmentsDialog
|
|
87 |
//
|
|
88 |
// Constructor.
|
|
89 |
// ---------------------------------------------------------
|
|
90 |
//
|
|
91 |
EXPORT_C CMsgViewAttachmentsDialog::CMsgViewAttachmentsDialog(
|
|
92 |
TDesC& aTitle, TInt aMenuId, CMsgAttachmentModel& aAttachmentModel )
|
|
93 |
: iAttachmentModel( aAttachmentModel ),
|
|
94 |
iNewTitle( aTitle ),
|
|
95 |
iMenuId( aMenuId )
|
|
96 |
{
|
|
97 |
}
|
|
98 |
|
|
99 |
// ---------------------------------------------------------
|
|
100 |
// CMsgViewAttachmentsDialog::~CMsgViewAttachmentsDialog
|
|
101 |
//
|
|
102 |
// Destructor.
|
|
103 |
// ---------------------------------------------------------
|
|
104 |
//
|
|
105 |
EXPORT_C CMsgViewAttachmentsDialog::~CMsgViewAttachmentsDialog()
|
|
106 |
{
|
|
107 |
delete iOldTitle;
|
|
108 |
|
|
109 |
// because it's not possible to set externally owned icon array
|
|
110 |
// for listbox, we delete our icon array here and set listbox
|
|
111 |
// icon array to NULL.
|
|
112 |
delete iIconArray;
|
|
113 |
if ( iListBox )
|
|
114 |
{
|
|
115 |
TRAP_IGNORE( iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( NULL ) );
|
|
116 |
}
|
|
117 |
|
|
118 |
delete iListItems;
|
|
119 |
delete iDocHandler;
|
|
120 |
|
|
121 |
// remove empty navi pane.
|
|
122 |
if ( iNaviPane )
|
|
123 |
{
|
|
124 |
iNaviPane->Pop();
|
|
125 |
}
|
|
126 |
delete iOpenParamList;
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------
|
|
130 |
// CMsgViewAttachmentsDialog::ConstructL
|
|
131 |
//
|
|
132 |
// 2nd phase constructor.
|
|
133 |
// ---------------------------------------------------------
|
|
134 |
//
|
|
135 |
EXPORT_C void CMsgViewAttachmentsDialog::ConstructL()
|
|
136 |
{
|
|
137 |
DoConstructL();
|
|
138 |
}
|
|
139 |
|
|
140 |
// ---------------------------------------------------------
|
|
141 |
// CMsgViewAttachmentsDialog::ConstructL
|
|
142 |
//
|
|
143 |
// 2nd phase constructor.
|
|
144 |
// ---------------------------------------------------------
|
|
145 |
//
|
|
146 |
EXPORT_C void CMsgViewAttachmentsDialog::ConstructL( CMsvEntry& aMessageEntry )
|
|
147 |
{
|
|
148 |
iMessageEntry = &aMessageEntry;
|
|
149 |
DoConstructL();
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
// CMsgViewAttachmentsDialog::DoConstructL
|
|
154 |
// ---------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CMsgViewAttachmentsDialog::DoConstructL()
|
|
157 |
{
|
|
158 |
CAknDialog::ConstructL( R_MEB_ATTACHMENTS_MENUBAR );
|
|
159 |
|
|
160 |
iDocHandler = CDocumentHandler::NewL( iEikonEnv->Process() );
|
|
161 |
|
|
162 |
// replace navi pane with empty one.
|
|
163 |
iNaviPane = static_cast<CAknNavigationControlContainer*>
|
|
164 |
( iEikonEnv->AppUiFactory()->StatusPane()->ControlL(
|
|
165 |
TUid::Uid( EEikStatusPaneUidNavi ) ) );
|
|
166 |
// CAknNavigationControlContainer internal array of decorators seem to
|
|
167 |
// have big enough granularity that it does not need realloc
|
|
168 |
// and therefore PushDefaultL does not leave.
|
|
169 |
iNaviPane->PushDefaultL();
|
|
170 |
|
|
171 |
iDocHandler->SetExitObserver( this );
|
|
172 |
}
|
|
173 |
|
|
174 |
// ---------------------------------------------------------
|
|
175 |
// CMsgViewAttachmentsDialog::CurrentListItemIndex
|
|
176 |
//
|
|
177 |
//
|
|
178 |
// ---------------------------------------------------------
|
|
179 |
//
|
|
180 |
EXPORT_C TInt CMsgViewAttachmentsDialog::CurrentListItemIndex()
|
|
181 |
{
|
|
182 |
return iListBox->CurrentItemIndex();
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------
|
|
186 |
// CMsgViewAttachmentsDialog::UpdateIcon
|
|
187 |
//
|
|
188 |
//
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
//
|
|
191 |
EXPORT_C void CMsgViewAttachmentsDialog::UpdateIcon( TInt aListIndex )
|
|
192 |
{
|
|
193 |
iListBox->DrawItem( aListIndex );
|
|
194 |
}
|
|
195 |
|
|
196 |
// ---------------------------------------------------------
|
|
197 |
// CMsgViewAttachmentsDialog::ProcessCommandL
|
|
198 |
//
|
|
199 |
//
|
|
200 |
// ---------------------------------------------------------
|
|
201 |
//
|
|
202 |
EXPORT_C void CMsgViewAttachmentsDialog::ProcessCommandL( TInt aCommandId )
|
|
203 |
{
|
|
204 |
HideMenu();
|
|
205 |
|
|
206 |
TFileName filename;
|
|
207 |
TInt index = iListBox->CurrentItemIndex();
|
|
208 |
|
|
209 |
switch ( aCommandId )
|
|
210 |
{
|
|
211 |
case EMsgViewAttachmentCmdOpen:
|
|
212 |
{
|
|
213 |
if ( iBusy )
|
|
214 |
{
|
|
215 |
return;
|
|
216 |
}
|
|
217 |
|
|
218 |
if ( index != KErrNotFound )
|
|
219 |
{
|
|
220 |
iBusy = ETrue;
|
|
221 |
CleanupStack::PushL( TCleanupItem( CleanupPointer, &iBusy ) );
|
|
222 |
CMsgAttachmentInfo& attInfo =
|
|
223 |
iAttachmentModel.AttachmentInfoAt( index );
|
|
224 |
|
|
225 |
TDataType datatype( attInfo.DataType() );
|
|
226 |
RFile file = iAttachmentModel.GetAttachmentFileL( index );
|
|
227 |
CleanupClosePushL( file );
|
|
228 |
|
|
229 |
TInt ret( KErrNone );
|
|
230 |
|
|
231 |
if ( datatype == KTextDataType() )
|
|
232 |
{
|
|
233 |
|
|
234 |
TInt charset( attInfo.CharacterSet() );
|
|
235 |
|
|
236 |
|
|
237 |
// file handle ownership transferred.
|
|
238 |
ret = CNotepadApi::ExecFileViewerL( file,
|
|
239 |
NULL,
|
|
240 |
ETrue,
|
|
241 |
charset != KErrNotFound ? EFalse : ETrue,
|
|
242 |
charset );
|
|
243 |
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
|
|
248 |
if ( iOpenParamList )
|
|
249 |
{
|
|
250 |
TRAP( ret,iDocHandler->OpenFileEmbeddedL( file, datatype, *iOpenParamList ) );
|
|
251 |
}
|
|
252 |
else
|
|
253 |
{
|
|
254 |
TRAP( ret,iDocHandler->OpenFileEmbeddedL( file, datatype ) );
|
|
255 |
}
|
|
256 |
|
|
257 |
}
|
|
258 |
// sets iBusy to EFalse.
|
|
259 |
CleanupStack::PopAndDestroy(2); // file , CleanupPointer
|
|
260 |
|
|
261 |
switch ( ret )
|
|
262 |
{
|
|
263 |
case KErrNone:
|
|
264 |
{
|
|
265 |
if (datatype != KTextDataType())
|
|
266 |
{
|
|
267 |
iBusy = ETrue;
|
|
268 |
}
|
|
269 |
|
|
270 |
}
|
|
271 |
case KUserCancel:
|
|
272 |
{
|
|
273 |
break;
|
|
274 |
}
|
|
275 |
case KErrNoMemory:
|
|
276 |
case KErrDiskFull:
|
|
277 |
{
|
|
278 |
User::Leave( ret );
|
|
279 |
}
|
|
280 |
default:
|
|
281 |
{
|
|
282 |
CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
|
|
283 |
HBufC* text = StringLoader::LoadLC( R_QTN_MMS_INFO_CANNOT_OPEN, iCoeEnv );
|
|
284 |
note->ExecuteLD( *text );
|
|
285 |
CleanupStack::PopAndDestroy(); // text
|
|
286 |
}
|
|
287 |
}
|
|
288 |
}
|
|
289 |
break;
|
|
290 |
}
|
|
291 |
case EMsgViewAttachmentCmdSave:
|
|
292 |
{
|
|
293 |
if ( index != KErrNotFound )
|
|
294 |
{
|
|
295 |
// Save to the default location of this type
|
|
296 |
TInt ret = KErrNone;
|
|
297 |
CMsgAttachmentInfo& attInfo = iAttachmentModel.AttachmentInfoAt( index );
|
|
298 |
TDataType datatype( attInfo.DataType() );
|
|
299 |
|
|
300 |
RFile file = iAttachmentModel.GetAttachmentFileL( index );
|
|
301 |
CleanupClosePushL( file );
|
|
302 |
|
|
303 |
if ( datatype == KTextDataType() )
|
|
304 |
{
|
|
305 |
ret = DoSaveTextFileL( file, attInfo.CharacterSet() );
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
TFileName dst;
|
|
310 |
User::LeaveIfError( file.Name( dst ) );
|
|
311 |
ret = iDocHandler->CopyL( file, dst, datatype, KEntryAttNormal );
|
|
312 |
}
|
|
313 |
|
|
314 |
CleanupStack::PopAndDestroy( &file );
|
|
315 |
|
|
316 |
if ( ret != KErrNone && ret != KUserCancel )
|
|
317 |
{
|
|
318 |
User::LeaveIfError( ret );
|
|
319 |
}
|
|
320 |
else if ( ret == KErrNone )
|
|
321 |
{
|
|
322 |
attInfo.SetSaved( ETrue );
|
|
323 |
}
|
|
324 |
}
|
|
325 |
break;
|
|
326 |
}
|
|
327 |
case EMsgViewAttachmentCmdRemove:
|
|
328 |
{
|
|
329 |
if ( index != KErrNotFound )
|
|
330 |
{
|
|
331 |
RemoveAttachmentL( index );
|
|
332 |
ItemRemovedL( index );
|
|
333 |
}
|
|
334 |
break;
|
|
335 |
}
|
|
336 |
case EMsgViewAttachmentCmdInsertImage:
|
|
337 |
{
|
|
338 |
if ( MsgAttachmentUtils::FetchFileL(
|
|
339 |
MsgAttachmentUtils::EImage, filename ) )
|
|
340 |
{
|
|
341 |
InsertAttachmentL( filename, aCommandId );
|
|
342 |
}
|
|
343 |
break;
|
|
344 |
}
|
|
345 |
case EMsgViewAttachmentCmdInsertAudio:
|
|
346 |
{
|
|
347 |
if ( MsgAttachmentUtils::FetchFileL(
|
|
348 |
MsgAttachmentUtils::EAudio, filename ) )
|
|
349 |
{
|
|
350 |
InsertAttachmentL( filename, aCommandId );
|
|
351 |
}
|
|
352 |
break;
|
|
353 |
}
|
|
354 |
case EMsgViewAttachmentCmdInsertVideo:
|
|
355 |
{
|
|
356 |
if ( MsgAttachmentUtils::FetchFileL(
|
|
357 |
MsgAttachmentUtils::EVideo, filename ) )
|
|
358 |
{
|
|
359 |
InsertAttachmentL( filename, aCommandId );
|
|
360 |
}
|
|
361 |
break;
|
|
362 |
}
|
|
363 |
case EMsgViewAttachmentCmdInsertNote:
|
|
364 |
{
|
|
365 |
if ( MsgAttachmentUtils::FetchFileL(
|
|
366 |
MsgAttachmentUtils::ENote, filename ) )
|
|
367 |
{
|
|
368 |
InsertAttachmentL( filename, aCommandId );
|
|
369 |
}
|
|
370 |
break;
|
|
371 |
}
|
|
372 |
case EAknCmdExit:
|
|
373 |
case EEikCmdExit:
|
|
374 |
{
|
|
375 |
static_cast<MEikCommandObserver*>( iEikonEnv->EikAppUi() )
|
|
376 |
->ProcessCommandL( EAknCmdExit );
|
|
377 |
break;
|
|
378 |
}
|
|
379 |
default:
|
|
380 |
{
|
|
381 |
break;
|
|
382 |
}
|
|
383 |
}
|
|
384 |
}
|
|
385 |
|
|
386 |
// ---------------------------------------------------------
|
|
387 |
// CMsgViewAttachmentsDialog::DynInitMenuPaneL
|
|
388 |
//
|
|
389 |
//
|
|
390 |
// ---------------------------------------------------------
|
|
391 |
//
|
|
392 |
EXPORT_C void CMsgViewAttachmentsDialog::DynInitMenuPaneL(
|
|
393 |
TInt aMenuId, CEikMenuPane* aMenuPane )
|
|
394 |
{
|
|
395 |
if ( aMenuId == R_MEB_ATTACHMENTS_MENUPANE )
|
|
396 |
{
|
|
397 |
// Add menu items from given menu.
|
|
398 |
aMenuPane->AddMenuItemsL( iMenuId, 0, ETrue );
|
|
399 |
// Delete our dummy first menu item.
|
|
400 |
aMenuPane->DeleteMenuItem( 0 );
|
|
401 |
}
|
|
402 |
}
|
|
403 |
|
|
404 |
// ---------------------------------------------------------
|
|
405 |
// CMsgViewAttachmentsDialog::HandleResourceChangeL
|
|
406 |
//
|
|
407 |
//
|
|
408 |
// ---------------------------------------------------------
|
|
409 |
//
|
|
410 |
EXPORT_C void CMsgViewAttachmentsDialog::HandleResourceChange(TInt aType)
|
|
411 |
{
|
|
412 |
if ( aType == KEikDynamicLayoutVariantSwitch ||
|
|
413 |
aType == KAknsMessageSkinChange )
|
|
414 |
{
|
|
415 |
TRAP_IGNORE( iAttachmentModel.LoadResourcesL() );
|
|
416 |
}
|
|
417 |
CEikDialog::HandleResourceChange( aType );
|
|
418 |
}
|
|
419 |
|
|
420 |
// ---------------------------------------------------------
|
|
421 |
// CMsgViewAttachmentsDialog::HandleServerAppExit
|
|
422 |
// ---------------------------------------------------------
|
|
423 |
//
|
|
424 |
EXPORT_C void CMsgViewAttachmentsDialog::HandleServerAppExit( TInt /*aReason*/)
|
|
425 |
{
|
|
426 |
// replace navi pane with empty one.
|
|
427 |
TRAP_IGNORE(iNaviPane->PushDefaultL());
|
|
428 |
iBusy = EFalse;
|
|
429 |
}
|
|
430 |
|
|
431 |
// ---------------------------------------------------------
|
|
432 |
// CMsgViewAttachmentsDialog::HandleControlStateChangeL
|
|
433 |
//
|
|
434 |
//
|
|
435 |
// ---------------------------------------------------------
|
|
436 |
//
|
|
437 |
EXPORT_C void CMsgViewAttachmentsDialog::HandleControlStateChangeL( TInt aControlId )
|
|
438 |
{
|
|
439 |
if ( aControlId == EMsgAttachmentListBoxId )
|
|
440 |
{
|
|
441 |
DoUpdateUiL();
|
|
442 |
}
|
|
443 |
|
|
444 |
CAknDialog::HandleControlStateChangeL( aControlId );
|
|
445 |
}
|
|
446 |
|
|
447 |
// ---------------------------------------------------------
|
|
448 |
// CMsgViewAttachmentsDialog::OkToExitL
|
|
449 |
//
|
|
450 |
//
|
|
451 |
// ---------------------------------------------------------
|
|
452 |
//
|
|
453 |
EXPORT_C TBool CMsgViewAttachmentsDialog::OkToExitL( TInt aButtonId )
|
|
454 |
{
|
|
455 |
if ( iBusy )
|
|
456 |
{
|
|
457 |
return EFalse;
|
|
458 |
}
|
|
459 |
|
|
460 |
if ( aButtonId == EAknSoftkeyBack )
|
|
461 |
{
|
|
462 |
iTitlePane->SetTextL( *iOldTitle );
|
|
463 |
}
|
|
464 |
else if ( aButtonId == EAknSoftkeyOpen )
|
|
465 |
{
|
|
466 |
if ( iAttachmentModel.NumberOfItems() != 0 &&
|
|
467 |
!iAttachmentModel.AttachmentInfoAt( CurrentListItemIndex() ).IsEmptyAttachment() )
|
|
468 |
{
|
|
469 |
ProcessCommandL( EMsgViewAttachmentCmdOpen );
|
|
470 |
}
|
|
471 |
|
|
472 |
return EFalse;
|
|
473 |
}
|
|
474 |
|
|
475 |
return CAknDialog::OkToExitL( aButtonId );
|
|
476 |
}
|
|
477 |
|
|
478 |
// ---------------------------------------------------------
|
|
479 |
// CMsgViewAttachmentsDialog::CreateCustomControlL
|
|
480 |
//
|
|
481 |
//
|
|
482 |
// ---------------------------------------------------------
|
|
483 |
//
|
|
484 |
EXPORT_C SEikControlInfo CMsgViewAttachmentsDialog::CreateCustomControlL( TInt aControlType )
|
|
485 |
{
|
|
486 |
SEikControlInfo controlInfo;
|
|
487 |
controlInfo.iControl = NULL;
|
|
488 |
controlInfo.iTrailerTextId = 0;
|
|
489 |
controlInfo.iFlags = 0;
|
|
490 |
|
|
491 |
if ( aControlType == EMsgAttachmentListBox )
|
|
492 |
{
|
|
493 |
controlInfo.iControl = new ( ELeave ) CMsgAttachmentsListBox( iAttachmentModel );
|
|
494 |
}
|
|
495 |
|
|
496 |
return controlInfo;
|
|
497 |
}
|
|
498 |
|
|
499 |
// ---------------------------------------------------------
|
|
500 |
// CMsgViewAttachmentsDialog::HandleListBoxEventL
|
|
501 |
//
|
|
502 |
//
|
|
503 |
// ---------------------------------------------------------
|
|
504 |
//
|
|
505 |
#ifdef RD_SCALABLE_UI_V2
|
|
506 |
EXPORT_C void CMsgViewAttachmentsDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/,
|
|
507 |
TListBoxEvent aEventType )
|
|
508 |
{
|
|
509 |
if ( aEventType == MEikListBoxObserver::EEventItemSingleClicked &&
|
|
510 |
!iAttachmentModel.AttachmentInfoAt( CurrentListItemIndex() ).IsEmptyAttachment() )
|
|
511 |
{
|
|
512 |
ProcessCommandL( EMsgViewAttachmentCmdOpen );
|
|
513 |
}
|
|
514 |
}
|
|
515 |
#else
|
|
516 |
EXPORT_C void CMsgViewAttachmentsDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/,
|
|
517 |
TListBoxEvent /*aEventType*/ )
|
|
518 |
{
|
|
519 |
}
|
|
520 |
#endif // RD_SCALABLE_UI_V2
|
|
521 |
// ---------------------------------------------------------
|
|
522 |
// CMsgViewAttachmentsDialog::PreLayoutDynInitL
|
|
523 |
//
|
|
524 |
//
|
|
525 |
// ---------------------------------------------------------
|
|
526 |
//
|
|
527 |
EXPORT_C void CMsgViewAttachmentsDialog::PreLayoutDynInitL()
|
|
528 |
{
|
|
529 |
CEikStatusPane *sp = static_cast<CAknAppUi*>
|
|
530 |
( iEikonEnv->EikAppUi() )->StatusPane();
|
|
531 |
iTitlePane = static_cast<CAknTitlePane*>
|
|
532 |
( sp->ControlL( TUid::Uid(EEikStatusPaneUidTitle ) ) );
|
|
533 |
|
|
534 |
const TDesC* title = iTitlePane->Text();
|
|
535 |
iOldTitle = title->AllocL();
|
|
536 |
|
|
537 |
iTitlePane->SetTextL( iNewTitle );
|
|
538 |
|
|
539 |
iListBox = static_cast<CMsgAttachmentsListBox*>
|
|
540 |
( Control( EMsgAttachmentListBoxId ) );
|
|
541 |
|
|
542 |
iListBox->CreateScrollBarFrameL( ETrue );
|
|
543 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
544 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
545 |
|
|
546 |
iListBox->SetListBoxObserver( this );
|
|
547 |
|
|
548 |
LoadFormDataL();
|
|
549 |
|
|
550 |
|
|
551 |
}
|
|
552 |
|
|
553 |
// ---------------------------------------------------------
|
|
554 |
// CMsgViewAttachmentsDialog::LoadFormDataL
|
|
555 |
//
|
|
556 |
//
|
|
557 |
// ---------------------------------------------------------
|
|
558 |
//
|
|
559 |
EXPORT_C void CMsgViewAttachmentsDialog::LoadFormDataL()
|
|
560 |
{
|
|
561 |
// iconarray for two icons.
|
|
562 |
// index 0: application icon.
|
|
563 |
// index 1: indicator.
|
|
564 |
iIconArray = new ( ELeave ) CArrayPtrFlat<CGulIcon>( 2 );
|
|
565 |
|
|
566 |
iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( iIconArray );
|
|
567 |
|
|
568 |
// list items is not actually an array but object that returns
|
|
569 |
// list item text for listbox in MdcaPoint method.
|
|
570 |
iListItems = CMsgAttaListItemArray::NewL( iAttachmentModel, iIconArray );
|
|
571 |
iListBox->Model()->SetItemTextArray( iListItems );
|
|
572 |
iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
573 |
}
|
|
574 |
|
|
575 |
// ---------------------------------------------------------
|
|
576 |
// CMsgViewAttachmentsDialog::ItemAddedL
|
|
577 |
//
|
|
578 |
//
|
|
579 |
// ---------------------------------------------------------
|
|
580 |
EXPORT_C void CMsgViewAttachmentsDialog::ItemAddedL( TInt aIndex )
|
|
581 |
{
|
|
582 |
iListBox->View()->CalcBottomItemIndex();
|
|
583 |
|
|
584 |
TInt itemIndex = aIndex;
|
|
585 |
|
|
586 |
if ( aIndex == -1 )
|
|
587 |
{
|
|
588 |
itemIndex = Max( iListBox->Model()->NumberOfItems() - 1, 0 );
|
|
589 |
}
|
|
590 |
|
|
591 |
iListBox->SetCurrentItemIndex( itemIndex );
|
|
592 |
|
|
593 |
if ( !iAttachmentModel.AttachmentInfoAt( itemIndex ).IsEmptyAttachment() )
|
|
594 |
{
|
|
595 |
if ( !ButtonGroupContainer().IsCommandVisible( EAknSoftkeyOpen ) )
|
|
596 |
{
|
|
597 |
// Set middle button visible if invisible and inserted attachment
|
|
598 |
// has content (i.e. it is not empty)
|
|
599 |
UpdateButtonVisiblity( EAknSoftkeyOpen, ETrue );
|
|
600 |
}
|
|
601 |
}
|
|
602 |
else
|
|
603 |
{
|
|
604 |
if ( ButtonGroupContainer().IsCommandVisible( EAknSoftkeyOpen ) )
|
|
605 |
{
|
|
606 |
// Set middle button invisible if visible and inserted attachment
|
|
607 |
// does not hava content (i.e. it is empty)
|
|
608 |
UpdateButtonVisiblity( EAknSoftkeyOpen, EFalse );
|
|
609 |
}
|
|
610 |
}
|
|
611 |
|
|
612 |
iListBox->HandleItemAdditionL();
|
|
613 |
}
|
|
614 |
|
|
615 |
// ---------------------------------------------------------
|
|
616 |
// CMsgViewAttachmentsDialog::ItemRemovedL
|
|
617 |
//
|
|
618 |
//
|
|
619 |
// ---------------------------------------------------------
|
|
620 |
EXPORT_C void CMsgViewAttachmentsDialog::ItemRemovedL( TInt aIndex )
|
|
621 |
{
|
|
622 |
iListBox->HandleItemRemovalL();
|
|
623 |
TInt lastItem = Max( iListBox->Model()->NumberOfItems() - 1, 0 );
|
|
624 |
|
|
625 |
if ( aIndex - 1 == lastItem )
|
|
626 |
{
|
|
627 |
TInt numItems = iListBox->View()->NumberOfItemsThatFitInRect(
|
|
628 |
iListBox->View()->ViewRect() );
|
|
629 |
TInt topItem = Max( lastItem - numItems, 0 );
|
|
630 |
iListBox->SetTopItemIndex( topItem );
|
|
631 |
}
|
|
632 |
|
|
633 |
iListBox->SetCurrentItemIndex( Min( aIndex, lastItem ) );
|
|
634 |
iListBox->DrawNow();
|
|
635 |
|
|
636 |
if ( iAttachmentModel.NumberOfItems() == 0 ||
|
|
637 |
iAttachmentModel.AttachmentInfoAt( CurrentListItemIndex() ).IsEmptyAttachment() )
|
|
638 |
{
|
|
639 |
UpdateButtonVisiblity( EAknSoftkeyOpen, EFalse );
|
|
640 |
}
|
|
641 |
}
|
|
642 |
|
|
643 |
// ---------------------------------------------------------
|
|
644 |
// CMsgViewAttachmentsDialog::InsertAttachmentL
|
|
645 |
//
|
|
646 |
//
|
|
647 |
// ---------------------------------------------------------
|
|
648 |
//
|
|
649 |
EXPORT_C void CMsgViewAttachmentsDialog::InsertAttachmentL(
|
|
650 |
const TFileName& aFileName,
|
|
651 |
TInt /*aCommandId*/,
|
|
652 |
TInt aIndex /*= -1*/ )
|
|
653 |
{
|
|
654 |
iBusy = ETrue;
|
|
655 |
// sets iBusy to EFalse on leave.
|
|
656 |
CleanupStack::PushL( TCleanupItem( CleanupPointer, &iBusy ) );
|
|
657 |
|
|
658 |
iWaitDialog = new ( ELeave ) CAknWaitDialog(
|
|
659 |
reinterpret_cast<CEikDialog**>( &iWaitDialog ),
|
|
660 |
ETrue );
|
|
661 |
CleanupStack::PushL( TCleanupItem( CleanupWaitDialog, (TAny**)&iWaitDialog ) );
|
|
662 |
|
|
663 |
iWaitDialog->PrepareLC( R_MEB_WAIT_NOTE );
|
|
664 |
|
|
665 |
HBufC* text = StringLoader::LoadLC( R_QTN_MAIL_WAIT_INSERT_ATTACHMENT );
|
|
666 |
iWaitDialog->SetTextL( *text );
|
|
667 |
CleanupStack::PopAndDestroy(); // text
|
|
668 |
|
|
669 |
iWaitDialog->RunLD();
|
|
670 |
|
|
671 |
// find file size
|
|
672 |
TInt filesize = 0;
|
|
673 |
RFile file;
|
|
674 |
RFs& fs = iEikonEnv->FsSession();
|
|
675 |
|
|
676 |
TInt err = file.Open( fs, aFileName, EFileShareAny );
|
|
677 |
if ( err == KErrAccessDenied || err == KErrInUse )
|
|
678 |
{
|
|
679 |
err = file.Open( fs, aFileName, EFileShareReadersOnly );
|
|
680 |
}
|
|
681 |
if ( err == KErrNone )
|
|
682 |
{
|
|
683 |
file.Size( filesize );
|
|
684 |
}
|
|
685 |
file.Close();
|
|
686 |
|
|
687 |
iAttachmentModel.AddAttachmentL( aFileName, filesize, 0, ETrue, aIndex );
|
|
688 |
|
|
689 |
ItemAddedL( aIndex );
|
|
690 |
|
|
691 |
// will delete iWaitDialog.
|
|
692 |
CleanupStack::PopAndDestroy(); // CleanupWaitDialog
|
|
693 |
|
|
694 |
// sets iBusy to EFalse.
|
|
695 |
CleanupStack::PopAndDestroy(); // CleanupPointer
|
|
696 |
}
|
|
697 |
|
|
698 |
// ---------------------------------------------------------
|
|
699 |
// CMsgViewAttachmentsDialog::RemoveAttachmentL
|
|
700 |
//
|
|
701 |
//
|
|
702 |
// ---------------------------------------------------------
|
|
703 |
//
|
|
704 |
EXPORT_C void CMsgViewAttachmentsDialog::RemoveAttachmentL( TInt aIndex )
|
|
705 |
{
|
|
706 |
// delete item from attachment model (notifies its observer about deletion).
|
|
707 |
iAttachmentModel.DeleteAttachment( aIndex );
|
|
708 |
}
|
|
709 |
|
|
710 |
// ---------------------------------------------------------
|
|
711 |
// CMsgViewAttachmentsDialog::CleanupPointer
|
|
712 |
//
|
|
713 |
//
|
|
714 |
// ---------------------------------------------------------
|
|
715 |
//
|
|
716 |
EXPORT_C void CMsgViewAttachmentsDialog::CleanupPointer( TAny* aItem )
|
|
717 |
{
|
|
718 |
TInt* item = static_cast<TInt*>( aItem );
|
|
719 |
*item = EFalse;
|
|
720 |
}
|
|
721 |
|
|
722 |
// ---------------------------------------------------------
|
|
723 |
// CMsgViewAttachmentsDialog::CleanupWaitDialog
|
|
724 |
//
|
|
725 |
//
|
|
726 |
// ---------------------------------------------------------
|
|
727 |
//
|
|
728 |
void CMsgViewAttachmentsDialog::CleanupWaitDialog( TAny* aAny )
|
|
729 |
{
|
|
730 |
CAknWaitDialog** dialog = (CAknWaitDialog**) aAny;
|
|
731 |
if ( dialog && *dialog )
|
|
732 |
{
|
|
733 |
delete *dialog;
|
|
734 |
}
|
|
735 |
}
|
|
736 |
|
|
737 |
// ---------------------------------------------------------
|
|
738 |
// CMsgViewAttachmentsDialog::SetOpenParamList
|
|
739 |
//
|
|
740 |
//
|
|
741 |
// ---------------------------------------------------------
|
|
742 |
//
|
|
743 |
EXPORT_C void CMsgViewAttachmentsDialog::SetOpenParamList(CAiwGenericParamList* aOpenParamList)
|
|
744 |
{
|
|
745 |
delete iOpenParamList;
|
|
746 |
iOpenParamList = aOpenParamList;
|
|
747 |
}
|
|
748 |
|
|
749 |
// ---------------------------------------------------------
|
|
750 |
// CMsgViewAttachmentsDialog::OpenParamList
|
|
751 |
//
|
|
752 |
//
|
|
753 |
// ---------------------------------------------------------
|
|
754 |
//
|
|
755 |
EXPORT_C CAiwGenericParamList* CMsgViewAttachmentsDialog::OpenParamList( )
|
|
756 |
{
|
|
757 |
return iOpenParamList;
|
|
758 |
}
|
|
759 |
|
|
760 |
// ---------------------------------------------------------
|
|
761 |
// CMsgViewAttachmentsDialog::DoSaveTextFileL
|
|
762 |
// ---------------------------------------------------------
|
|
763 |
//
|
|
764 |
TInt CMsgViewAttachmentsDialog::DoSaveTextFileL( RFile& aFile, TInt aCharSet )
|
|
765 |
{
|
|
766 |
TInt result( KErrNone );
|
|
767 |
|
|
768 |
if ( aCharSet == KErrNotFound )
|
|
769 |
{
|
|
770 |
TRAP( result, CNotepadApi::SaveFileAsMemoL( aFile ) );
|
|
771 |
}
|
|
772 |
else
|
|
773 |
{
|
|
774 |
TRAP( result, CNotepadApi::SaveFileAsMemoL( aFile,
|
|
775 |
aCharSet ) );
|
|
776 |
}
|
|
777 |
|
|
778 |
// Show confirmation note
|
|
779 |
RApaLsSession appList;
|
|
780 |
if ( result == KErrNone &&
|
|
781 |
appList.Connect() == KErrNone )
|
|
782 |
{
|
|
783 |
CleanupClosePushL( appList );
|
|
784 |
|
|
785 |
TApaAppInfo appInfo;
|
|
786 |
if ( appList.GetAppInfo( appInfo, KNotepadUID3 ) == KErrNone )
|
|
787 |
{
|
|
788 |
HBufC* text = StringLoader::LoadLC( R_MSG_FILE_SAVED_TO, appInfo.iCaption );
|
|
789 |
|
|
790 |
CAknConfirmationNote* note = new( ELeave ) CAknConfirmationNote( ETrue );
|
|
791 |
note->ExecuteLD( *text );
|
|
792 |
|
|
793 |
CleanupStack::PopAndDestroy( text );
|
|
794 |
}
|
|
795 |
|
|
796 |
CleanupStack::PopAndDestroy( &appList );
|
|
797 |
}
|
|
798 |
|
|
799 |
return result;
|
|
800 |
}
|
|
801 |
|
|
802 |
// ---------------------------------------------------------
|
|
803 |
// CMsgViewAttachmentsDialog::DoUpdateUiL
|
|
804 |
// ---------------------------------------------------------
|
|
805 |
//
|
|
806 |
void CMsgViewAttachmentsDialog::DoUpdateUiL()
|
|
807 |
{
|
|
808 |
if ( iAttachmentModel.NumberOfItems() == 0 ||
|
|
809 |
iAttachmentModel.AttachmentInfoAt( CurrentListItemIndex() ).IsEmptyAttachment() )
|
|
810 |
{
|
|
811 |
UpdateButtonVisiblity( EAknSoftkeyOpen, EFalse );
|
|
812 |
}
|
|
813 |
else
|
|
814 |
{
|
|
815 |
UpdateButtonVisiblity( EAknSoftkeyOpen, ETrue );
|
|
816 |
}
|
|
817 |
}
|
|
818 |
|
|
819 |
// ---------------------------------------------------------
|
|
820 |
// CMsgViewAttachmentsDialog::UpdateButtonVisiblity
|
|
821 |
// ---------------------------------------------------------
|
|
822 |
//
|
|
823 |
void CMsgViewAttachmentsDialog::UpdateButtonVisiblity( TInt aCommandId, TBool aValue )
|
|
824 |
{
|
|
825 |
if ( ButtonGroupContainer().ControlOrNull( aCommandId ) )
|
|
826 |
{
|
|
827 |
ButtonGroupContainer().MakeCommandVisible( aCommandId, aValue );
|
|
828 |
}
|
|
829 |
}
|
|
830 |
|
|
831 |
// End of File
|