activityfw/activitydatabase/hsactivitydbserver/src/afthumbnailtask.cpp
changeset 102 8b8b34fa9751
parent 100 0920c6a9b6c8
child 106 e78d6e055a5b
equal deleted inserted replaced
100:0920c6a9b6c8 102:8b8b34fa9751
     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 "activitycmd.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     RBuf8 mime;
       
    69     CleanupClosePushL(path);
       
    70     CleanupClosePushL(mime);
       
    71     mMsg.ReadL(0, width);
       
    72     mMsg.ReadL(1, height);
       
    73     path.CreateL(mMsg.GetDesLengthL(2));
       
    74     mMsg.ReadL(2, path);
       
    75     mime.CreateL(mMsg.GetDesLengthL(3));
       
    76     mMsg.ReadL(3, mime);
       
    77     
       
    78     CFbsBitmap *bitmap = new (ELeave) CFbsBitmap();
       
    79     CleanupStack::PushL(bitmap);
       
    80     User::LeaveIfError(bitmap->Load(path));
       
    81     mService = CTsGraphicFileScalingHandler::NewL(*this, 
       
    82                                                   *bitmap, 
       
    83                                                   TSize(width(), height()), 
       
    84                                                   CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding);
       
    85     CleanupStack::PopAndDestroy(bitmap);
       
    86 
       
    87     CleanupStack::PopAndDestroy(&mime);
       
    88     CleanupStack::PopAndDestroy(&path);
       
    89 }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CAfThumbnailTask::ImageReadyCallBack(TInt error,const CFbsBitmap *bitmap)
       
    96 {
       
    97     if (EFalse == mMsg.IsNull() &&
       
    98         KErrNone == error) {
       
    99         mMsg.Write(0, TPckgBuf<int>(const_cast<CFbsBitmap*>(bitmap)->Handle()));
       
   100         mMsg.Write(1, TPckgBuf<void *>(this));
       
   101         mMsg.Complete(error);
       
   102     } else {
       
   103         if (EFalse == mMsg.IsNull()) {
       
   104          mMsg.Complete(error);
       
   105         }
       
   106         mStorage.Pop(this);
       
   107         delete this;
       
   108     }
       
   109 }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 const TDesC8& CAfThumbnailTask::Data() const
       
   116 {
       
   117     return KNullDesC8();
       
   118 }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CAfThumbnailTask::BroadcastReceivedL(const RMessage2&)
       
   125 {
       
   126 }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 /**
       
   130  * Returns ETrue if task is related with session argument
       
   131  */
       
   132 TBool CAfThumbnailTask::IsSessionTask(const CSession2* session)
       
   133 {
       
   134     return mMsg.Session() == session ? ETrue : EFalse;
       
   135 }