cmmanager/cmmgr/cmmapi/src/cmmanager.cpp
changeset 20 9c97ad6591ae
child 27 489cf6208544
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 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 = NULL;
       
   214         buffer = KNullDesC().AllocL();
       
   215         }
       
   216 
       
   217     OstTraceFunctionExit0( RCMMANAGER_GETBEARERINFOSTRINGL_EXIT );
       
   218     return buffer;
       
   219     }
       
   220 
       
   221 //-----------------------------------------------------------------------------
       
   222 //  RCmManager::GetBearerInfoString8L()
       
   223 //-----------------------------------------------------------------------------
       
   224 //
       
   225 EXPORT_C HBufC8* RCmManager::GetBearerInfoString8L(
       
   226         TUint32 aBearerType,
       
   227         TUint32 aAttribute ) const
       
   228     {
       
   229     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_GETBEARERINFOSTRING8L_EXIT );
       
   252     return buffer8;
       
   253     }
       
   254 
       
   255 //-----------------------------------------------------------------------------
       
   256 //  RCmManager::GetConnectionMethodInfoIntL()
       
   257 //-----------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C TUint32 RCmManager::GetConnectionMethodInfoIntL(
       
   260         TUint32 aIapId,
       
   261         TUint32 aAttribute ) const
       
   262     {
       
   263     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_GETCONNECTIONMETHODINFOINTL_EXIT );
       
   275     return value;
       
   276     }
       
   277 
       
   278 //-----------------------------------------------------------------------------
       
   279 //  RCmManager::GetConnectionMethodInfoBoolL()
       
   280 //-----------------------------------------------------------------------------
       
   281 //
       
   282 EXPORT_C TBool RCmManager::GetConnectionMethodInfoBoolL(
       
   283         TUint32 aIapId,
       
   284         TUint32 aAttribute ) const
       
   285     {
       
   286     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_GETCONNECTIONMETHODINFOBOOLL_EXIT );
       
   298     return value;
       
   299     }
       
   300 
       
   301 //-----------------------------------------------------------------------------
       
   302 //  RCmManager::GetConnectionMethodInfoStringL()
       
   303 //-----------------------------------------------------------------------------
       
   304 //
       
   305 EXPORT_C HBufC* RCmManager::GetConnectionMethodInfoStringL(
       
   306         TUint32 aIapId,
       
   307         TUint32 aAttribute ) const
       
   308     {
       
   309     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_GETCONNECTIONMETHODINFOSTRINGL_EXIT );
       
   332     return buffer;
       
   333     }
       
   334 
       
   335 //-----------------------------------------------------------------------------
       
   336 //  RCmManager::GetConnectionMethodInfoString8L()
       
   337 //-----------------------------------------------------------------------------
       
   338 //
       
   339 EXPORT_C HBufC8* RCmManager::GetConnectionMethodInfoString8L(
       
   340         TUint32 aIapId,
       
   341         TUint32 aAttribute ) const
       
   342     {
       
   343     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_GETCONNECTIONMETHODINFOSTRING8L_EXIT );
       
   366     return buffer8;
       
   367     }
       
   368 
       
   369 //-----------------------------------------------------------------------------
       
   370 //  RCmManager::CreateDestinationL()
       
   371 //-----------------------------------------------------------------------------
       
   372 //
       
   373 EXPORT_C RCmDestination RCmManager::CreateDestinationL(
       
   374         const TDesC& aName )
       
   375     {
       
   376     OstTraceFunctionEntry0( RCMMANAGER_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     RCmDestination dest;
       
   393     dest.iCmDestinationWrapper = destWrap;
       
   394 
       
   395     OstTraceFunctionExit0( RCMMANAGER_CREATEDESTINATIONL_EXIT );
       
   396     return dest;
       
   397     }
       
   398 
       
   399 //-----------------------------------------------------------------------------
       
   400 //  RCmManager::CreateConnectionMethodL()
       
   401 //-----------------------------------------------------------------------------
       
   402 //
       
   403 EXPORT_C RCmConnectionMethod RCmManager::CreateConnectionMethodL(
       
   404         TUint32 aBearerType )
       
   405     {
       
   406     OstTraceFunctionEntry0( RCMMANAGER_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     RCmConnectionMethod cm;
       
   418     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   419 
       
   420     OstTraceFunctionExit0( RCMMANAGER_CREATECONNECTIONMETHODL_EXIT );
       
   421     return cm;
       
   422     }
       
   423 
       
   424 //-----------------------------------------------------------------------------
       
   425 //  RCmManager::CopyConnectionMethodL()
       
   426 //-----------------------------------------------------------------------------
       
   427 //
       
   428 EXPORT_C TInt RCmManager::CopyConnectionMethodL(
       
   429         RCmDestination& aTargetDestination,
       
   430         RCmConnectionMethod& aConnectionMethod )
       
   431     {
       
   432     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_COPYCONNECTIONMETHODL_EXIT );
       
   457     return index;
       
   458     }
       
   459 
       
   460 //-----------------------------------------------------------------------------
       
   461 //  RCmManager::MoveConnectionMethodL()
       
   462 //-----------------------------------------------------------------------------
       
   463 //
       
   464 EXPORT_C TInt RCmManager::MoveConnectionMethodL(
       
   465         RCmDestination& aSourceDestination,
       
   466         RCmDestination& aTargetDestination,
       
   467         RCmConnectionMethod& aConnectionMethod )
       
   468     {
       
   469     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_MOVECONNECTIONMETHODL_EXIT );
       
   499     return pkgData.iIndex;
       
   500     }
       
   501 
       
   502 //-----------------------------------------------------------------------------
       
   503 //  RCmManager::RemoveConnectionMethodL()
       
   504 //-----------------------------------------------------------------------------
       
   505 //
       
   506 EXPORT_C void RCmManager::RemoveConnectionMethodL(
       
   507         RCmDestination& aDestination,
       
   508         RCmConnectionMethod& aConnectionMethod )
       
   509     {
       
   510     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_REMOVECONNECTIONMETHODL_EXIT );
       
   534     }
       
   535 
       
   536 //-----------------------------------------------------------------------------
       
   537 //  RCmManager::RemoveAllReferencesL()
       
   538 //-----------------------------------------------------------------------------
       
   539 //
       
   540 EXPORT_C void RCmManager::RemoveAllReferencesL(
       
   541         RCmConnectionMethod& aConnectionMethod )
       
   542     {
       
   543     OstTraceFunctionEntry0( RCMMANAGER_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( RCMMANAGER_REMOVEALLREFERENCESL_EXIT );
       
   561     }
       
   562 
       
   563 //-----------------------------------------------------------------------------
       
   564 //  RCmManager::ConnectionMethodL()
       
   565 //-----------------------------------------------------------------------------
       
   566 //
       
   567 EXPORT_C void RCmManager::ConnectionMethodL(
       
   568         RArray<TUint32>& aCmArray,
       
   569         TBool aCheckBearerType,
       
   570         TBool aLegacyOnly,
       
   571         TBool aEasyWlan ) const
       
   572     {
       
   573     OstTraceFunctionEntry0( DUP1_RCMMANAGER_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( RCMMANAGER_CONNECTIONMETHODL_EXIT );
       
   588     }
       
   589 
       
   590 //-----------------------------------------------------------------------------
       
   591 //  RCmManager::AllDestinationsL()
       
   592 //-----------------------------------------------------------------------------
       
   593 //
       
   594 EXPORT_C void RCmManager::AllDestinationsL( RArray<TUint32>& aDestArray ) const
       
   595     {
       
   596     OstTraceFunctionEntry0( RCMMANAGER_ALLDESTINATIONSL_ENTRY );
       
   597 
       
   598     if ( !iCmManagerApi )
       
   599         {
       
   600         User::Leave( KErrBadHandle );
       
   601         }
       
   602 
       
   603     iCmManagerApi->GetAllDestinationsL( aDestArray );
       
   604 
       
   605     OstTraceFunctionExit0( RCMMANAGER_ALLDESTINATIONSL_EXIT );
       
   606     }
       
   607 
       
   608 //-----------------------------------------------------------------------------
       
   609 //  RCmManager::DestinationL()
       
   610 //-----------------------------------------------------------------------------
       
   611 //
       
   612 EXPORT_C RCmDestination RCmManager::DestinationL( TUint32 aDestinationId ) const
       
   613     {
       
   614     OstTraceFunctionEntry0( RCMMANAGER_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     RCmDestination dest;
       
   638     dest.iCmDestinationWrapper = destWrap;
       
   639 
       
   640     return dest;
       
   641     }
       
   642 
       
   643 //-----------------------------------------------------------------------------
       
   644 //  RCmManager::BearerPriorityArrayL()
       
   645 //-----------------------------------------------------------------------------
       
   646 //
       
   647 EXPORT_C void RCmManager::BearerPriorityArrayL(
       
   648         RArray<TBearerPriority>& aArray ) const
       
   649     {
       
   650     OstTraceFunctionEntry0( RCMMANAGER_BEARERPRIORITYARRAYL_ENTRY );
       
   651 
       
   652     if ( !iCmManagerApi )
       
   653         {
       
   654         User::Leave( KErrBadHandle );
       
   655         }
       
   656 
       
   657     iCmManagerApi->GetBearerPriorityArrayL( aArray );
       
   658 
       
   659     OstTraceFunctionExit0( RCMMANAGER_BEARERPRIORITYARRAYL_EXIT );
       
   660     }
       
   661 
       
   662 //-----------------------------------------------------------------------------
       
   663 //  RCmManager::UpdateBearerPriorityArrayL()
       
   664 //-----------------------------------------------------------------------------
       
   665 //
       
   666 EXPORT_C void RCmManager::UpdateBearerPriorityArrayL(
       
   667         const RArray<TBearerPriority>& aArray )
       
   668     {
       
   669     OstTraceFunctionEntry0( RCMMANAGER_UPDATEBEARERPRIORITYARRAYL_ENTRY );
       
   670 
       
   671     if ( !iCmManagerApi )
       
   672         {
       
   673         User::Leave( KErrBadHandle );
       
   674         }
       
   675 
       
   676     iCmManagerApi->SetBearerPriorityArrayL( aArray );
       
   677 
       
   678     OstTraceFunctionExit0( RCMMANAGER_UPDATEBEARERPRIORITYARRAYL_EXIT );
       
   679     }
       
   680 
       
   681 //-----------------------------------------------------------------------------
       
   682 //  RCmManager::CleanupGlobalPriorityArray()
       
   683 //-----------------------------------------------------------------------------
       
   684 //
       
   685 EXPORT_C void RCmManager::CleanupGlobalPriorityArray(
       
   686         RArray<TBearerPriority>& aArray ) const
       
   687     {
       
   688     OstTraceFunctionEntry0( RCMMANAGER_CLEANUPGLOBALPRIORITYARRAY_ENTRY );
       
   689 
       
   690     for ( TInt i = 0; i < aArray.Count(); i++ )
       
   691         {
       
   692         delete aArray[i].iServiceType;
       
   693         }
       
   694     aArray.Reset();
       
   695     aArray.Close();
       
   696 
       
   697     OstTraceFunctionExit0( RCMMANAGER_CLEANUPGLOBALPRIORITYARRAY_EXIT );
       
   698     }
       
   699 
       
   700 //-----------------------------------------------------------------------------
       
   701 //  RCmManager::SupportedBearersL()
       
   702 //-----------------------------------------------------------------------------
       
   703 //
       
   704 EXPORT_C void RCmManager::SupportedBearersL( RArray<TUint32>& aArray ) const
       
   705     {
       
   706     OstTraceFunctionEntry0( RCMMANAGER_SUPPORTEDBEARERSL_ENTRY );
       
   707 
       
   708     if ( !iCmManagerApi )
       
   709         {
       
   710         User::Leave( KErrBadHandle );
       
   711         }
       
   712     iCmManagerApi->GetSupportedBearersL( aArray );
       
   713 
       
   714     OstTraceFunctionExit0( RCMMANAGER_SUPPORTEDBEARERSL_EXIT );
       
   715     }
       
   716 
       
   717 //-----------------------------------------------------------------------------
       
   718 //  RCmManager::EasyWlanIdL()
       
   719 //-----------------------------------------------------------------------------
       
   720 //
       
   721 EXPORT_C TUint32 RCmManager::EasyWlanIdL() const
       
   722     {
       
   723     OstTraceFunctionEntry0( RCMMANAGER_EASYWLANIDL_ENTRY );
       
   724 
       
   725     if ( !iCmManagerApi )
       
   726         {
       
   727         User::Leave( KErrBadHandle );
       
   728         }
       
   729 
       
   730     TUint32 value( 0 );
       
   731     TInt err = iCmManagerApi->GetEasyWlanId( value );
       
   732     User::LeaveIfError( err );
       
   733 
       
   734     OstTraceFunctionExit0( RCMMANAGER_EASYWLANIDL_EXIT );
       
   735     return value;
       
   736     }
       
   737 
       
   738 //-----------------------------------------------------------------------------
       
   739 //  RCmManager::ReadDefConnL()
       
   740 //-----------------------------------------------------------------------------
       
   741 //
       
   742 EXPORT_C void RCmManager::ReadDefConnL(
       
   743         TCmDefConnValue& aDefConnSetting )
       
   744     {
       
   745     OstTraceFunctionEntry0( RCMMANAGER_READDEFCONNL_ENTRY );
       
   746 
       
   747     if ( !iCmManagerApi )
       
   748         {
       
   749         User::Leave( KErrBadHandle );
       
   750         }
       
   751 
       
   752     TInt err = iCmManagerApi->ReadDefaultConnection( aDefConnSetting );
       
   753     User::LeaveIfError( err );
       
   754 
       
   755     OstTraceFunctionExit0( RCMMANAGER_READDEFCONNL_EXIT );
       
   756     }
       
   757 
       
   758 //-----------------------------------------------------------------------------
       
   759 //  RCmManager::WriteDefConnL()
       
   760 //-----------------------------------------------------------------------------
       
   761 //
       
   762 EXPORT_C void RCmManager::WriteDefConnL(
       
   763         const TCmDefConnValue& aDefConnSetting )
       
   764     {
       
   765     OstTraceFunctionEntry0( RCMMANAGER_WRITEDEFCONNL_ENTRY );
       
   766 
       
   767     if ( !iCmManagerApi )
       
   768         {
       
   769         User::Leave( KErrBadHandle );
       
   770         }
       
   771 
       
   772     TInt err = iCmManagerApi->WriteDefaultConnection( aDefConnSetting );
       
   773     User::LeaveIfError( err );
       
   774 
       
   775     OstTraceFunctionExit0( RCMMANAGER_WRITEDEFCONNL_EXIT );
       
   776     }
       
   777 
       
   778 //-----------------------------------------------------------------------------
       
   779 //  RCmManager::ReadGenConnSettingsL()
       
   780 //-----------------------------------------------------------------------------
       
   781 //
       
   782 EXPORT_C void RCmManager::ReadGenConnSettingsL(
       
   783         TCmGenConnSettings& aGenConnSettings )
       
   784     {
       
   785     OstTraceFunctionEntry0( RCMMANAGER_READGENCONNSETTINGSL_ENTRY );
       
   786 
       
   787     if ( !iCmManagerApi )
       
   788         {
       
   789         User::Leave( KErrBadHandle );
       
   790         }
       
   791 
       
   792     TInt err = iCmManagerApi->ReadGeneralConnectionSettings( aGenConnSettings );
       
   793     User::LeaveIfError( err );
       
   794 
       
   795     OstTraceFunctionExit0( RCMMANAGER_READGENCONNSETTINGSL_EXIT );
       
   796     }
       
   797 
       
   798 //-----------------------------------------------------------------------------
       
   799 //  RCmManager::WriteGenConnSettingsL()
       
   800 //-----------------------------------------------------------------------------
       
   801 //
       
   802 EXPORT_C void RCmManager::WriteGenConnSettingsL(
       
   803         const TCmGenConnSettings& aGenConnSettings )
       
   804     {
       
   805     OstTraceFunctionEntry0( RCMMANAGER_WRITEGENCONNSETTINGSL_ENTRY );
       
   806 
       
   807     if ( !iCmManagerApi )
       
   808         {
       
   809         User::Leave( KErrBadHandle );
       
   810         }
       
   811 
       
   812     TInt err = iCmManagerApi->WriteGeneralConnectionSettings( aGenConnSettings );
       
   813     User::LeaveIfError( err );
       
   814 
       
   815     OstTraceFunctionExit0( RCMMANAGER_WRITEGENCONNSETTINGSL_EXIT );
       
   816     }
       
   817 
       
   818 //-----------------------------------------------------------------------------
       
   819 //  RCmManager::CreateDestinationL()
       
   820 //-----------------------------------------------------------------------------
       
   821 //
       
   822 EXPORT_C RCmDestination RCmManager::CreateDestinationL(
       
   823         const TDesC& aName,
       
   824         TUint32 aDestId )
       
   825     {
       
   826     OstTraceFunctionEntry0( DUP1_RCMMANAGER_CREATEDESTINATIONL_ENTRY );
       
   827 
       
   828     if ( aDestId == 0 )
       
   829         {
       
   830         return CreateDestinationL( aName );
       
   831         }
       
   832 
       
   833     if ( !iCmManagerApi )
       
   834         {
       
   835         User::Leave( KErrBadHandle );
       
   836         }
       
   837 
       
   838     if ( aName.Length() == 0 )
       
   839         {
       
   840         User::Leave( KErrArgument );
       
   841         }
       
   842 
       
   843     TUint32 adjustedDestId( 0 );
       
   844     if ( aDestId > KCmmDestIdIntervalLegacyMin && aDestId < KCmmDestIdIntervalLegacyMax )
       
   845         {
       
   846         adjustedDestId = aDestId + KCmDefaultDestinationAPTagId;
       
   847         }
       
   848     else if ( aDestId > KCmmDestIdIntervalMin && aDestId < KCmmDestIdIntervalMax )
       
   849         {
       
   850         adjustedDestId = aDestId;
       
   851         }
       
   852     else
       
   853         {
       
   854         User::Leave( KErrArgument );
       
   855         }
       
   856 
       
   857     CCmDestinationWrapper* destWrap = CCmDestinationWrapper::NewLC();
       
   858     destWrap->CreateDestByNameAndIdL( iCmManagerApi, aName, adjustedDestId );
       
   859     CleanupStack::Pop( destWrap );
       
   860 
       
   861     RCmDestination dest;
       
   862     dest.iCmDestinationWrapper = destWrap;
       
   863 
       
   864     OstTraceFunctionExit0( DUP1_RCMMANAGER_CREATEDESTINATIONL_EXIT );
       
   865     return dest;
       
   866     }
       
   867 
       
   868 //-----------------------------------------------------------------------------
       
   869 //  RCmManager::CreateConnectionMethodL()
       
   870 //-----------------------------------------------------------------------------
       
   871 //
       
   872 EXPORT_C RCmConnectionMethod RCmManager::CreateConnectionMethodL(
       
   873         TUint32 aBearerType,
       
   874         TUint32 aConnMethodId )
       
   875     {
       
   876     OstTraceFunctionEntry0( DUP1_RCMMANAGER_CREATECONNECTIONMETHODL_ENTRY );
       
   877 
       
   878     if ( aConnMethodId == 0 )
       
   879         {
       
   880         return CreateConnectionMethodL( aBearerType );
       
   881         }
       
   882 
       
   883     if ( !iCmManagerApi )
       
   884         {
       
   885         User::Leave( KErrBadHandle );
       
   886         }
       
   887     if ( !( aConnMethodId > KCmmConnMethodIdIntervalMin &&
       
   888             aConnMethodId < KCmmConnMethodIdIntervalMax ) )
       
   889         {
       
   890         User::Leave( KErrArgument );
       
   891         }
       
   892 
       
   893     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   894     cmWrapper->CreateConnMethodWithIdL( iCmManagerApi, aBearerType, aConnMethodId );
       
   895     CleanupStack::Pop( cmWrapper );
       
   896 
       
   897     RCmConnectionMethod cm;
       
   898     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   899 
       
   900     OstTraceFunctionExit0( DUP1_RCMMANAGER_CREATECONNECTIONMETHODL_EXIT );
       
   901     return cm;
       
   902     }
       
   903 
       
   904 //-----------------------------------------------------------------------------
       
   905 //  RCmManager::GetUncategorizedIconL()
       
   906 //-----------------------------------------------------------------------------
       
   907 //
       
   908 EXPORT_C HBufC* RCmManager::GetUncategorizedIconL() const
       
   909     {
       
   910     OstTraceFunctionEntry0( RCMMANAGER_GETUNCATEGORIZEDICONL_ENTRY );
       
   911 
       
   912     User::Leave( KErrNotSupported );
       
   913 
       
   914     OstTraceFunctionExit0( RCMMANAGER_GETUNCATEGORIZEDICONL_EXIT );
       
   915     return NULL;
       
   916     }
       
   917 
       
   918 // End of file