cmmanager/cmmgr/cmmapi/src/cmconnectionmethodwrapper.cpp
changeset 20 9c97ad6591ae
child 40 c5b848e6c7d1
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     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( *aCmManagerApi, aIapId, aExistingHandle );
       
    91     if ( !aExistingHandle )
       
    92         {
       
    93         iCmManagerApi->StoreConnMethodWrapper( this );
       
    94         }
       
    95 
       
    96     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODWITHIDL_EXIT );
       
    97     }
       
    98 
       
    99 void CCmConnectionMethodWrapper::GetConnMethodFromDestWithIndexL(
       
   100         RCmManagerApi* aCmManagerApi,
       
   101         const TInt aDestHandle,
       
   102         const TInt aIndex,
       
   103         TInt& aExistingHandle )
       
   104     {
       
   105     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHINDEXL_ENTRY );
       
   106 
       
   107     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   108         {
       
   109         User::Leave( KErrAlreadyExists );
       
   110         }
       
   111 
       
   112     iCmManagerApi = aCmManagerApi;
       
   113     iCmConnectionMethodApi.ConnectAndGetConnMethodFromDestWithIndexL(
       
   114             *aCmManagerApi,
       
   115             aDestHandle,
       
   116             aIndex,
       
   117             aExistingHandle );
       
   118     if ( !aExistingHandle )
       
   119         {
       
   120         iCmManagerApi->StoreConnMethodWrapper( this );
       
   121         }
       
   122 
       
   123     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHINDEXL_EXIT );
       
   124     }
       
   125 
       
   126 void CCmConnectionMethodWrapper::GetConnMethodFromDestWithIdL(
       
   127         RCmManagerApi* aCmManagerApi,
       
   128         const TInt aDestHandle,
       
   129         const TInt aIapId,
       
   130         TInt& aExistingHandle )
       
   131     {
       
   132     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHIDL_ENTRY );
       
   133 
       
   134     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   135         {
       
   136         User::Leave( KErrAlreadyExists );
       
   137         }
       
   138 
       
   139     iCmManagerApi = aCmManagerApi;
       
   140     iCmConnectionMethodApi.ConnectAndGetConnMethodFromDestWithIdL(
       
   141             *aCmManagerApi,
       
   142             aDestHandle,
       
   143             aIapId,
       
   144             aExistingHandle );
       
   145     if ( !aExistingHandle )
       
   146         {
       
   147         iCmManagerApi->StoreConnMethodWrapper( this );
       
   148         }
       
   149 
       
   150     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETCONNMETHODFROMDESTWITHIDL_EXIT );
       
   151     }
       
   152 
       
   153 void CCmConnectionMethodWrapper::CreateConnMethodL(
       
   154         RCmManagerApi* aCmManagerApi,
       
   155         const TUint32 aBearerType )
       
   156     {
       
   157     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODL_ENTRY );
       
   158 
       
   159     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   160         {
       
   161         User::Leave( KErrAlreadyExists );
       
   162         }
       
   163 
       
   164     iCmManagerApi = aCmManagerApi;
       
   165     iCmConnectionMethodApi.ConnectAndCreateConnMethodL(
       
   166             *aCmManagerApi,
       
   167             aBearerType );
       
   168     iCmManagerApi->StoreConnMethodWrapper( this );
       
   169 
       
   170     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODL_EXIT );
       
   171     }
       
   172 
       
   173 void CCmConnectionMethodWrapper::CreateConnMethodWithIdL(
       
   174         RCmManagerApi* aCmManagerApi,
       
   175         const TUint32 aBearerType,
       
   176         const TUint32 aIapId )
       
   177     {
       
   178     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODWITHIDL_ENTRY );
       
   179 
       
   180     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   181         {
       
   182         User::Leave( KErrAlreadyExists );
       
   183         }
       
   184 
       
   185     iCmManagerApi = aCmManagerApi;
       
   186     iCmConnectionMethodApi.ConnectAndCreateConnMethodWithIdL(
       
   187             *aCmManagerApi,
       
   188             aBearerType,
       
   189             aIapId );
       
   190     iCmManagerApi->StoreConnMethodWrapper( this );
       
   191 
       
   192     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODWITHIDL_EXIT );
       
   193     }
       
   194 
       
   195 TInt CCmConnectionMethodWrapper::CreateConnMethodCopy(
       
   196         RCmManagerApi* aCmManagerApi,
       
   197         const TInt aConnMethodHandle )
       
   198     {
       
   199     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODCOPY_ENTRY );
       
   200 
       
   201     TInt err( KErrNone );
       
   202 
       
   203     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   204         {
       
   205         err = KErrAlreadyExists;
       
   206         }
       
   207     else
       
   208         {
       
   209         err = iCmConnectionMethodApi.ConnectAndCreateConnMethodCopy(
       
   210                 *aCmManagerApi,
       
   211                 aConnMethodHandle );
       
   212         if ( !err )
       
   213             {
       
   214             iCmManagerApi = aCmManagerApi;
       
   215             iCmManagerApi->StoreConnMethodWrapper( this );
       
   216             }
       
   217         }
       
   218 
       
   219     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODCOPY_EXIT );
       
   220     return err;
       
   221     }
       
   222 
       
   223 void CCmConnectionMethodWrapper::CreateConnMethodToDestL(
       
   224         RCmManagerApi* aCmManagerApi,
       
   225         const TInt aDestHandle,
       
   226         const TUint32 aBearerType )
       
   227     {
       
   228     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTL_ENTRY );
       
   229 
       
   230     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   231         {
       
   232         User::Leave( KErrAlreadyExists );
       
   233         }
       
   234 
       
   235     iCmManagerApi = aCmManagerApi;
       
   236     iCmConnectionMethodApi.ConnectAndCreateConnMethodToDestL(
       
   237             *aCmManagerApi,
       
   238             aDestHandle,
       
   239             aBearerType );
       
   240     iCmManagerApi->StoreConnMethodWrapper( this );
       
   241 
       
   242     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTL_EXIT );
       
   243     }
       
   244 
       
   245 void CCmConnectionMethodWrapper::CreateConnMethodToDestWithIdL(
       
   246         RCmManagerApi* aCmManagerApi,
       
   247         const TInt aDestHandle,
       
   248         const TUint32 aBearerType,
       
   249         const TUint32 aIapId )
       
   250     {
       
   251     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTWITHIDL_ENTRY );
       
   252 
       
   253     if ( iCmManagerApi || iCmConnectionMethodApi.SessionConnected() )
       
   254         {
       
   255         User::Leave( KErrAlreadyExists );
       
   256         }
       
   257 
       
   258     iCmManagerApi = aCmManagerApi;
       
   259     iCmConnectionMethodApi.ConnectAndCreateConnMethodToDestWithIdL(
       
   260             *aCmManagerApi,
       
   261             aDestHandle,
       
   262             aBearerType,
       
   263             aIapId );
       
   264     iCmManagerApi->StoreConnMethodWrapper( this );
       
   265 
       
   266     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CREATECONNMETHODFROMDESTWITHIDL_EXIT );
       
   267     }
       
   268 
       
   269 TInt CCmConnectionMethodWrapper::GetIntAttribute(
       
   270         const TUint32 aAttribute,
       
   271         TUint32& aValue )
       
   272     {
       
   273     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETINTATTRIBUTE_ENTRY );
       
   274 
       
   275     TInt err = iCmConnectionMethodApi.GetIntAttribute( aAttribute, aValue );
       
   276 
       
   277     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETINTATTRIBUTE_EXIT );
       
   278     return err;
       
   279     }
       
   280 
       
   281 TInt CCmConnectionMethodWrapper::GetBoolAttribute(
       
   282         const TUint32 aAttribute,
       
   283         TBool& aValue )
       
   284     {
       
   285     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETBOOLATTRIBUTE_ENTRY );
       
   286 
       
   287     TInt err = iCmConnectionMethodApi.GetBoolAttribute( aAttribute, aValue );
       
   288 
       
   289     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETBOOLATTRIBUTE_EXIT );
       
   290     return err;
       
   291     }
       
   292 
       
   293 TInt CCmConnectionMethodWrapper::GetStringAttribute(
       
   294         const TUint32 aAttribute,
       
   295         HBufC* aBuffer )
       
   296     {
       
   297     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETSTRINGATTRIBUTE_ENTRY );
       
   298 
       
   299     TInt err = iCmConnectionMethodApi.GetStringAttribute( aAttribute, aBuffer );
       
   300 
       
   301     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETSTRINGATTRIBUTE_EXIT );
       
   302     return err;
       
   303     }
       
   304 
       
   305 TInt CCmConnectionMethodWrapper::GetString8Attribute(
       
   306         const TUint32 aAttribute,
       
   307         HBufC8* aBuffer8 )
       
   308     {
       
   309     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_GETSTRING8ATTRIBUTE_ENTRY );
       
   310 
       
   311     TInt err = iCmConnectionMethodApi.GetString8Attribute( aAttribute, aBuffer8 );
       
   312 
       
   313     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_GETSTRING8ATTRIBUTE_EXIT );
       
   314     return err;
       
   315     }
       
   316 
       
   317 TInt CCmConnectionMethodWrapper::SetIntAttribute(
       
   318         const TUint32 aAttribute,
       
   319         const TUint32 aValue )
       
   320     {
       
   321     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETINTATTRIBUTE_ENTRY );
       
   322 
       
   323     TInt err = iCmConnectionMethodApi.SetIntAttribute( aAttribute, aValue );
       
   324 
       
   325     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETINTATTRIBUTE_EXIT );
       
   326     return err;
       
   327     }
       
   328 
       
   329 TInt CCmConnectionMethodWrapper::SetBoolAttribute(
       
   330         const TUint32 aAttribute,
       
   331         const TBool aValue )
       
   332     {
       
   333     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETBOOLATTRIBUTE_ENTRY );
       
   334 
       
   335     TInt err = iCmConnectionMethodApi.SetBoolAttribute( aAttribute, aValue );
       
   336 
       
   337     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETBOOLATTRIBUTE_EXIT );
       
   338     return err;
       
   339     }
       
   340 
       
   341 TInt CCmConnectionMethodWrapper::SetStringAttribute(
       
   342         const TUint32 aAttribute,
       
   343         const TDesC16& aValue )
       
   344     {
       
   345     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETSTRINGATTRIBUTE_ENTRY );
       
   346 
       
   347     TInt err = iCmConnectionMethodApi.SetStringAttribute( aAttribute, aValue );
       
   348 
       
   349     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETSTRINGATTRIBUTE_EXIT );
       
   350     return err;
       
   351     }
       
   352 
       
   353 TInt CCmConnectionMethodWrapper::SetString8Attribute(
       
   354         const TUint32 aAttribute,
       
   355         const TDesC8& aValue )
       
   356     {
       
   357     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_SETSTRING8ATTRIBUTE_ENTRY );
       
   358 
       
   359     TInt err = iCmConnectionMethodApi.SetString8Attribute( aAttribute, aValue );
       
   360 
       
   361     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_SETSTRING8ATTRIBUTE_EXIT );
       
   362     return err;
       
   363     }
       
   364 
       
   365 TInt CCmConnectionMethodWrapper::Update()
       
   366     {
       
   367     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_UPDATE_ENTRY );
       
   368 
       
   369     TInt result = iCmConnectionMethodApi.Update();
       
   370 
       
   371     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_UPDATE_EXIT );
       
   372     return result;
       
   373     }
       
   374 
       
   375 TInt CCmConnectionMethodWrapper::Refresh()
       
   376     {
       
   377     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_REFRESH_ENTRY );
       
   378 
       
   379     TInt result = iCmConnectionMethodApi.Refresh();
       
   380 
       
   381     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_REFRESH_EXIT );
       
   382     return result;
       
   383     }
       
   384 
       
   385 TInt CCmConnectionMethodWrapper::Delete( TBool& aResult )
       
   386     {
       
   387     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_DELETE_ENTRY );
       
   388 
       
   389     TInt err = iCmConnectionMethodApi.Delete( aResult );
       
   390 
       
   391     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_DELETE_EXIT );
       
   392     return err;
       
   393     }
       
   394 
       
   395 TInt CCmConnectionMethodWrapper::IsEqual( const TInt aHandle, TBool& aResult )
       
   396     {
       
   397     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_ISEQUAL_ENTRY );
       
   398 
       
   399     TInt err = iCmConnectionMethodApi.IsEqual( aHandle, aResult );
       
   400 
       
   401     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_ISEQUAL_EXIT );
       
   402     return err;
       
   403     }
       
   404 
       
   405 TBool CCmConnectionMethodWrapper::SessionConnected() const
       
   406     {
       
   407     return iCmConnectionMethodApi.SessionConnected();
       
   408     }
       
   409 
       
   410 void CCmConnectionMethodWrapper::CloseSession()
       
   411     {
       
   412     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_CLOSESESSION_ENTRY );
       
   413     iCmConnectionMethodApi.Close();
       
   414     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_CLOSESESSION_EXIT );
       
   415     }
       
   416 
       
   417 TInt CCmConnectionMethodWrapper::GetHandle() const
       
   418     {
       
   419     return iCmConnectionMethodApi.SubSessionHandle();
       
   420     }
       
   421 
       
   422 RCmManagerApi* CCmConnectionMethodWrapper::GetMainSession() const
       
   423     {
       
   424     return iCmManagerApi;
       
   425     }
       
   426 
       
   427 void CCmConnectionMethodWrapper::IncreaseReferenceCounter()
       
   428     {
       
   429     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_INCREASEREFERENCECOUNTER_ENTRY );
       
   430     iReferenceCounter++;
       
   431     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_INCREASEREFERENCECOUNTER_EXIT );
       
   432     }
       
   433 
       
   434 TInt CCmConnectionMethodWrapper::DecreaseReferenceCounter()
       
   435     {
       
   436     OstTraceFunctionEntry0( CCMCONNECTIONMETHODWRAPPER_DECREASEREFERENCECOUNTER_ENTRY );
       
   437 
       
   438     iReferenceCounter--;
       
   439     if ( iReferenceCounter < 0 )
       
   440         {
       
   441         iReferenceCounter = 0;
       
   442         }
       
   443 
       
   444     OstTraceFunctionExit0( CCMCONNECTIONMETHODWRAPPER_DECREASEREFERENCECOUNTER_EXIT );
       
   445     return iReferenceCounter;
       
   446     }
       
   447 
       
   448 // End of file