|
1 /* |
|
2 * Copyright (c) 2010 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 * Interface for cbs client. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef MCBS_H |
|
21 #define MCBS_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <CbsCommon.h> |
|
25 |
|
26 /** |
|
27 * Interface MCbs is used to change real client server |
|
28 * connection to some test stub implementation. |
|
29 */ |
|
30 class MCbs |
|
31 { |
|
32 public: |
|
33 |
|
34 /** |
|
35 * Destructor. |
|
36 */ |
|
37 virtual ~MCbs() {} |
|
38 |
|
39 /** |
|
40 * Creates connection to the server. |
|
41 * |
|
42 * Note that the method must be called before calling any other |
|
43 * methods. The method returns an error code and, therefore, |
|
44 * the caller is responsible of checking that everything went just |
|
45 * fine. |
|
46 * |
|
47 * @return Error code. |
|
48 */ |
|
49 virtual TInt Connect() = 0; |
|
50 |
|
51 /** |
|
52 * Closes the session to the server. |
|
53 */ |
|
54 virtual void Close() = 0; |
|
55 |
|
56 /** |
|
57 * Returns the version of CbsClient. |
|
58 * |
|
59 * CbsServer and CbsClient must be of same version. |
|
60 * |
|
61 * @return Returns the version of CbsClient. |
|
62 */ |
|
63 virtual TVersion Version() const = 0; |
|
64 |
|
65 // === Settings-related methods |
|
66 |
|
67 /** |
|
68 * Returns the reception status in aStatus, which is ETrue if the reception is |
|
69 * on. Otherwise it is EFalse. |
|
70 * |
|
71 * @param aStatus The method returns the reception status in this parameter. |
|
72 */ |
|
73 virtual void GetReceptionStatus( TBool& aStatus ) = 0; |
|
74 |
|
75 /** |
|
76 * Changes the reception status to aStatus. |
|
77 * |
|
78 * @param aStatus It contains the new reception status. |
|
79 * @return Error code. |
|
80 */ |
|
81 virtual TInt SetReceptionStatus( TBool aStatus ) = 0; |
|
82 |
|
83 /** |
|
84 * Returns the topic detection status in aStatus, which is ETrue if the detection |
|
85 * is on. Otherwise it is EFalse. |
|
86 * |
|
87 * @param aStatus The method returns the topic detection status in this parameter. |
|
88 */ |
|
89 virtual void GetTopicDetectionStatus( TBool& aStatus ) = 0; |
|
90 |
|
91 /** |
|
92 * Changes the topic detection status to aStatus. |
|
93 * |
|
94 * @param aStatus It contains the new topic detection status. |
|
95 * @return Error code. |
|
96 */ |
|
97 virtual TInt SetTopicDetectionStatus( TBool aStatus ) = 0; |
|
98 |
|
99 /** |
|
100 * Returns the preferred languages in aLanguages. |
|
101 * |
|
102 * @param aLanguages The method returns the languages in this parameter. |
|
103 */ |
|
104 virtual void GetLanguages( TCbsSettingsLanguages& aLanguages ) = 0; |
|
105 |
|
106 /** |
|
107 * Changes the preferred languages to aLanguages. |
|
108 * |
|
109 * @param aLanguages It contains the new preferred languages. |
|
110 * @return Error code. |
|
111 */ |
|
112 virtual TInt SetLanguages( const TCbsSettingsLanguages& aLanguages ) = 0; |
|
113 |
|
114 /** |
|
115 * Requests the server to notify the client whenever any settings will be |
|
116 * changed. |
|
117 * |
|
118 * Note that for each subsession only one this kind of request can be pending. Each |
|
119 * client is responsible of assuring this. |
|
120 * |
|
121 * @param aStatus It is the variable that the server will modify whenever an event occurs. |
|
122 * @param aEvent The server will store the type of occurred event to this variable. |
|
123 */ |
|
124 virtual void NotifySettingsChanged( TRequestStatus& aStatus, TCbsSettingsEvent& aEvent ) = 0; |
|
125 |
|
126 /** |
|
127 * Cancels the request to notify the client. |
|
128 */ |
|
129 virtual void NotifySettingsChangedCancel() = 0; |
|
130 |
|
131 // === Topic Collection-related methods |
|
132 |
|
133 /** |
|
134 * Resets the iterator. Must be called prior any call to HasNextTopic() |
|
135 * or NextTopic()! |
|
136 */ |
|
137 virtual void StartCollectionBrowsing() = 0; |
|
138 |
|
139 /** |
|
140 * Returns ETrue, if there is a topic not accessed with NextTopic() |
|
141 * |
|
142 * @return ETrue, if there is a topic. EFalse if the end of the collection |
|
143 * has been reached. |
|
144 */ |
|
145 virtual TBool HasNextCollectionTopic() = 0; |
|
146 |
|
147 /** |
|
148 * Returns the next topic in the topic collection skipping all topics with |
|
149 * a topic number matching a topic already listed in the current topic list. |
|
150 * This function will return KErrNotFound if the collection is tried to |
|
151 * access beyond the end of the list. Otherwise the error code will be |
|
152 * the same returned by GetTopicInfo(). |
|
153 * |
|
154 * @param aInfo The topic information will be stored here. |
|
155 * @return The error code. KErrNotFound if there are no topics left. |
|
156 */ |
|
157 virtual TInt NextCollectionTopic( TCbsTopicInfo& aInfo ) = 0; |
|
158 |
|
159 // === Topic list-related methods |
|
160 |
|
161 /** |
|
162 * Returns the total amount of topics the topic list contains. |
|
163 * |
|
164 * @param aCount It will contain the total amount of topics. |
|
165 */ |
|
166 virtual void GetTopicCount( TInt& aCount ) = 0; |
|
167 |
|
168 /** |
|
169 * Returns information about a topic from the topic list. |
|
170 * |
|
171 * Return values: |
|
172 * KErrArgument Topic was not found. |
|
173 * |
|
174 * Rest of return values indicate a file error. |
|
175 * |
|
176 * @param aIndex It is the index to the topic. |
|
177 * @param aTopic It will contain the topic information. |
|
178 * @return Error code. |
|
179 */ |
|
180 virtual TInt GetTopic( const TInt aIndex, TCbsTopic& aTopic ) = 0; |
|
181 |
|
182 /** |
|
183 * Finds the topic by the given number. |
|
184 * |
|
185 * Return values: |
|
186 * KErrNone Topic returned in parameter aTopic. |
|
187 * KErrNotFound Topic was not found. |
|
188 * |
|
189 * @param aNumber Number of the topic |
|
190 * @param aTopic Return: contains the topic information |
|
191 * @return Error code |
|
192 */ |
|
193 virtual TInt FindTopicByNumber( TCbsTopicNumber aNumber, |
|
194 TCbsTopic& aTopic ) = 0; |
|
195 |
|
196 /** |
|
197 * Deletes an existing topic. |
|
198 * |
|
199 * @param aNumber Number of the topic to be deleted |
|
200 * @return Error code |
|
201 */ |
|
202 virtual TInt DeleteTopic( TCbsTopicNumber aNumber ) = 0; |
|
203 |
|
204 /** |
|
205 * Delete all topics. |
|
206 * |
|
207 * @return Error code. |
|
208 */ |
|
209 virtual TInt DeleteAllTopics() = 0; |
|
210 |
|
211 /** |
|
212 * Adds a new topic. The handle assigned to the topic will be returned |
|
213 * in aTopic. |
|
214 * |
|
215 * Return values: |
|
216 * KErrNone Topic was successfully added. |
|
217 * KErrAlreadyExists A topic of the same number already exists in DB |
|
218 * KErrArgument Topic number given was not in a proper range. |
|
219 * KErrDiskFull Topic not added - FFS out of space |
|
220 * |
|
221 * Note that the number of the new topic must be unused. |
|
222 * |
|
223 * @param aTopic Contains the information of the new topic. |
|
224 * On return, aTopic also contains the topic |
|
225 * handle. |
|
226 * @return Error code. |
|
227 */ |
|
228 virtual TInt AddTopic( TCbsTopic& aTopic ) = 0; |
|
229 |
|
230 /** |
|
231 * Changes the name and number of the existing topic. |
|
232 * |
|
233 * Note that the changing fails in case there is another topic with |
|
234 * the new topic number. It also fails if the topic is protected. |
|
235 * |
|
236 * Return values: |
|
237 * KErrNone Topic name and number successfully changed. |
|
238 * KErrDiskFull Topic information not changed - FFS out of space |
|
239 * |
|
240 * @param aOldNumber Number of the topic to be changed |
|
241 * @param aNewNumber Number to be given for the topic |
|
242 * @param aName Name to be given for the topic |
|
243 * @return Error code |
|
244 */ |
|
245 virtual TInt ChangeTopicNameAndNumber( |
|
246 TCbsTopicNumber aOldNumber, |
|
247 TCbsTopicNumber aNewNumber, |
|
248 const TCbsTopicName& aName ) = 0; |
|
249 |
|
250 /** |
|
251 * Changes topic subscription status. |
|
252 * |
|
253 * @param aNumber Number of the topic |
|
254 * @param aNewStatus New subscription status |
|
255 * @return Error code |
|
256 */ |
|
257 virtual TInt ChangeTopicSubscriptionStatus( |
|
258 TCbsTopicNumber aNumber, TBool aNewStatus ) = 0; |
|
259 |
|
260 /** |
|
261 * Changes topic hotmark status. |
|
262 * |
|
263 * @param aNumber Number of the topic |
|
264 * @param aNewStatus New hotmark status |
|
265 * @return Error code |
|
266 */ |
|
267 virtual TInt ChangeTopicHotmarkStatus( TCbsTopicNumber aNumber, |
|
268 TBool aNewStatus ) = 0; |
|
269 |
|
270 /** |
|
271 * Requests the server to notify the client whenever an event occurs |
|
272 * that changes the information of the topics. |
|
273 * |
|
274 * Note that the client may select what kind of events it is |
|
275 * interested in. Note also that there can be at most one pending |
|
276 * request per instance of the class. |
|
277 * |
|
278 * @param aStatus The variable that the server will modify |
|
279 * whenever an event occurs. |
|
280 * @param aRequested Events the client is interested in |
|
281 * @param aEvent Indicates the variable that will contain the |
|
282 * type of event that occured. |
|
283 * @param aNumber Indicates the variable that will contain the |
|
284 * topic number that was changed in event. |
|
285 */ |
|
286 virtual void NotifyOnTopicListEvent( |
|
287 TRequestStatus& aStatus, |
|
288 const TInt aRequested, |
|
289 TCbsTopicListEvent& aEvent, |
|
290 TCbsTopicNumber& aNumber ) = 0; |
|
291 |
|
292 /** |
|
293 * Cancels the pending notify request. |
|
294 */ |
|
295 virtual void NotifyOnTopicListEventCancel() = 0; |
|
296 |
|
297 /** |
|
298 * Returns the number of topics added since last GetNewTopicsCount() |
|
299 * by the topic detection feature. |
|
300 * |
|
301 * @param aCount It will contain the amount of new topics. |
|
302 * @return TInt Result code. |
|
303 */ |
|
304 virtual TInt GetNewTopicsCount( TInt& aCount ) = 0; |
|
305 |
|
306 /** |
|
307 * Returns the number of the topic which was last added |
|
308 * to topic list. |
|
309 * |
|
310 * Note: if a topic list cache is maintained by the client |
|
311 * (as CBS UI application does), this function has to |
|
312 * be called BEFORE calling GetTopicCount() and GetTopic() |
|
313 * to make sure that no topic is added in between |
|
314 * GetTopic() and GetLatestTopicHandle() calls. If this |
|
315 * happens, GetLatestTopicHandle() will return a handle |
|
316 * to a topic that is not cached client-side. |
|
317 * |
|
318 * Return codes: |
|
319 * KErrNone aNumber is a valid topic number. |
|
320 * KErrNotFound No topic added since server start, |
|
321 * aNumber is not valid. |
|
322 * |
|
323 * @param aNumber Returns: number of the topic last added |
|
324 * @return Result code |
|
325 */ |
|
326 virtual TInt GetLatestTopicNumber( TCbsTopicNumber& aNumber ) = 0; |
|
327 |
|
328 /** |
|
329 * Returns the total amount of unread messages. |
|
330 * |
|
331 * @param aCount Return: number of unread messages |
|
332 */ |
|
333 virtual void GetUnreadMessageCount( TInt& aCount ) = 0; |
|
334 |
|
335 /** |
|
336 * Returns the handle to the latest hotmarked message that has been |
|
337 * received after the system has started up. |
|
338 * |
|
339 * @param aMessage Handle to the message |
|
340 */ |
|
341 virtual void GetHotmarkedMessageHandle( TCbsMessageHandle& aMessage ) = 0; |
|
342 |
|
343 /** |
|
344 * Returns the number of unread messages in hotmarked topics. |
|
345 * |
|
346 * This function is to used by the client when deciding whether |
|
347 * the message or topic list view should be opened to display |
|
348 * a hotmarked message(s). |
|
349 * |
|
350 * @return Number of unread hotmarked messages |
|
351 */ |
|
352 virtual TInt NumberOfUnreadHotmarkedMessages() = 0; |
|
353 |
|
354 /** |
|
355 * Returns the numbers of topics that precede and succeed the given |
|
356 * topic in server-side topic list. |
|
357 * |
|
358 * If the given topic is the first topic in list, aPosition has |
|
359 * ECbsHead bit up. If the given topic is the last topic in list, |
|
360 * aPosition has ECbsTail bit up. |
|
361 * |
|
362 * Return code values: |
|
363 * KErrNone aPrevTopicNumber, aNextTopicNumber and aPosition |
|
364 * contain valid values. |
|
365 * KErrNotFound aCurrentTopicNumber specified a topic that was not |
|
366 * on topic list. |
|
367 * |
|
368 * @param aCurrentTopicNumber Number that specifies the topic |
|
369 * whose surroundings are returned |
|
370 * @param aPrevTopicNumber Returns: number of topic preceding |
|
371 * the given topic |
|
372 * @param aNextTopicNumber Returns: number of topic succeeding |
|
373 * the given topic |
|
374 * @param aPosition Returns: position of current |
|
375 * topic in list. |
|
376 * @return Result code |
|
377 */ |
|
378 virtual TInt GetNextAndPrevTopicNumber( |
|
379 const TCbsTopicNumber& aCurrentTopicNumber, |
|
380 TCbsTopicNumber& aPrevTopicNumber, |
|
381 TCbsTopicNumber& aNextTopicNumber, |
|
382 TInt& aPosition ) = 0; |
|
383 |
|
384 // === Topic Messages-related methods |
|
385 |
|
386 /** |
|
387 * Returns the total amount of messages the topic contains. |
|
388 * |
|
389 * Return codes: |
|
390 * KErrNotFound Invalid handle. |
|
391 * KErrNone aCount contains the number of messages |
|
392 * in topic |
|
393 * |
|
394 * @param aNumber Number of the topic. |
|
395 * @param aCount Number of messages in given topic. |
|
396 * @return Result code |
|
397 */ |
|
398 virtual TInt GetMessageCount( TCbsTopicNumber aNumber, |
|
399 TInt& aCount ) = 0; |
|
400 |
|
401 /** |
|
402 * Returns message information. |
|
403 * |
|
404 * Return codes: |
|
405 * KErrNotFound Topic or message not found. |
|
406 * KErrNone aMessage contains the message information. |
|
407 * |
|
408 * @param aNumber Number of the topic |
|
409 * @param aIndex Index to the message in topic. |
|
410 * @param aMessage Returns: the message information |
|
411 * @return Error code |
|
412 */ |
|
413 virtual TInt GetMessage( TCbsTopicNumber aNumber, TInt aIndex, |
|
414 TCbsMessage& aMessage ) = 0; |
|
415 |
|
416 /** |
|
417 * Finds a message by given handle. |
|
418 * |
|
419 * @param aHandle Handle to the message. |
|
420 * @param aMessage Return: contains the message information. |
|
421 * @return Error code. |
|
422 */ |
|
423 virtual TInt FindMessageByHandle( |
|
424 const TCbsMessageHandle& aHandle, |
|
425 TCbsMessage& aMessage ) = 0; |
|
426 |
|
427 /** |
|
428 * Returns the index of a message with given handle in topic. |
|
429 * |
|
430 * Result code KErrNotFound indicates that no message was found with |
|
431 * the given handle. |
|
432 * |
|
433 * @param aHandle Handle of the message |
|
434 * @param aIndex Return: index of the message in message topic |
|
435 * @return Result code |
|
436 */ |
|
437 virtual TInt GetMessageIndexByHandle( |
|
438 const TCbsMessageHandle& aHandle, TInt& aIndex ) = 0; |
|
439 |
|
440 /** |
|
441 * Deletes an existing message. |
|
442 * |
|
443 * Note that it does not care a lot about the status of the message. |
|
444 * |
|
445 * Please check also the description of LockMessage(). |
|
446 * |
|
447 * @param aHandle It is handle to the message. |
|
448 * @return Error code. |
|
449 */ |
|
450 virtual TInt DeleteMessage( const TCbsMessageHandle& aHandle ) = 0; |
|
451 |
|
452 /** |
|
453 * Saves a message (the saved message won't be deleted to make |
|
454 * room for new messages). |
|
455 * |
|
456 * Return codes: |
|
457 * KErrNone Message is saved. |
|
458 * KErrGeneral Message not saved -- total maximum of saved |
|
459 * messages reached. |
|
460 * KErrNotFound Message not saved -- no message associated |
|
461 * with the given handle. |
|
462 * KErrDiskFull Message not saved -- FFS out of space. |
|
463 * |
|
464 * @param aHandle Handle to the message to be saved. |
|
465 * @return Return code. |
|
466 */ |
|
467 virtual TInt SaveMessage( const TCbsMessageHandle& aHandle ) = 0; |
|
468 |
|
469 /** |
|
470 * Locks the message. |
|
471 * |
|
472 * Note that a single topic messages subsession can have at most one locked |
|
473 * message. |
|
474 * |
|
475 * Message can be unlocked by trying to lock a null message. Locked message |
|
476 * will also be automatically unlocked when subsession is closed. If a message |
|
477 * is locked, then it will not be deleted from the database. Thus, deleting a |
|
478 * message or trying to delete a topic that contains such a message will fail. |
|
479 * |
|
480 * Locking a message does not prevent to save the message nor read the message. |
|
481 * |
|
482 * @param aHandle It is handle to the message to be locked. |
|
483 * @return Error code. |
|
484 */ |
|
485 virtual TInt LockMessage( const TCbsMessageHandle& aHandle ) = 0; |
|
486 |
|
487 /** |
|
488 * Sets the message as read. |
|
489 * |
|
490 * @param aHandle It is handle to the message to be set read. |
|
491 */ |
|
492 virtual TInt ReadMessage( const TCbsMessageHandle& aHandle ) = 0; |
|
493 |
|
494 /** |
|
495 * Returns the message contents. |
|
496 * |
|
497 * @param aHandle It is handle to the message. |
|
498 * @param aBuffer It will contain the contents (as much as it fits). |
|
499 * @return Error code. |
|
500 */ |
|
501 virtual TInt GetMessageContents( |
|
502 const TCbsMessageHandle& aHandle, |
|
503 TDes& aBuffer ) = 0; |
|
504 |
|
505 /** |
|
506 * Returns the handles of messages that precede and succeed the |
|
507 * given message in server-side list of topic messages. |
|
508 * |
|
509 * Topic is resolved from the given message handle |
|
510 * |
|
511 * If the given handle specifies the first message in topic, |
|
512 * aPosition has ECbsHead bit up. If the given handle specifies |
|
513 * the last message in topic, aPosition has ECbsTail bit up. |
|
514 * |
|
515 * Return code values: |
|
516 * KErrNone aPrevMsgHandle, aNextMsgHandle and aPosition |
|
517 * contain valid values. |
|
518 * KErrNotFound aCurrentMsgHandle specified a message that was not |
|
519 * found. |
|
520 * |
|
521 * @param aCurrentMsgHandle Handle that specifies the message |
|
522 * whose surroundings are returned |
|
523 * @param aPrevMsgHandle Returns: handle of message |
|
524 * preceding the given message |
|
525 * @param aNextMsgHandle Returns: handle of message |
|
526 * succeeding the given topic |
|
527 * @param aPosition Returns: position of current topic |
|
528 * in list |
|
529 * @return Result code |
|
530 */ |
|
531 virtual TInt GetNextAndPrevMessageHandle( |
|
532 const TCbsMessageHandle& aCurrentMsgHandle, |
|
533 TCbsMessageHandle& aPrevMsgHandle, |
|
534 TCbsMessageHandle& aNextMsgHandle, |
|
535 TInt& aPosition ) = 0; |
|
536 |
|
537 // Other methods |
|
538 |
|
539 /** |
|
540 * Returns ETrue if CbsServer session has been established. |
|
541 * |
|
542 * @return ETrue, if session open. |
|
543 */ |
|
544 virtual TBool Connected() const = 0; |
|
545 |
|
546 /** |
|
547 * Forces the server to shut down. |
|
548 * |
|
549 * NOTE: Shutdown not fully implemented in CbsServer yet. |
|
550 */ |
|
551 virtual void Shutdown() const = 0; |
|
552 |
|
553 }; |
|
554 |
|
555 #endif // MCBS_H |
|
556 |
|
557 // End of file |