btobexprofiles/obexsendservices/obexservicesendutils/src/BTServiceDelayedDestroyer.cpp
branchRCL_3
changeset 23 9386f31cc85b
parent 22 613943a21004
child 24 269724087bed
equal deleted inserted replaced
22:613943a21004 23:9386f31cc85b
     1 /*
       
     2 * Copyright (c) 2005-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:  The base active class definition 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "BTServiceDelayedDestroyer.h"
       
    20 #include "BTSUDebug.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 // CBTServiceDelayedDestroyer::NewL()
       
    26 // -----------------------------------------------------------------------------
       
    27 //  
       
    28 CBTServiceDelayedDestroyer* CBTServiceDelayedDestroyer::NewL(CActive::TPriority aPriority)
       
    29     {
       
    30     CBTServiceDelayedDestroyer* self = CBTServiceDelayedDestroyer::NewLC(aPriority);
       
    31     CleanupStack::Pop(self);
       
    32     return self;
       
    33     }
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CBTServiceDelayedDestroyer::NewLC()
       
    37 // -----------------------------------------------------------------------------
       
    38 //  
       
    39 CBTServiceDelayedDestroyer* CBTServiceDelayedDestroyer::NewLC(CActive::TPriority aPriority)
       
    40     {
       
    41     CBTServiceDelayedDestroyer* self = new (ELeave) CBTServiceDelayedDestroyer(aPriority);
       
    42     CleanupStack::PushL(self);
       
    43     return self;
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CBTServiceDelayedDestroyer::CBTServiceDelayedDestroyer()
       
    48 // -----------------------------------------------------------------------------
       
    49 //  
       
    50 CBTServiceDelayedDestroyer::CBTServiceDelayedDestroyer(CActive::TPriority aPriority)
       
    51     : CActive(aPriority), iPtr(NULL)
       
    52     {
       
    53     FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::CBTServiceDelayedDestroyer()"));
       
    54     CActiveScheduler::Add(this);
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CBTServiceDelayedDestroyer::~CBTServiceDelayedDestroyer()
       
    59 // -----------------------------------------------------------------------------
       
    60 //  
       
    61 CBTServiceDelayedDestroyer::~CBTServiceDelayedDestroyer()
       
    62     {
       
    63     FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::Destructor()"));
       
    64     if( iPtr )
       
    65         {
       
    66         delete iPtr;
       
    67         iPtr = NULL;
       
    68         }
       
    69     Cancel();
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CBTServiceDelayedDestroyer::GoActive()
       
    74 // -----------------------------------------------------------------------------
       
    75 //  
       
    76 void CBTServiceDelayedDestroyer::GoActive()
       
    77     {
       
    78     FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::GoActive()"));
       
    79     if( !IsActive() )
       
    80         {
       
    81         TRequestStatus* status = &iStatus;
       
    82         iStatus = KRequestPending;
       
    83         User::RequestComplete(status, KErrNone);
       
    84     	SetActive();
       
    85         }
       
    86     else
       
    87     	{
       
    88         FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::GoActive(), Already active"));
       
    89     	}
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CBTServiceDelayedDestroyer::SetDestructPointer()
       
    94 // Must be called with GoActive, they are pairs, first call SetDestructPointer
       
    95 // and then GoActive.
       
    96 // -----------------------------------------------------------------------------
       
    97 //  
       
    98 void CBTServiceDelayedDestroyer::SetDestructPointer(CBTEngDiscovery* aPtr)
       
    99     {
       
   100     FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::SetDestructPointer()"));
       
   101     if( iPtr )
       
   102         {
       
   103         // If previous is not deleted yet, meaning, RunL is not called yet,
       
   104         // we can safely delete previous here.
       
   105         delete iPtr;
       
   106         }
       
   107     iPtr = aPtr;
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CBTServiceDelayedDestroyer::DoCancel()
       
   112 // -----------------------------------------------------------------------------
       
   113 //  
       
   114 void CBTServiceDelayedDestroyer::DoCancel()
       
   115     {
       
   116     FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::DoCancel()"));
       
   117     }
       
   118     
       
   119 // -----------------------------------------------------------------------------
       
   120 // CBTServiceDelayedDestroyer::RunL()
       
   121 // -----------------------------------------------------------------------------
       
   122 //  
       
   123 void CBTServiceDelayedDestroyer::RunL()
       
   124     {
       
   125     FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::RunL()"));
       
   126     delete iPtr;
       
   127     iPtr = NULL;
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CBTServiceDelayedDestroyer::RunError()
       
   132 // -----------------------------------------------------------------------------
       
   133 //      
       
   134 TInt CBTServiceDelayedDestroyer::RunError(TInt aError)
       
   135     {
       
   136     FTRACE(FPrint(_L("[BTSU]\t CBTServiceStarter::RunError() aError = %d"), aError) );
       
   137     (void) aError;
       
   138     return KErrNone;
       
   139     }