|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Slide set wallpaper timer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "aknssrvwallpapertimer.h" |
|
20 |
|
21 // ======== MEMBER FUNCTIONS ======== |
|
22 // --------------------------------------------------------------------------- |
|
23 // Constructor. |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CAknsSrvWallpaperTimer* CAknsSrvWallpaperTimer::NewL( |
|
27 MAknsSrvWallpaperListener* aListener ) |
|
28 { |
|
29 CAknsSrvWallpaperTimer* self = |
|
30 new (ELeave)CAknsSrvWallpaperTimer( aListener ); |
|
31 CleanupStack::PushL( self ); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop( self ); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // Handles an active object's request completion event. |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 void CAknsSrvWallpaperTimer::RunL() |
|
42 { |
|
43 if ( iStatus.Int() == KErrAbort && !iCanceled ) |
|
44 { |
|
45 TTime now; |
|
46 now.HomeTime(); |
|
47 TTimeIntervalSeconds seconds; |
|
48 now.SecondsFrom( iPreviousTime, seconds ); |
|
49 if ( seconds.Int() < iInterval ) |
|
50 { |
|
51 IssueRequest( iInterval-seconds.Int() ); |
|
52 return; |
|
53 } |
|
54 } |
|
55 |
|
56 iListener->WallpaperTimerTimeoutL(); |
|
57 if ( !iCanceled ) |
|
58 { |
|
59 IssueRequest(); |
|
60 } |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Cancels request. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CAknsSrvWallpaperTimer::DoCancel() |
|
68 { |
|
69 iCanceled = ETrue; |
|
70 iTimer.Cancel(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Issues a new request. |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CAknsSrvWallpaperTimer::IssueRequest( TInt aTempInterval ) |
|
78 { |
|
79 iCanceled = EFalse; |
|
80 if ( !IsActive() ) |
|
81 { |
|
82 TTime now; |
|
83 now.HomeTime(); |
|
84 if ( aTempInterval ) |
|
85 { |
|
86 now += TTimeIntervalSeconds( aTempInterval ); |
|
87 } |
|
88 else |
|
89 { |
|
90 iPreviousTime = now; |
|
91 now += TTimeIntervalSeconds( iInterval ); |
|
92 } |
|
93 iTimer.At( iStatus, now ); |
|
94 SetActive(); |
|
95 } |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // Destructor. |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CAknsSrvWallpaperTimer::~CAknsSrvWallpaperTimer() |
|
103 { |
|
104 iTimer.Close(); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // Second phase constructor. |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 void CAknsSrvWallpaperTimer::ConstructL() |
|
112 { |
|
113 User::LeaveIfError( iTimer.CreateLocal() ); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // C++ constructor. |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CAknsSrvWallpaperTimer::CAknsSrvWallpaperTimer( |
|
121 MAknsSrvWallpaperListener* aListener ) : |
|
122 CActive( CActive::EPriorityStandard ), |
|
123 iListener( aListener ) |
|
124 { |
|
125 CActiveScheduler::Add( this ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // Returns the interval period of the timer. |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CAknsSrvWallpaperTimer::Interval() |
|
133 { |
|
134 return iInterval; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // Start the timer. |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CAknsSrvWallpaperTimer::Start( TInt aInterval ) |
|
142 { |
|
143 Cancel(); |
|
144 iInterval = aInterval; |
|
145 IssueRequest(); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // Stop the timer. |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 void CAknsSrvWallpaperTimer::Stop() |
|
153 { |
|
154 Cancel(); |
|
155 } |
|
156 |
|
157 // End of file |