systemswstubs/examplecommonisc/IscApi/src/IscApi.cpp
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2005 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 RIscApi class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <E32svr.H>
       
    22 #include <f32file.h>
       
    23 #include <iscapi.h>
       
    24 #include <IscDefinitions.h>
       
    25 #include <iscdefinitions.h>
       
    26 #include "IscTrace.h"
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 
       
    32 // CONSTANTS
       
    33 _LIT( KIscApiPanic,"IscApi Panic" );
       
    34 _LIT( KIscDriverName,"IscDriver" );
       
    35 _LIT( KIscDriverExtensionName,"IscDriverExtension" );
       
    36 
       
    37 // MACROS
       
    38 
       
    39 // LOCAL CONSTANTS AND MACROS
       
    40 _LIT( KIniFile,"Z:\\resource\\ISC\\isc_config.ini" );
       
    41 _LIT( KMultiplexerLdd,"MultiplexerLdd" );
       
    42 _LIT( KDataTransmissionLdd,"DataTransmissionLdd" );
       
    43 _LIT( KDataTransmissionPdd,"DataTransmissionPdd" );
       
    44 _LIT( KPdd,"PDD" );
       
    45 _LIT( KLdd,"LDD" );
       
    46 _LIT( KHashSign,"#" );
       
    47 _LIT( KSemiColon,";" );
       
    48 _LIT( KEqualSign,"=" );
       
    49 
       
    50 _LIT( KIscDriverLdd, "iscdriver.ldd" );
       
    51 _LIT( KIscDriverExtensionLdd, "iscdriverextension.ldd" );
       
    52 
       
    53 const TInt KZeroLength( KErrNone );
       
    54 const TInt KStartPosition( KErrNone );
       
    55 const TInt KOneParam( 1 );
       
    56 const TInt KTwoParams( 2 );
       
    57 const TInt KThreeParams( 3 );
       
    58 const TInt KFirstParam( 0 );
       
    59 const TInt KSecondParam( 1 );
       
    60 const TInt KThirdParam( 2 );
       
    61 const TInt KMajor( KErrNone );
       
    62 const TInt KMinor( KErrNone );
       
    63 const TInt KBuild( KErrNone );
       
    64 const TInt KAddPosition( 1 );
       
    65 const TInt KInfoLength( 1 );
       
    66 
       
    67 // MODULE DATA STRUCTURES
       
    68 
       
    69 // LOCAL FUNCTION PROTOTYPES
       
    70 
       
    71 // FORWARD DECLARATIONS
       
    72 
       
    73 // ============================ MEMBER FUNCTIONS ===============================
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // RIscApi::RIscApi
       
    77 // C++ default constructor can NOT contain any code, that
       
    78 // might leave.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C RIscApi::RIscApi()
       
    82     :iNeededLen( NULL, KZeroLength ),
       
    83      iNeededDataLen( NULL, KZeroLength ),
       
    84      iConnectionStatus( NULL, KZeroLength ),
       
    85      iFlowControlStatus( NULL, KZeroLength ),
       
    86      iOpen( EFalse ),   
       
    87      iChannelNumber( KIscFrameReceiverNotFound )
       
    88 #ifdef __WINS__
       
    89      ,iInitializing( EFalse )
       
    90 #endif
       
    91     {
       
    92     }
       
    93 
       
    94 
       
    95 EXPORT_C RIscApi::~RIscApi()
       
    96     {
       
    97     
       
    98     if( iOpen || iChannelNumber != KIscFrameReceiverNotFound )
       
    99         {
       
   100         Close();
       
   101         }
       
   102     else
       
   103     	{
       
   104     	// Do nothing.	
       
   105     	}
       
   106     	
       
   107     }
       
   108 
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // RIscApi::Initialize
       
   112 // Initialize the ISC Interface
       
   113 // ( other items were commented in a header ).
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C void RIscApi::InitializeModemInterface
       
   117         ( 
       
   118         TRequestStatus& aStatus
       
   119         )
       
   120     {
       
   121     A_TRACE( ( _T( "RIscApi::InitializeModemInterface(0x%x)" ), &aStatus ) );
       
   122 
       
   123 #ifdef __WINS__
       
   124     iInitializing = ETrue;
       
   125 #endif
       
   126 
       
   127     CTrapCleanup* cleanup = CTrapCleanup::New();
       
   128     TInt r( KErrNone );
       
   129     TInt r2( KErrNone );
       
   130     HBufC8* multiplexerInit = NULL;
       
   131     TRAP( r, ( multiplexerInit = HBufC8::NewL( KIscIniLineLength ) ) );
       
   132     // buffer to hold the init-string for second-level driver
       
   133     HBufC8* dataTransmissionInit = NULL;
       
   134     TRAP( r2, ( dataTransmissionInit = HBufC8::NewL( KIscIniLineLength ) ) );
       
   135     __ASSERT_ALWAYS( ( KErrNone == r && KErrNone == r2 ),
       
   136     	User::Panic( KIscApiPanic, EIscApiMemoryAllocationFailure ) );
       
   137     // Read ini-file and load needed drivers.
       
   138     TRAP( r, LoadL( *multiplexerInit, *dataTransmissionInit ) );
       
   139     if( KErrAlreadyExists == r )
       
   140         {
       
   141         TRACE_ASSERT_ALWAYS;
       
   142         C_TRACE( ( _T( "RIscApi::InitializeModemInterface DRIVERS ERROR" ) ) );
       
   143         delete multiplexerInit;
       
   144         multiplexerInit = NULL;
       
   145         delete dataTransmissionInit;
       
   146         dataTransmissionInit = NULL;
       
   147         delete cleanup;
       
   148         cleanup = NULL;
       
   149         TRequestStatus* ptrStatus = &aStatus;
       
   150         User::RequestComplete( ptrStatus, r );
       
   151         return;
       
   152         }
       
   153     else
       
   154         {
       
   155         __ASSERT_ALWAYS( ( KErrNone == r ),
       
   156                            User::Panic( KIscApiPanic,EIscApiDriverLoadFail ) );
       
   157         }
       
   158 
       
   159     // Open control channel
       
   160     TInt channel( KIscControlChannel );
       
   161     TInt err = DoCreate( KIscDriverName, 
       
   162                             TVersion( KMajor, KMinor, KBuild ), 
       
   163                             channel,
       
   164                             NULL,
       
   165                             NULL,
       
   166                             EOwnerThread );
       
   167     __ASSERT_ALWAYS( KErrNone == err,
       
   168                      User::Panic( KIscApiPanic, EIscApiChannelCreateFail ) );
       
   169     iChannelNumber = static_cast<TUint16>( channel );
       
   170     iOpen = ETrue;
       
   171 
       
   172     TPtrC8 multiplexerInitString( multiplexerInit->Des() );
       
   173     TPtrC8 dataTransmissionInitString( dataTransmissionInit->Des() );
       
   174     TAny* params[ KThreeParams ];
       
   175     params[ KFirstParam ] = (TAny*)&aStatus;
       
   176     params[ KSecondParam ] = static_cast<TAny*>( &multiplexerInitString );
       
   177     params[ KThirdParam ] = static_cast<TAny*>( &dataTransmissionInitString );
       
   178     
       
   179     aStatus = KRequestPending;
       
   180     //Initialize Data transmission 
       
   181     DoSvControl( EIscAsyncInitializeModemInterface, params );
       
   182   
       
   183     delete multiplexerInit;
       
   184     multiplexerInit = NULL;
       
   185     delete dataTransmissionInit;
       
   186     dataTransmissionInit = NULL;
       
   187     delete cleanup;
       
   188     cleanup = NULL;
       
   189     
       
   190 #ifdef __WINS__
       
   191     iInitializing = EFalse;
       
   192 #endif
       
   193     A_TRACE( ( _T( "RIscApi::InitializeModemInterfaceL - return void" ) ) );
       
   194     
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // RIscApi::InitializeCancel
       
   199 // Cancel ISC Initialization sequence
       
   200 // ( other items were commented in a header ).
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 EXPORT_C void RIscApi::InitializeCancel()
       
   204     {
       
   205     A_TRACE( ( _T( "RIscApi::InitializeCancel()" ) ) );
       
   206 
       
   207 	if( iOpen && iChannelNumber == KIscControlChannel )
       
   208 		{
       
   209 		DoControl( EIscCancelAsyncInitialize );			
       
   210 		}
       
   211 	else
       
   212 		{
       
   213 		// Do nothing if not controlchannel who is handling the initialization.	
       
   214 		}
       
   215 
       
   216     A_TRACE( ( _T( "RIscApi::InitializeCancel - return void" ) ) );
       
   217     }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // RIscApi::LoadL
       
   221 // Load required drivers using Isc_config.ini file
       
   222 // ( other items were commented in a header ).
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void RIscApi::LoadL
       
   226         ( 
       
   227         const TDesC8& aMultiplexerInit,     // Multiplexer init. 
       
   228         const TDesC8& aDataTransmissionInit // Datatransmission init.
       
   229         ) const
       
   230     {
       
   231     C_TRACE( ( _T( "RIscApi::LoadL(0x%x, 0x%x)" ), &aMultiplexerInit,
       
   232     											   &aDataTransmissionInit ) );
       
   233 
       
   234     TInt err( KErrNone );
       
   235     TInt loadStatus( KErrNone );
       
   236     TInt pos( KErrNone );
       
   237     
       
   238     // Temporary buffers.
       
   239     HBufC* driverNameBuf = HBufC::NewLC( KIscIniLineLength );
       
   240     HBufC* iniFileLineBuf = HBufC::NewLC( KIscIniLineLength );
       
   241     HBufC* initStringBuf = HBufC::NewLC( KIscIniLineLength );
       
   242     // Temporary pointers.
       
   243     TPtr driverName( driverNameBuf->Des() );
       
   244     TPtr initString( initStringBuf->Des() );
       
   245     TPtr iniFileLine( iniFileLineBuf->Des() );
       
   246 
       
   247     RFs fsSession;
       
   248     CleanupClosePushL( fsSession );
       
   249     RFile file;
       
   250     CleanupClosePushL( file );
       
   251     TFileText fileText;
       
   252     User::LeaveIfError( fsSession.Connect() );
       
   253     User::LeaveIfError( file.Open( fsSession, KIniFile,
       
   254     							   EFileStreamText | EFileRead ) );
       
   255     fileText.Set( file );
       
   256 
       
   257     while( KErrNone == fileText.Read( iniFileLine ) )
       
   258         {
       
   259         if( KErrNone < iniFileLine.Length() )
       
   260             {
       
   261             C_TRACE( ( iniFileLine ) );
       
   262             pos = KErrNotFound;
       
   263             loadStatus = KErrNotFound;
       
   264             if ( iniFileLine.Find( KHashSign ) != KErrNotFound )
       
   265                 {
       
   266                 pos = KErrNone;
       
   267                 loadStatus = KErrNone;
       
   268                 }
       
   269             else if ( iniFileLine.Find( KDataTransmissionPdd ) != KErrNotFound )
       
   270                 {
       
   271                 C_TRACE( ( _T( "RIscApi::LoadL - datatransmissionpdd" ) ) );
       
   272                 iniFileLine.Trim();
       
   273                 pos = InifileLineParser( iniFileLine, driverName );
       
   274                 if( KErrNotFound != pos )
       
   275                     {
       
   276                     loadStatus = User::LoadPhysicalDevice( driverName );
       
   277                     }
       
   278                 else
       
   279                 	{
       
   280                 	// Do nothing.
       
   281                 	}
       
   282                 }          
       
   283             else if ( iniFileLine.Find( KDataTransmissionLdd ) != KErrNotFound )
       
   284                 {
       
   285                 C_TRACE( ( iniFileLine ) );
       
   286                 pos = InifileLineParser( iniFileLine, driverName );
       
   287                 if( KErrNotFound != pos )
       
   288                     {
       
   289                     DriverNameParser( initString, driverName,
       
   290                     				 *&aDataTransmissionInit );
       
   291                     loadStatus = User::LoadLogicalDevice( driverName );
       
   292                     }
       
   293                 else
       
   294                 	{
       
   295                 	// Do nothing.
       
   296                 	}
       
   297                 }
       
   298             else if ( iniFileLine.Find( KMultiplexerLdd ) != KErrNotFound )
       
   299                 {
       
   300                 C_TRACE( ( iniFileLine ) );
       
   301                 pos = InifileLineParser( iniFileLine, driverName );
       
   302                 if( KErrNotFound != pos )
       
   303                     {
       
   304                     DriverNameParser( initString, driverName,
       
   305                     				  *&aMultiplexerInit );
       
   306                     loadStatus = User::LoadLogicalDevice( driverName );
       
   307                     }
       
   308                 else
       
   309                 	{
       
   310                 	// Do nothing.
       
   311                 	}
       
   312                 }
       
   313             else if ( iniFileLine.Find( KPdd ) != KErrNotFound )
       
   314                 {
       
   315                 C_TRACE( ( _T( "RIscApi::LoadL - pdd" ) ) );
       
   316                 iniFileLine.Trim();
       
   317                 pos = InifileLineParser( iniFileLine, driverName );
       
   318                 if( KErrNotFound != pos )
       
   319                     {
       
   320                     loadStatus = User::LoadPhysicalDevice( driverName );
       
   321                     }
       
   322                 else
       
   323                 	{
       
   324                 	// Do nothing.
       
   325                 	}
       
   326                 }
       
   327             else if ( iniFileLine.Find( KLdd ) != KErrNotFound )
       
   328                 {
       
   329                 RDebug::Print( _L( "RIscApi::LoadL ldd" ) );
       
   330                 iniFileLine.Trim();
       
   331                 pos = InifileLineParser( iniFileLine, driverName );
       
   332                 if( KErrNotFound != pos )
       
   333                     {
       
   334                     loadStatus = User::LoadLogicalDevice( driverName );
       
   335                     }
       
   336                 else
       
   337                 	{
       
   338                 	// Do nothing.
       
   339                 	}
       
   340                 }
       
   341             __ASSERT_ALWAYS( pos != KErrNotFound,
       
   342             				 User::Panic( KIscApiPanic, EIscApiFalseIniFile ) );
       
   343             __ASSERT_ALWAYS( KErrAlreadyExists != loadStatus,
       
   344             				 User::Leave( loadStatus ) );
       
   345             __ASSERT_ALWAYS( KErrNone == loadStatus,
       
   346             				 User::Panic( KIscApiPanic, EIscApiDriverLoadFail ) );
       
   347             }
       
   348         else
       
   349         	{
       
   350         	C_TRACE( ( _T( "RIscApi::LoadL IniFileLength = KErrNone" ) ) );
       
   351         	}
       
   352         }
       
   353     loadStatus = User::LoadLogicalDevice( KIscDriverLdd );
       
   354     err = User::LoadLogicalDevice( KIscDriverExtensionLdd );
       
   355     C_TRACE( ( _T( "RIscApi::LoadL drivers iscdriver %d, iscdriverext %d" ),
       
   356     			    loadStatus, err ) );
       
   357     __ASSERT_ALWAYS( ( KErrNone == loadStatus|| KErrNone == err ),
       
   358                        User::Panic( KIscApiPanic, EIscApiDriverLoadFail ) );
       
   359     // R-Classes fsSession and file Close-method is called when deleted
       
   360     // from CleanupStack.
       
   361     CleanupStack::PopAndDestroy( KTwoParams );
       
   362     CleanupStack::PopAndDestroy( initStringBuf );
       
   363     CleanupStack::PopAndDestroy( iniFileLineBuf );
       
   364     CleanupStack::PopAndDestroy( driverNameBuf );
       
   365     C_TRACE( ( _T( "RIscApi::LoadL - return void" ) ) );
       
   366     
       
   367     }
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // IscApi::LoadLHelper
       
   371 // Helps parsing the .ini file.
       
   372 // ( other items were commented in a header ).
       
   373 // -----------------------------------------------------------------------------
       
   374 //
       
   375 TInt RIscApi::InifileLineParser
       
   376         (
       
   377         TDes& aInifileLine,
       
   378         TDes& aDriverName 
       
   379         ) const
       
   380     {
       
   381     C_TRACE( ( _T( "RIscApi::InifileLineParser" ) ) );
       
   382     
       
   383     TInt position( KErrNotFound );
       
   384     position = aInifileLine.Find( KEqualSign );
       
   385     if( KErrNotFound != position )
       
   386         {
       
   387         // Split the string.
       
   388         C_TRACE( ( aInifileLine ) );
       
   389         aDriverName.Zero();
       
   390         aDriverName.Append( aInifileLine.Mid( position + KAddPosition ) );
       
   391         aInifileLine.Delete(  KStartPosition, KIscIniLineLength );
       
   392         C_TRACE( ( aDriverName ) );
       
   393         }
       
   394     else
       
   395     	{
       
   396     	// Do nothing.	
       
   397     	}         
       
   398     C_TRACE( ( _T( "RIscApi::InifileLineParser return %d" ), position ) );
       
   399     return position;
       
   400        
       
   401     }
       
   402 
       
   403 // -----------------------------------------------------------------------------
       
   404 // IscApi::LoadLSecondHelper
       
   405 // Helps parsing the .ini file.
       
   406 // ( other items were commented in a header ).
       
   407 // -----------------------------------------------------------------------------
       
   408 //    
       
   409 void RIscApi::DriverNameParser
       
   410         (
       
   411         TDes& aInitString,
       
   412         TDes& aDriverName,
       
   413         const TDesC8& aString 
       
   414         )const    
       
   415     {
       
   416     C_TRACE( ( _T( "RIscApi::DriverNameParser" ) ) );
       
   417 
       
   418     TInt position = aDriverName.Find( KSemiColon );
       
   419     if( KErrNotFound != position )
       
   420         {
       
   421         C_TRACE( ( aInitString ) );
       
   422         // Split the string.
       
   423         aInitString.Zero();
       
   424         aInitString.Append( aDriverName.Mid( position + KAddPosition ) );
       
   425         aDriverName.Delete( position, KIscIniLineLength );
       
   426         C_TRACE( ( aDriverName ) );
       
   427         TPtr8 tmpPtr( ( static_cast<HBufC8*>( &const_cast<TDesC8&>( aString ) ) )->Des() );
       
   428         tmpPtr.Append( aInitString );
       
   429         C_TRACE( ( aInitString ) );
       
   430         }
       
   431     else
       
   432     	{
       
   433     	// Do nothing.	
       
   434     	}         
       
   435     C_TRACE( ( _T( "RIscApi::DriverNameParser return " ) ) );
       
   436 
       
   437     }
       
   438 
       
   439 // -----------------------------------------------------------------------------
       
   440 // RIscApi::Open
       
   441 // Open ISC channel asyncronously
       
   442 // ( other items were commented in a header ).
       
   443 // -----------------------------------------------------------------------------
       
   444 //
       
   445 EXPORT_C void RIscApi::Open(    
       
   446     const TUint16 aChannelNumber,    
       
   447     TRequestStatus& aStatus,
       
   448     TOwnerType aType,
       
   449     const TDesC8* aOpenParams )
       
   450     {
       
   451     A_TRACE( ( _T( "RIscApi::Open(0x%x, 0x%x, 0x%x, 0x%x) this %x" ),
       
   452     			  aChannelNumber, &aStatus, aType, aOpenParams, this ) );
       
   453 
       
   454     // In case if async Close() is called but channel is not destructed,
       
   455     // release kernel side memory allocations before actual channel opening.
       
   456     if( iChannelNumber != KIscFrameReceiverNotFound && iOpen == EFalse )
       
   457         {
       
   458         Close();
       
   459         }
       
   460     else
       
   461     	{
       
   462     	// Do nothing.	
       
   463     	}        
       
   464 
       
   465 #ifdef __WINS__
       
   466     // InitializeModemInterface() must be called to load correct drivers.
       
   467     // In HW this is done e.g. from EStart 
       
   468 
       
   469     RMutex iscapiMutex;
       
   470     if ( !iInitializing )
       
   471         {
       
   472         C_TRACE( ( _T( "RIscApi::Open mutex creation" ) ) );
       
   473         TInt createErr( iscapiMutex.CreateGlobal( _L( "ISCAPICONNECT" ) ) );
       
   474         if ( createErr == KErrNoMemory )
       
   475             {
       
   476             C_TRACE( ( _T( "RIscApi::Open mutex creation FAILED" ) ) );
       
   477             TRequestStatus* ptrStatus = &aStatus;
       
   478             User::RequestComplete( ptrStatus, KErrNoMemory );
       
   479             return;
       
   480             }
       
   481         else if ( createErr )
       
   482             {
       
   483             TInt openErr( iscapiMutex.OpenGlobal( _L( "ISCAPICONNECT" ) ) );
       
   484             if ( openErr )
       
   485                 {
       
   486                 C_TRACE( ( _T( "RIscApi::Open mutex open FAILED" ) ) );
       
   487                 TRequestStatus* ptrStatus = &aStatus;
       
   488                 User::RequestComplete( ptrStatus, KErrNoMemory );
       
   489                 return;
       
   490                 }
       
   491 			else
       
   492 				{
       
   493 				// Do nothing.	
       
   494 				}    
       
   495             }
       
   496 	    else
       
   497 	    	{
       
   498 	    	// Do nothing.	
       
   499 	    	}            
       
   500         iscapiMutex.Wait();
       
   501         }
       
   502         
       
   503     RDevice handle;
       
   504     // If already openend, initialization not needed
       
   505     TInt r = handle.Open( KIscDriverName );
       
   506     if( r == KErrNotFound && !iInitializing )
       
   507         {
       
   508         RIscApi temp;
       
   509         TRequestStatus status;
       
   510         temp.InitializeModemInterface( status );
       
   511         iInitializing = EFalse;
       
   512         
       
   513         User::WaitForRequest( status );
       
   514         r = status.Int();
       
   515 
       
   516         temp.Close();
       
   517         }
       
   518     else
       
   519     	{
       
   520     	// Do nothing.	
       
   521     	}        
       
   522     
       
   523     if( !iInitializing )
       
   524         {
       
   525         iscapiMutex.Signal();
       
   526         }
       
   527     else
       
   528     	{
       
   529     	// Do nothing.	
       
   530     	}            
       
   531 
       
   532     if( r != KErrNone )
       
   533         {
       
   534         C_TRACE( ( _T( "RIscApi::Open Initialization FAILED" ) ) );
       
   535         TRequestStatus* ptrStatus = &aStatus;
       
   536         User::RequestComplete( ptrStatus, r );
       
   537         return;
       
   538         }
       
   539     else
       
   540     	{
       
   541     	// Do nothing.	
       
   542     	}        
       
   543 #endif
       
   544 
       
   545     TBuf8<KInfoLength> info;
       
   546     TInt error( KErrInUse );
       
   547     if( !iOpen )
       
   548         {
       
   549         // handle channels 1 .. 31, open channel to IscDriver
       
   550         if ( aChannelNumber >= KIscFirstChannel 
       
   551             && aChannelNumber < KIscMaxChannelsInLdd )
       
   552             {
       
   553             C_TRACE( ( _T( "RIscApi::Open 1st ldd" ) ) );
       
   554             info.Append( ( TUint8 )aChannelNumber );
       
   555             error = DoCreate( KIscDriverName, 
       
   556                                 TVersion( KMajor, KMinor, KBuild ), 
       
   557                                 ( TInt )aChannelNumber, 
       
   558                                 NULL, 
       
   559                                 &info, 
       
   560                                 aType );
       
   561             
       
   562             }
       
   563         // handle channels 32 .. 63, open channel to IscDriverExtension
       
   564         else if ( aChannelNumber >= KIscMaxChannelsInLdd
       
   565                   && aChannelNumber < KIscNumberOfUnits )
       
   566             {
       
   567             C_TRACE( ( _T( "RIscApi::Open 2nd ldd" ) ) );
       
   568             info.Append( ( TUint8 )aChannelNumber );
       
   569             TInt channelCount( aChannelNumber - KIscMaxChannelsInLdd );
       
   570             error = DoCreate( KIscDriverExtensionName, 
       
   571                                 TVersion( KMajor, KMinor, KBuild ), 
       
   572                                 channelCount, 
       
   573                                 NULL, 
       
   574                                 &info, 
       
   575                                 aType );
       
   576             }
       
   577         // channel number out of range
       
   578         else // illegal channel number
       
   579             {
       
   580             User::Panic( KIscApiPanic,EIscApiChannelNumberOutOfRange );
       
   581             }
       
   582         }
       
   583 
       
   584     if ( error != KErrNone )
       
   585         {
       
   586         C_TRACE( ( _T( "RIscApi::Open - Channel open Failed,\
       
   587          channel 0x%x error %d" ), aChannelNumber, error ) );
       
   588         TRequestStatus* ptrStatus = &aStatus;
       
   589         User::RequestComplete( ptrStatus, error );
       
   590         }
       
   591     else
       
   592         {
       
   593         iChannelNumber = aChannelNumber;
       
   594         C_TRACE( ( _T( "RIscApi::Open iChannelNumber %d " ), iChannelNumber ) );
       
   595         iOpen = ETrue;
       
   596 	    TAny* params[ KThreeParams ];   
       
   597 	    params[ KFirstParam ] = (TAny*)&aStatus;
       
   598 	    params[ KSecondParam ] = (TAny*)aChannelNumber;
       
   599 	    params[ KThirdParam ] = (TAny*)aOpenParams;
       
   600 
       
   601         aStatus = KRequestPending;
       
   602         error = DoSvControl( EIscAsyncOpen, params );
       
   603         }
       
   604 
       
   605     A_TRACE(  (  _T(  "RIscApi::Open - return void" ) ) );
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 // RIscApi::OpenCancel
       
   610 // Cancel asynchronous channel opening
       
   611 // ( other items were commented in a header ).
       
   612 // -----------------------------------------------------------------------------
       
   613 //
       
   614 EXPORT_C void RIscApi::OpenCancel()
       
   615     {
       
   616     A_TRACE( ( _T( "RIscApi::OpenCancel() channel 0x%x" ), iChannelNumber ) );
       
   617 
       
   618     PanicIfNotOpen();
       
   619 
       
   620     DoSvControl( EIscCancelAsyncOpen );
       
   621     Close();
       
   622     
       
   623     A_TRACE( ( _T( "RIscApi::OpenCancel - return void" )  ) );
       
   624     }
       
   625 
       
   626 // -----------------------------------------------------------------------------
       
   627 // RIscApi::Close
       
   628 // Close ISC Channel
       
   629 // ( other items were commented in a header ).
       
   630 // -----------------------------------------------------------------------------
       
   631 //
       
   632 EXPORT_C void RIscApi::Close()
       
   633     {
       
   634     A_TRACE( ( _T( "RIscApi::Close channel 0x%x" ), iChannelNumber ) );
       
   635 
       
   636     if( iChannelNumber <= KIscLastChannel && iOpen )
       
   637         {
       
   638         DoSvControl( EIscSyncClose );
       
   639         }
       
   640     else
       
   641     	{
       
   642     	// Do nothing.	
       
   643     	}        
       
   644 
       
   645     iChannelNumber = KIscFrameReceiverNotFound;
       
   646     iOpen = EFalse;
       
   647     RHandleBase::Close();
       
   648 
       
   649     A_TRACE( ( _T( "RIscApi::Close - return void" )  ) );
       
   650     }
       
   651 
       
   652 // -----------------------------------------------------------------------------
       
   653 // RIscApi::Close
       
   654 // Close ISC Channel
       
   655 // ( other items were commented in a header ).
       
   656 // -----------------------------------------------------------------------------
       
   657 //
       
   658 EXPORT_C void RIscApi::Close( TRequestStatus& aStatus )
       
   659     {
       
   660     A_TRACE( ( _T( "RIscApi::Close(0x%x) channel (0x%x)" ), &aStatus,
       
   661     			  iChannelNumber ) );
       
   662     
       
   663     TAny* params[ KOneParam ];
       
   664 
       
   665     params[ KFirstParam ] = (TAny*)&aStatus;
       
   666     aStatus = KRequestPending;
       
   667     if ( iChannelNumber <= KIscLastChannel && 
       
   668          iOpen )
       
   669         {
       
   670         DoSvControl( EIscAsyncClose, params );
       
   671         }
       
   672     else												
       
   673         {
       
   674         C_TRACE((_T("RIscApi::Close FAILED")));
       
   675         TRequestStatus* ptrStatus = &aStatus;
       
   676         User::RequestComplete( ptrStatus, KErrNotReady );
       
   677         }
       
   678 
       
   679     iOpen = EFalse;
       
   680 
       
   681     A_TRACE( ( _T( "RIscApi::Close - return void" )  ) );
       
   682     }
       
   683 
       
   684 // -----------------------------------------------------------------------------
       
   685 // RIsaApi::ResetBuffers
       
   686 // Resets buffers.
       
   687 // ( other items were commented in a header ).
       
   688 // -----------------------------------------------------------------------------
       
   689 //
       
   690 EXPORT_C void RIscApi::ResetBuffers()
       
   691     {
       
   692     A_TRACE( ( _T( "RIscApi::ResetBuffers() 0x%x" ), iChannelNumber ) );
       
   693     
       
   694     PanicIfNotOpen();
       
   695     
       
   696     DoSvControl( EIscSyncResetBuffers );
       
   697     
       
   698     A_TRACE( ( _T( "RIscApi::ResetBuffers - return void" ) ) );
       
   699     }
       
   700 
       
   701 // -----------------------------------------------------------------------------
       
   702 // RIscApi::Send
       
   703 // Send data to Domestic OS ( asynchronous )
       
   704 // ( other items were commented in a header ).
       
   705 // -----------------------------------------------------------------------------
       
   706 //
       
   707 EXPORT_C void RIscApi::Send( 
       
   708     TRequestStatus& aStatus, 
       
   709     const TDesC8& aData )
       
   710     {
       
   711     A_TRACE( ( _T( "RIscApi::Send(0x%x, 0x%x) iChannelNumber (0x%x) this %x" ),
       
   712     			   &aStatus, &aData, iChannelNumber, this ) );
       
   713     
       
   714     PanicIfNotOpen();
       
   715     
       
   716     TAny* params[ KTwoParams ];
       
   717 
       
   718     params[ KFirstParam ] = (TAny*)&aStatus;
       
   719     params[ KSecondParam ] = (TAny*)&aData;
       
   720 
       
   721     aStatus = KRequestPending;
       
   722     DoControl( EIscAsyncSend, params );
       
   723 
       
   724     A_TRACE( ( _T( "RIscApi::Send - return void" )  ) );
       
   725     }
       
   726 
       
   727 // -----------------------------------------------------------------------------
       
   728 // RIscApi::Send
       
   729 // Send data to Domestic OS ( synchronous )
       
   730 // ( other items were commented in a header ).
       
   731 // -----------------------------------------------------------------------------
       
   732 //
       
   733 EXPORT_C TInt RIscApi::Send( 
       
   734     const TDesC8& aData )
       
   735     {
       
   736     A_TRACE( ( _T( "RIscApi::Send(0x%x) iChannelNumber (0x%x) this %x" ),
       
   737     			   &aData, iChannelNumber, this ) );    
       
   738     
       
   739     
       
   740     PanicIfNotOpen();
       
   741     
       
   742     TInt error( KErrNone );
       
   743          
       
   744     TAny* params[ KOneParam ];
       
   745     params[ KFirstParam ] = (TAny*)&aData;
       
   746     
       
   747     error = DoControl( EIscSyncSend, params );
       
   748     
       
   749     A_TRACE( ( _T( "RIscApi::Send - return %d" ), error ) );
       
   750     return error;
       
   751     }
       
   752 
       
   753 // -----------------------------------------------------------------------------
       
   754 // RIscApi::SendCancel
       
   755 // Cancel asynchronous Send request
       
   756 // ( other items were commented in a header ).
       
   757 // -----------------------------------------------------------------------------
       
   758 //
       
   759 EXPORT_C void RIscApi::SendCancel()
       
   760     {
       
   761     A_TRACE(  (  _T(  "RIscApi::SendCancel(), channel 0x%x" ), iChannelNumber ) );
       
   762 
       
   763     PanicIfNotOpen();
       
   764 
       
   765     DoSvControl( EIscCancelAsyncSend );
       
   766 
       
   767     A_TRACE( ( _T( "RIscApi::SendCancel - return void" ) ) );
       
   768     }
       
   769 
       
   770 // -----------------------------------------------------------------------------
       
   771 // RIscApi::Receive
       
   772 // Receive data from Domestic OS
       
   773 // ( other items were commented in a header ).
       
   774 // -----------------------------------------------------------------------------
       
   775 //
       
   776 EXPORT_C void RIscApi::Receive( 
       
   777     TRequestStatus& aStatus, 
       
   778     TDes8& aData,
       
   779     TUint16& aNeededBufLen )
       
   780     {
       
   781     A_TRACE( ( _T( "RIscApi::Receive 0x%x, 0x%x, 0x%x iChannelNumber 0x%x this\
       
   782     		    0x%x" ), &aStatus, &aData, aNeededBufLen, iChannelNumber, this ) );
       
   783         
       
   784     PanicIfNotOpen();
       
   785     
       
   786     TAny* params[ KThreeParams ];
       
   787     
       
   788     iNeededLen.Set( ( TUint8* )&aNeededBufLen, sizeof ( TUint16 ), sizeof ( TUint16 ) );
       
   789 
       
   790     params[ KFirstParam ] = (TAny*)&aStatus;
       
   791     params[ KSecondParam ] = (TAny*)&aData;
       
   792     params[ KThirdParam ] = (TAny*)&iNeededLen;
       
   793 
       
   794     aStatus = KRequestPending;
       
   795     DoControl( EIscAsyncReceive, params );
       
   796 
       
   797     A_TRACE( ( _T( "RIscApi::Receive - return void" ) ) );
       
   798     }
       
   799 
       
   800 // -----------------------------------------------------------------------------
       
   801 // RIscApi::ReceiveCancel
       
   802 // Cancel data receiving from Domestic OS
       
   803 // ( other items were commented in a header ).
       
   804 // -----------------------------------------------------------------------------
       
   805 //
       
   806 EXPORT_C void RIscApi::ReceiveCancel()
       
   807     {
       
   808     A_TRACE( ( _T( "RIscApi::ReceiveCancel() iChannelNumber (0x%x)" ),
       
   809     			    iChannelNumber ) );
       
   810     
       
   811     PanicIfNotOpen();
       
   812     
       
   813     DoControl( EIscCancelAsyncReceive );
       
   814 
       
   815     A_TRACE( ( _T( "RIscApi::ReceiveCancel - return void" ) ) );
       
   816     }
       
   817 
       
   818 // -----------------------------------------------------------------------------
       
   819 // RIscApi::DataReceiveCancel
       
   820 // Cancel data receiving from Domestic OS
       
   821 // ( other items were commented in a header ).
       
   822 // -----------------------------------------------------------------------------
       
   823 //
       
   824 EXPORT_C void RIscApi::DataReceiveCancel()
       
   825     {
       
   826     A_TRACE( ( _T( "RIscApi::DataReceiveCancel() channel 0x%x" ),
       
   827     			    iChannelNumber ) );
       
   828 
       
   829     PanicIfNotOpen();
       
   830     
       
   831     DoControl( EIscCancelAsyncDataReceive );
       
   832 
       
   833     A_TRACE( ( _T( "RIscApi::DataReceiveCancel - return void" ) ) );
       
   834     }
       
   835 
       
   836 // -----------------------------------------------------------------------------
       
   837 // RIscApi::ConnectionStatus
       
   838 // Get the current connection status
       
   839 // ( other items were commented in a header ).
       
   840 // -----------------------------------------------------------------------------
       
   841 //
       
   842 EXPORT_C TInt RIscApi::ConnectionStatus() 
       
   843     {
       
   844     A_TRACE( ( _T( "RIscApi::ConnectionStatus() channel 0x%x" ),
       
   845     			    iChannelNumber ) );
       
   846     
       
   847     PanicIfNotOpen();
       
   848     
       
   849     TInt state( EIscConnectionOk );
       
   850 
       
   851     state = DoControl( EIscSyncGetConnectionStatus );
       
   852     
       
   853     A_TRACE( ( _T( "RIscApi::ConnectionStatus - return 0x%x" ), state ) );
       
   854 
       
   855     return state;
       
   856     }
       
   857 
       
   858 // -----------------------------------------------------------------------------
       
   859 // RIscApi::NotifyConnectionStatus
       
   860 // Listen for connection status changes
       
   861 // ( other items were commented in a header ).
       
   862 // -----------------------------------------------------------------------------
       
   863 //
       
   864 EXPORT_C void RIscApi::NotifyConnectionStatus( 
       
   865     TRequestStatus& aStatus,
       
   866     TInt& aConnectionStatus )
       
   867     {
       
   868     A_TRACE( ( _T( "RIscApi::NotifyConnectionStatus(0x%x, 0x%x)\
       
   869     iChannelNumber (0x%x)" ), &aStatus, aConnectionStatus, iChannelNumber ) );
       
   870     
       
   871     PanicIfNotOpen();
       
   872         
       
   873     TAny* params[ KTwoParams ];
       
   874     
       
   875     iConnectionStatus.Set( ( TUint8* )&aConnectionStatus, 
       
   876     						 sizeof ( TInt ), sizeof ( TInt ) );
       
   877 
       
   878     params[ KFirstParam ] = (TAny*)&aStatus;
       
   879     params[ KSecondParam ] = (TAny*)&iConnectionStatus;
       
   880     
       
   881     aStatus = KRequestPending;
       
   882     DoControl( EIscAsyncNotifyConnectionStatus, params );
       
   883 
       
   884     A_TRACE( ( _T( "RIscApi::NotifyConnectionStatus - return void" ) ) );    
       
   885     }
       
   886 
       
   887 // -----------------------------------------------------------------------------
       
   888 // RIscApi::NotifyConnectionStatusCancel
       
   889 // Stop listening for connection status changes
       
   890 // ( other items were commented in a header ).
       
   891 // -----------------------------------------------------------------------------
       
   892 //
       
   893 EXPORT_C void RIscApi::NotifyConnectionStatusCancel()
       
   894     {
       
   895     A_TRACE( ( _T( "RIscApi::NotifyConnectionStatusCancel() channel 0x%x" ),
       
   896     			    iChannelNumber ) );
       
   897 
       
   898     PanicIfNotOpen();
       
   899     
       
   900     DoControl( EIscCancelAsyncNotifyConnection );
       
   901 
       
   902     A_TRACE( ( _T( "RIscApi::NotifyConnectionStatusCancel - return void" ) ) );
       
   903     }
       
   904 
       
   905 
       
   906 // -----------------------------------------------------------------------------
       
   907 // RIscApi::CustomFunction
       
   908 // Asynchronous API extension function
       
   909 // ( other items were commented in a header ).
       
   910 // -----------------------------------------------------------------------------
       
   911 //
       
   912 EXPORT_C void RIscApi::CustomFunction( 
       
   913     TRequestStatus& aStatus, 
       
   914     const TUint16 aOperation, 
       
   915     TAny* aParameters )
       
   916     {
       
   917     A_TRACE( ( _T( "RIscApi::CustomFunction(0x%x, 0x%x, 0x%x) iChannelNumber\
       
   918      0x%x" ), &aStatus, aOperation, aParameters, iChannelNumber ) );
       
   919     
       
   920     PanicIfNotOpen();
       
   921 
       
   922     // Check if custom operation is out of range. 
       
   923     if ( aOperation < EIscAsyncCustomOperation1 
       
   924         || aOperation > EIscAsyncCustomOperation5 )
       
   925         {
       
   926         User::Panic( KIscApiPanic, EIscApiCustomFunctionUndefined );
       
   927         }
       
   928     TAny* params[ KTwoParams ];
       
   929     
       
   930     params[ KFirstParam ] = (TAny*)&aStatus;
       
   931     params[ KSecondParam ] = aParameters;
       
   932 
       
   933     aStatus = KRequestPending;
       
   934     DoSvControl( aOperation, params );
       
   935     
       
   936     A_TRACE( ( _T( "RIscApi::CustomFunction - return void" ) ) );
       
   937     }
       
   938 
       
   939 // -----------------------------------------------------------------------------
       
   940 // RIscApi::CustomFunction
       
   941 // Synchronous API extension function
       
   942 // ( other items were commented in a header ).
       
   943 // -----------------------------------------------------------------------------
       
   944 //
       
   945 EXPORT_C TInt RIscApi::CustomFunction( 
       
   946     const TUint16 aOperation, 
       
   947     TAny* aParameters )
       
   948     {
       
   949     A_TRACE( ( _T( "RIscApi::CustomFunction(0x%x, 0x%x) iChannelNumber\
       
   950     	 (0x%x) this %x" ), aOperation, aParameters, iChannelNumber, this ) );
       
   951     
       
   952     PanicIfNotOpen();
       
   953 
       
   954     // Check if custom operation is out of range. 
       
   955     if ( aOperation < EIscSyncCustomOperation1 
       
   956         || aOperation > EIscSyncCustomOperation5 )
       
   957         {
       
   958         User::Panic( KIscApiPanic, EIscApiCustomFunctionUndefined );
       
   959         }
       
   960 
       
   961     TInt error( KErrNone );
       
   962     TAny* params[ KOneParam ];
       
   963     params[ KFirstParam ] = aParameters;
       
   964 
       
   965     error = DoSvControl( aOperation, params );
       
   966 
       
   967     A_TRACE( ( _T( "RIscApi::CustomFunction - return %d" ), error ) );
       
   968     return error;
       
   969     }
       
   970 
       
   971 // -----------------------------------------------------------------------------
       
   972 // RIscApi::CustomFunctionCancel
       
   973 // Cancel the execution of the asynchronous API extension function
       
   974 // ( other items were commented in a header ).
       
   975 // -----------------------------------------------------------------------------
       
   976 //
       
   977 EXPORT_C void RIscApi::CustomFunctionCancel( 
       
   978     const TUint16 aOperation )
       
   979     {
       
   980     A_TRACE( ( _T( "RIscApi::CustomFunctionCancel(0x%x) iChannelNumber (0x%x)" )
       
   981     			  , aOperation, iChannelNumber ) );
       
   982     
       
   983     PanicIfNotOpen();
       
   984 
       
   985     // Check if custom operation is out of range
       
   986     if ( aOperation < EIscCancelAsyncCustomOperation1 
       
   987         || aOperation > EIscCancelAsyncCustomOperation5 )
       
   988         {
       
   989         User::Panic( KIscApiPanic, EIscApiCustomFunctionUndefined );
       
   990         }
       
   991 
       
   992     DoSvControl( aOperation );
       
   993 
       
   994     A_TRACE( ( _T( "RIscApi::CustomFunctionCancel - return void" ) ) );
       
   995     }
       
   996 
       
   997 // -----------------------------------------------------------------------------
       
   998 // RIscApi::DataSend
       
   999 // Send data to Domestic OS ( asynchronous )
       
  1000 // ( other items were commented in a header ).
       
  1001 // -----------------------------------------------------------------------------
       
  1002 //
       
  1003 EXPORT_C void RIscApi::DataSend( 
       
  1004     TRequestStatus& aStatus,
       
  1005     const TDesC8& aData )
       
  1006     {
       
  1007     A_TRACE( ( _T( "RIscApi::DataSend(0x%x, 0x%x) iChannelNumber 0x%x" ),
       
  1008     			  &aStatus, &aData, iChannelNumber ) );
       
  1009     
       
  1010     PanicIfNotOpen();
       
  1011     
       
  1012     TAny* params[ KTwoParams ];
       
  1013     
       
  1014     params[ KFirstParam ] = (TAny*)&aStatus;
       
  1015     params[ KSecondParam ] = (TAny*)&aData;
       
  1016 
       
  1017     aStatus = KRequestPending;
       
  1018     DoControl( EIscAsyncDataSend, params );
       
  1019     
       
  1020     A_TRACE( ( _T( "RIscApi::DataSend - return void" ) ) );
       
  1021     }
       
  1022 
       
  1023 // -----------------------------------------------------------------------------
       
  1024 // RIscApi::DataSend
       
  1025 // Send data to Domestic OS ( synchronous )
       
  1026 // ( other items were commented in a header ).
       
  1027 // -----------------------------------------------------------------------------
       
  1028 //
       
  1029 EXPORT_C TInt RIscApi::DataSend( 
       
  1030     const TDesC8& aData )
       
  1031     {
       
  1032     A_TRACE( ( _T( "RIscApi::DataSend(0x%x) iChannelNumber 0x%x" ),
       
  1033     			    &aData, iChannelNumber ) );
       
  1034 
       
  1035     PanicIfNotOpen();
       
  1036 
       
  1037     TInt error(  KErrNone );
       
  1038     TAny* params[ KOneParam ];
       
  1039     
       
  1040     params[ KFirstParam ] = (TAny*)&aData;
       
  1041 
       
  1042     error = DoControl( EIscSyncDataSend, params );
       
  1043 
       
  1044     A_TRACE( ( _T( "RIscApi::DataSend - return %d" ), error ) );
       
  1045     return error;
       
  1046     }
       
  1047 
       
  1048 // -----------------------------------------------------------------------------
       
  1049 // RIscApi::DataSendCancel
       
  1050 // Cancel asynchronous DataSend request
       
  1051 // ( other items were commented in a header ).
       
  1052 // -----------------------------------------------------------------------------
       
  1053 //
       
  1054 EXPORT_C void RIscApi::DataSendCancel()
       
  1055     {
       
  1056     A_TRACE( ( _T( "RIscApi::DataSendCancel() iChannelNumber 0x%x" ),
       
  1057     			   iChannelNumber ) );
       
  1058 
       
  1059     PanicIfNotOpen();
       
  1060 
       
  1061     DoSvControl( EIscCancelAsyncDataSend );
       
  1062 
       
  1063     A_TRACE( ( _T( "RIscApi::DataSendCancel - return void" ) ) );
       
  1064     }
       
  1065 
       
  1066 // -----------------------------------------------------------------------------
       
  1067 // RIscApi::DataReceive
       
  1068 // Receive data from Domestic OS
       
  1069 // ( other items were commented in a header ).
       
  1070 // -----------------------------------------------------------------------------
       
  1071 //
       
  1072 EXPORT_C void RIscApi::DataReceive( 
       
  1073     TRequestStatus& aStatus,
       
  1074     TDes8& aData,
       
  1075     TUint16& aNeededBufLen )
       
  1076     {
       
  1077     A_TRACE( ( _T( "RIscApi::DataReceive(0x%x, 0x%x, 0x%x) iChannelNumber 0x%x" ),
       
  1078     			   &aStatus, &aData, aNeededBufLen, iChannelNumber ) );
       
  1079     
       
  1080     PanicIfNotOpen();
       
  1081     
       
  1082     TAny* params[ KThreeParams ];
       
  1083     
       
  1084     iNeededDataLen.Set( ( TUint8* )&aNeededBufLen, sizeof ( TUint16 ),sizeof ( TUint16 ) );
       
  1085 
       
  1086     params[ KFirstParam ] = (TAny*)&aStatus;
       
  1087     params[ KSecondParam ] = (TAny*)&aData;
       
  1088     params[ KThirdParam ] = (TAny*)&iNeededDataLen;
       
  1089 
       
  1090     aStatus = KRequestPending;
       
  1091     DoControl( EIscAsyncDataReceive, params );
       
  1092     
       
  1093     A_TRACE( ( _T( "RIscApi::DataReceive - return void" ) ) );
       
  1094     }
       
  1095 
       
  1096 // -----------------------------------------------------------------------------
       
  1097 // RIscApi::FlowControlStatus
       
  1098 // Get the current flow control status ( in uplink-direction )
       
  1099 // ( other items were commented in a header ).
       
  1100 // -----------------------------------------------------------------------------
       
  1101 //
       
  1102 EXPORT_C TInt RIscApi::FlowControlStatus()
       
  1103     {
       
  1104     A_TRACE( ( _T( "RIscApi::FlowControlStatus() channel 0x%x" ),
       
  1105     			   iChannelNumber ) );
       
  1106     
       
  1107     PanicIfNotOpen();
       
  1108 
       
  1109     TInt state( EIscFlowControlOff );
       
  1110 
       
  1111     state = DoControl( EIscSyncGetFlowControlStatus );
       
  1112 
       
  1113     A_TRACE( ( _T( "RIscApi::FlowControlStatus - return %d" ), state ) );
       
  1114 
       
  1115     return state;
       
  1116     }
       
  1117 
       
  1118 
       
  1119 // -----------------------------------------------------------------------------
       
  1120 // RIscApi::NotifyFlowControl
       
  1121 // Listen for flow control status changes
       
  1122 // ( other items were commented in a header ).
       
  1123 // -----------------------------------------------------------------------------
       
  1124 //
       
  1125 EXPORT_C void RIscApi::NotifyFlowControl( 
       
  1126     TRequestStatus& aStatus,
       
  1127     TInt& aFlowControlStatus )
       
  1128     {
       
  1129     A_TRACE( ( _T( "RIscApi::NotifyFlowControl(0x%x, 0x%x) channel 0x%x" ),
       
  1130     			  &aStatus, aFlowControlStatus, iChannelNumber ) );
       
  1131     
       
  1132     PanicIfNotOpen();
       
  1133     
       
  1134     TAny* params[ KTwoParams ];
       
  1135     
       
  1136     iFlowControlStatus.Set( ( TUint8* )&aFlowControlStatus,sizeof ( TInt ),sizeof ( TInt ) );
       
  1137 
       
  1138     params[ KFirstParam ] = (TAny*)&aStatus;
       
  1139     params[ KSecondParam ] = (TAny*)&iFlowControlStatus;
       
  1140     
       
  1141     aStatus = KRequestPending;
       
  1142     DoControl( EIscAsyncNotifyFlowControlStatus, params );
       
  1143     
       
  1144     A_TRACE( ( _T( "RIscApi::NotifyFlowControl - return void" ) ) );
       
  1145     }
       
  1146 
       
  1147 
       
  1148 // -----------------------------------------------------------------------------
       
  1149 // RIscApi::NotifyFlowControlCancel
       
  1150 // Stop listening for flow control status changes
       
  1151 // ( other items were commented in a header ).
       
  1152 // -----------------------------------------------------------------------------
       
  1153 //
       
  1154 EXPORT_C void RIscApi::NotifyFlowControlCancel()
       
  1155     {
       
  1156     A_TRACE(  (  _T(  "RIscApi::NotifyFlowControlCancel()" ) ) );
       
  1157 
       
  1158     PanicIfNotOpen();
       
  1159     
       
  1160     DoControl( EIscCancelAsyncNotifyFlowControl );
       
  1161 
       
  1162     A_TRACE( ( _T( "RIscApi::NotifyFlowControlCancel - return void" ) ) );
       
  1163     }
       
  1164 
       
  1165 // -----------------------------------------------------------------------------
       
  1166 // RIscApi::MaximumDataSize
       
  1167 // Get maximun data size ( for sending and receiving )
       
  1168 // ( other items were commented in a header ).
       
  1169 // -----------------------------------------------------------------------------
       
  1170 //
       
  1171 EXPORT_C TInt RIscApi::MaximumDataSize()
       
  1172     {
       
  1173     A_TRACE( ( _T( "RIscApi::MaximumDataSize() channel 0x%x" ),
       
  1174     				iChannelNumber ) );
       
  1175     
       
  1176     PanicIfNotOpen();
       
  1177 
       
  1178     TInt r = DoControl( EIscSyncGetMaximunDataSize );
       
  1179     A_TRACE( ( _T( "RIscApi::MaximumDataSize - return 0x%x" ), r ) );
       
  1180     return r;
       
  1181         
       
  1182     }
       
  1183 
       
  1184 // -----------------------------------------------------------------------------
       
  1185 // RIscApi::GetChannelInfo
       
  1186 // Get channel info from multiplexer
       
  1187 // ( other items were commented in a header ).
       
  1188 // -----------------------------------------------------------------------------
       
  1189 //
       
  1190 EXPORT_C TInt RIscApi::GetChannelInfo( 
       
  1191     const TUint16 aChannel, 
       
  1192     TDes8& aInfo )
       
  1193     {
       
  1194     A_TRACE( ( _T( "RIscApi::GetChannelInfo(0x%x, 0x%x)" ),
       
  1195     			    aChannel, &aInfo ) );
       
  1196     
       
  1197     PanicIfNotOpen();
       
  1198 
       
  1199     TAny* params[ KTwoParams ];  
       
  1200     params[ KFirstParam ] = (TAny*)aChannel;
       
  1201     params[ KSecondParam ] = (TAny*)&aInfo;
       
  1202     
       
  1203     TInt error = DoControl( EIscSyncGetChannelInfo, params );
       
  1204 
       
  1205     A_TRACE( ( _T( "RIscApi::GetChannelInfo - return %d" ), error ) );
       
  1206     return error;
       
  1207     }
       
  1208 
       
  1209 // -----------------------------------------------------------------------------
       
  1210 // IscApi::PanicIfNotOpen
       
  1211 // Panic if channel is not opened yet
       
  1212 // ( other items were commented in a header ).
       
  1213 // -----------------------------------------------------------------------------
       
  1214 //
       
  1215 void RIscApi::PanicIfNotOpen() const
       
  1216     {
       
  1217     
       
  1218     if( !iOpen ) 
       
  1219         {
       
  1220         C_TRACE( ( _T( "IscApi::PanicIfNotOpen() channel 0x%x" ),
       
  1221         			   iChannelNumber ) );
       
  1222         User::Panic( KIscApiPanic, EIscApiChannelNotOpen );
       
  1223         }
       
  1224     else
       
  1225         {
       
  1226         // Do nothing.
       
  1227         }
       
  1228     }
       
  1229 
       
  1230 //  End of File