cbs/CbsServer/ServerInc/CCbsRecCollector.h
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 file contains the header file of the CCbsRecCollector class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CCBSRECCOLLECTOR_H
       
    20 #define CCBSRECCOLLECTOR_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class TCbsMessageCompletion;
       
    27 class CCbsRecMessage;
       
    28 class CCbsMessage;
       
    29 class CCbsMessageFactory;
       
    30 class CCbsMessageCleanupTimer;
       
    31 
       
    32 // DATA TYPES
       
    33 // Dynamic array that contains collected message pages
       
    34 typedef CArrayPtrFlat<CCbsMessage> CMessageBuffer;
       
    35 
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *   This class represents a collector, which stores pages of multipaged 
       
    41 *   messages. Complete messages are assembled and returned back to 
       
    42 *   the caller of CollectL() method.
       
    43 *  
       
    44 *   CCbsRecCollector stores message pages in a number of dynamic arrays.
       
    45 *   If all but one page of a message are present in collector, and
       
    46 *   the remaining page is received, the pages will be assembled and
       
    47 *   the corresponding message chain deleted.
       
    48 *
       
    49 *   The maximum number of incomplete messages stored in collector at once
       
    50 *   is fixed and determined by KMaxCollectorMessages in CCbsRecCollector.cpp.
       
    51 *
       
    52 *   CCbsRecCollector implements a circular list to contain message.
       
    53 *   Each incomplete message occupies a slot in this list. If the list already
       
    54 *   contains KMaxCollectorMessages messages, the next received multipaged
       
    55 *   message will delete all received pages of the oldest message in list.
       
    56 *
       
    57 *   On receival of a message page, the collector compares network information
       
    58 *   (PLMN, LAC, CellId) of both messages to decide whether pages are of
       
    59 *   the same message. In short, for pages to be of the same message
       
    60 *   their network information have to meet the requirements set by the 
       
    61 *   geographical scope of the already collected page.
       
    62 *   See ETSI GSM 03.41 for a detailed description. 
       
    63 *   
       
    64 */
       
    65 class CCbsRecCollector : public CBase
       
    66     {
       
    67     public:  // Constructors and destructor
       
    68         
       
    69         /**
       
    70         *   Two-phased constructor.
       
    71         *
       
    72         *   @param  aFactory            Message factory instance
       
    73         *   @return                     New CCbsRecCollector instance
       
    74         */
       
    75          static CCbsRecCollector* NewL( CCbsMessageFactory& aFactory );
       
    76         
       
    77         /**
       
    78         *   Destructor.
       
    79         */
       
    80         virtual ~CCbsRecCollector();
       
    81 
       
    82     public: // New functions
       
    83 
       
    84         /**
       
    85         *   Called by the Receiver when a multipaged message is received.
       
    86         *   This method checks for other pages of this message to be
       
    87         *   present in the collector. If all pages are present the
       
    88         *   collector returns a pointer to completed message.
       
    89         *
       
    90         *   If some pages are still missing, function stores 
       
    91         *   the message page and returns NULL.
       
    92         *
       
    93         *   @param aMessage             Multipaged message page
       
    94         *   @return                     NULL or completed CB message
       
    95         */
       
    96         CCbsMessage* CollectL( CCbsMessage* aMessage, TInt aMessageType );
       
    97  
       
    98         /**
       
    99         *   Deletes all message pages contained in aArray.
       
   100         *
       
   101         *   @param aArray               Message chain.
       
   102         */
       
   103         void DeleteChainL( CMessageBuffer& aArray ) const; 
       
   104 
       
   105     private:    // new functions
       
   106 
       
   107         /**
       
   108         *   C++ default constructor.
       
   109         *
       
   110         *   @param aListener            Message factory instance
       
   111         */
       
   112         CCbsRecCollector( CCbsMessageFactory& aFactory  );
       
   113 
       
   114         /**
       
   115         *   By default constructor is private.
       
   116         */
       
   117         void ConstructL();
       
   118 
       
   119         /**
       
   120         *   Counts pages in message chain aArray and compares the result
       
   121         *   against the total number of pages in the message.
       
   122 
       
   123         *   @param  aArray              Message chain.
       
   124         *   @return                     ETrue, if the chain contains all pages
       
   125         *                               of the message and is ready to be 
       
   126         *                               merged.
       
   127         */
       
   128         TBool AllPagesPresent( const CMessageBuffer& aArray ) const;
       
   129 
       
   130         /**
       
   131         *   Merges all pages in message chain aArray and returns
       
   132         *   a pointer to the resulting assembled message. The pointer
       
   133         *   is also left on the cleanup stack.
       
   134         *
       
   135         *   @param aArray               Message chain
       
   136         *   @return                     Completed CB message
       
   137         */
       
   138         CCbsMessage* MergePagesLC( CMessageBuffer& aArray ) const;
       
   139 
       
   140         /**
       
   141         *   Finds and returns a message chain which already contains pages
       
   142         *   of aMessage's message. If none is found, NULL is returned.
       
   143         *
       
   144         *   @param aMessage             Message page for which a correct chain
       
   145         *                               is sought.
       
   146         *   @return                     NULL or message chain that contains
       
   147         *                               aMessage's pages.
       
   148         */
       
   149         CMessageBuffer* FindChainContainingPage( const CCbsMessage& aMessage ) const;
       
   150         
       
   151         /**
       
   152         *   Adds message page aMessage to the correct position in message chain
       
   153         *   aArray. Message chains are ordered in ascending page number order.
       
   154         *   Duplicate pages are not accepted.
       
   155         *
       
   156         *   Ownership of aMessage is transferred to aArray, if the given page
       
   157         *   hasn't been already collected. The given page will be deleted,
       
   158         *   if it already exists in the chain.
       
   159         *
       
   160         *   @param aMessage             Message page, which is inserted into 
       
   161         *                               the chain.
       
   162         *   @param aArray               Message chain.
       
   163         */
       
   164         void AddMessageToChainL( CCbsMessage* aMessage, 
       
   165             CMessageBuffer& aArray ) const;
       
   166 
       
   167         /**
       
   168         *   Checks if these pages can be merged. Returns ETrue, if merging is
       
   169         *   acceptable.
       
   170         *
       
   171         *   Decision is based network information and geographical scope of 
       
   172         *   pages. Network information consists of cell id, location area code
       
   173         *   and operator id.
       
   174         *
       
   175         *   @param aPage1               Message page.
       
   176         *   @param aPage2               Message page.
       
   177         */
       
   178         TBool CheckPageAreaInfoMatch( const CCbsMessage& aPage1, 
       
   179             const CCbsMessage& aPage2 ) const;
       
   180 
       
   181     private:    // prohibited functions
       
   182         // Prohibited copy constructor
       
   183         CCbsRecCollector( const CCbsRecCollector& );
       
   184 
       
   185         // Prohibited assignment operator
       
   186         CCbsRecCollector& operator=( const CCbsRecCollector& );
       
   187 
       
   188     private:    // data
       
   189         // Contains pointers to buffers, each containing a single partial
       
   190         // message with 1 or more pages. 
       
   191         CArrayPtrFlat< CMessageBuffer >* iRootNodeArray;
       
   192 
       
   193         // An iterator which points to a location in iRootNodeArray next used
       
   194         // to store a page of a message, which is "new" to the collector.
       
   195         // Being "new" here means that the collector doesn't contain any
       
   196         // pages of this message.
       
   197         TInt iRootNodeIterator;
       
   198 
       
   199         // Message factory
       
   200         CCbsMessageFactory& iFactory;
       
   201 		CArrayPtrFlat< CCbsMessageCleanupTimer >*	iMessageCleanupTimerArray;
       
   202 
       
   203     };
       
   204 
       
   205 #endif      // CCBSRECCOLLECTOR_H
       
   206             
       
   207 // End of File