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