cmmanager/cmmgr/cmmapi/src/cmdestinationapi.cpp
changeset 20 9c97ad6591ae
child 27 489cf6208544
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Client side IPC handling for Connection Method Manager server.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "cmmserverdefs.h"
       
    21 #include "cmdestinationapi.h"
       
    22 
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "cmdestinationapiTraces.h"
       
    26 #endif
       
    27 
       
    28 
       
    29 RCmDestinationApi::RCmDestinationApi()
       
    30     {
       
    31     OstTraceFunctionEntry0( RCMDESTINATIONAPI_RCMDESTINATIONAPI_ENTRY );
       
    32     iSessionConnected = EFalse;
       
    33     OstTraceFunctionExit0( RCMDESTINATIONAPI_RCMDESTINATIONAPI_EXIT );
       
    34     }
       
    35 
       
    36 TBool RCmDestinationApi::SessionConnected()
       
    37     {
       
    38     return iSessionConnected;
       
    39     }
       
    40 
       
    41 void RCmDestinationApi::ConnectAndGetDestWithIdL(
       
    42         const RSessionBase& aSession,
       
    43         const TUint32 aId,
       
    44         TInt& aExistingHandle )
       
    45     {
       
    46     OstTraceFunctionEntry0( RCMDESTINATIONAPI_CONNECTANDGETDESTWITHIDL_ENTRY );
       
    47 
       
    48     if ( iSessionConnected )
       
    49         {
       
    50         User::Leave( KErrAlreadyExists );
       
    51         }
       
    52 
       
    53     aExistingHandle = 0;
       
    54     TPckg<TInt> pckg( aExistingHandle );
       
    55     TIpcArgs args( aId, &pckg );
       
    56     TInt result = CreateSubSession( aSession, EDestGetDestination, args );
       
    57     if ( !aExistingHandle )
       
    58         {
       
    59         User::LeaveIfError( result );
       
    60         iSessionConnected = ETrue;
       
    61         }
       
    62     else
       
    63         {
       
    64         if ( result != KErrAlreadyExists )
       
    65             {
       
    66             User::Leave( result );
       
    67             }
       
    68         }
       
    69 
       
    70     OstTraceFunctionExit0( RCMDESTINATIONAPI_CONNECTANDGETDESTWITHIDL_EXIT );
       
    71     }
       
    72 
       
    73 void RCmDestinationApi::ConnectAndCreateDestWithNameL(
       
    74         const RSessionBase& aSession,
       
    75         const TDesC& aName )
       
    76     {
       
    77     OstTraceFunctionEntry0( RCMDESTINATIONAPI_CONNECTANDCREATEDESTWITHNAMEL_ENTRY );
       
    78 
       
    79     if ( iSessionConnected )
       
    80         {
       
    81         User::Leave( KErrAlreadyExists );
       
    82         }
       
    83     TIpcArgs args( &aName );
       
    84     User::LeaveIfError( CreateSubSession( aSession, EDestCreateDestinationWithName, args ) );
       
    85     iSessionConnected = ETrue;
       
    86 
       
    87     OstTraceFunctionExit0( RCMDESTINATIONAPI_CONNECTANDCREATEDESTWITHNAMEL_EXIT );
       
    88     }
       
    89 
       
    90 void RCmDestinationApi::ConnectAndCreateDestWithNameAndIdL(
       
    91         const RSessionBase& aSession,
       
    92         const TDesC& aName,
       
    93         const TUint32 aId )
       
    94     {
       
    95     OstTraceFunctionEntry0( RCMDESTINATIONAPI_CONNECTANDCREATEDESTWITHNAMEANDIDL_ENTRY );
       
    96 
       
    97     if ( iSessionConnected )
       
    98         {
       
    99         User::Leave( KErrAlreadyExists );
       
   100         }
       
   101     TIpcArgs args( &aName, aId );
       
   102     User::LeaveIfError( CreateSubSession( aSession, EDestCreateDestinationWithNameAndId, args ) );
       
   103     iSessionConnected = ETrue;
       
   104 
       
   105     OstTraceFunctionExit0( RCMDESTINATIONAPI_CONNECTANDCREATEDESTWITHNAMEANDIDL_EXIT );
       
   106     }
       
   107 
       
   108 void RCmDestinationApi::ConnectAndGetConnMethodAsEmbeddedDestL(
       
   109         const RSessionBase& aSession,
       
   110         const TInt aConnMethodHandle,
       
   111         TInt& aExistingHandle )
       
   112     {
       
   113     OstTraceFunctionEntry0( RCMDESTINATIONAPI_CONNECTANDGETCONNMETHODASEMBEDDEDDESTL_ENTRY );
       
   114 
       
   115     if ( iSessionConnected )
       
   116         {
       
   117         User::Leave( KErrAlreadyExists );
       
   118         }
       
   119 
       
   120     aExistingHandle = 0;
       
   121     TPckg<TInt> pckg( aExistingHandle );
       
   122     TIpcArgs args( aConnMethodHandle, &pckg );
       
   123     TInt result = CreateSubSession( aSession, EDestGetEmbeddedDestination, args );
       
   124     if ( !aExistingHandle )
       
   125         {
       
   126         User::LeaveIfError( result );
       
   127         iSessionConnected = ETrue;
       
   128         }
       
   129     else
       
   130         {
       
   131         if ( result != KErrAlreadyExists )
       
   132             {
       
   133             User::Leave( result );
       
   134             }
       
   135         }
       
   136 
       
   137     OstTraceFunctionExit0( RCMDESTINATIONAPI_CONNECTANDGETCONNMETHODASEMBEDDEDDESTL_EXIT );
       
   138     }
       
   139 
       
   140 void RCmDestinationApi::Close()
       
   141     {
       
   142     OstTraceFunctionEntry0( RCMDESTINATIONAPI_CLOSE_ENTRY );
       
   143 
       
   144     if ( iSessionConnected )
       
   145         {
       
   146         CloseSubSession( EDestCloseDestination );
       
   147         iSessionConnected = EFalse;
       
   148         }
       
   149 
       
   150     OstTraceFunctionExit0( RCMDESTINATIONAPI_CLOSE_EXIT );
       
   151     }
       
   152 
       
   153 TInt RCmDestinationApi::ConnectionMethodCount( TInt& aCount )
       
   154     {
       
   155     OstTraceFunctionEntry0( RCMDESTINATIONAPI_CONNECTIONMETHODCOUNT_ENTRY );
       
   156 
       
   157     TPckg<TInt> pckg( aCount );
       
   158     TIpcArgs args( &pckg );
       
   159     TInt err = SendReceive( EDestGetConnMethodCount, args );
       
   160 
       
   161     OstTraceFunctionExit0( RCMDESTINATIONAPI_CONNECTIONMETHODCOUNT_EXIT );
       
   162     return err;
       
   163     }
       
   164 
       
   165 TInt RCmDestinationApi::Priority( const TInt aHandle, TUint& aPriority )
       
   166     {
       
   167     OstTraceFunctionEntry0( RCMDESTINATIONAPI_PRIORITY_ENTRY );
       
   168 
       
   169     TPckg<TUint> pckg( aPriority );
       
   170     TIpcArgs args( aHandle, &pckg );
       
   171     TInt err = SendReceive( EDestGetConnMethodPriority, args );
       
   172 
       
   173     OstTraceFunctionExit0( RCMDESTINATIONAPI_PRIORITY_EXIT );
       
   174     return err;
       
   175     }
       
   176 
       
   177 TInt RCmDestinationApi::GetName( HBufC* aBuffer )
       
   178     {
       
   179     OstTraceFunctionEntry0( RCMDESTINATIONAPI_GETNAME_ENTRY );
       
   180 
       
   181     TPtr descriptor( aBuffer->Des() );
       
   182     TIpcArgs args( &descriptor );
       
   183     TInt err = SendReceive( EDestGetName, args );
       
   184 
       
   185     OstTraceFunctionExit0( RCMDESTINATIONAPI_GETNAME_EXIT );
       
   186     return err;
       
   187     }
       
   188 
       
   189 TInt RCmDestinationApi::GetId( TUint32& aId )
       
   190     {
       
   191     OstTraceFunctionEntry0( RCMDESTINATIONAPI_GETID_ENTRY );
       
   192 
       
   193     TPckg<TUint32> pckg( aId );
       
   194     TIpcArgs args( &pckg );
       
   195     TInt err = SendReceive( EDestGetId, args );
       
   196 
       
   197     OstTraceFunctionExit0( RCMDESTINATIONAPI_GETID_EXIT );
       
   198     return err;
       
   199     }
       
   200 
       
   201 TInt RCmDestinationApi::GetElementId( TUint32& aElementId )
       
   202     {
       
   203     OstTraceFunctionEntry0( RCMDESTINATIONAPI_GETELEMENTID_ENTRY );
       
   204 
       
   205     TPckg<TUint32> pckg( aElementId );
       
   206     TIpcArgs args( &pckg );
       
   207     TInt err = SendReceive( EDestGetElementId, args );
       
   208 
       
   209     OstTraceFunctionExit0( RCMDESTINATIONAPI_GETELEMENTID_EXIT );
       
   210     return err;
       
   211     }
       
   212 
       
   213 TInt RCmDestinationApi::GetMetadata(
       
   214         const TUint32 aMetadataField,
       
   215         TUint32& aValue )
       
   216     {
       
   217     OstTraceFunctionEntry0( RCMDESTINATIONAPI_GETMETADATA_ENTRY );
       
   218 
       
   219     TPckg<TUint32> pckg( aValue );
       
   220     TIpcArgs args( aMetadataField, &pckg );
       
   221     TInt err = SendReceive( EDestMetadata, args );
       
   222 
       
   223     OstTraceFunctionExit0( RCMDESTINATIONAPI_GETMETADATA_EXIT );
       
   224     return err;
       
   225     }
       
   226 
       
   227 TInt RCmDestinationApi::GetProtectionLevel( TInt& aProtectionLevel )
       
   228     {
       
   229     OstTraceFunctionEntry0( RCMDESTINATIONAPI_GETPROTECTIONLEVEL_ENTRY );
       
   230 
       
   231     TPckg<TInt> pckg( aProtectionLevel );
       
   232     TIpcArgs args( &pckg );
       
   233     TInt err = SendReceive( EDestGetProtectionLevel, args );
       
   234 
       
   235     OstTraceFunctionExit0( RCMDESTINATIONAPI_GETPROTECTIONLEVEL_EXIT );
       
   236     return err;
       
   237     }
       
   238 
       
   239 TInt RCmDestinationApi::AddConnectionMethod(
       
   240         const TInt aConnMethodHandle,
       
   241         TInt& aIndex )
       
   242     {
       
   243     OstTraceFunctionEntry0( RCMDESTINATIONAPI_ADDCONNECTIONMETHOD_ENTRY );
       
   244 
       
   245     TPckg<TInt> pckg( aIndex );
       
   246     TIpcArgs args( aConnMethodHandle, &pckg );
       
   247     TInt err = SendReceive( EDestAddConnMethod, args );
       
   248 
       
   249     OstTraceFunctionExit0( RCMDESTINATIONAPI_ADDCONNECTIONMETHOD_EXIT );
       
   250     return err;
       
   251     }
       
   252 
       
   253 TInt RCmDestinationApi::AddEmbeddedDestination(
       
   254         const TInt aDestHandle,
       
   255         TInt& aIndex )
       
   256     {
       
   257     OstTraceFunctionEntry0( RCMDESTINATIONAPI_ADDEMBEDDEDDESTINATION_ENTRY );
       
   258 
       
   259     TPckg<TInt> pckg( aIndex );
       
   260     TIpcArgs args( aDestHandle, &pckg );
       
   261     TInt err = SendReceive( EDestAddEmbeddedDestination, args );
       
   262 
       
   263     OstTraceFunctionExit0( RCMDESTINATIONAPI_ADDEMBEDDEDDESTINATION_EXIT );
       
   264     return err;
       
   265     }
       
   266 
       
   267 TInt RCmDestinationApi::DeleteConnectionMethod(
       
   268         const TInt aConnMethodHandle )
       
   269     {
       
   270     OstTraceFunctionEntry0( RCMDESTINATIONAPI_DELETECONNECTIONMETHOD_ENTRY );
       
   271 
       
   272     TIpcArgs args( aConnMethodHandle );
       
   273     TInt err = SendReceive( EDestDeleteConnMethod, args );
       
   274 
       
   275     OstTraceFunctionExit0( RCMDESTINATIONAPI_DELETECONNECTIONMETHOD_EXIT );
       
   276     return err;
       
   277     }
       
   278 
       
   279 TInt RCmDestinationApi::RemoveConnectionMethod(
       
   280         const TInt aConnMethodHandle )
       
   281     {
       
   282     OstTraceFunctionEntry0( RCMDESTINATIONAPI_REMOVECONNECTIONMETHOD_ENTRY );
       
   283 
       
   284     TIpcArgs args( aConnMethodHandle );
       
   285     TInt err = SendReceive( EDestRemoveConnMethod, args );
       
   286 
       
   287     OstTraceFunctionExit0( RCMDESTINATIONAPI_REMOVECONNECTIONMETHOD_EXIT );
       
   288     return err;
       
   289     }
       
   290 
       
   291 TInt RCmDestinationApi::ModifyPriority(
       
   292         const TInt aConnMethodHandle,
       
   293         const TUint aIndex )
       
   294     {
       
   295     OstTraceFunctionEntry0( RCMDESTINATIONAPI_MODIFYPRIORITY_ENTRY );
       
   296 
       
   297     TIpcArgs args( aConnMethodHandle, aIndex );
       
   298     TInt err = SendReceive( EDestModifyPriority, args );
       
   299 
       
   300     OstTraceFunctionExit0( RCMDESTINATIONAPI_MODIFYPRIORITY_EXIT );
       
   301     return err;
       
   302     }
       
   303 
       
   304 TInt RCmDestinationApi::SetName( const TDesC& aValue )
       
   305     {
       
   306     OstTraceFunctionEntry0( RCMDESTINATIONAPI_SETNAME_ENTRY );
       
   307 
       
   308     TIpcArgs args( &aValue );
       
   309     TInt err = SendReceive( EDestSetName, args );
       
   310 
       
   311     OstTraceFunctionExit0( RCMDESTINATIONAPI_SETNAME_EXIT );
       
   312     return err;
       
   313     }
       
   314 
       
   315 TInt RCmDestinationApi::SetMetadata(
       
   316         const TUint32 aMetaField,
       
   317         const TUint32 aValue )
       
   318     {
       
   319     OstTraceFunctionEntry0( RCMDESTINATIONAPI_SETMETADATA_ENTRY );
       
   320 
       
   321     TIpcArgs args( aMetaField, aValue );
       
   322     TInt err = SendReceive( EDestSetMetadata, args );
       
   323 
       
   324     OstTraceFunctionExit0( RCMDESTINATIONAPI_SETMETADATA_EXIT );
       
   325     return err;
       
   326     }
       
   327 
       
   328 TInt RCmDestinationApi::SetProtection( const TInt aValue )
       
   329     {
       
   330     OstTraceFunctionEntry0( RCMDESTINATIONAPI_SETPROTECTION_ENTRY );
       
   331 
       
   332     TIpcArgs args( aValue );
       
   333     TInt err = SendReceive( EDestSetProtection, args );
       
   334 
       
   335     OstTraceFunctionExit0( RCMDESTINATIONAPI_SETPROTECTION_EXIT );
       
   336     return err;
       
   337     }
       
   338 
       
   339 TInt RCmDestinationApi::SetHidden( const TBool aHidden )
       
   340     {
       
   341     OstTraceFunctionEntry0( RCMDESTINATIONAPI_SETHIDDEN_ENTRY );
       
   342 
       
   343     TIpcArgs args( aHidden );
       
   344     TInt err = SendReceive( EDestSetHidden, args );
       
   345 
       
   346     OstTraceFunctionExit0( RCMDESTINATIONAPI_SETHIDDEN_EXIT );
       
   347     return err;
       
   348     }
       
   349 
       
   350 TInt RCmDestinationApi::Update()
       
   351     {
       
   352     OstTraceFunctionEntry0( RCMDESTINATIONAPI_UPDATE_ENTRY );
       
   353 
       
   354     TInt err = SendReceive( EDestUpdate );
       
   355 
       
   356     OstTraceFunctionExit0( RCMDESTINATIONAPI_UPDATE_EXIT );
       
   357     return err;
       
   358     }
       
   359 
       
   360 TInt RCmDestinationApi::Refresh()
       
   361     {
       
   362     OstTraceFunctionEntry0( RCMDESTINATIONAPI_REFRESH_ENTRY );
       
   363 
       
   364     TInt err = SendReceive( EDestRefresh );
       
   365 
       
   366     OstTraceFunctionExit0( RCMDESTINATIONAPI_REFRESH_EXIT );
       
   367     return err;
       
   368     }
       
   369 
       
   370 TInt RCmDestinationApi::Delete()
       
   371     {
       
   372     OstTraceFunctionEntry0( RCMDESTINATIONAPI_DELETE_ENTRY );
       
   373 
       
   374     TInt err = SendReceive( EDestDelete );
       
   375 
       
   376     OstTraceFunctionExit0( RCMDESTINATIONAPI_DELETE_EXIT );
       
   377     return err;
       
   378     }
       
   379 
       
   380 TInt RCmDestinationApi::IsConnected( TBool& aResult )
       
   381     {
       
   382     OstTraceFunctionEntry0( RCMDESTINATIONAPI_ISCONNECTED_ENTRY );
       
   383 
       
   384     TPckg<TBool> pckg( aResult );
       
   385     TIpcArgs args( &pckg );
       
   386     TInt err = SendReceive( EDestIsConnected, args );
       
   387 
       
   388     OstTraceFunctionExit0( RCMDESTINATIONAPI_ISCONNECTED_EXIT );
       
   389     return err;
       
   390     }
       
   391 
       
   392 TInt RCmDestinationApi::IsHidden( TBool& aResult )
       
   393     {
       
   394     OstTraceFunctionEntry0( RCMDESTINATIONAPI_ISHIDDEN_ENTRY );
       
   395 
       
   396     TPckg<TBool> pckg( aResult );
       
   397     TIpcArgs args( &pckg );
       
   398     TInt err = SendReceive( EDestIsHidden, args );
       
   399 
       
   400     OstTraceFunctionExit0( RCMDESTINATIONAPI_ISHIDDEN_EXIT );
       
   401     return err;
       
   402     }
       
   403 
       
   404 TInt RCmDestinationApi::IsEqual( const TInt aHandle, TBool& aResult )
       
   405     {
       
   406     OstTraceFunctionEntry0( RCMDESTINATIONAPI_ISEQUAL_ENTRY );
       
   407 
       
   408     TPckg<TBool> pckg( aResult );
       
   409     TIpcArgs args( aHandle, &pckg );
       
   410     TInt err = SendReceive( EDestIsEqual, args );
       
   411 
       
   412     OstTraceFunctionExit0( RCMDESTINATIONAPI_ISEQUAL_EXIT );
       
   413     return err;
       
   414     }
       
   415 
       
   416 // End of file