cmmanager/cmmgr/cmmapi/src/cmdestinationwrapper.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 RCmDestination- and RCmDestinationExt-classes.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "cmdestinationwrapper.h"
       
    21 #include "cmmanagerapi.h"
       
    22 
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "cmdestinationwrapperTraces.h"
       
    26 #endif
       
    27 
       
    28 
       
    29 CCmDestinationWrapper* CCmDestinationWrapper::NewL()
       
    30     {
       
    31     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_NEWL_ENTRY );
       
    32 
       
    33     CCmDestinationWrapper* self = CCmDestinationWrapper::NewLC();
       
    34     CleanupStack::Pop( self );
       
    35 
       
    36     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_NEWL_EXIT );
       
    37     return self;
       
    38     }
       
    39 
       
    40 CCmDestinationWrapper* CCmDestinationWrapper::NewLC()
       
    41     {
       
    42     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_NEWLC_ENTRY );
       
    43 
       
    44     CCmDestinationWrapper* self = new (ELeave) CCmDestinationWrapper;
       
    45     CleanupStack::PushL( self );
       
    46 
       
    47     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_NEWLC_EXIT );
       
    48     return self;
       
    49     }
       
    50 
       
    51 CCmDestinationWrapper::~CCmDestinationWrapper()
       
    52     {
       
    53     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_CCMDESTINATIONWRAPPER_ENTRY );
       
    54 
       
    55     iCmDestinationApi.Close();
       
    56 
       
    57     if ( iCmManagerApi )
       
    58         {
       
    59         iCmManagerApi->RemoveDestinationWrapper( this );
       
    60         iCmManagerApi = NULL;
       
    61         }
       
    62 
       
    63     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_CCMDESTINATIONWRAPPER_EXIT );
       
    64     }
       
    65 
       
    66 CCmDestinationWrapper::CCmDestinationWrapper()
       
    67     {
       
    68     OstTraceFunctionEntry0( DUP1_CCMDESTINATIONWRAPPER_CCMDESTINATIONWRAPPER_ENTRY );
       
    69 
       
    70     iCmManagerApi = NULL;
       
    71     iReferenceCounter = 1;
       
    72 
       
    73     OstTraceFunctionExit0( DUP1_CCMDESTINATIONWRAPPER_CCMDESTINATIONWRAPPER_EXIT );
       
    74     }
       
    75 
       
    76 void CCmDestinationWrapper::GetDestWithIdL(
       
    77         RCmManagerApi* aCmManagerApi,
       
    78         const TUint32 aId,
       
    79         TInt& aExistingHandle )
       
    80     {
       
    81     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETDESTWITHIDL_ENTRY );
       
    82 
       
    83     if ( iCmManagerApi || iCmDestinationApi.SessionConnected() )
       
    84         {
       
    85         User::Leave( KErrAlreadyExists );
       
    86         }
       
    87 
       
    88     iCmManagerApi = aCmManagerApi;
       
    89     iCmDestinationApi.ConnectAndGetDestWithIdL( *aCmManagerApi, aId, aExistingHandle );
       
    90     if ( !aExistingHandle )
       
    91         {
       
    92         iCmManagerApi->StoreDestinationWrapper( this );
       
    93         }
       
    94 
       
    95     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETDESTWITHIDL_EXIT );
       
    96     }
       
    97 
       
    98 void CCmDestinationWrapper::CreateDestByNameL(
       
    99         RCmManagerApi* aCmManagerApi,
       
   100         const TDesC& aName )
       
   101     {
       
   102     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_CREATEDESTBYNAMEL_ENTRY );
       
   103 
       
   104     if ( iCmManagerApi || iCmDestinationApi.SessionConnected() )
       
   105         {
       
   106         User::Leave( KErrAlreadyExists );
       
   107         }
       
   108 
       
   109     iCmManagerApi = aCmManagerApi;
       
   110     iCmDestinationApi.ConnectAndCreateDestWithNameL( *aCmManagerApi, aName );
       
   111     iCmManagerApi->StoreDestinationWrapper( this );
       
   112 
       
   113     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_CREATEDESTBYNAMEL_EXIT );
       
   114     }
       
   115 
       
   116 void CCmDestinationWrapper::CreateDestByNameAndIdL(
       
   117         RCmManagerApi* aCmManagerApi,
       
   118         const TDesC& aName,
       
   119         const TUint32 aId )
       
   120     {
       
   121     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_CREATEDESTBYNAMEANDIDL_ENTRY );
       
   122 
       
   123     if ( iCmManagerApi || iCmDestinationApi.SessionConnected() )
       
   124         {
       
   125         User::Leave( KErrAlreadyExists );
       
   126         }
       
   127 
       
   128     iCmManagerApi = aCmManagerApi;
       
   129     iCmDestinationApi.ConnectAndCreateDestWithNameAndIdL( *aCmManagerApi, aName, aId );
       
   130     iCmManagerApi->StoreDestinationWrapper( this );
       
   131 
       
   132     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_CREATEDESTBYNAMEANDIDL_EXIT );
       
   133     }
       
   134 
       
   135 void CCmDestinationWrapper::GetConnMethodAsEmbeddedDestL(
       
   136         RCmManagerApi* aCmManagerApi,
       
   137         const TInt aConnMethodHandle,
       
   138         TInt& aExistingHandle )
       
   139     {
       
   140     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETCONNMETHODASEMBEDDEDDESTL_ENTRY );
       
   141 
       
   142     if ( iCmManagerApi || iCmDestinationApi.SessionConnected() )
       
   143         {
       
   144         User::Leave( KErrAlreadyExists );
       
   145         }
       
   146 
       
   147     iCmManagerApi = aCmManagerApi;
       
   148     iCmDestinationApi.ConnectAndGetConnMethodAsEmbeddedDestL(
       
   149             *aCmManagerApi,
       
   150             aConnMethodHandle,
       
   151             aExistingHandle );
       
   152     if ( !aExistingHandle )
       
   153         {
       
   154         iCmManagerApi->StoreDestinationWrapper( this );
       
   155         }
       
   156 
       
   157     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETCONNMETHODASEMBEDDEDDESTL_EXIT );
       
   158     }
       
   159 
       
   160 TInt CCmDestinationWrapper::ConnectionMethodCount( TInt& aCount )
       
   161     {
       
   162     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_CONNECTIONMETHODCOUNT_ENTRY );
       
   163 
       
   164     TInt err = iCmDestinationApi.ConnectionMethodCount( aCount );
       
   165 
       
   166     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_CONNECTIONMETHODCOUNT_EXIT );
       
   167     return err;
       
   168     }
       
   169 
       
   170 TInt CCmDestinationWrapper::Priority( const TInt aHandle, TUint& aPriority )
       
   171     {
       
   172     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_PRIORITY_ENTRY );
       
   173 
       
   174     TInt err = iCmDestinationApi.Priority( aHandle, aPriority );
       
   175 
       
   176     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_PRIORITY_EXIT );
       
   177     return err;
       
   178     }
       
   179 
       
   180 TInt CCmDestinationWrapper::GetName( HBufC* aBuffer )
       
   181     {
       
   182     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETNAME_ENTRY );
       
   183 
       
   184     TInt err = iCmDestinationApi.GetName( aBuffer );
       
   185 
       
   186     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETNAME_EXIT );
       
   187     return err;
       
   188     }
       
   189 
       
   190 TInt CCmDestinationWrapper::GetId( TUint32& aId )
       
   191     {
       
   192     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETID_ENTRY );
       
   193 
       
   194     TInt err = iCmDestinationApi.GetId( aId );
       
   195 
       
   196     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETID_EXIT );
       
   197     return err;
       
   198     }
       
   199 
       
   200 TInt CCmDestinationWrapper::GetElementId( TUint32& aElementId )
       
   201     {
       
   202     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETELEMENTID_ENTRY );
       
   203 
       
   204     TInt err = iCmDestinationApi.GetElementId( aElementId );
       
   205 
       
   206     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETELEMENTID_EXIT );
       
   207     return err;
       
   208     }
       
   209 
       
   210 TInt CCmDestinationWrapper::GetMetadata(
       
   211         const TUint32 aMetadataField,
       
   212         TUint32& aValue )
       
   213     {
       
   214     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETMETADATA_ENTRY );
       
   215 
       
   216     TInt err = iCmDestinationApi.GetMetadata( aMetadataField, aValue );
       
   217 
       
   218     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETMETADATA_EXIT );
       
   219     return err;
       
   220     }
       
   221 
       
   222 TInt CCmDestinationWrapper::GetProtectionLevel( TInt& aProtectionLevel )
       
   223     {
       
   224     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETPROTECTIONLEVEL_ENTRY );
       
   225 
       
   226     TInt err = iCmDestinationApi.GetProtectionLevel( aProtectionLevel );
       
   227 
       
   228     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETPROTECTIONLEVEL_EXIT );
       
   229     return err;
       
   230     }
       
   231 
       
   232 TInt CCmDestinationWrapper::AddConnectionMethod(
       
   233         const TInt aConnMethodHandle,
       
   234         TInt& aIndex )
       
   235     {
       
   236     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_ADDCONNECTIONMETHOD_ENTRY );
       
   237 
       
   238     TInt err = iCmDestinationApi.AddConnectionMethod( aConnMethodHandle, aIndex );
       
   239 
       
   240     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_ADDCONNECTIONMETHOD_EXIT );
       
   241     return err;
       
   242     }
       
   243 
       
   244 TInt CCmDestinationWrapper::AddEmbeddedDestination(
       
   245         const TInt aDestHandle,
       
   246         TInt& aIndex )
       
   247     {
       
   248     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_ADDEMBEDDEDDESTINATION_ENTRY );
       
   249 
       
   250     TInt err = iCmDestinationApi.AddEmbeddedDestination( aDestHandle, aIndex );
       
   251 
       
   252     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_ADDEMBEDDEDDESTINATION_EXIT );
       
   253     return err;
       
   254     }
       
   255 
       
   256 TInt CCmDestinationWrapper::DeleteConnectionMethod(
       
   257         const TInt aConnMethodHandle )
       
   258     {
       
   259     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_DELETECONNECTIONMETHOD_ENTRY );
       
   260 
       
   261     TInt err = iCmDestinationApi.DeleteConnectionMethod( aConnMethodHandle );
       
   262 
       
   263     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_DELETECONNECTIONMETHOD_EXIT );
       
   264     return err;
       
   265     }
       
   266 
       
   267 TInt CCmDestinationWrapper::RemoveConnectionMethod(
       
   268         const TInt aConnMethodHandle )
       
   269     {
       
   270     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_REMOVECONNECTIONMETHOD_ENTRY );
       
   271 
       
   272     TInt err = iCmDestinationApi.RemoveConnectionMethod( aConnMethodHandle );
       
   273 
       
   274     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_REMOVECONNECTIONMETHOD_EXIT );
       
   275     return err;
       
   276     }
       
   277 
       
   278 TInt CCmDestinationWrapper::ModifyPriority(
       
   279         const TInt aConnMethodHandle,
       
   280         const TUint aIndex )
       
   281     {
       
   282     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_MODIFYPRIORITY_ENTRY );
       
   283 
       
   284     TInt err = iCmDestinationApi.ModifyPriority( aConnMethodHandle, aIndex );
       
   285 
       
   286     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_MODIFYPRIORITY_EXIT );
       
   287     return err;
       
   288     }
       
   289 
       
   290 TInt CCmDestinationWrapper::SetName( const TDesC& aValue )
       
   291     {
       
   292     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_SETNAME_ENTRY );
       
   293 
       
   294     TInt err = iCmDestinationApi.SetName( aValue );
       
   295 
       
   296     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_SETNAME_EXIT );
       
   297     return err;
       
   298     }
       
   299 
       
   300 TInt CCmDestinationWrapper::SetMetadata(
       
   301         const TUint32 aMetaField,
       
   302         const TUint32 aValue )
       
   303     {
       
   304     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_SETMETADATA_ENTRY );
       
   305 
       
   306     TInt err = iCmDestinationApi.SetMetadata( aMetaField, aValue );
       
   307 
       
   308     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_SETMETADATA_EXIT );
       
   309     return err;
       
   310     }
       
   311 
       
   312 TInt CCmDestinationWrapper::SetProtection( const TInt aValue )
       
   313     {
       
   314     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_SETPROTECTION_ENTRY );
       
   315 
       
   316     TInt err = iCmDestinationApi.SetProtection( aValue );
       
   317 
       
   318     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_SETPROTECTION_EXIT );
       
   319     return err;
       
   320     }
       
   321 
       
   322 TInt CCmDestinationWrapper::SetHidden( const TBool aHidden )
       
   323     {
       
   324     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_SETHIDDEN_ENTRY );
       
   325 
       
   326     TInt err = iCmDestinationApi.SetHidden( aHidden );
       
   327 
       
   328     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_SETHIDDEN_EXIT );
       
   329     return err;
       
   330     }
       
   331 
       
   332 TInt CCmDestinationWrapper::Update()
       
   333     {
       
   334     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_UPDATE_ENTRY );
       
   335 
       
   336     TInt err = iCmDestinationApi.Update();
       
   337 
       
   338     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_UPDATE_EXIT );
       
   339     return err;
       
   340     }
       
   341 
       
   342 TInt CCmDestinationWrapper::Refresh()
       
   343     {
       
   344     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_REFRESH_ENTRY );
       
   345 
       
   346     TInt err = iCmDestinationApi.Refresh();
       
   347 
       
   348     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_REFRESH_EXIT );
       
   349     return err;
       
   350     }
       
   351 
       
   352 TInt CCmDestinationWrapper::Delete()
       
   353     {
       
   354     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_DELETE_ENTRY );
       
   355 
       
   356     TInt err = iCmDestinationApi.Delete();
       
   357 
       
   358     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_DELETE_EXIT );
       
   359     return err;
       
   360     }
       
   361 
       
   362 TInt CCmDestinationWrapper::IsConnected( TBool& aResult )
       
   363     {
       
   364     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_ISCONNECTED_ENTRY );
       
   365 
       
   366     TInt err = iCmDestinationApi.IsConnected( aResult );
       
   367 
       
   368     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_ISCONNECTED_EXIT );
       
   369     return err;
       
   370     }
       
   371 
       
   372 TInt CCmDestinationWrapper::IsHidden( TBool& aResult )
       
   373     {
       
   374     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_ISHIDDEN_ENTRY );
       
   375 
       
   376     TInt err = iCmDestinationApi.IsHidden( aResult );
       
   377 
       
   378     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_ISHIDDEN_EXIT );
       
   379     return err;
       
   380     }
       
   381 
       
   382 TInt CCmDestinationWrapper::IsEqual( const TInt aHandle, TBool& aResult )
       
   383     {
       
   384     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_ISEQUAL_ENTRY );
       
   385 
       
   386     TInt err = iCmDestinationApi.IsEqual( aHandle, aResult );
       
   387 
       
   388     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_ISEQUAL_EXIT );
       
   389     return err;
       
   390     }
       
   391 
       
   392 TInt CCmDestinationWrapper::GetIcon( HBufC* aBuffer )
       
   393     {
       
   394     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_GETICON_ENTRY );
       
   395 
       
   396     TInt err = iCmDestinationApi.GetIcon( aBuffer );
       
   397 
       
   398     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_GETICON_EXIT );
       
   399     return err;
       
   400     }
       
   401 
       
   402 TInt CCmDestinationWrapper::SetIcon( const TDesC& aValue)
       
   403     {
       
   404     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_SETICON_ENTRY );
       
   405 
       
   406     TInt err = iCmDestinationApi.SetIcon( aValue );
       
   407 
       
   408     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_SETICON_EXIT );
       
   409     return err;
       
   410     }
       
   411 
       
   412 TBool CCmDestinationWrapper::SessionConnected()
       
   413     {
       
   414     return iCmDestinationApi.SessionConnected();
       
   415     }
       
   416 
       
   417 void CCmDestinationWrapper::CloseSession()
       
   418     {
       
   419     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_CLOSESESSION_ENTRY );
       
   420     iCmDestinationApi.Close();
       
   421     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_CLOSESESSION_EXIT );
       
   422     }
       
   423 
       
   424 TInt CCmDestinationWrapper::GetHandle() const
       
   425     {
       
   426     return iCmDestinationApi.SubSessionHandle();
       
   427     }
       
   428 
       
   429 RCmManagerApi* CCmDestinationWrapper::GetMainSession() const
       
   430     {
       
   431     return iCmManagerApi;
       
   432     }
       
   433 
       
   434 void CCmDestinationWrapper::IncreaseReferenceCounter()
       
   435     {
       
   436     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_INCREASEREFERENCECOUNTER_ENTRY );
       
   437     iReferenceCounter++;
       
   438     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_INCREASEREFERENCECOUNTER_EXIT );
       
   439     }
       
   440 
       
   441 TInt CCmDestinationWrapper::DecreaseReferenceCounter()
       
   442     {
       
   443     OstTraceFunctionEntry0( CCMDESTINATIONWRAPPER_DECREASEREFERENCECOUNTER_ENTRY );
       
   444 
       
   445     iReferenceCounter--;
       
   446     if ( iReferenceCounter < 0 )
       
   447         {
       
   448         iReferenceCounter = 0;
       
   449         }
       
   450 
       
   451     OstTraceFunctionExit0( CCMDESTINATIONWRAPPER_DECREASEREFERENCECOUNTER_EXIT );
       
   452     return iReferenceCounter;
       
   453     }
       
   454 
       
   455 // End of file