calendarwidgetplugin/src/datetimeobserver_p.cpp
changeset 0 db1bf15cefff
equal deleted inserted replaced
-1:000000000000 0:db1bf15cefff
       
     1 /*
       
     2 * Copyright (c) 2010 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: Calendar widget datetime observer
       
    15 *
       
    16 */
       
    17 
       
    18 #include "datetimeobserver.h"
       
    19 #include "datetimeobserver_p.h"
       
    20 #include "calendarwidgetdebug.h"
       
    21 
       
    22 DateTimeObserverPrivate::DateTimeObserverPrivate(DateTimeObserver *q) :
       
    23     q_ptr(q)
       
    24 {
       
    25     LOGS("DateTimeObserverPrivate::DateTimeObserverPrivate");
       
    26     TCallBack callback(LocaleChangeCallback, this);
       
    27     iLocaleNotifier = CEnvironmentChangeNotifier::NewL(CActive::EPriorityStandard, callback);
       
    28     iLocaleNotifier->Start();
       
    29 }
       
    30 
       
    31 DateTimeObserverPrivate::~DateTimeObserverPrivate()
       
    32 {
       
    33     LOGS("DateTimeObserverPrivate::~DateTimeObserverPrivate");
       
    34     delete iLocaleNotifier;
       
    35 }
       
    36 
       
    37 TInt DateTimeObserverPrivate::HandleLocaleChange()
       
    38 {
       
    39     LOGS("DateTimeObserverPrivate::HandleLocaleChange");
       
    40     TInt handled = 0;
       
    41     if (iLocaleNotifier->Change() & (EChangesSystemTime | EChangesLocale | EChangesMidnightCrossover)) {
       
    42         q_ptr->handleCompletion();
       
    43         handled = 1;
       
    44     }
       
    45 
       
    46     return handled;
       
    47 }
       
    48 
       
    49 TInt DateTimeObserverPrivate::LocaleChangeCallback(TAny* aThisPtr)
       
    50 {
       
    51     LOGS("DateTimeObserverPrivate::LocaleChangeCallback");
       
    52     TInt ret = static_cast<DateTimeObserverPrivate*>(aThisPtr)->HandleLocaleChange();
       
    53     return ret;
       
    54 }