logsui/logsengine/logssymbianos/src/logssystemtimeobserver.cpp
changeset 15 76d2cf7a585e
parent 13 52d644758b05
child 17 90fe74753f71
equal deleted inserted replaced
13:52d644758b05 15:76d2cf7a585e
     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 
       
    18 // INCLUDE FILES
       
    19 #include <bacntf.h>                   // CEnvironmentChangeNotifier
       
    20 #include "logssystemtimeobserver.h"
       
    21 #include "logslogger.h"
       
    22 
       
    23 // CONSTANTS
       
    24 
       
    25 // ----------------------------------------------------------------------------
       
    26 //
       
    27 // ----------------------------------------------------------------------------
       
    28 //
       
    29 LogsSystemTimeObserver::LogsSystemTimeObserver(QObject* parent) : QObject(parent)
       
    30 {
       
    31     LOGS_QDEBUG( "logs [ENG] -> LogsSystemTimeObserver::LogsSystemTimeObserver()" )
       
    32     TCallBack callback(EnvironmentChangeCallback, this);
       
    33 
       
    34     QT_TRAP_THROWING(mEnvChangeNotifier = 
       
    35             CEnvironmentChangeNotifier::NewL( CActive::EPriorityStandard, callback ));
       
    36 
       
    37     mEnvChangeNotifier->Start();
       
    38     LOGS_QDEBUG( "logs [ENG] <- LogsSystemTimeObserver::LogsSystemTimeObserver()" )
       
    39 }
       
    40 
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 LogsSystemTimeObserver::~LogsSystemTimeObserver()
       
    46 {
       
    47     LOGS_QDEBUG( "logs [ENG] -> LogsSystemTimeObserver::~LogsSystemTimeObserver()" )
       
    48     
       
    49     delete mEnvChangeNotifier;
       
    50     
       
    51     LOGS_QDEBUG( "logs [ENG] <- LogsSystemTimeObserver::~LogsSystemTimeObserver()" )
       
    52 }
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 // ----------------------------------------------------------------------------
       
    57 //
       
    58 TInt LogsSystemTimeObserver::EnvironmentChangeCallback(TAny* aThis)
       
    59 {
       
    60     LOGS_QDEBUG( "logs [ENG] -> LogsSystemTimeObserver::EnvironmentChangeCallback()" )
       
    61     LogsSystemTimeObserver* self = static_cast<LogsSystemTimeObserver*>(aThis);
       
    62     if (self->mEnvChangeNotifier->Change() & EChangesLocale) {
       
    63         LOGS_QDEBUG( "logs [ENG] system time or Locale CHANGED!!!!" )
       
    64         emit self->timeFormatChanged();
       
    65     }
       
    66     return 0;
       
    67 }