|
1 /* |
|
2 * Copyright (c) 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: CSsyOrientationEventTimer class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "Ssyeventtimer.h" |
|
20 #include "SsyTrace.h" |
|
21 |
|
22 const TInt KOneMilSecondInMicroSeconds( 1000 ); |
|
23 |
|
24 // ---------------------------------------------------------------------------------- |
|
25 // CSsyOrientationEventTimer::CSsyOrientationEventTimer |
|
26 // ---------------------------------------------------------------------------------- |
|
27 // |
|
28 CSsyOrientationEventTimer::CSsyOrientationEventTimer( MSendDataCallBack& |
|
29 aPrtToCallback ) : |
|
30 CActive( CActive::EPriorityHigh ), |
|
31 iCallBack( aPrtToCallback ) |
|
32 { |
|
33 SSY_TRACE_IN(); |
|
34 CActiveScheduler::Add( this ); |
|
35 SSY_TRACE_OUT(); |
|
36 } |
|
37 |
|
38 // ---------------------------------------------------------------------------------- |
|
39 // CSsyOrientationEventTimer::~CSsyOrientationEventTimer |
|
40 // ---------------------------------------------------------------------------------- |
|
41 // |
|
42 CSsyOrientationEventTimer::~CSsyOrientationEventTimer() // destruct - virtual, so no export |
|
43 { |
|
44 SSY_TRACE_IN(); |
|
45 if( IsActive() ) |
|
46 { |
|
47 Cancel(); |
|
48 } |
|
49 iTimer.Close(); |
|
50 SSY_TRACE_OUT(); |
|
51 } |
|
52 |
|
53 // ---------------------------------------------------------------------------------- |
|
54 // CSsyOrientationEventTimer::NewL |
|
55 // ---------------------------------------------------------------------------------- |
|
56 // |
|
57 CSsyOrientationEventTimer* CSsyOrientationEventTimer::NewL( TInt aSetTimerToMilSeconds, |
|
58 MSendDataCallBack& aPrtToCallback ) |
|
59 { |
|
60 SSY_TRACE_IN(); |
|
61 |
|
62 CSsyOrientationEventTimer* self = new |
|
63 ( ELeave ) CSsyOrientationEventTimer( aPrtToCallback ); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL( aSetTimerToMilSeconds ); |
|
66 CleanupStack::Pop( self ); |
|
67 SSY_TRACE_OUT(); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------------- |
|
72 // CSsyOrientationEventTimer::ConstructL |
|
73 // ---------------------------------------------------------------------------------- |
|
74 // |
|
75 void CSsyOrientationEventTimer::ConstructL( TInt aSetTimerToMilSeconds ) |
|
76 { |
|
77 SSY_TRACE_IN(); |
|
78 User::LeaveIfError( iTimer.CreateLocal() ); |
|
79 if( aSetTimerToMilSeconds < 0 ) |
|
80 { |
|
81 User::Leave( KErrArgument ); |
|
82 } |
|
83 TTimeIntervalMicroSeconds32 interval( KOneMilSecondInMicroSeconds * |
|
84 aSetTimerToMilSeconds ); |
|
85 |
|
86 iTimer.After( iStatus, interval ); |
|
87 SetActive(); |
|
88 SSY_TRACE_OUT(); |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------------- |
|
92 // CSsyOrientationEventTimer::RunL |
|
93 // ---------------------------------------------------------------------------------- |
|
94 // |
|
95 void CSsyOrientationEventTimer::RunL() |
|
96 { |
|
97 SSY_TRACE_IN(); |
|
98 iCallBack.SendDataAfterTimer(); |
|
99 SSY_TRACE_OUT(); |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------------------------------------- |
|
103 // CSsyOrientationEventTimer::DoCancel |
|
104 // ---------------------------------------------------------------------------------- |
|
105 // |
|
106 void CSsyOrientationEventTimer::DoCancel() |
|
107 { |
|
108 SSY_TRACE_IN(); |
|
109 iTimer.Cancel(); |
|
110 SSY_TRACE_OUT(); |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------------- |
|
114 // CSsyOrientationEventTimer::RunError |
|
115 // ---------------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CSsyOrientationEventTimer::RunError( TInt aError ) |
|
118 { |
|
119 SSY_TRACE_IN(); |
|
120 if( aError != KErrNone ) |
|
121 { |
|
122 SSY_TRACE( EExtended, "CSsyOrientationEventTimer::RunError aError=%d", aError ); |
|
123 } |
|
124 SSY_TRACE_OUT(); |
|
125 return KErrNone; |
|
126 } |
|
127 |
|
128 // End of file |