uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/repositoryhandler.cpp
changeset 0 15bf7259bb7c
child 6 10534483575f
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 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:   Transition server repository handler.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "repositoryhandler.h"
       
    20 #include <alflogger.h>
       
    21 #include <centralrepository.h>
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 CRepositoryHandler::CRepositoryHandler(TInt aPriority, const TUid& aRepository, TInt aKey) :
       
    27     CActive(aPriority),
       
    28     iRepository(aRepository),
       
    29     iKey(aKey)
       
    30     {
       
    31     }
       
    32     
       
    33 // ---------------------------------------------------------------------------
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 void CRepositoryHandler::ConstructL()
       
    37     {
       
    38     iCrep = CRepository::NewL(iRepository);
       
    39     __ALFFXLOGSTRING("CRepositoryHandler: Starting");
       
    40     CActiveScheduler::Add(this);
       
    41     RunL();
       
    42     }
       
    43     
       
    44 // ---------------------------------------------------------------------------
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CRepositoryHandler* CRepositoryHandler::NewL(TInt aPriority, const TUid& aRepository, TUint32 aKey)
       
    48     {
       
    49     CRepositoryHandler* self = new (ELeave) CRepositoryHandler(aPriority, aRepository, aKey);
       
    50     CleanupStack::PushL(self);
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop(self);
       
    53     return self;
       
    54     }
       
    55     
       
    56 // ---------------------------------------------------------------------------
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CRepositoryHandler::~CRepositoryHandler()
       
    60     {
       
    61     Cancel();
       
    62     delete iCrep;
       
    63     }
       
    64     
       
    65 // ---------------------------------------------------------------------------
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CRepositoryHandler::RunL()
       
    69     {
       
    70     iError = iCrep->NotifyRequest(iKey, iStatus);
       
    71     TInt value;
       
    72     TInt err = iCrep->Get(iKey, value);
       
    73     if( err == KErrNone )
       
    74     	{
       
    75     	iValue = value;
       
    76     	}
       
    77     
       
    78     if(iError == KErrNone)
       
    79     	{
       
    80     	SetActive();
       
    81     	iError = err;
       
    82     	}
       
    83     }
       
    84     
       
    85 // ---------------------------------------------------------------------------
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 TInt CRepositoryHandler::GetValue(TInt& aValue)
       
    89 	{
       
    90 	if(iError != KErrNone) //if we had an error eariler
       
    91 		{
       
    92 		TInt value;
       
    93 		iError = iCrep->Get(iKey, value); //try to get the value
       
    94 		if(iError == KErrNone)
       
    95 			{
       
    96 			iValue = value;
       
    97 			if (!IsActive())
       
    98 			    {
       
    99     			iError = iCrep->NotifyRequest(iKey, iStatus); //try to start request
       
   100     			if(iError == KErrNone)
       
   101     				{
       
   102     				SetActive();
       
   103     				}
       
   104 			    }
       
   105 			}
       
   106 		}
       
   107 	aValue = iValue;
       
   108 	return iError;
       
   109 	}
       
   110 
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CRepositoryHandler::DoCancel()
       
   116     {
       
   117     __ALFFXLOGSTRING("CRepositoryHandler: Canceled");
       
   118     iCrep->NotifyCancel(iKey);
       
   119     }