messagingappbase/msgeditor/appuisrc/MsgAttaListItemArray.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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:  MsgAttaListItemArray 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 #include "MsgAttaListItemArray.h"
       
    57 
       
    58 #include <msgeditor.mbg>
       
    59 #include "MsgEditorAppUi.hrh"
       
    60 #include <MsgEditorAppUi.rsg>       // resouce identifiers
       
    61 
       
    62 #include <aknlistloadertfx.h>
       
    63 #include <aknlistboxtfxinternal.h>
       
    64 
       
    65 // ========== EXTERNAL DATA STRUCTURES =====================
       
    66 
       
    67 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    68 
       
    69 // ========== CONSTANTS ====================================
       
    70 
       
    71 _LIT( KStripList, "\x000A\x000D\x2029\x2028\x0085" );
       
    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 // CMsgAttaListItemArray::NewL
       
    87 //
       
    88 //
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 EXPORT_C CMsgAttaListItemArray* CMsgAttaListItemArray::NewL(
       
    92     CMsgAttachmentModel& aAttachmentModel,
       
    93     CArrayPtr<CGulIcon>* aIconArray )
       
    94     {
       
    95     CMsgAttaListItemArray* self = new ( ELeave ) CMsgAttaListItemArray(
       
    96         aAttachmentModel,
       
    97         aIconArray );
       
    98 
       
    99     CleanupStack::PushL( self );
       
   100     self->ConstructL();
       
   101     CleanupStack::Pop(); // self
       
   102 
       
   103     return self;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CMsgAttaListItemArray::~CMsgAttaListItemArray
       
   108 //
       
   109 //
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 EXPORT_C CMsgAttaListItemArray::~CMsgAttaListItemArray()
       
   113     {
       
   114     delete iListItemText;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------
       
   118 // CMsgAttaListItemArray::ConstructL
       
   119 //
       
   120 //
       
   121 // ---------------------------------------------------------
       
   122 //
       
   123 EXPORT_C void CMsgAttaListItemArray::ConstructL()
       
   124     {
       
   125     iListItemText = new ( ELeave ) TBuf<KMsgAttaItemTextLength>;
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // CMsgAttaListItemArray::MdcaCount
       
   130 //
       
   131 //
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 EXPORT_C TInt CMsgAttaListItemArray::MdcaCount() const
       
   135     {
       
   136     return iAttachmentModel.NumberOfItems();
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 // CMsgAttaListItemArray::MdcaPoint
       
   141 //
       
   142 //
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 TPtrC CMsgAttaListItemArray::MdcaPoint(TInt aIndex) const
       
   146     {
       
   147     CMsgAttachmentInfo& attInfo = iAttachmentModel.AttachmentInfoAt( aIndex );
       
   148 
       
   149     // if application icon has been inserted previously, delete it from index 0
       
   150     // and insert new app icon to index 0.
       
   151     iIconArray->Reset();
       
   152     TRAP_IGNORE( iIconArray->AppendL( attInfo.Icon() ) );
       
   153 
       
   154     // then get the file name from atta info full path name.
       
   155     TParsePtrC parser( attInfo.FileName() );
       
   156     TFileName filename( parser.NameAndExt() );
       
   157     
       
   158     HBufC* convertedFilename = NULL;
       
   159     
       
   160     if ( filename.Length() == 0 )
       
   161         {
       
   162         CEikonEnv::Static()->ReadResource( filename, R_QTN_MMS_NO_NAME_FOR_FILE );
       
   163         }
       
   164     else
       
   165         {
       
   166         TRAP_IGNORE( convertedFilename = AknTextUtils::ConvertFileNameL( filename ) );
       
   167         
       
   168         TPtr convertedFileNamePtr = convertedFilename->Des();
       
   169         AknTextUtils::StripCharacters( convertedFileNamePtr, KStripList );
       
   170         }
       
   171         
       
   172     // generate item text for list item by combining
       
   173     // icon index (always zero), file name and file size.
       
   174     iListItemText->Zero();
       
   175 
       
   176     iListItemText->AppendNum( 0 );
       
   177     iListItemText->Append( KColumnListSeparator );
       
   178     
       
   179     if ( convertedFilename )
       
   180         {
       
   181         iListItemText->Append( *convertedFilename );
       
   182         delete convertedFilename;
       
   183         }
       
   184     else
       
   185         {
       
   186         iListItemText->Append( filename );
       
   187         }
       
   188     
       
   189     iListItemText->Append( KColumnListSeparator );
       
   190     iListItemText->Append( attInfo.SizeString() );
       
   191 
       
   192     return *iListItemText;
       
   193     }
       
   194 
       
   195 // ---------------------------------------------------------
       
   196 // CMsgAttaListItemArray::CMsgAttaListItemArray
       
   197 //
       
   198 //
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 EXPORT_C CMsgAttaListItemArray::CMsgAttaListItemArray(
       
   202     CMsgAttachmentModel& aAttachmentModel,
       
   203     CArrayPtr<CGulIcon>* aIconArray )
       
   204     : iAttachmentModel( aAttachmentModel ),
       
   205       iIconArray( aIconArray )
       
   206     {
       
   207     }
       
   208 
       
   209 // End of File