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