messagingfw/senduiservices/datautils/src/SendUiOperationWait.cpp
branchRCL_3
changeset 22 d2c4c66342f3
parent 21 e5b3a2155e1a
child 23 d51193d814ea
equal deleted inserted replaced
21:e5b3a2155e1a 22:d2c4c66342f3
     1 /*
       
     2 * Copyright (c) 2002-2006 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:   Active object that is used for waiting the asyncronous
       
    15 *                request to complete, such as attachment insertion and 
       
    16 *                launching editor operations.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 
       
    24 #include <mtclbase.h>
       
    25 #include <akninputblock.h>
       
    26 
       
    27 #include "SendUiOperationWait.h"
       
    28 
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CSendUiOperationWait::CSendUiOperationWait
       
    34 // C++ default constructor can NOT contain any code, that
       
    35 // might leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CSendUiOperationWait::CSendUiOperationWait( TInt aPriority )
       
    39     : CActive( aPriority )
       
    40     {
       
    41     CActiveScheduler::Add( this );
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSendUiOperationWait::NewLC
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CSendUiOperationWait* CSendUiOperationWait::NewLC( TInt aPriority )
       
    49     {
       
    50     CSendUiOperationWait* self =
       
    51         new ( ELeave ) CSendUiOperationWait( aPriority );
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop( );
       
    55     return self;
       
    56     }
       
    57 
       
    58 // Destructor
       
    59 CSendUiOperationWait::~CSendUiOperationWait()
       
    60     {
       
    61     Cancel();
       
    62     if ( iInputBlock )
       
    63         {
       
    64         delete iInputBlock;
       
    65         }
       
    66     }
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CSendUiOperationWait::Start
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C TBool CSendUiOperationWait::Start()
       
    74     {
       
    75     iSuccess = ETrue;
       
    76     SetActive();
       
    77     // Start the scheduler loop.
       
    78     iWait.Start();
       
    79     return iSuccess;
       
    80     }
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSendUiOperationWait::Start
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C TBool CSendUiOperationWait::Start(CActive* aOperation)
       
    86     {
       
    87     iBaseMtmOperation = NULL;
       
    88     iOperation = aOperation;
       
    89     return Start();
       
    90     }
       
    91 // -----------------------------------------------------------------------------
       
    92 // CSendUiOperationWait::Start
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C TBool CSendUiOperationWait::Start(CBaseMtm* aBaseMtmOperation)
       
    96     {
       
    97     iOperation = NULL;
       
    98     iBaseMtmOperation = aBaseMtmOperation;
       
    99     return Start();
       
   100     }
       
   101 
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CSendUiOperationWait::RunL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CSendUiOperationWait::RunL()
       
   108     {
       
   109     if ( iWait.IsStarted() )
       
   110         {
       
   111         // Stops the scheduler loop, when all nested scheduler loops have stopped.
       
   112         iWait.AsyncStop();
       
   113         }
       
   114     iOperation = NULL;
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CSendUiOperationWait::DoCancel
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CSendUiOperationWait::DoCancel()
       
   122     {
       
   123     iSuccess = EFalse;    
       
   124     if ( iOperation )
       
   125         {
       
   126         iOperation->Cancel();
       
   127         iOperation = NULL;
       
   128         }
       
   129     else if(iBaseMtmOperation)
       
   130         {
       
   131         iBaseMtmOperation->CancelAttachmentOperation();
       
   132         iBaseMtmOperation = NULL;
       
   133         }
       
   134     
       
   135     if ( iWait.IsStarted() )
       
   136         {
       
   137         // Stops the scheduler loop, when all nested scheduler loops have stopped.
       
   138         iWait.AsyncStop();
       
   139         }
       
   140     iInputBlock->SetCancelActive( NULL ); // inputblock cancel was this DoCancel function. Deletion causes call to Cancel.
       
   141 	delete iInputBlock;
       
   142 	iInputBlock = NULL;
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CSendUiOperationWait::ConstructL
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CSendUiOperationWait::ConstructL()
       
   150 	{
       
   151     this->iInputBlock = CAknInputBlock::NewCancelActiveLC( this );  // notify "this" on cancel
       
   152 	}
       
   153 
       
   154 // End of file