satengine/SatServer/Commands/SendSSCmd/src/csatsendsshandler.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2010 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:  Process forwarding procedures.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "csatsendsshandler.h"
       
    19 #include <psetcallwaiting.h>
       
    20 #include <psetcontainer.h>
       
    21 #include <psetcallbarring.h>
       
    22 #include <psetcalldiverting.h>
       
    23 #include <psetcli.h>
       
    24 
       
    25 #include "csatsendssbarringnouiobs.h"
       
    26 #include "csatsendssdivertnouiobs.h"
       
    27 #include "csatsendsscallwaitingnouiobs.h"
       
    28 #include "csatsendssclinouiobs.h"
       
    29 
       
    30 #include    "SatLog.h"
       
    31 
       
    32 // ================= MEMBER FUNCTIONS ==========================================
       
    33 
       
    34 // Destructor
       
    35 CSatSendSsHandler::~CSatSendSsHandler()
       
    36     {
       
    37     delete iDivert;
       
    38     delete iBarring;
       
    39     delete iWaiting;
       
    40     delete iCli;
       
    41     delete iSettings;
       
    42     delete iSatCwObserver;
       
    43     delete iSatCbObserver;
       
    44     delete iSatCliObserver;
       
    45     delete iSatCfObserver;
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CSatSendSsHandler::ProcessForwardingL
       
    50 // -----------------------------------------------------------------------------
       
    51 void CSatSendSsHandler::ProcessForwardingL(
       
    52         TAction aAction,
       
    53         TForwardingProcedure aForwarding,
       
    54         const TDesC& aNumber,
       
    55         const TDesC& aBasicCode,
       
    56         const TDesC& aTimer )
       
    57     {
       
    58     LOG( SIMPLE, "CSatSendSsHandler::ProcessForwardingL calling" )
       
    59 
       
    60     TBasicServiceGroups bsc = ChangeToBsc( aBasicCode );
       
    61     ConnectToSsEngineL();
       
    62 
       
    63     TCallDivertSetting setDivert;
       
    64     setDivert.iNumber.Copy( aNumber );
       
    65     setDivert.iServiceGroup = EServiceGroupVoice;
       
    66     setDivert.iStatus = EDivertingStatusUnknown;
       
    67     setDivert.iNoReplyTimer = 0;// all unconditional
       
    68 
       
    69     LOG2( NORMAL, 
       
    70     "CSatSendSsHandler::ProcessForwardingL aForwarding: %d", aForwarding )
       
    71     switch ( aForwarding )
       
    72         {
       
    73         case EForwardingNotReachable:
       
    74             {
       
    75             LOG( NORMAL, 
       
    76             "CSatSendSsHandler::ProcessForwardingL EForwardingNotReachable" )
       
    77             setDivert.iCondition = EDivertConditionNotReachable;
       
    78             break;
       
    79             }
       
    80 
       
    81         case EForwardingNoReply:
       
    82             {
       
    83             LOG( NORMAL, 
       
    84             "CSatSendSsHandler::ProcessForwardingL EForwardingNoReply" )
       
    85             if ( aTimer.Length() != 0 )
       
    86                 {
       
    87                 TLex input( aTimer );
       
    88                 User::LeaveIfError( input.Val( setDivert.iNoReplyTimer ) );
       
    89                 }
       
    90             else
       
    91                 {
       
    92                 LOG( NORMAL, 
       
    93                 "CSatSendSsHandler::ProcessForwardingL iNoReplyTimer" )
       
    94                 setDivert.iNoReplyTimer = iDivert->GetTimerValueL();
       
    95                 }
       
    96             setDivert.iCondition = EDivertConditionNoReply;
       
    97             break;
       
    98             }
       
    99 
       
   100         case EForwardingBusy:
       
   101             {
       
   102             LOG( NORMAL, 
       
   103             "CSatSendSsHandler::ProcessForwardingL EForwardingBusy" )
       
   104             setDivert.iCondition = EDivertConditionBusy;
       
   105             break;
       
   106             }
       
   107 
       
   108         case EForwardingUnconditional:
       
   109             {
       
   110             LOG( NORMAL, 
       
   111             "CSatSendSsHandler::ProcessForwardingL EForwardingUnconditional" )
       
   112             setDivert.iCondition = EDivertConditionUnconditional;
       
   113             break;
       
   114             }
       
   115 
       
   116         case EForwardingAll:
       
   117             {
       
   118             LOG( NORMAL, 
       
   119             "CSatSendSsHandler::ProcessForwardingL EForwardingAll" )
       
   120             setDivert.iCondition = EDivertConditionAllCalls;
       
   121             break;
       
   122             }
       
   123 
       
   124         case EForwardingAllConditional:
       
   125             {
       
   126             LOG( NORMAL, 
       
   127             "CSatSendSsHandler::ProcessForwardingL \
       
   128             EForwardingAllConditional" )
       
   129             setDivert.iCondition = EDivertConditionAllConditionalCases;
       
   130             break;
       
   131             }
       
   132 
       
   133         default:
       
   134             {
       
   135             LOG( NORMAL, 
       
   136             "CSatSendSsHandler::ProcessForwardingL Unknown forwarding" )
       
   137             break;
       
   138             }
       
   139         }
       
   140 
       
   141     switch ( aAction )
       
   142         {
       
   143         case EActivate:
       
   144             {
       
   145             LOG( NORMAL, "CSatSendSsHandler::EActivate" )
       
   146             setDivert.iSetting = EActivateDiverting;
       
   147             iDivert->SetDivertingL( setDivert, bsc );
       
   148             break;
       
   149             }
       
   150 
       
   151         case EDeactivate:
       
   152             {
       
   153             LOG( NORMAL, "CSatSendSsHandler::EDeactivate" )
       
   154             setDivert.iSetting = ECancelDiverting;
       
   155             iDivert->SetDivertingL( setDivert, bsc );
       
   156             break;
       
   157             }
       
   158 
       
   159         case EInterrogate:
       
   160             {
       
   161             LOG( NORMAL, "CSatSendSsHandler::EInterrogate" )
       
   162             iDivert->GetDivertingStatusL( EServiceGroupVoice,
       
   163                 setDivert.iCondition, bsc );
       
   164             break;
       
   165             }
       
   166 
       
   167         case ERegister:
       
   168             {
       
   169             LOG( NORMAL, "CSatSendSsHandler::ERegister" )
       
   170             setDivert.iSetting = ERegisterDiverting;
       
   171             iDivert->SetDivertingL( setDivert, bsc );
       
   172             break;
       
   173             }
       
   174 
       
   175         case EErase:
       
   176             {
       
   177             LOG( NORMAL, "CSatSendSsHandler::EErase" )
       
   178             setDivert.iSetting = EEraseDiverting;
       
   179             iDivert->SetDivertingL( setDivert, bsc );
       
   180             break;
       
   181             }
       
   182 
       
   183         default:
       
   184             {
       
   185             LOG( NORMAL, "  Unknown action" )
       
   186             break;
       
   187             }
       
   188         }
       
   189 
       
   190     LOG( SIMPLE, "CSatSendSsHandler::ProcessForwardingL exiting" )
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CSatSendSsHandler::ProcessBarringL
       
   195 // -----------------------------------------------------------------------------
       
   196 void CSatSendSsHandler::ProcessBarringL(
       
   197         TAction aAction,
       
   198         TBarringProcedure aBarring,
       
   199         const TDesC& aPassword,
       
   200         const TDesC& aBasicCode )
       
   201     {
       
   202     LOG2( SIMPLE, "CSatSendSsHandler::ProcessBarringL calling, aBarring: %d",
       
   203           aBarring )
       
   204 
       
   205     TBasicServiceGroups bsc = ChangeToBsc( aBasicCode );
       
   206     ConnectToSsEngineL();
       
   207     TCallBarringSetting setBarring;
       
   208     setBarring.iServiceGroup = EServiceGroupVoice;
       
   209 
       
   210     setBarring.iPassword = aPassword;
       
   211     switch ( aBarring )
       
   212         {
       
   213         case EBarringAllOutgoingCalls:
       
   214             {
       
   215             setBarring.iType = EBarringTypeAllOutgoing;
       
   216             break;
       
   217             }
       
   218 
       
   219         case EBarringAllOutgoingInternationalCalls:
       
   220             {
       
   221             setBarring.iType = EBarringTypeOutgoingInternational;
       
   222             break;
       
   223             }
       
   224 
       
   225         case EBarringAllOutgoingInternationalCallsExceptHome:
       
   226             {
       
   227             setBarring.iType = EBarringTypeOutgoingInternationalExceptToHomeCountry;
       
   228             break;
       
   229             }
       
   230 
       
   231         case EBarringAllIncomingCalls:
       
   232             {
       
   233             setBarring.iType = EBarringTypeAllIncoming;
       
   234             break;
       
   235             }
       
   236 
       
   237         case EBarringAllIncomingCallsWhenRoaming:
       
   238             {
       
   239             setBarring.iType = EBarringTypeIncomingWhenRoaming;
       
   240             break;
       
   241             }
       
   242 
       
   243         case EBarringAllServices:
       
   244             {
       
   245             setBarring.iType = EBarringTypeAllServices;
       
   246             break;
       
   247             }
       
   248 
       
   249         case EBarringAllOutgoingServices:
       
   250             {
       
   251             setBarring.iType = EBarringTypeAllOutgoingServices;
       
   252             break;
       
   253             }
       
   254 
       
   255         case EBarringAllIncomingServices:
       
   256             {
       
   257             setBarring.iType = EBarringTypeAllIncomingServices;
       
   258             break;
       
   259             }
       
   260 
       
   261         default:
       
   262             {
       
   263             break;
       
   264             }
       
   265         }
       
   266     LOG2( SIMPLE, "CSatSendSsHandler::ProcessBarringL aAction: %d", aAction )
       
   267     switch ( aAction )
       
   268         {
       
   269         case EActivate:
       
   270             {
       
   271             setBarring.iSetting = EActivateBarring;
       
   272             iBarring->SetBarringL( setBarring, bsc );
       
   273             break;
       
   274             }
       
   275 
       
   276         case EDeactivate:
       
   277             {
       
   278             setBarring.iSetting = ECancelBarring;
       
   279             iBarring->SetBarringL( setBarring, bsc );
       
   280             break;
       
   281             }
       
   282 
       
   283         case EInterrogate:
       
   284             {
       
   285             iBarring->GetBarringStatusL( EServiceGroupVoice, setBarring.iType );
       
   286             break;
       
   287             }
       
   288 
       
   289         case ERegister:
       
   290         case EErase:
       
   291         default:
       
   292             {
       
   293             break;
       
   294             }
       
   295         }
       
   296 
       
   297     LOG( SIMPLE, "CSatSendSsHandler::ProcessBarringL exiting" )
       
   298     }
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CSatSendSsHandler::ProcessPasswordChangeL
       
   302 // -----------------------------------------------------------------------------
       
   303 void CSatSendSsHandler::ProcessPasswordChangeL(
       
   304         TPasswordProcedure aPassword,
       
   305         const TDesC& aOldPassword,
       
   306         const TDesC& aNewPassword,
       
   307         const TDesC& aVerifyNewPassword )
       
   308     {
       
   309     LOG( SIMPLE, "CSatSendSsHandler::ProcessPasswordChangeL calling" )
       
   310 
       
   311     ConnectToSsEngineL();
       
   312 
       
   313     //check the validity of aNewPassword and aVerifyNewPassword
       
   314     if ( aNewPassword.Compare( aVerifyNewPassword ) != 0 )
       
   315         {
       
   316         LOG( SIMPLE, 
       
   317         "CSatSendSsHandler::ProcessPasswordChangeL password error" )
       
   318         // if not equal, show "PASSWORD ERROR"
       
   319         iSatCbObserver->HandleBarringErrorL( 1 );
       
   320         }
       
   321     else
       
   322         {
       
   323         RMobilePhone::TMobilePhonePasswordChangeV2 passWords;
       
   324         passWords.iOldPassword = aOldPassword;
       
   325         passWords.iNewPassword = aNewPassword;
       
   326         passWords.iVerifiedPassword = aVerifyNewPassword;
       
   327         // if equal send to cpsetcallbarring
       
   328         if ( aPassword == EPasswordBarring )
       
   329             {
       
   330             LOG( SIMPLE, 
       
   331             "CSatSendSsHandler::ProcessPasswordChangeL EPasswordBarring" )
       
   332             iBarring->ChangePasswordL( passWords, ETrue );
       
   333             }
       
   334         else
       
   335             {
       
   336             LOG( SIMPLE, 
       
   337             "CSatSendSsHandler::ProcessPasswordChangeL others" )
       
   338             iBarring->ChangePasswordL( passWords, EFalse );
       
   339             }
       
   340         }
       
   341 
       
   342     LOG( SIMPLE, "CSatSendSsHandler::ProcessPasswordChangeL exiting" )
       
   343     }
       
   344 
       
   345 // -----------------------------------------------------------------------------
       
   346 // CSatSendSsHandler::ChangeToBsc
       
   347 // -----------------------------------------------------------------------------
       
   348 TBasicServiceGroups CSatSendSsHandler::ChangeToBsc(
       
   349     const TDesC& aBasicCode ) const
       
   350     {
       
   351     LOG( SIMPLE, "CSatSendSsHandler::ChangeToBsc calling" )
       
   352 
       
   353     // Null values must be handled as well, length == 0
       
   354     if ( aBasicCode.Length() == 0 )
       
   355         {
       
   356         LOG( SIMPLE, "CSatSendSsHandler::ChangeToBsc length is zero" )
       
   357         return EAllTeleAndBearer;
       
   358         }
       
   359 
       
   360     TInt value = 0;
       
   361     TLex input( aBasicCode );
       
   362     input.Val( value );
       
   363 
       
   364     // Presumed that the values given in aBasicCode are not acting violently
       
   365     TBasicServiceGroups returnValue =
       
   366         static_cast<TBasicServiceGroups>( value );
       
   367 
       
   368     LOG( SIMPLE, "CSatSendSsHandler::ChangeToBsc exiting" )
       
   369     return returnValue;
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // CSatSendSsHandler::ConnectToSsEngine
       
   374 // -----------------------------------------------------------------------------
       
   375 void CSatSendSsHandler::ConnectToSsEngineL()
       
   376     {
       
   377     LOG( SIMPLE, "CSatSendSsHandler::ConnectToSsEngineL calling" )
       
   378 
       
   379     if ( !iSettings ) //create connection
       
   380         {
       
   381         LOG( SIMPLE, 
       
   382         "CSatSendSsHandler::ConnectToSsEngineL iSettings false" )
       
   383         //creates the containers
       
   384         iSettings = CPsetContainer::NewL();
       
   385 
       
   386         //call waiting engine
       
   387         iSatCwObserver = new ( ELeave ) CSatSendSsCallWaitingNoUiObs();
       
   388 
       
   389         iWaiting = iSettings->CreateCWObjectL( *iSatCwObserver );
       
   390 
       
   391         //call barring engine
       
   392         iSatCbObserver = new ( ELeave ) CSatSendSsBarringNoUiObs();
       
   393 
       
   394         iBarring = iSettings->CreateCBObjectL( *iSatCbObserver );
       
   395 
       
   396         iSatCliObserver = new ( ELeave ) CSatSendSsCliNoUiObs();
       
   397 
       
   398         iCli = iSettings->CreateCliObjectL( *iSatCliObserver );
       
   399 
       
   400         //call divert observer and engine
       
   401         iSatCfObserver = new ( ELeave ) CSatSendSsDivertNoUiObs();
       
   402 
       
   403         iDivert = iSettings->CreateCFObjectL( *iSatCfObserver );
       
   404         }
       
   405 
       
   406     LOG( SIMPLE, "CSatSendSsHandler::ConnectToSsEngineL exiting" )
       
   407     }
       
   408 
       
   409 // -----------------------------------------------------------------------------
       
   410 // CSatSendSsHandler::Cancel
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 void CSatSendSsHandler::Cancel()
       
   414     {
       
   415     LOG( SIMPLE, "CSatSendSsHandler::Cancel calling" )
       
   416 
       
   417     if ( iWaiting )
       
   418         {
       
   419         iWaiting->CancelProcess();
       
   420         }
       
   421 
       
   422     if ( iBarring )
       
   423         {
       
   424         iBarring->CancelCurrentRequest();
       
   425         }
       
   426 
       
   427     if ( iCli )
       
   428         {
       
   429         iCli->CancelAll();
       
   430         }
       
   431 
       
   432     if ( iDivert )
       
   433         {
       
   434         iDivert->CancelCurrentRequest();
       
   435         }
       
   436 
       
   437     LOG( SIMPLE, "CSatSendSsHandler::Cancel exiting" )
       
   438     }
       
   439 
       
   440 // -----------------------------------------------------------------------------
       
   441 // CSatSendSsHandler::ProcessWaitingL
       
   442 // -----------------------------------------------------------------------------
       
   443 void CSatSendSsHandler::ProcessWaitingL(
       
   444         TAction aAction,
       
   445         const TDesC& aBasicCode )
       
   446     {
       
   447     LOG2( SIMPLE, "CSatSendSsHandler::ProcessWaitingL calling,aAction: %d",
       
   448           aAction )
       
   449 
       
   450     TBasicServiceGroups bsc = ChangeToBsc( aBasicCode );
       
   451     ConnectToSsEngineL();
       
   452 
       
   453     switch ( aAction )
       
   454         {
       
   455         case EActivate:
       
   456             {
       
   457             iWaiting->SetCallWaitingL( MPsetCallWaiting::EActivateCallWaiting,
       
   458                 bsc );
       
   459             break;
       
   460             }
       
   461 
       
   462         case EDeactivate:
       
   463             {
       
   464             iWaiting->SetCallWaitingL( MPsetCallWaiting::EDeactivateCallWaiting,
       
   465                 bsc );
       
   466             break;
       
   467             }
       
   468 
       
   469         case EInterrogate:
       
   470             {
       
   471             iWaiting->GetCallWaitingStatusL();
       
   472             break;
       
   473             }
       
   474 
       
   475         case ERegister:
       
   476         case EErase:
       
   477         default:
       
   478             {
       
   479             break;
       
   480             }
       
   481         }
       
   482 
       
   483     LOG( SIMPLE, "CSatSendSsHandler::ProcessWaitingL exiting" )
       
   484     }
       
   485 
       
   486 // -----------------------------------------------------------------------------
       
   487 // CSatSendSsHandler::ProcessClipStatusL
       
   488 // -----------------------------------------------------------------------------
       
   489 void CSatSendSsHandler::ProcessClipStatusL()
       
   490     {
       
   491     LOG( SIMPLE, "CSatSendSsHandler::ProcessClipStatusL calling" )
       
   492 
       
   493     ConnectToSsEngineL();
       
   494     iCli->GetClipModeL();
       
   495 
       
   496     LOG( SIMPLE, "CSatSendSsHandler::ProcessClipStatusL exiting" )
       
   497     }
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CSatSendSsHandler::ProcessClirStatusL
       
   501 // -----------------------------------------------------------------------------
       
   502 void CSatSendSsHandler::ProcessClirStatusL()
       
   503     {
       
   504     LOG( SIMPLE, "CSatSendSsHandler::ProcessClirStatusL calling" )
       
   505 
       
   506     ConnectToSsEngineL();
       
   507     iCli->GetClirModeL();
       
   508 
       
   509     LOG( SIMPLE, "CSatSendSsHandler::ProcessClirStatusL calling" )
       
   510     }
       
   511 
       
   512 // -----------------------------------------------------------------------------
       
   513 // CSatSendSsHandler::ProcessColpStatusL
       
   514 // -----------------------------------------------------------------------------
       
   515 void CSatSendSsHandler::ProcessColpStatusL()
       
   516     {
       
   517     LOG( SIMPLE, "CSatSendSsHandler::ProcessColpStatusL calling" )
       
   518 
       
   519     ConnectToSsEngineL();
       
   520     iCli->GetColpModeL();
       
   521 
       
   522     LOG( SIMPLE, "CSatSendSsHandler::ProcessColpStatusL exiting" )
       
   523     }
       
   524 
       
   525 // -----------------------------------------------------------------------------
       
   526 // CSatSendSsHandler::ProcessColrStatusL
       
   527 // -----------------------------------------------------------------------------
       
   528 void CSatSendSsHandler::ProcessColrStatusL()
       
   529     {
       
   530     LOG( SIMPLE, "CSatSendSsHandler::ProcessColrStatusL calling" )
       
   531 
       
   532     ConnectToSsEngineL();
       
   533     iCli->GetColrModeL();
       
   534 
       
   535     LOG( SIMPLE, "CSatSendSsHandler::ProcessColrStatusL exiting " )
       
   536     }
       
   537 
       
   538 // -----------------------------------------------------------------------------
       
   539 // CSatSendSsHandler::ProcessCnapStatusL
       
   540 // -----------------------------------------------------------------------------
       
   541 void CSatSendSsHandler::ProcessCnapStatusL()
       
   542     {
       
   543     LOG( SIMPLE, "CSatSendSsHandler::ProcessCnapStatusL calling" )
       
   544 
       
   545     ConnectToSsEngineL();
       
   546     iCli->GetCnapL();
       
   547 
       
   548     LOG( SIMPLE, "CSatSendSsHandler::ProcessCnapStatusL exiting" )
       
   549     }
       
   550 
       
   551 // -----------------------------------------------------------------------------
       
   552 // CSatSendSsHandler::RequestComplete
       
   553 // -----------------------------------------------------------------------------
       
   554 void CSatSendSsHandler::RequestComplete()
       
   555     {
       
   556     LOG( SIMPLE, "CSatSendSsHandler::RequestComplete calling - exiting" )
       
   557     }
       
   558 
       
   559 // -----------------------------------------------------------------------------
       
   560 // CSatSendSsHandler::RequestStatusChanged
       
   561 // -----------------------------------------------------------------------------
       
   562 void CSatSendSsHandler::RequestStatusChanged( TInt aNewStatus )
       
   563     {
       
   564     LOG( SIMPLE, "CSatSendSsHandler::RequestStatusChanged calling" )
       
   565 
       
   566     TInt status = aNewStatus;
       
   567     status = status;
       
   568     LOG2( SIMPLE, "   RequestStatusChanged (%i)", status )
       
   569 
       
   570     LOG( SIMPLE, "CSatSendSsHandler::RequestStatusChanged exiting" )
       
   571     }
       
   572 
       
   573 //  End of File