| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtBluetooth module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #include "qbluetoothhostinfo.h" |
| 41 | #include "qbluetoothhostinfo_p.h" |
| 42 | |
| 43 | QT_BEGIN_NAMESPACE |
| 44 | |
| 45 | /*! |
| 46 | \class QBluetoothHostInfo |
| 47 | \inmodule QtBluetooth |
| 48 | \brief The QBluetoothHostInfo class encapsulates the details of a local |
| 49 | QBluetooth device. |
| 50 | |
| 51 | \since 5.2 |
| 52 | |
| 53 | This class holds the name and address of a local Bluetooth device. |
| 54 | */ |
| 55 | |
| 56 | /*! |
| 57 | Constructs a null QBluetoothHostInfo object. |
| 58 | */ |
| 59 | QBluetoothHostInfo::QBluetoothHostInfo() : |
| 60 | d_ptr(new QBluetoothHostInfoPrivate) |
| 61 | { |
| 62 | } |
| 63 | |
| 64 | /*! |
| 65 | Constructs a new QBluetoothHostInfo which is a copy of \a other. |
| 66 | */ |
| 67 | QBluetoothHostInfo::QBluetoothHostInfo(const QBluetoothHostInfo &other) : |
| 68 | d_ptr(new QBluetoothHostInfoPrivate) |
| 69 | { |
| 70 | Q_D(QBluetoothHostInfo); |
| 71 | |
| 72 | d->m_address = other.d_func()->m_address; |
| 73 | d->m_name = other.d_func()->m_name; |
| 74 | } |
| 75 | |
| 76 | /*! |
| 77 | Destroys the QBluetoothHostInfo. |
| 78 | */ |
| 79 | QBluetoothHostInfo::~QBluetoothHostInfo() |
| 80 | { |
| 81 | delete d_ptr; |
| 82 | } |
| 83 | |
| 84 | /*! |
| 85 | Assigns \a other to this QBluetoothHostInfo instance. |
| 86 | */ |
| 87 | QBluetoothHostInfo &QBluetoothHostInfo::operator=(const QBluetoothHostInfo &other) |
| 88 | { |
| 89 | Q_D(QBluetoothHostInfo); |
| 90 | |
| 91 | d->m_address = other.d_func()->m_address; |
| 92 | d->m_name = other.d_func()->m_name; |
| 93 | |
| 94 | return *this; |
| 95 | } |
| 96 | |
| 97 | /*! |
| 98 | \since 5.5 |
| 99 | |
| 100 | Returns true if \a other is equal to this QBluetoothHostInfo, otherwise false. |
| 101 | */ |
| 102 | bool QBluetoothHostInfo::operator==(const QBluetoothHostInfo &other) const |
| 103 | { |
| 104 | if (d_ptr == other.d_ptr) |
| 105 | return true; |
| 106 | |
| 107 | return d_ptr->m_address == other.d_ptr->m_address && d_ptr->m_name == other.d_ptr->m_name; |
| 108 | } |
| 109 | |
| 110 | /*! |
| 111 | \since 5.5 |
| 112 | |
| 113 | Returns true if \a other is not equal to this QBluetoothHostInfo, otherwise false. |
| 114 | */ |
| 115 | bool QBluetoothHostInfo::operator!=(const QBluetoothHostInfo &other) const |
| 116 | { |
| 117 | return !operator==(other); |
| 118 | } |
| 119 | |
| 120 | /*! |
| 121 | Returns the Bluetooth address as a QBluetoothAddress. |
| 122 | */ |
| 123 | QBluetoothAddress QBluetoothHostInfo::address() const |
| 124 | { |
| 125 | Q_D(const QBluetoothHostInfo); |
| 126 | return d->m_address; |
| 127 | } |
| 128 | |
| 129 | /*! |
| 130 | Sets the Bluetooth \a address for this Bluetooth host info object. |
| 131 | */ |
| 132 | void QBluetoothHostInfo::setAddress(const QBluetoothAddress &address) |
| 133 | { |
| 134 | Q_D(QBluetoothHostInfo); |
| 135 | d->m_address = address; |
| 136 | } |
| 137 | |
| 138 | /*! |
| 139 | Returns the user visible name of the host info object. |
| 140 | */ |
| 141 | QString QBluetoothHostInfo::name() const |
| 142 | { |
| 143 | Q_D(const QBluetoothHostInfo); |
| 144 | return d->m_name; |
| 145 | } |
| 146 | |
| 147 | /*! |
| 148 | Sets the \a name of the host info object. |
| 149 | */ |
| 150 | void QBluetoothHostInfo::setName(const QString &name) |
| 151 | { |
| 152 | Q_D(QBluetoothHostInfo); |
| 153 | d->m_name = name; |
| 154 | } |
| 155 | |
| 156 | QT_END_NAMESPACE |
| 157 |
