cbs/CbsServer/ServerSrc/CCbsMessageFactory.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2004-2009 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:  Implementation of CCbsMessageFactory class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <featmgr.h>
       
    21 
       
    22 #include "CCbsMessageFactory.h"
       
    23 #include "CCbsRecMessage.h"
       
    24 #include "CCbsRecWcdmaMessage.h"
       
    25 #include "CCbsRecEtel.h"
       
    26 #include "CbsLogger.h"
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CCbsMessageFactory::CCbsMessageFactory
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CCbsMessageFactory::CCbsMessageFactory( CCbsRecEtel& aRecEtel )
       
    37 : iRecEtel( aRecEtel )
       
    38     {    
       
    39     }
       
    40 
       
    41 // Destructor    
       
    42 CCbsMessageFactory::~CCbsMessageFactory()
       
    43     {
       
    44     CBSLOGSTRING("CBSSERVER: >>> CCbsMessageFactory::~CCbsMessageFactory()");
       
    45     CBSLOGSTRING("CBSSERVER: <<< CCbsMessageFactory::~CCbsMessageFactory()");
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CCbsMessageFactory::NewL
       
    50 // Two-phased constructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CCbsMessageFactory* CCbsMessageFactory::NewL( CCbsRecEtel& aRecEtel )
       
    54     {
       
    55     CBSLOGSTRING("CBSSERVER: >>> CCbsMessageFactory::NewL()");
       
    56 
       
    57     CCbsMessageFactory* self = new ( ELeave ) CCbsMessageFactory( aRecEtel );
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop();
       
    61 
       
    62     CBSLOGSTRING("CBSSERVER: <<< CCbsMessageFactory::NewL()");
       
    63     return self;
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CCbsMessageFactory::ConstructL
       
    68 // Symbian 2nd phase constructor can leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CCbsMessageFactory::ConstructL()
       
    72     {
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CCbsMessageFactory::CreateMessageL
       
    77 // Creates a CB message.
       
    78 // (other items were commented in a header).
       
    79 // -----------------------------------------------------------------------------
       
    80 // 
       
    81 CCbsMessage* CCbsMessageFactory::CreateMessageL( const TDes8& aMessagePage,
       
    82     const RMobileBroadcastMessaging::TMobileBroadcastAttributesV2& aAttributes,
       
    83     TCbsMessageType& aMsgType )
       
    84     {
       
    85     CBSLOGSTRING("CBSSERVER: >>> CCbsMessageFactory::CreateMessageL()");
       
    86 
       
    87     CCbsMessage* currentMessage;
       
    88     currentMessage = NULL;
       
    89     
       
    90     if ( aAttributes.iFormat == RMobileBroadcastMessaging::EFormatWcdmaTpdu )
       
    91         {
       
    92         // Accept WCDMA messages only if the feature is supported.
       
    93         FeatureManager::InitializeLibL();
       
    94         
       
    95         if ( FeatureManager::FeatureSupported( KFeatureIdFf3gCellbroadcast ) )
       
    96             {
       
    97             CBSLOGSTRING("CBSSERVER: CCbsMessageFactory::CreateMessageL(): WCDMA msg...");
       
    98             currentMessage = CCbsRecWcdmaMessage::NewL( 
       
    99                 aMessagePage, aAttributes );        
       
   100             CBSLOGSTRING("CBSSERVER: CCbsMessageFactory::CreateMessageL(): WCDMA msg created OK.");
       
   101 
       
   102             iAttributes = aAttributes;
       
   103 
       
   104             // Set the message type
       
   105             aMsgType = ECbsMessageWcdma;
       
   106             }
       
   107         else
       
   108             {
       
   109             CBSLOGSTRING("CBSSERVER: CCbsMessageFactory::CreateMessageL(): WCDMA messages not supported, currentMessage set to NULL.");
       
   110             currentMessage = NULL;
       
   111             }
       
   112         FeatureManager::UnInitializeLib();
       
   113         }
       
   114     else if ( aAttributes.iFormat == RMobileBroadcastMessaging::EFormatGsmTpdu ||
       
   115         aAttributes.iFormat == RMobileBroadcastMessaging::EFormatUnspecified )
       
   116         {        
       
   117         CBSLOGSTRING("CBSSERVER: CCbsMessageFactory::CreateMessageL(): GSM msg...");
       
   118         currentMessage = CCbsRecMessage::NewL( aMessagePage );        
       
   119         CBSLOGSTRING("CBSSERVER: CCbsMessageFactory::CreateMessageL(): GSM msg created OK.");
       
   120 
       
   121         // Set the message type
       
   122         aMsgType = ECbsMessageGsm;
       
   123         }
       
   124     else
       
   125         {        
       
   126         CBSLOGSTRING("CBSSERVER: CCbsMessageFactory::CreateMessageL(): Unknown msg type, currentMessage set to NULL.");
       
   127         currentMessage = NULL;
       
   128         }
       
   129 
       
   130     if ( currentMessage )
       
   131         {
       
   132         // Livecast messages are handled separately
       
   133         if ( currentMessage->IsLivecastMessage() )
       
   134             {        
       
   135             CBSLOGSTRING("CBSSERVER: CCbsMessageFactory::CreateMessageL(): This is a LC msg, setting type to ECbsMessageLivecast.");
       
   136             // Set the message type
       
   137             aMsgType = ECbsMessageLivecast;    
       
   138             }
       
   139         }
       
   140     
       
   141     CBSLOGSTRING("CBSSERVER: <<< CCbsMessageFactory::CreateMessageL(), returning currentMessage");
       
   142     return currentMessage;    
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CCbsMessageFactory::CreateMessageL
       
   147 // Creates a CB message.
       
   148 // (other items were commented in a header).
       
   149 // -----------------------------------------------------------------------------
       
   150 // 
       
   151 CCbsMessage* CCbsMessageFactory::CreateMessageL( const CCbsMessage& aMessage )
       
   152     {
       
   153     CCbsMessage* message;
       
   154     message = NULL;
       
   155     
       
   156     if ( iAttributes.iFormat == RMobileBroadcastMessaging::EFormatWcdmaTpdu )
       
   157         {
       
   158         message = CCbsRecWcdmaMessage::NewL( aMessage );
       
   159         }
       
   160     else if ( iAttributes.iFormat == RMobileBroadcastMessaging::EFormatGsmTpdu ||
       
   161         iAttributes.iFormat == RMobileBroadcastMessaging::EFormatUnspecified )
       
   162         {
       
   163         message = CCbsRecMessage::NewL( aMessage );
       
   164         }
       
   165 
       
   166     return message;
       
   167     }
       
   168 
       
   169 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   170 
       
   171 //  End of File