cmmanager/cmmgr/Framework/Src/cmmanagerext.cpp
changeset 20 9c97ad6591ae
parent 18 fcbbe021d614
child 21 b8e8e15e80f2
child 23 7ec726f93df1
child 28 860702281757
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of RCmManagerExt
       
    15 *
       
    16 */
       
    17 
       
    18 #include <cmmanagerext.h>
       
    19 #include <cmpluginbaseeng.h>
       
    20 #include <cmpluginbase.h>
       
    21 #include <cmdestinationext.h>
       
    22 #include "cmlogger.h"
       
    23 #include "cmmanager.hrh"
       
    24 #include <cmcommonconstants.h>
       
    25 #include "cmmanagerimpl.h"
       
    26 #include "cmdestinationimpl.h"
       
    27 #include "cmmanager.hrh"
       
    28 #include <data_caging_path_literals.hrh>
       
    29 
       
    30 #include <StringLoader.h>
       
    31 #include <e32cmn.h>
       
    32 #include <cmmanager.rsg>    // resource
       
    33 
       
    34 //-----------------------------------------------------------------------------
       
    35 //  RCmManagerExt::~RCmManagerExt()
       
    36 //-----------------------------------------------------------------------------
       
    37 //
       
    38 EXPORT_C void RCmManagerExt::Close()
       
    39     {
       
    40     CLOG_WRITE( "RCmManagerExt::Close()" );
       
    41     delete iImplementation;
       
    42     iImplementation = NULL;
       
    43     
       
    44     CLOG_CLOSE;
       
    45     }
       
    46 
       
    47 //-----------------------------------------------------------------------------
       
    48 //  RCmManagerExt::ConstructL()
       
    49 //-----------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C void RCmManagerExt::OpenL()
       
    52     {
       
    53     CLOG_CREATE;
       
    54     CLOG_NAME_1( _L("ManagerExt_0x%x"), this );
       
    55     iImplementation = CCmManagerImpl::NewL(EFalse);
       
    56     CLOG_ATTACH( iImplementation, this );
       
    57     }
       
    58 
       
    59 //-----------------------------------------------------------------------------
       
    60 //  RCmManagerExt::ConstructL()
       
    61 //-----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C void RCmManagerExt::CreateTablesAndOpenL()
       
    64     {
       
    65     CLOG_CREATE;
       
    66     CLOG_NAME_1( _L("ManagerExt_0x%x"), this );
       
    67     iImplementation = CCmManagerImpl::NewL();
       
    68     CLOG_ATTACH( iImplementation, this );
       
    69     }
       
    70     
       
    71 //-----------------------------------------------------------------------------
       
    72 //  RCmManagerExt::OpenLC()
       
    73 //-----------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C void RCmManagerExt::OpenLC()
       
    76     {
       
    77     CLOG_CREATE;
       
    78     CLOG_NAME_1( _L("Manager_0x%x"), this );
       
    79     CleanupClosePushL(*this);
       
    80     iImplementation = NULL;
       
    81     iImplementation = CCmManagerImpl::NewL();
       
    82     CLOG_ATTACH( iImplementation, this );
       
    83     }
       
    84 
       
    85 //-----------------------------------------------------------------------------
       
    86 //  RCmManagerExt::GetBearerInfoIntL()
       
    87 //-----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C TUint32 RCmManagerExt::GetBearerInfoIntL( TUint32 aBearerType,
       
    90                                                    TUint32 aAttribute ) const
       
    91     {
       
    92     return iImplementation->GetBearerInfoIntL( aBearerType,
       
    93                                                        aAttribute );
       
    94     }
       
    95 
       
    96 //-----------------------------------------------------------------------------
       
    97 //  RCmManagerExt::GetBearerInfoBoolL()
       
    98 //-----------------------------------------------------------------------------
       
    99 //
       
   100 EXPORT_C TBool RCmManagerExt::GetBearerInfoBoolL( TUint32 aBearerType,
       
   101                                                   TUint32 aAttribute ) const
       
   102     {
       
   103     return iImplementation->GetBearerInfoBoolL( aBearerType,
       
   104                                                        aAttribute );
       
   105     }
       
   106 
       
   107 //-----------------------------------------------------------------------------
       
   108 //  RCmManagerExt::GetBearerInfoStringL()
       
   109 //-----------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C HBufC* RCmManagerExt::GetBearerInfoStringL( TUint32 aBearerType,
       
   112                                                      TUint32 aAttribute ) const
       
   113     {
       
   114     return iImplementation->GetBearerInfoStringL( aBearerType,
       
   115                                                        aAttribute );
       
   116     }
       
   117 
       
   118 //-----------------------------------------------------------------------------
       
   119 //  RCmManagerExt::GetBearerInfoString8L()
       
   120 //-----------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C HBufC8* 
       
   123                 RCmManagerExt::GetBearerInfoString8L( TUint32 aBearerType,
       
   124                                                       TUint32 aAttribute ) const
       
   125     {
       
   126     return iImplementation->GetBearerInfoString8L( aBearerType,
       
   127                                                    aAttribute );
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // RCmManagerExt::GetConnectionMethodInfoIntL()
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C TUint32 RCmManagerExt::GetConnectionMethodInfoIntL( TUint32 aIapId,
       
   135                                      TUint32 aAttribute ) const
       
   136     {
       
   137     return iImplementation->GetConnectionMethodInfoIntL( aIapId, aAttribute );
       
   138     }
       
   139     
       
   140 // -----------------------------------------------------------------------------
       
   141 // RCmManagerExt::GetConnectionMethodInfoBoolL()
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C TBool RCmManagerExt::GetConnectionMethodInfoBoolL( TUint32 aIapId,
       
   145                                     TUint32 aAttribute ) const
       
   146     {
       
   147     return iImplementation->GetConnectionMethodInfoBoolL( aIapId, aAttribute );
       
   148     }
       
   149     
       
   150 // -----------------------------------------------------------------------------
       
   151 // RCmManagerExt::GetConnectionMethodInfoStringL()
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 EXPORT_C HBufC* RCmManagerExt::GetConnectionMethodInfoStringL( TUint32 aIapId,
       
   155                                        TUint32 aAttribute ) const
       
   156     {
       
   157     return iImplementation->GetConnectionMethodInfoStringL( aIapId, 
       
   158                                                             aAttribute );
       
   159     }
       
   160     
       
   161 // -----------------------------------------------------------------------------
       
   162 // RCmManagerExt::GetConnectionMethodInfoStringL()
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 EXPORT_C HBufC8* 
       
   166     RCmManagerExt::GetConnectionMethodInfoString8L( TUint32 aIapId,
       
   167                                                     TUint32 aAttribute ) const
       
   168     {
       
   169     return iImplementation->GetConnectionMethodInfoString8L( aIapId, aAttribute );
       
   170     }
       
   171     
       
   172 //=============================================================================
       
   173 // CREATION / DELETION API
       
   174 //=============================================================================
       
   175 //
       
   176 
       
   177 //-----------------------------------------------------------------------------
       
   178 //  RCmManagerExt::CreateDestinationL( const TDesC& aName )
       
   179 //-----------------------------------------------------------------------------
       
   180 //
       
   181 EXPORT_C 
       
   182     RCmDestinationExt RCmManagerExt::CreateDestinationL( const TDesC& aName )
       
   183     {
       
   184     RCmDestinationExt dest;
       
   185     
       
   186     CCmDestinationImpl* destImp = iImplementation->CreateDestinationL( aName );
       
   187     dest.iDestinatonData = destImp->GetData();
       
   188     dest.iDestinatonData->IncrementRefCounter();
       
   189     delete destImp;
       
   190     
       
   191     return dest;
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // RCmManagerExt::CreateConnectionMethodL()
       
   196 // -----------------------------------------------------------------------------
       
   197 //  
       
   198 EXPORT_C RCmConnectionMethodExt 
       
   199         RCmManagerExt::CreateConnectionMethodL( TUint32 aImplementationUid )
       
   200     {
       
   201     RCmConnectionMethodExt cm;
       
   202         
       
   203     CCmPluginBase* cM =  
       
   204         iImplementation->CreateConnectionMethodL( aImplementationUid );
       
   205     cm.iImplementation = cM->Plugin();
       
   206     cm.iImplementation->IncrementRefCounter();
       
   207     delete cM;
       
   208 
       
   209     return cm;
       
   210     }
       
   211 
       
   212 //-----------------------------------------------------------------------------
       
   213 // RCmManagerExt::CopyL()
       
   214 //-----------------------------------------------------------------------------
       
   215 //
       
   216 EXPORT_C TInt RCmManagerExt::CopyConnectionMethodL( 
       
   217                                       RCmDestinationExt& aTargetDestination,
       
   218                                       RCmConnectionMethodExt& aConnectionMethod )
       
   219     {
       
   220     CCmDestinationImpl* aImplementation = 
       
   221             CCmDestinationImpl::NewLC(aTargetDestination.iDestinatonData);
       
   222     // Deleting aImplementation will decrement the ref counter
       
   223     aImplementation->IncrementRefCounter();
       
   224     CCmPluginBase* connMethod = new (ELeave) 
       
   225                             CCmPluginBase(aConnectionMethod.iImplementation);
       
   226     connMethod->IncrementRefCounter();    
       
   227     CleanupStack::PushL( connMethod );        
       
   228     TInt retVal = iImplementation->CopyConnectionMethodL( 
       
   229                                            *aImplementation, 
       
   230                                            *connMethod );
       
   231     CleanupStack::PopAndDestroy(connMethod);
       
   232     CleanupStack::PopAndDestroy(aImplementation);
       
   233     return retVal;
       
   234     }
       
   235 
       
   236 //-----------------------------------------------------------------------------
       
   237 // RCmManagerExt::MoveConnMethodL()
       
   238 //-----------------------------------------------------------------------------
       
   239 //
       
   240 EXPORT_C TInt RCmManagerExt::MoveConnectionMethodL( 
       
   241                                       RCmDestinationExt& aSourceDestination,
       
   242                                       RCmDestinationExt& aTargetDestination,
       
   243                                       RCmConnectionMethodExt& aConnectionMethod )
       
   244     {
       
   245     CCmDestinationImpl* aSourceImpl = 
       
   246             CCmDestinationImpl::NewLC(aSourceDestination.iDestinatonData);
       
   247     aSourceImpl->IncrementRefCounter();
       
   248     CCmDestinationImpl* aTargetImpl = 
       
   249             CCmDestinationImpl::NewLC(aTargetDestination.iDestinatonData);
       
   250     aTargetImpl->IncrementRefCounter();
       
   251     CCmPluginBase* connMethod = new (ELeave) 
       
   252                             CCmPluginBase(aConnectionMethod.iImplementation);
       
   253     connMethod->IncrementRefCounter();    
       
   254     CleanupStack::PushL( connMethod );        
       
   255     TInt retVal = iImplementation->MoveConnectionMethodL( 
       
   256                     *aSourceImpl, 
       
   257                     *aTargetImpl, 
       
   258                     *connMethod );
       
   259     CleanupStack::PopAndDestroy(connMethod);
       
   260     CleanupStack::PopAndDestroy(aTargetImpl);
       
   261     CleanupStack::PopAndDestroy(aSourceImpl);
       
   262     return retVal;
       
   263     }
       
   264 
       
   265 //-----------------------------------------------------------------------------
       
   266 // RCmManagerExt::RemoveConnectionMethodL()
       
   267 //-----------------------------------------------------------------------------
       
   268 //
       
   269 EXPORT_C void RCmManagerExt::RemoveConnectionMethodL( 
       
   270                                       RCmDestinationExt& aDestination,
       
   271                                       RCmConnectionMethodExt& aConnectionMethod )
       
   272     {
       
   273     CCmDestinationImpl* aDestImpl = 
       
   274             CCmDestinationImpl::NewLC(aDestination.iDestinatonData);
       
   275     aDestImpl->IncrementRefCounter();
       
   276     CCmPluginBase* connMethod = new (ELeave) 
       
   277                             CCmPluginBase(aConnectionMethod.iImplementation);
       
   278     connMethod->IncrementRefCounter();    
       
   279     CleanupStack::PushL( connMethod );        
       
   280     iImplementation->RemoveConnectionMethodL( 
       
   281                     *aDestImpl, 
       
   282                     *connMethod );
       
   283     CleanupStack::PopAndDestroy(connMethod);
       
   284     CleanupStack::PopAndDestroy(aDestImpl);
       
   285     }
       
   286 
       
   287 //-----------------------------------------------------------------------------
       
   288 // RCmManagerExt::RemoveAllReferencesL()
       
   289 //-----------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C void RCmManagerExt::RemoveAllReferencesL( 
       
   292                                     RCmConnectionMethodExt& aConnectionMethod )
       
   293     {
       
   294     iImplementation->RemoveAllReferencesL( *aConnectionMethod.iImplementation );
       
   295     }
       
   296 
       
   297 //-----------------------------------------------------------------------------
       
   298 //  RCmManagerExt::ConnectionMethodExtL()
       
   299 //-----------------------------------------------------------------------------
       
   300 //
       
   301 EXPORT_C RCmConnectionMethodExt 
       
   302                               RCmManagerExt::ConnectionMethodL( TUint32 aIapId )
       
   303     {
       
   304     RCmConnectionMethodExt cm;
       
   305     CCmPluginBase* cM =  iImplementation->GetConnectionMethodL( aIapId );
       
   306     cm.iImplementation = cM->Plugin();
       
   307     cm.iImplementation->IncrementRefCounter();
       
   308     delete cM;
       
   309         
       
   310     return cm;
       
   311     }
       
   312 
       
   313 //-----------------------------------------------------------------------------
       
   314 //  RCmManagerExt::ConnectionMethodL()
       
   315 //-----------------------------------------------------------------------------
       
   316 //
       
   317 EXPORT_C void RCmManagerExt::ConnectionMethodL( RArray<TUint32>& aCMArray,
       
   318                                                 TBool aCheckBearerType,
       
   319                                                 TBool aLegacyOnly,
       
   320                                                 TBool aEasyWlan )
       
   321     {
       
   322     iImplementation->ConnectionMethodL( aCMArray, 
       
   323                                                aCheckBearerType,
       
   324                                                aLegacyOnly,
       
   325                                                aEasyWlan );
       
   326     }
       
   327 
       
   328 //-----------------------------------------------------------------------------
       
   329 //  RCmManagerExt::DestinationL()
       
   330 //-----------------------------------------------------------------------------
       
   331 //  
       
   332 EXPORT_C RCmDestinationExt RCmManagerExt::DestinationL( TUint32 aId )
       
   333     {
       
   334     RCmDestinationExt dest;
       
   335     
       
   336     CCmDestinationImpl* aDestImpl = iImplementation->DestinationL( aId );
       
   337     dest.iDestinatonData = aDestImpl->GetData( );
       
   338     dest.iDestinatonData->IncrementRefCounter();
       
   339     delete aDestImpl;
       
   340     
       
   341     return dest;
       
   342     }
       
   343 
       
   344 //-----------------------------------------------------------------------------
       
   345 //  RCmManagerExt::AllDestinationsL()
       
   346 //-----------------------------------------------------------------------------
       
   347 //
       
   348 EXPORT_C void RCmManagerExt::AllDestinationsL( RArray<TUint32>& aDestArray )
       
   349     {   
       
   350     return iImplementation->AllDestinationsL( aDestArray );
       
   351     }
       
   352 
       
   353 //-----------------------------------------------------------------------------
       
   354 //  RCmManagerExt::BearerPriorityArrayL()
       
   355 //-----------------------------------------------------------------------------
       
   356 //
       
   357 EXPORT_C void RCmManagerExt::BearerPriorityArrayL( 
       
   358                                         RArray<TBearerPriority>& aArray ) const
       
   359     {
       
   360     LOGGER_ENTERFN( "RCmManagerExt:BearerPriorityArray" );
       
   361     iImplementation->BearerPriorityArrayL( aArray ); 
       
   362     }
       
   363 
       
   364 //-----------------------------------------------------------------------------
       
   365 //  RCmManagerExt::UpdateBearerPriorityArrayL()
       
   366 //-----------------------------------------------------------------------------
       
   367 //
       
   368 EXPORT_C void RCmManagerExt::UpdateBearerPriorityArrayL( 
       
   369                                         const RArray<TBearerPriority>& aArray )
       
   370     {
       
   371     LOGGER_ENTERFN( "RCmManagerExt::UpdateBearerPriorityArray" );    
       
   372     iImplementation->UpdateBearerPriorityArrayL( aArray );
       
   373     }
       
   374 
       
   375 //-----------------------------------------------------------------------------
       
   376 //  RCmManagerExt::CleanupGlobalPriorityArray()
       
   377 //-----------------------------------------------------------------------------
       
   378 //
       
   379 EXPORT_C void RCmManagerExt::CleanupGlobalPriorityArray( 
       
   380                                         RArray<TBearerPriority>& aArray ) const
       
   381     {
       
   382     LOGGER_ENTERFN( "RCmManagerExt:CleanupGlobalPriorityArray" );
       
   383     iImplementation->CleanupGlobalPriorityArray( aArray ); 
       
   384     }
       
   385 
       
   386 //-----------------------------------------------------------------------------
       
   387 //  RCmManagerExt::SupportedBearers()
       
   388 //-----------------------------------------------------------------------------
       
   389 //
       
   390 EXPORT_C void RCmManagerExt::SupportedBearersL( RArray<TUint32>& aArray ) const
       
   391     {
       
   392     return iImplementation->SupportedBearersL( aArray );        
       
   393     }
       
   394 
       
   395 //-----------------------------------------------------------------------------
       
   396 //  RCmManagerExt::UncategorizedIconL()
       
   397 //-----------------------------------------------------------------------------
       
   398 //    
       
   399 EXPORT_C CGulIcon* RCmManagerExt::UncategorizedIconL() const
       
   400     {
       
   401     return iImplementation->UncategorizedIconL();        
       
   402     }
       
   403 
       
   404 //-----------------------------------------------------------------------------
       
   405 //  RCmManagerExt::EasyWlanIdL()
       
   406 //-----------------------------------------------------------------------------
       
   407 //    
       
   408 EXPORT_C TUint32 RCmManagerExt::EasyWlanIdL()
       
   409     {
       
   410     return iImplementation->EasyWlanIdL();        
       
   411     }
       
   412     
       
   413 //-----------------------------------------------------------------------------
       
   414 //  RCmManagerExt::ReadDefConnL()
       
   415 //-----------------------------------------------------------------------------
       
   416 //    
       
   417 EXPORT_C void RCmManagerExt::ReadDefConnL( TCmDefConnValue& aDCSetting )
       
   418     {
       
   419     return iImplementation->ReadDefConnL( aDCSetting );        
       
   420     }
       
   421     
       
   422 //-----------------------------------------------------------------------------
       
   423 //  RCmManagerExt::WriteDefConnL()
       
   424 //-----------------------------------------------------------------------------
       
   425 //    
       
   426 EXPORT_C void RCmManagerExt::WriteDefConnL( const  TCmDefConnValue& aDCSetting )
       
   427     {
       
   428     return iImplementation->WriteDefConnL( aDCSetting );        
       
   429     }
       
   430 
       
   431  
       
   432 //-----------------------------------------------------------------------------
       
   433 //  RCmManagerExt::CreateDestinationL( const TDesC& aName,
       
   434 //                                     TUint32 aDestId )
       
   435 //-----------------------------------------------------------------------------
       
   436 //
       
   437 EXPORT_C RCmDestinationExt RCmManagerExt::CreateDestinationL(
       
   438     const TDesC& aName,
       
   439     TUint32 aDestId )
       
   440     {
       
   441     if ( aDestId == 0 )
       
   442         {
       
   443         return CreateDestinationL( aName );
       
   444         }
       
   445 
       
   446     // Check if there already exists a destination with the same Id
       
   447     RArray<TUint32> destIdArray = RArray<TUint32>( KCmArrayBigGranularity );
       
   448     iImplementation->AllDestinationsL( destIdArray );
       
   449     for ( TInt i = 0; i < destIdArray.Count(); i++ )
       
   450         {
       
   451         if ( aDestId > 0 && aDestId < 255 )
       
   452             {
       
   453             aDestId = aDestId + KCmDefaultDestinationAPTagId;
       
   454             }
       
   455         else if ( aDestId < KCmDefaultDestinationAPTagId+1 
       
   456                   && ( aDestId > ( KCmDefaultDestinationAPTagId+255 ) ) )
       
   457             {
       
   458             User::Leave( KErrArgument );
       
   459             }
       
   460         if ( aDestId == destIdArray[i] )
       
   461             {
       
   462             destIdArray.Close();
       
   463             User::Leave( KErrAlreadyExists );
       
   464             }
       
   465         }
       
   466     destIdArray.Close();
       
   467 
       
   468     RCmDestinationExt dest;
       
   469 
       
   470     CCmDestinationImpl* destImp =
       
   471                         iImplementation->CreateDestinationL( aName,
       
   472                                                              aDestId );
       
   473     dest.iDestinatonData = destImp->GetData();
       
   474     dest.iDestinatonData->IncrementRefCounter();
       
   475     delete destImp;
       
   476 
       
   477     return dest;
       
   478     }
       
   479 
       
   480 // -----------------------------------------------------------------------------
       
   481 // RCmManagerExt::CreateConnectionMethodL()
       
   482 // -----------------------------------------------------------------------------
       
   483 //  
       
   484 EXPORT_C RCmConnectionMethodExt RCmManagerExt::CreateConnectionMethodL(
       
   485     TUint32 aImplementationUid,
       
   486     TUint32 aConnMethodId )
       
   487     {
       
   488     if ( aConnMethodId == 0 )
       
   489         {
       
   490         return CreateConnectionMethodL( aImplementationUid );
       
   491         }
       
   492 
       
   493     RCmConnectionMethodExt cm;
       
   494 
       
   495     CCmPluginBase* cM =
       
   496                    iImplementation->CreateConnectionMethodL( aImplementationUid,
       
   497                                                              aConnMethodId );
       
   498     cm.iImplementation = cM->Plugin();
       
   499     cm.iImplementation->IncrementRefCounter();
       
   500     delete cM;
       
   501 
       
   502     return cm;
       
   503     }