cmmanager/cmmgr/cmmapi/src/cmconnectionmethodwrapper.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
       
     2 * Copyright (c) 2009-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 * Collects API calls from RCmConnectionMethod- and
       
    16 * RCmConnectionMethodExt-classes.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "cmconnectionmethodwrapper.h"
       
    22 #include "cmmanagerapi.h"
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "cmconnectionmethodwrapperTraces.h"
       
    27 #endif
       
    28 
       
    29 
       
    30 CCmConnectionMethodWrapper* CCmConnectionMethodWrapper::NewL()
       
    31     {
       
    32     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_NEWL_ENTRY );
       
    33 
       
    34     CCmConnectionMethodWrapper* self = CCmConnectionMethodWrapper::NewLC();
       
    35     CleanupStack::Pop( self );
       
    36 
       
    37     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_NEWL_EXIT );
       
    38     return self;
       
    39     }
       
    40 
       
    41 CCmConnectionMethodWrapper* CCmConnectionMethodWrapper::NewLC()
       
    42     {
       
    43     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_NEWLC_ENTRY );
       
    44 
       
    45     CCmConnectionMethodWrapper* self = new (ELeave) CCmConnectionMethodWrapper;
       
    46     CleanupStack::PushL( self );
       
    47 
       
    48     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_NEWLC_EXIT );
       
    49     return self;
       
    50     }
       
    51 
       
    52 CCmConnectionMethodWrapper::~CCmConnectionMethodWrapper()
       
    53     {
       
    54     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CCMCONNECTIONMETHODWRAPPER_ENTRY );
       
    55 
       
    56     iCmConnectionMethodApi.Close();
       
    57 
       
    58     if ( iCmManagerApi )
       
    59         {
       
    60         iCmManagerApi->RemoveConnMethodWrapper( this );
       
    61         iCmManagerApi = NULL;
       
    62         }
       
    63 
       
    64     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CCMCONNECTIONMETHODWRAPPER_EXIT );
       
    65     }
       
    66 
       
    67 CCmConnectionMethodWrapper::CCmConnectionMethodWrapper()
       
    68     {
       
    69     OstTraceFunctionEntry0( DUP1_CCMCONNECTIONMETHODWRAPPER_CCMCONNECTIONMETHODWRAPPER_ENTRY );
       
    70 
       
    71     iCmManagerApi = NULL;
       
    72     iReferenceCounter = 1;
       
    73 
       
    74     OstTraceFunctionExit0( DUP1_CCMCONNECTIONMETHODWRAPPER_CCMCONNECTIONMETHODWRAPPER_EXIT );
       
    75     }
       
    76 
       
    77 void CCmConnectionMethodWrapper::GetConnMethodWithIdL(
       
    78         RCmManagerApi* aCmManagerApi,
       
    79         const TUint32 aIapId,
       
    80         TInt& aExistingHandle )
       
    81     {
       
    82     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODWITHIDL_ENTRY );
       
    83 
       
    84     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
    85         {
       
    86         User::Leave( KErrAlreadyExists );
       
    87         }
       
    88 
       
    89     iCmManagerApi = aCmManagerApi;
       
    90     iCmConnectionMethodApi.ConnectAndGetConnMethodWithIdL(
       
    91             *aCmManagerApi,
       
    92             aIapId,
       
    93             aExistingHandle );
       
    94     if ( !aExistingHandle )
       
    95         {
       
    96         iCmManagerApi->StoreConnMethodWrapper( this );
       
    97         }
       
    98 
       
    99     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODWITHIDL_EXIT );
       
   100     }
       
   101 
       
   102 void CCmConnectionMethodWrapper::GetConnMethodFromDestWithIndexL(
       
   103         RCmManagerApi* aCmManagerApi,
       
   104         const TInt aDestHandle,
       
   105         const TInt aIndex,
       
   106         TInt& aExistingHandle )
       
   107     {
       
   108     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHINDEXL_ENTRY );
       
   109 
       
   110     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   111         {
       
   112         User::Leave( KErrAlreadyExists );
       
   113         }
       
   114 
       
   115     iCmManagerApi = aCmManagerApi;
       
   116     iCmConnectionMethodApi.ConnectAndGetConnMethodFromDestWithIndexL(
       
   117             *aCmManagerApi,
       
   118             aDestHandle,
       
   119             aIndex,
       
   120             aExistingHandle );
       
   121     if ( !aExistingHandle )
       
   122         {
       
   123         iCmManagerApi->StoreConnMethodWrapper( this );
       
   124         }
       
   125 
       
   126     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHINDEXL_EXIT );
       
   127     }
       
   128 
       
   129 void CCmConnectionMethodWrapper::GetConnMethodFromDestWithIdL(
       
   130         RCmManagerApi* aCmManagerApi,
       
   131         const TInt aDestHandle,
       
   132         const TInt aIapId,
       
   133         TInt& aExistingHandle )
       
   134     {
       
   135     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHIDL_ENTRY );
       
   136 
       
   137     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   138         {
       
   139         User::Leave( KErrAlreadyExists );
       
   140         }
       
   141 
       
   142     iCmManagerApi = aCmManagerApi;
       
   143     iCmConnectionMethodApi.ConnectAndGetConnMethodFromDestWithIdL(
       
   144             *aCmManagerApi,
       
   145             aDestHandle,
       
   146             aIapId,
       
   147             aExistingHandle );
       
   148     if ( !aExistingHandle )
       
   149         {
       
   150         iCmManagerApi->StoreConnMethodWrapper( this );
       
   151         }
       
   152 
       
   153     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHIDL_EXIT );
       
   154     }
       
   155 
       
   156 void CCmConnectionMethodWrapper::CreateConnMethodL(
       
   157         RCmManagerApi* aCmManagerApi,
       
   158         const TUint32 aBearerType )
       
   159     {
       
   160     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODL_ENTRY );
       
   161 
       
   162     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   163         {
       
   164         User::Leave( KErrAlreadyExists );
       
   165         }
       
   166 
       
   167     iCmManagerApi = aCmManagerApi;
       
   168     iCmConnectionMethodApi.ConnectAndCreateConnMethodL(
       
   169             *aCmManagerApi,
       
   170             aBearerType );
       
   171     iCmManagerApi->StoreConnMethodWrapper( this );
       
   172 
       
   173     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODL_EXIT );
       
   174     }
       
   175 
       
   176 void CCmConnectionMethodWrapper::CreateConnMethodWithIdL(
       
   177         RCmManagerApi* aCmManagerApi,
       
   178         const TUint32 aBearerType,
       
   179         const TUint32 aIapId )
       
   180     {
       
   181     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODWITHIDL_ENTRY );
       
   182 
       
   183     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   184         {
       
   185         User::Leave( KErrAlreadyExists );
       
   186         }
       
   187 
       
   188     iCmManagerApi = aCmManagerApi;
       
   189     iCmConnectionMethodApi.ConnectAndCreateConnMethodWithIdL(
       
   190             *aCmManagerApi,
       
   191             aBearerType,
       
   192             aIapId );
       
   193     iCmManagerApi->StoreConnMethodWrapper( this );
       
   194 
       
   195     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODWITHIDL_EXIT );
       
   196     }
       
   197 
       
   198 TInt CCmConnectionMethodWrapper::CreateConnMethodCopy(
       
   199         RCmManagerApi* aCmManagerApi,
       
   200         const TInt aConnMethodHandle )
       
   201     {
       
   202     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODCOPY_ENTRY );
       
   203 
       
   204     TInt err( KErrNone );
       
   205 
       
   206     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   207         {
       
   208         err = KErrAlreadyExists;
       
   209         }
       
   210     else
       
   211         {
       
   212         err = iCmConnectionMethodApi.ConnectAndCreateConnMethodCopy(
       
   213                 *aCmManagerApi,
       
   214                 aConnMethodHandle );
       
   215         if ( !err )
       
   216             {
       
   217             iCmManagerApi = aCmManagerApi;
       
   218             iCmManagerApi->StoreConnMethodWrapper( this );
       
   219             }
       
   220         }
       
   221 
       
   222     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODCOPY_EXIT );
       
   223     return err;
       
   224     }
       
   225 
       
   226 void CCmConnectionMethodWrapper::CreateConnMethodToDestL(
       
   227         RCmManagerApi* aCmManagerApi,
       
   228         const TInt aDestHandle,
       
   229         const TUint32 aBearerType )
       
   230     {
       
   231     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTL_ENTRY );
       
   232 
       
   233     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   234         {
       
   235         User::Leave( KErrAlreadyExists );
       
   236         }
       
   237 
       
   238     iCmManagerApi = aCmManagerApi;
       
   239     iCmConnectionMethodApi.ConnectAndCreateConnMethodToDestL(
       
   240             *aCmManagerApi,
       
   241             aDestHandle,
       
   242             aBearerType );
       
   243     iCmManagerApi->StoreConnMethodWrapper( this );
       
   244 
       
   245     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTL_EXIT );
       
   246     }
       
   247 
       
   248 void CCmConnectionMethodWrapper::CreateConnMethodToDestWithIdL(
       
   249         RCmManagerApi* aCmManagerApi,
       
   250         const TInt aDestHandle,
       
   251         const TUint32 aBearerType,
       
   252         const TUint32 aIapId )
       
   253     {
       
   254     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTWITHIDL_ENTRY );
       
   255 
       
   256     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   257         {
       
   258         User::Leave( KErrAlreadyExists );
       
   259         }
       
   260 
       
   261     iCmManagerApi = aCmManagerApi;
       
   262     iCmConnectionMethodApi.ConnectAndCreateConnMethodToDestWithIdL(
       
   263             *aCmManagerApi,
       
   264             aDestHandle,
       
   265             aBearerType,
       
   266             aIapId );
       
   267     iCmManagerApi->StoreConnMethodWrapper( this );
       
   268 
       
   269     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTWITHIDL_EXIT );
       
   270     }
       
   271 
       
   272 TInt CCmConnectionMethodWrapper::GetIntAttribute(
       
   273         const TUint32 aAttribute,
       
   274         TUint32& aValue )
       
   275     {
       
   276     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETINTATTRIBUTE_ENTRY );
       
   277 
       
   278     TInt err = iCmConnectionMethodApi.GetIntAttribute( aAttribute, aValue );
       
   279 
       
   280     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETINTATTRIBUTE_EXIT );
       
   281     return err;
       
   282     }
       
   283 
       
   284 TInt CCmConnectionMethodWrapper::GetBoolAttribute(
       
   285         const TUint32 aAttribute,
       
   286         TBool& aValue )
       
   287     {
       
   288     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETBOOLATTRIBUTE_ENTRY );
       
   289 
       
   290     TInt err = iCmConnectionMethodApi.GetBoolAttribute( aAttribute, aValue );
       
   291 
       
   292     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETBOOLATTRIBUTE_EXIT );
       
   293     return err;
       
   294     }
       
   295 
       
   296 TInt CCmConnectionMethodWrapper::GetStringAttribute(
       
   297         const TUint32 aAttribute,
       
   298         HBufC* aBuffer )
       
   299     {
       
   300     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETSTRINGATTRIBUTE_ENTRY );
       
   301 
       
   302     TInt err = iCmConnectionMethodApi.GetStringAttribute( aAttribute, aBuffer );
       
   303 
       
   304     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETSTRINGATTRIBUTE_EXIT );
       
   305     return err;
       
   306     }
       
   307 
       
   308 TInt CCmConnectionMethodWrapper::GetString8Attribute(
       
   309         const TUint32 aAttribute,
       
   310         HBufC8* aBuffer8 )
       
   311     {
       
   312     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETSTRING8ATTRIBUTE_ENTRY );
       
   313 
       
   314     TInt err = iCmConnectionMethodApi.GetString8Attribute( aAttribute, aBuffer8 );
       
   315 
       
   316     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETSTRING8ATTRIBUTE_EXIT );
       
   317     return err;
       
   318     }
       
   319 
       
   320 TInt CCmConnectionMethodWrapper::SetIntAttribute(
       
   321         const TUint32 aAttribute,
       
   322         const TUint32 aValue )
       
   323     {
       
   324     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETINTATTRIBUTE_ENTRY );
       
   325 
       
   326     TInt err = iCmConnectionMethodApi.SetIntAttribute( aAttribute, aValue );
       
   327 
       
   328     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETINTATTRIBUTE_EXIT );
       
   329     return err;
       
   330     }
       
   331 
       
   332 TInt CCmConnectionMethodWrapper::SetBoolAttribute(
       
   333         const TUint32 aAttribute,
       
   334         const TBool aValue )
       
   335     {
       
   336     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETBOOLATTRIBUTE_ENTRY );
       
   337 
       
   338     TInt err = iCmConnectionMethodApi.SetBoolAttribute( aAttribute, aValue );
       
   339 
       
   340     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETBOOLATTRIBUTE_EXIT );
       
   341     return err;
       
   342     }
       
   343 
       
   344 TInt CCmConnectionMethodWrapper::SetStringAttribute(
       
   345         const TUint32 aAttribute,
       
   346         const TDesC16& aValue )
       
   347     {
       
   348     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETSTRINGATTRIBUTE_ENTRY );
       
   349 
       
   350     TInt err = iCmConnectionMethodApi.SetStringAttribute( aAttribute, aValue );
       
   351 
       
   352     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETSTRINGATTRIBUTE_EXIT );
       
   353     return err;
       
   354     }
       
   355 
       
   356 TInt CCmConnectionMethodWrapper::SetString8Attribute(
       
   357         const TUint32 aAttribute,
       
   358         const TDesC8& aValue )
       
   359     {
       
   360     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETSTRING8ATTRIBUTE_ENTRY );
       
   361 
       
   362     TInt err = iCmConnectionMethodApi.SetString8Attribute( aAttribute, aValue );
       
   363 
       
   364     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETSTRING8ATTRIBUTE_EXIT );
       
   365     return err;
       
   366     }
       
   367 
       
   368 TInt CCmConnectionMethodWrapper::Update()
       
   369     {
       
   370     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_UPDATE_ENTRY );
       
   371 
       
   372     TInt result = iCmConnectionMethodApi.Update();
       
   373 
       
   374     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_UPDATE_EXIT );
       
   375     return result;
       
   376     }
       
   377 
       
   378 TInt CCmConnectionMethodWrapper::Refresh()
       
   379     {
       
   380     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_REFRESH_ENTRY );
       
   381 
       
   382     TInt result = iCmConnectionMethodApi.Refresh();
       
   383 
       
   384     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_REFRESH_EXIT );
       
   385     return result;
       
   386     }
       
   387 
       
   388 TInt CCmConnectionMethodWrapper::Delete( TBool& aResult )
       
   389     {
       
   390     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_DELETE_ENTRY );
       
   391 
       
   392     TInt err = iCmConnectionMethodApi.Delete( aResult );
       
   393 
       
   394     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_DELETE_EXIT );
       
   395     return err;
       
   396     }
       
   397 
       
   398 TInt CCmConnectionMethodWrapper::IsEqual( const TInt aHandle, TBool& aResult )
       
   399     {
       
   400     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_ISEQUAL_ENTRY );
       
   401 
       
   402     TInt err = iCmConnectionMethodApi.IsEqual( aHandle, aResult );
       
   403 
       
   404     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_ISEQUAL_EXIT );
       
   405     return err;
       
   406     }
       
   407 
       
   408 TBool CCmConnectionMethodWrapper::SessionConnected() const
       
   409     {
       
   410     return iCmConnectionMethodApi.SessionConnected();
       
   411     }
       
   412 
       
   413 void CCmConnectionMethodWrapper::CloseSession()
       
   414     {
       
   415     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CLOSESESSION_ENTRY );
       
   416     iCmConnectionMethodApi.Close();
       
   417     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CLOSESESSION_EXIT );
       
   418     }
       
   419 
       
   420 TInt CCmConnectionMethodWrapper::GetHandle() const
       
   421     {
       
   422     return iCmConnectionMethodApi.SubSessionHandle();
       
   423     }
       
   424 
       
   425 RCmManagerApi* CCmConnectionMethodWrapper::GetMainSession() const
       
   426     {
       
   427     return iCmManagerApi;
       
   428     }
       
   429 
       
   430 void CCmConnectionMethodWrapper::IncreaseReferenceCounter()
       
   431     {
       
   432     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_INCREASEREFERENCECOUNTER_ENTRY );
       
   433     iReferenceCounter++;
       
   434     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_INCREASEREFERENCECOUNTER_EXIT );
       
   435     }
       
   436 
       
   437 TInt CCmConnectionMethodWrapper::DecreaseReferenceCounter()
       
   438     {
       
   439     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_DECREASEREFERENCECOUNTER_ENTRY );
       
   440 
       
   441     iReferenceCounter--;
       
   442     if ( iReferenceCounter < 0 )
       
   443         {
       
   444         iReferenceCounter = 0;
       
   445         }
       
   446 
       
   447     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_DECREASEREFERENCECOUNTER_EXIT );
       
   448     return iReferenceCounter;
       
   449     }
       
   450 
       
   451 // End of file