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: Implements geotagging 3AM timer |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "mylocationgeotagtimerao.h" |
|
19 #include <mylocationlogger.h> |
|
20 #include <aknappui.h> |
|
21 #include <aknnotewrappers.h> |
|
22 #include <avkon.hrh> |
|
23 |
|
24 //Time at which the geotagging should be triggered( 3.00 AM ) |
|
25 const TInt GEOTAGGING_TIME_IN_HOURS = 3; |
|
26 //Hour specified in minutes |
|
27 const TInt HOUR_VALUE_IN_MINUTES = 60; |
|
28 //Hour specified in seconds |
|
29 const TInt HOUR_VALUE_IN_SECONDS = 3600; |
|
30 |
|
31 // -------------------------------------------------------------------------- |
|
32 // CLocationGeoTagTimerAO::CLocationGeoTagTimerAO |
|
33 // -------------------------------------------------------------------------- |
|
34 // |
|
35 CLocationGeoTagTimerAO::CLocationGeoTagTimerAO( MyLocationTimerObserver& aObserver ): |
|
36 CTimer(EPriorityStandard ), |
|
37 iTimerObserver(&aObserver) |
|
38 { |
|
39 |
|
40 } |
|
41 |
|
42 |
|
43 // -------------------------------------------------------------------------- |
|
44 // CLocationGeoTagTimerAO::~CLocationGeoTagTimerAO |
|
45 // -------------------------------------------------------------------------- |
|
46 // |
|
47 CLocationGeoTagTimerAO::~CLocationGeoTagTimerAO() |
|
48 { |
|
49 MYLOCLOGSTRING ("CLocationGeoTagTimerAO::~CLocationGeoTagTimerAO(), begin"); |
|
50 Cancel(); |
|
51 MYLOCLOGSTRING ("CLocationGeoTagTimerAO::~CLocationGeoTagTimerAO(), end"); |
|
52 } |
|
53 |
|
54 // -------------------------------------------------------------------------- |
|
55 // CLocationGeoTagTimerAO::NewL |
|
56 // -------------------------------------------------------------------------- |
|
57 // |
|
58 CLocationGeoTagTimerAO* CLocationGeoTagTimerAO::NewL( MyLocationTimerObserver& aObserver ) |
|
59 { |
|
60 CLocationGeoTagTimerAO* self = |
|
61 new( ELeave ) CLocationGeoTagTimerAO( aObserver); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(); |
|
65 |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // CLocationGeoTagTimerAO::ConstructL |
|
72 // -------------------------------------------------------------------------- |
|
73 // |
|
74 void CLocationGeoTagTimerAO::ConstructL() |
|
75 { |
|
76 MYLOCLOGSTRING ("CLocationGeoTagTimerAO::ConstructL(), begin"); |
|
77 CActiveScheduler::Add(this); |
|
78 CTimer::ConstructL(); |
|
79 MYLOCLOGSTRING ("CLocationGeoTagTimerAO::ConstructL(), end"); |
|
80 } |
|
81 |
|
82 // -------------------------------------------------------------------------- |
|
83 // CLocationGeoTagTimerAO::StartTimer |
|
84 // -------------------------------------------------------------------------- |
|
85 // |
|
86 void CLocationGeoTagTimerAO::StartTimer() |
|
87 { |
|
88 MYLOCLOGSTRING ("CLocationGeoTagTimerAO::StartTimer(), begin"); |
|
89 if(!IsActive()) |
|
90 { |
|
91 TTime hometime; |
|
92 hometime.HomeTime(); |
|
93 |
|
94 //Get the current time in Hour,Minute, Second |
|
95 TDateTime currentDateTime = hometime.DateTime(); |
|
96 TInt currentHr = currentDateTime.Hour(); |
|
97 TInt currentMin = currentDateTime.Minute(); |
|
98 TInt currentSec = currentDateTime.Second(); |
|
99 |
|
100 //3 AM in seconds |
|
101 TInt targetTimeInSeconds = GEOTAGGING_TIME_IN_HOURS * HOUR_VALUE_IN_SECONDS; |
|
102 TInt timeDifference; |
|
103 |
|
104 //Find the time difference in seconds between current time to 3.00 AM |
|
105 //Either on same day or next day. |
|
106 if ( currentHr < GEOTAGGING_TIME_IN_HOURS ) |
|
107 { |
|
108 timeDifference = targetTimeInSeconds - |
|
109 ( ( currentHr * HOUR_VALUE_IN_SECONDS ) + ( currentMin * HOUR_VALUE_IN_MINUTES ) + currentSec ); |
|
110 } |
|
111 else |
|
112 { |
|
113 timeDifference = ( 24 * HOUR_VALUE_IN_SECONDS - ( |
|
114 ( currentHr * HOUR_VALUE_IN_SECONDS ) + ( currentMin * HOUR_VALUE_IN_MINUTES ) + currentSec ) ) + |
|
115 targetTimeInSeconds ; |
|
116 } |
|
117 |
|
118 //Add the time difference to current time to set the target time ( 3.00 AM ) |
|
119 TTimeIntervalSeconds interval( timeDifference ); |
|
120 TTime timeToSet; |
|
121 timeToSet.HomeTime(); |
|
122 timeToSet+= interval; |
|
123 |
|
124 At( timeToSet ); |
|
125 } |
|
126 MYLOCLOGSTRING ("CLocationGeoTagTimerAO::StartTimer(), end"); |
|
127 } |
|
128 |
|
129 |
|
130 // -------------------------------------------------------------------------- |
|
131 // CLocationGeoTagTimerAO::RunL |
|
132 // -------------------------------------------------------------------------- |
|
133 // |
|
134 void CLocationGeoTagTimerAO::RunL( ) |
|
135 { |
|
136 MYLOCLOGSTRING ("CLocationGeoTagTimerAO::RunL(), begin"); |
|
137 TInt status = iStatus.Int(); |
|
138 |
|
139 switch( status ) |
|
140 { |
|
141 case KErrNone: |
|
142 //Trigger the reverse geocoding and start the timer again |
|
143 //Create the instance of geotagger class |
|
144 iTimerObserver->MyLocationThreeAMTimerExpiredL(); |
|
145 |
|
146 break; |
|
147 default: |
|
148 StartTimer(); |
|
149 break; |
|
150 } |
|
151 MYLOCLOGSTRING ( "CLocationGeoTagTimerAO::RunL(), end" ); |
|
152 } |
|
153 |
|
154 // End of file |
|
155 |
|