|
1 /* |
|
2 * Copyright (c) 2007-2007 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: This is the btpbap bteng ecom plugin class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "Pbapplugin.h" |
|
19 #include "DisconnectHelper.h" |
|
20 #include "debug.h" |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // NewL |
|
24 // --------------------------------------------------------------------------- |
|
25 CPBAPplugin* CPBAPplugin::NewL() |
|
26 { |
|
27 TRACE_FUNC |
|
28 CPBAPplugin* self = new ( ELeave ) CPBAPplugin(); |
|
29 CleanupStack::PushL( self ); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop( self ); |
|
32 return self; |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Destructor |
|
37 // --------------------------------------------------------------------------- |
|
38 CPBAPplugin::~CPBAPplugin() |
|
39 { |
|
40 TRACE_FUNC_ENTRY |
|
41 if( iBPAP.Handle() ) |
|
42 { |
|
43 iBPAP.Close(); |
|
44 } |
|
45 delete iDisconnectHelper; |
|
46 iDisconnectHelper = NULL; |
|
47 TRACE_FUNC_EXIT |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Constructor |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CPBAPplugin::CPBAPplugin() : iDisconnectHelper( NULL ) |
|
55 { |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // ConstructL |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CPBAPplugin::ConstructL() |
|
63 { |
|
64 TRACE_FUNC_ENTRY |
|
65 TInt error; |
|
66 iDisconnectHelper=CDisconnectHelper::NewL( this ); |
|
67 error=iBPAP.Connect(); |
|
68 if ( error == KErrNone ) |
|
69 { |
|
70 error=iBPAP.Start(); |
|
71 if( error ) |
|
72 { |
|
73 TRACE_ERROR(( _L("[PBAP]\tPBAP\tCPBAPplugin::ConstructL() start failed %d"), error) ); |
|
74 User::Leave( error ); |
|
75 } |
|
76 } |
|
77 else |
|
78 { |
|
79 TRACE_ERROR(( _L("[PBAP]\tPBAP\tCPBAPplugin::ConstructL() connect failed %d"), error ) ); |
|
80 User::Leave( error ); |
|
81 } |
|
82 TRACE_FUNC_EXIT |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // From class CBTEngPlugin |
|
87 // CPBAPplugin::SetObserver |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CPBAPplugin::SetObserver( MBTEngPluginObserver* aObserver ) |
|
91 { |
|
92 iObserver = aObserver; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // From class CBTEngPlugin |
|
97 // CPBAPplugin::GetSupportedProfiles |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 void CPBAPplugin::GetSupportedProfiles( RProfileArray& aProfiles ) |
|
101 { |
|
102 aProfiles.Append( EBTProfilePBAP ); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // From class CBTEngPlugin |
|
107 // CPBAPplugin::IsProfileSupported |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 TBool CPBAPplugin::IsProfileSupported( const TBTProfile aProfile ) const |
|
111 { |
|
112 if ( aProfile == EBTProfilePBAP ) |
|
113 { |
|
114 return ETrue; |
|
115 } |
|
116 return EFalse; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // From class CBTEngPlugin |
|
121 // CPBAPplugin::Connect |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 TInt CPBAPplugin::Connect( const TBTDevAddr& /*aAddr*/ ) |
|
125 { |
|
126 return KErrNotSupported; |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // From class CBTEngPlugin |
|
131 // CPBAPplugin::CancelConnect |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 void CPBAPplugin::CancelConnect( const TBTDevAddr& /*aAddr*/ ) |
|
135 { |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // From class CBTEngPlugin |
|
140 // CPBAPplugin::Disconnect |
|
141 // --------------------------------------------------------- |
|
142 // |
|
143 TInt CPBAPplugin::Disconnect( const TBTDevAddr& aAddr, TBTDisconnectType /*aDiscType*/ ) |
|
144 { |
|
145 if ( iObserver ) |
|
146 { |
|
147 return KErrGeneral; |
|
148 } |
|
149 iAddr = aAddr; |
|
150 return iDisconnectHelper->Activate(); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------- |
|
154 // From class CBTEngPlugin |
|
155 // CPBAPplugin::GetConnections |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 void CPBAPplugin::GetConnections( RBTDevAddrArray& /*aAddrArray*/, TBTProfile /*aConnectedProfile*/ ) |
|
159 { |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------- |
|
163 // CPBAPplugin::IsConnected, from CBTEngPlugin |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 TBTEngConnectionStatus CPBAPplugin::IsConnected( const TBTDevAddr& /*aAddr*/ ) |
|
167 { |
|
168 return EBTEngNotConnected; |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------- |
|
172 // From class MDisconnectionCallback |
|
173 // CPBAPplugin::CompleteDisconnection |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 void CPBAPplugin::CompleteDisconnection() |
|
177 { |
|
178 |
|
179 iBPAP.Stop(); |
|
180 TInt err = iBPAP.Start(); |
|
181 TRACE_INFO((_L("Failed to start RPbapSession err = %d"), err)); |
|
182 static_cast<void>(err); |
|
183 if ( iObserver ) |
|
184 { |
|
185 iObserver->DisconnectComplete( iAddr, EBTProfilePBAP, KErrNone ); |
|
186 } |
|
187 } |