pushmtm/MtmUtilSrc/PushAsyncOpRunner.cpp
changeset 0 84ad3b177aa3
equal deleted inserted replaced
-1:000000000000 0:84ad3b177aa3
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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 *      This file contains the member definitions of CPushAsyncOpRunner.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 //  INCLUDES
       
    23 
       
    24 #include "PushAsyncOpRunner.h"
       
    25 #include "PushMtmUtilPanic.h"
       
    26 #include <msvapi.h>
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // ---------------------------------------------------------
       
    31 // CPushAsyncOpRunner::StartL
       
    32 // ---------------------------------------------------------
       
    33 //
       
    34 EXPORT_C void CPushAsyncOpRunner::StartL()
       
    35     {
       
    36     Cancel();
       
    37     TBool isObserving( EFalse );
       
    38     iReady = OnStartupL( isObserving );
       
    39     SetActive();
       
    40     if ( !isObserving )
       
    41         {
       
    42         InvokeRun();
       
    43         }
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------
       
    47 // CPushAsyncOpRunner::ProgressL
       
    48 // ---------------------------------------------------------
       
    49 //
       
    50 EXPORT_C const TDesC8& CPushAsyncOpRunner::ProgressL()
       
    51     {
       
    52     if ( iOperation )
       
    53         {
       
    54         return iOperation->ProgressL();
       
    55         }
       
    56     else
       
    57         {
       
    58         return iDummyProgressBuf;
       
    59         }
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CPushAsyncOpRunner::CPushAsyncOpRunner
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 EXPORT_C CPushAsyncOpRunner::CPushAsyncOpRunner( CMsvSession& aSession, 
       
    67                                                  const TMsvId aEntryId, 
       
    68                                                  TRequestStatus& aObserverStatus ) 
       
    69 :   CPushMtmOperation( aSession, aEntryId, aObserverStatus ), 
       
    70     iReady( EFalse ), 
       
    71     iDummyProgressBuf( KNullDesC8 )
       
    72     {
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // CPushAsyncOpRunner::~CPushAsyncOpRunner
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CPushAsyncOpRunner::~CPushAsyncOpRunner()
       
    80     {
       
    81     Cancel();
       
    82     delete iOperation;
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------
       
    86 // CPushAsyncOpRunner::OnStartupL
       
    87 // ---------------------------------------------------------
       
    88 //
       
    89 EXPORT_C TBool CPushAsyncOpRunner::OnStartupL( TBool& aIsObserving )
       
    90     {
       
    91     aIsObserving = EFalse;
       
    92     return ETrue;
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------
       
    96 // CPushAsyncOpRunner::OnRunLActionL
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 EXPORT_C TBool CPushAsyncOpRunner::OnRunLActionL( TBool& aIsObserving )
       
   100     {
       
   101     aIsObserving = EFalse;
       
   102     return ETrue;
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------
       
   106 // CPushAsyncOpRunner::SetOperation
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 EXPORT_C void CPushAsyncOpRunner::SetOperation( CMsvOperation* aOp )
       
   110     {
       
   111     delete iOperation;
       
   112     iOperation = NULL;
       
   113     iOperation = aOp;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CPushAsyncOpRunner::SetOperation
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 EXPORT_C void CPushAsyncOpRunner::DeleteOperation()
       
   121     {
       
   122     delete iOperation;
       
   123     iOperation = NULL;
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CPushAsyncOpRunner::Operation
       
   128 // ---------------------------------------------------------
       
   129 //
       
   130 EXPORT_C CMsvOperation& CPushAsyncOpRunner::Operation()
       
   131     {
       
   132     __ASSERT_DEBUG( iOperation, UtilPanic( EPushMtmUtilPanNull ) );
       
   133     return *iOperation;
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------
       
   137 // CPushAsyncOpRunner::DoCancel
       
   138 // ---------------------------------------------------------
       
   139 //
       
   140 EXPORT_C void CPushAsyncOpRunner::DoCancel()
       
   141     {
       
   142     if ( iOperation )
       
   143         {
       
   144         iOperation->Cancel();
       
   145         }
       
   146     CPushMtmOperation::DoCancel();
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CPushAsyncOpRunner::RunError
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 EXPORT_C TInt CPushAsyncOpRunner::RunError( TInt aError )
       
   154     {
       
   155     if ( iOperation )
       
   156         {
       
   157         iOperation->Cancel();
       
   158         delete iOperation;
       
   159         iOperation = NULL;
       
   160         }
       
   161     return CPushMtmOperation::RunError( aError );
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // CPushAsyncOpRunner::RunL
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 EXPORT_C void CPushAsyncOpRunner::RunL()
       
   169     {
       
   170     if ( iReady )
       
   171         {
       
   172         SignalObserver( KErrNone );
       
   173         }
       
   174     else
       
   175         {
       
   176         TBool isObserving( EFalse );
       
   177         iReady = OnRunLActionL( isObserving );
       
   178         if ( iReady )
       
   179             {
       
   180             SignalObserver( KErrNone );
       
   181             }
       
   182         else
       
   183             {
       
   184             // Invoke RunL again and run OnRunLActionL in it again.
       
   185             SetActive();
       
   186             if ( !isObserving )
       
   187                 {
       
   188                 InvokeRun();
       
   189                 }
       
   190             }
       
   191         }
       
   192     }
       
   193 
       
   194 // End of file.