systemswstubs/examplecommonisc/IscMultiplexerBase/src/IscMultiplexerBase.cpp
changeset 43 e71858845f73
parent 40 b7e5ed8c1342
child 46 e1758cbb96ac
equal deleted inserted replaced
40:b7e5ed8c1342 43:e71858845f73
     1 /*
       
     2 * Copyright (c) 2007 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:  Implementation of DIscMultiplexerBase class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <IscDefinitions.h>
       
    22 #include <IscDevice.h>
       
    23 #include "IscMultiplexerBase.h"
       
    24 #include "IscTrace.h"
       
    25 
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES  
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // MACROS
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 
       
    37 // MODULE DATA STRUCTURES
       
    38 
       
    39 // LOCAL FUNCTION PROTOTYPES
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // DIscMultiplexerBase::DIscMultiplexerBase
       
    48 // C++ default constructor can NOT contain any code, that
       
    49 // might leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C DIscMultiplexerBase::DIscMultiplexerBase()
       
    53     :iDevice( NULL )
       
    54     {
       
    55     C_TRACE( ( _T( "DIscMultiplexerBase::DIscMultiplexerBase()" ) ) );
       
    56     C_TRACE( ( _T( "DIscMultiplexerBase::DIscMultiplexerBase - return 0x%x" ) ) );
       
    57     }
       
    58     
       
    59 // Destructor
       
    60 EXPORT_C DIscMultiplexerBase::~DIscMultiplexerBase()
       
    61     {    
       
    62     C_TRACE( ( _T( "DIscMultiplexerBase::~DIscMultiplexerBase()" ) ) );
       
    63     C_TRACE( ( _T( "DIscMultiplexerBase::~DIscMultiplexerBase - return 0x%x" ) ) );
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // DIscMultiplexerBase::CustomFunction
       
    68 // API extension function
       
    69 // ( other items were commented in a header ).
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 #ifndef API_TRACE_FLAG
       
    73 EXPORT_C TInt DIscMultiplexerBase::CustomFunction( 
       
    74     const TUint16,
       
    75     const TUint16 aOperation,
       
    76     TAny* ,
       
    77     const TAny* aChannelPtr )
       
    78 #else 
       
    79 EXPORT_C TInt DIscMultiplexerBase::CustomFunction( 
       
    80     const TUint16 aChannelId,
       
    81     const TUint16 aOperation,
       
    82     TAny* aParameters,
       
    83     const TAny* aChannelPtr )
       
    84 #endif
       
    85     {
       
    86     A_TRACE( ( _T( "DIscMultiplexerBase::CustomFunction(0x%x, 0x%x, 0x%x, 0x%x)" ), aChannelId, aOperation, aParameters, aChannelPtr ) );
       
    87     CompleteRequest( aOperation, KErrNotSupported, aChannelPtr );
       
    88     return KErrNotSupported;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // DIscMultiplexerBase::GetChannelInfo
       
    93 // Get information on specified channel
       
    94 // ( other items were commented in a header ).
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 #ifndef API_TRACE_FLAG
       
    98 EXPORT_C TInt DIscMultiplexerBase::GetChannelInfo( 
       
    99     const TUint16, 
       
   100     TDes8& )
       
   101 #else 
       
   102 EXPORT_C TInt DIscMultiplexerBase::GetChannelInfo( 
       
   103     const TUint16 aChannelNumber, 
       
   104     TDes8& aInfo )
       
   105 #endif
       
   106 
       
   107     {
       
   108     A_TRACE( ( _T( "DIscMultiplexerBase::GetChannelInfo(0x%x, 0x%x)" ), aChannelNumber, &aInfo ) );
       
   109     return KErrNotSupported;
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // DIscMultiplexerBase::CompleteRequest
       
   114 // Complete specified asynchronous request
       
   115 // ( other items were commented in a header ).
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 // This method has been modified to allow channel sharing between application.
       
   119 // The completion routine uses directly a pointer on a DLogicalChannel instead of a channel index
       
   120 //
       
   121 EXPORT_C void DIscMultiplexerBase::CompleteRequest( 
       
   122     TUint16 aReqNumber, 
       
   123     TInt aStatus, 
       
   124     const TAny* aChannelPtr )
       
   125     {
       
   126     A_TRACE( ( _T( "DIscMultiplexerBase::CompleteRequest(0x%x, 0x%x, 0x%x)" ), aReqNumber, aStatus, aChannelPtr ) );
       
   127     iDevice->CompleteRequest( aReqNumber, aStatus, aChannelPtr );
       
   128     A_TRACE( ( _T( "DIscMultiplexerBase::CompleteRequest - return void" ) ) );
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // DIscMultiplexerBase::IsPending
       
   133 // Check if specified request is pending in ISC Driver
       
   134 // ( other items were commented in a header ).
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C TInt DIscMultiplexerBase::IsPending( 
       
   138     const TUint16 aReqNumber, 
       
   139     const TAny* aChannelPtr )
       
   140     {
       
   141     A_TRACE( ( _T( "DIscMultiplexerBase::IsPending(0x%x, 0x%x)" ), aReqNumber, aChannelPtr ) );
       
   142     return iDevice->IsPending( aReqNumber, aChannelPtr );
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // DIscMultiplexerBase::QueueFrame
       
   147 // Queue frame for sending
       
   148 // ( other items were commented in a header ).
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 EXPORT_C TInt DIscMultiplexerBase::QueueFrame( 
       
   152     const TUint16 aChannelId,
       
   153     const TDesC8* aFrame,
       
   154     const TAny* aChannelPtr,
       
   155     TAny* aFrameInfo )
       
   156     {
       
   157     A_TRACE( ( _T( "DIscMultiplexerBase::QueueFrame(0x%x, 0x%x, 0x%x, 0x%x)" ), aChannelId, aFrame, aChannelPtr, aFrameInfo ) );
       
   158     TInt error( KErrNone );
       
   159     if ( !aFrame )
       
   160         {
       
   161         error = KErrBadDescriptor;
       
   162         }
       
   163     else 
       
   164         {
       
   165         error = iDevice->QueueFrame( aChannelId, aFrame, aChannelPtr, aFrameInfo );
       
   166         }
       
   167 
       
   168     return error;
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // DIscMultiplexerBase::FlushQueue
       
   173 // Start sending the frames
       
   174 // ( other items were commented in a header ).
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C void DIscMultiplexerBase::FlushQueues()
       
   178     {
       
   179     A_TRACE( ( _T( "DIscMultiplexerBase::FlushQueue()" ) ) );
       
   180     iDevice->FlushQueues();
       
   181     A_TRACE( ( _T( "DIscMultiplexerBase::FlushQueue - return void" ) ) );
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // DIscMultiplexerBase::ULFlowControl
       
   186 // Notify flow control changes to ISC Driver
       
   187 // ( other items were commented in a header ).
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 EXPORT_C void DIscMultiplexerBase::ULFlowControl( 
       
   191     const TInt aULFlowStatus, 
       
   192     TUint16 aChannelId,
       
   193     TAny* aChannelPtr )
       
   194     {
       
   195     A_TRACE( ( _T( "DIscMultiplexerBase::ULFlowControl(0x%x, 0x%x)" ), aULFlowStatus, aChannelPtr ) );    
       
   196     iDevice->ULFlowControl( aULFlowStatus, aChannelId, aChannelPtr );
       
   197     A_TRACE( ( _T( "DIscMultiplexerBase::ULFlowControl - return void" ) ) );
       
   198     }
       
   199 
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // DIscMultiplexerBase::ReserveMemoryBlock
       
   203 // Reserve memory block
       
   204 // ( other items were commented in a header ).
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 EXPORT_C void DIscMultiplexerBase::ReserveMemoryBlock( 
       
   208     TDes8*& aPtr, 
       
   209     const TUint16 aSize )
       
   210     {
       
   211     A_TRACE( ( _T( "DIscMultiplexerBase::ReserveMemoryBlock(0x%x, 0x%x)" ), aPtr, aSize ) );
       
   212     iDevice->ReserveMemoryBlock( aPtr,aSize );
       
   213     A_TRACE( ( _T( "DIscMultiplexerBase::ReserveMemoryBlock - return void" ) ) );
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // DIscMultiplexerBase::ReleaseMemoryBlock
       
   218 // Release the reserved memory block
       
   219 // ( other items were commented in a header ).
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 EXPORT_C void DIscMultiplexerBase::ReleaseMemoryBlock( 
       
   223     TDes8* aPtr )
       
   224     {
       
   225     A_TRACE( ( _T( "DIscMultiplexerBase::ReleaseMemoryBlock(0x%x)" ), aPtr ) );
       
   226     iDevice->ReleaseMemoryBlock( aPtr );
       
   227     A_TRACE( ( _T( "DIscMultiplexerBase::ReleaseMemoryBlock - return void" ) ) );
       
   228     }
       
   229 
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // DIscMultiplexerBase::CopyFromUserBuffer
       
   233 // Due to GetThreadPtr this method will be deprecated in the future.
       
   234 // It is preffered to use GetThreadPtr instead. 
       
   235 // ( other items were commented in a header ).
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C TInt DIscMultiplexerBase::CopyFromUserBuffer( 
       
   239     const TDesC8& aUserBuffer,
       
   240     TDes8& aKernelBuffer,
       
   241     const TAny* aChannelPtr,
       
   242     const TInt aOffset )
       
   243     {
       
   244     A_TRACE( ( _T( "DIscMultiplexerBase::CopyFromUserBuffer(0x%x, 0x%x, 0x%x, 0x%x)" ), &aUserBuffer, &aKernelBuffer, aChannelPtr, aOffset ) );
       
   245     return iDevice->CopyFromUserBuffer( aUserBuffer, aKernelBuffer, aChannelPtr, aOffset );
       
   246     }
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // DIscMultiplexerBase::CopyToUserBuffer
       
   250 // Due to GetThreadPtr this method will be deprecated in the future.
       
   251 // It is preffered to use GetThreadPtr instead.  
       
   252 // ( other items were commented in a header ).
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 EXPORT_C TInt DIscMultiplexerBase::CopyToUserBuffer( 
       
   256     TAny* aUserBuffer, 
       
   257     const TDesC8& aKernelBuffer, 
       
   258     const TAny* aChannelPtr,
       
   259     const TInt aOffset )
       
   260     {
       
   261     A_TRACE( ( _T( "DIscMultiplexerBase::CopyToUserBuffer(0x%x, 0x%x, 0x%x, 0x%x)" ), aUserBuffer, &aKernelBuffer, aChannelPtr, aOffset ) );
       
   262     return iDevice->CopyToUserBuffer( aUserBuffer, aKernelBuffer, aChannelPtr, aOffset );
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // DIscMultiplexerBase::GetThreadPtr
       
   267 // Returns user side thread pointer no owenership is given.
       
   268 // ( other items were commented in a header ).
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 EXPORT_C DThread* DIscMultiplexerBase::GetThreadPtr( const TAny* aChannelPtr )
       
   272 	{
       
   273     A_TRACE( ( _T( "DIscMultiplexerBase::DIscMultiplexerBase::GetThreadPtr(0x%x)" ), aChannelPtr ) );
       
   274 	TRACE_ASSERT( aChannelPtr );
       
   275 	return iDevice->GetThreadPtr( aChannelPtr );	
       
   276 	}
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 // DIscMultiplexerBase::CancelSending
       
   280 // 
       
   281 // ( other items were commented in a header ).
       
   282 // -----------------------------------------------------------------------------
       
   283 //
       
   284 EXPORT_C TInt DIscMultiplexerBase::CancelSending( 
       
   285     const TUint16 aChannelId, 
       
   286     const TAny* aChannelPtr )
       
   287     {
       
   288     A_TRACE( ( _T( "DIscMultiplexerBase::CancelSending(0x%x, 0x%x)" ), aChannelId, aChannelPtr ) );
       
   289     return iDevice->CancelSending( aChannelId, aChannelPtr );
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // DIscMultiplexerBase::Connect
       
   294 // Connect ISC Driver to ISC Multiplexer
       
   295 // ( other items were commented in a header ).
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 EXPORT_C void DIscMultiplexerBase::Connect( 
       
   299     DIscDevice* aDevice )
       
   300     {
       
   301     A_TRACE( ( _T( "DIscMultiplexerBase::Connect(0x%x)" ), aDevice ) );
       
   302     ASSERT_RESET_ALWAYS( aDevice, "IscMultiplexerBase",EIscNullIscDriverPointer );
       
   303     iDevice = aDevice;
       
   304     A_TRACE( ( _T( "DIscMultiplexerBase::Connect - return void" ) ) );
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // DIscMultiplexerBase::SetInitializationParameters
       
   309 // Initialization string to multiplexer in case if needed before datatransmission driver has been initialized
       
   310 // ( other items were commented in a header ).
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 #ifndef API_TRACE_FLAG
       
   314 EXPORT_C void DIscMultiplexerBase::SetInitializationParameters( const TDesC8&)
       
   315 #else 
       
   316 EXPORT_C void DIscMultiplexerBase::SetInitializationParameters( const TDesC8& aParameters )
       
   317 #endif
       
   318     {
       
   319     A_TRACE( ( _T( "DIscMultiplexerBase::SetInitializationParameters not supported(0x%x)" ), &aParameters ) );
       
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // DIscMultiplexerBase::Install
       
   324 // Install from DLogicalDevice
       
   325 // ( other items were commented in a header ).
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 EXPORT_C TInt DIscMultiplexerBase::Install()
       
   329     {
       
   330     A_TRACE( ( _T( "DIscMultiplexerBase::Install()" ) ) );
       
   331     SetName( &KIscMultiplexerName );
       
   332     TInt r = Install2ndPhase();
       
   333     C_TRACE( ( _T( "DIscMultiplexerBase::Install - return 0x%x" ), r ) );
       
   334     return r;
       
   335     }
       
   336 
       
   337 // ================= E32Dll ==============
       
   338 // E32Dll
       
   339 // Dll entry point.
       
   340 // Returns: TInt Invariably return KErrNone.
       
   341 //
       
   342 #if defined( __WINSCW__ )
       
   343 DECLARE_STANDARD_LDD()
       
   344     {
       
   345     return NULL;
       
   346     }
       
   347 #endif
       
   348 //  End of File