uiacceltk/hitchcock/ServerCore/Src/themerepositorylistener.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2009 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: 
       
    15 *
       
    16 */
       
    17 #include "themerepositorylistener.h"
       
    18 
       
    19 #include <platform/mw/pslninternalcrkeys.h>
       
    20 _LIT(KBgAnimExeName, "z:\\sys\\bin\\backgroundanimhost.exe");
       
    21 
       
    22 CThemeRepositoryListener::CThemeRepositoryListener() : CActive(EPriorityStandard)
       
    23     {
       
    24     CActiveScheduler::Add(this);
       
    25     }
       
    26 
       
    27 CThemeRepositoryListener::~CThemeRepositoryListener()
       
    28     {
       
    29     Cancel();
       
    30     delete iThemesRepository;
       
    31     }
       
    32 
       
    33 CThemeRepositoryListener* CThemeRepositoryListener::NewL()
       
    34     {
       
    35     CThemeRepositoryListener* me = new (ELeave)CThemeRepositoryListener;
       
    36     CleanupStack::PushL(me);
       
    37     me->ConstructL();
       
    38     CleanupStack::Pop();
       
    39     return me;
       
    40     }
       
    41 
       
    42 void DoStartBgAnim()
       
    43     {
       
    44     // start the app
       
    45     RProcess image;
       
    46     TInt err = image.Create(KBgAnimExeName,KNullDesC);
       
    47     if (!err)
       
    48         {
       
    49         image.Resume();
       
    50         }
       
    51     image.Close();
       
    52     }
       
    53 
       
    54 void CThemeRepositoryListener::ConstructL()
       
    55     {
       
    56     iThemesRepository = CRepository::NewL(KCRUidThemes);
       
    57     User::LeaveIfError(iThemesRepository->Get(KThemesAnimBackgroundSupport, iPreviousValue));
       
    58     }
       
    59 
       
    60 
       
    61 void CThemeRepositoryListener::RunL()
       
    62     {
       
    63     TInt value = 0;
       
    64     iThemesRepository->Get(KThemesAnimBackgroundSupport, value);
       
    65 #if !defined(__WINS__)
       
    66     if (!value && value != iPreviousValue)
       
    67         {
       
    68         DoStartBgAnim();
       
    69         }
       
    70 #endif
       
    71     iPreviousValue = value;
       
    72     
       
    73     if (iStatus.Int() != KErrCancel)
       
    74         {
       
    75         IssueRequest();
       
    76         }
       
    77     }
       
    78 
       
    79 void CThemeRepositoryListener::DoCancel()
       
    80     {
       
    81     iThemesRepository->NotifyCancelAll();    
       
    82     }
       
    83 
       
    84 void CThemeRepositoryListener::IssueRequest()
       
    85     {
       
    86     TInt err = iThemesRepository->NotifyRequest(KThemesAnimBackgroundSupport,iStatus);
       
    87     if (!err)
       
    88         {
       
    89         SetActive();
       
    90         }
       
    91     }
       
    92 
       
    93     
       
    94 
       
    95