activityfw/storage/server/src/afthumbnailtask.cpp
changeset 104 9b022b1f357c
child 119 50e220be30d1
equal deleted inserted replaced
103:b99b84bcd2d1 104:9b022b1f357c
       
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "afthumbnailtask.h"
       
    19 #include "afcmd.h"
       
    20 
       
    21 #include <fbs.h>
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 /**
       
    25  * Constructor for performing 1st stage construction
       
    26  */
       
    27 CAfThumbnailTask::CAfThumbnailTask(MAfTaskStorage& storage, 
       
    28                                    const RMessage2 msg)
       
    29 :
       
    30     mStorage(storage), 
       
    31     mMsg(msg)
       
    32 {
       
    33     // No implementation required
       
    34 }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 /**
       
    38  * Destructor.
       
    39  */
       
    40 CAfThumbnailTask::~CAfThumbnailTask()
       
    41 {
       
    42     delete mService;
       
    43 }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CAfThumbnailTask::ExecuteLD(MAfTaskStorage& taskStorage,
       
    50                                  const RMessage2& message)
       
    51 {
       
    52     CAfThumbnailTask *self = new (ELeave)CAfThumbnailTask(taskStorage, 
       
    53                                                                       message);
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL();
       
    56     taskStorage.PushL(self);
       
    57     CleanupStack::Pop(self);
       
    58 }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 /**
       
    62  * EPOC default constructor for performing 2nd stage construction
       
    63  */
       
    64 void CAfThumbnailTask::ConstructL()
       
    65 {
       
    66     TPckgBuf<int> width(0), height(0);
       
    67     RBuf path;
       
    68     CleanupClosePushL(path);
       
    69     mMsg.ReadL(0, width);
       
    70     mMsg.ReadL(1, height);
       
    71     path.CreateL(mMsg.GetDesLengthL(2));
       
    72     mMsg.ReadL(2, path);
       
    73     
       
    74     CFbsBitmap *bitmap = new (ELeave) CFbsBitmap();
       
    75     CleanupStack::PushL(bitmap);
       
    76     User::LeaveIfError(bitmap->Load(path));
       
    77     mService = CTsGraphicFileScalingHandler::NewL(*this, 
       
    78                                                   *bitmap, 
       
    79                                                   TSize(width(), height()), 
       
    80                                                   CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding);
       
    81     CleanupStack::PopAndDestroy(bitmap);
       
    82     CleanupStack::PopAndDestroy(&path);
       
    83 }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CAfThumbnailTask::ImageReadyCallBack(TInt error,const CFbsBitmap *bitmap)
       
    90 {
       
    91     if (EFalse == mMsg.IsNull() &&
       
    92         KErrNone == error) {
       
    93         mMsg.Write(0, TPckgBuf<int>(const_cast<CFbsBitmap*>(bitmap)->Handle()));
       
    94         mMsg.Write(1, TPckgBuf<void *>(this));
       
    95         mMsg.Complete(error);
       
    96     } else {
       
    97         if (EFalse == mMsg.IsNull()) {
       
    98          mMsg.Complete(error);
       
    99         }
       
   100         mStorage.Pop(this);
       
   101         delete this;
       
   102     }
       
   103 }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 const TDesC8& CAfThumbnailTask::Data() const
       
   110 {
       
   111     return KNullDesC8();
       
   112 }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CAfThumbnailTask::BroadcastReceivedL(const RMessage2&)
       
   119 {
       
   120 }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 /**
       
   124  * Returns ETrue if task is related with session argument
       
   125  */
       
   126 TBool CAfThumbnailTask::IsSessionTask(const CSession2* session)
       
   127 {
       
   128     return mMsg.Session() == session ? ETrue : EFalse;
       
   129 }