1 /* |
1 /* |
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
43 // ----------------------------------------------------------------------------- |
43 // ----------------------------------------------------------------------------- |
44 CBtmcCallingHandler::~CBtmcCallingHandler() |
44 CBtmcCallingHandler::~CBtmcCallingHandler() |
45 { |
45 { |
46 TRACE_FUNC_ENTRY |
46 TRACE_FUNC_ENTRY |
47 delete iActive; |
47 delete iActive; |
|
48 iRespProperty.Close(); |
48 iCmdProperty.Close(); |
49 iCmdProperty.Close(); |
49 TRACE_FUNC_EXIT |
50 TRACE_FUNC_EXIT |
50 } |
51 } |
51 |
52 |
52 |
53 |
53 void CBtmcCallingHandler::HandleCallingCmdL(const CATCommand& aCmd) |
54 void CBtmcCallingHandler::HandleCallingCmdL(const CATCommand& aCmd) |
54 { |
55 { |
55 TRACE_FUNC_ENTRY |
56 TRACE_FUNC_ENTRY |
56 TRACE_ASSERT(!iBusy, KErrInUse) |
57 TRACE_ASSERT(!iActive->IsActive(), KErrInUse) |
|
58 // Delegate the command to btmonobearer for processing |
57 TInt err = iCmdProperty.Set(aCmd.Des()); |
59 TInt err = iCmdProperty.Set(aCmd.Des()); |
58 if (err) |
60 if (err) |
59 { |
61 { |
60 TRACE_INFO((_L8("PS set returned %d"), err)) |
62 TRACE_INFO((_L8("PS set returned %d"), err)) |
61 CATResult* nok = CATResult::NewLC(EATERROR); |
63 CATResult* nok = CATResult::NewLC(EATERROR); |
63 CleanupStack::PopAndDestroy(nok); |
65 CleanupStack::PopAndDestroy(nok); |
64 iProtocol.CmdHandlingCompletedL(); |
66 iProtocol.CmdHandlingCompletedL(); |
65 } |
67 } |
66 else |
68 else |
67 { |
69 { |
68 iBusy = ETrue; |
70 // wait for the response from btmonobearer |
69 iCmdId = aCmd.Id(); |
71 iCmdId = aCmd.Id(); |
70 iActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KCallingResponse); |
72 iRespProperty.Subscribe(iActive->iStatus); |
71 iCmdProperty.Subscribe(iActive->iStatus); |
|
72 iActive->GoActive(); |
73 iActive->GoActive(); |
73 } |
74 } |
74 TRACE_FUNC_EXIT |
75 TRACE_FUNC_EXIT |
75 } |
76 } |
76 |
77 |
77 TBool CBtmcCallingHandler::ActiveCmdHandling() const |
78 TBool CBtmcCallingHandler::ActiveCmdHandling() const |
78 { |
79 { |
79 return iBusy; |
80 return iActive->IsActive(); |
80 } |
81 } |
81 |
82 |
82 TBool CBtmcCallingHandler::ActiveChldHandling() const |
83 TBool CBtmcCallingHandler::ActiveChldHandling() const |
83 { |
84 { |
84 return iBusy && ( iCmdId == EATCHLD ); |
85 return ActiveCmdHandling() && ( iCmdId == EATCHLD ); |
85 } |
86 } |
86 |
87 |
87 void CBtmcCallingHandler::RequestCompletedL(CBtmcActive& aActive, TInt aErr) |
88 void CBtmcCallingHandler::RequestCompletedL(CBtmcActive& aActive, TInt aErr) |
88 { |
89 { |
89 switch (aActive.ServiceId()) |
90 switch (aActive.ServiceId()) |
90 { |
91 { |
91 case KCallingResponse: |
92 case KCallingResponse: |
92 { |
93 { |
93 delete iActive; |
|
94 iActive = NULL; |
|
95 if (!iBusy) |
|
96 { |
|
97 break; |
|
98 } |
|
99 iBusy = EFalse; |
|
100 TInt result = KErrNone; |
94 TInt result = KErrNone; |
101 if (!aErr) |
95 if (!aErr) |
102 { |
96 { |
103 TBuf8<KMaxATSize> buf; |
97 TBuf8<KMaxATSize> buf; |
104 aErr = iCmdProperty.Get(buf); |
98 aErr = iRespProperty.Get(buf); |
105 if (!aErr && buf.Length() >= sizeof(TInt)) |
99 if (!aErr && buf.Length() >= sizeof(TInt)) |
106 { |
100 { |
107 const TUint8* ptr = buf.Ptr(); |
101 const TUint8* ptr = buf.Ptr(); |
108 result = *((const TInt*)ptr); |
102 result = *((const TInt*)ptr); |
109 } |
103 } |
116 if (iCmdId == EATBVRA) |
110 if (iCmdId == EATBVRA) |
117 { |
111 { |
118 iProtocol.VoiceRecognitionError(); |
112 iProtocol.VoiceRecognitionError(); |
119 } |
113 } |
120 } |
114 } |
121 |
|
122 CATResult* nok = CATResult::NewLC(atid); |
115 CATResult* nok = CATResult::NewLC(atid); |
123 iProtocol.SendResponseL(*nok); |
116 iProtocol.SendResponseL(*nok); |
124 CleanupStack::PopAndDestroy(nok); |
117 CleanupStack::PopAndDestroy(nok); |
125 iProtocol.CmdHandlingCompletedL(); |
118 iProtocol.CmdHandlingCompletedL(); |
126 break; |
119 break; |
156 // CBtmcCallingHandler::ConstructL |
149 // CBtmcCallingHandler::ConstructL |
157 // ----------------------------------------------------------------------------- |
150 // ----------------------------------------------------------------------------- |
158 void CBtmcCallingHandler::ConstructL() |
151 void CBtmcCallingHandler::ConstructL() |
159 { |
152 { |
160 TRACE_FUNC |
153 TRACE_FUNC |
161 iCmdProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTATCodec); |
154 LEAVE_IF_ERROR( iCmdProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTHfpATCommand) ); |
|
155 LEAVE_IF_ERROR( iRespProperty.Attach(KPSUidBluetoothEnginePrivateCategory, KBTHfpATResponse) ); |
|
156 iActive = CBtmcActive::NewL(*this, CActive::EPriorityStandard, KCallingResponse); |
162 TRACE_FUNC_EXIT |
157 TRACE_FUNC_EXIT |
163 } |
158 } |
164 |
159 |
165 // End of file |
160 // End of file |