|
1 /* |
|
2 * Copyright (c) 2004 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CCbsLivecastHandler.h" |
|
21 #include "CCbsRecMessage.h" |
|
22 #include "CCbsRecWcdmaMessage.h" |
|
23 #include "CCbsRecEtel.h" |
|
24 #include "CCbsRecCollector.h" |
|
25 #include "CCbsReceiverHelper.h" |
|
26 #include "CbsLogger.h" |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CCbsLivecastHandler::CCbsLivecastHandler |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CCbsLivecastHandler::CCbsLivecastHandler( CCbsRecEtel& aRecEtel ) |
|
37 : iRecEtel( aRecEtel ) |
|
38 { |
|
39 } |
|
40 |
|
41 // Destructor |
|
42 CCbsLivecastHandler::~CCbsLivecastHandler() |
|
43 { |
|
44 CBSLOGSTRING("CBSSERVER: >>> ~CCbsLivecastHandler::~CCbsLivecastHandler()"); |
|
45 CBSLOGSTRING("CBSSERVER: <<< ~CCbsLivecastHandler::~CCbsLivecastHandler()"); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CCbsLivecastHandler::NewL |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CCbsLivecastHandler* CCbsLivecastHandler::NewL( CCbsRecEtel& aRecEtel ) |
|
54 { |
|
55 CBSLOGSTRING("CBSSERVER: >>> CCbsLivecastHandler::NewL()"); |
|
56 |
|
57 CCbsLivecastHandler* self = new ( ELeave ) CCbsLivecastHandler( aRecEtel ); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop(); |
|
61 |
|
62 CBSLOGSTRING("CBSSERVER: <<< CCbsLivecastHandler::NewL()"); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CCbsLivecastHandler::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CCbsLivecastHandler::ConstructL() |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CCbsLivecastHandler::HandleLivecastMessageL |
|
77 // Processes the message. |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CCbsLivecastHandler::HandleLivecastMessageL( |
|
82 CCbsMessage* aLivecastMessage ) |
|
83 { |
|
84 CBSLOGSTRING("CBSSERVER: >>> CCbsLivecastHandler::HandleLivecastMessageL()"); |
|
85 |
|
86 // Take ownership |
|
87 CleanupStack::PushL( aLivecastMessage ); |
|
88 |
|
89 // Check if this message must be rejected: |
|
90 // 1. Is message compressed |
|
91 // 2. Is message defined as 'Class 2' or 'Class 3' message |
|
92 |
|
93 TInt msgclass ( aLivecastMessage->MessageClass() ); |
|
94 |
|
95 if ( aLivecastMessage->IsCompressed() || |
|
96 msgclass == 3 || msgclass == 2 ) |
|
97 { |
|
98 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Rejected, compressed/msg class."); |
|
99 |
|
100 // Reject the message |
|
101 CleanupStack::PopAndDestroy(); // aLivecastMessage |
|
102 } |
|
103 else |
|
104 { |
|
105 // Add network information to message |
|
106 TInt error = iRecEtel.AddNetworkInfo( *aLivecastMessage ); |
|
107 |
|
108 CBSLOGSTRING2("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): AddNetworkInfo() error: %d", error ); |
|
109 |
|
110 // Handle the message |
|
111 // Is message multipaged |
|
112 if ( aLivecastMessage->TotalPages() > 1 ) |
|
113 { |
|
114 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Message multipaged."); |
|
115 |
|
116 // Ensure that the network info is available. |
|
117 // If not, reject the message, because info is required to collect |
|
118 // pages of a multipaged message. |
|
119 if ( KErrNone != error ) |
|
120 { |
|
121 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Message rejected, AddNetworkInfo() error."); |
|
122 CleanupStack::PopAndDestroy( aLivecastMessage ); |
|
123 } |
|
124 else |
|
125 { |
|
126 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Sending msg to Collector..."); |
|
127 |
|
128 // Ownership of aLivecastMessage transferred to collector with |
|
129 // aLivecastMessage left on the cleanup stack. |
|
130 CCbsMessage* completedMsg = iRecEtel.Collector().CollectL( aLivecastMessage, ECbsMessageLivecast ); |
|
131 |
|
132 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Collector finished."); |
|
133 |
|
134 if ( completedMsg ) |
|
135 { |
|
136 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Msg collected."); |
|
137 |
|
138 // Message pages combined => Handle like a single-paged msg. |
|
139 // Result code ignored. |
|
140 CleanupStack::PushL( completedMsg ); |
|
141 |
|
142 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Routing msg to RecEtel..."); |
|
143 iRecEtel.RouteMessageL( *completedMsg ); |
|
144 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Routing finished."); |
|
145 |
|
146 CleanupStack::PopAndDestroy( completedMsg ); |
|
147 } |
|
148 } |
|
149 } |
|
150 // Message is single paged |
|
151 else |
|
152 { |
|
153 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Message single paged."); |
|
154 |
|
155 iRecEtel.RouteMessageL( *aLivecastMessage ); |
|
156 CBSLOGSTRING("CBSSERVER: CCbsLivecastHandler::HandleLivecastMessageL(): Single paged RouteMessageL() OK."); |
|
157 |
|
158 CleanupStack::PopAndDestroy( aLivecastMessage ); |
|
159 } |
|
160 } |
|
161 CBSLOGSTRING("CBSSERVER: <<< CCbsLivecastHandler::HandleLivecastMessageL()"); |
|
162 } |
|
163 |
|
164 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
165 |
|
166 // End of File |