|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QDebug> |
|
19 #include <bacntf.h> |
|
20 #include "nmhswidgetdatetimeobserver.h" |
|
21 #include "nmhswidgetdatetimeobserver_p.h" |
|
22 |
|
23 /*! |
|
24 \fn NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate() |
|
25 |
|
26 /param q pointer to public interface |
|
27 /post Observer listens to environment change events via callback |
|
28 */ |
|
29 NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate(NmHsWidgetDateTimeObserver *q) : |
|
30 q_ptr(q) |
|
31 { |
|
32 qDebug() << "NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate --> IN" ; |
|
33 TCallBack callback( LocaleChangeCallback, this ); |
|
34 //TODO: Handle leave properly |
|
35 TRAP_IGNORE(iLocaleNotifier = CEnvironmentChangeNotifier::NewL( CActive::EPriorityStandard, callback )); |
|
36 iLocaleNotifier->Start(); |
|
37 qDebug() << "NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate <-- OUT" ; |
|
38 } |
|
39 |
|
40 /*! |
|
41 \fn NmHsWidgetDateTimeObserverPrivate::~NmHsWidgetDateTimeObserverPrivate() |
|
42 |
|
43 Destructor |
|
44 */ |
|
45 NmHsWidgetDateTimeObserverPrivate::~NmHsWidgetDateTimeObserverPrivate() |
|
46 { |
|
47 qDebug() << "NmHsWidgetDateTimeObserverPrivate::~NmHsWidgetDateTimeObserverPrivate --> IN" ; |
|
48 if(iLocaleNotifier){ |
|
49 delete iLocaleNotifier; |
|
50 iLocaleNotifier = NULL; |
|
51 } |
|
52 qDebug() << "NmHsWidgetDateTimeObserverPrivate::~NmHsWidgetDateTimeObserverPrivate <-- OUT" ; |
|
53 } |
|
54 |
|
55 /*! |
|
56 \fn TInt NmHsWidgetDateTimeObserverPrivate::HandleLocaleChange() |
|
57 |
|
58 /post If event includes change for system time, locale or midnight crossover |
|
59 indicates poblic interface about the change |
|
60 /return Returns count of handled change events |
|
61 */ |
|
62 TInt NmHsWidgetDateTimeObserverPrivate::HandleLocaleChange() |
|
63 { |
|
64 qDebug() << "NmHsWidgetDateTimeObserverPrivate::HandleLocaleChange"; |
|
65 TInt handled = 0; |
|
66 if( iLocaleNotifier->Change() & ( EChangesSystemTime | EChangesLocale | EChangesMidnightCrossover )) |
|
67 { |
|
68 q_ptr->handleCompletion(); |
|
69 handled = 1; |
|
70 } |
|
71 return handled; |
|
72 } |
|
73 |
|
74 /*! |
|
75 \fn TInt NmHsWidgetDateTimeObserverPrivate::LocaleChangeCallback(TAny* aThisPtr) |
|
76 /param aThisPtr Pointer to tis observer from callback object |
|
77 /post Event is checked and handled if valid change |
|
78 /return Returns count of handled change events |
|
79 */ |
|
80 TInt NmHsWidgetDateTimeObserverPrivate::LocaleChangeCallback(TAny* aThisPtr) |
|
81 { |
|
82 qDebug() << "NmHsWidgetDateTimeObserverPrivate::LocaleChangeCallback" ; |
|
83 TInt ret = static_cast<NmHsWidgetDateTimeObserverPrivate*>(aThisPtr)->HandleLocaleChange(); |
|
84 return ret; |
|
85 } |