telephonyserverplugins/common_tsy/commontsy/src/mmtsy/cmmdatalinetsy.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 42 3adadc800673
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 //INCLUDE FILES
       
    19 #include "cmmdatalinetsy.h"
       
    20 #include "cmmphonetsy.h"
       
    21 #include "cmmdatacalltsy.h"
       
    22 #include "cmmcallextinterface.h"
       
    23 #include "cmmlinelist.h"
       
    24 #include "cmmcalllist.h"
       
    25 #include "cmmtsyreqhandlestore.h"
       
    26 #include "cmmmessagemanagerbase.h"
       
    27 #include "CMmCommonStaticUtility.h"
       
    28 #include <ctsy/pluginapi/cmmdatapackage.h>
       
    29 
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 CMmDataLineTsy::CMmDataLineTsy()
       
    34     {
       
    35     }
       
    36 
       
    37 
       
    38 void CMmDataLineTsy::ConstructL()
       
    39     {
       
    40 TFLOGSTRING("TSY: CMmDataLineTsy::ConstructL");
       
    41 
       
    42     CMmLineTsy::ConstructL();
       
    43     }
       
    44 
       
    45 CMmDataLineTsy* CMmDataLineTsy::NewL(
       
    46     CMmPhoneTsy* aMmPhone,
       
    47     RMobilePhone::TMobileService aMode,
       
    48     const TDesC& aName,
       
    49     CMmMessageManagerBase* aMessageManager )
       
    50     {
       
    51 TFLOGSTRING2("TSY: CMmDataLineTsy::NewL - Data line %S created", &aName);
       
    52     CMmDataLineTsy* mmLineTsy = NULL;
       
    53 
       
    54     if ( NULL != aMmPhone && RMobilePhone::ECircuitDataService == aMode )
       
    55         {
       
    56         mmLineTsy = new ( ELeave ) CMmDataLineTsy();
       
    57  
       
    58         CleanupClosePushL( *mmLineTsy );
       
    59         mmLineTsy->iMmPhone  = aMmPhone;    
       
    60         mmLineTsy->iLineName = aName;
       
    61         mmLineTsy->iLineMode = aMode;
       
    62         mmLineTsy->iMessageManager = aMessageManager;
       
    63         mmLineTsy->ConstructL();
       
    64         CleanupStack::Pop();
       
    65         }
       
    66 
       
    67     return mmLineTsy;
       
    68     }
       
    69 
       
    70 CMmDataLineTsy::~CMmDataLineTsy()
       
    71     {
       
    72 TFLOGSTRING2("TSY: CMmDataLineTsy::~CMmDataLineTsy - Line name: %S",
       
    73     &iLineName);
       
    74 
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // CMmDataLineTsy::OpenNewObjectL
       
    79 // This method creates a new name for a call and opens a new  call. This  
       
    80 // method is called when the client uses RCall::OpenNewCall method. Currently 
       
    81 // the maximum number of opened calls from tsy is 20.
       
    82 // (other items were commented in a header).
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CTelObject* CMmDataLineTsy::OpenNewObjectL(
       
    86     TDes& aNewName )
       
    87     {
       
    88     CMmDataCallTsy* mmCall = NULL;
       
    89 
       
    90     //Logic here to prevent creation of unlimited amount of call objects
       
    91     //by clients. The proposed maximum amount of call objects is 20:
       
    92     //
       
    93     //  - 2 voice call object (1 for each line for incoming calls
       
    94     //  - 1 data call object (for incoming data call)
       
    95     //  - 1 emergency call object
       
    96     //  - 1+7 call objects for Confence call (max number of CC participants)
       
    97     //  - phonebook 1
       
    98     //  - javaphone 1
       
    99     //  - WTA 1
       
   100     //  - voice mail box 1
       
   101     //  - csd 1
       
   102     //  - fax 1
       
   103     //  - 3rd party 2
       
   104     //
       
   105 
       
   106     //Incoming calls can not be created if the maximum number is exceeded!
       
   107     if ( KMaxNumberOfCallObjectsFromTsy 
       
   108             > iMmPhone->CallList()->GetNumberOfObjects() )
       
   109         {
       
   110         CreateNewCallName( aNewName );
       
   111         mmCall = CMmDataCallTsy::NewL( iMmPhone, this, iLineMode, aNewName,
       
   112             iMessageManager );
       
   113         iNameOfLastCallAdded = aNewName;
       
   114 
       
   115         // Add the new call to the list of calls
       
   116         TInt ret = iMmPhone->CallList()->AddObject( mmCall );
       
   117         if ( KErrNone != ret )
       
   118             {
       
   119             //If call cannot be added to CallList -> leave with KErrNoMemory
       
   120             //CallList has to have information about every call.
       
   121             mmCall->Close();
       
   122             mmCall = NULL;
       
   123             User::Leave( KErrNoMemory );
       
   124             }
       
   125         else
       
   126             {
       
   127             CompleteNotifyCallAdded( aNewName );
       
   128             }
       
   129         }
       
   130     else
       
   131         {
       
   132         User::Leave( KErrAccessDenied );
       
   133         }
       
   134 
       
   135     return mmCall;
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CMmDataLineTsy::InitInternalAttributesL
       
   140 // Initialises miscellaneous internal attributes.
       
   141 // (other items were commented in a header).
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 void CMmDataLineTsy::InitInternalAttributesL()
       
   145     {
       
   146     CMmLineTsy::InitInternalAttributesL();
       
   147 
       
   148     // The line supports data connections.
       
   149     iLineCaps.iFlags = RLine::KCapsData | RLine::KCapsEventIncomingCall;
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // CMmDataLineTsy::CreateCallObjectForIncomingCall
       
   154 // This function creates and stores a Call object that is used for a incoming 
       
   155 // call.
       
   156 // (other items were commented in a header).
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 TInt CMmDataLineTsy::CreateCallObjectForIncomingCall()
       
   160     {
       
   161     TInt trapError( KErrNone );
       
   162     TInt result( CMmPhoneTsy::EMultimodePhoneOutOfMemory );
       
   163 
       
   164     if ( !iCallForIncomingCall )
       
   165         {
       
   166         TName newName;
       
   167         CreateNewCallName( newName );
       
   168 
       
   169         TRAP( trapError,
       
   170             iCallForIncomingCall = CMmDataCallTsy::NewL(
       
   171                 iMmPhone, this, iLineMode, newName, iMessageManager );
       
   172             );
       
   173 
       
   174         if ( KErrNone == trapError ) 
       
   175             {
       
   176             iNameOfLastCallAdded = newName;
       
   177             // Don't add the new call to the list of calls yet. Will be
       
   178             // Added when incoming call has been received...
       
   179             result = KErrNone;
       
   180             }
       
   181         }
       
   182 
       
   183     return result;
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 // CMmDataLineTsy::CreateGhostCallObject
       
   188 // This method creates a Call object for the Ghost call. A ghost call is a  
       
   189 // call that has been initiated bypassing the ETel.
       
   190 // (other items were commented in a header).
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 CMmCallTsy* CMmDataLineTsy::CreateGhostCallObject(
       
   194     TInt aCallId,
       
   195     RMobilePhone::TMobileService,
       
   196     RMobileCall::TMobileCallStatus aCallStatus )
       
   197     {
       
   198     TInt trapError( KErrNone );
       
   199     TName newName;
       
   200     CreateNewCallName( newName );
       
   201     CMmDataCallTsy* mmCall = NULL;
       
   202 
       
   203     TRAP( trapError,
       
   204         mmCall = CMmDataCallTsy::NewL(
       
   205             iMmPhone, this, iLineMode, newName, iMessageManager );
       
   206         );
       
   207 
       
   208     if ( KErrNone == trapError && NULL != mmCall )
       
   209         {
       
   210         //set call ID
       
   211         mmCall->SetCallId( aCallId );
       
   212         //set call status
       
   213         if( aCallStatus >= RMobileCall::EStatusDialling )
       
   214             {
       
   215             //Status is allways set to dialing. If call is alredy
       
   216             //e.g. connecting, missed status changes are simulated.
       
   217             mmCall->SetCallStatus(
       
   218                 RCall::EStatusDialling, RMobileCall::EStatusDialling );
       
   219             }
       
   220         //set call caps
       
   221         mmCall->SetCallCaps( RCall::KCapsData | RCall::KCapsHangUp );
       
   222         //set call direction to MO call
       
   223         mmCall->SetCallDirection( RMobileCall::EMobileOriginated );
       
   224         //set flag indicating that this is a ghost call
       
   225         mmCall->SetGhostCall( ETrue );
       
   226         //save name of the last added call
       
   227         iNameOfLastCallAdded = mmCall->CallName();
       
   228         }
       
   229 
       
   230     return mmCall;
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CMmDataLineTsy::CompleteNotifyIncomingCall
       
   235 // This method notifies clients about incoming call. Basic information: one 
       
   236 // Call object is allocated in the boot-up for incoming call. When an incoming 
       
   237 // call occurs the call object will be given to the client that answers the
       
   238 // call. Therefore TSY creates a new call object for the next incoming call.
       
   239 // In case of out of memory situation, the next incoming call cannot be
       
   240 // received! General error message about OutOfMemory situation is sent to the
       
   241 // client. 
       
   242 // (other items were commented in a header).
       
   243 // ---------------------------------------------------------------------------
       
   244 //
       
   245 void CMmDataLineTsy::CompleteNotifyIncomingCall(
       
   246     CMmDataPackage* aDataPackage )
       
   247     {
       
   248     TInt callId( -1 );
       
   249     RMobilePhone::TMobileService callMode( RMobilePhone::EVoiceService );
       
   250 
       
   251     CCallDataPackage* callDataPackage =
       
   252         reinterpret_cast<CCallDataPackage*>(aDataPackage);
       
   253     callDataPackage->GetCallIdAndMode( callId, callMode ); 
       
   254 
       
   255 TFLOGSTRING3("TSY: CMmDataLineTsy::CompleteNotifyIncomingCall - \
       
   256     Line name: %S, Call id: %d", &iLineName, callId );
       
   257 
       
   258     //reset req handle. Returns the deleted req handle
       
   259     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( 
       
   260         EMultimodeLineNotifyIncomingCall );
       
   261 
       
   262     CMmDataCallTsy* mmCall = NULL;
       
   263     // First check if the incoming call is for Call Back functionality.
       
   264     // E.g. client has dialled server, which calls back to save user
       
   265     // the data call charging.
       
   266     mmCall = reinterpret_cast<CMmDataCallTsy*>(
       
   267         iMmPhone->WaitingCallForData() );
       
   268     if ( mmCall )
       
   269         {
       
   270         // If call object is valid, then there is already a call object and
       
   271         // client waiting for this incoming call!
       
   272         // Set new call id
       
   273         mmCall->SetCallId( callId );
       
   274         // Set call status
       
   275         mmCall->SetCallStatus(
       
   276             RCall::EStatusRinging, RMobileCall::EStatusRinging );        
       
   277         // Set call direction to EMobileTerminated
       
   278         mmCall->SetCallDirection( RMobileCall::EMobileTerminated );
       
   279         // Remove dial capability from existing call capabilities
       
   280         TUint32 callCaps = mmCall->CallCaps();
       
   281         callCaps &= ~RCall::KCapsDial;
       
   282         mmCall->SetCallCaps( callCaps );
       
   283 
       
   284         mmCall->ActiveCallExtension()->RemoveGSMCallCaps(
       
   285             RCall::KCapsDial );
       
   286         mmCall->CompleteNotifyMobileCallCapsChange( KErrNone );
       
   287 
       
   288         iNameOfCallForAnswering = mmCall->CallName();
       
   289         
       
   290         *iRetIncomingCallName = mmCall->CallName(); 
       
   291         iCallForIncomingCall = NULL;
       
   292 
       
   293         // Used to pass information for call object's GetMobileCallInfo.
       
   294         // Set data to gsm extension
       
   295         //( direction added because not uppdated in messagehandler)
       
   296         mmCall->ActiveCallExtension()->SetMobileCallData(
       
   297             aDataPackage, RMobileCall::EMobileTerminated );
       
   298         // Data caps are changed
       
   299         RMobileCall::TMobileCallDataCapsV1 caps;
       
   300 
       
   301         mmCall->ActiveCallExtension()->GetMobileDataCallCapsV1( caps );
       
   302            
       
   303         caps.iSpeedCaps = RMobileCall::KCapsSpeedAutobauding;
       
   304         caps.iProtocolCaps = 0x00;
       
   305         caps.iServiceCaps = 0x00;
       
   306         caps.iQoSCaps = 0x00;
       
   307         caps.iHscsdSupport = EFalse;
       
   308         caps.iMaxRxTimeSlots = 0x00;
       
   309         caps.iMaxTxTimeSlots = 0x00;
       
   310         caps.iCodingCaps = 0x00;
       
   311         caps.iAsymmetryCaps = 0x00;
       
   312         caps.iUserInitUpgrade = EFalse;
       
   313         caps.iRLPVersionCaps = 0x00;
       
   314         caps.iV42bisCaps = 0x00;
       
   315         mmCall->ActiveCallExtension()->ReceivedMobileDataCallCaps( &caps );
       
   316         mmCall->CompleteNotifyMobileDataCallCapsChange();
       
   317 
       
   318         // If notification is requested, complete it here!
       
   319         if ( EMultimodeLineReqHandleUnknown != reqHandle )
       
   320             {
       
   321             ReqCompleted( reqHandle, KErrNone );
       
   322             }
       
   323         mmCall = NULL;
       
   324         }
       
   325     // Check if notification is requested
       
   326     else if ( EMultimodeLineReqHandleUnknown != reqHandle )
       
   327         {
       
   328         mmCall = reinterpret_cast<CMmDataCallTsy*>(
       
   329             CallObjectForIncomingCall() );
       
   330 
       
   331         if ( mmCall )
       
   332             {
       
   333             // Add the new call to the list of calls
       
   334             TInt ret = iMmPhone->CallList()->AddObject( mmCall );
       
   335 
       
   336             if ( KErrNone == ret )
       
   337                 {
       
   338                 // Set flag indicating that this is a unowned incoming call
       
   339                 mmCall->SetUnownedCallObjectFlag( ETrue );
       
   340                 // Set call ID
       
   341                 mmCall->SetCallId( callId );
       
   342                 // Set call status
       
   343                 mmCall->SetCallStatus(
       
   344                     RCall::EStatusRinging, RMobileCall::EStatusRinging );                
       
   345                 // Set call direction to EMobileTerminated
       
   346                 mmCall->SetCallDirection( RMobileCall::EMobileTerminated );
       
   347 
       
   348                 // Remove dial capability from existing call capabilities
       
   349                 TUint32 callCaps = mmCall->CallCaps();
       
   350                 callCaps &= ~RCall::KCapsDial;
       
   351                 mmCall->SetCallCaps( callCaps );
       
   352 
       
   353                 mmCall->ActiveCallExtension()->RemoveGSMCallCaps(
       
   354                     RCall::KCapsDial );
       
   355                 mmCall->CompleteNotifyMobileCallCapsChange( KErrNone );
       
   356 
       
   357                 // Set data to gsm extension
       
   358                 //( direction added because not uppdated in messagehandler)
       
   359                 mmCall->ActiveCallExtension()->SetMobileCallData(
       
   360                     aDataPackage, RMobileCall::EMobileTerminated );
       
   361 
       
   362                 iNameOfCallForAnswering = mmCall->CallName();
       
   363 
       
   364                 *iRetIncomingCallName = mmCall->CallName(); 
       
   365                 iCallForIncomingCall = NULL;
       
   366 				iNumCalls++;
       
   367 
       
   368                 ReqCompleted( reqHandle, KErrNone );
       
   369 
       
   370                 // Data caps are changed
       
   371                 RMobileCall::TMobileCallDataCapsV1 caps;
       
   372       
       
   373                 mmCall->ActiveCallExtension()->GetMobileDataCallCapsV1( caps );                   
       
   374           
       
   375                 caps.iSpeedCaps = RMobileCall::KCapsSpeedAutobauding;
       
   376                 caps.iProtocolCaps = 0x00;
       
   377                 caps.iServiceCaps = 0x00;
       
   378                 caps.iQoSCaps = 0x00;
       
   379                 caps.iHscsdSupport = EFalse;
       
   380                 caps.iMaxRxTimeSlots = 0x00;
       
   381                 caps.iMaxTxTimeSlots = 0x00;
       
   382                 caps.iCodingCaps = 0x00;
       
   383                 caps.iAsymmetryCaps = 0x00;
       
   384                 caps.iUserInitUpgrade = EFalse;
       
   385                 caps.iRLPVersionCaps = 0x00;
       
   386                 caps.iV42bisCaps = 0x00;
       
   387                 mmCall->ActiveCallExtension()->
       
   388                     ReceivedMobileDataCallCaps( &caps );
       
   389                 mmCall->CompleteNotifyMobileDataCallCapsChange();
       
   390 
       
   391                 // Create and store a new Call Object for incoming call.
       
   392                 CreateCallObjectForIncomingCall();
       
   393                 }
       
   394             else
       
   395                 {
       
   396                 //call object could not be added to the call list. Incoming 
       
   397                 //call cannot be received.
       
   398                 ReqCompleted( reqHandle, KErrNoMemory );
       
   399                 }
       
   400             }
       
   401         else
       
   402             {
       
   403             //call object could not be get. Incoming call cannot be received.
       
   404             //General error message about OutOfMemory situation has been sent
       
   405             //to the client.
       
   406             ReqCompleted( reqHandle, KErrNoMemory );
       
   407             }
       
   408         }
       
   409     }
       
   410 
       
   411 // ---------------------------------------------------------------------------
       
   412 // CMmDataLineTsy::CompleteNotifyDiallingStatus
       
   413 // This method notifies line that a call has entered Dialling state. It means
       
   414 // that Call ID should be saved and in case of ghost call a new call object
       
   415 // should be created.
       
   416 // (other items were commented in a header).
       
   417 // ---------------------------------------------------------------------------
       
   418 //
       
   419 void CMmDataLineTsy::CompleteNotifyDiallingStatus(
       
   420     CMmDataPackage* aDataPackage )
       
   421     {
       
   422 TFLOGSTRING("TSY: CMmDataLineTsy::CompleteNotifyDiallingStatus");
       
   423 
       
   424     TInt callId( -1 );
       
   425     TBool ghostCall( EFalse );
       
   426     RMobilePhone::TMobileService callMode( 
       
   427                                       RMobilePhone::ECircuitDataService );
       
   428 
       
   429     CCallDataPackage* callData =
       
   430         reinterpret_cast<CCallDataPackage*>( aDataPackage );
       
   431 
       
   432     callData->GetCallIdAndMode( callId, callMode );
       
   433 
       
   434     CMmDataCallTsy* mmCall = reinterpret_cast<CMmDataCallTsy*>(
       
   435         iMmPhone->CallList()->GetMmCallByMode( callMode ) );
       
   436 
       
   437     if ( NULL == mmCall )
       
   438         {
       
   439         TFLOGSTRING("TSY: CMmDataLineTsy::CompleteNotifyDiallingStatus - \
       
   440             GhostCall");
       
   441         ghostCall = ETrue;
       
   442         }
       
   443     else
       
   444         {
       
   445         TBool result( EFalse );
       
   446         TBool resultNoFdnCheck( EFalse );
       
   447 
       
   448         //now we have to check, if this is a ghost call
       
   449         result = mmCall->IsServiceLocallyRequested(
       
   450             CMmCallTsy::EMultimodeCallDial );
       
   451 
       
   452         //now we have to check, if this is a ghost call
       
   453         resultNoFdnCheck = mmCall->IsServiceLocallyRequested( 
       
   454             CMmCallTsy::EMultimodeCallDialNoFdnCheck );
       
   455 
       
   456 TFLOGSTRING2("TSY: CMmDataLineTsy::CompleteNotifyDiallingStatus - IsDial: %d", result );  
       
   457 TFLOGSTRING2("TSY: CMmDataLineTsy::CompleteNotifyDiallingStatus - IsDialNoFdnCheck: %d", resultNoFdnCheck );  
       
   458 
       
   459         if ( result || resultNoFdnCheck )
       
   460             {
       
   461             for ( TInt i = 0; i < iMmPhone->CallList()->
       
   462                                                 GetNumberOfObjects(); i++ )
       
   463                 {    
       
   464                 mmCall = reinterpret_cast<CMmDataCallTsy*>(
       
   465                     iMmPhone->CallList()->GetMmCallByIndex(i) );
       
   466                     
       
   467                 if ( ( mmCall->ServiceRequested(
       
   468                         CMmCallTsy::EMultimodeCallDial ) )
       
   469                     || ( mmCall->ServiceRequested(
       
   470                         CMmCallTsy::EMultimodeCallDialNoFdnCheck ) ) )
       
   471                     {
       
   472                     mmCall->SetCallId( callId );
       
   473 TFLOGSTRING2("TSY: CMmDataLineTsy::CompleteNotifyDiallingStatus - mmCall SetCallId: %d", callId);                           
       
   474                     mmCall->CompleteNotifyMobileCallInfoChange( 
       
   475                                 aDataPackage );
       
   476                     break;
       
   477                     }
       
   478                 }
       
   479             }
       
   480         else
       
   481             {
       
   482 TFLOGSTRING("TSY: CMmDataLineTsy::CompleteNotifyDiallingStatus - Dial not found");
       
   483             ghostCall = ETrue;
       
   484             }
       
   485         }
       
   486     //Ghost call handling starts here
       
   487     if ( ghostCall )
       
   488         {
       
   489 TFLOGSTRING("TSY: CMmDataLineTsy::CompleteNotifyDiallingStatus -> CompleteNotifyAddBypassingCall");        
       
   490         //complete call added notification directly from here
       
   491         CompleteNotifyAddBypassingCall( aDataPackage ); 
       
   492         }
       
   493     }
       
   494 
       
   495 
       
   496 
       
   497 //  End of File