cbs/CbsServer/ServerSrc/CCbsTopicList.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     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 module contains the implementation of CCbsTopicList class 
       
    15 *                member functions. 
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 
       
    24 #include "CbsCommon.h"
       
    25 #include "CbsServerConstants.h"
       
    26 #include "CCbsSession.h"
       
    27 #include "CCbsTopicList.h"
       
    28 
       
    29 #include "CCbsDbImpTopicList.h"
       
    30 #include "CCbsRecEtel.h"
       
    31 #include "CCbsServer.h"
       
    32 #include "CbsLogger.h"
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CCbsTopicList::CCbsTopicList
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CCbsTopicList::CCbsTopicList( 
       
    43     CCbsSession& aSession, 
       
    44     CCbsDbImpTopicList& aTopicList, 
       
    45     CCbsRecEtel& aReceiver )
       
    46     : CCbsObject( aSession ), 
       
    47     iTopicList( aTopicList ), 
       
    48     iReceiver( aReceiver ), 
       
    49     iIsMessage( EFalse )
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CCbsTopicList::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CCbsTopicList::ConstructL()
       
    59     {
       
    60     iTopicList.AddObserverL( this );
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CCbsTopicList::NewL
       
    65 // Two-phased constructor.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CCbsTopicList* CCbsTopicList::NewL( 
       
    69     CCbsSession& aSession, 
       
    70     CCbsDbImpTopicList& aTopicList, 
       
    71     CCbsRecEtel& aReceiver )
       
    72     {
       
    73     CCbsTopicList* self = 
       
    74             new ( ELeave ) CCbsTopicList( aSession, aTopicList, aReceiver );
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL();
       
    77     CleanupStack::Pop();
       
    78     return self;
       
    79     }
       
    80    
       
    81 // Destructor
       
    82 CCbsTopicList::~CCbsTopicList()
       
    83     {
       
    84     CBSLOGSTRING("CBSSERVER: >>> CCbsTopicList::~CCbsTopicList()");
       
    85     iTopicList.RemoveObserver( this );
       
    86     CBSLOGSTRING("CBSSERVER: <<< CCbsTopicList::~CCbsTopicList()");
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CCbsTopicList::HandleRequestsL
       
    91 // Handle the requests for the object. 
       
    92 // (other items were commented in a header).
       
    93 // -----------------------------------------------------------------------------
       
    94 //  
       
    95 TBool CCbsTopicList::HandleRequestsL( 
       
    96     const RMessage2& aMessage )
       
    97     {
       
    98     CBSLOGSTRING("CBSSERVER: >>> CCbsTopicList::HandleRequestsL()");
       
    99     
       
   100     TBool requestHandled( ETrue );
       
   101     
       
   102     // Handle all requests for the subsession
       
   103     switch ( aMessage.Function() )
       
   104         {
       
   105         case ECbsCloseTopicListSubsession:
       
   106             CloseTopicList();
       
   107             aMessage.Complete( KErrNone );
       
   108             break;
       
   109         case ECbsGetTopicCount:
       
   110             GetTopicCountL();
       
   111             break;
       
   112     
       
   113         case ECbsGetTopic:
       
   114             GetTopicL();
       
   115             break;
       
   116         
       
   117         case ECbsFindTopicByNumber:
       
   118             FindTopicByNumberL();
       
   119             break;
       
   120 
       
   121         case ECbsGetNextAndPrevTopicNumber:
       
   122             GetNextAndPrevTopicNumberL();
       
   123             break;
       
   124 
       
   125         case ECbsDeleteTopic:
       
   126             DeleteTopicL();
       
   127             break;
       
   128 
       
   129         case ECbsChangeTopicNameAndNumber:
       
   130             ChangeTopicNameAndNumberL();
       
   131             break;
       
   132 
       
   133         case ECbsChangeTopicSubscriptionStatus:
       
   134             ChangeTopicSubscriptionStatusL();
       
   135             break;
       
   136 
       
   137         case ECbsChangeTopicHotmarkStatus:
       
   138             ChangeTopicHotmarkStatusL();
       
   139             break;
       
   140 
       
   141         case ECbsAddTopic:
       
   142             AddTopicL();
       
   143             break;
       
   144 
       
   145         case ECbsNotifyOnEvent:
       
   146             NotifyOnEvent();
       
   147             break;
       
   148 
       
   149         case ECbsNotifyOnEventCancel:
       
   150             NotifyOnEventCancel();
       
   151             break;
       
   152 
       
   153         case ECbsGetNewTopicsCount:
       
   154             GetNewTopicsCountL();
       
   155             break;
       
   156 
       
   157         case ECbsGetLatestTopicNumber:
       
   158             GetLatestTopicNumberL();
       
   159             break;
       
   160 
       
   161         case ECbsGetUnreadMessageCount:
       
   162             GetUnreadMessageCountL();
       
   163             break;
       
   164 
       
   165         case ECbsGetHotmarkedMessageHandle:
       
   166             GetHotmarkedMessageHandleL();
       
   167             break;
       
   168 
       
   169         case ECbsDeleteAll:        
       
   170             DeleteAllL();
       
   171             break;
       
   172 
       
   173         case ECbsGetUnreadHotmarkedMessageCount:
       
   174             GetUnreadHotmarkedMessageCountL();
       
   175             break;
       
   176         
       
   177         default:
       
   178             requestHandled = EFalse;
       
   179             break;
       
   180         }    
       
   181 
       
   182     // Return truth value indicating whether it was possible 
       
   183     // to handle the request or not.    
       
   184     
       
   185     CBSLOGSTRING2("CBSSERVER: <<< CCbsTopicList::HandleRequestsL(), returning requestHandled: %d", requestHandled );
       
   186     
       
   187     return requestHandled;
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CCbsTopicList::TopicListInitializedIndL
       
   192 // Called when the topic list is initialized.
       
   193 // (other items were commented in a header).
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 void CCbsTopicList::TopicListInitializedIndL()
       
   197     {
       
   198     // Notification.
       
   199     NotifyClientL( ECbsTopicListInitialized, 0 );
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CCbsTopicList::TopicAddedIndL
       
   204 // Called whenever a topic is created. 
       
   205 // If necessary, the client will be notified.
       
   206 // (other items were commented in a header).
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 void CCbsTopicList::TopicAddedIndL( 
       
   210     const TCbsDbTopicNumber& aNumber )
       
   211     {
       
   212     // Notification.
       
   213     NotifyClientL( ECbsTopicAdded, aNumber );
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CCbsTopicList::TopicDeletedIndL
       
   218 // Called whenever a topic is deleted.  
       
   219 // If necessary, the client will be notified.
       
   220 // (other items were commented in a header).
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 void CCbsTopicList::TopicDeletedIndL( 
       
   224     const TCbsDbTopicNumber& aNumber )
       
   225     {
       
   226     // Notification.
       
   227     NotifyClientL( ECbsTopicDeleted, aNumber );
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CCbsTopicList::TopicModifiedIndL
       
   232 // Called whenever a topic is modified.  
       
   233 // If necessary, the client will be notified.
       
   234 // (other items were commented in a header).
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void CCbsTopicList::TopicModifiedIndL( 
       
   238     const TCbsDbTopicNumber& aNumber )
       
   239     {
       
   240     // Notification.
       
   241     NotifyClientL( ECbsTopicModified, aNumber );
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CCbsTopicList::TopicNewMessageReceivedIndL
       
   246 // Called whenever a new message has been received.   
       
   247 // If necessary, the client will be notified.
       
   248 // (other items were commented in a header).
       
   249 // -----------------------------------------------------------------------------
       
   250 //  
       
   251 void CCbsTopicList::TopicNewMessageReceivedIndL( 
       
   252     const TCbsDbMessageHandle& aHandle )
       
   253     {
       
   254     TCbsTopicNumber topic( iTopicList.ExtractTopicNumber( aHandle ) );
       
   255     NotifyClientL( ECbsTopicReceivedNewMessage, topic );
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CCbsTopicList::CloseTopicList
       
   260 // Closes and destroys the subsession. 
       
   261 // Note that after the call has completed, the object is no longer
       
   262 // valid. It is also left for the callee's task to complete 
       
   263 // the request.
       
   264 // (other items were commented in a header).
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 void CCbsTopicList::CloseTopicList()
       
   268     {
       
   269     // Removes the object.
       
   270     Session().Server().DeleteObjectByHandle( Message().Int3() );
       
   271     }
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // CCbsTopicList::GetTopicCountL
       
   275 // Returns the total number of topics to the client.
       
   276 // (other items were commented in a header).
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 void CCbsTopicList::GetTopicCountL()
       
   280     {
       
   281     // Write the topic count to the client side.
       
   282     TInt count( 0 );
       
   283     iTopicList.GetTopicCount( count );
       
   284     TPckgBuf< TInt > pckg( count );
       
   285 
       
   286     Message().WriteL( 0, pckg );
       
   287 
       
   288     // Complete the request
       
   289     Message().Complete( KErrNone );
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // CCbsTopicList::GetTopicL
       
   294 // Returns the requested topic to the client.
       
   295 // Retrieves topic information with an index to topic list.
       
   296 // (other items were commented in a header).
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 void CCbsTopicList::GetTopicL()
       
   300     {
       
   301     // First, read the index from the client side
       
   302     TInt topicIndex( 0 );
       
   303     topicIndex = Message().Int0();
       
   304 
       
   305     // Then read the topic from the topic list
       
   306     TPckgBuf< TCbsTopic > pckgTopic;
       
   307     TRAPD( errorCode, iTopicList.GetTopicL( topicIndex, pckgTopic() ) );
       
   308 
       
   309     if ( errorCode == KErrNone )
       
   310         {
       
   311         // Finally, write the topic information to the client side
       
   312         Message().WriteL( 1, pckgTopic );
       
   313         }
       
   314 
       
   315     // Complete the request.
       
   316     Message().Complete( errorCode );
       
   317     }
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 // CCbsTopicList::FindTopicByNumberL
       
   321 // Finds a topic by number and returns it to the client.
       
   322 // (other items were commented in a header).
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 void CCbsTopicList::FindTopicByNumberL()
       
   326     {
       
   327     // First, read the number from the client side
       
   328     TInt topicNumber( 0 );
       
   329     topicNumber = Message().Int0();    
       
   330     
       
   331     // Find topic by handle
       
   332     TPckgBuf< TCbsTopic > pckgTopic;
       
   333     iTopicList.FindTopicByNumberL( static_cast<TUint16> ( topicNumber ), 
       
   334         pckgTopic() );
       
   335 
       
   336     // Finally, write the topic information to the client side
       
   337     Message().WriteL( 1, pckgTopic );
       
   338 
       
   339     // Complete the request.
       
   340     Message().Complete( KErrNone );
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CCbsTopicList::DeleteTopicL
       
   345 // Deletes a topic by its number and returns it to the client.
       
   346 // (other items were commented in a header).
       
   347 // -----------------------------------------------------------------------------
       
   348 //
       
   349 void CCbsTopicList::DeleteTopicL()
       
   350     {
       
   351     // First, read the handle from the client side    
       
   352     TInt topicNumber( 0 );
       
   353     topicNumber = Message().Int0();
       
   354 
       
   355     // Delete the topic
       
   356     iTopicList.DeleteTopicL( static_cast<TUint16> ( topicNumber ) );
       
   357 
       
   358     iReceiver.DeleteSimTopicL( static_cast<TUint16> ( topicNumber ), EFalse );
       
   359 
       
   360     iReceiver.ApplyStateChangesL();
       
   361 
       
   362     // Complete the request
       
   363     Message().Complete( KErrNone );
       
   364     }
       
   365 
       
   366 // -----------------------------------------------------------------------------
       
   367 // CCbsTopicList::ChangeTopicNameAndNumberL
       
   368 // Changes a topic name and number.
       
   369 // (other items were commented in a header).
       
   370 // -----------------------------------------------------------------------------
       
   371 //
       
   372 void CCbsTopicList::ChangeTopicNameAndNumberL()
       
   373     {
       
   374     TCbsDbTopicName name;
       
   375     TInt oldNumber( 0 );
       
   376     TInt newNumber( 0 );
       
   377 
       
   378     oldNumber = Message().Int0();
       
   379     newNumber = Message().Int1();
       
   380     Message().ReadL( 2, name );
       
   381 
       
   382     // First find the topic.
       
   383     TCbsDbTopic topic;
       
   384     iTopicList.FindTopicByNumberL( static_cast<TUint16> ( oldNumber ), topic );
       
   385 
       
   386     // Then do the operations.
       
   387     iTopicList.UpdateTopicNameAndNumberL( static_cast<TUint16> ( oldNumber ), 
       
   388         static_cast<TUint16> ( newNumber ), name );
       
   389 
       
   390     // Now we may need to change the subscriptions
       
   391     if ( oldNumber != newNumber )
       
   392         {
       
   393         iReceiver.DeleteSimTopicL( static_cast<TUint16> ( oldNumber ), EFalse );
       
   394         }
       
   395 
       
   396     // Complete the request.
       
   397     Message().Complete( KErrNone );
       
   398     }
       
   399         
       
   400 // -----------------------------------------------------------------------------
       
   401 // CCbsTopicList::ChangeTopicSubscriptionStatusL
       
   402 // Changes topic subscription status.
       
   403 // (other items were commented in a header).
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 void CCbsTopicList::ChangeTopicSubscriptionStatusL()
       
   407     {
       
   408     TInt topicNumber( 0 );
       
   409     TPckgBuf< TBool > pckgStatus;
       
   410     
       
   411     topicNumber = Message().Int0();
       
   412     Message().ReadL( 1, pckgStatus );
       
   413 
       
   414     // First find the topic.
       
   415     TCbsDbTopic topic;
       
   416     iTopicList.FindTopicByNumberL( static_cast<TUint16> ( topicNumber ), topic );
       
   417 
       
   418     // Then update.
       
   419     iTopicList.UpdateTopicSubscriptionStatusL( static_cast<TUint16> ( topicNumber ), pckgStatus() );
       
   420     iReceiver.ApplyStateChangesL();
       
   421 
       
   422     // Complete the request.
       
   423     Message().Complete( KErrNone );
       
   424     }
       
   425      
       
   426 // -----------------------------------------------------------------------------
       
   427 // CCbsTopicList::ChangeTopicHotmarkStatusL
       
   428 // Changes topic hotmark status.
       
   429 // (other items were commented in a header).
       
   430 // -----------------------------------------------------------------------------
       
   431 //
       
   432 void CCbsTopicList::ChangeTopicHotmarkStatusL()
       
   433     {
       
   434     TPckgBuf< TBool > pckgStatus;
       
   435     TInt topicNumber( 0 );
       
   436     topicNumber = Message().Int0();
       
   437     Message().ReadL( 1, pckgStatus );
       
   438 
       
   439     // Then update
       
   440     iTopicList.UpdateTopicHotmarkStatusL( static_cast<TUint16> ( topicNumber ), pckgStatus() );
       
   441 
       
   442     // Complete the request.
       
   443     Message().Complete( KErrNone );
       
   444     }
       
   445 
       
   446 // -----------------------------------------------------------------------------
       
   447 // CCbsTopicList::AddTopicL
       
   448 // Adds a topic to the list.
       
   449 // (other items were commented in a header).
       
   450 // -----------------------------------------------------------------------------
       
   451 //
       
   452 void CCbsTopicList::AddTopicL()
       
   453     {
       
   454     // First, get the topic information from the client side
       
   455     TPckgBuf< TCbsTopic > pckgTopic;
       
   456     Message().ReadL( 0, pckgTopic );
       
   457 
       
   458     // It is not allowed to set protected.
       
   459     if ( pckgTopic().iProtected )
       
   460         {
       
   461         User::Leave( KErrArgument );
       
   462         }
       
   463 
       
   464     // Add the topic, not detected automatically
       
   465     iTopicList.AddTopicL( pckgTopic(), EFalse );
       
   466 
       
   467     // Load the default topic stream
       
   468     iTopicList.LoadDefaultTopicStreamL();
       
   469     
       
   470     // Write updated data to the client side (only handle is updated)
       
   471     Message().WriteL( 0, pckgTopic );
       
   472     
       
   473     // Complete the request
       
   474     Message().Complete( KErrNone );
       
   475     }
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CCbsTopicList::NotifyOnEvent
       
   479 // Sets up a pending notification request.
       
   480 // (other items were commented in a header).
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 void CCbsTopicList::NotifyOnEvent()
       
   484     {
       
   485     if ( iIsMessage )
       
   486         {
       
   487         NotifyOnEventCancel();
       
   488         }
       
   489 
       
   490     iMessage = Message();
       
   491     iIsMessage = ETrue;
       
   492     }
       
   493 
       
   494 // -----------------------------------------------------------------------------
       
   495 // CCbsTopicList::NotifyOnEventCancel
       
   496 // Cancels a pending notification request.
       
   497 // (other items were commented in a header).
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 void CCbsTopicList::NotifyOnEventCancel()
       
   501     {
       
   502     // Cancel the pending notify request.
       
   503     if ( iIsMessage )
       
   504         {
       
   505         iMessage.Complete( KErrCancel );
       
   506         iIsMessage = EFalse;
       
   507         }
       
   508 
       
   509     // Complete the request.
       
   510     Message().Complete( KErrNone );
       
   511     }
       
   512 
       
   513 // -----------------------------------------------------------------------------
       
   514 // CCbsTopicList::GetNewTopicsCountL
       
   515 // Returns the number of "new" topics to the client.
       
   516 // By new it is referred to topics that are created because of 
       
   517 // topic detection since last power on.
       
   518 // (other items were commented in a header).
       
   519 // -----------------------------------------------------------------------------
       
   520 //
       
   521 void CCbsTopicList::GetNewTopicsCountL()
       
   522     {
       
   523     TPckgBuf< TInt > pckg( Session().TotalTopicsDetected() );
       
   524     Message().WriteL( 0, pckg );
       
   525 
       
   526     // Complete the request
       
   527     Message().Complete( KErrNone );
       
   528     }
       
   529 
       
   530 // -----------------------------------------------------------------------------
       
   531 // CCbsTopicList::GetLatestTopicNumberL
       
   532 // Retrieves the number of the topic that was added
       
   533 // last to the topic list.
       
   534 // (other items were commented in a header).
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 void CCbsTopicList::GetLatestTopicNumberL()
       
   538     {
       
   539     TCbsTopicNumber number( 0 );
       
   540     TInt result( iTopicList.GetLatestTopicNumber( number ) );
       
   541     if ( result == KErrNone )
       
   542         {
       
   543         TPckgBuf<TCbsTopicNumber> pckg( number );
       
   544         Message().WriteL( 0, pckg );
       
   545         Message().Complete( KErrNone );
       
   546         }
       
   547     else
       
   548         {
       
   549         User::Leave( result );
       
   550         }
       
   551     }
       
   552    
       
   553 // -----------------------------------------------------------------------------
       
   554 // CCbsTopicList::GetUnreadMessageCountL
       
   555 // Returns the total amount of unread messages.
       
   556 // (other items were commented in a header).
       
   557 // -----------------------------------------------------------------------------
       
   558 // 
       
   559 void CCbsTopicList::GetUnreadMessageCountL()
       
   560     {
       
   561     // Get unread message count from the database.
       
   562     TPckgBuf<TInt> pckg( 0 );
       
   563     iTopicList.GetUnreadMessageCount( pckg() );
       
   564 
       
   565     Message().WriteL( 0, pckg );
       
   566 
       
   567     // Complete the request.
       
   568     Message().Complete( KErrNone );
       
   569     }
       
   570 
       
   571 // -----------------------------------------------------------------------------
       
   572 // CCbsTopicList::GetHotmarkedMessageHandleL
       
   573 // Returns a handle to the latest (that is not yet taken) 
       
   574 // hotmarked message handle.
       
   575 // (other items were commented in a header).
       
   576 // -----------------------------------------------------------------------------
       
   577 // 
       
   578 void CCbsTopicList::GetHotmarkedMessageHandleL()
       
   579     {
       
   580     // Get the hotmarked message handle.
       
   581     TCbsMessageHandle handle( 0 );
       
   582     iTopicList.GetHotmarkedMessageHandleL( handle );
       
   583 
       
   584     // And then write it to the client.
       
   585     TPckgBuf< TCbsMessageHandle > pckg( handle );
       
   586     Message().WriteL( 0, pckg );
       
   587 
       
   588     // Complete the request.
       
   589     Message().Complete( KErrNone );
       
   590     }
       
   591 
       
   592 // -----------------------------------------------------------------------------
       
   593 // CCbsTopicList::GetUnreadHotmarkedMessageCountL
       
   594 // Returns the number of hotmarked, unread messages.
       
   595 // (other items were commented in a header).
       
   596 // -----------------------------------------------------------------------------
       
   597 //
       
   598 void CCbsTopicList::GetUnreadHotmarkedMessageCountL()
       
   599     {
       
   600     TInt number( iTopicList.UnreadHotmarkedMessageCount() );
       
   601     TPckgBuf<TInt> pckgNumber( number );
       
   602     Message().WriteL( 0, pckgNumber );
       
   603     Message().Complete( KErrNone );
       
   604     }
       
   605 
       
   606 // -----------------------------------------------------------------------------
       
   607 // CCbsTopicList::DeleteAllL
       
   608 // Deletes all topics.
       
   609 // (other items were commented in a header).
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 void CCbsTopicList::DeleteAllL()
       
   613     {
       
   614     // Delete all topic from the SIM card
       
   615     iReceiver.DeleteAllSimTopicsL();
       
   616     
       
   617     // Delete all topic from the server store
       
   618     iTopicList.InitializeListL( EFalse );
       
   619     iReceiver.ApplyStateChangesL();
       
   620 
       
   621     Message().Complete( KErrNone );
       
   622     }
       
   623 
       
   624 // -----------------------------------------------------------------------------
       
   625 // CCbsTopicList::NotifyClientL
       
   626 // If there is a pending notify request, notifies 
       
   627 // the client.
       
   628 // (other items were commented in a header).
       
   629 // -----------------------------------------------------------------------------
       
   630 //
       
   631 void CCbsTopicList::NotifyClientL( 
       
   632     TCbsTopicListEvent aEvent, 
       
   633     TCbsTopicNumber aNumber )
       
   634     {
       
   635     // If there is a pending request, then process it.
       
   636     if ( iIsMessage )
       
   637         {
       
   638         // First check if the client is interested of the topics.
       
   639         TInt requested( iMessage.Int0() );
       
   640         if ( ( requested & aEvent ) )
       
   641             {
       
   642             // The client is interested of the event, so notify the client.
       
   643             // Make up a pointer descriptors.
       
   644             TPtr8 eventPtr( reinterpret_cast<TText8*>(&aEvent),
       
   645                     sizeof( TCbsTopicListEvent ),
       
   646                     sizeof( TCbsTopicListEvent) );
       
   647 
       
   648             TPtr8 numberPtr( reinterpret_cast<TText8*>(&aNumber),
       
   649                     sizeof( TCbsTopicNumber ),
       
   650                     sizeof( TCbsTopicNumber) );
       
   651             // Write through the pointer descriptors.
       
   652             iMessage.WriteL( 1, eventPtr );
       
   653             iMessage.WriteL( 2, numberPtr );
       
   654 
       
   655             iMessage.Complete( KErrNone );
       
   656             iIsMessage = EFalse;
       
   657             }        
       
   658         }        
       
   659     }
       
   660 
       
   661 // -----------------------------------------------------------------------------
       
   662 // CCbsTopicList::GetNextAndPrevTopicNumberL
       
   663 // Retrieves and returns the numbers of topics that
       
   664 // precede and succeed the given topic in topic list.
       
   665 // Also returns two flags indicating whether the
       
   666 // given topic is the first and/or the last topic in list.
       
   667 // (other items were commented in a header).
       
   668 // -----------------------------------------------------------------------------
       
   669 //
       
   670 void CCbsTopicList::GetNextAndPrevTopicNumberL()
       
   671     {
       
   672     // Retrieve the requested topic number
       
   673     TPckgBuf<TCbsTopicNumber> pckgCurrentTopic( 0 );
       
   674     Message().ReadL( 0, pckgCurrentTopic );
       
   675 
       
   676     // Determine requested information
       
   677     TCbsTopicNumber nextTopic( 0 );
       
   678     TCbsTopicNumber prevTopic( 0 );
       
   679     TInt position( 0 );
       
   680     iTopicList.GetNextAndPrevTopicNumberL(
       
   681         pckgCurrentTopic(), nextTopic, prevTopic, position );
       
   682 
       
   683     // Write results back
       
   684     TPckgBuf<TCbsNextPrevTopicAndPosition> pckgResults;
       
   685     pckgResults().iNextTopic = nextTopic;
       
   686     pckgResults().iPrevTopic = prevTopic;
       
   687     pckgResults().iPosition = position;
       
   688     Message().WriteL( 1, pckgResults );
       
   689 
       
   690     // Complete request
       
   691     Message().Complete( KErrNone );
       
   692     }
       
   693 
       
   694 
       
   695 // ================= OTHER EXPORTED FUNCTIONS ==============
       
   696 
       
   697 //  End of File