|
1 /* |
|
2 * Copyright (c) 2004-2009 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: This module contains the implementation of CCbsRecWcdmaMessage |
|
15 * class member functions. |
|
16 * |
|
17 * CCbsRecWcdmaMessage represents a WCDMA message page generated |
|
18 * by CCbsRecEtelMonitor. CCbsRecWcdmaMessage is constructed from a |
|
19 * CB message page received from ETel server. |
|
20 * |
|
21 * |
|
22 */ |
|
23 |
|
24 |
|
25 |
|
26 // INCLUDE FILES |
|
27 |
|
28 #include <e32svr.h> |
|
29 #include "CCbsRecWcdmaMessage.h" |
|
30 #include "CbsServerPanic.h" |
|
31 #include "CbsLogger.h" |
|
32 |
|
33 // The empty message length. 1 octet is for page parameter |
|
34 const TInt KCbsRecWcdmaMessageMinLength = 1; |
|
35 // The maximum message length |
|
36 const TInt KCbsRecWcdmaMessageMaxLength = 82; |
|
37 // The value that use for parse the page parameter octet. |
|
38 const TInt KCbsRecWcdmaPageOfNumberMaskForLow4 = 0x000f; |
|
39 |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================================= |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CCbsRecWcdmaMessage::CCbsRecWcdmaMessage |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CCbsRecWcdmaMessage::CCbsRecWcdmaMessage( |
|
50 const RMobileBroadcastMessaging::TMobileBroadcastAttributesV2& aAttributes ) |
|
51 : iWcdmaAttributes( aAttributes ) |
|
52 { |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CCbsRecWcdmaMessage::CCbsRecWcdmaMessage |
|
57 // C++ default constructor can NOT contain any code, that |
|
58 // might leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CCbsRecWcdmaMessage::CCbsRecWcdmaMessage() |
|
62 { |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CCbsRecWcdmaMessage::ConstructL |
|
67 // Symbian 2nd phase constructor can leave. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CCbsRecWcdmaMessage::ConstructL( |
|
71 const TDes8& aMessagePage, // ETel received msg page |
|
72 const RMobileBroadcastMessaging::TMobileBroadcastAttributesV2& aAttributes ) |
|
73 { |
|
74 // Message attributes |
|
75 iTotalNumberOfPages = |
|
76 ( aAttributes.iNumberOfPages & KCbsRecWcdmaPageOfNumberMaskForLow4 ) ? |
|
77 ( aAttributes.iNumberOfPages & KCbsRecWcdmaPageOfNumberMaskForLow4 ) : 1; |
|
78 |
|
79 iMessageType = aAttributes.iMessageType; |
|
80 iMessageIdentifier = aAttributes.iMessageId; |
|
81 iSerialNumber = aAttributes.iSerialNum; |
|
82 iDCS = aAttributes.iDCS; |
|
83 |
|
84 // 16-bit representation not prepared. |
|
85 iMessage = NULL; |
|
86 // A buffer for the message contents. |
|
87 iMessage8 = HBufC8::NewL( RMobileBroadcastMessaging::KWCdmaBroadcastPageSize ); |
|
88 TPtr8 messagePtr = iMessage8->Des(); |
|
89 messagePtr.Trim(); |
|
90 |
|
91 TPtrC8 sourceMessagePtr; |
|
92 TInt msgLength = aMessagePage.Length(); |
|
93 CBSLOGSTRING2("CBSSERVER: CCbsRecWcdmaMessage::\ |
|
94 ConstructL(): msgLength: %d", msgLength ); |
|
95 |
|
96 // Message from ETel for 3G has no header and CTSY will append the page |
|
97 // parameter to the last of message. So the non-empty message's length |
|
98 // must more than 1 octet. The max length for one message page must |
|
99 // less than 82 octets. Additional octets will be omitted. |
|
100 if ( msgLength > KCbsRecWcdmaMessageMinLength ) |
|
101 { |
|
102 // Number of this page. Taken form the last byte of the message. |
|
103 // Max 15, therefore masked with 0xF |
|
104 iPageParameter = |
|
105 ( aMessagePage[ msgLength - KCbsRecWcdmaMessageMinLength ] |
|
106 & KCbsRecWcdmaPageOfNumberMaskForLow4 ) ? |
|
107 ( aMessagePage[ msgLength - KCbsRecWcdmaMessageMinLength ] |
|
108 & KCbsRecWcdmaPageOfNumberMaskForLow4 ) : 1; |
|
109 |
|
110 sourceMessagePtr.Set( aMessagePage.Left( msgLength - |
|
111 KCbsRecWcdmaMessageMinLength) ); |
|
112 |
|
113 if ( KCbsRecWcdmaMessageMaxLength < sourceMessagePtr.Length() ) |
|
114 { |
|
115 sourceMessagePtr.Set( aMessagePage.Left( |
|
116 KCbsRecWcdmaMessageMaxLength ) ); |
|
117 } |
|
118 } |
|
119 |
|
120 // Copy the TCbs page contents into this buffer. |
|
121 messagePtr.Copy( sourceMessagePtr ); |
|
122 |
|
123 // Indicate that we have no network info available |
|
124 iNetworkInfo.iCountryCode = KRecMessageNoNetworkInfo; |
|
125 |
|
126 // Set network mode |
|
127 iNetworkMode = ECbsNetworkWcdma; |
|
128 |
|
129 CBSLOGSTRING2("CBSSERVER: CCbsRecWcdmaMessage::ConstructL(): \ |
|
130 iTotalNumberOfPages: %d", iTotalNumberOfPages ); |
|
131 CBSLOGSTRING2("CBSSERVER: CCbsRecWcdmaMessage::ConstructL(): \ |
|
132 iSerialNumber: %d", iSerialNumber ); |
|
133 CBSLOGSTRING2("CBSSERVER: CCbsRecWcdmaMessage::ConstructL(): \ |
|
134 iMessageIdentifier: %d", iMessageIdentifier ); |
|
135 CBSLOGSTRING2("CBSSERVER: CCbsRecWcdmaMessage::ConstructL(): \ |
|
136 iDCS: %d", iDCS ); |
|
137 CBSLOGSTRING2("CBSSERVER: CCbsRecWcdmaMessage::ConstructL(): \ |
|
138 iPageParameter: %d", iPageParameter ); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CCbsRecWcdmaMessage::ConstructL |
|
143 // Symbian 2nd phase constructor can leave. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CCbsRecWcdmaMessage::ConstructL( const CCbsMessage& aMessage ) |
|
147 { |
|
148 // Message attributes |
|
149 iTotalNumberOfPages = aMessage.TotalPages(); |
|
150 iMessageType = (TUint8) aMessage.MessageType(); |
|
151 iMessageIdentifier = aMessage.TopicNumber(); |
|
152 iSerialNumber = aMessage.Key(); |
|
153 iDCS = aMessage.DCS(); |
|
154 // Number of this page, extracted from last octet of the message data |
|
155 iPageParameter = aMessage.PageParameter(); |
|
156 |
|
157 iLanguage = aMessage.Language(); |
|
158 |
|
159 // A buffer for the message contents. |
|
160 if ( aMessage.Message() ) |
|
161 { |
|
162 iMessage = HBufC::NewL( aMessage.Contents().Length() ); |
|
163 iMessage->Des().Copy( aMessage.Contents() ); |
|
164 } |
|
165 |
|
166 if ( aMessage.Message8() ) |
|
167 { |
|
168 iMessage8 = HBufC8::NewL( aMessage.Contents8().Length() ); |
|
169 TPtr8 messagePtr = iMessage8->Des(); |
|
170 messagePtr.Copy( aMessage.Contents8() ); |
|
171 } |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CCbsRecWcdmaMessage::NewL |
|
176 // Two-phased constructor. |
|
177 // Constructs a new CCbsRecWcdmaMessage based on TDes8& and message attributes |
|
178 // (which is a descriptor) received from EPOC Telephony Server. |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 CCbsRecWcdmaMessage* CCbsRecWcdmaMessage::NewL( |
|
182 const TDes8& aMessagePage, // page received from EPOC Telephony Server |
|
183 const RMobileBroadcastMessaging::TMobileBroadcastAttributesV2& aAttributes ) |
|
184 { |
|
185 CCbsRecWcdmaMessage* self = new ( ELeave ) CCbsRecWcdmaMessage( aAttributes ); |
|
186 CleanupStack::PushL( self ); |
|
187 self->ConstructL( aMessagePage, aAttributes ); |
|
188 CleanupStack::Pop( self ); |
|
189 return self; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CCbsRecWcdmaMessage::NewL |
|
194 // Two-phased constructor. |
|
195 // Constructs a new CCbsRecWcdmaMessage based on an existing message. |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 CCbsRecWcdmaMessage* CCbsRecWcdmaMessage::NewL( const CCbsMessage& aMessage ) |
|
199 { |
|
200 CCbsRecWcdmaMessage* self = new ( ELeave ) CCbsRecWcdmaMessage(); |
|
201 CleanupStack::PushL( self ); |
|
202 self->ConstructL( aMessage ); |
|
203 CleanupStack::Pop( self ); |
|
204 return self; |
|
205 } |
|
206 |
|
207 |
|
208 // Destructor |
|
209 CCbsRecWcdmaMessage::~CCbsRecWcdmaMessage() |
|
210 { |
|
211 CBSLOGSTRING("CBSSERVER: >>> CCbsRecWcdmaMessage::~CCbsRecWcdmaMessage()"); |
|
212 delete iMessage; |
|
213 delete iMessage8; |
|
214 CBSLOGSTRING("CBSSERVER: <<< CCbsRecWcdmaMessage::~CCbsRecWcdmaMessage()"); |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CCbsRecWcdmaMessage::ThisPage |
|
219 // Returns the page number of this page in the message page sequence |
|
220 // (other items were commented in a header). |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 TUint CCbsRecWcdmaMessage::ThisPage() const |
|
224 { |
|
225 return PageParameter(); |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CCbsRecWcdmaMessage::TotalPages |
|
230 // Returns the total number of pages in this page's message. |
|
231 // (other items were commented in a header). |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 TUint CCbsRecWcdmaMessage::TotalPages() const |
|
235 { |
|
236 return iTotalNumberOfPages; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CCbsRecWcdmaMessage::MessageType |
|
241 // Returns the message type of this message. |
|
242 // (other items were commented in a header). |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 TInt CCbsRecWcdmaMessage::MessageType() const |
|
246 { |
|
247 return iMessageType; |
|
248 } |
|
249 |
|
250 // End of File |