|
1 /* |
|
2 * Copyright (c) 2007 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: TCUtil class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "tcutil.h" |
|
20 #include "tcstate.h" |
|
21 #include "common.h" |
|
22 |
|
23 // LOCAL DEFINITIONS |
|
24 |
|
25 namespace TiltSSY |
|
26 { |
|
27 // CONSTANTS |
|
28 |
|
29 /** State types as descriptor */ |
|
30 _LIT( KStateTypeTilt, "TILT" ); |
|
31 |
|
32 /** States as descriptor */ |
|
33 _LIT( KStateIdle, "IDLE" ); |
|
34 _LIT( KStateOpen, "OPEN" ); |
|
35 _LIT( KStateListenData, "LISTEN DATA" ); |
|
36 _LIT( KStateBufferFull, "BUFFER FULL" ); |
|
37 _LIT( KStateClosing, "CLOSING" ); |
|
38 _LIT( KStateInvalid, "INVALID" ); |
|
39 _LIT( KStateNull, "NULL" ); |
|
40 |
|
41 /** Event as descriptor */ |
|
42 _LIT( KEventIdHandleOpenChannel, "EEventIdHandleOpenChannel" ); |
|
43 _LIT( KEventIdHandleCloseChannel, "EEventIdHandleCloseChannel" ); |
|
44 _LIT( KEventIdHandleStartChannelData, "EEventIdHandleStartChannelData" ); |
|
45 _LIT( KEventIdHandleStopChannelData, "EEventIdHandleStopChannelData" ); |
|
46 _LIT( KEventIdHandleForceBufferFull, "EEventIdHandleForceBufferFull" ); |
|
47 _LIT( KEventIdHandleAccelerometer, "EEventIdHandleForceBufferFull" ); |
|
48 _LIT( KEventIdHandleMagnetometer, "EEventIdHandleMagnetometer" ); |
|
49 _LIT( KEventIdHandlePropertyChanged, "EEventIdHandlePropertyChanged" ); |
|
50 _LIT( KEventIdHandleTimerExpired, "EEventIdHandleTimerExpired" ); |
|
51 _LIT( KEventIdInvalid, "INVALID EVENT ID!" ); |
|
52 |
|
53 /** Trasaction as descriptor */ |
|
54 _LIT( KTCTransactionIdOpenChannel, "ETCTransactionIdOpenChannel" ); |
|
55 _LIT( KTCTransactionIdCloseChannel, "ETCTransactionIdCloseChannel" ); |
|
56 _LIT( KTCTransactionIdStartChannelData, "ETCTransactionIdStartChannelData" ); |
|
57 _LIT( KTCTransactionIdStopChannelData, "ETCTransactionIdStopChannelData" ); |
|
58 _LIT( KTCTransactionIdFlushBuffer, "ETCTransactionIdFlushBuffer" ); |
|
59 _LIT( KTCTransactionIdInvalid, "INVALID TRANSACTION ID!" ); |
|
60 } |
|
61 |
|
62 // Converts state type as descriptor |
|
63 const TDesC& TCUtil::StateTypeAsDesC( CTCState* aState ) |
|
64 { |
|
65 if( aState ) |
|
66 { |
|
67 switch( aState->Type() ) |
|
68 { |
|
69 case CTCState::ETCStateTypeTilt: |
|
70 { |
|
71 return TiltSSY::KStateTypeTilt; |
|
72 } |
|
73 default: |
|
74 { |
|
75 return TiltSSY::KStateInvalid; |
|
76 } |
|
77 } |
|
78 } |
|
79 return TiltSSY::KStateNull; |
|
80 } |
|
81 |
|
82 // Converts state ID to descriptor |
|
83 const TDesC& TCUtil::StateIdAsDesC( CTCState* aState ) |
|
84 { |
|
85 if( aState ) |
|
86 { |
|
87 switch( aState->Id() ) |
|
88 { |
|
89 case CTCState::ETCStateIdle: |
|
90 { |
|
91 return TiltSSY::KStateIdle; |
|
92 } |
|
93 case CTCState::ETCStateOpen: |
|
94 { |
|
95 return TiltSSY::KStateOpen; |
|
96 } |
|
97 case CTCState::ETCStateListenData: |
|
98 { |
|
99 return TiltSSY::KStateListenData; |
|
100 } |
|
101 case CTCState::ETCStateBufferFull: |
|
102 { |
|
103 return TiltSSY::KStateBufferFull; |
|
104 } |
|
105 case CTCState::ETCStateClosing: |
|
106 { |
|
107 return TiltSSY::KStateClosing; |
|
108 } |
|
109 default: |
|
110 { |
|
111 return TiltSSY::KStateInvalid; |
|
112 } |
|
113 } |
|
114 } |
|
115 |
|
116 return TiltSSY::KStateNull; |
|
117 } |
|
118 |
|
119 // Converts event ID to descriptor |
|
120 const TDesC& TCUtil::EventIdAsDesC( TTCEventId aId ) |
|
121 { |
|
122 switch( aId ) |
|
123 { |
|
124 case EEventIdHandleOpenChannel: |
|
125 { |
|
126 return TiltSSY::KEventIdHandleOpenChannel; |
|
127 } |
|
128 case EEventIdHandleCloseChannel: |
|
129 { |
|
130 return TiltSSY::KEventIdHandleCloseChannel; |
|
131 } |
|
132 case EEventIdHandleStartChannelData: |
|
133 { |
|
134 return TiltSSY::KEventIdHandleStartChannelData; |
|
135 } |
|
136 case EEventIdHandleStopChannelData: |
|
137 { |
|
138 return TiltSSY::KEventIdHandleStopChannelData; |
|
139 } |
|
140 case EEventIdHandleForceBufferFull: |
|
141 { |
|
142 return TiltSSY::KEventIdHandleForceBufferFull; |
|
143 } |
|
144 case EEventIdHandleAccelerometer: |
|
145 { |
|
146 return TiltSSY::KEventIdHandleAccelerometer; |
|
147 } |
|
148 case EEventIdHandleMagnetometer: |
|
149 { |
|
150 return TiltSSY::KEventIdHandleMagnetometer; |
|
151 } |
|
152 case EEventIdHandlePropertyChanged: |
|
153 { |
|
154 return TiltSSY::KEventIdHandlePropertyChanged; |
|
155 } |
|
156 case EEventIdHandleTimerExpriredSend: |
|
157 { |
|
158 return TiltSSY::KEventIdHandleTimerExpired; |
|
159 } |
|
160 case EEventIdNull: |
|
161 // Fall through |
|
162 default: |
|
163 { |
|
164 return TiltSSY::KEventIdInvalid; |
|
165 } |
|
166 } |
|
167 |
|
168 } |
|
169 |
|
170 // Converts transaction ID to descriptor |
|
171 const TDesC& TCUtil::TransactionIdAsDesC( TTCTransactionId aId ) |
|
172 { |
|
173 switch( aId ) |
|
174 { |
|
175 case ETCTransactionIdOpenChannel: |
|
176 { |
|
177 return TiltSSY::KTCTransactionIdOpenChannel; |
|
178 } |
|
179 case ETCTransactionIdCloseChannel: |
|
180 { |
|
181 return TiltSSY::KTCTransactionIdCloseChannel; |
|
182 } |
|
183 case ETCTransactionIdStartChannelData: |
|
184 { |
|
185 return TiltSSY::KTCTransactionIdStartChannelData; |
|
186 } |
|
187 case ETCTransactionIdStopChannelData: |
|
188 { |
|
189 return TiltSSY::KTCTransactionIdStopChannelData; |
|
190 } |
|
191 case ETCTransactionIdFlushBuffer: |
|
192 { |
|
193 return TiltSSY::KTCTransactionIdFlushBuffer; |
|
194 } |
|
195 case ETCTransactionIdNull: |
|
196 // Fall through |
|
197 default: |
|
198 { |
|
199 return TiltSSY::KTCTransactionIdInvalid; |
|
200 } |
|
201 } |
|
202 } |
|
203 |
|
204 // End of File |