|
1 /* |
|
2 * Copyright (c) 2003 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 file contains the header file of the CCbsReceiverHelper class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCBSRECEIVERHELPER_H |
|
20 #define CCBSRECEIVERHELPER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "CbsCommon.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CCbsRecMessage; |
|
28 class CCbsServer; |
|
29 class CCbsDbImp; |
|
30 class CVwsSessionWrapper; |
|
31 class CCbsMessage; |
|
32 |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * CCbsReceiverHelper gets the messages from the receiver and |
|
38 * sends them to the database. All received messages are |
|
39 * sent to CCbsReceiverHelper instance by CCbsRecEtel. |
|
40 * This class makes subscription and existence checks |
|
41 * to these messages and also implements topic detection |
|
42 * feature. |
|
43 */ |
|
44 class CCbsReceiverHelper : public CBase |
|
45 { |
|
46 public: // New functions |
|
47 |
|
48 /** |
|
49 * Creates an instance of the class. |
|
50 * |
|
51 * @param aDatabase Database object. |
|
52 * @return New CCbsReceiverHelper instance. |
|
53 */ |
|
54 static CCbsReceiverHelper* NewL( CCbsDbImp& aDatabase ); |
|
55 |
|
56 /** |
|
57 * The destructor. |
|
58 */ |
|
59 ~CCbsReceiverHelper(); |
|
60 |
|
61 /** |
|
62 * Clears the topic detected counter. |
|
63 */ |
|
64 void ClearTopicsDetectedCounter(); |
|
65 |
|
66 /** |
|
67 * Returns the amount of detected topics. |
|
68 * |
|
69 * @return The amount of detected topics. |
|
70 */ |
|
71 TUint TopicsDetected() const; |
|
72 |
|
73 /** |
|
74 * This function is called when a message is received. |
|
75 * |
|
76 * Assumptions; |
|
77 * 1. The message doesn't have it's permanent or read |
|
78 * flags raised - method leaves with KErrNotSupported |
|
79 * if this is the case. |
|
80 * 2. If an index message (root or subindex) is passed as |
|
81 * a parameter, the language indication prefix, if any, |
|
82 * has been removed before HandleReceivedMessageL() is called. |
|
83 * |
|
84 * Assumption (2) holds because language indications are removed |
|
85 * by Receiver module in an instance of CCbsRecDecoder. |
|
86 * |
|
87 * Exceptions: |
|
88 * KErrNoMemory OOM occurred. |
|
89 * KErrNotSupported aMessage's flags were invalid. |
|
90 * KErrAlreadyExists aMessage is already stored in |
|
91 * the database. |
|
92 * |
|
93 * @param aMessage Interface to get the information |
|
94 * about the message. |
|
95 */ |
|
96 void HandleReceivedMessageL( CCbsMessage& aMessage ); |
|
97 |
|
98 /** |
|
99 * Checks if aMessage's topic is in the topic list. |
|
100 * If the topic detection is enabled and the aMessage's topic |
|
101 * is not in the list, the topic is added. The method |
|
102 * will then return ETrue. Otherwise EFalse is returned. |
|
103 * |
|
104 * @param aMessage Message page. |
|
105 * @return ETrue, if topic added |
|
106 */ |
|
107 TBool CheckForNewTopicL( const CCbsMessage& aMessage ); |
|
108 |
|
109 /** |
|
110 * Checks if aMessage's topic is subscribed and |
|
111 * if the message already exists in the database. |
|
112 * |
|
113 * Returns ETrue only if the message does not exist in the |
|
114 * database and the message's topic is subscribed. |
|
115 * |
|
116 * @param aMessage Message page. |
|
117 * @return ETrue, if message can be received |
|
118 */ |
|
119 TBool CheckForSubscriptionAndExistenceL( const CCbsMessage& aMessage ); |
|
120 |
|
121 /** |
|
122 * Checks if aMessage's language has been subscribed by the user. |
|
123 * |
|
124 * ETrue is returned either if the language specified has been |
|
125 * subscribed, message language is "Other" or the user has |
|
126 * preferred to receive messages of all languages. |
|
127 * |
|
128 * @param aMessage Message page |
|
129 * @return ETrue, if message can be received |
|
130 */ |
|
131 TBool LanguageOfMessageSubscribedL( const CCbsMessage& aMessage ); |
|
132 |
|
133 /** |
|
134 * Stores the CB topic (aNumber, aName) retrieved from |
|
135 * SIM into the DB. If a topic of the same number already exists |
|
136 * in DB, does nothing. |
|
137 * |
|
138 * @param aNumber Number of the topic. |
|
139 * @param aName Name of the topic. |
|
140 */ |
|
141 void AddSimTopicL( const TUint aNumber, const TDesC& aName ); |
|
142 |
|
143 /** |
|
144 * Returns a reference to the CCbsDbImp instance. |
|
145 * |
|
146 * @return Main database object. |
|
147 */ |
|
148 CCbsDbImp& Database() const; |
|
149 |
|
150 /** |
|
151 * Returns a reference to SIM Topic array |
|
152 * |
|
153 * @return SIM Topic array. |
|
154 */ |
|
155 CArrayFixFlat<TInt>& SimTopics() const; |
|
156 |
|
157 /** |
|
158 * Deletes a topic from the local SIM Topic array. |
|
159 * |
|
160 * @param aNumber Number of the topic. |
|
161 */ |
|
162 void DeleteFromSimTopicCache( const TUint16 aNumber ); |
|
163 |
|
164 /** |
|
165 * Requests a notification to be launched when a message |
|
166 * arrives to a hotmarked topic. |
|
167 * |
|
168 * @param aPlayTone Should the message alert tone be |
|
169 * played. |
|
170 */ |
|
171 void LaunchMessageSoftNotificationL( const TBool aPlayTone ); |
|
172 |
|
173 private: |
|
174 |
|
175 /** |
|
176 * The constructor. |
|
177 * |
|
178 * @param aDatabase Database object. |
|
179 * @param aServer Server object. |
|
180 */ |
|
181 CCbsReceiverHelper( CCbsDbImp& aDatabase ); |
|
182 |
|
183 /** |
|
184 Finalizes the construction. |
|
185 */ |
|
186 void ConstructL(); |
|
187 |
|
188 /** |
|
189 * Handles detected topic. |
|
190 * |
|
191 * @param iTopicNumber The number of the topic detected. |
|
192 * @return ETrue if the detected topic is added |
|
193 * to the topic list. EFalse otherwise. |
|
194 */ |
|
195 TBool HandleTopicDetectedL( const TCbsDbTopicNumber& iTopicNumber ); |
|
196 |
|
197 /** |
|
198 * Handles index message. Parses topic identities and |
|
199 * stores them into the database. |
|
200 * |
|
201 * Leave reasons: |
|
202 * KErrNoMemory OOM occured. |
|
203 * KErrNotSupported Index message was of unsupported |
|
204 * version. |
|
205 * KErrCorrupt Parsing of the index message failed. |
|
206 * |
|
207 * @param aContents Index message body. |
|
208 * @param aIsChildSubIndex ETrue, if child subindex. |
|
209 * EFalse, if root index. |
|
210 * @return Result code. |
|
211 */ |
|
212 void HandleIndexMessageL( const TDesC& aContents, |
|
213 const TBool aIsChildSubIndex ); |
|
214 |
|
215 /** |
|
216 * Parses all topic identities from aText which is assumed to be |
|
217 * an index message's content. |
|
218 * |
|
219 * Leave code values: |
|
220 * KErrNoMemory Storing of topic identities failed |
|
221 * because of insufficient memory. |
|
222 * KErrNotSupported Index message identifies itself as |
|
223 * an index of unknown type to the server. |
|
224 * KErrCorrupt A problem was encountered while parsing |
|
225 * the index message content. |
|
226 * KErrAlreadyExists Index message contained two or more |
|
227 * identities which shared the same topic |
|
228 * number. |
|
229 * |
|
230 * @param aText Index message body |
|
231 */ |
|
232 void ParseTopicIdentitiesL( const TDesC& aText ); |
|
233 |
|
234 /** |
|
235 * Requests a notification to be launched about a message that |
|
236 * requires immediate displaying. |
|
237 * |
|
238 * @param aMessage Message to be displayed |
|
239 */ |
|
240 void LaunchMessageImmediateDisplay( const TCbsDbMessage& aMessage ); |
|
241 |
|
242 /** |
|
243 * Turn lights on |
|
244 */ |
|
245 void TurnLightsOn(); |
|
246 |
|
247 /** |
|
248 * Play Cbs tone. |
|
249 */ |
|
250 void PlayCbsTone(); |
|
251 |
|
252 private: // Member variables |
|
253 |
|
254 // Reference to the database |
|
255 CCbsDbImp& iDatabase; |
|
256 |
|
257 // Number of topics detected after startup. |
|
258 TUint iTopicsDetected; |
|
259 |
|
260 CArrayFixFlat<TInt>* iSimTopics; |
|
261 |
|
262 // View server session wrapper. |
|
263 // Used to launch CBS UI application on arrival of |
|
264 // CB messages designated "requiring immediate display". |
|
265 CVwsSessionWrapper* iVwsSession; |
|
266 |
|
267 // Local variation bits, fetched from CenRep |
|
268 TInt iLVBits; |
|
269 }; |
|
270 |
|
271 #endif // CCBSRECEIVERHELPER_H |
|
272 |
|
273 // End of File |
|
274 |
|
275 |