|
1 /* |
|
2 * Copyright (c) 2004-2006 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: Provides a comfort noise generator class |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <mmfformat.h> |
|
20 #include "sendstatemachine.h" |
|
21 #include "msrppayloadformatdefs.h" |
|
22 |
|
23 // MACROS |
|
24 |
|
25 // ============================= LOCAL FUNCTIONS =============================== |
|
26 |
|
27 // RECOMMENDED default time out value |
|
28 const TInt KDefaultTimeoutValue = 300000; |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CSendStateMachine::CSendStateMachine |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CSendStateMachine::CSendStateMachine( MSendStateObserver* aClient ) : |
|
38 iClient( aClient ) |
|
39 { |
|
40 DP_MSRP_WRITE( "CSendStateMachine::CSendStateMachine" ); |
|
41 iTimeOutValue = KDefaultTimeoutValue; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CSendStateMachine::ConstructL() |
|
46 // Symbian 2nd phase constructor can leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CSendStateMachine::ConstructL( ) |
|
50 { |
|
51 DP_MSRP_WRITE( "CSendStateMachine::ConstructL" ); |
|
52 |
|
53 // iTimer.CreateLocal(); |
|
54 User::LeaveIfNull( iClient ); |
|
55 iPeriodic = CPeriodic::NewL(0); |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CSendStateMachine::NewL |
|
61 // Static constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CSendStateMachine* CSendStateMachine::NewL( |
|
65 MSendStateObserver* aClient ) |
|
66 { |
|
67 DP_MSRP_WRITE( "CSendStateMachine::NewL" ); |
|
68 |
|
69 CSendStateMachine* self = |
|
70 new ( ELeave ) CSendStateMachine( aClient ); |
|
71 |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ------------------------------------------------------------------------------ |
|
80 // CSendStateMachine::~CSendStateMachine |
|
81 // Destructor |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CSendStateMachine::~CSendStateMachine( ) |
|
85 { |
|
86 DP_MSRP_WRITE( "CSendStateMachine::~CSendStateMachine" ); |
|
87 |
|
88 if (iPeriodic) |
|
89 { |
|
90 iPeriodic->Cancel (); |
|
91 delete iPeriodic; |
|
92 } |
|
93 |
|
94 iClient = NULL; |
|
95 } |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CSendStateMachine::SetTimeOut |
|
100 // SetTimeOut for periodic timer |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CSendStateMachine::SetTimeOut(TTimeIntervalMicroSeconds32 aValue) |
|
104 { |
|
105 DP_MSRP_WRITE( "CSendStateMachine::SetTimeOut" ); |
|
106 if (!iPeriodic->IsActive () ) |
|
107 { |
|
108 iTimeOutValue = aValue; |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CSendStateMachine::Start |
|
115 // Starts the PeriodicTimer |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CSendStateMachine::Start () |
|
119 { |
|
120 DP_MSRP_WRITE( "CSendStateMachine::Start" ); |
|
121 if (!iPeriodic->IsActive () ) |
|
122 { |
|
123 iPeriodic->Start(iTimeOutValue,iTimeOutValue,TCallBack(IdleCallBackL, this)); |
|
124 } |
|
125 |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CSendStateMachine::Cancel |
|
131 // Cancels the PeriodicTimer |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CSendStateMachine::Cancel () |
|
135 { |
|
136 DP_MSRP_WRITE( "CSendStateMachine::Cancel" ); |
|
137 iPeriodic->Cancel(); |
|
138 } |
|
139 |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CSendStateMachine::IdleCallBackL |
|
143 // IdleCallBackL is the callback function that actually calls |
|
144 // back clients TimerExpiredL function |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CSendStateMachine::IdleCallBackL (TAny* aPtr) |
|
148 { |
|
149 DP_MSRP_WRITE( "CSendStateMachine::IdleCallBackL" ); |
|
150 CSendStateMachine* me = ((CSendStateMachine*)aPtr); |
|
151 me->iClient->TimerExpiredL(); |
|
152 return ETrue; |
|
153 } |
|
154 |
|
155 // End of line |
|
156 |