haiku/headers/os/bluetooth/DeviceClass.h
Oliver Ruiz Dorantes 981f1b1135 - Add method in LocalDevice class to write its class to the dongle
- Rework and style the DeviceClass class
- Implement option "Identify host as..." in preferences with mentioned method, this should allow us to be visible to more RemoteDevices



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31502 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-10 14:19:17 +00:00

97 lines
1.5 KiB
C++

/*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _DEVICE_CLASS_H
#define _DEVICE_CLASS_H
#include <String.h>
#include <View.h>
namespace Bluetooth {
#define UNKNOWN_CLASS_OF_DEVICE 0x000000
class DeviceClass {
public:
static const uint8 PixelsForIcon = 32;
static const uint8 IconInsets = 5;
DeviceClass(uint8 record[3])
{
SetRecord(record);
}
DeviceClass(uint8 major, uint8 minor, uint16 service)
{
SetRecord(major, minor, service);
}
DeviceClass(void)
{
fRecord = UNKNOWN_CLASS_OF_DEVICE;
}
void SetRecord(uint8 record[3])
{
fRecord = record[0]|record[1]<<8|record[2]<<16;
}
void SetRecord(uint8 major, uint8 minor, uint16 service)
{
fRecord = (minor & 0x3F) << 2;
fRecord |= (major & 0x1F) << 8;
fRecord |= (service & 0x7FF) << 13;
}
uint16 ServiceClass()
{
return (fRecord & 0x00FFE000) >> 13;
}
uint8 MajorDeviceClass()
{
return (fRecord & 0x00001F00) >> 8;
}
uint8 MinorDeviceClass()
{
return (fRecord & 0x000000FF) >> 2;
}
uint32 Record()
{
return fRecord;
}
bool IsUnknownDeviceClass()
{
return (fRecord == UNKNOWN_CLASS_OF_DEVICE);
}
void GetServiceClass(BString&);
void GetMajorDeviceClass(BString&);
void GetMinorDeviceClass(BString&);
void DumpDeviceClass(BString&);
void Draw(BView* view, const BPoint& point);
private:
uint32 fRecord;
};
}
#ifndef _BT_USE_EXPLICIT_NAMESPACE
using Bluetooth::DeviceClass;
#endif
#endif // _DEVICE_CLASS_H