|
1 /* |
|
2 * Copyright (c) 2009-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 * Definition file for the EnvironmentChangeNotifier class. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <bacntf.h> |
|
21 |
|
22 // User includes |
|
23 #include "environmentchangenotifier.h" |
|
24 #include "timezoneclient.h" |
|
25 #include "OstTraceDefinitions.h" |
|
26 #ifdef OST_TRACE_COMPILER_IN_USE |
|
27 #include "environmentchangenotifierTraces.h" |
|
28 #endif |
|
29 |
|
30 |
|
31 /*! |
|
32 \class EnvironmentChangeNotifier |
|
33 |
|
34 This class listens to the enviroment changes and notifies the client. |
|
35 */ |
|
36 |
|
37 /*! |
|
38 The constructor. |
|
39 */ |
|
40 EnvironmentChangeNotifier::EnvironmentChangeNotifier(TimezoneClient *client) |
|
41 { |
|
42 OstTraceFunctionEntry0( ENVIRONMENTCHANGENOTIFIER_ENVIRONMENTCHANGENOTIFIER_ENTRY ); |
|
43 mTzClient = client; |
|
44 |
|
45 TCallBack callback(environmentCallback, this); |
|
46 |
|
47 mNotifier = CEnvironmentChangeNotifier::NewL( |
|
48 CActive::EPriorityStandard, callback); |
|
49 mNotifier->Start(); |
|
50 |
|
51 OstTraceFunctionExit0( ENVIRONMENTCHANGENOTIFIER_ENVIRONMENTCHANGENOTIFIER_EXIT ); |
|
52 } |
|
53 |
|
54 EnvironmentChangeNotifier::~EnvironmentChangeNotifier() |
|
55 { |
|
56 OstTraceFunctionEntry0( DUP1_ENVIRONMENTCHANGENOTIFIER_ENVIRONMENTCHANGENOTIFIER_ENTRY ); |
|
57 if (mNotifier) { |
|
58 mNotifier->Cancel(); |
|
59 delete mNotifier; |
|
60 mNotifier = 0; |
|
61 } |
|
62 OstTraceFunctionExit0( DUP1_ENVIRONMENTCHANGENOTIFIER_ENVIRONMENTCHANGENOTIFIER_EXIT ); |
|
63 } |
|
64 |
|
65 int EnvironmentChangeNotifier::environmentCallback(TAny* obj) |
|
66 { |
|
67 OstTraceFunctionEntry0( ENVIRONMENTCHANGENOTIFIER_ENVIRONMENTCALLBACK_ENTRY ); |
|
68 EnvironmentChangeNotifier* self = |
|
69 static_cast<EnvironmentChangeNotifier *> (obj); |
|
70 |
|
71 int changes = KInitialEvent; |
|
72 if (self->mNotifier) { |
|
73 changes = self->mNotifier->Change(); |
|
74 } |
|
75 |
|
76 if (KInitialEvent <= changes) { |
|
77 // We're not concerned about handling environment changes in that range. |
|
78 OstTraceFunctionExit0( ENVIRONMENTCHANGENOTIFIER_ENVIRONMENTCALLBACK_EXIT ); |
|
79 return 0; |
|
80 } |
|
81 |
|
82 if (changes & (EChangesMidnightCrossover | |
|
83 EChangesLocale | |
|
84 EChangesSystemTime)) { |
|
85 // emit self->timechanged(); TODO: notify timezone client. |
|
86 // |
|
87 self->notifyEnvChange(); |
|
88 } else { |
|
89 // Nothing to do. |
|
90 } |
|
91 OstTraceFunctionExit0( DUP1_ENVIRONMENTCHANGENOTIFIER_ENVIRONMENTCALLBACK_EXIT ); |
|
92 return 0; |
|
93 } |
|
94 |
|
95 void EnvironmentChangeNotifier::notifyEnvChange() |
|
96 { |
|
97 OstTraceFunctionEntry0( ENVIRONMENTCHANGENOTIFIER_NOTIFYENVCHANGE_ENTRY ); |
|
98 mTzClient->notifyTimeChange(); |
|
99 OstTraceFunctionExit0( ENVIRONMENTCHANGENOTIFIER_NOTIFYENVCHANGE_EXIT ); |
|
100 } |
|
101 |
|
102 // End of file -- Do not remove this. |