convergedcallengine/cce/src/cccepluginmanager.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Handles plugins / threads
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 #include "cccepluginmanager.h"
       
    21 #include "mccedtmfobserver.h"
       
    22 #include "ccceplugin.h"
       
    23 #include "cccelogger.h"
       
    24 #include "cccecallcontainer.h"
       
    25 #include "ccceemergencycall.h"
       
    26 #include "cccecall.h"
       
    27 #include "mccpdtmfprovider.h"
       
    28 #include "cconvergedcallprovider.h"
       
    29 #include "icmapi.h"
       
    30 #include "cccespsettingshandler.h"
       
    31 
       
    32 
       
    33 
       
    34 // ======== MEMBER FUNCTIONS ========
       
    35 // -----------------------------------------------------------------------------
       
    36 // NewL()
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CCCEPluginManager* CCCEPluginManager::NewL( 
       
    40     CCCECallContainer& aCallContainer,
       
    41     CCCETransferController& aTransferController )
       
    42     {
       
    43     CCCEPluginManager* self = new (ELeave) CCCEPluginManager( 
       
    44         aCallContainer, 
       
    45         aTransferController );
       
    46         
       
    47     CleanupStack::PushL(self);
       
    48     self->ConstructL();
       
    49     CleanupStack::Pop(self);
       
    50     return self;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CCCEPluginManager() 
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CCCEPluginManager::CCCEPluginManager( 
       
    58     CCCECallContainer& aCallContainer,
       
    59     CCCETransferController& aTransferController ) : 
       
    60         CActive( EPriorityStandard ),
       
    61         iCallContainer( aCallContainer ),
       
    62         iTransferController( aTransferController )
       
    63     {
       
    64     iPluginArray.Reset();
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // ConstructL()
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CCCEPluginManager::ConstructL()
       
    72     {
       
    73 #if 0
       
    74 // capabilities still todo here
       
    75 
       
    76 	static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
       
    77 	static _LIT_SECURITY_POLICY_C2(	KICMPolicy, 
       
    78 									ECapabilityNetworkControl,
       
    79 									ECapabilityWriteDeviceData);	
       
    80 
       
    81         
       
    82     // define first property to be integer type
       
    83     TInt err = RProperty::Define( KPSUidICMIncomingCall, 
       
    84         KPropertyKeyICMPluginUID, RProperty::EInt, KAllowAllPolicy, KICMPolicy );
       
    85 #else
       
    86     // define first property to be integer type
       
    87     TInt err = RProperty::Define( KPSUidICMIncomingCall, 
       
    88         KPropertyKeyICMPluginUID, RProperty::EInt );
       
    89 #endif
       
    90         
       
    91     if ( err != KErrAlreadyExists )
       
    92         {
       
    93         User::LeaveIfError( err );
       
    94         }
       
    95         
       
    96     User::LeaveIfError( iProperty.Attach( KPSUidICMIncomingCall,
       
    97         KPropertyKeyICMPluginUID ) );
       
    98     CActiveScheduler::Add(this);
       
    99     RunL();
       
   100 
       
   101     iIdle = CIdle::NewL( EPriorityIdle );
       
   102     iIdle->Start( TCallBack(DoAfterBoot,this) );
       
   103     
       
   104     iSPSettings = CCCESPSettingsHandler::NewL( *this );
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // ~CCCEPluginManager()
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 CCCEPluginManager::~CCCEPluginManager()
       
   112     {
       
   113     delete iSPSettings;
       
   114     
       
   115     if( iIdle )
       
   116         {
       
   117         iIdle->Cancel();
       
   118         delete iIdle;
       
   119         iIdle = NULL;
       
   120         }
       
   121 
       
   122     iPluginArray.ResetAndDestroy();
       
   123     iPluginArray.Close();
       
   124     
       
   125     iPluginsToClose.ResetAndDestroy();
       
   126     iPluginsToClose.Close();
       
   127     
       
   128     iAlternativeEmergencyPlugins.Reset();
       
   129     iAlternativeEmergencyPlugins.Close();
       
   130     
       
   131     Cancel();
       
   132     iProperty.Close();
       
   133     
       
   134     REComSession::FinalClose();
       
   135     
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // RunL()
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CCCEPluginManager::RunL()
       
   143     {
       
   144     // TODO If there is two calls arriving same time. How ICM can handle it?
       
   145     
       
   146     CCELOGSTRING("CCCEPluginManager::RunL()" );
       
   147     // resubscribe before processing new value to prevent missing updates
       
   148     iProperty.Subscribe( iStatus );
       
   149     SetActive();
       
   150     // property updated, get new value
       
   151 
       
   152     TInt keyValue;
       
   153     if ( iProperty.Get( keyValue ) == KErrNotFound )
       
   154         {
       
   155         // property deleted, do necessary actions here...
       
   156         }
       
   157     else
       
   158         {
       
   159         if( keyValue )
       
   160             {
       
   161             TUid pluginId = TUid::Uid(keyValue);
       
   162 
       
   163             CCELOGSTRING2("CCCEPluginManager::RunL: IncomingCallAPI = %d",
       
   164                 pluginId.iUid );
       
   165             // use new value ...
       
   166             GetPluginL( pluginId );
       
   167             }
       
   168         }
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // SetObserver()
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void CCCEPluginManager::SetObserver( const MCCEObserver& aObserver )
       
   176     {
       
   177     iObserver = &aObserver;
       
   178     }
       
   179     
       
   180 // -----------------------------------------------------------------------------
       
   181 // SetObserver()
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CCCEPluginManager::SetEmergencyCallObserver(MCCPCallObserver& aEmergencyCallObserver)
       
   185     {
       
   186     iEmergencyCallObserver = &aEmergencyCallObserver;
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // DoAfterBoot()
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 TInt CCCEPluginManager::DoAfterBoot( TAny* aPluginManager )
       
   194     {
       
   195     CCELOGSTRING("CCCEPluginManager::DoAfterBoot()" );
       
   196     
       
   197     CCCEPluginManager* manager = 
       
   198         static_cast< CCCEPluginManager* >( aPluginManager );
       
   199         TRAP_IGNORE(manager->LoadBootPluginsL());
       
   200    
       
   201     return KErrNone;
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // Remove unneeded plug-ins
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 TInt CCCEPluginManager::RemovePlugins( TAny* aPluginManager )
       
   209     {
       
   210     CCELOGSTRING("CCCEPluginManager::RemovePlugins()" );
       
   211     
       
   212     CCCEPluginManager* manager = 
       
   213         static_cast< CCCEPluginManager* >( aPluginManager );
       
   214         TRAP_IGNORE(manager->iPluginsToClose.ResetAndDestroy());
       
   215    
       
   216     return KErrNone;
       
   217     }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // ServiceEnabledL
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 void CCCEPluginManager::ServiceEnabledL( TUid aImplementationUid )
       
   224     {
       
   225     CCELOGSTRING("CCCEPluginManager::ServiceEnabledL" );
       
   226     CConvergedCallProvider* provider = GetPluginL( aImplementationUid );
       
   227     
       
   228     if( provider )
       
   229         {
       
   230         CCCEPlugin* plugin( NULL );
       
   231         for( TInt i=0; i<iPluginArray.Count(); i++ )
       
   232             {
       
   233             TUid oldPlugin = iPluginArray[i]->Type();
       
   234            
       
   235             if( oldPlugin.iUid == aImplementationUid.iUid )
       
   236                 {
       
   237                 plugin =  iPluginArray[i];
       
   238                 // set plugin to stay in memory
       
   239                 plugin->SetReleaseWhenIdle( EFalse );
       
   240                 i = iPluginArray.Count();
       
   241                 }
       
   242             }
       
   243         }
       
   244     else
       
   245         {
       
   246         User::Leave( KErrGeneral );
       
   247         }
       
   248     }
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // ServiceDisabledL
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 void CCCEPluginManager::ServiceDisabledL( TUid aImplementationUid )
       
   255     {
       
   256     CCELOGSTRING("CCCEPluginManager::ServiceDisabledL" );
       
   257     CCCEPlugin* plugin( NULL );
       
   258     for( TInt i=0; i<iPluginArray.Count(); i++ )
       
   259         {
       
   260         TUid oldPlugin = iPluginArray[i]->Type();
       
   261        
       
   262         if( oldPlugin.iUid == aImplementationUid.iUid )
       
   263             {
       
   264             plugin =  iPluginArray[i];
       
   265             i = iPluginArray.Count();
       
   266             }
       
   267         }
       
   268 
       
   269     if( !plugin )
       
   270         {
       
   271         CCELOGSTRING("CCCEPluginManager:: No plugin found" );
       
   272         User::Leave( KErrNotFound );
       
   273         }
       
   274     else if( iCallContainer.CountCalls( aImplementationUid ) )
       
   275         {
       
   276         CCELOGSTRING("CCCEPluginManager:: Plugin found with ongoing calls" );
       
   277         plugin->SetReleaseWhenIdle( ETrue );
       
   278         }
       
   279     else
       
   280         {
       
   281         CCELOGSTRING("CCCEPluginManager:: Plugin found" );
       
   282         plugin->SetReleaseWhenIdle( ETrue );
       
   283         RemovePlugin( aImplementationUid );
       
   284         }
       
   285     }
       
   286 
       
   287 // -----------------------------------------------------------------------------
       
   288 // Load EBootstrapCallProvider marked or enabled plugins
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void CCCEPluginManager::LoadBootPluginsL()
       
   292     {
       
   293     //List implementations
       
   294 #ifdef _DEBUG
       
   295     RImplInfoPtrArray implementations;
       
   296     CConvergedCallProvider::ListImplementationsL(implementations);
       
   297     CCELOGSTRING2("CCCEPluginManager::GetPluginL: %d Implementation(s) found", 
       
   298         implementations.Count() );
       
   299         
       
   300     for( TInt i=0; i<implementations.Count(); i++ )
       
   301         {
       
   302         CImplementationInformation *info = implementations[i];
       
   303         
       
   304         CCELOGSTRING3("CCCEPluginManager::GetPluginL: Uid = %d, Name = %S", 
       
   305             info->ImplementationUid().iUid, &info->DisplayName() );
       
   306         CCELOGSTRING3("CCCEPluginManager::GetPluginL: ->RomBased = %d, RomOnly = %d", 
       
   307             info->RomBased(), info->RomOnly() );
       
   308         }
       
   309   
       
   310     implementations.ResetAndDestroy();
       
   311     implementations.Close();
       
   312 #endif // _DEBUG
       
   313     
       
   314     RIdArray serviceIDArray;
       
   315     CleanupClosePushL( serviceIDArray );
       
   316     iSPSettings->GetServicesL( serviceIDArray );
       
   317     const TInt serviceCount = serviceIDArray.Count();
       
   318     iPrimaryEmergencyCallPlugin = NULL;
       
   319     TInt err = KErrNone;
       
   320     
       
   321     CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Service count: %d", serviceCount );
       
   322     for( TInt service = 0; service < serviceCount; service++ )
       
   323         {
       
   324         CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Processing service: %d", service );
       
   325         CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: ServiceID: %d", serviceIDArray[service] );
       
   326         
       
   327         TRAP( err, LoadBootPluginL( serviceIDArray[service] ) )
       
   328         
       
   329         CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Result %i", err );
       
   330         }
       
   331 
       
   332     CleanupStack::PopAndDestroy();
       
   333     }
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // Load EBootstrapCallProvider marked or enabled plugin
       
   337 // -----------------------------------------------------------------------------
       
   338 //
       
   339 void CCCEPluginManager::LoadBootPluginL( TInt aServiceId )
       
   340     {
       
   341     const TUid id = iSPSettings->ImplementationUidL( aServiceId );
       
   342     CCELOGSTRING2("CCCEPluginManager::LoadBootPluginL: Plugin id: %i", id );
       
   343     
       
   344     const TInt mask = iSPSettings->CapabilitiesL( aServiceId );
       
   345     CCELOGSTRING2("CCCEPluginManager::LoadBootPluginL: Service mask: %d", mask );
       
   346     
       
   347     const TBool enabled = iSPSettings->IsEnabledL( aServiceId );
       
   348     CCELOGSTRING2("CCCEPluginManager::LoadBootPluginL: VoIP enabled: %i", enabled );
       
   349     
       
   350     const TBool emergencyCall = mask & ESupportsEmergencyCall;
       
   351     CCELOGSTRING2(
       
   352         "CCCEPluginManager::LoadBootPluginL: Support EmergencyCall: %i", emergencyCall );
       
   353     
       
   354     if( mask & EBootstrapCallProvider || enabled )
       
   355         {
       
   356         CCELOGSTRING("CCCEPluginManager::LoadBootPluginL: Bootable plugin found" );
       
   357         ServiceEnabledL( id );
       
   358         }
       
   359 
       
   360     if( emergencyCall )
       
   361         {
       
   362         if( !iPrimaryEmergencyCallPlugin )
       
   363             {
       
   364             CCCEPlugin* plugin( NULL );
       
   365             for( TInt i=0; i<iPluginArray.Count(); i++ )
       
   366                 {
       
   367                 TUid oldPlugin = iPluginArray[i]->Type();
       
   368                 
       
   369                 if( oldPlugin.iUid == id.iUid )
       
   370                     {
       
   371                     plugin =  iPluginArray[i];
       
   372                     i = iPluginArray.Count();
       
   373                     }
       
   374                 }
       
   375             
       
   376             if( plugin )
       
   377                 {
       
   378                 CCELOGSTRING("CCCEPluginManager::LoadBootPluginL: Initialise primary emergency call" );
       
   379                 plugin->InitialiseEmergencyCallL( *iEmergencyCallObserver );
       
   380                 iPrimaryEmergencyCallPlugin = plugin;
       
   381                 }
       
   382             else
       
   383                 {
       
   384                 CCELOGSTRING("CCCEPluginManager::LoadBootPluginL: append plugin to alternative emergency array" );
       
   385                 AddToAlternativeEmergencyArray( id );   
       
   386                 }
       
   387             }
       
   388         else
       
   389             {
       
   390             CCELOGSTRING("CCCEPluginManager::LoadBootPluginL: append plugin to alternative emergency array" );
       
   391             AddToAlternativeEmergencyArray( id );   
       
   392             } 
       
   393         }
       
   394     }
       
   395 
       
   396 // -----------------------------------------------------------------------------
       
   397 // DoCancel()
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 void CCCEPluginManager::DoCancel()
       
   401     {
       
   402     CCELOGSTRING("CCCEPluginManager::DoCancel()" );
       
   403     iProperty.Cancel();
       
   404     }
       
   405     
       
   406 // -----------------------------------------------------------------------------
       
   407 // Return Primary emergency call 
       
   408 // -----------------------------------------------------------------------------
       
   409 //    
       
   410 MCCPEmergencyCall* CCCEPluginManager::PrimaryEmergencyCall()
       
   411     {
       
   412      MCCPEmergencyCall* call (NULL);
       
   413      if( iPrimaryEmergencyCallPlugin )
       
   414         {
       
   415         call =  iPrimaryEmergencyCallPlugin->GetEmergencyCall();
       
   416         }
       
   417     return call;      
       
   418     }
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // Return Primary emergency call plugin uid
       
   422 // -----------------------------------------------------------------------------
       
   423 //    
       
   424 TUid CCCEPluginManager::PrimaryEmergencyCallUid() const
       
   425     {
       
   426     TUid id( KNullUid );
       
   427     
       
   428     if( iPrimaryEmergencyCallPlugin )
       
   429         {
       
   430         id = iPrimaryEmergencyCallPlugin->Type();
       
   431         }
       
   432     
       
   433     return id;
       
   434     }
       
   435     
       
   436 // -----------------------------------------------------------------------------
       
   437 // Get array of know emergency plugins
       
   438 // -----------------------------------------------------------------------------
       
   439 //  
       
   440 RArray<TUid>& CCCEPluginManager::AlternativeEmergencyPlugins()
       
   441     {
       
   442     CCELOGSTRING("CCCEPluginManager::AlternativeEmergencyPlugins ");
       
   443     RImplInfoPtrArray implementations;
       
   444     TRAP_IGNORE( CConvergedCallProvider::ListImplementationsL(implementations) );
       
   445     iAlternativeEmergencyPlugins.Reset();
       
   446         
       
   447     for( TInt i=0; i<implementations.Count(); i++ )
       
   448         {
       
   449         CImplementationInformation *info = implementations[i];
       
   450         CCELOGSTRING2("CCCEPluginManager::AlternativeEmergencyPlugins: Found %d ", info->ImplementationUid());
       
   451         AddToAlternativeEmergencyArray(info->ImplementationUid());
       
   452         }
       
   453          
       
   454     implementations.ResetAndDestroy();
       
   455     implementations.Close();  
       
   456  
       
   457     return iAlternativeEmergencyPlugins;
       
   458     }
       
   459 
       
   460 // -----------------------------------------------------------------------------
       
   461 // Add new plugin to array. Do not allow duplicates
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 void CCCEPluginManager::AddToAlternativeEmergencyArray( TUid aUid )
       
   465     {
       
   466     if( iPrimaryEmergencyCallPlugin &&
       
   467         ( iPrimaryEmergencyCallPlugin->Type().iUid == aUid.iUid ) )
       
   468         {
       
   469         CCELOGSTRING("CCCEPluginManager::AddToAlternativeEmergencyArray: Is Primary emergency plugin ");
       
   470         }
       
   471     else if( iAlternativeEmergencyPlugins.Find( aUid ) == KErrNotFound )
       
   472         {
       
   473         CCELOGSTRING("CCCEPluginManager::AddToAlternativeEmergencyArray: New plugin. Append to array ");    
       
   474         iAlternativeEmergencyPlugins.Append( aUid );  
       
   475         }    
       
   476     else
       
   477         {
       
   478         CCELOGSTRING("CCCEPluginManager::AddToAlternativeEmergencyArray: Is already in Alternative Plugins ");    
       
   479         }
       
   480     
       
   481     }
       
   482 // -----------------------------------------------------------------------------
       
   483 // Return protocol interface object of wanted service ID
       
   484 // -----------------------------------------------------------------------------
       
   485 // 
       
   486 CConvergedCallProvider* CCCEPluginManager::GetPluginL( TUint32 aServiceId )
       
   487     {
       
   488     CCELOGSTRING2("CCCEPluginManager::GetPluginL: Get plugin for servce id %d", aServiceId);
       
   489     TUid id( KNullUid );
       
   490     
       
   491     id = iSPSettings->ImplementationUidL( aServiceId );
       
   492 
       
   493     if( !id.iUid )
       
   494         {
       
   495         CCELOGSTRING("CCCEPluginManager::GetPluginL: PluginId not found");
       
   496         User::Leave( KErrNotFound );
       
   497         }
       
   498     
       
   499     return GetPluginL( id );
       
   500     }
       
   501     
       
   502 // -----------------------------------------------------------------------------
       
   503 // Return protocol interface object of wanted type.
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 CConvergedCallProvider* CCCEPluginManager::GetPluginL( const TUid& aType )
       
   507     {
       
   508     CCCEPlugin* plugin = NULL;
       
   509    
       
   510    //Is plugin started? 
       
   511     CCELOGSTRING2("CCCEPluginManager::GetPluginL: %d Implementation(s) running", 
       
   512         iPluginArray.Count() );
       
   513 
       
   514     // Checked if ie. VoIP Plugins is supported
       
   515     iSPSettings->IsPluginSupportedL( aType );
       
   516     
       
   517     for( TInt i=0; i<iPluginArray.Count(); i++ )
       
   518         {
       
   519         TUid oldPlugin = iPluginArray[i]->Type();
       
   520         CCELOGSTRING2("CCCEPluginManager::GetPluginL: existing plugin = %d",
       
   521             oldPlugin.iUid );
       
   522             
       
   523         if( oldPlugin.iUid == aType.iUid )
       
   524             {
       
   525             CCELOGSTRING("CCCEPluginManager::GetPluginL: Plugin found" );
       
   526             plugin =  iPluginArray[i];
       
   527             }
       
   528         }
       
   529  
       
   530     if (!plugin)
       
   531         {
       
   532         //Start plugin
       
   533         CCELOGSTRING("CCCEPluginManager::GetPluginL: New Plugin" );
       
   534         CCELOGSTRING2("CCCEPluginManager::GetPluginL: Plugin Uid = %d",
       
   535             aType.iUid );
       
   536         plugin = CCCEPlugin::NewL(
       
   537             aType, const_cast<MCCEObserver&>(*iObserver),
       
   538                  iCallContainer, *this, iTransferController );
       
   539                  
       
   540         CleanupStack::PushL(plugin);
       
   541         CCELOGSTRING("CCCEPluginManager::GetPluginL: Append to array" );
       
   542         iPluginArray.AppendL( plugin );
       
   543         CleanupStack::Pop();
       
   544         }
       
   545         
       
   546    return plugin->GetPluginL();
       
   547    }
       
   548 
       
   549 // -----------------------------------------------------------------------------
       
   550 // remove protocol interface object of wanted type.
       
   551 // -----------------------------------------------------------------------------
       
   552 //   
       
   553 void CCCEPluginManager::RemovePlugin( const TUid& aType )
       
   554     {
       
   555     CCELOGSTRING2("CCCEPluginManager::RemovePlugin: %d Implementation(s) running", 
       
   556         iPluginArray.Count() );
       
   557         
       
   558     TInt pluginCount = iPluginArray.Count();
       
   559     for (TInt a = pluginCount-1; a >= 0 ; a--)
       
   560         {
       
   561         if ( iPluginArray[a]->Type() == aType && 
       
   562              iPluginArray[a]->ReleaseWhenIdle() )
       
   563             {
       
   564             // keep track that only one instance of pointer is in array
       
   565             iPluginsToClose.InsertInAddressOrder(iPluginArray[a]);
       
   566             CCELOGSTRING("CCCEPluginManager::RemovePlugin scheduled") 
       
   567             
       
   568             if (!iIdle->IsActive())
       
   569                 {
       
   570                 iIdle->Start( TCallBack(RemovePlugins,this) );
       
   571                 }
       
   572             iPluginArray.Remove(a);
       
   573             iPluginArray.Compress();
       
   574             break;
       
   575             }
       
   576         }
       
   577     }
       
   578    
       
   579     
       
   580 // ---------------------------------------------------------------------------
       
   581 // Returns ETrue if plugin can be relesed if idle
       
   582 // ---------------------------------------------------------------------------
       
   583 //
       
   584 TBool CCCEPluginManager::ReleaseWhenIdle( const TUid aType )
       
   585     {
       
   586     
       
   587     TBool release = EFalse;     
       
   588     TInt pluginCount = iPluginArray.Count();
       
   589     for (TInt a = 0; a < pluginCount; a++)
       
   590         {
       
   591         if ( iPluginArray[a]->Type() == aType )
       
   592             {
       
   593             release = iPluginArray[a]->ReleaseWhenIdle();
       
   594             break;
       
   595             }
       
   596         }
       
   597         
       
   598     CCELOGSTRING2("CCCEPluginManager::ReleaseWhenIdle  returning %d ", (TInt) release);
       
   599     return release;
       
   600     }
       
   601 
       
   602 // -----------------------------------------------------------------------------
       
   603 // Return array of dtmf providers.
       
   604 // -----------------------------------------------------------------------------
       
   605 //
       
   606 MCCPDTMFProvider& CCCEPluginManager::DtmfProviderL( 
       
   607     const MCCPDTMFObserver& aObserver,
       
   608     TUid aImplementationUid ) const
       
   609     {
       
   610     CCCEPlugin* plugin( NULL );
       
   611     
       
   612     for( TInt i=0; i<iPluginArray.Count(); i++ )
       
   613         {
       
   614         if( iPluginArray[i]->Type().iUid == aImplementationUid.iUid )
       
   615             {
       
   616             plugin =  iPluginArray[i];
       
   617             i = iPluginArray.Count();
       
   618             }
       
   619         }
       
   620   
       
   621     if ( !plugin )
       
   622         {
       
   623         User::Leave( KErrNotFound );
       
   624         }
       
   625    
       
   626     return plugin->GetDtmfProviderL( aObserver );
       
   627     }
       
   628 
       
   629 // -----------------------------------------------------------------------------
       
   630 // From class MPluginObserver.
       
   631 // 
       
   632 // -----------------------------------------------------------------------------
       
   633 //
       
   634 
       
   635 void CCCEPluginManager::CCPPluginDiedEvent(TUid aPluginId, TInt /*aDeathType*/, TInt /*aReason*/)
       
   636     {
       
   637 
       
   638     CCELOGSTRING2("CCCEPluginManager::CCPPluginDiedEvent: %d", aPluginId.iUid );
       
   639        
       
   640     RPointerArray<CCCECall> calls;
       
   641     
       
   642     TInt count = iCallContainer.GetCall(aPluginId, calls);
       
   643     CCELOGSTRING2("CCCEPluginManager::CCPPluginDiedEvent: %d calls found!", count);
       
   644     for (TInt i = 0; i < count; i++)
       
   645         {
       
   646         calls[i]->ErrorOccurred( ECCPServerFailure, &calls[i]->GetCCPCall() );
       
   647         calls[i]->CallStateChanged( MCCPCallObserver::ECCPStateIdle, &calls[i]->GetCCPCall() );
       
   648         }
       
   649         
       
   650     calls.Close();
       
   651     
       
   652     CCELOGSTRING("CCCEPluginManager::CCPPluginDiedEvent: Plugin calls terminated");
       
   653 
       
   654     TInt pluginCount = iPluginArray.Count();
       
   655     for (TInt a = 0; a < pluginCount; a++)
       
   656         {
       
   657         if ( iPluginArray[a]->Type() == aPluginId )
       
   658             {
       
   659             iPluginsToClose.Append(iPluginArray[a]);
       
   660             if (!iIdle->IsActive())
       
   661                 {
       
   662                 iIdle->Start( TCallBack(RemovePlugins,this) );
       
   663                 }
       
   664             iPluginArray.Remove(a);
       
   665             iPluginArray.Compress();
       
   666             return;
       
   667             }
       
   668         }
       
   669     }
       
   670 // -----------------------------------------------------------------------------
       
   671 // From class MPluginObserver.
       
   672 // 
       
   673 // -----------------------------------------------------------------------------
       
   674 //    
       
   675 
       
   676 void CCCEPluginManager::CCPPluginInitialisationFailed(TUid aPluginUid, TInt /*aError*/)
       
   677     {
       
   678  
       
   679     CCELOGSTRING2("CCCEPluginManager::CCPPluginInitialisationFailed: %d", aPluginUid.iUid );
       
   680     if (iCallContainer.CountCalls(aPluginUid))
       
   681         {
       
   682         // there is active call, cannot close.
       
   683         return;
       
   684         }
       
   685         
       
   686     TInt pluginCount = iPluginArray.Count();
       
   687     for (TInt a = 0; a < pluginCount; a++)
       
   688         {
       
   689         if ( iPluginArray[a]->Type() == aPluginUid )
       
   690             {
       
   691             iPluginsToClose.Append(iPluginArray[a]);
       
   692             if (!iIdle->IsActive())
       
   693                 {
       
   694                 iIdle->Start( TCallBack(RemovePlugins,this) );
       
   695                 }
       
   696             iPluginArray.Remove(a);
       
   697             iPluginArray.Compress();
       
   698             return;
       
   699             }
       
   700         }
       
   701     }
       
   702     
       
   703 // end of file