42
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef BTUIDEVTYPEMAP_H
|
|
19 |
#define BTUIDEVTYPEMAP_H
|
|
20 |
|
|
21 |
#include <qglobal.h>
|
|
22 |
#include <btdevice.h>
|
|
23 |
|
|
24 |
class BtuiDevProperty
|
|
25 |
{
|
|
26 |
public: // type definitions:
|
|
27 |
/*
|
|
28 |
* Major device property values.
|
|
29 |
*/
|
|
30 |
enum DevMajorProperty {
|
|
31 |
NullProperty = 0x00000000, // device without any specific filter.
|
|
32 |
Bonded = 0x00000001, // device is in registry and bonded with phone
|
|
33 |
Blocked = 0x00000002, // device is in registry and blocked by user
|
|
34 |
RecentlyUsed = 0x00000004, // device is in registry and was used in last 30 days.
|
|
35 |
Trusted = 0x00000008, // device is in registry and authorized by user.
|
|
36 |
InRegistry = 0x00000010, // device exists in registry.
|
|
37 |
|
|
38 |
Connected = 0x00000020, // device is currently connected to one or more
|
|
39 |
// services managed by Bluetooth Engine.
|
|
40 |
Connectable = 0x00000040, // device is connectable to one or more
|
|
41 |
// services managed by Bluetooth Engine.
|
|
42 |
InRange = 0x00000100, // device is in range
|
|
43 |
|
|
44 |
// bits re-defined according to Class of Device:
|
|
45 |
Computer = 0x00010000, // a computer
|
|
46 |
Phone = 0x00020000, // a phone
|
|
47 |
LANAccessDev = 0x00040000, // a LAN access point
|
|
48 |
AVDev = 0x00080000, // an A/V device
|
|
49 |
Peripheral = 0x00100000, // a peripheral (input device)
|
|
50 |
ImagingDev = 0x00200000, // an imaging device
|
|
51 |
WearableDev = 0x00400000, // a wearable device
|
|
52 |
Toy = 0x00800000, // a toy
|
|
53 |
HealthDev = 0x01000000, // a health device
|
|
54 |
UncategorizedDev = 0x02000000, // a generic device that is uncategorized
|
|
55 |
|
|
56 |
// all properties derived from BT registry
|
|
57 |
RegistryProperties = Bonded |
|
|
58 |
Blocked | RecentlyUsed | Trusted | InRegistry,
|
|
59 |
|
|
60 |
// all properties derived from CoD
|
|
61 |
CodProperties = Computer | Phone | LANAccessDev |
|
|
62 |
AVDev | Peripheral | ImagingDev | WearableDev |
|
|
63 |
Toy | HealthDev | UncategorizedDev,
|
|
64 |
};
|
|
65 |
|
|
66 |
/*
|
|
67 |
* Minor device filters for major property \code AVDev \endcode
|
|
68 |
*/
|
|
69 |
enum AVDevMinorProperty {
|
|
70 |
Carkit = 0x00000001,
|
|
71 |
Headset = 0x00000002,
|
|
72 |
};
|
|
73 |
|
|
74 |
/*
|
|
75 |
* Minor device filters for major property \code Peripheral \endcode
|
|
76 |
*/
|
|
77 |
enum PeripheralMinorProperty {
|
|
78 |
Mouse = 0x00000001,
|
|
79 |
Keyboard = 0x00000002,
|
|
80 |
};
|
|
81 |
|
|
82 |
public:
|
|
83 |
static void mapDeiveType(int &majorProperty, int &minorProperty, int cod );
|
|
84 |
|
|
85 |
};
|
|
86 |
|
|
87 |
|
|
88 |
class DevTypeMapping
|
|
89 |
{
|
|
90 |
public:
|
|
91 |
int majorDevClass; // major device class value from CoD
|
|
92 |
int minorDevClass; // minor device class value from CoD
|
|
93 |
int majorProperty; // one of major properties defined in BtDeviceModel
|
|
94 |
int minorProperty; // one of minor properties defined in BtDeviceModel
|
|
95 |
};
|
|
96 |
|
|
97 |
// mapping table from major and minor Device Classes to device types
|
|
98 |
// which are specifically defined in Bluetooth ui namespace.
|
|
99 |
// (Note audio device mapping is not in this table due to its complex logic)
|
|
100 |
static const DevTypeMapping DeviceTypeMappingTable[] =
|
|
101 |
{
|
|
102 |
{EMajorDeviceComputer, 0, BtuiDevProperty::Computer, 0 },
|
|
103 |
{EMajorDevicePhone, 0, BtuiDevProperty::Phone, 0 },
|
|
104 |
{EMajorDeviceLanAccessPoint, 0, BtuiDevProperty::LANAccessDev, 0},
|
|
105 |
{EMajorDevicePeripheral, EMinorDevicePeripheralKeyboard,
|
|
106 |
BtuiDevProperty::Peripheral,
|
|
107 |
BtuiDevProperty::Keyboard},
|
|
108 |
{EMajorDevicePeripheral, EMinorDevicePeripheralPointer,
|
|
109 |
BtuiDevProperty::Peripheral,
|
|
110 |
BtuiDevProperty::Mouse},
|
|
111 |
{EMajorDeviceImaging, 0, BtuiDevProperty::ImagingDev, 0},
|
|
112 |
{EMajorDeviceWearable, 0, BtuiDevProperty::WearableDev, 0},
|
|
113 |
{EMajorDeviceToy, 0, BtuiDevProperty::Toy, 0}
|
|
114 |
};
|
|
115 |
|
|
116 |
static const int DeviceTypeMappingTableSize =
|
|
117 |
sizeof( DeviceTypeMappingTable ) / sizeof( DevTypeMapping );
|
|
118 |
|
|
119 |
inline void BtuiDevProperty::mapDeiveType(
|
|
120 |
int &majorProperty, int &minorProperty, int cod )
|
|
121 |
{
|
|
122 |
// remove garbage value.
|
|
123 |
majorProperty = 0;
|
|
124 |
minorProperty = 0;
|
|
125 |
TBTDeviceClass codClass = TBTDeviceClass( cod );
|
|
126 |
|
|
127 |
// device type must be mapped according to CoD:
|
|
128 |
int majorServiceCls = codClass.MajorServiceClass();
|
|
129 |
int majorDevCls = codClass.MajorDeviceClass();
|
|
130 |
int minorDevCls = codClass.MinorDeviceClass();
|
|
131 |
|
|
132 |
int i;
|
|
133 |
for (i = 0; i < DeviceTypeMappingTableSize; ++i ) {
|
|
134 |
if ( DeviceTypeMappingTable[i].majorDevClass == majorDevCls &&
|
|
135 |
( DeviceTypeMappingTable[i].minorDevClass == 0 ||
|
|
136 |
DeviceTypeMappingTable[i].minorDevClass == minorDevCls ) ) {
|
|
137 |
// device classes match a item in table, get the mapping:
|
|
138 |
majorProperty |= DeviceTypeMappingTable[i].majorProperty;
|
|
139 |
minorProperty |= DeviceTypeMappingTable[i].minorProperty;
|
|
140 |
break;
|
|
141 |
}
|
|
142 |
}
|
|
143 |
|
|
144 |
// AV device mapping are not defined in the table,
|
|
145 |
// do mapping here if no device type has been mapped so far.
|
|
146 |
// This part is not reliably working with all AV devices.
|
|
147 |
if ( i == DeviceTypeMappingTableSize) {
|
|
148 |
// audio device, carkit, headset or speaker:
|
|
149 |
if( ( majorDevCls == EMajorDeviceAV)
|
|
150 |
|| (majorServiceCls == EMajorServiceRendering
|
|
151 |
&& majorDevCls != EMajorDeviceImaging) ) {
|
|
152 |
majorProperty |= BtuiDevProperty::AVDev;
|
|
153 |
if( minorDevCls == EMinorDeviceAVCarAudio ) {
|
|
154 |
// carkit:
|
|
155 |
minorProperty |= BtuiDevProperty::Carkit;
|
|
156 |
}
|
|
157 |
else {
|
|
158 |
// headset:
|
|
159 |
minorProperty |= BtuiDevProperty::Headset;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
}
|
|
163 |
}
|
|
164 |
#endif // BTUIDEVTYPEMAP_H
|