cmmanager/cmmgr/cmmapi/src/cmdestinationext.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     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 RCmDestinationExt.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <cmdestinationext.h>
       
    21 #include <cmconnectionmethodext.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 "cmdestinationextTraces.h"
       
    31 #endif
       
    32 
       
    33 
       
    34 //-----------------------------------------------------------------------------
       
    35 //  RCmDestinationExt::Close()
       
    36 //-----------------------------------------------------------------------------
       
    37 //
       
    38 EXPORT_C void RCmDestinationExt::Close()
       
    39     {
       
    40     OstTraceFunctionEntry0( RCMDESTINATIONEXT_CLOSE_ENTRY );
       
    41 
       
    42     if ( iCmDestinationWrapper )
       
    43         {
       
    44         if ( iCmDestinationWrapper->DecreaseReferenceCounter() <= 0 )
       
    45             {
       
    46             delete iCmDestinationWrapper;
       
    47             }
       
    48         iCmDestinationWrapper = NULL;
       
    49         }
       
    50 
       
    51     OstTraceFunctionExit0( RCMDESTINATIONEXT_CLOSE_EXIT );
       
    52     }
       
    53 
       
    54 //-----------------------------------------------------------------------------
       
    55 //  RCmDestinationExt::~RCmDestinationExt()
       
    56 //-----------------------------------------------------------------------------
       
    57 //
       
    58 EXPORT_C RCmDestinationExt::~RCmDestinationExt()
       
    59     {
       
    60     OstTraceFunctionEntry0( RCMDESTINATIONEXT_RCMDESTINATIONEXT_ENTRY );
       
    61     Close();
       
    62     OstTraceFunctionExit0( RCMDESTINATIONEXT_RCMDESTINATIONEXT_EXIT );
       
    63     }
       
    64 
       
    65 //-----------------------------------------------------------------------------
       
    66 //  RCmDestinationExt::RCmDestinationExt()
       
    67 //-----------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C RCmDestinationExt::RCmDestinationExt(
       
    70         const RCmDestinationExt& aDestination )
       
    71     {
       
    72     OstTraceFunctionEntry0( DUP1_RCMDESTINATIONEXT_RCMDESTINATIONEXT_ENTRY );
       
    73 
       
    74     this->iCmDestinationWrapper = aDestination.iCmDestinationWrapper;
       
    75     if ( iCmDestinationWrapper )
       
    76         {
       
    77         iCmDestinationWrapper->IncreaseReferenceCounter();
       
    78         }
       
    79 
       
    80     OstTraceFunctionExit0( DUP1_RCMDESTINATIONEXT_RCMDESTINATIONEXT_EXIT );
       
    81     }
       
    82 
       
    83 //-----------------------------------------------------------------------------
       
    84 //  RCmDestinationExt::operator=()
       
    85 //-----------------------------------------------------------------------------
       
    86 //
       
    87 EXPORT_C RCmDestinationExt& RCmDestinationExt::operator=(
       
    88         const RCmDestinationExt& aDestination )
       
    89     {
       
    90     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_OPERATOR_EXIT );
       
   103     return *this;
       
   104     }
       
   105 
       
   106 //-----------------------------------------------------------------------------
       
   107 //  RCmDestinationExt::ConnectionMethodCount()
       
   108 //-----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C TInt RCmDestinationExt::ConnectionMethodCount()
       
   111     {
       
   112     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_CONNECTIONMETHODCOUNT_EXIT );
       
   126     return value;
       
   127     }
       
   128 
       
   129 //-----------------------------------------------------------------------------
       
   130 //  RCmDestinationExt::ConnectionMethodL()
       
   131 //-----------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C RCmConnectionMethodExt RCmDestinationExt::ConnectionMethodL(
       
   134         TInt aIndex )
       
   135     {
       
   136     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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     RCmConnectionMethodExt cm;
       
   164     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   165 
       
   166     OstTraceFunctionExit0( RCMDESTINATIONEXT_CONNECTIONMETHODL_EXIT );
       
   167     return cm;
       
   168     }
       
   169 
       
   170 //-----------------------------------------------------------------------------
       
   171 //  RCmDestinationExt::ConnectionMethodByIDL()
       
   172 //-----------------------------------------------------------------------------
       
   173 //
       
   174 EXPORT_C RCmConnectionMethodExt RCmDestinationExt::ConnectionMethodByIDL(
       
   175         TInt aConnMethodId )
       
   176     {
       
   177     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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     RCmConnectionMethodExt cm;
       
   205     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   206 
       
   207     OstTraceFunctionExit0( RCMDESTINATIONEXT_CONNECTIONMETHODBYIDL_EXIT );
       
   208     return cm;
       
   209     }
       
   210 
       
   211 //-----------------------------------------------------------------------------
       
   212 //  RCmDestinationExt::PriorityL()
       
   213 //-----------------------------------------------------------------------------
       
   214 //
       
   215 EXPORT_C TUint RCmDestinationExt::PriorityL(
       
   216         const RCmConnectionMethodExt& aConnectionMethod )
       
   217     {
       
   218     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_PRIORITYL_EXIT );
       
   236     return priority;
       
   237     }
       
   238 
       
   239 //-----------------------------------------------------------------------------
       
   240 //  RCmDestinationExt::NameLC()
       
   241 //-----------------------------------------------------------------------------
       
   242 //
       
   243 EXPORT_C HBufC* RCmDestinationExt::NameLC()
       
   244     {
       
   245     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_NAMELC_EXIT );
       
   258     return buffer;
       
   259     }
       
   260 
       
   261 //-----------------------------------------------------------------------------
       
   262 //  RCmDestinationExt::Id()
       
   263 //-----------------------------------------------------------------------------
       
   264 //
       
   265 EXPORT_C TUint32 RCmDestinationExt::Id()
       
   266     {
       
   267     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_ID_EXIT );
       
   281     return id;
       
   282     }
       
   283 
       
   284 //-----------------------------------------------------------------------------
       
   285 //  RCmDestinationExt::ElementId()
       
   286 //-----------------------------------------------------------------------------
       
   287 //
       
   288 EXPORT_C TUint32 RCmDestinationExt::ElementId()
       
   289     {
       
   290     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_ELEMENTID_EXIT );
       
   304     return elementId;
       
   305     }
       
   306 
       
   307 //-----------------------------------------------------------------------------
       
   308 //  RCmDestinationExt::MetadataL()
       
   309 //-----------------------------------------------------------------------------
       
   310 //
       
   311 EXPORT_C TUint32 RCmDestinationExt::MetadataL(
       
   312         CMManager::TSnapMetadataField aMetadataField ) const
       
   313     {
       
   314     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_METADATAL_EXIT );
       
   326     return value;
       
   327     }
       
   328 
       
   329 //-----------------------------------------------------------------------------
       
   330 //  RCmDestinationExt::ProtectionLevel()
       
   331 //-----------------------------------------------------------------------------
       
   332 //
       
   333 EXPORT_C CMManager::TProtectionLevel RCmDestinationExt::ProtectionLevel()
       
   334     {
       
   335     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_PROTECTIONLEVEL_EXIT );
       
   349     return ( CMManager::TProtectionLevel )protectionLevel;
       
   350     }
       
   351 
       
   352 //-----------------------------------------------------------------------------
       
   353 //  RCmDestinationExt::IsHidden()
       
   354 //-----------------------------------------------------------------------------
       
   355 //
       
   356 EXPORT_C TBool RCmDestinationExt::IsHidden()
       
   357     {
       
   358     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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( RCMDESTINATIONEXT_ISHIDDEN_EXIT );
       
   372     return value;
       
   373     }
       
   374 
       
   375 //-----------------------------------------------------------------------------
       
   376 //  RCmDestinationExt::CreateConnectionMethodL()
       
   377 //-----------------------------------------------------------------------------
       
   378 //
       
   379 EXPORT_C RCmConnectionMethodExt RCmDestinationExt::CreateConnectionMethodL(
       
   380         TUint32 aBearerType )
       
   381     {
       
   382     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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     RCmConnectionMethodExt cm;
       
   398     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   399 
       
   400     OstTraceFunctionExit0( RCMDESTINATIONEXT_CREATECONNECTIONMETHODL_EXIT );
       
   401     return cm;
       
   402     }
       
   403 
       
   404 //-----------------------------------------------------------------------------
       
   405 //  RCmDestinationExt::CreateConnectionMethodL()
       
   406 //-----------------------------------------------------------------------------
       
   407 //
       
   408 EXPORT_C RCmConnectionMethodExt RCmDestinationExt::CreateConnectionMethodL(
       
   409         TUint32 aBearerType,
       
   410         TUint32 aConnMethodId )
       
   411     {
       
   412     OstTraceFunctionEntry0( DUP1_RCMDESTINATIONEXT_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     RCmConnectionMethodExt cm;
       
   429     cm.iCmConnectionMethodWrapper = cmWrapper;
       
   430 
       
   431     OstTraceFunctionExit0( DUP1_RCMDESTINATIONEXT_CREATECONNECTIONMETHODL_EXIT );
       
   432     return cm;
       
   433     }
       
   434 
       
   435 //-----------------------------------------------------------------------------
       
   436 //  RCmDestinationExt::AddConnectionMethodL()
       
   437 //-----------------------------------------------------------------------------
       
   438 //
       
   439 EXPORT_C TInt RCmDestinationExt::AddConnectionMethodL(
       
   440         RCmConnectionMethodExt aConnectionMethod )
       
   441     {
       
   442     OstTraceFunctionEntry0( RCMDESTINATIONEXT_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 
       
   458     User::LeaveIfError( err );
       
   459 
       
   460     OstTraceFunctionExit0( RCMDESTINATIONEXT_ADDCONNECTIONMETHODL_EXIT );
       
   461     return index;
       
   462     }
       
   463 
       
   464 //-----------------------------------------------------------------------------
       
   465 //  RCmDestinationExt::AddEmbeddedDestinationL()
       
   466 //-----------------------------------------------------------------------------
       
   467 //
       
   468 EXPORT_C TInt RCmDestinationExt::AddEmbeddedDestinationL(
       
   469         const RCmDestinationExt& aDestination )
       
   470     {
       
   471     OstTraceFunctionEntry0( RCMDESTINATIONEXT_ADDEMBEDDEDDESTINATIONL_ENTRY );
       
   472 
       
   473     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   474         {
       
   475         User::Leave( KErrBadHandle );
       
   476         }
       
   477     if ( iCmDestinationWrapper == aDestination.iCmDestinationWrapper )
       
   478         {
       
   479         User::Leave( KErrArgument );
       
   480         }
       
   481     if ( !aDestination.iCmDestinationWrapper ||
       
   482             !aDestination.iCmDestinationWrapper->SessionConnected() )
       
   483         {
       
   484         User::Leave( KErrArgument );
       
   485         }
       
   486 
       
   487     TInt index( 0 );
       
   488     TInt destinationHandle = aDestination.iCmDestinationWrapper->GetHandle();
       
   489     TInt err = iCmDestinationWrapper->AddEmbeddedDestination( destinationHandle, index );
       
   490 
       
   491     User::LeaveIfError( err );
       
   492 
       
   493     OstTraceFunctionExit0( RCMDESTINATIONEXT_ADDEMBEDDEDDESTINATIONL_EXIT );
       
   494     return index;
       
   495     }
       
   496 
       
   497 //-----------------------------------------------------------------------------
       
   498 //  RCmDestinationExt::DeleteConnectionMethodL()
       
   499 //-----------------------------------------------------------------------------
       
   500 //
       
   501 EXPORT_C void RCmDestinationExt::DeleteConnectionMethodL(
       
   502         RCmConnectionMethodExt& aConnectionMethod )
       
   503     {
       
   504     OstTraceFunctionEntry0( RCMDESTINATIONEXT_DELETECONNECTIONMETHODL_ENTRY );
       
   505 
       
   506     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   507         {
       
   508         User::Leave( KErrBadHandle );
       
   509         }
       
   510     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   511             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   512         {
       
   513         User::Leave( KErrArgument );
       
   514         }
       
   515 
       
   516     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   517     TInt err = iCmDestinationWrapper->DeleteConnectionMethod( connMethodHandle );
       
   518     User::LeaveIfError( err );
       
   519 
       
   520     OstTraceFunctionExit0( RCMDESTINATIONEXT_DELETECONNECTIONMETHODL_EXIT );
       
   521     }
       
   522 
       
   523 //-----------------------------------------------------------------------------
       
   524 //  RCmDestinationExt::RemoveConnectionMethodL()
       
   525 //-----------------------------------------------------------------------------
       
   526 //
       
   527 EXPORT_C void RCmDestinationExt::RemoveConnectionMethodL(
       
   528         RCmConnectionMethodExt aConnectionMethod )
       
   529     {
       
   530     OstTraceFunctionEntry0( RCMDESTINATIONEXT_REMOVECONNECTIONMETHODL_ENTRY );
       
   531 
       
   532     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   533         {
       
   534         User::Leave( KErrBadHandle );
       
   535         }
       
   536     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   537             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   538         {
       
   539         User::Leave( KErrArgument );
       
   540         }
       
   541 
       
   542     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   543     TInt err = iCmDestinationWrapper->RemoveConnectionMethod( connMethodHandle );
       
   544     User::LeaveIfError( err );
       
   545 
       
   546     OstTraceFunctionExit0( RCMDESTINATIONEXT_REMOVECONNECTIONMETHODL_EXIT );
       
   547     }
       
   548 
       
   549 //-----------------------------------------------------------------------------
       
   550 //  RCmDestinationExt::ModifyPriorityL()
       
   551 //-----------------------------------------------------------------------------
       
   552 //
       
   553 EXPORT_C void RCmDestinationExt::ModifyPriorityL(
       
   554         RCmConnectionMethodExt& aConnectionMethod,
       
   555         TUint aIndex )
       
   556     {
       
   557     OstTraceFunctionEntry0( RCMDESTINATIONEXT_MODIFYPRIORITYL_ENTRY );
       
   558 
       
   559     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   560         {
       
   561         User::Leave( KErrBadHandle );
       
   562         }
       
   563     if ( !aConnectionMethod.iCmConnectionMethodWrapper ||
       
   564             !aConnectionMethod.iCmConnectionMethodWrapper->SessionConnected() )
       
   565         {
       
   566         User::Leave( KErrArgument );
       
   567         }
       
   568 
       
   569     TInt connMethodHandle = aConnectionMethod.iCmConnectionMethodWrapper->GetHandle();
       
   570     TInt err = iCmDestinationWrapper->ModifyPriority( connMethodHandle, aIndex );
       
   571     User::LeaveIfError( err );
       
   572 
       
   573     OstTraceFunctionExit0( RCMDESTINATIONEXT_MODIFYPRIORITYL_EXIT );
       
   574     }
       
   575 
       
   576 //-----------------------------------------------------------------------------
       
   577 //  RCmDestinationExt::SetNameL()
       
   578 //-----------------------------------------------------------------------------
       
   579 //
       
   580 EXPORT_C void RCmDestinationExt::SetNameL( const TDesC& aName )
       
   581     {
       
   582     OstTraceFunctionEntry0( RCMDESTINATIONEXT_SETNAMEL_ENTRY );
       
   583 
       
   584     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   585         {
       
   586         User::Leave( KErrBadHandle );
       
   587         }
       
   588 
       
   589     TInt err = iCmDestinationWrapper->SetName( aName );
       
   590     User::LeaveIfError( err );
       
   591 
       
   592     OstTraceFunctionExit0( RCMDESTINATIONEXT_SETNAMEL_EXIT );
       
   593     }
       
   594 
       
   595 //-----------------------------------------------------------------------------
       
   596 //  RCmDestinationExt::SetMetadataL()
       
   597 //-----------------------------------------------------------------------------
       
   598 //
       
   599 EXPORT_C void RCmDestinationExt::SetMetadataL(
       
   600         CMManager::TSnapMetadataField aMetadataField,
       
   601         TUint32 aValue )
       
   602     {
       
   603     OstTraceFunctionEntry0( RCMDESTINATIONEXT_SETMETADATAL_ENTRY );
       
   604 
       
   605     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   606         {
       
   607         User::Leave( KErrBadHandle );
       
   608         }
       
   609 
       
   610     TInt err = iCmDestinationWrapper->SetMetadata( aMetadataField, aValue );
       
   611     User::LeaveIfError( err );
       
   612 
       
   613     OstTraceFunctionExit0( RCMDESTINATIONEXT_SETMETADATAL_EXIT );
       
   614     }
       
   615 
       
   616 //-----------------------------------------------------------------------------
       
   617 //  RCmDestinationExt::SetProtectionL()
       
   618 //-----------------------------------------------------------------------------
       
   619 //
       
   620 EXPORT_C void RCmDestinationExt::SetProtectionL( CMManager::TProtectionLevel aProtLevel )
       
   621     {
       
   622     OstTraceFunctionEntry0( RCMDESTINATIONEXT_SETPROTECTIONL_ENTRY );
       
   623 
       
   624     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   625         {
       
   626         User::Leave( KErrBadHandle );
       
   627         }
       
   628 
       
   629     TInt err = iCmDestinationWrapper->SetProtection( aProtLevel );
       
   630     User::LeaveIfError( err );
       
   631 
       
   632     OstTraceFunctionExit0( RCMDESTINATIONEXT_SETPROTECTIONL_EXIT );
       
   633     }
       
   634 
       
   635 //-----------------------------------------------------------------------------
       
   636 //  RCmDestinationExt::SetHiddenL()
       
   637 //-----------------------------------------------------------------------------
       
   638 //
       
   639 EXPORT_C void RCmDestinationExt::SetHiddenL( TBool aHidden )
       
   640     {
       
   641     OstTraceFunctionEntry0( RCMDESTINATIONEXT_SETHIDDENL_ENTRY );
       
   642 
       
   643     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   644         {
       
   645         User::Leave( KErrBadHandle );
       
   646         }
       
   647 
       
   648     TInt err = iCmDestinationWrapper->SetHidden( aHidden );
       
   649     User::LeaveIfError( err );
       
   650 
       
   651     OstTraceFunctionExit0( RCMDESTINATIONEXT_SETHIDDENL_EXIT );
       
   652     }
       
   653 
       
   654 //-----------------------------------------------------------------------------
       
   655 //  RCmDestinationExt::UpdateL()
       
   656 //-----------------------------------------------------------------------------
       
   657 //
       
   658 EXPORT_C void RCmDestinationExt::UpdateL()
       
   659     {
       
   660     OstTraceFunctionEntry0( RCMDESTINATIONEXT_UPDATEL_ENTRY );
       
   661 
       
   662     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   663         {
       
   664         User::Leave( KErrBadHandle );
       
   665         }
       
   666 
       
   667     TInt err = iCmDestinationWrapper->Update();
       
   668     User::LeaveIfError( err );
       
   669 
       
   670     OstTraceFunctionExit0( RCMDESTINATIONEXT_UPDATEL_EXIT );
       
   671     }
       
   672 
       
   673 //-----------------------------------------------------------------------------
       
   674 //  RCmDestinationExt::DeleteLD()
       
   675 //-----------------------------------------------------------------------------
       
   676 //
       
   677 EXPORT_C void RCmDestinationExt::DeleteLD()
       
   678     {
       
   679     OstTraceFunctionEntry0( RCMDESTINATIONEXT_DELETELD_ENTRY );
       
   680 
       
   681     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   682         {
       
   683         User::Leave( KErrBadHandle );
       
   684         }
       
   685 
       
   686     TInt err = iCmDestinationWrapper->Delete();
       
   687     User::LeaveIfError( err );
       
   688 
       
   689     // Instead of calling Close(), we need to force this handle closed even if
       
   690     // copies have been made. So we delete the destination wrapper directly.
       
   691     delete iCmDestinationWrapper;
       
   692     iCmDestinationWrapper = NULL;
       
   693 
       
   694     OstTraceFunctionExit0( RCMDESTINATIONEXT_DELETELD_EXIT );
       
   695     }
       
   696 
       
   697 //-----------------------------------------------------------------------------
       
   698 //  RCmDestinationExt::IsConnectedL()
       
   699 //-----------------------------------------------------------------------------
       
   700 //
       
   701 EXPORT_C TBool RCmDestinationExt::IsConnectedL() const
       
   702     {
       
   703     OstTraceFunctionEntry0( RCMDESTINATIONEXT_ISCONNECTEDL_ENTRY );
       
   704 
       
   705     if ( !iCmDestinationWrapper || !iCmDestinationWrapper->SessionConnected() )
       
   706         {
       
   707         User::Leave( KErrBadHandle );
       
   708         }
       
   709 
       
   710     TBool value( 0 );
       
   711     TInt err = iCmDestinationWrapper->IsConnected( value );
       
   712     User::LeaveIfError( err );
       
   713 
       
   714     OstTraceFunctionExit0( RCMDESTINATIONEXT_ISCONNECTEDL_EXIT );
       
   715     return value;
       
   716     }
       
   717 
       
   718 //-----------------------------------------------------------------------------
       
   719 //  RCmDestinationExt::RCmDestinationExt()
       
   720 //-----------------------------------------------------------------------------
       
   721 //
       
   722 EXPORT_C RCmDestinationExt::RCmDestinationExt() : iCmDestinationWrapper( NULL )
       
   723     {
       
   724     OstTraceFunctionEntry0( DUP2_RCMDESTINATIONEXT_RCMDESTINATIONEXT_ENTRY );
       
   725     OstTraceFunctionExit0( DUP2_RCMDESTINATIONEXT_RCMDESTINATIONEXT_EXIT );
       
   726     }
       
   727 
       
   728 //-----------------------------------------------------------------------------
       
   729 //  RCmDestinationExt::operator==()
       
   730 //-----------------------------------------------------------------------------
       
   731 //
       
   732 EXPORT_C TBool RCmDestinationExt::operator==(
       
   733         const RCmDestinationExt& aDestination ) const
       
   734     {
       
   735     OstTraceFunctionEntry0( DUP1_RCMDESTINATIONEXT_OPERATOR_ENTRY );
       
   736 
       
   737     TBool result( EFalse );
       
   738     if ( !aDestination.iCmDestinationWrapper )
       
   739         {
       
   740         if ( !iCmDestinationWrapper )
       
   741             {
       
   742             result = ETrue; // Both empty.
       
   743             }
       
   744         else
       
   745             {
       
   746             result = EFalse;
       
   747             }
       
   748         }
       
   749     else if ( !iCmDestinationWrapper )
       
   750         {
       
   751         result = EFalse;
       
   752         }
       
   753     else
       
   754         {
       
   755         // Both destination objects have wrappers.
       
   756 
       
   757         if ( !iCmDestinationWrapper->SessionConnected() ||
       
   758                 !aDestination.iCmDestinationWrapper->SessionConnected() )
       
   759             {
       
   760             result = EFalse;
       
   761             }
       
   762         else
       
   763             {
       
   764             // Both destination objects are connected to server.
       
   765 
       
   766             TInt handle = aDestination.iCmDestinationWrapper->GetHandle();
       
   767             TInt err = iCmDestinationWrapper->IsEqual( handle, result );
       
   768             if ( err )
       
   769                 {
       
   770                 result = EFalse;
       
   771                 }
       
   772             }
       
   773         }
       
   774 
       
   775     OstTraceFunctionExit0( DUP1_RCMDESTINATIONEXT_OPERATOR_EXIT );
       
   776     return result;
       
   777     }
       
   778 
       
   779 //-----------------------------------------------------------------------------
       
   780 //RCmDestinationExt::operator!=()
       
   781 //-----------------------------------------------------------------------------
       
   782 //
       
   783 EXPORT_C TBool RCmDestinationExt::operator!=(
       
   784         const RCmDestinationExt& aDestination ) const
       
   785     {
       
   786     OstTraceFunctionEntry0( DUP2_RCMDESTINATIONEXT_OPERATOR_ENTRY );
       
   787 
       
   788     TBool result = !( operator==( aDestination ) );
       
   789 
       
   790     OstTraceFunctionExit0( DUP2_RCMDESTINATIONEXT_OPERATOR_EXIT );
       
   791     return result;
       
   792     }
       
   793 
       
   794 // End of file