mmsharing/mmshui/src/musuibitmapdecoder.cpp
changeset 0 f0cf47e981f9
child 21 ce86b6d44a6d
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     1 /*
       
     2 * Copyright (c) 2005 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "musuibitmapdecoder.h"
       
    21 #include "musuibitmapdecoderobserver.h"
       
    22 #include "muslogger.h" // debug logging
       
    23 
       
    24 #include <imageconversion.h>
       
    25 
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CMusUiBitmapDecoder::~CMusUiBitmapDecoder()
       
    32     {
       
    33     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBitmapDecoder::~CMusUiBitmapDecoder" );
       
    34     Cancel();
       
    35     iFs.Close();
       
    36     delete iData;
       
    37     delete iDecoder;
       
    38     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBitmapDecoder::~CMusUiBitmapDecoder" );
       
    39     }
       
    40 
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // Symbian two-phase constructor.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CMusUiBitmapDecoder* CMusUiBitmapDecoder::NewL(
       
    47                         MMusUiBitmapDecoderObserver& aObserver )
       
    48     {
       
    49     CMusUiBitmapDecoder* self = new (ELeave) CMusUiBitmapDecoder( aObserver );
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop( self );
       
    53     return self;
       
    54     }
       
    55 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CMusUiBitmapDecoder::CMusUiBitmapDecoder(
       
    62                         MMusUiBitmapDecoderObserver& aObserver ) :
       
    63     CActive( EPriorityNormal ),
       
    64     iObserver( aObserver )
       
    65     {
       
    66     // nothing
       
    67     }
       
    68 
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // Symbian second-phase constructor.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CMusUiBitmapDecoder::ConstructL()
       
    75     {
       
    76     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBitmapDecoder::ConstructL" );
       
    77     User::LeaveIfError( iFs.Connect() );
       
    78     //delete iData;
       
    79     iData = NULL;
       
    80     //delete iDecoder;
       
    81     iDecoder = NULL;
       
    82     CActiveScheduler::Add( this );
       
    83     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBitmapDecoder::ConstructL" );
       
    84     }
       
    85 
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CMusUiBitmapDecoder::ConvertL( HBufC8* aData, CFbsBitmap* aBitmap )
       
    92     {
       
    93     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBitmapDecoder::ConvertL" );
       
    94 
       
    95     if ( IsActive() )
       
    96         {
       
    97         Cancel();
       
    98         }
       
    99 
       
   100     iData = aData->AllocL();
       
   101     iBitmap = aBitmap;
       
   102 
       
   103     delete iDecoder;
       
   104     iDecoder = NULL;
       
   105     iDecoder = CImageDecoder::DataNewL( iFs, *iData );
       
   106 
       
   107     iBitmap->Create( iDecoder->FrameInfo().iFrameCoordsInPixels.Size(),
       
   108                      iDecoder->FrameInfo().iFrameDisplayMode );
       
   109 
       
   110     iDecoder->Convert( &iStatus, *iBitmap, 0 );
       
   111     SetActive();
       
   112 
       
   113     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBitmapDecoder::ConvertL" );
       
   114 
       
   115     }
       
   116 
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CMusUiBitmapDecoder::DoCancel()
       
   123     {
       
   124     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBitmapDecoder::DoCancel" );
       
   125     iDecoder->Cancel();
       
   126     Cancel();
       
   127     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBitmapDecoder::DoCancel" );
       
   128     }
       
   129 
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CMusUiBitmapDecoder::RunL()
       
   136     {
       
   137     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBitmapDecoder::RunL" );
       
   138     if (iStatus == KErrNone)
       
   139         {
       
   140         iObserver.UpdateBitmap( iBitmap );
       
   141         }
       
   142     else
       
   143         {
       
   144         MUS_LOG1( "mus: [MUSUI ]        CMusUiBitmapDecoder::RunL: iStatus: [%d]",
       
   145                                 iStatus.Int() );
       
   146         User::Leave( iStatus.Int() );
       
   147         }
       
   148     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBitmapDecoder::RunL" );
       
   149     }
       
   150 
       
   151 
       
   152 // end of file