adaptationlayer/tsy/nokiatsy_dll/src/cmmdataporthandler.cpp
changeset 0 63b37f68c1ce
child 5 8ccc39f9d787
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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 the License "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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cmmdataporthandler.h"
       
    22 #include <ctsy/pluginapi/cmmdatapackage.h>
       
    23 #include "cmmmessagerouter.h"
       
    24 #include "cmmstaticutility.h"
       
    25 #include "tsylogger.h"
       
    26 
       
    27 #include <commdb.h>
       
    28 #include <etelmmerr.h>
       
    29 
       
    30 #include "osttracedefinitions.h"
       
    31 #ifdef OST_TRACE_COMPILER_IN_USE
       
    32 #include "cmmdataporthandlertraces.h"
       
    33 #endif
       
    34 
       
    35 // EXTERNAL DATA STRUCTURES
       
    36     //None
       
    37 
       
    38 // EXTERNAL FUNCTION PROTOTYPES
       
    39     //None
       
    40 
       
    41 // CONSTANTS
       
    42     //None
       
    43 
       
    44 // MACROS
       
    45     //None
       
    46 
       
    47 // LOCAL CONSTANTS AND MACROS
       
    48     //None
       
    49 
       
    50 // MODULE DATA STRUCTURES
       
    51     //None
       
    52 
       
    53 // LOCAL FUNCTION PROTOTYPES
       
    54     //None
       
    55 
       
    56 // ============================= LOCAL FUNCTIONS ==============================
       
    57 
       
    58     //None
       
    59 
       
    60 // ============================ MEMBER FUNCTIONS ==============================
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CMmDataPortHandler::CMmDataPortHandler
       
    64 // C++ default constructor can NOT contain any code, that
       
    65 // might leave.
       
    66 // ----------------------------------------------------------------------------
       
    67 //
       
    68 CMmDataPortHandler::CMmDataPortHandler()
       
    69     {
       
    70 
       
    71     TFLOGSTRING("TSY: CMmDataPortHandler::CMmDataPortHandler");
       
    72 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_CMMDATAPORTHANDLER, "CMmDataPortHandler::CMmDataPortHandler" );
       
    73 
       
    74     }
       
    75 
       
    76 // ----------------------------------------------------------------------------
       
    77 // CMmDataPortHandler::ConstructL
       
    78 // Symbian 2nd phase constructor can leave.
       
    79 // ----------------------------------------------------------------------------
       
    80 //
       
    81 void CMmDataPortHandler::ConstructL()
       
    82     {
       
    83 
       
    84     TFLOGSTRING("TSY: CMmDataPortHandler::ConstructL");
       
    85 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_CONSTRUCTL, "CMmDataPortHandler::ConstructL" );
       
    86 
       
    87     iDP0LoanedToClient = EFalse;
       
    88     iDP1LoanedToClient = EFalse;
       
    89     iDP4LoanedToClient = EFalse;
       
    90     iDP5LoanedToClient = EFalse;
       
    91 
       
    92     // Reset internal attributes
       
    93     ResetInternalAttributes();
       
    94 
       
    95     InitDataParamsL();
       
    96     }
       
    97 
       
    98 // ----------------------------------------------------------------------------
       
    99 // CMmDataPortHandler::NewL
       
   100 // Two-phased constructor.
       
   101 // ----------------------------------------------------------------------------
       
   102 //
       
   103 CMmDataPortHandler* CMmDataPortHandler::NewL(
       
   104     CMmMessageRouter* aMessageRouter )
       
   105     {
       
   106 
       
   107     TFLOGSTRING("TSY: CMmDataPortHandler::NewL");
       
   108 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_NEWL, "CMmDataPortHandler::NewL" );
       
   109 
       
   110     CMmDataPortHandler* dataHandler = new ( ELeave ) CMmDataPortHandler();
       
   111 
       
   112     CleanupStack::PushL( dataHandler );
       
   113     dataHandler->iMessageRouter = aMessageRouter;
       
   114 
       
   115     dataHandler->ConstructL();
       
   116     CleanupStack::Pop( dataHandler );
       
   117 
       
   118     return dataHandler;
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CMmDataPortHandler::~CMmDataPortHandler
       
   123 // Destructor, deletes all allocated resources.
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 CMmDataPortHandler::~CMmDataPortHandler()
       
   127     {
       
   128 
       
   129     TFLOGSTRING("TSY: CMmDataPortHandler::~CMmDataPortHandler");
       
   130 OstTrace0( TRACE_NORMAL, DUP1_CMMDATAPORTHANDLER_CMMDATAPORTHANDLER, "CMmDataPortHandler::~CMmDataPortHandler" );
       
   131 
       
   132     // Close Comms server connections
       
   133     if ( ECommsDataportOpened <= iCommsStatus )
       
   134         {
       
   135         iDataPort.Close();
       
   136         }
       
   137     //no else
       
   138 
       
   139     if ( ECommsModuleLoaded <= iCommsStatus )
       
   140         {
       
   141         iCommServer.UnloadCommModule( iCommPort.iCsy );
       
   142         }
       
   143     //no else
       
   144 
       
   145     if ( ECommsServerConnected <= iCommsStatus )
       
   146         {
       
   147         iCommServer.Close();
       
   148         }
       
   149     //no else
       
   150     }
       
   151 
       
   152 // ----------------------------------------------------------------------------
       
   153 // CMmDataPortHandler::ResetInternalAttributes
       
   154 // Initialises owner, bearer service and data call info attributes.
       
   155 // ----------------------------------------------------------------------------
       
   156 //
       
   157 void CMmDataPortHandler::ResetInternalAttributes()
       
   158     {
       
   159 
       
   160     TFLOGSTRING("TSY: CMmDataPortHandler::ResetInternalAttributes");
       
   161 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_RESETINTERNALATTRIBUTES, "CMmDataPortHandler::ResetInternalAttributes" );
       
   162 
       
   163     iBearerService.iBearerCaps = ( RCall::KBearerCapsCompressionNone |
       
   164         RCall::KBearerCapsProtocolUnknown );
       
   165     iBearerService.iBearerSpeed = RCall::EBearerDataUnknown;
       
   166 
       
   167     // Call info
       
   168     iCallType = ECallTypeUnknown;
       
   169     iCallDirection = RMobileCall::EDirectionUnknown;
       
   170     iIsMultimedia = EFalse;
       
   171     iIsWaitingCall = EFalse;
       
   172     iMobileCallInfo.iRemoteParty.iDirection = iCallDirection;
       
   173     iMobileCallInfo.iService = RMobilePhone::EServiceUnspecified;
       
   174     iMobileCallInfo.iStatus = RMobileCall::EStatusUnknown;
       
   175     iMobileCallInfo.iCallId = -1;
       
   176     iMobileCallInfo.iEmergency = EFalse;
       
   177     iMobileCallInfo.iForwarded = EFalse;
       
   178     iMobileCallInfo.iRemoteParty.iRemoteIdStatus =
       
   179         RMobileCall::ERemoteIdentityUnknown;
       
   180     iMobileCallInfo.iRemoteParty.iRemoteNumber.iTypeOfNumber =
       
   181         RMobilePhone::EUnknownNumber;
       
   182     iMobileCallInfo.iRemoteParty.iRemoteNumber.iNumberPlan =
       
   183         RMobilePhone::EUnknownNumberingPlan;
       
   184     iMobileCallInfo.iRemoteParty.iRemoteNumber.iTelNumber.Zero();
       
   185     iMobileCallInfo.iRemoteParty.iCallingName.Zero();
       
   186     iMobileCallInfo.iDialledParty.iTypeOfNumber =
       
   187         RMobilePhone::EUnknownNumber;
       
   188     iMobileCallInfo.iDialledParty.iNumberPlan =
       
   189         RMobilePhone::EUnknownNumberingPlan;
       
   190     iMobileCallInfo.iDialledParty.iTelNumber.Zero();
       
   191     iMobileCallInfo.iAlternatingCall =
       
   192         RMobilePhone::EAlternatingModeUnspecified;
       
   193     iMobileCallInfo.iValid = 0;
       
   194 
       
   195     iCSDParams.iService = RMobileCall::EServiceDataCircuitAsync;
       
   196     iCSDParams.iSpeed = RMobileCall::ESpeedUnspecified;
       
   197     iCSDParams.iProtocol = RMobileCall::EProtocolUnspecified;
       
   198     iCSDParams.iQoS = RMobileCall::EQoSNonTransparent;
       
   199 
       
   200     iCurrentHSCSDInfo.iAiur = RMobileCall::EAiurBpsUnspecified;
       
   201     iCurrentHSCSDInfo.iRxTimeSlots = 0;
       
   202     iCurrentHSCSDInfo.iTxTimeSlots = 0;
       
   203     iCurrentHSCSDInfo.iCodings = RMobileCall::ETchCodingUnspecified;
       
   204 
       
   205     // If false, notifies the client about incoming call
       
   206     iAlreadyNotified = EFalse;
       
   207 
       
   208     iIPC = EEtelCallDial;
       
   209     }
       
   210 
       
   211 // ----------------------------------------------------------------------------
       
   212 // CMmDataPortHandler::InitDataParamsL
       
   213 // Initialises data parameters
       
   214 // (other items were commented in a header).
       
   215 // ----------------------------------------------------------------------------
       
   216 //
       
   217 void CMmDataPortHandler::InitDataParamsL()
       
   218     {
       
   219 
       
   220     TFLOGSTRING("TSY: CMmDataPortHandler::InitDataParamsL");
       
   221 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_INITDATAPARAMSL, "CMmDataPortHandler::InitDataParamsL" );
       
   222 
       
   223     // Open dataport for AT commands.
       
   224     if ( ECommsNotConnected == iCommsStatus )
       
   225         {
       
   226         iCommPort.iCsy  = KDataPortName;
       
   227         iCommPort.iPort = KDataPortPort0;
       
   228         TRAPD( trapError, OpenDataPortL() );
       
   229         // If trap caught error, there is nothing else to do but call
       
   230         // HandleDataPortError.
       
   231         if ( KErrNone != trapError )
       
   232             {
       
   233 
       
   234             TFLOGSTRING2("TSY: CMmDataPortHandler::OpenDataPortL - Left with error: %d", trapError);
       
   235 OstTrace1( TRACE_NORMAL, DUP1_CMMDATAPORTHANDLER_INITDATAPARAMSL, "CMmDataPortHandler::InitDataParamsL;Left with error=%d", trapError );
       
   236             }
       
   237         //no else
       
   238 
       
   239         User::LeaveIfError( trapError );
       
   240         }
       
   241     //no else
       
   242     }
       
   243 
       
   244 // ----------------------------------------------------------------------------
       
   245 // CMmDataPortHandler::OpenDataPortL
       
   246 // Opens dataport for TSY. Loads device for dataport, opens dataport,
       
   247 // sets dataport configurations and sends AT commands for initialisation.
       
   248 // (other items were commented in a header).
       
   249 // ----------------------------------------------------------------------------
       
   250 //
       
   251 void CMmDataPortHandler::OpenDataPortL()
       
   252     {
       
   253 
       
   254     TFLOGSTRING("TSY: CMmDataPortHandler::OpenDataPortL");
       
   255 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_OPENDATAPORTL, "CMmDataPortHandler::OpenDataPortL" );
       
   256 
       
   257     TInt ret( KErrNone );
       
   258 
       
   259 #ifdef __WINS__
       
   260     ret = User::LoadPhysicalDevice( KPddName );
       
   261     if ( KErrNone != ret && KErrAlreadyExists != ret )
       
   262         {
       
   263         User::Leave( ret );
       
   264         }
       
   265     //no else
       
   266 
       
   267     ret = User::LoadLogicalDevice( KLddName );
       
   268     if ( KErrNone != ret && KErrAlreadyExists != ret )
       
   269         {
       
   270         User::Leave( ret );
       
   271         }
       
   272     //no else
       
   273 #endif // __WINS__
       
   274 
       
   275     ret = StartC32();
       
   276     if ( KErrNone != ret && KErrAlreadyExists != ret )
       
   277         {
       
   278         User::Leave( ret );
       
   279         }
       
   280     //no else
       
   281 
       
   282     // Connect to Comms server
       
   283     User::LeaveIfError( iCommServer.Connect() );
       
   284     iCommsStatus = ECommsServerConnected;
       
   285 
       
   286     TFLOGSTRING2("TSY: CMmDataPortHandler::OpenDataPortL - iCommPort.iCsy: %S", &iCommPort.iCsy );
       
   287 OstTraceExt1( TRACE_NORMAL, DUP1_CMMDATAPORTHANDLER_OPENDATAPORTL, "CMmDataPortHandler::OpenDataPortL;iCommPort.iCsy=%S", iCommPort.iCsy );
       
   288 
       
   289     // Load dataport module
       
   290     User::LeaveIfError( iCommServer.LoadCommModule( iCommPort.iCsy ) );
       
   291     iCommsStatus = ECommsModuleLoaded;
       
   292 
       
   293     TFLOGSTRING2("TSY: CMmDataPortHandler::OpenDataPortL - iCommPort.iPort: %S", &iCommPort.iPort);
       
   294 OstTraceExt1( TRACE_NORMAL, DUP2_CMMDATAPORTHANDLER_OPENDATAPORTL, "CMmDataPortHandler::OpenDataPortL;iCommPort.iPort=%S", iCommPort.iPort );
       
   295 
       
   296     // Open dataport
       
   297     User::LeaveIfError( iDataPort.Open( iCommServer, iCommPort.iPort,
       
   298         ECommShared, ECommRoleDTE ) );
       
   299     iCommsStatus = ECommsDataportOpened;
       
   300 
       
   301     RPhone::TStatus modemStatus;
       
   302     modemStatus.iModemDetected = RPhone::EDetectedPresent;
       
   303     modemStatus.iMode          = RPhone::EModeIdle;
       
   304 
       
   305     // create data package
       
   306     CMmDataPackage dataPackage;
       
   307     // pack modem status
       
   308     dataPackage.PackData( &modemStatus );
       
   309     // complete modem detected notification
       
   310     iMessageRouter->Complete(
       
   311         EEtelPhoneNotifyModemDetected,
       
   312         &dataPackage,
       
   313         KErrNone );
       
   314 
       
   315     // Set dataport configurations
       
   316     iDataPort.Config( iDataPortSettings );
       
   317     // The line feed character is the single terminator
       
   318     iDataPortSettings().iTerminator[0]   = KLinefeed()[0];
       
   319     iDataPortSettings().iTerminatorCount = KLinefeed().Length();
       
   320     // Write the config into DP
       
   321     User::LeaveIfError( iDataPort.SetConfig( iDataPortSettings ) );
       
   322 
       
   323     // Set the receive buffer to the same amount as rate demands -> 5760kb
       
   324     iDataPort.SetReceiveBufferLength( KDPReceiveBufLen );
       
   325     // Reset both TX and RX buffers
       
   326     iDataPort.ResetBuffers();
       
   327     }
       
   328 
       
   329 // ----------------------------------------------------------------------------
       
   330 // CMmDataPortHandler::LoanDataPort
       
   331 // Loans dataport to the client.
       
   332 // (other items were commented in a header).
       
   333 // ----------------------------------------------------------------------------
       
   334 //
       
   335 TInt CMmDataPortHandler::LoanDataPort(
       
   336     const CCallDataPackage* aCallDataPackage )
       
   337     {
       
   338 
       
   339     TFLOGSTRING("TSY: CMmDataPortHandler::LoanDataPort");
       
   340 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_LOANDATAPORT, "CMmDataPortHandler::LoanDataPort" );
       
   341 
       
   342     TInt ret( KErrNone );
       
   343     TInt callId( KCallIdNone );
       
   344     RMobilePhone::TMobileService callMode( RMobilePhone::EServiceUnspecified );
       
   345     RCall::TCommPort* commPort = NULL;
       
   346 
       
   347     aCallDataPackage->GetCallIdAndMode( callId, callMode );
       
   348     aCallDataPackage->UnPackData( &commPort );
       
   349 
       
   350     if ( commPort && ECommsDataportOpened <= iCommsStatus )
       
   351         {
       
   352 
       
   353         TFLOGSTRING2("TSY: CMmDataPortHandler::LoanDataPort - Client taking control: %S", &commPort->iPort);
       
   354 OstTraceExt1( TRACE_NORMAL, DUP2_CMMDATAPORTHANDLER_LOANDATAPORT, "CMmDataPortHandler::LoanDataPort;commPort->iPort=%S", commPort->iPort );
       
   355         // Check port and mode
       
   356         if ( ( commPort->iPort == KDataPortPort1 ||
       
   357             commPort->iPort == KDataPortPort4 ||
       
   358             commPort->iPort == KDataPortPort5 ||
       
   359             commPort->iPort == KDataPortPortDUN ) &&
       
   360             callMode == RMobilePhone::ECircuitDataService )
       
   361             {
       
   362             if ( commPort->iPort == KDataPortPortDUN )
       
   363                 {
       
   364                 // Dynamic port allocation for DUN
       
   365                 ret = GetNextFreeDialUpPort( commPort );
       
   366                 }
       
   367             //no else
       
   368             if ( KErrNone == ret)
       
   369                 {
       
   370                 ret = LoanDialUpPort( commPort );
       
   371                 }
       
   372             //no else
       
   373             }
       
   374         else
       
   375             {
       
   376             if ( commPort->iPort != KDataPortPort0 )
       
   377                 {
       
   378                 commPort->iPort = KDataPortPort0;
       
   379                 }
       
   380             //no else
       
   381 
       
   382             if ( !iDP0LoanedToClient )
       
   383                 {
       
   384                 commPort->iCsy.Copy( KDataPortName );
       
   385                 iDP0LoanedToClient = ETrue;
       
   386                 TFLOGSTRING2("TSY: CMmDataPortHandler::LoanDataPort - %S Loaned", &commPort->iPort );
       
   387 OstTraceExt1( TRACE_NORMAL, DUP3_CMMDATAPORTHANDLER_LOANDATAPORT, "CMmDataPortHandler::LoanDataPort;commPort->iPort=%S", commPort->iPort );
       
   388 
       
   389                 }
       
   390             else
       
   391                 {
       
   392                 ret = KErrEtelPortAlreadyLoaned;
       
   393                 }
       
   394             }
       
   395         }
       
   396     else
       
   397         {
       
   398         ret = KErrNotReady;
       
   399         }
       
   400 
       
   401     TFLOGSTRING2("TSY: CMmDataPortHandler::LoanDataPort - Result: %d", ret );
       
   402 OstTrace1( TRACE_NORMAL, DUP1_CMMDATAPORTHANDLER_LOANDATAPORT, "CMmDataPortHandler::LoanDataPort;ret=%d", ret );
       
   403 
       
   404     return ret;
       
   405     }
       
   406 
       
   407 // ----------------------------------------------------------------------------
       
   408 // CMmDataPortHandler::GetNextFreeDialUpPort
       
   409 // Get next free dial-up port.
       
   410 // (other items were commented in a header).
       
   411 // ----------------------------------------------------------------------------
       
   412 //
       
   413 TInt CMmDataPortHandler::GetNextFreeDialUpPort(
       
   414     RCall::TCommPort* aCommPort ) const
       
   415     {
       
   416 
       
   417     TFLOGSTRING("TSY: CMmDataPortHandler::GetNextFreeDialUpPort");
       
   418 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_GETNEXTFREEDIALUPPORT, "CMmDataPortHandler::GetNextFreeDialUpPort" );
       
   419 
       
   420     TInt result( KErrNone );
       
   421 
       
   422     if ( !iDP1LoanedToClient )
       
   423         {
       
   424         aCommPort->iPort.Copy( KDataPortPort1 );
       
   425 
       
   426         TFLOGSTRING2("TSY: CMmDataPortHandler::GetNextFreeDialUpPort - %S Free", &aCommPort->iPort );
       
   427 
       
   428 OstTraceExt1( TRACE_NORMAL, DUP3_CMMDATAPORTHANDLER_GETNEXTFREEDIALUPPORT, "CMmDataPortHandler::GetNextFreeDialUpPort;aCommPort->iPort=%S Free", aCommPort->iPort );
       
   429         }
       
   430     else if ( !iDP4LoanedToClient )
       
   431         {
       
   432         aCommPort->iPort.Copy( KDataPortPort4 );
       
   433 
       
   434         TFLOGSTRING2("TSY: CMmDataPortHandler::GetNextFreeDialUpPort - %S Free", &aCommPort->iPort );
       
   435 
       
   436 OstTraceExt1( TRACE_NORMAL, DUP1_CMMDATAPORTHANDLER_GETNEXTFREEDIALUPPORT, "CMmDataPortHandler::GetNextFreeDialUpPort;aCommPort->iPort=%S Free", aCommPort->iPort );
       
   437         }
       
   438     else if ( !iDP5LoanedToClient )
       
   439         {
       
   440         aCommPort->iPort.Copy( KDataPortPort5 );
       
   441 
       
   442         TFLOGSTRING2("TSY: CMmDataPortHandler::GetNextFreeDialUpPort - %S Free", &aCommPort->iPort );
       
   443 
       
   444 OstTraceExt1( TRACE_NORMAL, DUP2_CMMDATAPORTHANDLER_GETNEXTFREEDIALUPPORT, "CMmDataPortHandler::GetNextFreeDialUpPort;aCommPort->iPort=%S - Free", aCommPort->iPort );
       
   445         }
       
   446     else
       
   447         {
       
   448         result = KErrEtelPortAlreadyLoaned;
       
   449         }
       
   450 
       
   451     return result;
       
   452     }
       
   453 
       
   454 // ----------------------------------------------------------------------------
       
   455 // CMmDataPortHandler::LoanDialUpPort
       
   456 // Loans dial-up port to the client.
       
   457 // (other items were commented in a header).
       
   458 // ----------------------------------------------------------------------------
       
   459 //
       
   460 TInt CMmDataPortHandler::LoanDialUpPort(
       
   461     RCall::TCommPort* aCommPort )
       
   462     {
       
   463 
       
   464     TFLOGSTRING("TSY: CMmDataPortHandler::LoanDialUpPort");
       
   465 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_LOANDIALUPPORT, "CMmDataPortHandler::LoanDialUpPort" );
       
   466 
       
   467     TInt result( KErrNone );
       
   468 
       
   469     if ( aCommPort->iPort == KDataPortPort1 )
       
   470         {
       
   471         if ( !iDP1LoanedToClient )
       
   472             {
       
   473             aCommPort->iCsy.Copy( KDataPortName );
       
   474             iDP1LoanedToClient = ETrue;
       
   475 
       
   476             TFLOGSTRING2("TSY: CMmDataPortHandler::LoanDialUpPort - %S Loaned", &aCommPort->iPort );
       
   477 
       
   478 OstTraceExt1( TRACE_NORMAL, DUP1_CMMDATAPORTHANDLER_LOANDIALUPPORT, "CMmDataPortHandler::LoanDialUpPort;aCommPort->iPort=%S Loaned", aCommPort->iPort );
       
   479             }
       
   480          else
       
   481             {
       
   482             result = KErrEtelPortAlreadyLoaned;
       
   483             }
       
   484         }
       
   485     else if ( aCommPort->iPort == KDataPortPort4 )
       
   486         {
       
   487         if ( !iDP4LoanedToClient )
       
   488             {
       
   489             aCommPort->iCsy.Copy( KDataPortName );
       
   490             iDP4LoanedToClient = ETrue;
       
   491 
       
   492             TFLOGSTRING2("TSY: CMmDataPortHandler::LoanDialUpPort - %S Loaned", &aCommPort->iPort );
       
   493 
       
   494 OstTraceExt1( TRACE_NORMAL, DUP2_CMMDATAPORTHANDLER_LOANDIALUPPORT, "CMmDataPortHandler::LoanDialUpPort;aCommPort->iPort=%S Loaned", aCommPort->iPort );
       
   495             }
       
   496          else
       
   497             {
       
   498             result = KErrEtelPortAlreadyLoaned;
       
   499             }
       
   500         }
       
   501     else if ( aCommPort->iPort == KDataPortPort5 )
       
   502         {
       
   503         if ( !iDP5LoanedToClient )
       
   504             {
       
   505             aCommPort->iCsy.Copy( KDataPortName );
       
   506             iDP5LoanedToClient = ETrue;
       
   507 
       
   508             TFLOGSTRING2("TSY: CMmDataPortHandler::LoanDialUpPort - %S Loaned", &aCommPort->iPort );
       
   509 
       
   510 OstTraceExt1( TRACE_NORMAL, DUP3_CMMDATAPORTHANDLER_LOANDIALUPPORT, "CMmDataPortHandler::LoanDialUpPort;aCommPort->iPort=%S Loaned", aCommPort->iPort );
       
   511             }
       
   512          else
       
   513             {
       
   514             result = KErrEtelPortAlreadyLoaned;
       
   515             }
       
   516         }
       
   517     else
       
   518         {
       
   519         // Port number not supported
       
   520         result = KErrEtelConfigPortFailure;
       
   521         }
       
   522 
       
   523     return result;
       
   524     }
       
   525 
       
   526 // ----------------------------------------------------------------------------
       
   527 // CMmDataPortHandler::RecoverDataPort
       
   528 // Recovers dataport from the client.
       
   529 // (other items were commented in a header).
       
   530 // ----------------------------------------------------------------------------
       
   531 //
       
   532 TInt CMmDataPortHandler::RecoverDataPort(
       
   533     const CCallDataPackage* aCallDataPackage )
       
   534     {
       
   535 
       
   536     TFLOGSTRING("TSY: CMmDataPortHandler::RecoverDataPort");
       
   537 OstTrace0( TRACE_NORMAL, CMMDATAPORTHANDLER_RECOVERDATAPORT, "CMmDataPortHandler::RecoverDataPort" );
       
   538 
       
   539     TInt ret( KErrNone );
       
   540     RCall::TCommPort* commPort = NULL;
       
   541 
       
   542     aCallDataPackage->UnPackData( &commPort );
       
   543 
       
   544     if ( commPort && ECommsDataportOpened <= iCommsStatus )
       
   545         {
       
   546 
       
   547         TFLOGSTRING2("TSY: CMmDataPortHandler::RecoverDataPort - Client returning control: %S", &commPort->iPort );
       
   548 OstTraceExt1( TRACE_NORMAL, DUP2_CMMDATAPORTHANDLER_RECOVERDATAPORT, "CMmDataPortHandler::RecoverDataPort;Client returning control=%S", commPort->iPort );
       
   549         // Check if port 0 has been loaned
       
   550         if ( iDP0LoanedToClient && commPort->iPort == KDataPortPort0 )
       
   551             {
       
   552             iDP0LoanedToClient = EFalse;
       
   553 
       
   554             TFLOGSTRING2("TSY: CMmDataPortHandler::RecoverDataPort - %S Recovered", &commPort->iPort );
       
   555 
       
   556 OstTraceExt1( TRACE_NORMAL, DUP3_CMMDATAPORTHANDLER_RECOVERDATAPORT, "CMmDataPortHandler::RecoverDataPort;commPort->iPort=%S Recovered", commPort->iPort );
       
   557             }
       
   558         else if ( iDP1LoanedToClient && commPort->iPort == KDataPortPort1 )
       
   559             {
       
   560             iDP1LoanedToClient = EFalse;
       
   561 
       
   562             TFLOGSTRING2("TSY: CMmDataPortHandler::RecoverDataPort - %S Recovered", &commPort->iPort );
       
   563 
       
   564 OstTraceExt1( TRACE_NORMAL, DUP4_CMMDATAPORTHANDLER_RECOVERDATAPORT, "CMmDataPortHandler::RecoverDataPort;commPort->iPort=%S Recovered", commPort->iPort );
       
   565             }
       
   566         else if ( iDP4LoanedToClient && commPort->iPort == KDataPortPort4 )
       
   567             {
       
   568             iDP4LoanedToClient = EFalse;
       
   569 
       
   570             TFLOGSTRING2("TSY: CMmDataPortHandler::RecoverDataPort - %S Recovered", &commPort->iPort );
       
   571 
       
   572 OstTraceExt1( TRACE_NORMAL, DUP5_CMMDATAPORTHANDLER_RECOVERDATAPORT, "CMmDataPortHandler::RecoverDataPort;commPort->iPort=%S Recovered", commPort->iPort );
       
   573             }
       
   574         else if ( iDP5LoanedToClient && commPort->iPort == KDataPortPort5 )
       
   575             {
       
   576             iDP5LoanedToClient = EFalse;
       
   577 
       
   578             TFLOGSTRING2("TSY: CMmDataPortHandler::RecoverDataPort - %S Recovered", &commPort->iPort );
       
   579 
       
   580 OstTraceExt1( TRACE_NORMAL, DUP6_CMMDATAPORTHANDLER_RECOVERDATAPORT, "CMmDataPortHandler::RecoverDataPort;commPort->iPort=%S Recovered", commPort->iPort );
       
   581             }
       
   582         else
       
   583             {
       
   584             ret = KErrEtelPortNotLoanedToClient;
       
   585             }
       
   586         }
       
   587     else
       
   588         {
       
   589         ret = KErrNotReady;
       
   590         }
       
   591 
       
   592     return ret;
       
   593     }
       
   594 
       
   595 // ========================== OTHER EXPORTED FUNCTIONS ========================
       
   596 
       
   597     //None
       
   598 
       
   599 // End of File