satengine/SatServer/Commands/ProvideLocalInfoCmd/src/CProvideLocalInfoHandler.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Handles ProvideLocalInfo command
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    "MSatApi.h"
       
    20 #include    "MSatUtils.h"
       
    21 #include    "MSatUiSession.h"
       
    22 #include    "MSatSystemState.h"
       
    23 #include    "SatSOpcodes.h"
       
    24 #include    "MSatSUiClientHandler.h"
       
    25 #include    "MSatEventMonitorContainer.h"
       
    26 #include    "CProvideLocalInfoHandler.h"
       
    27 #include    "SatLog.h"
       
    28 
       
    29 const TInt8 KLangDescrSize( 2 );
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CProvideLocalInfoHandler::CProvideLocalInfoHandler
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CProvideLocalInfoHandler::CProvideLocalInfoHandler() :
       
    40     CSatCommandHandler(),
       
    41     iLocalInfoData(),
       
    42     iLocalInfoPckg( iLocalInfoData ),
       
    43     iLocalInfoRsp(),
       
    44     iLocalInfoRspPckg( iLocalInfoRsp )
       
    45     {
       
    46     LOG( SIMPLE,
       
    47         "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
    48             CProvideLocalInfoHandler calling - exiting" )
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CProvideLocalInfoHandler::NewL
       
    53 // Two-phased constructor.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CProvideLocalInfoHandler* CProvideLocalInfoHandler::NewL( MSatUtils* aUtils )
       
    57     {
       
    58     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::NewL calling" )
       
    59 
       
    60     CProvideLocalInfoHandler* self = new( ELeave ) CProvideLocalInfoHandler;
       
    61 
       
    62     CleanupStack::PushL( self );
       
    63     self->BaseConstructL( aUtils );
       
    64     // ConstructL not needed.
       
    65     CleanupStack::Pop( self );
       
    66 
       
    67     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::NewL exiting" )
       
    68     return self;
       
    69     }
       
    70 
       
    71 // Destructor
       
    72 CProvideLocalInfoHandler::~CProvideLocalInfoHandler()
       
    73     {
       
    74     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
    75         CProvideLocalInfoHandler calling" )
       
    76 
       
    77     Cancel();
       
    78 
       
    79     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
    80         ~CProvideLocalInfoHandler exiting" )
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CProvideLocalInfoHandler::ClientResponse
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 void CProvideLocalInfoHandler::ClientResponse()
       
    88     {
       
    89     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
    90         ClientResponse calling-exiting" )
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CProvideLocalInfoHandler::DoCancel
       
    95 // Cancels the sat request.
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void CProvideLocalInfoHandler::DoCancel()
       
    99     {
       
   100     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   101         DoCancel calling" )
       
   102 
       
   103     iUtils->USatAPI().NotifyLocalInfoCancel();
       
   104 
       
   105     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   106         DoCancel exiting" )
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CProvideLocalInfoHandler::IssueUSATRequest
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CProvideLocalInfoHandler::IssueUSATRequest( TRequestStatus& aStatus )
       
   114     {
       
   115     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   116         IssueUSATRequest calling" )
       
   117 
       
   118     // Clear the IPC package.
       
   119     new (&iLocalInfoData) RSat::TLocalInfoV3();
       
   120 
       
   121     iUtils->USatAPI().NotifyLocalInfo( aStatus, iLocalInfoPckg );
       
   122 
       
   123     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   124         IssueUSATRequest exiting" )
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CProvideLocalInfoHandler::CommandAllowed
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 TBool CProvideLocalInfoHandler::CommandAllowed()
       
   132     {
       
   133     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::CommandAllowed \
       
   134         calling - exiting" )
       
   135     return ETrue;
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CProvideLocalInfoHandler::NeedUiSession
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 TBool CProvideLocalInfoHandler::NeedUiSession()
       
   143     {
       
   144     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::NeedUiSession \
       
   145         calling - exiting" )
       
   146     return EFalse;
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CProvideLocalInfoHandler::HandleCommand
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 void CProvideLocalInfoHandler::HandleCommand()
       
   154     {
       
   155     LOG( SIMPLE,
       
   156         "PROVIDELOCALINFO: CProvideLocalInfoHandler::HandleCommand calling" )
       
   157 
       
   158     iUtils->NotifyEvent( MSatUtils::ELocalInfoExecuting );
       
   159 
       
   160     if ( RSat::KProvideLocalInfoLanguage == iLocalInfoData.iInfoType )
       
   161         {
       
   162         LOG( SIMPLE,"PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   163         HandleCommand KProvideLocalInfoLanguage" )
       
   164 
       
   165         // Get new display text language from SAT SystemState.
       
   166         TInt language( iUtils->SystemState().DisplayTextLanguage() );
       
   167 
       
   168         // Maximum size in ISO 639-1 language is 2.
       
   169         TBuf<KLangDescrSize> languageISO( KNullDesC );
       
   170 
       
   171         // Verify language.
       
   172         // If it is automatic, language preferred by SIM is used
       
   173         TRAPD( err, iUtils->EventMonitors()->LanguageSettingL( language ) );
       
   174         LOG2( NORMAL, 
       
   175         "PROVIDELOCALINFO: CProvideLocalInfoHandler::HandleCommand err %i", 
       
   176         err )
       
   177         if ( KErrNone == err )
       
   178             {
       
   179             LOG2( NORMAL, 
       
   180             "PROVIDELOCALINFO: CProvideLocalInfoHandler::HandleCommand \
       
   181             language: %i", language )
       
   182             // If language is automatic, language = 0
       
   183             if ( language )
       
   184                 {
       
   185                 // Event monitor container has the function for resolving
       
   186                 // language string
       
   187                 iUtils->EventMonitors()->GetLanguageString(
       
   188                     language, languageISO );
       
   189                 }
       
   190             }
       
   191         
       
   192         // Check the language string and build the response
       
   193         if ( languageISO != KNullDesC )
       
   194             {
       
   195             LOG( NORMAL, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   196                 HandleCommand Success" )
       
   197             iLocalInfoRsp.iGeneralResult = RSat::KSuccess;
       
   198             iLocalInfoRsp.iInfoType = RSat::KLocalInformation;
       
   199             iLocalInfoRsp.iAdditionalInfo.Copy( languageISO );
       
   200             }
       
   201         else
       
   202             {
       
   203             LOG( NORMAL, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   204                 HandleCommand UnableToProcessCmd" )
       
   205             iLocalInfoRsp.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   206             iLocalInfoRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   207             iLocalInfoRsp.iAdditionalInfo.Zero();
       
   208             }
       
   209         }
       
   210     else
       
   211         {
       
   212         LOG( NORMAL, "PROVIDELOCALINFO: CProvideLocalInfoHandler::\
       
   213                 HandleCommand TypeNotUnderstood" )
       
   214         iLocalInfoRsp.iGeneralResult = RSat::KCmdTypeNotUnderstood;
       
   215         iLocalInfoRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   216         iLocalInfoRsp.iAdditionalInfo.Zero();
       
   217         }
       
   218 
       
   219     iLocalInfoRsp.SetPCmdNumber( iLocalInfoData.PCmdNumber() );
       
   220     TerminalRsp( RSat::ELocalInfo, iLocalInfoRspPckg );
       
   221 
       
   222     LOG( SIMPLE,
       
   223         "PROVIDELOCALINFO: CProvideLocalInfoHandler::HandleCommand exiting" )
       
   224     }
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CProvideLocalInfoHandler::UiLaunchFailed
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 void CProvideLocalInfoHandler::UiLaunchFailed()
       
   231     {
       
   232     LOG( SIMPLE, "PROVIDELOCALINFO: CProvideLocalInfoHandler::UiLaunchFailed \
       
   233         calling-exiting" )
       
   234     }