cellular/telephonysettings/src/PsetCli.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002 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:  CPsetCli is provides calling line identification SS.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //INCLUDE FILES
       
    21 #include "psetcli.h" 
       
    22 #include "psetpanic.h" 
       
    23 #include "psetconstants.h" 
       
    24 #include "mpsetrequestobs.h" 
       
    25 #include <bldvariant.hrh>
       
    26 #include <featmgr.h>
       
    27 
       
    28 // CONSTANTS    
       
    29 _LIT( KPSNameOfClass, "CPsetCli" );
       
    30 
       
    31 //  MEMBER FUNCTIONS
       
    32 // ---------------------------------------------------------------------------
       
    33 // Symbian OS 1st phase Constructor.
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C CPsetCli* CPsetCli::NewL( RMobilePhone& aPhone, MPsetCliObserver& aObserver )
       
    37     {
       
    38     CPsetCli* self = new ( ELeave ) CPsetCli( aPhone );
       
    39     CleanupStack::PushL( self );
       
    40     // Sets up TLS, must be done before FeatureManager is used.
       
    41     FeatureManager::InitializeLibL();
       
    42     CleanupStack::Pop( self );
       
    43     self->SetObserver( aObserver );
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Destructor.
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C CPsetCli::~CPsetCli()
       
    52     {
       
    53     // Remove FeatureManager
       
    54     FeatureManager::UnInitializeLib();
       
    55     Cancel();
       
    56     iReqObserver = NULL;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // C++ Constructor.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CPsetCli::CPsetCli( RMobilePhone& aPhone ) : CActive( EPriorityStandard ),
       
    64 iPhone( aPhone )
       
    65     {
       
    66     CActiveScheduler::Add( this );
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Cancels all requests.
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C void CPsetCli::CancelAll()
       
    74     {
       
    75     // Set PSUI so that correct observer is used and hide requesting note.
       
    76     // When interrupting a note, does not leave.
       
    77     // This needs to be done first, since notes must be cleared from screen
       
    78     // even though request is not active.
       
    79     iObserver->SetEngineContact( this );
       
    80     TRAPD( ignore, iObserver->HandleCliRequestingL( EFalse, ETrue ) );
       
    81     // Line below fixes armv5 warning.
       
    82     ignore = ignore;
       
    83     
       
    84     if ( !IsActive() )
       
    85         {
       
    86         return;
       
    87         }    
       
    88     
       
    89     Cancel();
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // Requests for COLP mode.
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 EXPORT_C void CPsetCli::GetColpModeL()
       
    97     {
       
    98     /*****************************************************
       
    99     *    Series 60 Customer / ETel
       
   100     *    Series 60  ETel API
       
   101     *****************************************************/
       
   102     IssueRequestL( RMobilePhone::EIdServiceConnectedPresentation );
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Requests for CLIP mode.
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 EXPORT_C void CPsetCli::GetClipModeL()
       
   110     {
       
   111     /*****************************************************
       
   112     *    Series 60 Customer / ETel
       
   113     *    Series 60  ETel API
       
   114     *****************************************************/
       
   115     IssueRequestL( RMobilePhone::EIdServiceCallerPresentation );
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // Requests for COLP mode.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C void CPsetCli::GetClirModeL()
       
   123     {
       
   124     /*****************************************************
       
   125     *    Series 60 Customer / ETel
       
   126     *    Series 60  ETel API
       
   127     *****************************************************/
       
   128     IssueRequestL( RMobilePhone::EIdServiceCallerRestriction );
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // Requests for COLR mode.
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 EXPORT_C void CPsetCli::GetColrModeL()
       
   136     {
       
   137     /*****************************************************
       
   138     *    Series 60 Customer / ETel
       
   139     *    Series 60  ETel API
       
   140     *****************************************************/
       
   141     IssueRequestL( RMobilePhone::EIdServiceConnectedRestriction );
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // Sets request observer.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C void CPsetCli::SetRequestObserver( MPsetRequestObserver* aObs )
       
   149     {
       
   150     iReqObserver = aObs;
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // Make request to get CNAP status
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C void CPsetCli::GetCnapL()
       
   158     {
       
   159     if ( FeatureManager::FeatureSupported( KFeatureIdPhoneCnap ) )
       
   160         {
       
   161         /*****************************************************
       
   162         *    Series 60 Customer / ETel
       
   163         *    Series 60  ETel API
       
   164         *****************************************************/
       
   165         IssueRequestL( RMobilePhone::EIdServiceCallerName );
       
   166         }
       
   167     }
       
   168 
       
   169 //---------------------------------------------------------------------------
       
   170 // Handles completed request. 
       
   171 // 
       
   172 //---------------------------------------------------------------------------
       
   173 //
       
   174 void CPsetCli::RunL()
       
   175     {
       
   176     __ASSERT_ALWAYS( iObserver, Panic( KPSNameOfClass, ECliNoObserver ) );
       
   177     TBool commonNotes = ETrue;
       
   178     
       
   179     //Hide requesting note - does not leave when deleting a note.
       
   180     iObserver->SetEngineContact( this );
       
   181     iObserver->HandleCliRequestingL( EFalse, EFalse );
       
   182     if ( iStatus != KErrNone )
       
   183         {
       
   184         iObserver->HandleCliErrorL( iStatus.Int() );
       
   185         RequestCompleted( iStatus.Int() );        
       
   186         return;
       
   187         }
       
   188     
       
   189     TPsuiCli type = EPsuiCliUnknown; 
       
   190     
       
   191     switch ( iRequestedService )
       
   192         {
       
   193         /*****************************************************
       
   194         *    Series 60 Customer / ETel
       
   195         *    Series 60  ETel API
       
   196         *****************************************************/
       
   197         case RMobilePhone::EIdServiceConnectedRestriction:
       
   198             switch ( iServiceStatus )
       
   199                 {
       
   200                 case RMobilePhone::EIdServiceActivePermanent:
       
   201                     type = EPsuiColrOn;
       
   202                     break;
       
   203                 case RMobilePhone::EIdServiceNotProvisioned:
       
   204                     type = EPsuiColrOff;
       
   205                     break;
       
   206                 case RMobilePhone::EIdServiceUnknown:
       
   207                     type = EPsuiCliUnknown;
       
   208                     break;
       
   209                 default:
       
   210                     break;
       
   211                 }
       
   212             break;
       
   213         case RMobilePhone::EIdServiceConnectedPresentation:
       
   214             switch ( iServiceStatus )
       
   215                 
       
   216                 {
       
   217                 case RMobilePhone::EIdServiceActivePermanent:
       
   218                     type = EPsuiColpOn;
       
   219                     break;
       
   220                 case RMobilePhone::EIdServiceNotProvisioned:
       
   221                     type = EPsuiColpOff;
       
   222                     break;
       
   223                 case RMobilePhone::EIdServiceUnknown:
       
   224                     type = EPsuiCliUnknown;
       
   225                     break;
       
   226                 default:
       
   227                     break;
       
   228                 }
       
   229             break;
       
   230         case RMobilePhone::EIdServiceCallerRestriction:
       
   231             switch ( iServiceStatus )
       
   232             
       
   233                 {
       
   234                 case RMobilePhone::EIdServiceActivePermanent:                
       
   235                 case RMobilePhone::EIdServiceActiveDefaultRestricted:
       
   236                     type = EPsuiClirOn;
       
   237                     break;
       
   238                 case RMobilePhone::EIdServiceActiveDefaultAllowed:
       
   239                 case RMobilePhone::EIdServiceNotProvisioned:
       
   240                     type = EPsuiClirOff;
       
   241                     break;
       
   242                 case RMobilePhone::EIdServiceUnknown:
       
   243                     type = EPsuiCliUnknown;
       
   244                     break;
       
   245                 default:
       
   246                     break;
       
   247                 }
       
   248             break;
       
   249         case RMobilePhone::EIdServiceCallerPresentation:
       
   250             switch ( iServiceStatus )
       
   251                 {
       
   252                 case RMobilePhone::EIdServiceActivePermanent:
       
   253                     type = EPsuiClipOn;
       
   254                     break;
       
   255                 case RMobilePhone::EIdServiceNotProvisioned:
       
   256                     type = EPsuiClipOff;
       
   257                     break;
       
   258                 case RMobilePhone::EIdServiceUnknown:
       
   259                     type = EPsuiCliUnknown;
       
   260                     break;
       
   261                 default:
       
   262                     break;
       
   263                 }
       
   264             break;
       
   265         case RMobilePhone::EIdServiceCallerName:
       
   266             commonNotes = EFalse;
       
   267             iObserver->HandleCnapStatusL( iServiceStatus );
       
   268             break;
       
   269         default:
       
   270             Panic( KPSNameOfClass, ECliParameter );
       
   271             break;
       
   272         } 
       
   273 
       
   274     if ( commonNotes )
       
   275         {
       
   276         iObserver->CliInformationL( type );
       
   277         }    
       
   278     RequestCompleted( KErrNone );
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // Cancels pending request.
       
   283 // 
       
   284 // ---------------------------------------------------------------------------
       
   285 //
       
   286 void CPsetCli::DoCancel()
       
   287     {
       
   288     if ( !IsActive() )
       
   289         {
       
   290         return;
       
   291         }
       
   292     switch ( iRequestedService )
       
   293         {
       
   294         /*****************************************************
       
   295         *    Series 60 Customer / ETel
       
   296         *    Series 60  ETel API
       
   297         *****************************************************/
       
   298         case RMobilePhone::EIdServiceConnectedRestriction:
       
   299         case RMobilePhone::EIdServiceConnectedPresentation:
       
   300         case RMobilePhone::EIdServiceCallerRestriction:
       
   301         case RMobilePhone::EIdServiceCallerPresentation:
       
   302         case RMobilePhone::EIdServiceCallerName:
       
   303             iPhone.CancelAsyncRequest( EMobilePhoneGetIdentityServiceStatus );
       
   304             break;
       
   305         default:
       
   306             break;            
       
   307         }
       
   308     SetRequestStatus( RMobilePhone::EIdServiceUnspecified );
       
   309     }
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // Sets observer.
       
   313 // ---------------------------------------------------------------------------
       
   314 //
       
   315 void CPsetCli::SetObserver( MPsetCliObserver& aObserver )
       
   316     {
       
   317     iObserver = &aObserver;
       
   318     iObserver->SetEngineContact( this );
       
   319     }
       
   320 
       
   321 // ---------------------------------------------------------------------------
       
   322 // 
       
   323 // Push object into cleanupstack to catch leaving.
       
   324 // 
       
   325 // ---------------------------------------------------------------------------
       
   326 //
       
   327 void CPsetCli::CleanupLeavePushL()
       
   328     {
       
   329     CleanupStack::PushL( TCleanupItem( DoHandleLeave, this ) );
       
   330     }
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 // 
       
   334 // Things to do when leave occurs.
       
   335 // 
       
   336 // ---------------------------------------------------------------------------
       
   337 //
       
   338 void CPsetCli::HandleLeave()
       
   339     {
       
   340     CancelAll();
       
   341     }
       
   342 
       
   343 // ---------------------------------------------------------------------------
       
   344 // 
       
   345 // Object has caused a leave.
       
   346 // 
       
   347 // ---------------------------------------------------------------------------
       
   348 //
       
   349 void CPsetCli::DoHandleLeave( TAny* aAny )
       
   350     {
       
   351     REINTERPRET_CAST( CPsetCli*, aAny )->HandleLeave();
       
   352     }
       
   353 
       
   354 // ---------------------------------------------------------------------------
       
   355 // Inform the request observer that request has been completed.
       
   356 // ---------------------------------------------------------------------------
       
   357 //
       
   358 void CPsetCli::RequestCompleted( const TInt& aError )
       
   359     {
       
   360     if ( aError != KErrNone )
       
   361         {
       
   362         SetRequestStatus( 
       
   363             static_cast <RMobilePhone::TMobilePhoneIdService> (aError) );
       
   364         }
       
   365     SetRequestStatus( RMobilePhone::EIdServiceUnspecified );
       
   366     
       
   367     if ( iReqObserver )
       
   368         {
       
   369         iReqObserver->RequestComplete(); 
       
   370         }
       
   371     }
       
   372 
       
   373 // ---------------------------------------------------------------------------
       
   374 // Issues pre-defined request.
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 void CPsetCli::IssueRequestL( RMobilePhone::TMobilePhoneIdService aService ) 
       
   378     {    
       
   379     if ( IsActive() )
       
   380         {
       
   381         /*****************************************************
       
   382         *    Series 60 Customer / ETel
       
   383         *    Series 60  ETel API
       
   384         *****************************************************/
       
   385         User::Leave( KErrGeneral );
       
   386         }    
       
   387     SetRequestStatus( aService );
       
   388        
       
   389     iPhone.GetIdentityServiceStatus( iStatus, aService, iServiceStatus );    
       
   390     SetActive();
       
   391     
       
   392     // Set PSUI so that correct observer is used and show note.
       
   393     iObserver->SetEngineContact( this );
       
   394     CleanupLeavePushL();    
       
   395     iObserver->HandleCliRequestingL( ETrue, EFalse );
       
   396     CleanupStack::Pop(); // CleanupCancelPushL
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // Update the request status - both internally and to observers.
       
   401 // ---------------------------------------------------------------------------
       
   402 //
       
   403 void CPsetCli::SetRequestStatus( RMobilePhone::TMobilePhoneIdService aStatus )
       
   404     {
       
   405     iRequestedService = aStatus;
       
   406     if ( iReqObserver )
       
   407         {
       
   408         iReqObserver->RequestStatusChanged( aStatus );
       
   409         }
       
   410     }
       
   411 
       
   412 // End of file