|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "ASSrvDSTChange.h" |
|
17 #include "ASSrvAlarmQueue.h" |
|
18 |
|
19 #include <e32property.h> |
|
20 |
|
21 // These are copies of definitions in the tz server |
|
22 // they must not change there |
|
23 const TInt KDSTChangePropertyKey(0x10285B32); |
|
24 |
|
25 CASSrvDSTChange* CASSrvDSTChange::NewL(CASSrvAlarmQueue& aASSrvAlarmQueue) |
|
26 { |
|
27 CASSrvDSTChange* self = new(ELeave) CASSrvDSTChange(aASSrvAlarmQueue); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop(self); |
|
31 return self; |
|
32 } |
|
33 |
|
34 CASSrvDSTChange::CASSrvDSTChange(CASSrvAlarmQueue& aASSrvAlarmQueue) |
|
35 :CActive(CActive::EPriorityStandard), |
|
36 iASSrvAlarmQueue(aASSrvAlarmQueue), |
|
37 iNextDSTChangeUTC(Time::NullTTime()), |
|
38 iNextUTCOffset(0), |
|
39 iPreviousDSTChangeUTC(Time::NullTTime()), |
|
40 iPreviousUTCOffset(0) |
|
41 { |
|
42 CActiveScheduler::Add(this); |
|
43 } |
|
44 |
|
45 void CASSrvDSTChange::ConstructL() |
|
46 { |
|
47 TInt attachError = iDSTChangeProperty.Attach(KUidSystemCategory, KDSTChangePropertyKey); |
|
48 |
|
49 if (attachError == KErrNone) |
|
50 { |
|
51 // Only subscribe if there was no error. There should only be an error if the property |
|
52 // has not yet been defined and there was no memory to create the property. The behaviour |
|
53 // in this fail case will be for the alarm server to not be aware of any DST change events |
|
54 // that are scheduled. |
|
55 |
|
56 iDSTChangeProperty.Subscribe(iStatus); |
|
57 SetActive(); |
|
58 |
|
59 UpdatePropertyValuesL(); |
|
60 } |
|
61 } |
|
62 |
|
63 CASSrvDSTChange::~CASSrvDSTChange() |
|
64 { |
|
65 Cancel(); |
|
66 iDSTChangeProperty.Close(); |
|
67 } |
|
68 |
|
69 TTime CASSrvDSTChange::NextDSTChangeUTC() const |
|
70 { |
|
71 return iNextDSTChangeUTC; |
|
72 } |
|
73 |
|
74 TTimeIntervalMinutes CASSrvDSTChange::NextUTCOffset() const |
|
75 { |
|
76 return iNextUTCOffset; |
|
77 } |
|
78 |
|
79 TTime CASSrvDSTChange::PreviousDSTChangeUTC() const |
|
80 { |
|
81 return iPreviousDSTChangeUTC; |
|
82 } |
|
83 |
|
84 TTimeIntervalMinutes CASSrvDSTChange::PreviousUTCOffset() const |
|
85 { |
|
86 return iPreviousUTCOffset; |
|
87 } |
|
88 |
|
89 void CASSrvDSTChange::UpdatePropertyValuesL() |
|
90 { |
|
91 TPckgBuf<TNextDSTChange> fetchedDSTChangeBuf; |
|
92 TInt getError = iDSTChangeProperty.Get(fetchedDSTChangeBuf); |
|
93 |
|
94 if (getError == KErrNone) |
|
95 { |
|
96 iNextDSTChangeUTC = fetchedDSTChangeBuf().iNextDSTChangeUTC; |
|
97 iNextUTCOffset = fetchedDSTChangeBuf().iNextUTCOffset; |
|
98 |
|
99 if (fetchedDSTChangeBuf().iVersion >= 2) |
|
100 { |
|
101 iPreviousDSTChangeUTC = fetchedDSTChangeBuf().iPreviousDSTChangeUTC; |
|
102 iPreviousUTCOffset = fetchedDSTChangeBuf().iPreviousUTCOffset; |
|
103 } |
|
104 } |
|
105 } |
|
106 |
|
107 void CASSrvDSTChange::RunL() |
|
108 { |
|
109 if (iStatus.Int() == KErrNone) |
|
110 { |
|
111 // Subscribe again before handling the change |
|
112 iDSTChangeProperty.Subscribe(iStatus); |
|
113 SetActive(); |
|
114 |
|
115 UpdatePropertyValuesL(); |
|
116 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
117 // Tell the alarm queue that it may need to reset the RTC |
|
118 iASSrvAlarmQueue.HandleNextDSTChangeEventL(); |
|
119 #endif |
|
120 } |
|
121 } |
|
122 |
|
123 void CASSrvDSTChange::DoCancel() |
|
124 { |
|
125 iDSTChangeProperty.Cancel(); |
|
126 } |
|
127 |
|
128 |