convergedconnectionhandler/cchserver/src/cchserviceinfo.cpp
changeset 0 a4daefaec16c
child 12 876a3df1f464
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 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:  CCCHServiceInfo implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cchserviceinfo.h"
       
    21 #include "cchsubserviceinfo.h"
       
    22 #include "cchserverbase.h"
       
    23 #include "cchpluginhandler.h"
       
    24 #include "cchrequeststorage.h"
       
    25 #include "cchspshandler.h"
       
    26 #include "cchservicehandler.h"
       
    27 #include "cchlogger.h"
       
    28 #include "cchpluginhandler.h"
       
    29 
       
    30 // EXTERNAL DATA STRUCTURES
       
    31 // None
       
    32 
       
    33 // EXTERNAL FUNCTION PROTOTYPES
       
    34 // None
       
    35 
       
    36 // CONSTANTS
       
    37 // None
       
    38 
       
    39 // MACROS
       
    40 // None
       
    41 
       
    42 // LOCAL CONSTANTS AND MACROS
       
    43 // None
       
    44 
       
    45 // MODULE DATA STRUCTURES
       
    46 // None
       
    47 
       
    48 // LOCAL FUNCTION PROTOTYPES
       
    49 // None
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 // None
       
    53 
       
    54 // =========================== LOCAL FUNCTIONS ===============================
       
    55 
       
    56 // ============================ MEMBER FUNCTIONS =============================
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CCCHServiceInfo::CCCHServiceInfo
       
    60 // C++ default constructor can NOT contain any code, that might leave.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CCCHServiceInfo::CCCHServiceInfo( CCCHServerBase& aServer ):
       
    64     iServer( aServer ), 
       
    65     iReserved( ETrue )
       
    66     {
       
    67     // No implementation required
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CCCHServiceInfo::NewL
       
    72 // Two-phased constructor.
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CCCHServiceInfo* CCCHServiceInfo::NewL( CCCHServerBase& aServer )
       
    76     {
       
    77     CCCHServiceInfo* self = CCCHServiceInfo::NewLC( aServer );
       
    78     CleanupStack::Pop( self );
       
    79     return self;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CCCHServiceInfo::NewLC
       
    84 // Two-phased constructor.
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CCCHServiceInfo* CCCHServiceInfo::NewLC( CCCHServerBase& aServer )
       
    88     {
       
    89     CCCHServiceInfo* self = new (ELeave) CCCHServiceInfo( aServer );
       
    90     CleanupStack::PushL( self );
       
    91     return self;
       
    92     }
       
    93 
       
    94 // Destructor
       
    95 CCCHServiceInfo::~CCCHServiceInfo()
       
    96     {
       
    97     iSubservices.ResetAndDestroy();
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // CCCHServiceInfo::GetServiceId
       
   102 // (other items were commented in a header).
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 TUint32 CCCHServiceInfo::GetServiceId() const
       
   106     {
       
   107     return iServiceId;
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CCCHServiceInfo::SetServiceId
       
   112 // (other items were commented in a header).
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CCCHServiceInfo::SetServiceId( TUint32 aServiceId )
       
   116     {
       
   117     iServiceId = aServiceId;
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CCCHServiceInfo::GetName
       
   122 // (other items were commented in a header).
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 const TDesC CCCHServiceInfo::GetName() const
       
   126     {
       
   127     return iServiceName;
       
   128     }
       
   129     
       
   130 // ---------------------------------------------------------------------------
       
   131 // CCCHServiceInfo::SetName
       
   132 // (other items were commented in a header).
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 void CCCHServiceInfo::SetName( const TDesC& aName )
       
   136     {
       
   137     iServiceName.Copy( aName );
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CCCHServiceInfo::EnableL
       
   142 // (other items were commented in a header).
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 void CCCHServiceInfo::EnableL( 
       
   146     const TCCHSubserviceType aServiceType, 
       
   147     const TBool aConnectivityCheck,
       
   148     MCCHServiceNotifier* aNotifier )
       
   149     {
       
   150     CCHLOGSTRING( "CCCHServiceInfo::EnableL: IN" );
       
   151     CCHLOGSTRING2( "CCCHServiceInfo::EnableL: ServiceId = %d", iServiceId );
       
   152     CCHLOGSTRING2( "CCCHServiceInfo::EnableL: iType %d", aServiceType );
       
   153     CCHLOGSTRING2( "CCCHServiceInfo::EnableL: connectivitycheck %d", 
       
   154         aConnectivityCheck );
       
   155     
       
   156     RArray<TUid> uids;
       
   157     CleanupClosePushL( uids );
       
   158         
       
   159     TUid pluginUid( KNullUid );
       
   160     TBool found( EFalse );
       
   161     TUint iapId( 0 );
       
   162         
       
   163     for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   164         {
       
   165         pluginUid = iSubservices[ i ]->GetPluginUid();
       
   166             
       
   167         found = ( KErrNotFound != uids.Find( pluginUid ) );
       
   168            
       
   169         if ( !found && pluginUid != KNullUid && 
       
   170             ( ECCHUnknown == aServiceType ||
       
   171               aServiceType == iSubservices[ i ]->Type() ) )
       
   172             {
       
   173             uids.Append( pluginUid );
       
   174             }
       
   175         }
       
   176     
       
   177     0 < uids.Count() ? iServer.PluginHandler().EnableServiceL( 
       
   178         iServiceId, uids, aServiceType, aNotifier, iapId, aConnectivityCheck ) : 
       
   179             User::Leave( KErrNotFound );
       
   180     
       
   181     CleanupStack::PopAndDestroy( &uids );
       
   182     
       
   183     // Update service table
       
   184     if ( ECCHUnknown != aServiceType )
       
   185         {        
       
   186         iServer.SPSHandler().SetLoadAtStartUpL( iServiceId,
       
   187             aServiceType, ETrue );
       
   188         }
       
   189     else
       
   190         {
       
   191         for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   192             {
       
   193             iServer.SPSHandler().SetLoadAtStartUpL( iServiceId,
       
   194             iSubservices[ i ]->Type(), ETrue );
       
   195             }
       
   196         }        
       
   197     CCHLOGSTRING( "CCCHServiceInfo::EnableL: OUT" );
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CCCHServiceInfo::DisableL
       
   202 // (other items were commented in a header).
       
   203 // ---------------------------------------------------------------------------
       
   204 //
       
   205 void CCCHServiceInfo::DisableL( const TCCHSubserviceType aServiceType )
       
   206     {
       
   207     CCHLOGSTRING( "CCCHServiceInfo::DisableL: IN" );
       
   208     CCHLOGSTRING2( "CCCHServiceInfo::DisableL: ServiceId = %d", iServiceId );
       
   209     CCHLOGSTRING2( "CCCHServiceInfo::DisableL: iType %d", aServiceType );
       
   210     
       
   211     RArray<TUid> uids;
       
   212     CleanupClosePushL( uids );
       
   213         
       
   214     TUid pluginUid( KNullUid );
       
   215     TBool found( EFalse );
       
   216         
       
   217     for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   218         {
       
   219         pluginUid = iSubservices[ i ]->GetPluginUid();
       
   220             
       
   221         found = ( KErrNotFound != uids.Find( pluginUid ) );
       
   222                        
       
   223         if ( !found && pluginUid != KNullUid && 
       
   224             ( ECCHUnknown == aServiceType ||
       
   225               aServiceType == iSubservices[ i ]->Type() ) )
       
   226             {
       
   227             uids.Append( pluginUid );
       
   228             }
       
   229         }
       
   230     
       
   231     0 < uids.Count() ? iServer.PluginHandler().DisableServiceL( 
       
   232         iServiceId, uids, aServiceType ) : User::Leave( KErrNotFound );
       
   233         
       
   234     CleanupStack::PopAndDestroy( &uids );
       
   235     
       
   236     // Update service table
       
   237     if ( ECCHUnknown != aServiceType )
       
   238         {        
       
   239         iServer.SPSHandler().SetLoadAtStartUpL( iServiceId,
       
   240             aServiceType, EFalse );
       
   241         }
       
   242     else
       
   243         {
       
   244         for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   245             {
       
   246             iServer.SPSHandler().SetLoadAtStartUpL( iServiceId,
       
   247             iSubservices[ i ]->Type(), EFalse );
       
   248             }
       
   249         }
       
   250                 
       
   251     CCHLOGSTRING( "CCCHServiceInfo::DisableL: OUT" );
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // CCCHServiceInfo::SetConnectionInfoL
       
   256 // (other items were commented in a header).
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 void CCCHServiceInfo::SetConnectionInfoL( 
       
   260     const TServiceConnectionInfo aServiceConnInfo )
       
   261     {
       
   262     CCHLOGSTRING( "CCCHServiceInfo::SetConnectionInfoL: IN" );
       
   263     
       
   264     RArray<TUid> uids;
       
   265     CleanupClosePushL( uids );
       
   266         
       
   267     TUid pluginUid( KNullUid );
       
   268     TBool found( EFalse );
       
   269         
       
   270     for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   271         {        
       
   272         pluginUid = iSubservices[ i ]->GetPluginUid();
       
   273             
       
   274         found = ( KErrNotFound != uids.Find( pluginUid ) );
       
   275         
       
   276         if ( !found && pluginUid != KNullUid && 
       
   277             ( ECCHUnknown == aServiceConnInfo.iServiceSelection.iType ||
       
   278               aServiceConnInfo.iServiceSelection.iType == 
       
   279               iSubservices[ i ]->Type() ) )
       
   280             {
       
   281             uids.Append( pluginUid );
       
   282             }
       
   283         // Set connection information to subservice
       
   284         if ( ECCHUnknown == aServiceConnInfo.iServiceSelection.iType ||
       
   285               aServiceConnInfo.iServiceSelection.iType == 
       
   286               iSubservices[ i ]->Type() ) 
       
   287             {
       
   288             iSubservices[ i ]->SetIapId( aServiceConnInfo.iIapId );
       
   289             iSubservices[ i ]->SetSNAPId( aServiceConnInfo.iSNAPId );
       
   290             }
       
   291         }
       
   292     
       
   293     if ( 0 == uids.Count() )
       
   294         {
       
   295         User::Leave( KErrNotFound );
       
   296         }
       
   297                 
       
   298     if ( !aServiceConnInfo.iIapId && aServiceConnInfo.iSNAPId )
       
   299         {
       
   300         iServer.PluginHandler().SetSnapIdL( 
       
   301             aServiceConnInfo.ServiceId(), uids, 
       
   302                 aServiceConnInfo.Type(), 
       
   303                 aServiceConnInfo.iSNAPId );
       
   304         }
       
   305     else if ( aServiceConnInfo.iIapId && !aServiceConnInfo.iSNAPId )
       
   306         {
       
   307         iServer.PluginHandler().SetIapIdL( 
       
   308             aServiceConnInfo.ServiceId(), uids, 
       
   309                 aServiceConnInfo.Type(), 
       
   310                 aServiceConnInfo.iIapId );
       
   311         }
       
   312     else if ( aServiceConnInfo.iIapId && aServiceConnInfo.iSNAPId )
       
   313         {
       
   314         iServer.PluginHandler().SetIapIdL( 
       
   315             aServiceConnInfo.ServiceId(), uids, 
       
   316                 aServiceConnInfo.Type(),
       
   317                 aServiceConnInfo.iIapId );
       
   318         iServer.PluginHandler().SetSnapIdL( 
       
   319             aServiceConnInfo.ServiceId(), uids, 
       
   320             aServiceConnInfo.Type(),
       
   321                 aServiceConnInfo.iSNAPId );
       
   322         }
       
   323    
       
   324     // username must not be empty. And check this field should be set 
       
   325     if ( aServiceConnInfo.iServiceSelection.iParameter == ECchUsername && 
       
   326          aServiceConnInfo.iUsername.Length() )
       
   327         {
       
   328         iServer.PluginHandler().SetUsernameL( 
       
   329             aServiceConnInfo.ServiceId(), uids, 
       
   330                 aServiceConnInfo.Type(), 
       
   331                 aServiceConnInfo.iUsername );
       
   332         }
       
   333 
       
   334     // empty password is ok. And check this field should be set
       
   335     if ( aServiceConnInfo.iServiceSelection.iParameter == ECchPassword )
       
   336         {
       
   337         iServer.PluginHandler().SetPasswordL( 
       
   338             aServiceConnInfo.ServiceId(), uids, 
       
   339                 aServiceConnInfo.Type(), 
       
   340                 aServiceConnInfo.iPassword );
       
   341         }
       
   342     
       
   343     if ( aServiceConnInfo.iServiceSelection.iParameter == ECchReserved )
       
   344         {
       
   345         iReserved = aServiceConnInfo.iReserved;
       
   346         CCHLOGSTRING2( "CCCHServiceInfo::SetConnectionInfoL: reserved no action=%d", iReserved );
       
   347         }
       
   348 
       
   349     CleanupStack::PopAndDestroy( &uids );
       
   350     
       
   351     CCHLOGSTRING( "CCCHServiceInfo::SetConnectionInfoL: OUT" );
       
   352     }
       
   353     
       
   354 // ---------------------------------------------------------------------------
       
   355 // CCCHServiceInfo::GetConnectionInfoL
       
   356 // (other items were commented in a header).
       
   357 // ---------------------------------------------------------------------------
       
   358 //
       
   359 void CCCHServiceInfo::GetConnectionInfoL( 
       
   360         TServiceConnectionInfo& aServiceConnInfo ) const
       
   361         {
       
   362         CCHLOGSTRING( "CCCHServiceInfo::GetConnectionInfoL: IN" );
       
   363                
       
   364         TUid pluginUid( KNullUid );
       
   365         TInt index( KErrNone );
       
   366                
       
   367         if ( aServiceConnInfo.iServiceSelection.iType != ECCHUnknown )
       
   368             {
       
   369             index = FindSubservice( aServiceConnInfo.iServiceSelection.iType );
       
   370             }
       
   371 
       
   372                
       
   373         if ( KErrNotFound != index && iSubservices.Count() )
       
   374             {
       
   375                    
       
   376             pluginUid = iSubservices[ index ]->GetPluginUid();
       
   377 
       
   378             if( aServiceConnInfo.iServiceSelection.iParameter == ECchUsername )
       
   379                 {
       
   380                 const CCCHPluginHandler& ch = iServer.PluginHandler();
       
   381                 const TServiceConnectionInfo& css = aServiceConnInfo;
       
   382 
       
   383                 RBuf buffer; 
       
   384                 buffer.CreateL(KCCHMaxProtocolNameLength);
       
   385                 iServer.PluginHandler().GetConnectionParameter( 
       
   386                         pluginUid,
       
   387                         css.iServiceSelection, 
       
   388                         buffer );
       
   389 
       
   390                 aServiceConnInfo.iUsername = buffer;
       
   391                 buffer.Close();
       
   392                 }
       
   393             else if( aServiceConnInfo.iServiceSelection.iParameter == 
       
   394                                                         ECchReserved )
       
   395                 {
       
   396                 CCHLOGSTRING2( "CCCHServiceInfo::GetConnectionInfoL: reserved no action=%d", iReserved );
       
   397                 aServiceConnInfo.iReserved = iReserved;
       
   398                 }
       
   399             else
       
   400                 {
       
   401                 User::LeaveIfError( iServer.PluginHandler().GetServiceNetworkInfo( 
       
   402                     aServiceConnInfo.ServiceId(), pluginUid, aServiceConnInfo.Type(), 
       
   403                         aServiceConnInfo.iSNAPId, aServiceConnInfo.iIapId, 
       
   404                         aServiceConnInfo.iSNAPLocked, aServiceConnInfo.iPasswordSet ) );                }
       
   405             }
       
   406         else
       
   407             {
       
   408             User::Leave( KErrNotFound );
       
   409             }
       
   410             
       
   411         CCHLOGSTRING( "CCCHServiceInfo::GetConnectionInfoL: OUT" );
       
   412     }
       
   413 
       
   414 // ---------------------------------------------------------------------------
       
   415 // CCCHServiceInfo::ReserveServiceL
       
   416 // (other items were commented in a header).
       
   417 // ---------------------------------------------------------------------------
       
   418 //
       
   419 void CCCHServiceInfo::ReserveServiceL( 
       
   420     const TCCHSubserviceType aServiceType ) 
       
   421     {
       
   422     CCHLOGSTRING( "CCCHServiceInfo::ReserveServiceL: IN" );
       
   423     
       
   424     TUid pluginUid( KNullUid );
       
   425     TInt index( FindSubservice( aServiceType ) );
       
   426     if ( KErrNotFound != index )
       
   427         {
       
   428         pluginUid = iSubservices[ index ]->GetPluginUid();
       
   429         User::LeaveIfError( iServer.PluginHandler().ReserveService( 
       
   430             iServiceId, pluginUid, aServiceType ));
       
   431         }
       
   432     else
       
   433         {
       
   434         User::Leave( KErrNotFound );
       
   435         }
       
   436         
       
   437     CCHLOGSTRING( "CCCHServiceInfo::ReserveServiceL: OUT" );
       
   438     }
       
   439 
       
   440 // ---------------------------------------------------------------------------
       
   441 // CCCHServiceInfo::FreeServiceL
       
   442 // (other items were commented in a header).
       
   443 // ---------------------------------------------------------------------------
       
   444 //
       
   445 void CCCHServiceInfo::FreeServiceL( 
       
   446     const TCCHSubserviceType aServiceType )
       
   447     {
       
   448     CCHLOGSTRING( "CCCHServiceInfo::FreeServiceL: IN" );
       
   449     
       
   450     TUid pluginUid( KNullUid );
       
   451     TInt index( FindSubservice( aServiceType ) );
       
   452     if ( KErrNotFound != index )
       
   453         {
       
   454         pluginUid = iSubservices[ index ]->GetPluginUid();
       
   455         User::LeaveIfError( iServer.PluginHandler().FreeService( 
       
   456             iServiceId, pluginUid, aServiceType ));
       
   457         }
       
   458     else
       
   459         {
       
   460         User::Leave( KErrNotFound );
       
   461         }
       
   462         
       
   463     CCHLOGSTRING( "CCCHServiceInfo::FreeServiceL: OUT" );
       
   464     }
       
   465 
       
   466 // ---------------------------------------------------------------------------
       
   467 // CCCHServiceInfo::IsReservedL
       
   468 // (other items were commented in a header).
       
   469 // ---------------------------------------------------------------------------
       
   470 //
       
   471 TBool CCCHServiceInfo::IsReservedL( 
       
   472     const TCCHSubserviceType aServiceType ) const
       
   473     {
       
   474     CCHLOGSTRING( "CCCHServiceInfo::IsReservedL: IN" );
       
   475     
       
   476     TBool ret(EFalse);
       
   477     TUid pluginUid( KNullUid );
       
   478     TInt index( FindSubservice( aServiceType ) );
       
   479     if ( KErrNotFound != index )
       
   480         {
       
   481         pluginUid = iSubservices[ index ]->GetPluginUid();
       
   482         User::LeaveIfError( ret = iServer.PluginHandler().IsReserved( 
       
   483             iServiceId, pluginUid, aServiceType ));
       
   484         }
       
   485     else
       
   486         {
       
   487         User::Leave( KErrNotFound );
       
   488         }
       
   489         
       
   490     CCHLOGSTRING( "CCCHServiceInfo::IsReservedL: OUT" );
       
   491     return ret;
       
   492     }         
       
   493                              
       
   494 // ---------------------------------------------------------------------------
       
   495 // CCCHServiceInfo::IsEnabled
       
   496 // (other items were commented in a header).
       
   497 // ---------------------------------------------------------------------------
       
   498 //
       
   499 TBool CCCHServiceInfo::IsEnabled() const
       
   500     {
       
   501     return iIsEnabled;
       
   502     }
       
   503 
       
   504 // ---------------------------------------------------------------------------
       
   505 // CCCHServiceInfo::AddSubservice
       
   506 // (other items were commented in a header).
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 void CCCHServiceInfo::AddSubserviceL( TCCHSubservice& aSubservice )
       
   510     {
       
   511     CCHLOGSTRING( "CCCHServiceInfo::AddSubserviceL: IN" );
       
   512     
       
   513     CCCHSubserviceInfo* subserviceInfo = NULL;
       
   514     if ( ECCHUnknown != aSubservice.iConnectionInfo.iServiceSelection.iType )
       
   515         {
       
   516         // Create new instance and set service id
       
   517         subserviceInfo = 
       
   518             CCCHSubserviceInfo::NewL( aSubservice.iConnectionInfo.iServiceSelection.iServiceId, iServer );
       
   519         // Set subserviceID
       
   520         subserviceInfo->SetSubserviceId( aSubservice.iSubserviceId );
       
   521         
       
   522         // Get plugin uid from service table
       
   523         TUid pUid( KNullUid );
       
   524         
       
   525         iServer.SPSHandler().GetConnectivityPluginUidL( 
       
   526                 aSubservice.iConnectionInfo.iServiceSelection.iServiceId, aSubservice.iConnectionInfo.iServiceSelection.iType, pUid ); 
       
   527         subserviceInfo->SetPluginUid( pUid ); 
       
   528           
       
   529         subserviceInfo->SetState( aSubservice.iState );
       
   530         subserviceInfo->SetType( aSubservice.iConnectionInfo.iServiceSelection.iType );
       
   531         subserviceInfo->SetIapId( aSubservice.iConnectionInfo.iIapId );
       
   532         subserviceInfo->SetSNAPId( aSubservice.iConnectionInfo.iSNAPId );    
       
   533         TBool startupFlag( EFalse );
       
   534         iServer.SPSHandler().LoadAtStartUpL( aSubservice.iConnectionInfo.iServiceSelection.iServiceId,
       
   535              aSubservice.iConnectionInfo.iServiceSelection.iType, startupFlag );
       
   536         subserviceInfo->SetStartupFlag( startupFlag );        
       
   537         // Append pointer to array
       
   538         iSubservices.Append( subserviceInfo );
       
   539         }
       
   540    
       
   541     CCHLOGSTRING( "CCCHServiceInfo::AddSubserviceL: OUT" );
       
   542     }
       
   543 
       
   544 // ---------------------------------------------------------------------------
       
   545 // CCCHServiceInfo::UpdateL
       
   546 // (other items were commented in a header).
       
   547 // ---------------------------------------------------------------------------
       
   548 //
       
   549 void CCCHServiceInfo::UpdateL( TBool aReadServiceTable )
       
   550     {
       
   551     CCHLOGSTRING( "CCCHServiceInfo::UpdateL: IN" );
       
   552     
       
   553     iIsEnabled = EFalse;
       
   554     if ( aReadServiceTable )
       
   555         {
       
   556         TBool found( EFalse );
       
   557         TInt index( KErrNotFound );
       
   558         TCCHService service;
       
   559         // Read service information from service table
       
   560         iServer.SPSHandler().GetServiceInfoL( iServiceId , service );
       
   561         for ( TInt i( 0 ); i < service.iSubservices.Count(); i++ )
       
   562             {            
       
   563             TCCHSubservice subservice = service.iSubservices[ i ];
       
   564             
       
   565             if ( KErrNotFound != ( index = FindSubservice( 
       
   566                 subservice.iConnectionInfo.iServiceSelection.iType ) ) )
       
   567                 {
       
   568                 TBool startupFlag( EFalse );
       
   569                 iServer.SPSHandler().LoadAtStartUpL( subservice.iConnectionInfo.iServiceSelection.iServiceId,
       
   570                     subservice.iConnectionInfo.iServiceSelection.iType, startupFlag );
       
   571                 iSubservices[ index ]->SetStartupFlag( startupFlag );
       
   572                 iSubservices[ index ]->Update();
       
   573                 if ( !iIsEnabled )
       
   574                     {
       
   575                     iIsEnabled = iSubservices[ index ]->IsEnabled();
       
   576                     }
       
   577                 }
       
   578             else
       
   579                 {
       
   580                 AddSubserviceL( subservice );
       
   581                 }
       
   582             }
       
   583         // Check that all subservices really exist in service table
       
   584         if ( service.iSubservices.Count() < iSubservices.Count() )
       
   585             {
       
   586             for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   587                 {                
       
   588                 found = ETrue;
       
   589                 for ( TInt j( 0 ); j < service.iSubservices.Count() && 
       
   590                     found; j++ )
       
   591                     {
       
   592                     found = 
       
   593                         service.iSubservices[ j ].iConnectionInfo.iServiceSelection.iType == 
       
   594                             iSubservices[ i ]->Type();
       
   595                     }
       
   596                 // if this subservice is not in service table then remove it.
       
   597                 if ( !found )
       
   598                     {
       
   599                     delete iSubservices[ i ];
       
   600                     iSubservices.Remove( i );
       
   601                     i--;
       
   602                     }                
       
   603                 }
       
   604             }
       
   605         }
       
   606     else
       
   607         {
       
   608         for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   609             {
       
   610             iSubservices[ i ]->Update();
       
   611             if ( !iIsEnabled )
       
   612                 {
       
   613                 iIsEnabled = iSubservices[ i ]->IsEnabled();    
       
   614                 }
       
   615             }
       
   616         }
       
   617             
       
   618     CCHLOGSTRING( "CCCHServiceInfo::UpdateL: OUT" );
       
   619     }
       
   620 
       
   621 // ---------------------------------------------------------------------------
       
   622 // CCCHServiceInfo::SetStateL
       
   623 // (other items were commented in a header).
       
   624 // ---------------------------------------------------------------------------
       
   625 //    
       
   626 void CCCHServiceInfo::SetStateL( 
       
   627     const TCCHSubserviceType aType, 
       
   628     const TInt aState )
       
   629     {
       
   630     CCHLOGSTRING( "CCCHServiceInfo::SetStateL IN" );
       
   631     
       
   632     TInt index( FindSubservice( aType ) );
       
   633     if ( KErrNotFound != index )
       
   634         {
       
   635         iSubservices[ index ]->SetState( 
       
   636                 static_cast<TCCHSubserviceState>( aState ) );
       
   637         }
       
   638     else
       
   639         {
       
   640         User::Leave( index );
       
   641         }       
       
   642 
       
   643     // Before we update our clients handle exception error cases
       
   644     HandleErrorExceptions();
       
   645     UpdateL();    
       
   646     CCHLOGSTRING( "CCCHServiceInfo::SetStateL :OUT" );
       
   647     }
       
   648 
       
   649 // ---------------------------------------------------------------------------
       
   650 // CCCHServiceInfo::SetStateL
       
   651 // (other items were commented in a header).
       
   652 // ---------------------------------------------------------------------------
       
   653 //    
       
   654 void CCCHServiceInfo::SetStateL( 
       
   655     const TUid& aPluginUid, 
       
   656     const TCCHSubserviceState& aState )
       
   657     {
       
   658     CCHLOGSTRING( "CCCHServiceInfo::SetStateL IN" );
       
   659     
       
   660     
       
   661     for ( TInt i( 0 ); i < iSubservices.Count() && 
       
   662         i < KCCHMaxSubservicesCount; i++ )
       
   663         {
       
   664         if( aPluginUid == GetUidL( i ) )
       
   665             {
       
   666             iSubservices[ i ]->SetState( aState );
       
   667             }
       
   668         }
       
   669         
       
   670     UpdateL();    
       
   671     CCHLOGSTRING( "CCCHServiceInfo::SetStateL :OUT" );
       
   672     }
       
   673 
       
   674 // ---------------------------------------------------------------------------
       
   675 // CCCHServiceInfo::SetErrorL
       
   676 // (other items were commented in a header).
       
   677 // ---------------------------------------------------------------------------
       
   678 //    
       
   679 void CCCHServiceInfo::SetErrorL( 
       
   680     const TCCHSubserviceType aType, 
       
   681     const TInt aError )
       
   682     {
       
   683     CCHLOGSTRING( "CCCHServiceInfo::SetErrorL IN" );
       
   684     
       
   685     TInt index( FindSubservice( aType ) );
       
   686     if ( KErrNotFound != index )
       
   687         {
       
   688         iSubservices[ index ]->SetError( aError );        
       
   689         }
       
   690     else
       
   691         {
       
   692         User::Leave( index );
       
   693         }           
       
   694     CCHLOGSTRING( "CCCHServiceInfo::SetErrorL :OUT" );
       
   695     }
       
   696 
       
   697 // ---------------------------------------------------------------------------
       
   698 // CCCHServiceInfo::SubserviceCount
       
   699 // (other items were commented in a header).
       
   700 // ---------------------------------------------------------------------------
       
   701 //
       
   702 TInt CCCHServiceInfo::SubserviceCount() const
       
   703     {
       
   704     return iSubservices.Count();
       
   705     }
       
   706 
       
   707 // ---------------------------------------------------------------------------
       
   708 // CCCHServiceInfo::GetUidL
       
   709 // (other items were commented in a header).
       
   710 // ---------------------------------------------------------------------------
       
   711 //
       
   712 TUid CCCHServiceInfo::GetUidL( TInt aSubserviceIndex ) const
       
   713     {
       
   714     if ( aSubserviceIndex > iSubservices.Count() )
       
   715         {
       
   716         User::Leave( KErrNotFound );
       
   717         }
       
   718     return iSubservices[ aSubserviceIndex ]->GetPluginUid();
       
   719     }
       
   720 
       
   721 // ---------------------------------------------------------------------------
       
   722 // CCCHServiceInfo::FillServiceInfo
       
   723 // (other items were commented in a header).
       
   724 // ---------------------------------------------------------------------------
       
   725 //
       
   726 void CCCHServiceInfo::FillServiceInfo( TCCHService& service )
       
   727     {
       
   728     CCHLOGSTRING( "CCCHServiceInfo::FillServiceInfo: IN" );
       
   729     service.iServiceId = iServiceId;
       
   730     service.iServiceName.Copy( iServiceName );
       
   731     
       
   732     for ( TInt i( 0 ); i < iSubservices.Count() && 
       
   733         i < KCCHMaxSubservicesCount; i++ )
       
   734         {
       
   735         iSubservices[ i ]->FillSubserviceInfo( service.iSubservices.At( i ) );              
       
   736         }
       
   737         
       
   738     CCHLOGSTRING( "CCCHServiceInfo::FillServiceInfo: OUT" );
       
   739     }
       
   740 
       
   741 // ---------------------------------------------------------------------------
       
   742 // CCCHServiceInfo::GetStatus
       
   743 // (other items were commented in a header).
       
   744 // ---------------------------------------------------------------------------
       
   745 //
       
   746 TInt CCCHServiceInfo::GetStatus( 
       
   747     TCCHSubserviceType aType, TCCHSubserviceState& aState ) const
       
   748     {    
       
   749     TInt error = KErrNone;
       
   750     TInt index( FindSubservice( aType ) );
       
   751     
       
   752     if( index == KErrNotFound )
       
   753         {
       
   754         error = KErrNotFound;
       
   755         }
       
   756     else
       
   757         {
       
   758         aState = iSubservices[ index ]->GetState();
       
   759         }
       
   760         
       
   761     return error;
       
   762     }
       
   763 
       
   764 // ---------------------------------------------------------------------------
       
   765 // CCCHServiceInfo::GetState
       
   766 // (other items were commented in a header).
       
   767 // ---------------------------------------------------------------------------
       
   768 //
       
   769 TCCHSubserviceState CCCHServiceInfo::GetState() const
       
   770     {    
       
   771     TCCHSubserviceState ret( ECCHUninitialized );
       
   772 
       
   773     for ( TInt i( 0 ); i < iSubservices.Count() && !ret; i++ )
       
   774         {
       
   775         if( iSubservices[ i ]->GetState() > ret )
       
   776             {
       
   777             ret = iSubservices[ i ]->GetState();
       
   778             }
       
   779         }
       
   780         
       
   781     CCHLOGSTRING2( "CCCHServiceHandler::GetState: %d", ret );
       
   782     return ret;
       
   783     }
       
   784 
       
   785 // ---------------------------------------------------------------------------
       
   786 // CCCHServiceInfo::GetError
       
   787 // (other items were commented in a header).
       
   788 // ---------------------------------------------------------------------------
       
   789 //
       
   790 TInt CCCHServiceInfo::GetError( 
       
   791     TCCHSubserviceType aType ) const
       
   792     {    
       
   793     TInt index( FindSubservice( aType ) );
       
   794     return ( KErrNotFound != index ) ? iSubservices[ index ]->GetError() :
       
   795         KErrNone;
       
   796     }
       
   797 
       
   798 // ---------------------------------------------------------------------------
       
   799 // CCCHServiceInfo::GetServiceInfoL
       
   800 // (other items were commented in a header).
       
   801 // ---------------------------------------------------------------------------
       
   802 //
       
   803 void CCCHServiceInfo::GetServiceInfoL( 
       
   804     TDes& aBuffer,
       
   805     TCCHSubserviceType aType ) const
       
   806     {
       
   807     TUid pluginUid( KNullUid );
       
   808     TInt index( FindSubservice( aType ) );
       
   809     if ( KErrNotFound != index )
       
   810         {
       
   811         pluginUid = iSubservices[ index ]->GetPluginUid();
       
   812         
       
   813         User::LeaveIfError( iServer.PluginHandler().GetServiceInfo( 
       
   814             iServiceId, pluginUid, aType, aBuffer ) );
       
   815         }
       
   816     else
       
   817     	{
       
   818     	User::Leave( KErrNotFound );
       
   819     	}
       
   820     }
       
   821 
       
   822 // ---------------------------------------------------------------------------
       
   823 // CCCHServiceInfo::SubserviceExist
       
   824 // (other items were commented in a header).
       
   825 // ---------------------------------------------------------------------------
       
   826 //
       
   827 TBool CCCHServiceInfo::SubserviceExist( TCCHSubserviceType aType ) const     
       
   828     {
       
   829     // If subservice is specified then check if it really exist.
       
   830     // Otherwise return ETrue
       
   831     return ( ECCHUnknown != aType ) ?  
       
   832         ( ( KErrNotFound != FindSubservice( aType ) ) ? ETrue : EFalse ) :
       
   833         ETrue;
       
   834     }
       
   835     
       
   836 // ---------------------------------------------------------------------------
       
   837 // CCCHServiceInfo::FindSubservice
       
   838 // (other items were commented in a header).
       
   839 // ---------------------------------------------------------------------------
       
   840 //
       
   841 TInt CCCHServiceInfo::FindSubservice( TCCHSubserviceType aType ) const
       
   842     {
       
   843     TInt index( KErrNotFound );
       
   844     TBool exist( EFalse );
       
   845     for ( TInt i( 0 ); i < iSubservices.Count() && 
       
   846             i < KCCHMaxSubservicesCount && !exist; i++ )
       
   847         {
       
   848         exist = iSubservices[ i ]->Type() == aType;
       
   849         index = i;
       
   850         }
       
   851     return !exist ? KErrNotFound : index;
       
   852     }
       
   853 
       
   854 // ---------------------------------------------------------------------------
       
   855 // CCCHServiceInfo::StartupFlagSet
       
   856 // (other items were commented in a header).
       
   857 // ---------------------------------------------------------------------------
       
   858 //
       
   859 TBool CCCHServiceInfo::StartupFlagSet() const
       
   860     {
       
   861     TBool ret( EFalse );
       
   862     for ( TInt i( 0 ); i < iSubservices.Count() && !ret; i++ )
       
   863         {
       
   864         ret = iSubservices[ i ]->GetStartUpFlag(); 
       
   865         }
       
   866     CCHLOGSTRING2( "CCCHServiceHandler::StartupFlagSet: %d", ret );        
       
   867     return ret;
       
   868     }
       
   869 
       
   870 // ---------------------------------------------------------------------------
       
   871 // CCCHServiceInfo::StartupFlagSet
       
   872 // (other items were commented in a header).
       
   873 // ---------------------------------------------------------------------------
       
   874 //    
       
   875 TBool CCCHServiceInfo::StartupFlagSet( TInt aSubserviceIndex ) const
       
   876     {
       
   877     return aSubserviceIndex > iSubservices.Count() ? EFalse :
       
   878         iSubservices[ aSubserviceIndex ]->GetStartUpFlag();
       
   879     }
       
   880 
       
   881 // ---------------------------------------------------------------------------
       
   882 // CCCHServiceInfo::SetStartupFlag
       
   883 // (other items were commented in a header).
       
   884 // ---------------------------------------------------------------------------
       
   885 //
       
   886 TInt CCCHServiceInfo::SetStartupFlag(
       
   887     TCCHSubserviceType aType,
       
   888     TBool aLoadAtStartUp ) const
       
   889     {
       
   890     TInt exist( KErrNotFound );
       
   891     for ( TInt i( 0 ); i < iSubservices.Count() && 
       
   892             i < KCCHMaxSubservicesCount; i++ )
       
   893         {
       
   894         if ( iSubservices[ i ]->Type() == aType )
       
   895             {
       
   896             iSubservices[ i ]->SetStartupFlag( aLoadAtStartUp );
       
   897             exist = KErrNone;
       
   898             break;
       
   899             }
       
   900         }
       
   901     return exist;
       
   902     }
       
   903 
       
   904 // ---------------------------------------------------------------------------
       
   905 // CCCHServiceInfo::GetSubserviceType
       
   906 // (other items were commented in a header).
       
   907 // ---------------------------------------------------------------------------
       
   908 //    
       
   909 TCCHSubserviceType CCCHServiceInfo::GetSubserviceType( 
       
   910     TInt aSubserviceIndex ) const
       
   911     {
       
   912     return aSubserviceIndex > iSubservices.Count() ? ECCHUnknown :
       
   913         iSubservices[ aSubserviceIndex ]->Type();
       
   914     }
       
   915     
       
   916 // ---------------------------------------------------------------------------
       
   917 // CCCHServiceInfo::GetSubserviceL
       
   918 // (other items were commented in a header).
       
   919 // ---------------------------------------------------------------------------
       
   920 //
       
   921 CCCHSubserviceInfo& CCCHServiceInfo::GetSubserviceL( 
       
   922     TCCHSubserviceType aType ) const
       
   923     {
       
   924     TInt index( FindSubservice( aType ) );
       
   925     if ( KErrNotFound == index )
       
   926         {
       
   927         User::Leave( index );
       
   928         }
       
   929         
       
   930     return *iSubservices[ index ];
       
   931     }
       
   932 
       
   933 // ---------------------------------------------------------------------------
       
   934 // CCCHServiceInfo::HandleErrorExceptions
       
   935 // (other items were commented in a header).
       
   936 // ---------------------------------------------------------------------------
       
   937 //    
       
   938 void CCCHServiceInfo::HandleErrorExceptions()
       
   939     {
       
   940     CCHLOGSTRING( "CCCHServiceInfo::HandleErrorExceptions IN" );
       
   941     
       
   942     for ( TInt i( 0 ); i < iSubservices.Count(); i++ )
       
   943         {
       
   944         switch ( iSubservices[ i ]->GetError() )
       
   945             {
       
   946             
       
   947             // KErrCancel caused by CSIPProfileRegistry::ErrorOccurred(-3)
       
   948             // User has canceled connecting dialog and we have to remove
       
   949             // service from the load at startup list.
       
   950             // At last make sure that unnecessary wlan scan is OFF
       
   951             case KErrCancel:
       
   952                 {
       
   953                 TRAP_IGNORE( iServer.SPSHandler().SetLoadAtStartUpL( 
       
   954                     iServiceId, iSubservices[ i ]->Type(), EFalse ) );
       
   955                 iServer.ServiceHandler().DisableWlanScan();
       
   956                 }
       
   957                 break;
       
   958                 
       
   959             default:
       
   960                 break;
       
   961             }
       
   962         
       
   963         }
       
   964      
       
   965     CCHLOGSTRING( "CCCHServiceInfo::HandleErrorExceptions :OUT" );
       
   966     }
       
   967 
       
   968 // ========================== OTHER EXPORTED FUNCTIONS =======================
       
   969 
       
   970 //  End of File