landmarks/locationlandmarks/server/src/EPos_CPosLmActiveCompacter.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2005 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: Implementation of Active object that compacts database.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    <epos_cposlmcompactdatabase.h>
       
    23 #include    "EPos_CPosLmActiveCompacter.h"
       
    24 #include    "EPos_CPosLmLocalAccessSubsession.h"
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CPosLmActiveCompacter::CPosLmActiveCompacter
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CPosLmActiveCompacter::CPosLmActiveCompacter(
       
    37     CPosLmLocalAccessSubsession& aOwner) :
       
    38     CActive(EPriorityIdle),
       
    39     iOwner(aOwner)
       
    40     {
       
    41     CActiveScheduler::Add(this);
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CPosLmActiveCompacter::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CPosLmActiveCompacter::ConstructL(CPosLmLocalDbAccess& aDb)
       
    50     {
       
    51     iCompactDb = CPosLmCompactDatabase::NewL(aDb);
       
    52 
       
    53     CompleteSelf();
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CPosLmActiveCompacter::NewL
       
    58 // Two-phased constructor.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CPosLmActiveCompacter* CPosLmActiveCompacter::NewL(
       
    62     CPosLmLocalAccessSubsession& aOwner,
       
    63     CPosLmLocalDbAccess& aDb)
       
    64     {
       
    65     CPosLmActiveCompacter* self = new (ELeave) CPosLmActiveCompacter(aOwner);
       
    66 
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL(aDb);
       
    69     CleanupStack::Pop();
       
    70 
       
    71     return self;
       
    72     }
       
    73 
       
    74 
       
    75 // Destructor
       
    76 CPosLmActiveCompacter::~CPosLmActiveCompacter()
       
    77     {
       
    78     Cancel();
       
    79     delete iCompactDb;
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CPosLmActiveCompacter::DoCancel
       
    84 //
       
    85 // (other items were commented in a header).
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CPosLmActiveCompacter::DoCancel()
       
    89     {
       
    90     delete iCompactDb;
       
    91     iCompactDb = NULL;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CPosLmActiveCompacter::RunL
       
    96 //
       
    97 // (other items were commented in a header).
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CPosLmActiveCompacter::RunL()
       
   101     {
       
   102     TReal32 progress;
       
   103     TBool compactDone = iCompactDb->NextL(progress);
       
   104 
       
   105     if (compactDone)
       
   106         {
       
   107         delete iCompactDb;
       
   108         iCompactDb = NULL;
       
   109 
       
   110         iOwner.ReleaseCompactLock();
       
   111         }
       
   112     else
       
   113         {
       
   114         CompleteSelf();
       
   115         }
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CPosLmActiveCompacter::RunError
       
   120 //
       
   121 // (other items were commented in a header).
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TInt CPosLmActiveCompacter::RunError(TInt /*aError*/)
       
   125     {
       
   126     iOwner.ReleaseCompactLock();
       
   127     return KErrNone;
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CPosLmActiveCompacter::CompleteSelf
       
   132 //
       
   133 // (other items were commented in a header).
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CPosLmActiveCompacter::CompleteSelf()
       
   137     {
       
   138     TRequestStatus* status = &iStatus;
       
   139     User::RequestComplete(status, KErrNone);
       
   140     SetActive();
       
   141     }
       
   142 
       
   143 //  End of File