QBluetoothZero  2.0
QBtDevice.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * Licensed under the Apache License, Version 2.0 (the "License");
00004  * you may not use this file except in compliance with the License.
00005  * You may obtain a copy of the License at
00006  *
00007  *      http://www.apache.org/licenses/LICENSE-2.0
00008  *
00009  * Unless required by applicable law or agreed to in writing, software
00010  * distributed under the License is distributed on an "AS IS" BASIS,
00011  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012  * See the License for the specific language governing permissions and
00013  * limitations under the License.
00014  */
00015 
00016 #ifndef QBTDEVICE_H
00017 #define QBTDEVICE_H
00018 
00019 #include <QtCore/QList>
00020 #include <QtCore/QString>
00021 #include <QBtGlobal.h>
00022 #include <QBtService.h>
00023 #include <QBtAddress.h>
00024 
00025 //#include <QtDeclarative/QtDeclarative.h>
00026 
00027 QBT_NAMESPACE_BEGIN
00028 
00048 class DLL_EXPORT QBtDevice : public QObject
00049 {
00050         Q_OBJECT
00051         Q_ENUMS(DeviceMajor)
00052         Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
00053         Q_PROPERTY(QBtAddress address READ getAddress WRITE setAddress)
00054         Q_PROPERTY(DeviceMajor type READ getType WRITE setType)
00055 
00056 public:
00057     typedef QList<QBtDevice> List;
00058     
00059     enum DeviceMajor
00060     {
00061         Uncategorized,  //Uncategorized device
00062         Computer,               //Computer device
00063         Phone,                  //Phone device
00064         LANAccess,              //Some form of a local area network router
00065         AudioVideo,             //Audio / Video device
00066         Peripheral,             //Mouse, Joystick, Keyboard
00067         Imaging,                //Camera or Scanner device
00068         Wearable,               //Wearable Device
00069         Toy,                    //Toy device
00070         Miscellaneous   //Miscellaneous device
00071     };
00072 
00073 public:
00074     QBtDevice(QObject* parent=0);
00075 
00079     QBtDevice(const QBtDevice& dev, QObject* parent=0);
00080     QBtDevice (const QString & devName, const QBtAddress & devAddress, DeviceMajor devType, QObject* parent=0);
00081     ~QBtDevice();
00082 
00083     void addNewService (const QBtService& newService);
00084     //void setName (const QString & newName);
00085         void setName (const QString & newName);
00086     void setAddress (const QBtAddress& newAddress);
00087     void setType(DeviceMajor newType);
00088     void setSupportedServices (const QBtService::List& newSupportedServices);
00089     
00090     bool serviceListUpdated() const;
00091 
00092         Q_INVOKABLE QString name() const;
00093     Q_INVOKABLE QString getName() const;
00094     const QBtAddress& getAddress() const;
00095     DeviceMajor getType() const;
00096     QString getTypeAsString() const;
00097     const QBtService::List & getSupportedServices() const;
00098     
00099     // really needed? does not require special processing to copy the members
00100         //      ->      It is required as it turns out when inheriting from QObject. If not implemented
00101         //              then i get linker error (at least when compiling for Windows)
00102     QBtDevice& operator= (const QBtDevice& dev);
00103 
00104 signals:
00105         void nameChanged(QString newName);
00106 
00107 private:
00108     QString _name;
00109     QBtAddress _address;
00110     DeviceMajor _type;
00111     QBtService::List _supportedServices;
00112     
00113     bool _serviceListUpdated;
00114 };
00115 
00116 #if QT_VERSION >= 0x040700
00117 //QML_DECLARE_TYPE (QBtDevice)
00118 #endif
00119 
00120 //Q_DECLARE_METATYPE(QBtDevice)
00121 //Q_DECLARE_METATYPE(QBtDevice::DeviceMajor)
00122 QBT_NAMESPACE_END
00123 
00124 //Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtDevice))
00125 
00126 
00127 
00128 #endif // QBTDEVICE_H
00129 
00130 
00131 //QML_DECLARE_TYPE(type)