messagingappbase/mce/src/MceDeliveryReportControlContainer.cpp
changeset 0 72b543305e3a
child 1 d09ac5c1e252
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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:  
       
    15 *     Mce delivery report view container control class implementation.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <aknnotedialog.h>      // Popup note
       
    23 #include <mce.rsg>
       
    24 #include <AknsUtils.h>
       
    25 
       
    26 #include "MceDeliveryReportControlContainer.h"
       
    27 #include "MceDeliveryReportAdapter.h"
       
    28 #include "MceLogEngine.h"
       
    29 #include "mceui.h"
       
    30 #include "MceCommands.hrh"       // UID enumeration.
       
    31 
       
    32 #include <bldvariant.hrh>
       
    33 
       
    34 #include <csxhelp/mce.hlp.hrh>
       
    35 #include "MceIds.h"
       
    36 
       
    37 #include <muiu.mbg>
       
    38 #include <akncontext.h>
       
    39 
       
    40 // security data caging
       
    41 #include <data_caging_path_literals.hrh>
       
    42 
       
    43 #include <centralrepository.h>
       
    44 #include <LogsDomainCRKeys.h>
       
    45 
       
    46 #include "MceSessionHolder.h"
       
    47 
       
    48 // CONSTANTS
       
    49 
       
    50 _LIT( KMceDirAndFileMuiu,"muiu.mbm" );
       
    51 
       
    52 // LOCAL CONSTANTS AND MACROS
       
    53 
       
    54 #ifdef _DEBUG
       
    55 _LIT( KPanicText, "Mce" );
       
    56 const TInt KCRepositorySettingFailure = 1;
       
    57 #endif
       
    58 
       
    59 #ifdef RD_MULTIPLE_DRIVE
       
    60 #include <driveinfo.h>
       
    61 #endif
       
    62 
       
    63 
       
    64 // ================= MEMBER FUNCTIONS =======================
       
    65 
       
    66 CMceDeliveryReportControlContainer* CMceDeliveryReportControlContainer::NewL(
       
    67     CMceDeliveryReportView* aMceDeliveryReportView,
       
    68     CMceSessionHolder& aSessionHolder, const TRect& aRect )
       
    69     {
       
    70     CMceDeliveryReportControlContainer* self = new( ELeave )
       
    71                     CMceDeliveryReportControlContainer( aMceDeliveryReportView,
       
    72                     									aSessionHolder );
       
    73     self->SetMopParent( aMceDeliveryReportView );
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL( aRect );
       
    76     CleanupStack::Pop( self );
       
    77     return self;
       
    78     }
       
    79 
       
    80 CMceDeliveryReportControlContainer::CMceDeliveryReportControlContainer(
       
    81     CMceDeliveryReportView* aMceDeliveryReportView,
       
    82     CMceSessionHolder& aSessionHolder ) : iSessionHolder(aSessionHolder)
       
    83     {
       
    84     iMceDeliveryReportView = aMceDeliveryReportView;
       
    85     iSessionHolder.AddClient();
       
    86     }
       
    87 
       
    88 
       
    89 void CMceDeliveryReportControlContainer::ConstructL( const TRect& aRect )
       
    90     {
       
    91     // security data caging
       
    92     TParse fp;
       
    93    
       
    94     fp.Set( KMceDirAndFileMuiu, &KDC_APP_BITMAP_DIR , NULL );
       
    95     iFilenameMuiu = fp.FullName();
       
    96 
       
    97     /// Register for model observervation.
       
    98     iMceDeliveryReportView->MceAppUi()->LogEngine()->SetContainerObserver( this );
       
    99 
       
   100     CreateWindowL();
       
   101 
       
   102     iListBox = new( ELeave ) CAknDoubleGraphicStyleListBox;
       
   103     iListBox->SetContainerWindowL( *this );
       
   104     iListBox->ConstructL( this, EAknListBoxSelectionList );
       
   105 
       
   106     CMceDeliveryReportAdapter* adapter = CMceDeliveryReportAdapter::NewL(
       
   107                     iMceDeliveryReportView->MceAppUi()->LogEngine(), iListBox );
       
   108     iListBox->Model()->SetItemTextArray( adapter );
       
   109     iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
       
   110 
       
   111     // Load icons.
       
   112     CAknIconArray* icons = new( ELeave ) CAknIconArray( 2 );
       
   113     CleanupStack::PushL( icons );
       
   114 
       
   115      // First icon & mask.   
       
   116     AddIconL( KAknsIIDQgnPropMceSmsInfo, icons, iFilenameMuiu, EMbmMuiuQgn_prop_mce_sms_info,
       
   117               EMbmMuiuQgn_prop_mce_sms_info_mask );
       
   118     // Second icon & mask.
       
   119     AddIconL( KAknsIIDQgnPropMceMmsInfo, icons, iFilenameMuiu, EMbmMuiuQgn_prop_mce_mms_info,
       
   120               EMbmMuiuQgn_prop_mce_mms_info_mask );
       
   121 
       
   122     iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
       
   123     CleanupStack::Pop( icons );
       
   124 
       
   125     /// Check if Logs application has stopped logging?
       
   126 
       
   127 
       
   128     MakeEmptyTextListBoxL( iListBox, R_MCE_DELIVERY_REPORT_NO_LOG_LBX_TEXT );
       
   129 
       
   130     CEikScrollBarFrame* sBFrame = iListBox->CreateScrollBarFrameL(ETrue);
       
   131     sBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
       
   132 
       
   133     SetRect( aRect );
       
   134     // Activate the control and all subcontrols
       
   135     ActivateL();
       
   136     }
       
   137 
       
   138 
       
   139 CMceDeliveryReportControlContainer::~CMceDeliveryReportControlContainer()
       
   140     {
       
   141     /// Stop observing LogEngine.
       
   142     if( iMceDeliveryReportView )
       
   143         {
       
   144         iMceDeliveryReportView->MceAppUi()->LogEngine()
       
   145             ->RemoveContainerObserver();
       
   146         }
       
   147 
       
   148     /// Destroy the list box control
       
   149     delete iListBox;
       
   150     iSessionHolder.RemoveClient();
       
   151     }
       
   152 
       
   153 TKeyResponse CMceDeliveryReportControlContainer::OfferKeyEventL(
       
   154                             const TKeyEvent& aKeyEvent, TEventCode aType )
       
   155     {
       
   156     if( aType == EEventKey )
       
   157         {
       
   158         if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow )
       
   159             {
       
   160             // needed for tab changing, should be left to MCE UI to handle these
       
   161             return EKeyWasNotConsumed;
       
   162             }
       
   163 
       
   164         if( aKeyEvent.iCode == EKeyPhoneSend )
       
   165             {
       
   166             if( iMceDeliveryReportView->MceAppUi()->
       
   167                         LogEngine()->IsNumberAvailable( iListBox->CurrentItemIndex() ) )
       
   168                 {
       
   169                 iMceDeliveryReportView->HandleCommandL( EMceCmdCall );
       
   170                 }
       
   171             return EKeyWasConsumed;
       
   172             }
       
   173         if( aKeyEvent.iCode == EKeyOK ||  aKeyEvent.iCode == EKeyEnter )
       
   174             {
       
   175             if( iMceDeliveryReportView->MceAppUi()->
       
   176                         LogEngine()->IsNumberAvailable( iListBox->CurrentItemIndex() ) )
       
   177                 {
       
   178                 iMceDeliveryReportView->LaunchPopupMenuL( R_MCE_DELIVERY_REPORT_OK_MENUBAR );
       
   179                 }
       
   180             return EKeyWasConsumed;
       
   181             }
       
   182         }
       
   183     if( aType == EEventKeyUp )
       
   184 		{
       
   185 		iMceDeliveryReportView->SetMSKButtonL();
       
   186 		}
       
   187         
       
   188     return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   189     }
       
   190 
       
   191 TInt CMceDeliveryReportControlContainer::CountComponentControls() const
       
   192     {
       
   193     return 1;
       
   194     }
       
   195 
       
   196 CCoeControl* CMceDeliveryReportControlContainer::ComponentControl(
       
   197     TInt /*aIndex*/ ) const
       
   198     {
       
   199     return iListBox;
       
   200     }
       
   201 
       
   202 void CMceDeliveryReportControlContainer::SizeChanged()
       
   203     {
       
   204     if( iListBox )
       
   205         {
       
   206         iListBox->SetRect( Rect() );
       
   207         }
       
   208     }
       
   209 
       
   210 
       
   211 CAknDoubleGraphicStyleListBox* CMceDeliveryReportControlContainer::ListBox() const
       
   212     {
       
   213     return iListBox;
       
   214     }
       
   215 
       
   216 
       
   217 void CMceDeliveryReportControlContainer::PopUpNoteL()
       
   218     {
       
   219     CAknNoteDialog* noteDlg = new(ELeave) CAknNoteDialog(
       
   220                             CAknNoteDialog::ENoTone,
       
   221                             CAknNoteDialog::ELongTimeout );
       
   222     noteDlg->ExecuteLD( R_MCE_DR_NO_LOG_NOTE );
       
   223     }
       
   224 
       
   225 
       
   226 void CMceDeliveryReportControlContainer::MceLogEngineListBoxStateHasChangedL()
       
   227     {
       
   228     iListBox->HandleItemAdditionL();
       
   229     iMceDeliveryReportView->SetMSKButtonL();
       
   230     }
       
   231 
       
   232 
       
   233 void CMceDeliveryReportControlContainer::HandleControlEventL
       
   234         ( CCoeControl* /*aControl*/,
       
   235           TCoeEvent /*aEventType*/ )
       
   236     {
       
   237     }
       
   238 
       
   239 void CMceDeliveryReportControlContainer::Draw( const TRect& /*aRect*/ ) const
       
   240     {
       
   241     }
       
   242 
       
   243 void CMceDeliveryReportControlContainer::AddIconL(
       
   244     TAknsItemID aId,
       
   245     CAknIconArray* aIcons,
       
   246     const TDesC& aIconFileWithPath,
       
   247     TInt aIconGraphicsIndex,
       
   248     TInt aIconGraphicsMaskIndex )
       
   249     {    
       
   250     // icon & mask.   
       
   251 
       
   252     MAknsSkinInstance* skins = AknsUtils::SkinInstance();  
       
   253     CFbsBitmap* bitmap;
       
   254     CFbsBitmap* mask;
       
   255     AknsUtils::CreateIconL( skins, aId, bitmap,
       
   256         mask, aIconFileWithPath, aIconGraphicsIndex, 
       
   257         aIconGraphicsMaskIndex );
       
   258     // Append it to icons array
       
   259     CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   260     CleanupStack::PushL( icon );
       
   261     aIcons->AppendL( icon );    
       
   262     CleanupStack::Pop( icon );
       
   263     }
       
   264 
       
   265 
       
   266 TInt CMceDeliveryReportControlContainer::LogDisabledL()
       
   267     {
       
   268     TInt getValue( 1 );
       
   269 
       
   270     CRepository* repository = NULL;
       
   271     TRAPD( ret, repository = CRepository::NewL(KCRUidLogs) );
       
   272     CleanupStack::PushL( repository );
       
   273 
       
   274     if ( ret == KErrNone )
       
   275         {
       
   276         TInt ret = repository->Get( KLogsLoggingEnabled, getValue );
       
   277         __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );
       
   278         }
       
   279 
       
   280     CleanupStack::Pop( repository );
       
   281     delete repository;
       
   282 
       
   283     return getValue;
       
   284     }
       
   285 
       
   286 void CMceDeliveryReportControlContainer::MakeEmptyTextListBoxL(
       
   287           CEikFormattedCellListBoxTypedef* aListBox,
       
   288           TInt aResourceText )
       
   289     {
       
   290     HBufC* textFromResourceFile = iCoeEnv->AllocReadResourceLC( aResourceText );
       
   291     // Set the view's listbox empty text.
       
   292     aListBox->View()->SetListEmptyTextL( *textFromResourceFile );
       
   293     CleanupStack::PopAndDestroy();  // textFromResourceFile.
       
   294     }
       
   295 
       
   296 // ----------------------------------------------------
       
   297 // CMceDeliveryReportControlContainer::GetHelpContext
       
   298 // returns helpcontext as aContext
       
   299 //
       
   300 // ----------------------------------------------------
       
   301 void CMceDeliveryReportControlContainer::GetHelpContext
       
   302         (TCoeHelpContext& aContext) const
       
   303     {
       
   304     aContext.iMajor = KMceApplicationUid;
       
   305     aContext.iContext = KMCE_HLP_DELIVERY_REPORTS;
       
   306 
       
   307     }
       
   308 
       
   309 // ----------------------------------------------------
       
   310 // CMceListContainer::HandleResourceChange
       
   311 // ----------------------------------------------------
       
   312 void CMceDeliveryReportControlContainer::HandleResourceChange( TInt aType )
       
   313     {   
       
   314     CCoeControl::HandleResourceChange( aType );
       
   315     if( aType == KAknsMessageSkinChange )
       
   316         {
       
   317         // change skin bitmap
       
   318         TRAP_IGNORE( SkinBitmapChangesL( ) );        
       
   319         }    
       
   320     }
       
   321 
       
   322 // ----------------------------------------------------
       
   323 // CMceListContainer::SkinBitmapChangesL
       
   324 // ----------------------------------------------------
       
   325 void CMceDeliveryReportControlContainer::SkinBitmapChangesL( )
       
   326     {    
       
   327     //first change application icon
       
   328     
       
   329     CEikStatusPane *sp = ( (CAknAppUi*)CEikonEnv::Static()->EikAppUi() )->StatusPane();
       
   330     CAknContextPane* contextPane = (CAknContextPane *)sp->ControlL( TUid::Uid(EEikStatusPaneUidContext) );
       
   331     
       
   332     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
       
   333     CFbsBitmap* appBitmap;
       
   334     CFbsBitmap* appBitmapMask;
       
   335     
       
   336 #ifdef RD_MULTIPLE_DRIVE
       
   337     TInt phoneDrive;
       
   338     // At this point, try avoid using any predefined numbers E.G. EDriveC
       
   339     // in order to increase the safety and code flexibility
       
   340     User::LeaveIfError( DriveInfo::GetDefaultDrive( DriveInfo:: EDefaultPhoneMemory, phoneDrive ) );
       
   341     TInt currentDrive = TInt( iSessionHolder.Session()->CurrentDriveL() );
       
   342     if ( currentDrive != phoneDrive )
       
   343 #else
       
   344     if ( TInt(iSessionHolder.Session()->CurrentDriveL()) == EDriveE )
       
   345 #endif //RD_MULTIPLE_DRIVE
       
   346         {
       
   347 #ifndef __SCALABLE_ICONS
       
   348         AknsUtils::CreateIconL( skins, KAknsIIDQgnMenuMceMmcCxt, appBitmap,
       
   349            appBitmapMask, iFilenameMuiu, EMbmMuiuQgn_menu_mce_mmc_cxt,
       
   350            EMbmMuiuQgn_menu_mce_mmc_cxt + 1 );        
       
   351 #else
       
   352         AknsUtils::CreateIconL( skins, KAknsIIDQgnMenuMceMmcCxt, appBitmap,
       
   353            appBitmapMask, iFilenameMuiu, EMbmMuiuQgn_menu_mce_mmc,
       
   354            EMbmMuiuQgn_menu_mce_mmc + 1 );
       
   355 #endif
       
   356         }
       
   357     else
       
   358         {
       
   359 #ifndef __SCALABLE_ICONS
       
   360         AknsUtils::CreateIconL( skins, KAknsIIDQgnMenuMceCxt, appBitmap,
       
   361            appBitmapMask, iFilenameMuiu, EMbmMuiuQgn_menu_mce_cxt,
       
   362            EMbmMuiuQgn_menu_mce_cxt + 1 );
       
   363 #else
       
   364         AknsUtils::CreateIconL( skins, KAknsIIDQgnMenuMceCxt, appBitmap,
       
   365            appBitmapMask, iFilenameMuiu, EMbmMuiuQgn_menu_mce,
       
   366            EMbmMuiuQgn_menu_mce + 1 );
       
   367 #endif
       
   368         } 
       
   369     contextPane->SetPicture( appBitmap, appBitmapMask );
       
   370     //change other bitmaps according to the skins
       
   371 
       
   372     CArrayPtr<CGulIcon> *icons = 0;
       
   373     icons = iListBox->ItemDrawer()->
       
   374         ColumnData()->IconArray();
       
   375     TAknsItemID id; 
       
   376     id.iMajor = 0;
       
   377     id.iMinor = 0;    
       
   378 
       
   379     TInt count = icons->Count();
       
   380     TInt bitmapIndex = 0;
       
   381     TInt bitmapMaskIndex = 0;    
       
   382     
       
   383     for ( TInt cc=count; --cc>=0; )
       
   384         {
       
   385         switch( cc )
       
   386             {
       
   387             case EMceDeliverySmsInfo:                
       
   388                 bitmapIndex = EMbmMuiuQgn_prop_mce_sms_info;                
       
   389                 bitmapMaskIndex = EMbmMuiuQgn_prop_mce_sms_info_mask;
       
   390                 id = KAknsIIDQgnPropMceSmsInfo;
       
   391                 break;
       
   392             case EMceDeliveryMmsInfo:
       
   393             default:
       
   394                 bitmapIndex = EMbmMuiuQgn_prop_mce_mms_info;
       
   395                 bitmapMaskIndex = EMbmMuiuQgn_prop_mce_mms_info_mask;
       
   396                 id = KAknsIIDQgnPropMceMmsInfo;
       
   397                 break;           
       
   398             } 
       
   399         
       
   400         CFbsBitmap* bitmap;
       
   401         CFbsBitmap* mask;
       
   402         AknsUtils::CreateIconL( skins, id, bitmap,
       
   403             mask, iFilenameMuiu /*iFilenameLog*/, bitmapIndex, bitmapMaskIndex );      
       
   404 
       
   405         CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   406      
       
   407         CleanupStack::PushL( icon );
       
   408         CGulIcon* iconToBeDelete = icons->At( cc );
       
   409         icons->At( cc ) = icon;
       
   410         delete iconToBeDelete;
       
   411         iconToBeDelete = NULL;
       
   412 
       
   413         CleanupStack::Pop(); // icon
       
   414     
       
   415         }  
       
   416     }
       
   417     
       
   418 // ----------------------------------------------------
       
   419 // CMceListContainer::FocusChanged
       
   420 // ----------------------------------------------------
       
   421 void CMceDeliveryReportControlContainer::FocusChanged(TDrawNow /*aDrawNow*/)
       
   422     {
       
   423     if (iListBox)
       
   424         {
       
   425         iListBox->SetFocus(IsFocused());
       
   426         }
       
   427     }
       
   428 
       
   429 
       
   430 //  End of File