photosgallery/collectionframework/thumbnailcreator/src/glxtndeletethumbnailstask.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Implementation of CGlxtnDeleteThumbnailsTask
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  * @internal reviewed 31/07/2007 by Simon Brooks
       
    23  */
       
    24 
       
    25 // INCLUDE FILES
       
    26 
       
    27 #include "glxtndeletethumbnailstask.h"
       
    28 
       
    29 #include <glxassert.h>
       
    30 #include "glxtnfileinfo.h"
       
    31 #include "mglxtnstorage.h"
       
    32 #include "mglxtnthumbnailcreatorclient.h"
       
    33 #include <glxtracer.h>
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ===============================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // C++ default constructor can NOT contain any code, that might leave.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CGlxtnDeleteThumbnailsTask::CGlxtnDeleteThumbnailsTask(
       
    42             const TGlxMediaId& aItemId, MGlxtnThumbnailCreatorClient& aClient) :
       
    43     CGlxtnClientTask(KGlxtnTaskIdDeleteThumbnails, aItemId, aClient)
       
    44     {
       
    45     TRACER("CGlxtnDeleteThumbnailsTask::CGlxtnDeleteThumbnailsTask()");
       
    46     GLX_ASSERT_ALWAYS( Storage(), Panic( EGlxPanicIllegalArgument ),
       
    47                     "CGlxtnDeleteThumbnailsTask created without storage" );
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // ConstructL
       
    52 // Symbian 2nd phase constructor can leave.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 void CGlxtnDeleteThumbnailsTask::ConstructL()
       
    56     {
       
    57     TRACER("void CGlxtnDeleteThumbnailsTask::ConstructL()");
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // NewL
       
    62 // Two-phased constructor.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CGlxtnDeleteThumbnailsTask* CGlxtnDeleteThumbnailsTask::NewL(
       
    66             const TGlxMediaId& aItemId, MGlxtnThumbnailCreatorClient& aClient)
       
    67     {
       
    68     TRACER("CGlxtnDeleteThumbnailsTask::NewL()");
       
    69     CGlxtnDeleteThumbnailsTask* self = new (ELeave) CGlxtnDeleteThumbnailsTask(
       
    70                                                             aItemId, aClient);
       
    71 
       
    72     CleanupStack::PushL(self);
       
    73     self->ConstructL();
       
    74     CleanupStack::Pop( self );
       
    75 
       
    76     return self;
       
    77     }
       
    78 
       
    79 // Destructor
       
    80 CGlxtnDeleteThumbnailsTask::~CGlxtnDeleteThumbnailsTask()
       
    81     {
       
    82     TRACER("Destructor CGlxtnDeleteThumbnailsTask::~CGlxtnDeleteThumbnailsTask()");
       
    83     delete iInfo;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // DoStartL
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 TBool CGlxtnDeleteThumbnailsTask::DoStartL(TRequestStatus& aStatus)
       
    91     {
       
    92     TRACER("CGlxtnDeleteThumbnailsTask::DoStartL()");
       
    93     iInfo = new (ELeave) CGlxtnFileInfo;
       
    94     Client().FetchFileInfoL(iInfo, ItemId(), &aStatus);
       
    95 
       
    96     return ETrue;
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // DoCancel
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CGlxtnDeleteThumbnailsTask::DoCancel()
       
   104     {
       
   105     TRACER("CGlxtnDeleteThumbnailsTask::DoCancel()");
       
   106     Storage()->StorageCancel();
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // DoRunL
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 TBool CGlxtnDeleteThumbnailsTask::DoRunL(TRequestStatus& aStatus)
       
   114     {
       
   115     TRACER("CGlxtnDeleteThumbnailsTask::DoRunL()");
       
   116     User::LeaveIfError(aStatus.Int());
       
   117 
       
   118     TBool active = EFalse;
       
   119 
       
   120     if ( iDeleting )
       
   121         {
       
   122         Client().ThumbnailDeletionComplete(ItemId(), KErrNone);
       
   123         }
       
   124     else
       
   125         {
       
   126         User::LeaveIfNull(iInfo);
       
   127         Storage()->DeleteThumbnailsL(ItemId(), *iInfo, &aStatus);
       
   128         iDeleting = ETrue;
       
   129         active = ETrue;
       
   130         }
       
   131 
       
   132     return active;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // DoRunError
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 TBool CGlxtnDeleteThumbnailsTask::DoRunError(TInt aError)
       
   140     {
       
   141     TRACER("CGlxtnDeleteThumbnailsTask::DoRunError()");
       
   142     Client().ThumbnailDeletionComplete(ItemId(), aError);
       
   143 
       
   144     return EFalse;
       
   145     }
       
   146 
       
   147 //  End of File