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