|
1 /* |
|
2 * Copyright (c) 2006 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: Implements getting/setting outgoing pair status |
|
15 * from/to P&S KBTOutgoingPairing from btengprivatepskeys.h. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "btengprivatepskeys.h" |
|
20 #include <e32property.h> |
|
21 |
|
22 // ---------------------------------------------------------- |
|
23 // Get outgoing pair status from PS |
|
24 // ---------------------------------------------------------- |
|
25 // |
|
26 inline void OutgoPairingProperty(RProperty& aProperty, |
|
27 TBTDevAddr& aAddr, TBTOutgoingPairMode& aMode) |
|
28 { |
|
29 TBuf8<sizeof( TBTOutgoingPairProperty )> propDes; |
|
30 TInt err = aProperty.Get( propDes ); |
|
31 if ( !err && propDes.Length() == sizeof( TBTOutgoingPairProperty ) ) |
|
32 { |
|
33 TBTOutgoingPairProperty prop; |
|
34 TPckgC<TBTOutgoingPairProperty> tmpPckg( prop ); |
|
35 tmpPckg.Set( propDes ); |
|
36 aAddr = tmpPckg().iAddr; |
|
37 aMode = tmpPckg().iMode; |
|
38 } |
|
39 else |
|
40 { |
|
41 aMode = EBTOutgoingPairNone; |
|
42 } |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------- |
|
46 // Get outgoing pair status from PS |
|
47 // ---------------------------------------------------------- |
|
48 // |
|
49 inline void OutgoPairingProperty(TBTDevAddr& aAddr, TBTOutgoingPairMode& aMode) |
|
50 { |
|
51 RProperty property; |
|
52 TInt err = property.Attach( |
|
53 KPSUidBluetoothEnginePrivateCategory, KBTOutgoingPairing ); |
|
54 if ( !err ) |
|
55 { |
|
56 OutgoPairingProperty( property, aAddr, aMode ); |
|
57 } |
|
58 else |
|
59 { |
|
60 aMode = EBTOutgoingPairNone; |
|
61 } |
|
62 property.Close(); |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------- |
|
66 // Tells if another outgoing pairing is ongoing with a device |
|
67 // other than the specified one. |
|
68 // ---------------------------------------------------------- |
|
69 // |
|
70 inline TBool OtherOutgoPairing( const TBTDevAddr& aAddr ) |
|
71 { |
|
72 TBTDevAddr outpaddr; |
|
73 TBTOutgoingPairMode mode; |
|
74 OutgoPairingProperty( outpaddr, mode ); |
|
75 return mode != EBTOutgoingPairNone && outpaddr != aAddr; |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------- |
|
79 // Gets the status of outgoing pair with the specified device. |
|
80 // ---------------------------------------------------------- |
|
81 // |
|
82 inline TBTOutgoingPairMode OutgoPairingMode( |
|
83 RProperty& aProperty, const TBTDevAddr& aAddr ) |
|
84 { |
|
85 TBTDevAddr addr; |
|
86 TBTOutgoingPairMode mode; |
|
87 OutgoPairingProperty(aProperty, addr, mode ); |
|
88 return ( addr == aAddr ) ? mode : EBTOutgoingPairNone; |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------- |
|
92 // Gets the status of outgoing pair with the specified device. |
|
93 // ---------------------------------------------------------- |
|
94 // |
|
95 inline TBTOutgoingPairMode OutgoPairingMode(const TBTDevAddr& aAddr) |
|
96 { |
|
97 TBTDevAddr addr; |
|
98 TBTOutgoingPairMode mode; |
|
99 OutgoPairingProperty( addr, mode ); |
|
100 return ( addr == aAddr ) ? mode : EBTOutgoingPairNone; |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------- |
|
104 // publish outgoing pairing status to PS |
|
105 // ---------------------------------------------------------- |
|
106 // |
|
107 inline void SetOutgoPairProperty(RProperty& aProperty, |
|
108 const TBTDevAddr& aAddr, |
|
109 TBTOutgoingPairMode aMode ) |
|
110 { |
|
111 if ( aMode == EBTOutgoingPairNone ) |
|
112 { |
|
113 (void) aProperty.Set( KNullDesC8 ); |
|
114 return; |
|
115 } |
|
116 TPckgBuf<TBTOutgoingPairProperty> tmpPckg; |
|
117 tmpPckg().iAddr = aAddr; |
|
118 tmpPckg().iMode = aMode; |
|
119 (void) aProperty.Set( tmpPckg ); |
|
120 } |
|
121 |
|
122 // ---------------------------------------------------------- |
|
123 // Locally instantiate a RProperty and Set Outgoing Pair Property |
|
124 // ---------------------------------------------------------- |
|
125 // |
|
126 inline void SetOutgoPairProperty(const TBTDevAddr& aAddr, |
|
127 TBTOutgoingPairMode aMode ) |
|
128 { |
|
129 RProperty property; |
|
130 TInt err = property.Attach( |
|
131 KPSUidBluetoothEnginePrivateCategory, KBTOutgoingPairing ); |
|
132 if ( !err ) |
|
133 { |
|
134 SetOutgoPairProperty( property, aAddr, aMode ); |
|
135 } |
|
136 property.Close(); |
|
137 } |