iaupdate/IAD/engine/controller/src/iaupdatecontentoperation.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   CIAUpdateContentOperation 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "iaupdatecontentoperation.h"
       
    21 #include "iaupdatecontentoperationobserver.h"
       
    22 #include "iaupdatenodeimpl.h"
       
    23 #include "iaupdatenodedetails.h"
       
    24 
       
    25 #include "iaupdatedebug.h"
       
    26 
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CIAUpdateContentOperation::CIAUpdateContentOperation
       
    30 // 
       
    31 // ---------------------------------------------------------------------------
       
    32 // 
       
    33 CIAUpdateContentOperation::CIAUpdateContentOperation( 
       
    34     CIAUpdateBaseNode& aNode,
       
    35     MIAUpdateContentOperationObserver& aObserver )
       
    36 : CBase(),
       
    37   iNode( aNode ),
       
    38   iObserver( aObserver )
       
    39     {
       
    40     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::CIAUpdateContentOperation");
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CIAUpdateContentOperation::ConstructL
       
    46 // 
       
    47 // ---------------------------------------------------------------------------
       
    48 // 
       
    49 void CIAUpdateContentOperation::ConstructL()
       
    50     {
       
    51     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::ConstructL");
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CIAUpdateContentOperation::~CIAUpdateContentOperation
       
    57 // 
       
    58 // ---------------------------------------------------------------------------
       
    59 // 
       
    60 CIAUpdateContentOperation::~CIAUpdateContentOperation()
       
    61     {
       
    62     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::~CIAUpdateContentOperation begin");
       
    63 
       
    64     // Do not call CancelOperation here because its implementation depends on 
       
    65     // child class implementations. So, this object is deleted, the child classes
       
    66     // are already deleted and their implementation is not available.
       
    67     // So, call CancelOperation in child classes.
       
    68 
       
    69     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::~CIAUpdateContentOperation end");
       
    70     }
       
    71 
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CIAUpdateContentOperation::StartL
       
    75 // 
       
    76 // ---------------------------------------------------------------------------
       
    77 //     
       
    78 TBool CIAUpdateContentOperation::StartOperationL()
       
    79     {
       
    80     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::StartL begin");
       
    81     
       
    82     if ( OperationInUse() )
       
    83         {
       
    84         IAUPDATE_TRACE("[IAUPDATE] ERROR Operation already existed");
       
    85         User::Leave( KErrInUse );
       
    86         }
       
    87 
       
    88     if ( Node().Details().EmbededDegrades() )
       
    89         {
       
    90         // Do not continue operation if embedded content degrades already
       
    91         // installed content.
       
    92         IAUPDATE_TRACE("[IAUPDATE] Embeded content degrades. Leave with KErrPermissionDenied.");
       
    93         User::Leave( KErrPermissionDenied );
       
    94         }
       
    95 
       
    96     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::StartL end");
       
    97 
       
    98     // No operation is started here. So, return EFalse.
       
    99     // Child classes should provide their own implementation.
       
   100     return EFalse;
       
   101     }
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CIAUpdateContentOperation::OperationComplete
       
   106 // 
       
   107 // ---------------------------------------------------------------------------
       
   108 // 
       
   109 void CIAUpdateContentOperation::OperationComplete( TInt aError )
       
   110     {
       
   111     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::OperationComplete() begin");
       
   112 
       
   113     // Reset and set everything before calling observer complete because
       
   114     // the observer may delete this object immediately.
       
   115 
       
   116     // Operation has completed. So, it is not in use anymore.
       
   117     SetOperationInUse( EFalse );
       
   118 
       
   119 
       
   120     // Inform the observer about the completion of the operation. 
       
   121     // Give the main node as a parameter.
       
   122     Observer().ContentOperationComplete( Node(), aError );
       
   123 
       
   124     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateContentOperation::OperationComplete() end");
       
   125     }
       
   126 
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CIAUpdateContentOperation::OperationProgress
       
   130 // 
       
   131 // ---------------------------------------------------------------------------
       
   132 // 
       
   133 void CIAUpdateContentOperation::OperationProgress( 
       
   134     TInt aProgress, TInt aMaxProgress )
       
   135     {
       
   136     Observer().ContentOperationProgress( Node(), aProgress, aMaxProgress );
       
   137     }
       
   138 
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CIAUpdateContentOperation::Node
       
   142 // 
       
   143 // ---------------------------------------------------------------------------
       
   144 // 
       
   145 CIAUpdateBaseNode& CIAUpdateContentOperation::Node() const
       
   146     {
       
   147     return iNode;
       
   148     }
       
   149     
       
   150     
       
   151 // ---------------------------------------------------------------------------
       
   152 // CIAUpdateContentOperation::Observer
       
   153 // 
       
   154 // ---------------------------------------------------------------------------
       
   155 // 
       
   156 MIAUpdateContentOperationObserver& CIAUpdateContentOperation::Observer() const
       
   157     {
       
   158     return iObserver;
       
   159     }
       
   160 
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // CIAUpdateContentOperation::OperationInUse
       
   164 // 
       
   165 // ---------------------------------------------------------------------------
       
   166 // 
       
   167 TBool CIAUpdateContentOperation::OperationInUse() const
       
   168     {
       
   169     return iInUse;
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CIAUpdateContentOperation::SetOperationInUse
       
   174 // 
       
   175 // ---------------------------------------------------------------------------
       
   176 // 
       
   177 void CIAUpdateContentOperation::SetOperationInUse( TBool aInUse )
       
   178     {
       
   179     iInUse = aInUse;
       
   180     }