cmmanager/cmmgr/cmmapi/src/cmmanagerext.cpp
changeset 20 9c97ad6591ae
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     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 RCmManagerExt.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <cmmanagerext.h>
       
    21 #include <cmconnectionmethodext.h>
       
    22 #include <cmdestinationext.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 "cmmanagerextTraces.h"
       
    32 #endif
       
    33 
       
    34 
       
    35 //-----------------------------------------------------------------------------
       
    36 //  RCmManagerExt::OpenL()
       
    37 //-----------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C void RCmManagerExt::OpenL()
       
    40     {
       
    41     OstTraceFunctionEntry0( RCMMANAGEREXT_OPENL_ENTRY );
       
    42 
       
    43     OpenLC();
       
    44     CleanupStack::Pop( this );
       
    45 
       
    46     OstTraceFunctionExit0( RCMMANAGEREXT_OPENL_EXIT );
       
    47     }
       
    48 
       
    49 //-----------------------------------------------------------------------------
       
    50 //  RCmManagerExt::OpenLC()
       
    51 //-----------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C void RCmManagerExt::OpenLC()
       
    54     {
       
    55     OstTraceFunctionEntry0( RCMMANAGEREXT_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( RCMMANAGEREXT_OPENLC_EXIT );
       
    67     }
       
    68 
       
    69 //-----------------------------------------------------------------------------
       
    70 //  RCmManagerExt::Close()
       
    71 //-----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C void RCmManagerExt::Close()
       
    74     {
       
    75     OstTraceFunctionEntry0( RCMMANAGEREXT_CLOSE_ENTRY );
       
    76 
       
    77     if ( iCmManagerApi )
       
    78         {
       
    79         iCmManagerApi->Close();
       
    80         delete iCmManagerApi;
       
    81         iCmManagerApi = NULL;
       
    82         }
       
    83 
       
    84     OstTraceFunctionExit0( RCMMANAGEREXT_CLOSE_EXIT );
       
    85     }
       
    86 
       
    87 //-----------------------------------------------------------------------------
       
    88 //  RCmManagerExt::CreateTablesAndOpenL()
       
    89 //-----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void RCmManagerExt::CreateTablesAndOpenL()
       
    92     {
       
    93     OstTraceFunctionEntry0( RCMMANAGEREXT_CREATETABLESANDOPENL_ENTRY );
       
    94     OpenL();
       
    95     OstTraceFunctionExit0( RCMMANAGEREXT_CREATETABLESANDOPENL_EXIT );
       
    96     }
       
    97 
       
    98 //-----------------------------------------------------------------------------
       
    99 //  RCmManagerExt::ConnectionMethodL()
       
   100 //-----------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C RCmConnectionMethodExt RCmManagerExt::ConnectionMethodL(
       
   103         TUint32 aConnectionMethodId )
       
   104     {
       
   105     OstTraceFunctionEntry0( RCMMANAGEREXT_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     RCmConnectionMethodExt cm;
       
   135     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   136 
       
   137     OstTraceFunctionExit0( RCMMANAGEREXT_CONNECTIONMETHODL_EXIT );
       
   138     return cm;
       
   139     }
       
   140 
       
   141 //-----------------------------------------------------------------------------
       
   142 //  RCmManagerExt::GetBearerInfoIntL()
       
   143 //-----------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C TUint32 RCmManagerExt::GetBearerInfoIntL(
       
   146         TUint32 aBearerType,
       
   147         TUint32 aAttribute ) const
       
   148     {
       
   149     OstTraceFunctionEntry0( RCMMANAGEREXT_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( RCMMANAGEREXT_GETBEARERINFOINTL_EXIT );
       
   161     return value;
       
   162     }
       
   163 
       
   164 //-----------------------------------------------------------------------------
       
   165 //  RCmManagerExt::GetBearerInfoBoolL()
       
   166 //-----------------------------------------------------------------------------
       
   167 //
       
   168 EXPORT_C TBool RCmManagerExt::GetBearerInfoBoolL(
       
   169         TUint32 aBearerType,
       
   170         TUint32 aAttribute ) const
       
   171     {
       
   172     OstTraceFunctionEntry0( RCMMANAGEREXT_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( RCMMANAGEREXT_GETBEARERINFOBOOLL_EXIT );
       
   184     return value;
       
   185     }
       
   186 
       
   187 //-----------------------------------------------------------------------------
       
   188 //  RCmManagerExt::GetBearerInfoStringL()
       
   189 //-----------------------------------------------------------------------------
       
   190 //
       
   191 EXPORT_C HBufC* RCmManagerExt::GetBearerInfoStringL(
       
   192         TUint32 aBearerType,
       
   193         TUint32 aAttribute ) const
       
   194     {
       
   195     OstTraceFunctionEntry0( RCMMANAGEREXT_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 = NULL;
       
   214         buffer = KNullDesC().AllocL();
       
   215         }
       
   216 
       
   217     OstTraceFunctionExit0( RCMMANAGEREXT_GETBEARERINFOSTRINGL_EXIT );
       
   218     return buffer;
       
   219     }
       
   220 
       
   221 //-----------------------------------------------------------------------------
       
   222 //  RCmManagerExt::GetBearerInfoString8L()
       
   223 //-----------------------------------------------------------------------------
       
   224 //
       
   225 EXPORT_C HBufC8* RCmManagerExt::GetBearerInfoString8L(
       
   226         TUint32 aBearerType,
       
   227         TUint32 aAttribute ) const
       
   228     {
       
   229     OstTraceFunctionEntry0( RCMMANAGEREXT_GETBEARERINFOSTRING8L_ENTRY );
       
   230 
       
   231     if ( !iCmManagerApi )
       
   232         {
       
   233         User::Leave( KErrBadHandle );
       
   234         }
       
   235 
       
   236     HBufC8* buffer8 = HBufC8::NewLC( KCmmStringLengthMax );
       
   237     TInt err = iCmManagerApi->GetBearerInfoString8( aBearerType, aAttribute, buffer8 );
       
   238     User::LeaveIfError( err );
       
   239 
       
   240     if ( buffer8->Length() > 0 )
       
   241         {
       
   242         CleanupStack::Pop( buffer8 );
       
   243         }
       
   244     else
       
   245         {
       
   246         CleanupStack::PopAndDestroy( buffer8 );
       
   247         buffer8 = NULL;
       
   248         buffer8 = KNullDesC8().AllocL();
       
   249         }
       
   250 
       
   251     OstTraceFunctionExit0( RCMMANAGEREXT_GETBEARERINFOSTRING8L_EXIT );
       
   252     return buffer8;
       
   253     }
       
   254 
       
   255 //-----------------------------------------------------------------------------
       
   256 //  RCmManagerExt::GetConnectionMethodInfoIntL()
       
   257 //-----------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C TUint32 RCmManagerExt::GetConnectionMethodInfoIntL(
       
   260         TUint32 aIapId,
       
   261         TUint32 aAttribute ) const
       
   262     {
       
   263     OstTraceFunctionEntry0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOINTL_ENTRY );
       
   264 
       
   265     if ( !iCmManagerApi )
       
   266         {
       
   267         User::Leave( KErrBadHandle );
       
   268         }
       
   269 
       
   270     TUint32 value( 0 );
       
   271     TInt err = iCmManagerApi->GetConnectionMethodInfoInt( aIapId, aAttribute, value );
       
   272     User::LeaveIfError( err );
       
   273 
       
   274     OstTraceFunctionExit0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOINTL_EXIT );
       
   275     return value;
       
   276     }
       
   277 
       
   278 //-----------------------------------------------------------------------------
       
   279 //  RCmManagerExt::GetConnectionMethodInfoBoolL()
       
   280 //-----------------------------------------------------------------------------
       
   281 //
       
   282 EXPORT_C TBool RCmManagerExt::GetConnectionMethodInfoBoolL(
       
   283         TUint32 aIapId,
       
   284         TUint32 aAttribute ) const
       
   285     {
       
   286     OstTraceFunctionEntry0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOBOOLL_ENTRY );
       
   287 
       
   288     if ( !iCmManagerApi )
       
   289         {
       
   290         User::Leave( KErrBadHandle );
       
   291         }
       
   292 
       
   293     TBool value( 0 );
       
   294     TInt err = iCmManagerApi->GetConnectionMethodInfoBool( aIapId, aAttribute, value );
       
   295     User::LeaveIfError( err );
       
   296 
       
   297     OstTraceFunctionExit0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOBOOLL_EXIT );
       
   298     return value;
       
   299     }
       
   300 
       
   301 //-----------------------------------------------------------------------------
       
   302 //  RCmManagerExt::GetConnectionMethodInfoStringL()
       
   303 //-----------------------------------------------------------------------------
       
   304 //
       
   305 EXPORT_C HBufC* RCmManagerExt::GetConnectionMethodInfoStringL(
       
   306         TUint32 aIapId,
       
   307         TUint32 aAttribute ) const
       
   308     {
       
   309     OstTraceFunctionEntry0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOSTRINGL_ENTRY );
       
   310 
       
   311     if ( !iCmManagerApi )
       
   312         {
       
   313         User::Leave( KErrBadHandle );
       
   314         }
       
   315 
       
   316     HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
       
   317     TInt err = iCmManagerApi->GetConnectionMethodInfoString( aIapId, aAttribute, buffer );
       
   318     User::LeaveIfError( err );
       
   319 
       
   320     if ( buffer->Length() > 0 )
       
   321         {
       
   322         CleanupStack::Pop( buffer );
       
   323         }
       
   324     else
       
   325         {
       
   326         CleanupStack::PopAndDestroy( buffer );
       
   327         buffer = NULL;
       
   328         buffer = KNullDesC().AllocL();
       
   329         }
       
   330 
       
   331     OstTraceFunctionExit0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOSTRINGL_EXIT );
       
   332     return buffer;
       
   333     }
       
   334 
       
   335 //-----------------------------------------------------------------------------
       
   336 //  RCmManagerExt::GetConnectionMethodInfoString8L()
       
   337 //-----------------------------------------------------------------------------
       
   338 //
       
   339 EXPORT_C HBufC8* RCmManagerExt::GetConnectionMethodInfoString8L(
       
   340         TUint32 aIapId,
       
   341         TUint32 aAttribute ) const
       
   342     {
       
   343     OstTraceFunctionEntry0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOSTRING8L_ENTRY );
       
   344 
       
   345     if ( !iCmManagerApi )
       
   346         {
       
   347         User::Leave( KErrBadHandle );
       
   348         }
       
   349 
       
   350     HBufC8* buffer8 = HBufC8::NewLC( KCmmStringLengthMax );
       
   351     TInt err = iCmManagerApi->GetConnectionMethodInfoString8( aIapId, aAttribute, buffer8 );
       
   352     User::LeaveIfError( err );
       
   353 
       
   354     if ( buffer8->Length() > 0 )
       
   355         {
       
   356         CleanupStack::Pop( buffer8 );
       
   357         }
       
   358     else
       
   359         {
       
   360         CleanupStack::PopAndDestroy( buffer8 );
       
   361         buffer8 = NULL;
       
   362         buffer8 = KNullDesC8().AllocL();
       
   363         }
       
   364 
       
   365     OstTraceFunctionExit0( RCMMANAGEREXT_GETCONNECTIONMETHODINFOSTRING8L_EXIT );
       
   366     return buffer8;
       
   367     }
       
   368 
       
   369 //-----------------------------------------------------------------------------
       
   370 //  RCmManagerExt::CreateDestinationL()
       
   371 //-----------------------------------------------------------------------------
       
   372 //
       
   373 EXPORT_C RCmDestinationExt RCmManagerExt::CreateDestinationL(
       
   374         const TDesC& aName )
       
   375     {
       
   376     OstTraceFunctionEntry0( RCMMANAGEREXT_CREATEDESTINATIONL_ENTRY );
       
   377 
       
   378     if ( !iCmManagerApi )
       
   379         {
       
   380         User::Leave( KErrBadHandle );
       
   381         }
       
   382 
       
   383     if ( aName.Length() == 0 )
       
   384         {
       
   385         User::Leave( KErrArgument );
       
   386         }
       
   387 
       
   388     CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC();
       
   389     destWrap->CreateDestByNameL( iCmManagerApi, aName );
       
   390     CleanupStack::Pop( destWrap );
       
   391 
       
   392     RCmDestinationExt dest;
       
   393     dest.iCmDestinationWrapper = destWrap;
       
   394 
       
   395     OstTraceFunctionExit0( RCMMANAGEREXT_CREATEDESTINATIONL_EXIT );
       
   396     return dest;
       
   397     }
       
   398 
       
   399 //-----------------------------------------------------------------------------
       
   400 //  RCmManagerExt::CreateConnectionMethodL()
       
   401 //-----------------------------------------------------------------------------
       
   402 //
       
   403 EXPORT_C RCmConnectionMethodExt RCmManagerExt::CreateConnectionMethodL(
       
   404         TUint32 aBearerType )
       
   405     {
       
   406     OstTraceFunctionEntry0( RCMMANAGEREXT_CREATECONNECTIONMETHODL_ENTRY );
       
   407 
       
   408     if ( !iCmManagerApi )
       
   409         {
       
   410         User::Leave( KErrBadHandle );
       
   411         }
       
   412 
       
   413     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   414     cmWrapper->CreateConnMethodL( iCmManagerApi, aBearerType );
       
   415     CleanupStack::Pop( cmWrapper );
       
   416 
       
   417     RCmConnectionMethodExt cm;
       
   418     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   419 
       
   420     OstTraceFunctionExit0( RCMMANAGEREXT_CREATECONNECTIONMETHODL_EXIT );
       
   421     return cm;
       
   422     }
       
   423 
       
   424 //-----------------------------------------------------------------------------
       
   425 //  RCmManagerExt::CopyConnectionMethodL()
       
   426 //-----------------------------------------------------------------------------
       
   427 //
       
   428 EXPORT_C TInt RCmManagerExt::CopyConnectionMethodL(
       
   429         RCmDestinationExt& aTargetDestination,
       
   430         RCmConnectionMethodExt& aConnectionMethod )
       
   431     {
       
   432     OstTraceFunctionEntry0( RCMMANAGEREXT_COPYCONNECTIONMETHODL_ENTRY );
       
   433 
       
   434     if ( !iCmManagerApi )
       
   435         {
       
   436         User::Leave( KErrBadHandle );
       
   437         }
       
   438 
       
   439     if ( !aTargetDestination.iCmDestinationWrapper ||
       
   440             !aConnectionMethod.iCmConnectionMethodWrapper )
       
   441         {
       
   442         User::Leave( KErrArgument );
       
   443         }
       
   444     if ( !aTargetDestination.iCmDestinationWrapper->SessionConnected() ||
       
   445             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   446         {
       
   447         User::Leave( KErrArgument );
       
   448         }
       
   449 
       
   450     TInt index( 0 );
       
   451     TInt targetDestHandle = aTargetDestination.iCmDestinationWrapper->GetHandle();
       
   452     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   453     TInt err = iCmManagerApi->CopyConnectionMethod( targetDestHandle, connMethodHandle, index );
       
   454     User::LeaveIfError( err );
       
   455 
       
   456     OstTraceFunctionExit0( RCMMANAGEREXT_COPYCONNECTIONMETHODL_EXIT );
       
   457     return index;
       
   458     }
       
   459 
       
   460 //-----------------------------------------------------------------------------
       
   461 //  RCmManagerExt::MoveConnectionMethodL()
       
   462 //-----------------------------------------------------------------------------
       
   463 //
       
   464 EXPORT_C TInt RCmManagerExt::MoveConnectionMethodL(
       
   465         RCmDestinationExt& aSourceDestination,
       
   466         RCmDestinationExt& aTargetDestination,
       
   467         RCmConnectionMethodExt& aConnectionMethod )
       
   468     {
       
   469     OstTraceFunctionEntry0( RCMMANAGEREXT_MOVECONNECTIONMETHODL_ENTRY );
       
   470 
       
   471     if ( !iCmManagerApi )
       
   472         {
       
   473         User::Leave( KErrBadHandle );
       
   474         }
       
   475 
       
   476     if ( !aSourceDestination.iCmDestinationWrapper ||
       
   477             !aTargetDestination.iCmDestinationWrapper ||
       
   478             !aConnectionMethod.iCmConnectionMethodWrapper )
       
   479         {
       
   480         User::Leave( KErrArgument );
       
   481         }
       
   482     if ( !aSourceDestination.iCmDestinationWrapper->SessionConnected() ||
       
   483             !aTargetDestination.iCmDestinationWrapper->SessionConnected() ||
       
   484             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   485         {
       
   486         User::Leave( KErrArgument );
       
   487         }
       
   488 
       
   489     TCmmIpcStructMoveConnMethod pkgData;
       
   490     pkgData.iSourceDestHandle = aSourceDestination.iCmDestinationWrapper->GetHandle();
       
   491     pkgData.iTargetDestHandle = aTargetDestination.iCmDestinationWrapper->GetHandle();
       
   492     pkgData.iConnMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   493     pkgData.iIndex = 0;
       
   494 
       
   495     TInt err = iCmManagerApi->MoveConnectionMethod( pkgData );
       
   496     User::LeaveIfError( err );
       
   497 
       
   498     OstTraceFunctionExit0( RCMMANAGEREXT_MOVECONNECTIONMETHODL_EXIT );
       
   499     return pkgData.iIndex;
       
   500     }
       
   501 
       
   502 //-----------------------------------------------------------------------------
       
   503 //  RCmManagerExt::RemoveConnectionMethodL()
       
   504 //-----------------------------------------------------------------------------
       
   505 //
       
   506 EXPORT_C void RCmManagerExt::RemoveConnectionMethodL(
       
   507         RCmDestinationExt& aDestination,
       
   508         RCmConnectionMethodExt& aConnectionMethod )
       
   509     {
       
   510     OstTraceFunctionEntry0( RCMMANAGEREXT_REMOVECONNECTIONMETHODL_ENTRY );
       
   511 
       
   512     if ( !iCmManagerApi )
       
   513         {
       
   514         User::Leave( KErrBadHandle );
       
   515         }
       
   516 
       
   517     if ( !aDestination.iCmDestinationWrapper ||
       
   518             !aConnectionMethod.iCmConnectionMethodWrapper )
       
   519         {
       
   520         User::Leave( KErrArgument );
       
   521         }
       
   522     if ( !aDestination.iCmDestinationWrapper->SessionConnected() ||
       
   523             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   524         {
       
   525         User::Leave( KErrArgument );
       
   526         }
       
   527 
       
   528     TInt targetDestHandle = aDestination.iCmDestinationWrapper->GetHandle();
       
   529     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   530     TInt err = iCmManagerApi->RemoveConnectionMethod( targetDestHandle, connMethodHandle );
       
   531     User::LeaveIfError( err );
       
   532 
       
   533     OstTraceFunctionExit0( RCMMANAGEREXT_REMOVECONNECTIONMETHODL_EXIT );
       
   534     }
       
   535 
       
   536 //-----------------------------------------------------------------------------
       
   537 //  RCmManagerExt::RemoveAllReferencesL()
       
   538 //-----------------------------------------------------------------------------
       
   539 //
       
   540 EXPORT_C void RCmManagerExt::RemoveAllReferencesL(
       
   541         RCmConnectionMethodExt& aConnectionMethod )
       
   542     {
       
   543     OstTraceFunctionEntry0( RCMMANAGEREXT_REMOVEALLREFERENCESL_ENTRY );
       
   544 
       
   545     if ( !iCmManagerApi )
       
   546         {
       
   547         User::Leave( KErrBadHandle );
       
   548         }
       
   549 
       
   550     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   551             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   552         {
       
   553         User::Leave( KErrArgument );
       
   554         }
       
   555 
       
   556     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   557     TInt err = iCmManagerApi->RemoveAllReferences( connMethodHandle );
       
   558     User::LeaveIfError( err );
       
   559 
       
   560     OstTraceFunctionExit0( RCMMANAGEREXT_REMOVEALLREFERENCESL_EXIT );
       
   561     }
       
   562 
       
   563 //-----------------------------------------------------------------------------
       
   564 //  RCmManagerExt::ConnectionMethodL()
       
   565 //-----------------------------------------------------------------------------
       
   566 //
       
   567 EXPORT_C void RCmManagerExt::ConnectionMethodL(
       
   568         RArray<TUint32>& aCmArray,
       
   569         TBool aCheckBearerType,
       
   570         TBool aLegacyOnly,
       
   571         TBool aEasyWlan )
       
   572     {
       
   573     OstTraceFunctionEntry0( DUP1_RCMMANAGEREXT_CONNECTIONMETHODL_ENTRY );
       
   574 
       
   575     if ( !iCmManagerApi )
       
   576         {
       
   577         User::Leave( KErrBadHandle );
       
   578         }
       
   579 
       
   580     TCmmIpcStructGetConnMethods parameters;
       
   581     parameters.iCheckBearerType = aCheckBearerType;
       
   582     parameters.iLegacyOnly = aLegacyOnly;
       
   583     parameters.iEasyWlan = aEasyWlan;
       
   584 
       
   585     iCmManagerApi->GetConnMethodsL( parameters, aCmArray );
       
   586 
       
   587     OstTraceFunctionExit0( DUP1_RCMMANAGEREXT_CONNECTIONMETHODL_EXIT );
       
   588     }
       
   589 
       
   590 //-----------------------------------------------------------------------------
       
   591 //  RCmManagerExt::AllDestinationsL()
       
   592 //-----------------------------------------------------------------------------
       
   593 //
       
   594 EXPORT_C void RCmManagerExt::AllDestinationsL( RArray<TUint32>& aDestArray )
       
   595     {
       
   596     OstTraceFunctionEntry0( RCMMANAGEREXT_ALLDESTINATIONSL_ENTRY );
       
   597 
       
   598     if ( !iCmManagerApi )
       
   599         {
       
   600         User::Leave( KErrBadHandle );
       
   601         }
       
   602 
       
   603     iCmManagerApi->GetAllDestinationsL( aDestArray );
       
   604 
       
   605     OstTraceFunctionExit0( RCMMANAGEREXT_ALLDESTINATIONSL_EXIT );
       
   606     }
       
   607 
       
   608 //-----------------------------------------------------------------------------
       
   609 //  RCmManagerExt::DestinationL()
       
   610 //-----------------------------------------------------------------------------
       
   611 //
       
   612 EXPORT_C RCmDestinationExt RCmManagerExt::DestinationL( TUint32 aDestinationId )
       
   613     {
       
   614     OstTraceFunctionEntry0( RCMMANAGEREXT_DESTINATIONL_ENTRY );
       
   615 
       
   616     if ( !iCmManagerApi )
       
   617         {
       
   618         User::Leave( KErrBadHandle );
       
   619         }
       
   620 
       
   621     // If client already has a handle open to this destination, give a
       
   622     // reference to it.
       
   623     CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC();
       
   624     TInt existingHandle( 0 );
       
   625     destWrap->GetDestWithIdL( iCmManagerApi, aDestinationId, existingHandle );
       
   626     if ( existingHandle )
       
   627         {
       
   628         CleanupStack::PopAndDestroy( destWrap );
       
   629         destWrap = iCmManagerApi->GetDestinationWrapperL( existingHandle );
       
   630         destWrap->IncreaseReferenceCounter();
       
   631         }
       
   632     else
       
   633         {
       
   634         CleanupStack::Pop( destWrap );
       
   635         }
       
   636 
       
   637     RCmDestinationExt dest;
       
   638     dest.iCmDestinationWrapper = destWrap;
       
   639 
       
   640     OstTraceFunctionExit0( RCMMANAGEREXT_DESTINATIONL_EXIT );
       
   641     return dest;
       
   642     }
       
   643 
       
   644 //-----------------------------------------------------------------------------
       
   645 //  RCmManagerExt::BearerPriorityArrayL()
       
   646 //-----------------------------------------------------------------------------
       
   647 //
       
   648 EXPORT_C void RCmManagerExt::BearerPriorityArrayL(
       
   649         RArray<TBearerPriority>& aArray ) const
       
   650     {
       
   651     OstTraceFunctionEntry0( RCMMANAGEREXT_BEARERPRIORITYARRAYL_ENTRY );
       
   652 
       
   653     if ( !iCmManagerApi )
       
   654         {
       
   655         User::Leave( KErrBadHandle );
       
   656         }
       
   657 
       
   658     iCmManagerApi->GetBearerPriorityArrayL( aArray );
       
   659 
       
   660     OstTraceFunctionExit0( RCMMANAGEREXT_BEARERPRIORITYARRAYL_EXIT );
       
   661     }
       
   662 
       
   663 //-----------------------------------------------------------------------------
       
   664 //  RCmManagerExt::UpdateBearerPriorityArrayL()
       
   665 //-----------------------------------------------------------------------------
       
   666 //
       
   667 EXPORT_C void RCmManagerExt::UpdateBearerPriorityArrayL(
       
   668         const RArray<TBearerPriority>& aArray )
       
   669     {
       
   670     OstTraceFunctionEntry0( RCMMANAGEREXT_UPDATEBEARERPRIORITYARRAYL_ENTRY );
       
   671 
       
   672     if ( !iCmManagerApi )
       
   673         {
       
   674         User::Leave( KErrBadHandle );
       
   675         }
       
   676 
       
   677     iCmManagerApi->SetBearerPriorityArrayL( aArray );
       
   678 
       
   679     OstTraceFunctionExit0( RCMMANAGEREXT_UPDATEBEARERPRIORITYARRAYL_EXIT );
       
   680     }
       
   681 
       
   682 //-----------------------------------------------------------------------------
       
   683 //  RCmManagerExt::CleanupGlobalPriorityArray()
       
   684 //-----------------------------------------------------------------------------
       
   685 //
       
   686 EXPORT_C void RCmManagerExt::CleanupGlobalPriorityArray(
       
   687         RArray<TBearerPriority>& aArray ) const
       
   688     {
       
   689     OstTraceFunctionEntry0( RCMMANAGEREXT_CLEANUPGLOBALPRIORITYARRAY_ENTRY );
       
   690 
       
   691     for ( TInt i = 0; i < aArray.Count(); i++ )
       
   692         {
       
   693         delete aArray[i].iServiceType;
       
   694         }
       
   695     aArray.Reset();
       
   696     aArray.Close();
       
   697 
       
   698     OstTraceFunctionExit0( RCMMANAGEREXT_CLEANUPGLOBALPRIORITYARRAY_EXIT );
       
   699     }
       
   700 
       
   701 //-----------------------------------------------------------------------------
       
   702 //  RCmManagerExt::SupportedBearersL()
       
   703 //-----------------------------------------------------------------------------
       
   704 //
       
   705 EXPORT_C void RCmManagerExt::SupportedBearersL( RArray<TUint32>& aArray ) const
       
   706     {
       
   707     OstTraceFunctionEntry0( RCMMANAGEREXT_SUPPORTEDBEARERSL_ENTRY );
       
   708 
       
   709     if ( !iCmManagerApi )
       
   710         {
       
   711         User::Leave( KErrBadHandle );
       
   712         }
       
   713     iCmManagerApi->GetSupportedBearersL( aArray );
       
   714 
       
   715     OstTraceFunctionExit0( RCMMANAGEREXT_SUPPORTEDBEARERSL_EXIT );
       
   716     }
       
   717 
       
   718 //-----------------------------------------------------------------------------
       
   719 //  RCmManagerExt::EasyWlanIdL()
       
   720 //-----------------------------------------------------------------------------
       
   721 //
       
   722 EXPORT_C TUint32 RCmManagerExt::EasyWlanIdL()
       
   723     {
       
   724     OstTraceFunctionEntry0( RCMMANAGEREXT_EASYWLANIDL_ENTRY );
       
   725 
       
   726     if ( !iCmManagerApi )
       
   727         {
       
   728         User::Leave( KErrBadHandle );
       
   729         }
       
   730 
       
   731     TUint32 value( 0 );
       
   732     TInt err = iCmManagerApi->GetEasyWlanId( value );
       
   733     User::LeaveIfError( err );
       
   734     OstTraceFunctionExit0( RCMMANAGEREXT_EASYWLANIDL_EXIT );
       
   735     return value;
       
   736     }
       
   737 
       
   738 //-----------------------------------------------------------------------------
       
   739 //  RCmManagerExt::ReadDefConnL()
       
   740 //-----------------------------------------------------------------------------
       
   741 //
       
   742 EXPORT_C void RCmManagerExt::ReadDefConnL( TCmDefConnValue& aDefConnSetting )
       
   743     {
       
   744     OstTraceFunctionEntry0( RCMMANAGEREXT_READDEFCONNL_ENTRY );
       
   745 
       
   746     if ( !iCmManagerApi )
       
   747         {
       
   748         User::Leave( KErrBadHandle );
       
   749         }
       
   750 
       
   751     TInt err = iCmManagerApi->ReadDefaultConnection( aDefConnSetting );
       
   752     User::LeaveIfError( err );
       
   753 
       
   754     OstTraceFunctionExit0( RCMMANAGEREXT_READDEFCONNL_EXIT );
       
   755     }
       
   756 
       
   757 //-----------------------------------------------------------------------------
       
   758 //  RCmManagerExt::WriteDefConnL()
       
   759 //-----------------------------------------------------------------------------
       
   760 //
       
   761 EXPORT_C void RCmManagerExt::WriteDefConnL( const TCmDefConnValue& aDefConnSetting )
       
   762     {
       
   763     OstTraceFunctionEntry0( RCMMANAGEREXT_WRITEDEFCONNL_ENTRY );
       
   764 
       
   765     if ( !iCmManagerApi )
       
   766         {
       
   767         User::Leave( KErrBadHandle );
       
   768         }
       
   769 
       
   770     TInt err = iCmManagerApi->WriteDefaultConnection( aDefConnSetting );
       
   771     User::LeaveIfError( err );
       
   772 
       
   773     OstTraceFunctionExit0( RCMMANAGEREXT_WRITEDEFCONNL_EXIT );
       
   774     }
       
   775 
       
   776 //-----------------------------------------------------------------------------
       
   777 //  RCmManagerExt::CreateDestinationL()
       
   778 //-----------------------------------------------------------------------------
       
   779 //
       
   780 EXPORT_C RCmDestinationExt RCmManagerExt::CreateDestinationL(
       
   781         const TDesC& aName,
       
   782         TUint32 aDestId )
       
   783     {
       
   784     OstTraceFunctionEntry0( DUP1_RCMMANAGEREXT_CREATEDESTINATIONL_ENTRY );
       
   785 
       
   786     if ( aDestId == 0 )
       
   787         {
       
   788         return CreateDestinationL( aName );
       
   789         }
       
   790 
       
   791     if ( !iCmManagerApi )
       
   792         {
       
   793         User::Leave( KErrBadHandle );
       
   794         }
       
   795 
       
   796     if ( aName.Length() == 0 )
       
   797         {
       
   798         User::Leave( KErrArgument );
       
   799         }
       
   800 
       
   801     TUint32 adjustedDestId( 0 );
       
   802     if ( aDestId > KCmmDestIdIntervalLegacyMin && aDestId < KCmmDestIdIntervalLegacyMax )
       
   803         {
       
   804         adjustedDestId = aDestId + KCmDefaultDestinationAPTagId;
       
   805         }
       
   806     else if ( aDestId > KCmmDestIdIntervalMin && aDestId < KCmmDestIdIntervalMax )
       
   807         {
       
   808         adjustedDestId = aDestId;
       
   809         }
       
   810     else
       
   811         {
       
   812         User::Leave( KErrArgument );
       
   813         }
       
   814 
       
   815     CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC();
       
   816     destWrap->CreateDestByNameAndIdL( iCmManagerApi, aName, adjustedDestId );
       
   817     CleanupStack::Pop( destWrap );
       
   818 
       
   819     RCmDestinationExt dest;
       
   820     dest.iCmDestinationWrapper = destWrap;
       
   821 
       
   822     OstTraceFunctionExit0( DUP1_RCMMANAGEREXT_CREATEDESTINATIONL_EXIT );
       
   823     return dest;
       
   824     }
       
   825 
       
   826 //-----------------------------------------------------------------------------
       
   827 //  RCmManagerExt::CreateConnectionMethodL()
       
   828 //-----------------------------------------------------------------------------
       
   829 //
       
   830 EXPORT_C RCmConnectionMethodExt RCmManagerExt::CreateConnectionMethodL(
       
   831         TUint32 aBearerType,
       
   832         TUint32 aConnMethodId )
       
   833     {
       
   834     OstTraceFunctionEntry0( DUP1_RCMMANAGEREXT_CREATECONNECTIONMETHODL_ENTRY );
       
   835 
       
   836     if ( aConnMethodId == 0 )
       
   837         {
       
   838         return CreateConnectionMethodL( aBearerType );
       
   839         }
       
   840 
       
   841     if ( !iCmManagerApi )
       
   842         {
       
   843         User::Leave( KErrBadHandle );
       
   844         }
       
   845     if ( !( aConnMethodId > KCmmConnMethodIdIntervalMin &&
       
   846             aConnMethodId < KCmmConnMethodIdIntervalMax ) )
       
   847         {
       
   848         User::Leave( KErrArgument );
       
   849         }
       
   850 
       
   851     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   852     cmWrapper->CreateConnMethodWithIdL( iCmManagerApi, aBearerType, aConnMethodId );
       
   853     CleanupStack::Pop( cmWrapper );
       
   854 
       
   855     RCmConnectionMethodExt cm;
       
   856     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   857 
       
   858     OstTraceFunctionExit0( DUP1_RCMMANAGEREXT_CREATECONNECTIONMETHODL_EXIT );
       
   859     return cm;
       
   860     }
       
   861 
       
   862 // End of file