|
1 /* |
|
2 * Copyright (c) 2005 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: Command expiration timer implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 #include "MediatorCommandTimer.h" |
|
22 #include "Debug.h" |
|
23 |
|
24 // CONSTANTS |
|
25 const TInt KMilliSeconds = 1000; |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CMediatorCommandTimer::CMediatorCommandTimer |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CMediatorCommandTimer::CMediatorCommandTimer() |
|
35 : CTimer( EPriorityNormal ) |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMediatorCommandTimer::ConstructL |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 void CMediatorCommandTimer::ConstructL() |
|
44 { |
|
45 CTimer::ConstructL(); |
|
46 CActiveScheduler::Add( this ); |
|
47 |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMediatorCommandTimer::NewL |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CMediatorCommandTimer* CMediatorCommandTimer::NewL() |
|
55 { |
|
56 CMediatorCommandTimer* self = new( ELeave ) CMediatorCommandTimer(); |
|
57 |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop( self ); |
|
61 |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMediatorCommandTimer::~CMediatorCommandTimer |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CMediatorCommandTimer::~CMediatorCommandTimer() |
|
70 { |
|
71 Cancel(); |
|
72 iCallBack = NULL; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CMediatorCommandTimer::RunL |
|
77 // |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CMediatorCommandTimer::RunL() |
|
82 { |
|
83 if ( iCallBack ) |
|
84 { |
|
85 iCallBack->TimerCallBack( iDomain, iCategory, iCommandId ); |
|
86 } |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CMediatorCommandTimer::StartTimer |
|
91 // |
|
92 // (other items were commented in a header). |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 TInt CMediatorCommandTimer::StartTimer( MMediatorTimerCallback* aCallBack, |
|
96 TUid aDomain, |
|
97 TUid aCategory, |
|
98 TInt aCommandId, |
|
99 TInt aInterval ) |
|
100 { |
|
101 TInt error = KErrNone; |
|
102 if ( IsActive() ) |
|
103 { |
|
104 ERROR_TRACE(Print(_L("[Mediator] CMediatorCommandTimer::StartTimer: failure, command %d in category %d of domain %d\n"), aCommandId, |
|
105 aCategory.iUid, |
|
106 aDomain.iUid )); |
|
107 error = KErrInUse; |
|
108 } |
|
109 else |
|
110 { |
|
111 iCallBack = aCallBack; |
|
112 iDomain = aDomain; |
|
113 iCategory = aCategory; |
|
114 iCommandId = aCommandId; |
|
115 CTimer::After( aInterval * KMilliSeconds ); |
|
116 } |
|
117 return error; |
|
118 } |
|
119 |
|
120 // End of File |