|
1 /* |
|
2 * Copyright (c) 2002-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: In this state, BTSAC is listening for remote connection |
|
15 * from a stereo audio accessory |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "btsacStateConnecting.h" |
|
24 #include "btsacStateConnected.h" |
|
25 #include "btsacStateListening.h" |
|
26 #include "btsacactive.h" |
|
27 #include "btsacGavdp.h" |
|
28 #include "btsacSEPManager.h" |
|
29 #include "btsacStreamerController.h" |
|
30 #include "debug.h" |
|
31 |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CBtsacConnecting::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CBtsacConnecting* CBtsacConnecting::NewL(CBTSAController& aParent, TBTConnType aConnType) |
|
40 { |
|
41 CBtsacConnecting* self = new( ELeave ) CBtsacConnecting(aParent, aConnType); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CBtsacConnecting::CBtsacConnecting |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CBtsacConnecting::CBtsacConnecting(CBTSAController& aParent, TBTConnType aConnType) |
|
50 : CBtsacState(aParent, EStateConnecting), iConnType(aConnType) |
|
51 { |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CBtsacConnecting::~CBtsacConnecting |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CBtsacConnecting::~CBtsacConnecting() |
|
59 { |
|
60 TRACE_FUNC |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CBtsacConnecting::EnterL |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CBtsacConnecting::EnterL() |
|
68 { |
|
69 TRACE_STATE(_L("[BTSAC State] Connecting")) |
|
70 _LIT(KName, "CBtsacStateConnecting"); |
|
71 const TDesC& Name = KName; |
|
72 Parent().iGavdp->RegisterObserver(this, Name); // gavdp call-backs |
|
73 Parent().iGavdp->Connect(Parent().GetRemoteAddr()); |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CBtsacConnecting::CancelActionL |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CBtsacConnecting::CancelActionL(TInt aError, TBTSACGavdpResetReason aGavdpReset) |
|
81 { |
|
82 TRACE_FUNC |
|
83 Parent().CompletePendingRequests((KConnectReq | KOpenAudioReq), aError); |
|
84 Parent().ChangeStateL(CBtsacListening::NewL(Parent(), aGavdpReset, aError)); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CBtsacConnecting::CancelOpenAudioL() |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CBtsacConnecting::CancelOpenAudioL(const TBTDevAddr& /*aAddr*/) |
|
92 { |
|
93 TRACE_FUNC |
|
94 CancelActionL(KErrCancel, EGavdpResetReasonGeneral); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CBtsacConnecting::CancelConnectL |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CBtsacConnecting::CancelConnectL() |
|
102 { |
|
103 TRACE_FUNC |
|
104 CancelActionL(KErrCancel, EGavdpResetReasonGeneral); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CBtsacConnecting::GAVDP_ConnectConfirm |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CBtsacConnecting::GAVDP_ConnectConfirm(const TBTDevAddr& aAddr) |
|
112 { |
|
113 TRACE_INFO((_L("CBtsacConnecting::GAVDP_ConnectConfirm() Connected with accessory."))) |
|
114 if (Parent().GetRemoteAddr() == aAddr) |
|
115 { |
|
116 // Complete connect request when configuration is complete |
|
117 // cause BT Acc Server will not send a seperate configure request |
|
118 TRAP_IGNORE(Parent().ChangeStateL(CBtsacConnected::NewL(Parent(), iConnType))); |
|
119 } |
|
120 else // not the accessory that we are trying to connect to ! |
|
121 // only possibility is that another accessory has made incoming connection, after we have sent a connect request |
|
122 // what a coincidence ! |
|
123 { |
|
124 TRAP_IGNORE(CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral)); |
|
125 } |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CBtsacConnecting::HandleGavdpErrorL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CBtsacConnecting::HandleGavdpErrorL(TInt /*aError*/) |
|
133 { |
|
134 TRACE_FUNC |
|
135 // Seen error codes: |
|
136 // KErrDied -13 |
|
137 // KErrInUse -14 |
|
138 // KErrCouldNotConnect -34 |
|
139 // KErrL2CAPRequestTimeout -6312 |
|
140 CancelActionL(KErrDisconnected, EGavdpResetReasonGeneral); |
|
141 } |
|
142 |
|
143 // End of File |