bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallactive.cpp
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     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:  General Active Object offering asynchronous service
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "btmccallactive.h"
       
    20 #include "debug.h"
       
    21 
       
    22 // -----------------------------------------------------------------------------
       
    23 // CBtmcCallActive::NewL
       
    24 // -----------------------------------------------------------------------------
       
    25 CBtmcCallActive* CBtmcCallActive::NewL(
       
    26     MBtmcActiveObserver& aObserver, 
       
    27     CActive::TPriority aPriority,
       
    28     TInt aServiceId,
       
    29     RMobileLine& aLine,
       
    30     const TName& aName)
       
    31     {
       
    32     CBtmcCallActive* self = CBtmcCallActive::NewLC(aObserver, aPriority, aServiceId, aLine, aName);
       
    33     CleanupStack::Pop(self);
       
    34     return self;
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CBtmcCallActive::NewLC
       
    39 // -----------------------------------------------------------------------------
       
    40 CBtmcCallActive* CBtmcCallActive::NewLC(
       
    41     MBtmcActiveObserver& aObserver, 
       
    42     CActive::TPriority aPriority, 
       
    43     TInt aServiceId,
       
    44     RMobileLine& aLine,
       
    45     const TName& aName)
       
    46     {
       
    47     CBtmcCallActive* self = new (ELeave) CBtmcCallActive(aObserver, aPriority, aServiceId, aLine, aName);
       
    48     CleanupStack::PushL(self);
       
    49     self->ConstructL();
       
    50     return self;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CBtmcCallActive::~CBtmcCallActive
       
    55 // -----------------------------------------------------------------------------
       
    56 CBtmcCallActive::~CBtmcCallActive()
       
    57     {
       
    58     TRACE_FUNC_ENTRY
       
    59     Cancel();
       
    60     iCall.Close();
       
    61     TRACE_FUNC_EXIT
       
    62     }
       
    63 
       
    64 // -------------------------------------------------------------------------------
       
    65 // CBtmcCallActive::GoActive
       
    66 // -------------------------------------------------------------------------------
       
    67 void CBtmcCallActive::GoActive()
       
    68     {
       
    69     TRACE_ASSERT(!IsActive(), KErrGeneral);
       
    70     iCall.NotifyMobileCallStatusChange(iStatus, iCallStatus);
       
    71     SetActive();
       
    72     TRACE_FUNC
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CBtmcCallActive::CallName
       
    77 //
       
    78 // Gets call name.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 const TDesC& CBtmcCallActive::CallName() const
       
    82     {
       
    83     return iName;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CBtmcCallActive::RemotePartyNumber
       
    88 //
       
    89 // Get caller's phone number.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 const TDesC& CBtmcCallActive::RemotePartyNumber() const
       
    93     {
       
    94     return iRemoteNumber;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CBtmcCallActive::CallStatus
       
    99 //
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 RMobileCall::TMobileCallStatus CBtmcCallActive::CallStatus() const
       
   103     {
       
   104     return iCallStatus;
       
   105     }
       
   106 
       
   107 // -------------------------------------------------------------------------------
       
   108 // CBtmcCallActive::RunL
       
   109 // -------------------------------------------------------------------------------
       
   110 void CBtmcCallActive::RunL()
       
   111     {
       
   112     TRACE_FUNC_ENTRY
       
   113     TRACE_INFO((_L("ao status %d"), iStatus.Int()))
       
   114     TRACE_INFO((_L("name '%S' new status %d, old status %d"), &iName, iCallStatus, iPrevCallStatus))
       
   115     
       
   116     if(iCallStatus != iPrevCallStatus)
       
   117         {
       
   118         iPrevCallStatus = iCallStatus;
       
   119     	if( iCallStatus != RMobileCall::EStatusIdle &&
       
   120     		!iEmergency )
       
   121     		{
       
   122     		RMobileCall::TMobileCallInfoV1 myInfo;
       
   123     		GetCallInfo( myInfo );
       
   124     		if ( myInfo.iValid & RMobileCall::KCallEmergency &&
       
   125     			 myInfo.iEmergency )
       
   126     			{
       
   127     			TRACE_INFO((_L("Emergency call object detected")))
       
   128             	iEmergency = ETrue;
       
   129             	}
       
   130     		}
       
   131 
       
   132         Observer().RequestCompletedL(*this, iStatus.Int());
       
   133         }
       
   134     else if( iCallStatus == RMobileCall::EStatusIdle )
       
   135         {
       
   136         Observer().RequestCompletedL(*this, iStatus.Int());    
       
   137         }
       
   138     else
       
   139         {
       
   140         GoActive();
       
   141         }
       
   142         
       
   143     TRACE_FUNC_EXIT
       
   144     }
       
   145 
       
   146 // -------------------------------------------------------------------------------
       
   147 // CBtmcCallActive::DoCancel
       
   148 // -------------------------------------------------------------------------------
       
   149 void CBtmcCallActive::DoCancel()
       
   150     {
       
   151     iCall.CancelAsyncRequest(EMobileCallNotifyMobileCallStatusChange);
       
   152     TRACE_FUNC
       
   153     }
       
   154 
       
   155 // -------------------------------------------------------------------------------
       
   156 // CBtmcCallActive::RunError
       
   157 // -------------------------------------------------------------------------------
       
   158 TInt CBtmcCallActive::RunError(TInt /*aErr*/)
       
   159     {
       
   160     Cancel();
       
   161     iCall.Close();
       
   162     TRACE_FUNC
       
   163     return KErrNone;
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CBtmcCallActive::CBtmcCallActive
       
   168 // -----------------------------------------------------------------------------
       
   169 CBtmcCallActive::CBtmcCallActive(
       
   170     MBtmcActiveObserver& aObserver,
       
   171     CActive::TPriority aPriority,
       
   172     TInt aServiceId,
       
   173     RMobileLine& aLine,
       
   174     const TName& aName)
       
   175     : CBtmcActive(aObserver, aPriority, aServiceId), iLine(aLine)
       
   176     {
       
   177     iName.Copy(aName);
       
   178     }
       
   179 
       
   180 void CBtmcCallActive::ConstructL()
       
   181     {
       
   182     TRACE_FUNC_ENTRY
       
   183     LEAVE_IF_ERROR(iCall.OpenExistingCall(iLine, iName))
       
   184     LEAVE_IF_ERROR(iCall.GetMobileCallStatus(iCallStatus))
       
   185     iPrevCallStatus = iCallStatus;
       
   186     TRACE_INFO((_L("name '%S' status %d"), &iName, iCallStatus))
       
   187 
       
   188     RMobileCall::TMobileCallInfoV1 info;
       
   189     RMobileCall::TMobileCallInfoV1Pckg package(info);
       
   190     LEAVE_IF_ERROR(iCall.GetMobileCallInfo(package))
       
   191     iCall.GetMobileCallInfo(package);
       
   192     if ((info.iValid & RMobileCall::KCallRemoteParty) && 
       
   193         info.iRemoteParty.iRemoteIdStatus == RMobileCall::ERemoteIdentityAvailable)
       
   194         {
       
   195         iRemoteNumber.Copy(info.iRemoteParty.iRemoteNumber.iTelNumber);
       
   196         }
       
   197 	else if (info.iValid & RMobileCall::KCallDialledParty)
       
   198 		{
       
   199 		//number for outgoing call
       
   200 		iRemoteNumber.Copy(info.iDialledParty.iTelNumber);
       
   201 		}
       
   202 
       
   203     TRACE_INFO((_L("remote party '%S' "), &iRemoteNumber))
       
   204  
       
   205     TRACE_FUNC_EXIT
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CBTMonoCallActive::GetCallInfo
       
   210 // -----------------------------------------------------------------------------
       
   211 void CBtmcCallActive::GetCallInfo(RMobileCall::TMobileCallInfoV1& info)
       
   212     {
       
   213     RMobileCall::TMobileCallInfoV1Pckg package(info);
       
   214     iCall.GetMobileCallInfo(package);
       
   215     }
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CBTMonoCallActive::IsEmergencyCall
       
   219 // -----------------------------------------------------------------------------
       
   220 TBool CBtmcCallActive::IsEmergencyCall() const
       
   221 		{
       
   222 		return iEmergency;
       
   223 		}
       
   224 
       
   225 // End of File