cmmanager/cmmgr/cmmapi/src/cmdestination.cpp
branchRCL_3
changeset 57 05bc53fe583b
equal deleted inserted replaced
55:fc7b30ed2058 57:05bc53fe583b
       
     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 RCmDestination.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <cmdestination.h>
       
    21 #include <cmconnectionmethod.h>
       
    22 
       
    23 #include "cmmserverdefs.h"
       
    24 #include "cmmanagerapi.h"
       
    25 #include "cmdestinationwrapper.h"
       
    26 #include "cmconnectionmethodwrapper.h"
       
    27 
       
    28 #include "OstTraceDefinitions.h"
       
    29 #ifdef OST_TRACE_COMPILER_IN_USE
       
    30 #include "cmdestinationTraces.h"
       
    31 #endif
       
    32 
       
    33 
       
    34 //-----------------------------------------------------------------------------
       
    35 //  RCmDestination::Close()
       
    36 //-----------------------------------------------------------------------------
       
    37 //
       
    38 EXPORT_C void RCmDestination::Close()
       
    39     {
       
    40     OstTraceFunctionEntry0( RCMDESTINATION_CLOSE_ENTRY );
       
    41 
       
    42     if ( iCmDestinationWrapper )
       
    43         {
       
    44         if ( iCmDestinationWrapper->DecreaseReferenceCounter() <= 0 )
       
    45             {
       
    46             delete iCmDestinationWrapper;
       
    47             }
       
    48         iCmDestinationWrapper = NULL;
       
    49         }
       
    50 
       
    51     OstTraceFunctionExit0( RCMDESTINATION_CLOSE_EXIT );
       
    52     }
       
    53 
       
    54 //-----------------------------------------------------------------------------
       
    55 //  RCmDestination::~RCmDestination()
       
    56 //-----------------------------------------------------------------------------
       
    57 //
       
    58 EXPORT_C RCmDestination::~RCmDestination()
       
    59     {
       
    60     OstTraceFunctionEntry0( RCMDESTINATION_RCMDESTINATION_ENTRY );
       
    61     Close();
       
    62     OstTraceFunctionExit0( RCMDESTINATION_RCMDESTINATION_EXIT );
       
    63     }
       
    64 
       
    65 //-----------------------------------------------------------------------------
       
    66 //  RCmDestination::RCmDestination()
       
    67 //-----------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C RCmDestination::RCmDestination(
       
    70         const RCmDestination& aDestination )
       
    71     {
       
    72     OstTraceFunctionEntry0( DUP1_RCMDESTINATION_RCMDESTINATION_ENTRY );
       
    73 
       
    74     this->iCmDestinationWrapper = aDestination.iCmDestinationWrapper;
       
    75     if ( iCmDestinationWrapper )
       
    76         {
       
    77         iCmDestinationWrapper->IncreaseReferenceCounter();
       
    78         }
       
    79 
       
    80     OstTraceFunctionExit0( DUP1_RCMDESTINATION_RCMDESTINATION_EXIT );
       
    81     }
       
    82 
       
    83 //-----------------------------------------------------------------------------
       
    84 //  RCmDestination::operator=()
       
    85 //-----------------------------------------------------------------------------
       
    86 //
       
    87 EXPORT_C RCmDestination& RCmDestination::operator=(
       
    88         const RCmDestination& aDestination )
       
    89     {
       
    90     OstTraceFunctionEntry0( RCMDESTINATION_OPERATOR_ENTRY );
       
    91 
       
    92     if ( this != &aDestination )
       
    93         {
       
    94         Close();
       
    95         this->iCmDestinationWrapper = aDestination.iCmDestinationWrapper;
       
    96         if ( iCmDestinationWrapper )
       
    97             {
       
    98             iCmDestinationWrapper->IncreaseReferenceCounter();
       
    99             }
       
   100         }
       
   101 
       
   102     OstTraceFunctionExit0( RCMDESTINATION_OPERATOR_EXIT );
       
   103     return *this;
       
   104     }
       
   105 
       
   106 //-----------------------------------------------------------------------------
       
   107 //  RCmDestination::ConnectionMethodCount()
       
   108 //-----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C TInt RCmDestination::ConnectionMethodCount() const
       
   111     {
       
   112     OstTraceFunctionEntry0( RCMDESTINATION_CONNECTIONMETHODCOUNT_ENTRY );
       
   113 
       
   114     __ASSERT_ALWAYS( iCmDestinationWrapper && iCmDestinationWrapper->SessionConnected(),
       
   115             User::Panic( KCmmPanicCategoryApi, EDestNotConnectedToServer ) );
       
   116 
       
   117     TInt value( 0 );
       
   118     TInt err = iCmDestinationWrapper->ConnectionMethodCount( value );
       
   119 
       
   120     if ( err )
       
   121         {
       
   122         value = 0;
       
   123         }
       
   124 
       
   125     OstTraceFunctionExit0( RCMDESTINATION_CONNECTIONMETHODCOUNT_EXIT );
       
   126     return value;
       
   127     }
       
   128 
       
   129 //-----------------------------------------------------------------------------
       
   130 //  RCmDestination::ConnectionMethodL()
       
   131 //-----------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C RCmConnectionMethod RCmDestination::ConnectionMethodL(
       
   134         TInt aIndex ) const
       
   135     {
       
   136     OstTraceFunctionEntry0( RCMDESTINATION_CONNECTIONMETHODL_ENTRY );
       
   137 
       
   138     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   139         {
       
   140         User::Leave( KErrBadHandle );
       
   141         }
       
   142 
       
   143     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   144     TInt destHandle = iCmDestinationWrapper->GetHandle();
       
   145     TInt existingHandle( 0 );
       
   146     cmWrapper->GetConnMethodFromDestWithIndexL(
       
   147             iCmDestinationWrapper->GetMainSession(),
       
   148             destHandle,
       
   149             aIndex,
       
   150             existingHandle );
       
   151     if ( existingHandle )
       
   152         {
       
   153         CleanupStack::PopAndDestroy( cmWrapper );
       
   154         cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL(
       
   155                 existingHandle );
       
   156         cmWrapper->IncreaseReferenceCounter();
       
   157         }
       
   158     else
       
   159         {
       
   160         CleanupStack::Pop( cmWrapper );
       
   161         }
       
   162 
       
   163     RCmConnectionMethod cm;
       
   164     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   165 
       
   166     OstTraceFunctionExit0( RCMDESTINATION_CONNECTIONMETHODL_EXIT );
       
   167     return cm;
       
   168     }
       
   169 
       
   170 //-----------------------------------------------------------------------------
       
   171 //  RCmDestination::ConnectionMethodByIDL()
       
   172 //-----------------------------------------------------------------------------
       
   173 //
       
   174 EXPORT_C RCmConnectionMethod RCmDestination::ConnectionMethodByIDL(
       
   175         TInt aConnMethodId ) const
       
   176     {
       
   177     OstTraceFunctionEntry0( RCMDESTINATION_CONNECTIONMETHODBYIDL_ENTRY );
       
   178 
       
   179     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   180         {
       
   181         User::Leave( KErrBadHandle );
       
   182         }
       
   183 
       
   184     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   185     TInt destHandle = iCmDestinationWrapper->GetHandle();
       
   186     TInt existingHandle( 0 );
       
   187     cmWrapper->GetConnMethodFromDestWithIdL(
       
   188             iCmDestinationWrapper->GetMainSession(),
       
   189             destHandle,
       
   190             aConnMethodId,
       
   191             existingHandle );
       
   192     if ( existingHandle )
       
   193         {
       
   194         CleanupStack::PopAndDestroy( cmWrapper );
       
   195         cmWrapper = iCmDestinationWrapper->GetMainSession()->GetConnMethodWrapperL(
       
   196                 existingHandle );
       
   197         cmWrapper->IncreaseReferenceCounter();
       
   198         }
       
   199     else
       
   200         {
       
   201         CleanupStack::Pop( cmWrapper );
       
   202         }
       
   203 
       
   204     RCmConnectionMethod cm;
       
   205     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   206 
       
   207     OstTraceFunctionExit0( RCMDESTINATION_CONNECTIONMETHODBYIDL_EXIT );
       
   208     return cm;
       
   209     }
       
   210 
       
   211 //-----------------------------------------------------------------------------
       
   212 //  RCmDestination::PriorityL()
       
   213 //-----------------------------------------------------------------------------
       
   214 //
       
   215 EXPORT_C TUint RCmDestination::PriorityL(
       
   216         const RCmConnectionMethod& aConnectionMethod ) const
       
   217     {
       
   218     OstTraceFunctionEntry0( RCMDESTINATION_PRIORITYL_ENTRY );
       
   219 
       
   220     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   221         {
       
   222         User::Leave( KErrBadHandle );
       
   223         }
       
   224     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   225             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   226         {
       
   227         User::Leave( KErrArgument );
       
   228         }
       
   229 
       
   230     TUint priority( 0 );
       
   231     TInt handle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   232     TInt err = iCmDestinationWrapper->Priority( handle, priority );
       
   233     User::LeaveIfError( err );
       
   234 
       
   235     OstTraceFunctionExit0( RCMDESTINATION_PRIORITYL_EXIT );
       
   236     return priority;
       
   237     }
       
   238 
       
   239 //-----------------------------------------------------------------------------
       
   240 //  RCmDestination::NameLC()
       
   241 //-----------------------------------------------------------------------------
       
   242 //
       
   243 EXPORT_C HBufC* RCmDestination::NameLC() const
       
   244     {
       
   245     OstTraceFunctionEntry0( RCMDESTINATION_NAMELC_ENTRY );
       
   246 
       
   247     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   248         {
       
   249         User::Leave( KErrBadHandle );
       
   250         }
       
   251 
       
   252     HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
       
   253     TInt err = iCmDestinationWrapper->GetName( buffer );
       
   254     User::LeaveIfError( err );
       
   255     // Leave buffer in cleanup stack.
       
   256 
       
   257     OstTraceFunctionExit0( RCMDESTINATION_NAMELC_EXIT );
       
   258     return buffer;
       
   259     }
       
   260 
       
   261 //-----------------------------------------------------------------------------
       
   262 //  RCmDestination::Id()
       
   263 //-----------------------------------------------------------------------------
       
   264 //
       
   265 EXPORT_C TUint32 RCmDestination::Id() const
       
   266     {
       
   267     OstTraceFunctionEntry0( RCMDESTINATION_ID_ENTRY );
       
   268 
       
   269     __ASSERT_ALWAYS( iCmDestinationWrapper && iCmDestinationWrapper->SessionConnected(),
       
   270             User::Panic( KCmmPanicCategoryApi, EDestNotConnectedToServer ) );
       
   271 
       
   272     TUint32 id( 0 );
       
   273     TInt err = iCmDestinationWrapper->GetId( id );
       
   274 
       
   275     if ( err )
       
   276         {
       
   277         id = 0;
       
   278         }
       
   279 
       
   280     OstTraceFunctionExit0( RCMDESTINATION_ID_EXIT );
       
   281     return id;
       
   282     }
       
   283 
       
   284 //-----------------------------------------------------------------------------
       
   285 //  RCmDestination::ElementId()
       
   286 //-----------------------------------------------------------------------------
       
   287 //
       
   288 EXPORT_C TUint32 RCmDestination::ElementId() const
       
   289     {
       
   290     OstTraceFunctionEntry0( RCMDESTINATION_ELEMENTID_ENTRY );
       
   291 
       
   292     __ASSERT_ALWAYS( iCmDestinationWrapper && iCmDestinationWrapper->SessionConnected(),
       
   293             User::Panic( KCmmPanicCategoryApi, EDestNotConnectedToServer ) );
       
   294 
       
   295     TUint32 elementId( 0 );
       
   296     TInt err = iCmDestinationWrapper->GetElementId( elementId );
       
   297 
       
   298     if ( err )
       
   299         {
       
   300         elementId = 0;
       
   301         }
       
   302 
       
   303     OstTraceFunctionExit0( RCMDESTINATION_ELEMENTID_EXIT );
       
   304     return elementId;
       
   305     }
       
   306 
       
   307 //-----------------------------------------------------------------------------
       
   308 //  RCmDestination::MetadataL()
       
   309 //-----------------------------------------------------------------------------
       
   310 //
       
   311 EXPORT_C TUint32 RCmDestination::MetadataL(
       
   312         CMManager::TSnapMetadataField aMetadataField ) const
       
   313     {
       
   314     OstTraceFunctionEntry0( RCMDESTINATION_METADATAL_ENTRY );
       
   315 
       
   316     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   317         {
       
   318         User::Leave( KErrBadHandle );
       
   319         }
       
   320 
       
   321     TUint32 value( 0 );
       
   322     TInt err = iCmDestinationWrapper->GetMetadata( aMetadataField, value );
       
   323     User::LeaveIfError( err );
       
   324 
       
   325     OstTraceFunctionExit0( RCMDESTINATION_METADATAL_EXIT );
       
   326     return value;
       
   327     }
       
   328 
       
   329 //-----------------------------------------------------------------------------
       
   330 //  RCmDestination::ProtectionLevel()
       
   331 //-----------------------------------------------------------------------------
       
   332 //
       
   333 EXPORT_C CMManager::TProtectionLevel RCmDestination::ProtectionLevel() const
       
   334     {
       
   335     OstTraceFunctionEntry0( RCMDESTINATION_PROTECTIONLEVEL_ENTRY );
       
   336 
       
   337     __ASSERT_ALWAYS( iCmDestinationWrapper && iCmDestinationWrapper->SessionConnected(),
       
   338             User::Panic( KCmmPanicCategoryApi, EDestNotConnectedToServer ) );
       
   339 
       
   340     TInt protectionLevel( CMManager::EProtLevel0 );
       
   341     TInt err = iCmDestinationWrapper->GetProtectionLevel( protectionLevel );
       
   342 
       
   343     if ( err )
       
   344         {
       
   345         protectionLevel = CMManager::EProtLevel0;
       
   346         }
       
   347 
       
   348     OstTraceFunctionExit0( RCMDESTINATION_PROTECTIONLEVEL_EXIT );
       
   349     return ( CMManager::TProtectionLevel )protectionLevel;
       
   350     }
       
   351 
       
   352 //-----------------------------------------------------------------------------
       
   353 //  RCmDestination::IsHidden()
       
   354 //-----------------------------------------------------------------------------
       
   355 //
       
   356 EXPORT_C TBool RCmDestination::IsHidden() const
       
   357     {
       
   358     OstTraceFunctionEntry0( RCMDESTINATION_ISHIDDEN_ENTRY );
       
   359 
       
   360     __ASSERT_ALWAYS( iCmDestinationWrapper && iCmDestinationWrapper->SessionConnected(),
       
   361             User::Panic( KCmmPanicCategoryApi, EDestNotConnectedToServer ) );
       
   362 
       
   363     TBool value( EFalse );
       
   364     TInt err = iCmDestinationWrapper->IsHidden( value );
       
   365 
       
   366     if ( err )
       
   367         {
       
   368         value = EFalse;
       
   369         }
       
   370 
       
   371     OstTraceFunctionExit0( RCMDESTINATION_ISHIDDEN_EXIT );
       
   372     return value;
       
   373     }
       
   374 
       
   375 //-----------------------------------------------------------------------------
       
   376 //  RCmDestination::CreateConnectionMethodL()
       
   377 //-----------------------------------------------------------------------------
       
   378 //
       
   379 EXPORT_C RCmConnectionMethod RCmDestination::CreateConnectionMethodL(
       
   380         TUint32 aBearerType )
       
   381     {
       
   382     OstTraceFunctionEntry0( RCMDESTINATION_CREATECONNECTIONMETHODL_ENTRY );
       
   383 
       
   384     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   385         {
       
   386         User::Leave( KErrBadHandle );
       
   387         }
       
   388 
       
   389     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   390     TInt destHandle = iCmDestinationWrapper->GetHandle();
       
   391     cmWrapper->CreateConnMethodToDestL(
       
   392             iCmDestinationWrapper->GetMainSession(),
       
   393             destHandle,
       
   394             aBearerType );
       
   395     CleanupStack::Pop( cmWrapper );
       
   396 
       
   397     RCmConnectionMethod cm;
       
   398     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   399 
       
   400     OstTraceFunctionExit0( RCMDESTINATION_CREATECONNECTIONMETHODL_EXIT );
       
   401     return cm;
       
   402     }
       
   403 
       
   404 //-----------------------------------------------------------------------------
       
   405 //  RCmDestination::CreateConnectionMethodL()
       
   406 //-----------------------------------------------------------------------------
       
   407 //
       
   408 EXPORT_C RCmConnectionMethod RCmDestination::CreateConnectionMethodL(
       
   409         TUint32 aBearerType,
       
   410         TUint32 aConnMethodId )
       
   411     {
       
   412     OstTraceFunctionEntry0( DUP1_RCMDESTINATION_CREATECONNECTIONMETHODL_ENTRY );
       
   413 
       
   414     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   415         {
       
   416         User::Leave( KErrBadHandle );
       
   417         }
       
   418 
       
   419     CCmConnectionMethodWrapper* cmWrapper = CCmConnectionMethodWrapper::NewLC();
       
   420     TInt destHandle = iCmDestinationWrapper->GetHandle();
       
   421     cmWrapper->CreateConnMethodToDestWithIdL(
       
   422             iCmDestinationWrapper->GetMainSession(),
       
   423             destHandle,
       
   424             aBearerType,
       
   425             aConnMethodId );
       
   426     CleanupStack::Pop( cmWrapper );
       
   427 
       
   428     RCmConnectionMethod cm;
       
   429     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   430 
       
   431     OstTraceFunctionExit0( DUP1_RCMDESTINATION_CREATECONNECTIONMETHODL_EXIT );
       
   432     return cm;
       
   433     }
       
   434 
       
   435 //-----------------------------------------------------------------------------
       
   436 //  RCmDestination::AddConnectionMethodL()
       
   437 //-----------------------------------------------------------------------------
       
   438 //
       
   439 EXPORT_C TInt RCmDestination::AddConnectionMethodL(
       
   440         RCmConnectionMethod aConnectionMethod )
       
   441     {
       
   442     OstTraceFunctionEntry0( RCMDESTINATION_ADDCONNECTIONMETHODL_ENTRY );
       
   443 
       
   444     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   445         {
       
   446         User::Leave( KErrBadHandle );
       
   447         }
       
   448     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   449             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   450         {
       
   451         User::Leave( KErrArgument );
       
   452         }
       
   453 
       
   454     TInt index( 0 );
       
   455     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   456     TInt err = iCmDestinationWrapper->AddConnectionMethod( connMethodHandle, index );
       
   457     User::LeaveIfError( err );
       
   458 
       
   459     OstTraceFunctionExit0( RCMDESTINATION_ADDCONNECTIONMETHODL_EXIT );
       
   460     return index;
       
   461     }
       
   462 
       
   463 //-----------------------------------------------------------------------------
       
   464 //  RCmDestination::AddEmbeddedDestinationL()
       
   465 //-----------------------------------------------------------------------------
       
   466 //
       
   467 EXPORT_C TInt RCmDestination::AddEmbeddedDestinationL(
       
   468         const RCmDestination& aDestination )
       
   469     {
       
   470     OstTraceFunctionEntry0( RCMDESTINATION_ADDEMBEDDEDDESTINATIONL_ENTRY );
       
   471 
       
   472     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   473         {
       
   474         User::Leave( KErrBadHandle );
       
   475         }
       
   476     if ( iCmDestinationWrapper == aDestination.iCmDestinationWrapper )
       
   477         {
       
   478         User::Leave( KErrArgument );
       
   479         }
       
   480     if ( !aDestination.iCmDestinationWrapper ||
       
   481             !aDestination.iCmDestinationWrapper->SessionConnected() )
       
   482         {
       
   483         User::Leave( KErrArgument );
       
   484         }
       
   485 
       
   486     TInt index( 0 );
       
   487     TInt destinationHandle = aDestination.iCmDestinationWrapper->GetHandle();
       
   488     TInt err = iCmDestinationWrapper->AddEmbeddedDestination( destinationHandle, index );
       
   489     User::LeaveIfError( err );
       
   490 
       
   491     OstTraceFunctionExit0( RCMDESTINATION_ADDEMBEDDEDDESTINATIONL_EXIT );
       
   492     return index;
       
   493     }
       
   494 
       
   495 //-----------------------------------------------------------------------------
       
   496 //  RCmDestination::DeleteConnectionMethodL()
       
   497 //-----------------------------------------------------------------------------
       
   498 //
       
   499 EXPORT_C void RCmDestination::DeleteConnectionMethodL(
       
   500         RCmConnectionMethod& aConnectionMethod )
       
   501     {
       
   502     OstTraceFunctionEntry0( RCMDESTINATION_DELETECONNECTIONMETHODL_ENTRY );
       
   503 
       
   504     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   505         {
       
   506         User::Leave( KErrBadHandle );
       
   507         }
       
   508     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   509             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   510         {
       
   511         User::Leave( KErrArgument );
       
   512         }
       
   513 
       
   514     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   515     TInt err = iCmDestinationWrapper->DeleteConnectionMethod( connMethodHandle );
       
   516     User::LeaveIfError( err );
       
   517 
       
   518     OstTraceFunctionExit0( RCMDESTINATION_DELETECONNECTIONMETHODL_EXIT );
       
   519     }
       
   520 
       
   521 //-----------------------------------------------------------------------------
       
   522 //  RCmDestination::RemoveConnectionMethodL()
       
   523 //-----------------------------------------------------------------------------
       
   524 //
       
   525 EXPORT_C void RCmDestination::RemoveConnectionMethodL(
       
   526         RCmConnectionMethod aConnectionMethod )
       
   527     {
       
   528     OstTraceFunctionEntry0( RCMDESTINATION_REMOVECONNECTIONMETHODL_ENTRY );
       
   529 
       
   530     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   531         {
       
   532         User::Leave( KErrBadHandle );
       
   533         }
       
   534     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   535             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   536         {
       
   537         User::Leave( KErrArgument );
       
   538         }
       
   539 
       
   540     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   541     TInt err = iCmDestinationWrapper->RemoveConnectionMethod( connMethodHandle );
       
   542     User::LeaveIfError( err );
       
   543 
       
   544     OstTraceFunctionExit0( RCMDESTINATION_REMOVECONNECTIONMETHODL_EXIT );
       
   545     }
       
   546 
       
   547 //-----------------------------------------------------------------------------
       
   548 //  RCmDestination::ModifyPriorityL()
       
   549 //-----------------------------------------------------------------------------
       
   550 //
       
   551 EXPORT_C void RCmDestination::ModifyPriorityL(
       
   552         RCmConnectionMethod& aConnectionMethod,
       
   553         TUint aIndex )
       
   554     {
       
   555     OstTraceFunctionEntry0( RCMDESTINATION_MODIFYPRIORITYL_ENTRY );
       
   556 
       
   557     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   558         {
       
   559         User::Leave( KErrBadHandle );
       
   560         }
       
   561     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   562             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   563         {
       
   564         User::Leave( KErrArgument );
       
   565         }
       
   566 
       
   567     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   568     TInt err = iCmDestinationWrapper->ModifyPriority( connMethodHandle, aIndex );
       
   569     User::LeaveIfError( err );
       
   570 
       
   571     OstTraceFunctionExit0( RCMDESTINATION_MODIFYPRIORITYL_EXIT );
       
   572     }
       
   573 
       
   574 //-----------------------------------------------------------------------------
       
   575 //  RCmDestination::SetNameL()
       
   576 //-----------------------------------------------------------------------------
       
   577 //
       
   578 EXPORT_C void RCmDestination::SetNameL( const TDesC& aName )
       
   579     {
       
   580     OstTraceFunctionEntry0( RCMDESTINATION_SETNAMEL_ENTRY );
       
   581 
       
   582     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   583         {
       
   584         User::Leave( KErrBadHandle );
       
   585         }
       
   586 
       
   587     TInt err = iCmDestinationWrapper->SetName( aName );
       
   588     User::LeaveIfError( err );
       
   589 
       
   590     OstTraceFunctionExit0( RCMDESTINATION_SETNAMEL_EXIT );
       
   591     }
       
   592 
       
   593 //-----------------------------------------------------------------------------
       
   594 //  RCmDestination::SetMetadataL()
       
   595 //-----------------------------------------------------------------------------
       
   596 //
       
   597 EXPORT_C void RCmDestination::SetMetadataL(
       
   598         CMManager::TSnapMetadataField aMetadataField,
       
   599         TUint32 aValue )
       
   600     {
       
   601     OstTraceFunctionEntry0( RCMDESTINATION_SETMETADATAL_ENTRY );
       
   602 
       
   603     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   604         {
       
   605         User::Leave( KErrBadHandle );
       
   606         }
       
   607 
       
   608     TInt err = iCmDestinationWrapper->SetMetadata( aMetadataField, aValue );
       
   609     User::LeaveIfError( err );
       
   610 
       
   611     OstTraceFunctionExit0( RCMDESTINATION_SETMETADATAL_EXIT );
       
   612     }
       
   613 
       
   614 //-----------------------------------------------------------------------------
       
   615 //  RCmDestination::SetProtectionL()
       
   616 //-----------------------------------------------------------------------------
       
   617 //
       
   618 EXPORT_C void RCmDestination::SetProtectionL( CMManager::TProtectionLevel aProtLevel )
       
   619     {
       
   620     OstTraceFunctionEntry0( RCMDESTINATION_SETPROTECTIONL_ENTRY );
       
   621 
       
   622     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   623         {
       
   624         User::Leave( KErrBadHandle );
       
   625         }
       
   626 
       
   627     TInt err = iCmDestinationWrapper->SetProtection( aProtLevel );
       
   628     User::LeaveIfError( err );
       
   629 
       
   630     OstTraceFunctionExit0( RCMDESTINATION_SETPROTECTIONL_EXIT );
       
   631     }
       
   632 
       
   633 //-----------------------------------------------------------------------------
       
   634 //  RCmDestination::SetHiddenL()
       
   635 //-----------------------------------------------------------------------------
       
   636 //
       
   637 EXPORT_C void RCmDestination::SetHiddenL( TBool aHidden )
       
   638     {
       
   639     OstTraceFunctionEntry0( RCMDESTINATION_SETHIDDENL_ENTRY );
       
   640 
       
   641     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   642         {
       
   643         User::Leave( KErrBadHandle );
       
   644         }
       
   645 
       
   646     TInt err = iCmDestinationWrapper->SetHidden( aHidden );
       
   647     User::LeaveIfError( err );
       
   648 
       
   649     OstTraceFunctionExit0( RCMDESTINATION_SETHIDDENL_EXIT );
       
   650     }
       
   651 
       
   652 //-----------------------------------------------------------------------------
       
   653 //  RCmDestination::UpdateL()
       
   654 //-----------------------------------------------------------------------------
       
   655 //
       
   656 EXPORT_C void RCmDestination::UpdateL()
       
   657     {
       
   658     OstTraceFunctionEntry0( RCMDESTINATION_UPDATEL_ENTRY );
       
   659 
       
   660     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   661         {
       
   662         User::Leave( KErrBadHandle );
       
   663         }
       
   664 
       
   665     TInt err = iCmDestinationWrapper->Update();
       
   666     User::LeaveIfError( err );
       
   667 
       
   668     OstTraceFunctionExit0( RCMDESTINATION_UPDATEL_EXIT );
       
   669     }
       
   670 
       
   671 //-----------------------------------------------------------------------------
       
   672 //  RCmDestination::DeleteLD()
       
   673 //-----------------------------------------------------------------------------
       
   674 //
       
   675 EXPORT_C void RCmDestination::DeleteLD()
       
   676     {
       
   677     OstTraceFunctionEntry0( RCMDESTINATION_DELETELD_ENTRY );
       
   678 
       
   679     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   680         {
       
   681         User::Leave( KErrBadHandle );
       
   682         }
       
   683 
       
   684     TInt err = iCmDestinationWrapper->Delete();
       
   685     User::LeaveIfError( err );
       
   686 
       
   687     // Instead of calling Close(), we need to force this handle closed even if
       
   688     // copies have been made. So we delete the destination wrapper directly.
       
   689     delete iCmDestinationWrapper;
       
   690     iCmDestinationWrapper = NULL;
       
   691 
       
   692     OstTraceFunctionExit0( RCMDESTINATION_DELETELD_EXIT );
       
   693     }
       
   694 
       
   695 //-----------------------------------------------------------------------------
       
   696 //  RCmDestination::IsConnectedL()
       
   697 //-----------------------------------------------------------------------------
       
   698 //
       
   699 EXPORT_C TBool RCmDestination::IsConnectedL() const
       
   700     {
       
   701     OstTraceFunctionEntry0( RCMDESTINATION_ISCONNECTEDL_ENTRY );
       
   702 
       
   703     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   704         {
       
   705         User::Leave( KErrBadHandle );
       
   706         }
       
   707 
       
   708     TBool value( 0 );
       
   709     TInt err = iCmDestinationWrapper->IsConnected( value );
       
   710     User::LeaveIfError( err );
       
   711 
       
   712     OstTraceFunctionExit0( RCMDESTINATION_ISCONNECTEDL_EXIT );
       
   713     return value;
       
   714     }
       
   715 
       
   716 //-----------------------------------------------------------------------------
       
   717 //  RCmDestination::RCmDestination()
       
   718 //-----------------------------------------------------------------------------
       
   719 //
       
   720 EXPORT_C RCmDestination::RCmDestination() : iCmDestinationWrapper( NULL )
       
   721     {
       
   722     OstTraceFunctionEntry0( DUP2_RCMDESTINATION_RCMDESTINATION_ENTRY );
       
   723     OstTraceFunctionExit0( DUP2_RCMDESTINATION_RCMDESTINATION_EXIT );
       
   724     }
       
   725 
       
   726 //-----------------------------------------------------------------------------
       
   727 //  RCmDestination::operator==()
       
   728 //-----------------------------------------------------------------------------
       
   729 //
       
   730 EXPORT_C TBool RCmDestination::operator==(
       
   731         const RCmDestination& aDestination ) const
       
   732     {
       
   733     OstTraceFunctionEntry0( DUP1_RCMDESTINATION_OPERATOR_ENTRY );
       
   734 
       
   735     TBool result( EFalse );
       
   736     if ( !aDestination.iCmDestinationWrapper )
       
   737         {
       
   738         if ( !iCmDestinationWrapper )
       
   739             {
       
   740             result = ETrue; // Both empty.
       
   741             }
       
   742         else
       
   743             {
       
   744             result = EFalse;
       
   745             }
       
   746         }
       
   747     else if ( !iCmDestinationWrapper )
       
   748         {
       
   749         result = EFalse;
       
   750         }
       
   751     else
       
   752         {
       
   753         // Both destination objects have wrappers.
       
   754 
       
   755         if ( !iCmDestinationWrapper->SessionConnected() ||
       
   756                 !aDestination.iCmDestinationWrapper->SessionConnected() )
       
   757             {
       
   758             result = EFalse;
       
   759             }
       
   760         else
       
   761             {
       
   762             // Both destination objects are connected to server.
       
   763 
       
   764             TInt handle = aDestination.iCmDestinationWrapper->GetHandle();
       
   765             TInt err = iCmDestinationWrapper->IsEqual( handle, result );
       
   766             if ( err )
       
   767                 {
       
   768                 result = EFalse;
       
   769                 }
       
   770             }
       
   771         }
       
   772 
       
   773     OstTraceFunctionExit0( DUP1_RCMDESTINATION_OPERATOR_EXIT );
       
   774     return result;
       
   775     }
       
   776 
       
   777 //-----------------------------------------------------------------------------
       
   778 //
       
   779 //-----------------------------------------------------------------------------
       
   780 //
       
   781 EXPORT_C TBool RCmDestination::operator!=(
       
   782         const RCmDestination& aDestination ) const
       
   783     {
       
   784     OstTraceFunctionEntry0( DUP2_RCMDESTINATION_OPERATOR_ENTRY );
       
   785 
       
   786     TBool result = !( operator==( aDestination ) );
       
   787 
       
   788     OstTraceFunctionExit0( DUP2_RCMDESTINATION_OPERATOR_EXIT );
       
   789     return result;
       
   790     }
       
   791 
       
   792 //-----------------------------------------------------------------------------
       
   793 //  RCmDestination::GetIconL()
       
   794 //-----------------------------------------------------------------------------
       
   795 //
       
   796 EXPORT_C HBufC* RCmDestination::GetIconL() const
       
   797     {
       
   798     OstTraceFunctionEntry0( RCMDESTINATION_GETICONL_ENTRY );
       
   799 
       
   800     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   801         {
       
   802         User::Leave( KErrBadHandle );
       
   803         }
       
   804 
       
   805     HBufC* buffer = HBufC::NewLC( KCmmStringLengthMax );
       
   806     TInt err = iCmDestinationWrapper->GetIcon( buffer );
       
   807     User::LeaveIfError( err );
       
   808 
       
   809     if ( buffer->Length() > 0 )
       
   810         {
       
   811         CleanupStack::Pop( buffer );
       
   812         }
       
   813     else
       
   814         {
       
   815         CleanupStack::PopAndDestroy( buffer );
       
   816         buffer = KNullDesC().AllocL();
       
   817         }
       
   818 
       
   819     OstTraceFunctionExit0( RCMDESTINATION_GETICONL_EXIT );
       
   820     return buffer;
       
   821     }
       
   822 
       
   823 //-----------------------------------------------------------------------------
       
   824 //  RCmDestination::SetIconL()
       
   825 //-----------------------------------------------------------------------------
       
   826 //
       
   827 EXPORT_C void RCmDestination::SetIconL( const TDesC& aIcon )
       
   828     {
       
   829     OstTraceFunctionEntry0( RCMDESTINATION_SETICONL_ENTRY );
       
   830 
       
   831     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   832         {
       
   833         User::Leave( KErrBadHandle );
       
   834         }
       
   835 
       
   836     TInt err = iCmDestinationWrapper->SetIcon( aIcon );
       
   837     User::LeaveIfError( err );
       
   838 
       
   839     OstTraceFunctionExit0( RCMDESTINATION_SETICONL_EXIT );
       
   840     }
       
   841 
       
   842 //-----------------------------------------------------------------------------
       
   843 //  RCmDestination::RefreshL()
       
   844 //-----------------------------------------------------------------------------
       
   845 //
       
   846 EXPORT_C void RCmDestination::RefreshL()
       
   847     {
       
   848     OstTraceFunctionEntry0( RCMDESTINATION_REFRESHL_ENTRY );
       
   849 
       
   850     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   851         {
       
   852         User::Leave( KErrBadHandle );
       
   853         }
       
   854 
       
   855     TInt err = iCmDestinationWrapper->Refresh();
       
   856     User::LeaveIfError( err );
       
   857 
       
   858     OstTraceFunctionExit0( RCMDESTINATION_REFRESHL_EXIT );
       
   859     }
       
   860 
       
   861 // End of file