diff -r 000000000000 -r 72b543305e3a email/mail/EditorSrc/CMsgAddMailHeadersDlg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/email/mail/EditorSrc/CMsgAddMailHeadersDlg.cpp Thu Dec 17 08:44:11 2009 +0200 @@ -0,0 +1,195 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: View for setting additional mail headers +* +*/ + + + +// INCLUDE FILES +#include "CMsgAddMailHeadersDlg.h" +#include "MsgMailPreferences.h" +#include +#include +#include +#include +#include +#include "MailUtils.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CMsgAddMailHeadersDlg::CMsgAddMailHeadersDlg +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CMsgAddMailHeadersDlg::CMsgAddMailHeadersDlg( + RPointerArray& aHeaders): iHeaders(aHeaders) + { + } + +// ----------------------------------------------------------------------------- +// CMsgAddMailHeadersDlg::NewLC +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CMsgAddMailHeadersDlg* CMsgAddMailHeadersDlg::NewLC( + RPointerArray& aHeaders) + { + CMsgAddMailHeadersDlg* self = new(ELeave) CMsgAddMailHeadersDlg(aHeaders); + CleanupStack::PushL(self); + return self; + } + + +// Destructor +CMsgAddMailHeadersDlg::~CMsgAddMailHeadersDlg() + { + } + + +// ----------------------------------------------------------------------------- +// CMsgAddMailHeadersDlg::ExecuteDialogL +// Constructs a CSelectionList array and launches the setting view +// Collects the changed values to iHeaders array +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +TBool CMsgAddMailHeadersDlg::ExecuteDialogL() + { + TBool rc(EFalse); + + CArrayFixFlat* arrayChoices = + new(ELeave) CArrayFixFlat( iHeaders.Count() ); + CleanupStack::PushL(arrayChoices); + + CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(arrayChoices); + dlg->PrepareLC( R_ADDITIONAL_HEADERS_LIST_QUERY ); + + CDesCArrayFlat* headersArray = CreateItemTextArrayLC( arrayChoices ); + + dlg->SetItemTextArray( headersArray ); + dlg->SetOwnershipType( ELbmOwnsItemArray ); + CleanupStack::Pop( headersArray ); + + CEikListBox* listbox = dlg->ListBox(); + listbox->SetSelectionIndexesL(arrayChoices); + + if(dlg->RunLD()) + { + UpdateHeadersArrayL( arrayChoices ); + rc = ETrue; + } + + CleanupStack::PopAndDestroy(arrayChoices); + return rc; + } + +// ----------------------------------------------------------------------------- +// CMsgAddMailHeadersDlg::CreateItemTextArrayLC +// ----------------------------------------------------------------------------- +// +CDesCArrayFlat* CMsgAddMailHeadersDlg::CreateItemTextArrayLC( + CArrayFixFlat* aVisibleItems ) + { + ASSERT( aVisibleItems ); + CDesCArrayFlat* headersArray = + new ( ELeave ) CDesCArrayFlat( iHeaders.Count() ); + CleanupStack::PushL( headersArray ); + + for ( TInt index(0); indexiStatus == EHeaderVisible ) + { + aVisibleItems->AppendL( index ); + } + TInt resource(0); + switch (iHeaders[index]->iHeaderValue) + { + case EMsgComponentIdCc: + resource = R_QTN_MSG_HEADERS_CC; + break; + case EMsgComponentIdBcc: + resource = R_QTN_MSG_HEADERS_BCC; + break; + case EMsgComponentIdSubject: + resource = R_QTN_MSG_HEADERS_SUBJECT; + break; + default: + __ASSERT_DEBUG( EFalse, User::Invariant() ); + } + HBufC* headerText = StringLoader::LoadLC( resource ); + headersArray->AppendL( * headerText ); + CleanupStack::PopAndDestroy(headerText); // headerText + } + return headersArray; + } + +// ----------------------------------------------------------------------------- +// CMsgAddMailHeadersDlg::UpdateHeadersArrayL +// ----------------------------------------------------------------------------- +// +void CMsgAddMailHeadersDlg::UpdateHeadersArrayL( + CArrayFixFlat* aSelectedItems ) + { + ASSERT( aSelectedItems ); + // Reset visibility + for ( TInt index(0); indexiStatus = EHeaderHidden; + } + // Set selected items visible + for ( TInt ii=0; iiCount(); ii++ ) + { + iHeaders[aSelectedItems->At(ii)]->iStatus = EHeaderVisible; + } + // Find invisible items that has some content + TInt contentCount(0); + for ( TInt xx=0;xxiStatus == + EHeaderHidden && iHeaders[xx]->iHasContent ) + { + contentCount++; + } + } + // We are removing control that has some content + if( contentCount ) + { + // plural? + TUint queryString = (contentCount > 1) ? + R_QTN_MSG_QRY_HEADERS_REMOVE : + R_QTN_MSG_QRY_HEADER_REMOVE; + + TInt queryResult = MailUtils::ConfirmationQueryL( + queryString, + R_MAIL_EDITOR_DELETE_MESSAGE); + + // Do not remove control, only save visibility of controls + if( !queryResult ) + { + for ( TInt yy=0;yyiStatus == + EHeaderHidden && iHeaders[yy]->iHasContent ) + { + iHeaders[yy]->iStatus = EHeaderOnlySave; + } + } + } + } + + } +// End of File