cbs/CbsServer/ServerInc/CCbsRecEtel.h
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     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 CCbsRecEtel class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef     CCBSRECETEL_H
       
    20 #define     CCBSRECETEL_H
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include "CMcn.h"
       
    25 #include "MCbsEtelMessaging.h"
       
    26 
       
    27 		/*****************************************************
       
    28 		*	Series 60 Customer / ETel
       
    29 		*	Series 60  ETel API
       
    30 		*****************************************************/
       
    31 #include <rmmcustomapi.h>       // SIM topics
       
    32 
       
    33 // CONSTANTS
       
    34 		/*****************************************************
       
    35 		*	Series 60 Customer / TSY
       
    36 		*	Needs customer TSY implementation
       
    37 		*****************************************************/
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CCbsEtelFactory;
       
    41 class CCbsRecEtelMonitor;
       
    42 class CCbsRecCollector;
       
    43 class CCbsRecDecoder;
       
    44 class CCbsRecNetworkListener;
       
    45 class CCbsRecMessage;
       
    46 class CCbsReceiverHelper;
       
    47 class MCbsMcnSubscriptionsProvider;
       
    48 class CCbsSetFilterSettingHandler;
       
    49 class CCbsRecWcdmaMessage;
       
    50 class CCbsMessage;
       
    51 class CCbsMessageFactory;
       
    52 class CCbsLivecastHandler;
       
    53 
       
    54 
       
    55 //  CLASS DECLARATION 
       
    56 
       
    57 /**
       
    58 *   CCbsRecEtel sets up the receiver subsystem for receiving CBS messages 
       
    59 *   from the ETEL server.
       
    60 *
       
    61 *   This class creates instances of CCbsRecEtelMonitor to communicate with 
       
    62 *   ETel server, CCbsRecDecoder to decode message pages and 
       
    63 *   CCbsRecCollector to combine partial messages together. CCbsRecEtel 
       
    64 *   sends completed messages to the database via an interface 
       
    65 *   class CCbsReceiverHelper.
       
    66 *
       
    67 *   An instance of CCbsRecNetworkListener is created to monitor network
       
    68 *   state changes and report them to CCbsRecEtel instance.
       
    69 *
       
    70 *   CCbsRecEtel is also responsible for controlling the CBMI list entries 
       
    71 *   in ME defining Message Identifiers and DCSes that are to be received. 
       
    72 *
       
    73 *   CCbsRecEtel instance does not store information on what topics and
       
    74 *   languages to subscribe. Instead, on call to ApplyStateChangesL(), 
       
    75 *   subscriptions and other CB settings are retrieved from the database 
       
    76 *   and passed to EPOC Telephony server.
       
    77 *
       
    78 *   Thus, after topic subscriptions, languages or reception status have
       
    79 *   been modified, a call to ApplyStateChangesL() has to be made in order
       
    80 *   to actually bring the changes into effect.
       
    81 *
       
    82 *   ON SUBSCRIPTION OF TOPICS AND LANGUAGES
       
    83 *
       
    84 *   Although EPOC Telephony server can be requested to relay messages of certain topics and
       
    85 *   languages, there is a couple of things to note.
       
    86 *
       
    87 *   1. In order to detect topics broadcasted within the current region, all
       
    88 *   CB messages have to be received. This is done by subscribing all topics
       
    89 *   and languages.
       
    90 *
       
    91 *   2. Since MCN clients may subscribe any number of topics, topic filtering 
       
    92 *   has to be made to remove messages not requested by the UI client.
       
    93 *
       
    94 *   3. All languages have to be subscribed at all times. This is because
       
    95 *   TSY limits the number of languages and a single language (e.g., English),
       
    96 *   may be represented by multiple DCS values. In addition, CBS specification
       
    97 *   tells that any message in unspecified language has to be received.
       
    98 *   Thus the only possibility here is to ignore EPOC Telephony server provided facilities
       
    99 *   to filter languages, and implement filtering in CbsServer. 
       
   100 *   This is done in CCbsReceiverHelper.
       
   101 */
       
   102 class CCbsRecEtel : public CBase
       
   103     {
       
   104     public:     // New functions
       
   105         
       
   106         /**
       
   107         *   Creates an instance of the class.
       
   108         *
       
   109         *   @return A new instance of CCbsRecEtel.
       
   110         */
       
   111         static CCbsRecEtel* NewL();
       
   112 
       
   113         /**
       
   114         *   Destructor.
       
   115         */
       
   116         ~CCbsRecEtel();
       
   117 
       
   118         /**
       
   119         *   Called by the network listener (instance of CCbsRecEtelMonitor)
       
   120         *   to indicate that a new message has been received and must be 
       
   121         *   handled.
       
   122         *
       
   123         *   The message page is decoded, cell information (if present) is 
       
   124         *   extracted and routed to MCN clients. Pages of multipaged messages 
       
   125         *   are then given to the collector. If the message is completed
       
   126         *   (all pages collected) or the message is singlepaged, it is
       
   127         *   given onwards to CCbsReceiverHelper.
       
   128         *
       
   129         *   Note that a multipaged message page is routed to MCN clients 
       
   130         *   before it is assembled. This is acceptable because maximum
       
   131         *   length of a MCN message is specified to be 20 characters.
       
   132         *
       
   133         *   Ownership of aMessage transferred to CCbsRecEtel.
       
   134         *
       
   135         *   @param aMessage A pointer to the message page received.
       
   136         */
       
   137         void HandleMessageReceivedL( CCbsMessage* aMessage );
       
   138 
       
   139         /**
       
   140         *   Augments aMessage with current network information (i.e., PLMN, LAC
       
   141         *   and Cell ID). Does nothing if the network listener iListener
       
   142         *   is unavailable.        
       
   143         *
       
   144         *   @param aMessage Message page.
       
   145         */
       
   146         TInt AddNetworkInfo( CCbsMessage& aMessage ) const;
       
   147             
       
   148         /**
       
   149         *   Sets the interface to which all accepted messages are given. 
       
   150         *   
       
   151         *   @param aInterface A pointer to the receiver interface.
       
   152         */
       
   153         void SetInterface( CCbsReceiverHelper* aInterface );
       
   154 
       
   155         /**
       
   156         *   Returns the current and maximum number of subscribed topics.
       
   157         *
       
   158         *   Topic restrictions are imposed by the TSY in use.
       
   159         *
       
   160         *   @param aTotal               Total amount of subscribed topics.
       
   161         *   @param aMax                 Maximum amount of subscribed topics.
       
   162         */
       
   163         void GetSubscriptionsLimitsL( TInt& aTotal, TInt& aMax );
       
   164         
       
   165         /**
       
   166         *   MCN client sessions register to CCbsRecEtel using this function.
       
   167         *
       
   168         *   When topic subscriptions are gathered during execution of
       
   169         *   ApplyStateChangesL(), subscriptions of each registered subscription
       
   170         *   provider are added to the CBMI list that determines which
       
   171         *   topics are received.
       
   172         *
       
   173         *   @param aProvider            Topic subscription providing instance
       
   174         */
       
   175         void AddSubscriptionProviderL( 
       
   176             MCbsMcnSubscriptionsProvider* aProvider );
       
   177 
       
   178         /**
       
   179         *   Removes a topic subscription provider.
       
   180         *
       
   181         *   @param aProvider            Topic subscription providing instance
       
   182         */
       
   183         void RemoveSubscriptionProviderL( 
       
   184             const MCbsMcnSubscriptionsProvider* aProvider );
       
   185 
       
   186         /**
       
   187         *   Retrieves current subscriptions, languages and settings
       
   188         *   from DB. This data is augmented by topic subscription
       
   189         *   information retrieved from MCN client(s). Resulting
       
   190         *   topic subscriptions, languages and settings will then
       
   191         *   be requested from EPOC Telephony server.
       
   192         *
       
   193         */    
       
   194         void ApplyStateChangesL();
       
   195 
       
   196         /**
       
   197         *   Returns the current cell information.
       
   198         *
       
   199         *   The information is retrieved from the last cell information
       
   200         *   message received.
       
   201         *
       
   202         *   Result codes:
       
   203         *   KErrNone                    Operation successful, aCellInfo 
       
   204         *                               contains a valid cell info message
       
   205         *   KErrNotFound                Cell information hasn't been received
       
   206         *                               yet - aCellInfo is invalid.
       
   207         *
       
   208         *   @param  aInfoMessage        Current info message
       
   209         *   @param  aTopicNumber        Number of the topic that 
       
   210         *                               the msg belongs to
       
   211         *   @return                     Result code
       
   212         */
       
   213         TInt GetCurrentMessage( TDes& aInfoMessage, TInt aTopicNumber );
       
   214 
       
   215         /**
       
   216         *   Loads CB topics from SIM and adds them on the topic list.
       
   217         *   A topic is not added on the list if the same topic
       
   218         *   already exists on the list. This identification is done
       
   219         *   by the number of the topic only. 
       
   220         *
       
   221         *   The name of an added topic will be taken from SIM.
       
   222         *   If no name has been associated with the topic, the string
       
   223         *   <qtn_cb_litext_sim_topic> will be given to the topic.
       
   224         *
       
   225         *   Result codes:
       
   226         *   KErrNotSupported            TSY does not support SIM topics.
       
   227         *
       
   228         *   @return                     Result code.
       
   229         */
       
   230         TInt LoadSimTopicsL();
       
   231 
       
   232         /**
       
   233         *   Deletes a CB topic matching the given topic number from SIM.
       
   234         *
       
   235         *   Leaves if the operation is unsuccessful.
       
   236         *   
       
   237         *   @param aNumber              Number of topic to be deleted from SIM.
       
   238         *   @param aDeleteAll           Are we deleting all SIM topics, ETrue/EFalse
       
   239         */
       
   240         void DeleteSimTopicL( const TUint16 aNumber, const TBool aDeleteAll );
       
   241         
       
   242         /**
       
   243         *   Deletes all topics from the SIM card.
       
   244         *
       
   245         *   Leaves if the operation is unsuccessful.
       
   246         *           
       
   247         */
       
   248         void DeleteAllSimTopicsL();
       
   249 
       
   250         /**
       
   251         *   Passes the given CB message to each registered subscriptions
       
   252         *   provider (a subscription provider is a MCN client wishing
       
   253         *   CB message routing service).
       
   254         *
       
   255         *   @param  aMessage                CB message
       
   256         */
       
   257         void RouteMessageL( const CCbsMessage& aMessage );
       
   258 
       
   259         /**
       
   260         *   Returns the message collector reference.
       
   261         *
       
   262         *   @return                     Collector reference
       
   263         */
       
   264         CCbsRecCollector& Collector();
       
   265         
       
   266         /**
       
   267         *   Returns the receiver helper reference.
       
   268         *
       
   269         *   @return                     Receiver helper reference
       
   270         */
       
   271         CCbsReceiverHelper& Interface() const;
       
   272 
       
   273    private:
       
   274         
       
   275         /**
       
   276         *   Constructor.
       
   277         */
       
   278         CCbsRecEtel();
       
   279 
       
   280         /**
       
   281         *   Finalizes the construction.
       
   282         */
       
   283         void ConstructL();
       
   284 
       
   285         /**
       
   286         *   Establishes a connection with the EPOC Telephony server.
       
   287         *
       
   288         *   Also opens the necessary EPOC Telephony server resources such as RMobilePhone and
       
   289         *   RMobileBroadcastMessaging sessions.
       
   290         */
       
   291         void ConnectToEtelL();
       
   292         
       
   293         /**
       
   294         *   Sets the given CB reception mode on ME.
       
   295         *
       
   296         *   @param aSetting         CB receive mode
       
   297         */
       
   298         void SetReceptionStatusL( 
       
   299             RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter aSetting );
       
   300 
       
   301         /**
       
   302         *   Returns the total number of topic subscriptions made by
       
   303         *   MCN clients registered to the server.
       
   304         *
       
   305         *   @return                     Number of subscriptions by
       
   306         *                               MCN clients.
       
   307         */
       
   308         TUint NumberOfMcnSubscriptions() const;
       
   309 
       
   310         /**
       
   311         *   Copies cell information message body into an internal
       
   312         *   cache. This way MCN clients can be provided the current
       
   313         *   cell information message even without message routing service.
       
   314         *
       
   315         *   The given message is assumed to be a valid cell information
       
   316         *   message (CB message of topic 050).
       
   317         *
       
   318         *   @param  aMessage                Cell information message
       
   319         */
       
   320         void ExtractCellInformation( const CCbsMessage& aMessage );
       
   321 
       
   322         /**
       
   323         *   Copies cell information message body into an internal
       
   324         *   cache. This way MCN clients can be provided the current
       
   325         *   HomeZone message even without message routing service.
       
   326         *
       
   327         *   The given message is assumed to be a valid HomeZone
       
   328         *   message (CB message of topic 221).
       
   329         *
       
   330         *   @param  aMessage                Cell information message
       
   331         */
       
   332         void ExtractHomeZoneInformation( const CCbsMessage& aMessage );
       
   333 
       
   334         /**
       
   335         *   Checks if the time of the day is such that the user does
       
   336         *   not want to receive any messages.
       
   337         *
       
   338         *   @param  aMessage                CB message
       
   339         *   @return                         ETrue if the message should
       
   340         *                                   be recived, otherwise EFalse.
       
   341         */
       
   342         TBool CheckTimeL( const CCbsMessage* aMessage );
       
   343                 
       
   344     private:    // Data
       
   345 
       
   346         // Own: Collector, which is responsible for combining multipaged
       
   347         // messages.        
       
   348         CCbsRecCollector* iCollector;
       
   349         
       
   350         // Own: responsible for converting 7-bit and 8-bit representations 
       
   351         // into UCS-2.
       
   352         CCbsRecDecoder* iDecoder;
       
   353 
       
   354         // Current reception status. This is a cached version of 
       
   355         // a variable stored in ME/SIM.
       
   356         RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter iReception;
       
   357 
       
   358         // Ref: interface to the server. 
       
   359         CCbsReceiverHelper* iInterface;
       
   360         
       
   361         // Own: SMS messaging object for receiving CBS message pages 
       
   362         // from the EPOC Telephony server.
       
   363         MCbsEtelMessaging* iMessaging;
       
   364 
       
   365         // Own: ETel monitor receives the message pages and forwards them to
       
   366         // CCbsRecEtel.
       
   367         CCbsRecEtelMonitor* iEtelMonitor;
       
   368 
       
   369         // Own: Filter setting handler processes asynchronous 
       
   370         // Set Filter Setting command.
       
   371         CCbsSetFilterSettingHandler* iFilterSettingHandler;   
       
   372 
       
   373         // EPOC Telephony server session.
       
   374         RTelServer iEtelServer;
       
   375 
       
   376         // Represents the GSM phone used for messaging and network information
       
   377         // retrieving.
       
   378 
       
   379 		/*****************************************************
       
   380 		*	Series 60 Customer / ETel
       
   381 		*	Series 60  ETel API
       
   382 		*****************************************************/
       
   383         RMobilePhone iGsmPhone;
       
   384 
       
   385         // Custom API is used for SIM Topic handling.
       
   386 
       
   387 		/*****************************************************
       
   388 		*	Series 60 Customer / ETel
       
   389 		*	Series 60  ETel API
       
   390 		*****************************************************/
       
   391         RMmCustomAPI iCustomPhone;
       
   392 
       
   393         // Own: active object which listens to changes in network state
       
   394         // and reports them to CCbsRecEtel instance.
       
   395         CCbsRecNetworkListener* iNetworkListener;
       
   396 
       
   397         // Own: set of MCN sessions that provide their topic subscriptions and
       
   398         // get cell information routing services
       
   399         CArrayFixFlat< MCbsMcnSubscriptionsProvider* >* iSubscriptionProviders;
       
   400 
       
   401         // ETrue if a cell information message has been received.
       
   402         TBool iCellInfoReceived;
       
   403         
       
   404         // Current reception status. This is a cached version of 
       
   405         // a variable stored in ME.       
       
   406         TBool iReceptionEnabled;
       
   407 
       
   408         // Current cell information message.
       
   409         TMcnMessage iCurrentCellInfoMessage;
       
   410 
       
   411         // Has the user set a time to limit the reception
       
   412         TBool iLimitedReception;
       
   413 
       
   414         // The current time
       
   415         TTime iNow;
       
   416         TDateTime iDateTimeNow;
       
   417 
       
   418         // Start and end times of limited reception
       
   419         TTime iStartTime;
       
   420         TTime iEndTime;
       
   421 
       
   422         // Cell info cache variables
       
   423         RMobilePhone::TMobilePhoneNetworkInfoV1 iCellInfoPLMN;
       
   424         TUint iCellInfoLAC;
       
   425         TUint iCellInfoCellId;
       
   426 
       
   427         // ETrue if HomeZone message has been received
       
   428         TBool iHomeZoneReceived;
       
   429 
       
   430         // HomeZone cache variables
       
   431         RMobilePhone::TMobilePhoneNetworkInfoV1 iHomeZonePLMN;
       
   432         TUint iHomeZoneLAC;
       
   433         TUint iHomeZoneCellId;
       
   434 
       
   435         // Current HomeZone message
       
   436         TMcnMessage iCurrentHomeZoneMessage;
       
   437 
       
   438         // Message factory
       
   439         CCbsMessageFactory* iFactory;
       
   440 
       
   441         // LC message handler
       
   442         CCbsLivecastHandler* iLivecastHandler;
       
   443 
       
   444         // Local variation bits, fetched from CenRep
       
   445         TInt iLVBits;
       
   446                 
       
   447         // Indication of new SIM Topics
       
   448         TBool iNewSimTopicsAdded;
       
   449         
       
   450         __DECLARE_TEST;
       
   451     };
       
   452 
       
   453 #endif      //  CCBSRECETEL_H   
       
   454             
       
   455 // End of File
       
   456 
       
   457