src/screensaverrepositorywatcher.cpp
changeset 0 040fcad49f44
equal deleted inserted replaced
-1:000000000000 0:040fcad49f44
       
     1 /*
       
     2 * Copyright (c) 2003 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:   CScreensaverRepositoryWatcher implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <centralrepository.h>
       
    21 
       
    22 #include "screensaverrepositorywatcher.h"
       
    23 #include "ScreensaverUtils.h"
       
    24 //
       
    25 // CScreensaverRepositoryWatcher
       
    26 //
       
    27 // -----------------------------------------------------------------------------
       
    28 // CScreensaverRepositoryWatcher::NewL
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CScreensaverRepositoryWatcher* CScreensaverRepositoryWatcher::NewL(
       
    32     const TUid aUid,
       
    33     const TUint32 aKey,
       
    34     CCenRepNotifyHandler::TCenRepKeyType aKeyType,
       
    35     TCallBack aCallBack,
       
    36     CRepository* aRepository)
       
    37     {
       
    38     CScreensaverRepositoryWatcher* self = new(ELeave) CScreensaverRepositoryWatcher(aUid, aKey, aCallBack, aRepository);
       
    39 
       
    40     CleanupStack::PushL(self);
       
    41     self->ConstructL(aKeyType);
       
    42     CleanupStack::Pop(self);
       
    43 
       
    44     return self;
       
    45     }
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CScreensaverRepositoryWatcher::NewL
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CScreensaverRepositoryWatcher* CScreensaverRepositoryWatcher::NewL(
       
    53     const TUid aUid,
       
    54     TCallBack aCallBack,
       
    55     CRepository* aRepository)
       
    56     {
       
    57     CScreensaverRepositoryWatcher* self = new(ELeave) CScreensaverRepositoryWatcher(
       
    58         aUid, NCentralRepositoryConstants::KInvalidNotificationId, aCallBack, aRepository);
       
    59 
       
    60     CleanupStack::PushL(self);
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop(self);
       
    63 
       
    64     return self;
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CScreensaverRepositoryWatcher::CScreensaverRepositoryWatcher
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CScreensaverRepositoryWatcher::~CScreensaverRepositoryWatcher()
       
    73     {
       
    74     if (iNotifyHandler)
       
    75         {
       
    76         iNotifyHandler->StopListening();
       
    77         delete iNotifyHandler;
       
    78         }
       
    79     }
       
    80 
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CScreensaverRepositoryWatcher::CScreensaverRepositoryWatcher
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CScreensaverRepositoryWatcher::CScreensaverRepositoryWatcher(
       
    87     const TUid aUid,
       
    88     const TUint32 aKey,
       
    89     TCallBack aCallBack,
       
    90     CRepository* aRepository)
       
    91     :iUid(aUid), iKey(aKey), iCallBack(aCallBack), iRepository(aRepository)
       
    92     {
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CScreensaverRepositoryWatcher::ConstructL
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CScreensaverRepositoryWatcher::ConstructL(CCenRepNotifyHandler::TCenRepKeyType aKeyType)
       
   101     {
       
   102     iNotifyHandler = CCenRepNotifyHandler::NewL(*this, *iRepository, aKeyType, iKey);
       
   103     iNotifyHandler->StartListeningL();
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CScreensaverRepositoryWatcher::ConstructL
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CScreensaverRepositoryWatcher::ConstructL()
       
   111     {
       
   112     iNotifyHandler = CCenRepNotifyHandler::NewL(*this, *iRepository);
       
   113     iNotifyHandler->StartListeningL();
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CScreensaverRepositoryWatcher::ChangedKey
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 TUint32 CScreensaverRepositoryWatcher::ChangedKey()
       
   121     {
       
   122     return iChangedKey;
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CScreensaverRepositoryWatcher::HandleNotifyInt
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CScreensaverRepositoryWatcher::HandleNotifyInt(TUint32 aKey, TInt aNewValue)
       
   130     {
       
   131     SCRLOGGER_WRITEF(_L("SCR: HandleNotifyInt aKey=%d, aNewValue=%d"), aKey, aNewValue);
       
   132 
       
   133     iChangedKey = aKey;
       
   134     iCallBack.CallBack();
       
   135     iChangedKey = NCentralRepositoryConstants::KInvalidNotificationId;
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CScreensaverRepositoryWatcher::HandleNotifyString
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CScreensaverRepositoryWatcher::HandleNotifyString(TUint32 aKey, const TDesC16& aNewValue)
       
   143     {
       
   144     SCRLOGGER_WRITEF(_L("SCR: HandleNotifyString aKey=%d, aNewValue=%S"), aKey, &aNewValue);
       
   145 
       
   146     iChangedKey = aKey;
       
   147     iCallBack.CallBack();
       
   148     iChangedKey = NCentralRepositoryConstants::KInvalidNotificationId;
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CScreensaverRepositoryWatcher::HandleNotifyGeneric
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CScreensaverRepositoryWatcher::HandleNotifyGeneric(TUint32 aKey)
       
   156     {
       
   157     iChangedKey = aKey;
       
   158     iCallBack.CallBack();
       
   159     iChangedKey = NCentralRepositoryConstants::KInvalidNotificationId;
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CScreensaverRepositoryWatcher::HandleNotifyError
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CScreensaverRepositoryWatcher::HandleNotifyError(TUint32 /*aKey*/, TInt /*aError*/, CCenRepNotifyHandler* /*aHandler*/)
       
   167     {
       
   168     }
       
   169 
       
   170 
       
   171 // End of file.