cmmanager/cmmgr/cmmapi/src/cmmanager.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
       
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Implementation of RCmManager.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <cmmanager.h>
       
    21 #include <cmconnectionmethod.h>
       
    22 #include <cmdestination.h>
       
    23 
       
    24 #include "cmmserverdefs.h"
       
    25 #include "cmmanagerapi.h"
       
    26 #include "cmconnectionmethodwrapper.h"
       
    27 #include "cmdestinationwrapper.h"
       
    28 
       
    29 #include "OstTraceDefinitions.h"
       
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 #include "cmmanagerTraces.h"
       
    32 #endif
       
    33 
       
    34 
       
    35 //-----------------------------------------------------------------------------
       
    36 //  RCmManager::OpenL()
       
    37 //-----------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C void RCmManager::OpenL()
       
    40     {
       
    41     OstTraceFunctionEntry0( RCMMANAGER_OPENL_ENTRY );
       
    42 
       
    43     OpenLC();
       
    44     CleanupStack::Pop( this );
       
    45 
       
    46     OstTraceFunctionExit0( RCMMANAGER_OPENL_EXIT );
       
    47     }
       
    48 
       
    49 //-----------------------------------------------------------------------------
       
    50 //  RCmManager::OpenLC()
       
    51 //-----------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C void RCmManager::OpenLC()
       
    54     {
       
    55     OstTraceFunctionEntry0( RCMMANAGER_OPENLC_ENTRY );
       
    56 
       
    57     if ( iCmManagerApi )
       
    58         {
       
    59         User::Leave( KErrAlreadyExists );
       
    60         }
       
    61 
       
    62     CleanupClosePushL( *this );
       
    63     iCmManagerApi = new (ELeave) RCmManagerApi();
       
    64     User::LeaveIfError( iCmManagerApi->Connect() );
       
    65 
       
    66     OstTraceFunctionExit0( RCMMANAGER_OPENLC_EXIT );
       
    67     }
       
    68 
       
    69 //-----------------------------------------------------------------------------
       
    70 //  RCmManager::Close()
       
    71 //-----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C void RCmManager::Close()
       
    74     {
       
    75     OstTraceFunctionEntry0( RCMMANAGER_CLOSE_ENTRY );
       
    76 
       
    77     if ( iCmManagerApi )
       
    78         {
       
    79         iCmManagerApi->Close();
       
    80         delete iCmManagerApi;
       
    81         iCmManagerApi = NULL;
       
    82         }
       
    83 
       
    84     OstTraceFunctionExit0( RCMMANAGER_CLOSE_EXIT );
       
    85     }
       
    86 
       
    87 //-----------------------------------------------------------------------------
       
    88 //  RCmManager::CreateTablesAndOpenL()
       
    89 //-----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void RCmManager::CreateTablesAndOpenL()
       
    92     {
       
    93     OstTraceFunctionEntry0( RCMMANAGER_CREATETABLESANDOPENL_ENTRY );
       
    94     OpenL();
       
    95     OstTraceFunctionExit0( RCMMANAGER_CREATETABLESANDOPENL_EXIT );
       
    96     }
       
    97 
       
    98 //-----------------------------------------------------------------------------
       
    99 //  RCmManager::ConnectionMethodL()
       
   100 //-----------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C RCmConnectionMethod RCmManager::ConnectionMethodL(
       
   103         TUint32 aConnectionMethodId ) const
       
   104     {
       
   105     OstTraceFunctionEntry0( RCMMANAGER_CONNECTIONMETHODL_ENTRY );
       
   106 
       
   107     if ( !iCmManagerApi )
       
   108         {
       
   109         User::Leave( KErrBadHandle );
       
   110         }
       
   111 
       
   112     if ( !( ( aConnectionMethodId > KCmmConnMethodIdIntervalMin ) &&
       
   113             ( aConnectionMethodId < KCmmConnMethodIdIntervalMax ) ) )
       
   114         {
       
   115         User::Leave( KErrArgument );
       
   116         }
       
   117 
       
   118     // If client already has a handle open to this connection method, give a
       
   119     // reference to it.
       
   120     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   121     TInt existingHandle( 0 );
       
   122     cmWrapper->GetConnMethodWithIdL( iCmManagerApi, aConnectionMethodId, existingHandle );
       
   123     if ( existingHandle )
       
   124         {
       
   125         CleanupStack::PopAndDestroy( cmWrapper );
       
   126         cmWrapper = iCmManagerApi->GetConnMethodWrapperL( existingHandle );
       
   127         cmWrapper->IncreaseReferenceCounter();
       
   128         }
       
   129     else
       
   130         {
       
   131         CleanupStack::Pop( cmWrapper );
       
   132         }
       
   133 
       
   134     RCmConnectionMethod cm;
       
   135     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   136 
       
   137     OstTraceFunctionExit0( DUP1_RCMMANAGER_CONNECTIONMETHODL_EXIT );
       
   138     return cm;
       
   139     }
       
   140 
       
   141 //-----------------------------------------------------------------------------
       
   142 //  RCmManager::GetBearerInfoIntL()
       
   143 //-----------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C TUint32 RCmManager::GetBearerInfoIntL(
       
   146         TUint32 aBearerType,
       
   147         TUint32 aAttribute ) const
       
   148     {
       
   149     OstTraceFunctionEntry0( RCMMANAGER_GETBEARERINFOINTL_ENTRY );
       
   150 
       
   151     if ( !iCmManagerApi )
       
   152         {
       
   153         User::Leave( KErrBadHandle );
       
   154         }
       
   155 
       
   156     TUint32 value( 0 );
       
   157     TInt err = iCmManagerApi->GetBearerInfoInt( aBearerType, aAttribute, value );
       
   158     User::LeaveIfError( err );
       
   159 
       
   160     OstTraceFunctionExit0( RCMMANAGER_GETBEARERINFOINTL_EXIT );
       
   161     return value;
       
   162     }
       
   163 
       
   164 //-----------------------------------------------------------------------------
       
   165 //  RCmManager::GetBearerInfoBoolL()
       
   166 //-----------------------------------------------------------------------------
       
   167 //
       
   168 EXPORT_C TBool RCmManager::GetBearerInfoBoolL(
       
   169         TUint32 aBearerType,
       
   170         TUint32 aAttribute ) const
       
   171     {
       
   172     OstTraceFunctionEntry0( RCMMANAGER_GETBEARERINFOBOOLL_ENTRY );
       
   173 
       
   174     if ( !iCmManagerApi )
       
   175         {
       
   176         User::Leave( KErrBadHandle );
       
   177         }
       
   178 
       
   179     TBool value( 0 );
       
   180     TInt err = iCmManagerApi->GetBearerInfoBool( aBearerType, aAttribute, value );
       
   181     User::LeaveIfError( err );
       
   182 
       
   183     OstTraceFunctionExit0( RCMMANAGER_GETBEARERINFOBOOLL_EXIT );
       
   184     return value;
       
   185     }
       
   186 
       
   187 //-----------------------------------------------------------------------------
       
   188 //  RCmManager::GetBearerInfoStringL()
       
   189 //-----------------------------------------------------------------------------
       
   190 //
       
   191 EXPORT_C HBufC* RCmManager::GetBearerInfoStringL(
       
   192         TUint32 aBearerType,
       
   193         TUint32 aAttribute ) const
       
   194     {
       
   195     OstTraceFunctionEntry0( RCMMANAGER_GETBEARERINFOSTRINGL_ENTRY );
       
   196 
       
   197     if ( !iCmManagerApi )
       
   198         {
       
   199         User::Leave( KErrBadHandle );
       
   200         }
       
   201 
       
   202     HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
       
   203     TInt err = iCmManagerApi->GetBearerInfoString( aBearerType, aAttribute, buffer );
       
   204     User::LeaveIfError( err );
       
   205 
       
   206     if ( buffer->Length() > 0 )
       
   207         {
       
   208         CleanupStack::Pop( buffer );
       
   209         }
       
   210     else
       
   211         {
       
   212         CleanupStack::PopAndDestroy( buffer );
       
   213         buffer = KNullDesC().AllocL();
       
   214         }
       
   215 
       
   216     OstTraceFunctionExit0( RCMMANAGER_GETBEARERINFOSTRINGL_EXIT );
       
   217     return buffer;
       
   218     }
       
   219 
       
   220 //-----------------------------------------------------------------------------
       
   221 //  RCmManager::GetBearerInfoString8L()
       
   222 //-----------------------------------------------------------------------------
       
   223 //
       
   224 EXPORT_C HBufC8* RCmManager::GetBearerInfoString8L(
       
   225         TUint32 aBearerType,
       
   226         TUint32 aAttribute ) const
       
   227     {
       
   228     OstTraceFunctionEntry0( RCMMANAGER_GETBEARERINFOSTRING8L_ENTRY );
       
   229 
       
   230     if ( !iCmManagerApi )
       
   231         {
       
   232         User::Leave( KErrBadHandle );
       
   233         }
       
   234 
       
   235     HBufC8* buffer8 = HBufC8::NewLC( KCmmStringLengthMax );
       
   236     TInt err = iCmManagerApi->GetBearerInfoString8( aBearerType, aAttribute, buffer8 );
       
   237     User::LeaveIfError( err );
       
   238 
       
   239     if ( buffer8->Length() > 0 )
       
   240         {
       
   241         CleanupStack::Pop( buffer8 );
       
   242         }
       
   243     else
       
   244         {
       
   245         CleanupStack::PopAndDestroy( buffer8 );
       
   246         buffer8 = KNullDesC8().AllocL();
       
   247         }
       
   248 
       
   249     OstTraceFunctionExit0( RCMMANAGER_GETBEARERINFOSTRING8L_EXIT );
       
   250     return buffer8;
       
   251     }
       
   252 
       
   253 //-----------------------------------------------------------------------------
       
   254 //  RCmManager::GetConnectionMethodInfoIntL()
       
   255 //-----------------------------------------------------------------------------
       
   256 //
       
   257 EXPORT_C TUint32 RCmManager::GetConnectionMethodInfoIntL(
       
   258         TUint32 aIapId,
       
   259         TUint32 aAttribute ) const
       
   260     {
       
   261     OstTraceFunctionEntry0( RCMMANAGER_GETCONNECTIONMETHODINFOINTL_ENTRY );
       
   262 
       
   263     if ( !iCmManagerApi )
       
   264         {
       
   265         User::Leave( KErrBadHandle );
       
   266         }
       
   267 
       
   268     TUint32 value( 0 );
       
   269     TInt err = iCmManagerApi->GetConnectionMethodInfoInt( aIapId, aAttribute, value );
       
   270     User::LeaveIfError( err );
       
   271 
       
   272     OstTraceFunctionExit0( RCMMANAGER_GETCONNECTIONMETHODINFOINTL_EXIT );
       
   273     return value;
       
   274     }
       
   275 
       
   276 //-----------------------------------------------------------------------------
       
   277 //  RCmManager::GetConnectionMethodInfoBoolL()
       
   278 //-----------------------------------------------------------------------------
       
   279 //
       
   280 EXPORT_C TBool RCmManager::GetConnectionMethodInfoBoolL(
       
   281         TUint32 aIapId,
       
   282         TUint32 aAttribute ) const
       
   283     {
       
   284     OstTraceFunctionEntry0( RCMMANAGER_GETCONNECTIONMETHODINFOBOOLL_ENTRY );
       
   285 
       
   286     if ( !iCmManagerApi )
       
   287         {
       
   288         User::Leave( KErrBadHandle );
       
   289         }
       
   290 
       
   291     TBool value( 0 );
       
   292     TInt err = iCmManagerApi->GetConnectionMethodInfoBool( aIapId, aAttribute, value );
       
   293     User::LeaveIfError( err );
       
   294 
       
   295     OstTraceFunctionExit0( RCMMANAGER_GETCONNECTIONMETHODINFOBOOLL_EXIT );
       
   296     return value;
       
   297     }
       
   298 
       
   299 //-----------------------------------------------------------------------------
       
   300 //  RCmManager::GetConnectionMethodInfoStringL()
       
   301 //-----------------------------------------------------------------------------
       
   302 //
       
   303 EXPORT_C HBufC* RCmManager::GetConnectionMethodInfoStringL(
       
   304         TUint32 aIapId,
       
   305         TUint32 aAttribute ) const
       
   306     {
       
   307     OstTraceFunctionEntry0( RCMMANAGER_GETCONNECTIONMETHODINFOSTRINGL_ENTRY );
       
   308 
       
   309     if ( !iCmManagerApi )
       
   310         {
       
   311         User::Leave( KErrBadHandle );
       
   312         }
       
   313 
       
   314     HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
       
   315     TInt err = iCmManagerApi->GetConnectionMethodInfoString( aIapId, aAttribute, buffer );
       
   316     User::LeaveIfError( err );
       
   317 
       
   318     if ( buffer->Length() > 0 )
       
   319         {
       
   320         CleanupStack::Pop( buffer );
       
   321         }
       
   322     else
       
   323         {
       
   324         CleanupStack::PopAndDestroy( buffer );
       
   325         buffer = KNullDesC().AllocL();
       
   326         }
       
   327 
       
   328     OstTraceFunctionExit0( RCMMANAGER_GETCONNECTIONMETHODINFOSTRINGL_EXIT );
       
   329     return buffer;
       
   330     }
       
   331 
       
   332 //-----------------------------------------------------------------------------
       
   333 //  RCmManager::GetConnectionMethodInfoString8L()
       
   334 //-----------------------------------------------------------------------------
       
   335 //
       
   336 EXPORT_C HBufC8* RCmManager::GetConnectionMethodInfoString8L(
       
   337         TUint32 aIapId,
       
   338         TUint32 aAttribute ) const
       
   339     {
       
   340     OstTraceFunctionEntry0( RCMMANAGER_GETCONNECTIONMETHODINFOSTRING8L_ENTRY );
       
   341 
       
   342     if ( !iCmManagerApi )
       
   343         {
       
   344         User::Leave( KErrBadHandle );
       
   345         }
       
   346 
       
   347     HBufC8* buffer8 = HBufC8::NewLC( KCmmStringLengthMax );
       
   348     TInt err = iCmManagerApi->GetConnectionMethodInfoString8( aIapId, aAttribute, buffer8 );
       
   349     User::LeaveIfError( err );
       
   350 
       
   351     if ( buffer8->Length() > 0 )
       
   352         {
       
   353         CleanupStack::Pop( buffer8 );
       
   354         }
       
   355     else
       
   356         {
       
   357         CleanupStack::PopAndDestroy( buffer8 );
       
   358         buffer8 = KNullDesC8().AllocL();
       
   359         }
       
   360 
       
   361     OstTraceFunctionExit0( RCMMANAGER_GETCONNECTIONMETHODINFOSTRING8L_EXIT );
       
   362     return buffer8;
       
   363     }
       
   364 
       
   365 //-----------------------------------------------------------------------------
       
   366 //  RCmManager::CreateDestinationL()
       
   367 //-----------------------------------------------------------------------------
       
   368 //
       
   369 EXPORT_C RCmDestination RCmManager::CreateDestinationL(
       
   370         const TDesC& aName )
       
   371     {
       
   372     OstTraceFunctionEntry0( RCMMANAGER_CREATEDESTINATIONL_ENTRY );
       
   373 
       
   374     if ( !iCmManagerApi )
       
   375         {
       
   376         User::Leave( KErrBadHandle );
       
   377         }
       
   378 
       
   379     if ( aName.Length() == 0 )
       
   380         {
       
   381         User::Leave( KErrArgument );
       
   382         }
       
   383 
       
   384     CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC();
       
   385     destWrap->CreateDestByNameL( iCmManagerApi, aName );
       
   386     CleanupStack::Pop( destWrap );
       
   387 
       
   388     RCmDestination dest;
       
   389     dest.iCmDestinationWrapper = destWrap;
       
   390 
       
   391     OstTraceFunctionExit0( RCMMANAGER_CREATEDESTINATIONL_EXIT );
       
   392     return dest;
       
   393     }
       
   394 
       
   395 //-----------------------------------------------------------------------------
       
   396 //  RCmManager::CreateConnectionMethodL()
       
   397 //-----------------------------------------------------------------------------
       
   398 //
       
   399 EXPORT_C RCmConnectionMethod RCmManager::CreateConnectionMethodL(
       
   400         TUint32 aBearerType )
       
   401     {
       
   402     OstTraceFunctionEntry0( RCMMANAGER_CREATECONNECTIONMETHODL_ENTRY );
       
   403 
       
   404     if ( !iCmManagerApi )
       
   405         {
       
   406         User::Leave( KErrBadHandle );
       
   407         }
       
   408 
       
   409     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   410     cmWrapper->CreateConnMethodL( iCmManagerApi, aBearerType );
       
   411     CleanupStack::Pop( cmWrapper );
       
   412 
       
   413     RCmConnectionMethod cm;
       
   414     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   415 
       
   416     OstTraceFunctionExit0( RCMMANAGER_CREATECONNECTIONMETHODL_EXIT );
       
   417     return cm;
       
   418     }
       
   419 
       
   420 //-----------------------------------------------------------------------------
       
   421 //  RCmManager::CopyConnectionMethodL()
       
   422 //-----------------------------------------------------------------------------
       
   423 //
       
   424 EXPORT_C TInt RCmManager::CopyConnectionMethodL(
       
   425         RCmDestination& aTargetDestination,
       
   426         RCmConnectionMethod& aConnectionMethod )
       
   427     {
       
   428     OstTraceFunctionEntry0( RCMMANAGER_COPYCONNECTIONMETHODL_ENTRY );
       
   429 
       
   430     if ( !iCmManagerApi )
       
   431         {
       
   432         User::Leave( KErrBadHandle );
       
   433         }
       
   434 
       
   435     if ( !aTargetDestination.iCmDestinationWrapper ||
       
   436             !aConnectionMethod.iCmConnectionMethodWrapper )
       
   437         {
       
   438         User::Leave( KErrArgument );
       
   439         }
       
   440     if ( !aTargetDestination.iCmDestinationWrapper->SessionConnected() ||
       
   441             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   442         {
       
   443         User::Leave( KErrArgument );
       
   444         }
       
   445 
       
   446     TInt index( 0 );
       
   447     TInt targetDestHandle = aTargetDestination.iCmDestinationWrapper->GetHandle();
       
   448     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   449     TInt err = iCmManagerApi->CopyConnectionMethod( targetDestHandle, connMethodHandle, index );
       
   450     User::LeaveIfError( err );
       
   451 
       
   452     OstTraceFunctionExit0( RCMMANAGER_COPYCONNECTIONMETHODL_EXIT );
       
   453     return index;
       
   454     }
       
   455 
       
   456 //-----------------------------------------------------------------------------
       
   457 //  RCmManager::MoveConnectionMethodL()
       
   458 //-----------------------------------------------------------------------------
       
   459 //
       
   460 EXPORT_C TInt RCmManager::MoveConnectionMethodL(
       
   461         RCmDestination& aSourceDestination,
       
   462         RCmDestination& aTargetDestination,
       
   463         RCmConnectionMethod& aConnectionMethod )
       
   464     {
       
   465     OstTraceFunctionEntry0( RCMMANAGER_MOVECONNECTIONMETHODL_ENTRY );
       
   466 
       
   467     if ( !iCmManagerApi )
       
   468         {
       
   469         User::Leave( KErrBadHandle );
       
   470         }
       
   471 
       
   472     if ( !aSourceDestination.iCmDestinationWrapper ||
       
   473             !aTargetDestination.iCmDestinationWrapper ||
       
   474             !aConnectionMethod.iCmConnectionMethodWrapper )
       
   475         {
       
   476         User::Leave( KErrArgument );
       
   477         }
       
   478     if ( !aSourceDestination.iCmDestinationWrapper->SessionConnected() ||
       
   479             !aTargetDestination.iCmDestinationWrapper->SessionConnected() ||
       
   480             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   481         {
       
   482         User::Leave( KErrArgument );
       
   483         }
       
   484 
       
   485     TCmmIpcStructMoveConnMethod pkgData;
       
   486     pkgData.iSourceDestHandle = aSourceDestination.iCmDestinationWrapper->GetHandle();
       
   487     pkgData.iTargetDestHandle = aTargetDestination.iCmDestinationWrapper->GetHandle();
       
   488     pkgData.iConnMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   489     pkgData.iIndex = 0;
       
   490 
       
   491     TInt err = iCmManagerApi->MoveConnectionMethod( pkgData );
       
   492     User::LeaveIfError( err );
       
   493 
       
   494     OstTraceFunctionExit0( RCMMANAGER_MOVECONNECTIONMETHODL_EXIT );
       
   495     return pkgData.iIndex;
       
   496     }
       
   497 
       
   498 //-----------------------------------------------------------------------------
       
   499 //  RCmManager::RemoveConnectionMethodL()
       
   500 //-----------------------------------------------------------------------------
       
   501 //
       
   502 EXPORT_C void RCmManager::RemoveConnectionMethodL(
       
   503         RCmDestination& aDestination,
       
   504         RCmConnectionMethod& aConnectionMethod )
       
   505     {
       
   506     OstTraceFunctionEntry0( RCMMANAGER_REMOVECONNECTIONMETHODL_ENTRY );
       
   507 
       
   508     if ( !iCmManagerApi )
       
   509         {
       
   510         User::Leave( KErrBadHandle );
       
   511         }
       
   512 
       
   513     if ( !aDestination.iCmDestinationWrapper ||
       
   514             !aConnectionMethod.iCmConnectionMethodWrapper )
       
   515         {
       
   516         User::Leave( KErrArgument );
       
   517         }
       
   518     if ( !aDestination.iCmDestinationWrapper->SessionConnected() ||
       
   519             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   520         {
       
   521         User::Leave( KErrArgument );
       
   522         }
       
   523 
       
   524     TInt targetDestHandle = aDestination.iCmDestinationWrapper->GetHandle();
       
   525     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   526     TInt err = iCmManagerApi->RemoveConnectionMethod( targetDestHandle, connMethodHandle );
       
   527     User::LeaveIfError( err );
       
   528 
       
   529     OstTraceFunctionExit0( RCMMANAGER_REMOVECONNECTIONMETHODL_EXIT );
       
   530     }
       
   531 
       
   532 //-----------------------------------------------------------------------------
       
   533 //  RCmManager::RemoveAllReferencesL()
       
   534 //-----------------------------------------------------------------------------
       
   535 //
       
   536 EXPORT_C void RCmManager::RemoveAllReferencesL(
       
   537         RCmConnectionMethod& aConnectionMethod )
       
   538     {
       
   539     OstTraceFunctionEntry0( RCMMANAGER_REMOVEALLREFERENCESL_ENTRY );
       
   540 
       
   541     if ( !iCmManagerApi )
       
   542         {
       
   543         User::Leave( KErrBadHandle );
       
   544         }
       
   545 
       
   546     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   547             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   548         {
       
   549         User::Leave( KErrArgument );
       
   550         }
       
   551 
       
   552     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   553     TInt err = iCmManagerApi->RemoveAllReferences( connMethodHandle );
       
   554     User::LeaveIfError( err );
       
   555 
       
   556     OstTraceFunctionExit0( RCMMANAGER_REMOVEALLREFERENCESL_EXIT );
       
   557     }
       
   558 
       
   559 //-----------------------------------------------------------------------------
       
   560 //  RCmManager::ConnectionMethodL()
       
   561 //-----------------------------------------------------------------------------
       
   562 //
       
   563 EXPORT_C void RCmManager::ConnectionMethodL(
       
   564         RArray<TUint32>& aCmArray,
       
   565         TBool aCheckBearerType,
       
   566         TBool aLegacyOnly,
       
   567         TBool aEasyWlan ) const
       
   568     {
       
   569     OstTraceFunctionEntry0( DUP1_RCMMANAGER_CONNECTIONMETHODL_ENTRY );
       
   570 
       
   571     if ( !iCmManagerApi )
       
   572         {
       
   573         User::Leave( KErrBadHandle );
       
   574         }
       
   575 
       
   576     TCmmIpcStructGetConnMethods parameters;
       
   577     parameters.iCheckBearerType = aCheckBearerType;
       
   578     parameters.iLegacyOnly = aLegacyOnly;
       
   579     parameters.iEasyWlan = aEasyWlan;
       
   580 
       
   581     iCmManagerApi->GetConnMethodsL( parameters, aCmArray );
       
   582 
       
   583     OstTraceFunctionExit0( RCMMANAGER_CONNECTIONMETHODL_EXIT );
       
   584     }
       
   585 
       
   586 //-----------------------------------------------------------------------------
       
   587 //  RCmManager::AllDestinationsL()
       
   588 //-----------------------------------------------------------------------------
       
   589 //
       
   590 EXPORT_C void RCmManager::AllDestinationsL( RArray<TUint32>& aDestArray ) const
       
   591     {
       
   592     OstTraceFunctionEntry0( RCMMANAGER_ALLDESTINATIONSL_ENTRY );
       
   593 
       
   594     if ( !iCmManagerApi )
       
   595         {
       
   596         User::Leave( KErrBadHandle );
       
   597         }
       
   598 
       
   599     iCmManagerApi->GetAllDestinationsL( aDestArray );
       
   600 
       
   601     OstTraceFunctionExit0( RCMMANAGER_ALLDESTINATIONSL_EXIT );
       
   602     }
       
   603 
       
   604 //-----------------------------------------------------------------------------
       
   605 //  RCmManager::DestinationL()
       
   606 //-----------------------------------------------------------------------------
       
   607 //
       
   608 EXPORT_C RCmDestination RCmManager::DestinationL( TUint32 aDestinationId ) const
       
   609     {
       
   610     OstTraceFunctionEntry0( RCMMANAGER_DESTINATIONL_ENTRY );
       
   611 
       
   612     if ( !iCmManagerApi )
       
   613         {
       
   614         User::Leave( KErrBadHandle );
       
   615         }
       
   616 
       
   617     // If client already has a handle open to this destination, give a
       
   618     // reference to it.
       
   619     CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC();
       
   620     TInt existingHandle( 0 );
       
   621     destWrap->GetDestWithIdL( iCmManagerApi, aDestinationId, existingHandle );
       
   622     if ( existingHandle )
       
   623         {
       
   624         CleanupStack::PopAndDestroy( destWrap );
       
   625         destWrap = iCmManagerApi->GetDestinationWrapperL( existingHandle );
       
   626         destWrap->IncreaseReferenceCounter();
       
   627         }
       
   628     else
       
   629         {
       
   630         CleanupStack::Pop( destWrap );
       
   631         }
       
   632 
       
   633     RCmDestination dest;
       
   634     dest.iCmDestinationWrapper = destWrap;
       
   635 
       
   636     return dest;
       
   637     }
       
   638 
       
   639 //-----------------------------------------------------------------------------
       
   640 //  RCmManager::BearerPriorityArrayL()
       
   641 //-----------------------------------------------------------------------------
       
   642 //
       
   643 EXPORT_C void RCmManager::BearerPriorityArrayL(
       
   644         RArray<TBearerPriority>& aArray ) const
       
   645     {
       
   646     OstTraceFunctionEntry0( RCMMANAGER_BEARERPRIORITYARRAYL_ENTRY );
       
   647 
       
   648     if ( !iCmManagerApi )
       
   649         {
       
   650         User::Leave( KErrBadHandle );
       
   651         }
       
   652 
       
   653     iCmManagerApi->GetBearerPriorityArrayL( aArray );
       
   654 
       
   655     OstTraceFunctionExit0( RCMMANAGER_BEARERPRIORITYARRAYL_EXIT );
       
   656     }
       
   657 
       
   658 //-----------------------------------------------------------------------------
       
   659 //  RCmManager::UpdateBearerPriorityArrayL()
       
   660 //-----------------------------------------------------------------------------
       
   661 //
       
   662 EXPORT_C void RCmManager::UpdateBearerPriorityArrayL(
       
   663         const RArray<TBearerPriority>& aArray )
       
   664     {
       
   665     OstTraceFunctionEntry0( RCMMANAGER_UPDATEBEARERPRIORITYARRAYL_ENTRY );
       
   666 
       
   667     if ( !iCmManagerApi )
       
   668         {
       
   669         User::Leave( KErrBadHandle );
       
   670         }
       
   671 
       
   672     iCmManagerApi->SetBearerPriorityArrayL( aArray );
       
   673 
       
   674     OstTraceFunctionExit0( RCMMANAGER_UPDATEBEARERPRIORITYARRAYL_EXIT );
       
   675     }
       
   676 
       
   677 //-----------------------------------------------------------------------------
       
   678 //  RCmManager::CleanupGlobalPriorityArray()
       
   679 //-----------------------------------------------------------------------------
       
   680 //
       
   681 EXPORT_C void RCmManager::CleanupGlobalPriorityArray(
       
   682         RArray<TBearerPriority>& aArray ) const
       
   683     {
       
   684     OstTraceFunctionEntry0( RCMMANAGER_CLEANUPGLOBALPRIORITYARRAY_ENTRY );
       
   685 
       
   686     for ( TInt i = 0; i < aArray.Count(); i++ )
       
   687         {
       
   688         delete aArray[i].iServiceType;
       
   689         }
       
   690     aArray.Reset();
       
   691     aArray.Close();
       
   692 
       
   693     OstTraceFunctionExit0( RCMMANAGER_CLEANUPGLOBALPRIORITYARRAY_EXIT );
       
   694     }
       
   695 
       
   696 //-----------------------------------------------------------------------------
       
   697 //  RCmManager::SupportedBearersL()
       
   698 //-----------------------------------------------------------------------------
       
   699 //
       
   700 EXPORT_C void RCmManager::SupportedBearersL( RArray<TUint32>& aArray ) const
       
   701     {
       
   702     OstTraceFunctionEntry0( RCMMANAGER_SUPPORTEDBEARERSL_ENTRY );
       
   703 
       
   704     if ( !iCmManagerApi )
       
   705         {
       
   706         User::Leave( KErrBadHandle );
       
   707         }
       
   708     iCmManagerApi->GetSupportedBearersL( aArray );
       
   709 
       
   710     OstTraceFunctionExit0( RCMMANAGER_SUPPORTEDBEARERSL_EXIT );
       
   711     }
       
   712 
       
   713 //-----------------------------------------------------------------------------
       
   714 //  RCmManager::EasyWlanIdL()
       
   715 //-----------------------------------------------------------------------------
       
   716 //
       
   717 EXPORT_C TUint32 RCmManager::EasyWlanIdL() const
       
   718     {
       
   719     OstTraceFunctionEntry0( RCMMANAGER_EASYWLANIDL_ENTRY );
       
   720 
       
   721     if ( !iCmManagerApi )
       
   722         {
       
   723         User::Leave( KErrBadHandle );
       
   724         }
       
   725 
       
   726     TUint32 value( 0 );
       
   727     TInt err = iCmManagerApi->GetEasyWlanId( value );
       
   728     User::LeaveIfError( err );
       
   729 
       
   730     OstTraceFunctionExit0( RCMMANAGER_EASYWLANIDL_EXIT );
       
   731     return value;
       
   732     }
       
   733 
       
   734 //-----------------------------------------------------------------------------
       
   735 //  RCmManager::ReadDefConnL()
       
   736 //-----------------------------------------------------------------------------
       
   737 //
       
   738 EXPORT_C void RCmManager::ReadDefConnL(
       
   739         TCmDefConnValue& aDefConnSetting )
       
   740     {
       
   741     OstTraceFunctionEntry0( RCMMANAGER_READDEFCONNL_ENTRY );
       
   742 
       
   743     if ( !iCmManagerApi )
       
   744         {
       
   745         User::Leave( KErrBadHandle );
       
   746         }
       
   747 
       
   748     TInt err = iCmManagerApi->ReadDefaultConnection( aDefConnSetting );
       
   749     User::LeaveIfError( err );
       
   750 
       
   751     OstTraceFunctionExit0( RCMMANAGER_READDEFCONNL_EXIT );
       
   752     }
       
   753 
       
   754 //-----------------------------------------------------------------------------
       
   755 //  RCmManager::WriteDefConnL()
       
   756 //-----------------------------------------------------------------------------
       
   757 //
       
   758 EXPORT_C void RCmManager::WriteDefConnL(
       
   759         const TCmDefConnValue& aDefConnSetting )
       
   760     {
       
   761     OstTraceFunctionEntry0( RCMMANAGER_WRITEDEFCONNL_ENTRY );
       
   762 
       
   763     if ( !iCmManagerApi )
       
   764         {
       
   765         User::Leave( KErrBadHandle );
       
   766         }
       
   767 
       
   768     TInt err = iCmManagerApi->WriteDefaultConnection( aDefConnSetting );
       
   769     User::LeaveIfError( err );
       
   770 
       
   771     OstTraceFunctionExit0( RCMMANAGER_WRITEDEFCONNL_EXIT );
       
   772     }
       
   773 
       
   774 //-----------------------------------------------------------------------------
       
   775 //  RCmManager::ReadGenConnSettingsL()
       
   776 //-----------------------------------------------------------------------------
       
   777 //
       
   778 EXPORT_C void RCmManager::ReadGenConnSettingsL(
       
   779         TCmGenConnSettings& aGenConnSettings )
       
   780     {
       
   781     OstTraceFunctionEntry0( RCMMANAGER_READGENCONNSETTINGSL_ENTRY );
       
   782 
       
   783     if ( !iCmManagerApi )
       
   784         {
       
   785         User::Leave( KErrBadHandle );
       
   786         }
       
   787 
       
   788     TInt err = iCmManagerApi->ReadGeneralConnectionSettings( aGenConnSettings );
       
   789     User::LeaveIfError( err );
       
   790 
       
   791     OstTraceFunctionExit0( RCMMANAGER_READGENCONNSETTINGSL_EXIT );
       
   792     }
       
   793 
       
   794 //-----------------------------------------------------------------------------
       
   795 //  RCmManager::WriteGenConnSettingsL()
       
   796 //-----------------------------------------------------------------------------
       
   797 //
       
   798 EXPORT_C void RCmManager::WriteGenConnSettingsL(
       
   799         const TCmGenConnSettings& aGenConnSettings )
       
   800     {
       
   801     OstTraceFunctionEntry0( RCMMANAGER_WRITEGENCONNSETTINGSL_ENTRY );
       
   802 
       
   803     if ( !iCmManagerApi )
       
   804         {
       
   805         User::Leave( KErrBadHandle );
       
   806         }
       
   807 
       
   808     TInt err = iCmManagerApi->WriteGeneralConnectionSettings( aGenConnSettings );
       
   809     User::LeaveIfError( err );
       
   810 
       
   811     OstTraceFunctionExit0( RCMMANAGER_WRITEGENCONNSETTINGSL_EXIT );
       
   812     }
       
   813 
       
   814 //-----------------------------------------------------------------------------
       
   815 //  RCmManager::CreateDestinationL()
       
   816 //-----------------------------------------------------------------------------
       
   817 //
       
   818 EXPORT_C RCmDestination RCmManager::CreateDestinationL(
       
   819         const TDesC& aName,
       
   820         TUint32 aDestId )
       
   821     {
       
   822     OstTraceFunctionEntry0( DUP1_RCMMANAGER_CREATEDESTINATIONL_ENTRY );
       
   823 
       
   824     if ( aDestId == 0 )
       
   825         {
       
   826         return CreateDestinationL( aName );
       
   827         }
       
   828 
       
   829     if ( !iCmManagerApi )
       
   830         {
       
   831         User::Leave( KErrBadHandle );
       
   832         }
       
   833 
       
   834     if ( aName.Length() == 0 )
       
   835         {
       
   836         User::Leave( KErrArgument );
       
   837         }
       
   838 
       
   839     TUint32 adjustedDestId( 0 );
       
   840     if ( aDestId > KCmmDestIdIntervalLegacyMin && aDestId < KCmmDestIdIntervalLegacyMax )
       
   841         {
       
   842         adjustedDestId = aDestId + KCmDefaultDestinationAPTagId;
       
   843         }
       
   844     else if ( aDestId > KCmmDestIdIntervalMin && aDestId < KCmmDestIdIntervalMax )
       
   845         {
       
   846         adjustedDestId = aDestId;
       
   847         }
       
   848     else
       
   849         {
       
   850         User::Leave( KErrArgument );
       
   851         }
       
   852 
       
   853     CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC();
       
   854     destWrap->CreateDestByNameAndIdL( iCmManagerApi, aName, adjustedDestId );
       
   855     CleanupStack::Pop( destWrap );
       
   856 
       
   857     RCmDestination dest;
       
   858     dest.iCmDestinationWrapper = destWrap;
       
   859 
       
   860     OstTraceFunctionExit0( DUP1_RCMMANAGER_CREATEDESTINATIONL_EXIT );
       
   861     return dest;
       
   862     }
       
   863 
       
   864 //-----------------------------------------------------------------------------
       
   865 //  RCmManager::CreateConnectionMethodL()
       
   866 //-----------------------------------------------------------------------------
       
   867 //
       
   868 EXPORT_C RCmConnectionMethod RCmManager::CreateConnectionMethodL(
       
   869         TUint32 aBearerType,
       
   870         TUint32 aConnMethodId )
       
   871     {
       
   872     OstTraceFunctionEntry0( DUP1_RCMMANAGER_CREATECONNECTIONMETHODL_ENTRY );
       
   873 
       
   874     if ( aConnMethodId == 0 )
       
   875         {
       
   876         return CreateConnectionMethodL( aBearerType );
       
   877         }
       
   878 
       
   879     if ( !iCmManagerApi )
       
   880         {
       
   881         User::Leave( KErrBadHandle );
       
   882         }
       
   883     if ( !( aConnMethodId > KCmmConnMethodIdIntervalMin &&
       
   884             aConnMethodId < KCmmConnMethodIdIntervalMax ) )
       
   885         {
       
   886         User::Leave( KErrArgument );
       
   887         }
       
   888 
       
   889     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   890     cmWrapper->CreateConnMethodWithIdL( iCmManagerApi, aBearerType, aConnMethodId );
       
   891     CleanupStack::Pop( cmWrapper );
       
   892 
       
   893     RCmConnectionMethod cm;
       
   894     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   895 
       
   896     OstTraceFunctionExit0( DUP1_RCMMANAGER_CREATECONNECTIONMETHODL_EXIT );
       
   897     return cm;
       
   898     }
       
   899 
       
   900 //-----------------------------------------------------------------------------
       
   901 //  RCmManager::GetUncategorizedIconL()
       
   902 //-----------------------------------------------------------------------------
       
   903 //
       
   904 EXPORT_C HBufC* RCmManager::GetUncategorizedIconL() const
       
   905     {
       
   906     OstTraceFunctionEntry0( RCMMANAGER_GETUNCATEGORIZEDICONL_ENTRY );
       
   907 
       
   908     if ( !iCmManagerApi )
       
   909         {
       
   910         User::Leave( KErrBadHandle );
       
   911         }
       
   912 
       
   913     HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
       
   914     TInt err = iCmManagerApi->GetUncategorizedIcon( buffer );
       
   915     User::LeaveIfError( err );
       
   916 
       
   917     if ( buffer->Length() > 0 )
       
   918         {
       
   919         CleanupStack::Pop( buffer );
       
   920         }
       
   921     else
       
   922         {
       
   923         CleanupStack::PopAndDestroy( buffer );
       
   924         buffer = KNullDesC().AllocL();
       
   925         }
       
   926 
       
   927     OstTraceFunctionExit0( RCMMANAGER_GETUNCATEGORIZEDICONL_EXIT );
       
   928     return buffer;
       
   929     }
       
   930 
       
   931 // End of file