~saiarcot895/ubuntu/utopic/qtconnectivity-opensource-src/enable-bluetooth

« back to all changes in this revision

Viewing changes to src/bluetooth/qbluetoothtransferrequest.cpp

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-08-20 08:46:41 UTC
  • Revision ID: package-import@ubuntu.com-20130820084641-09v00451dpna7ydk
Tags: upstream-5.0~git20130802
ImportĀ upstreamĀ versionĀ 5.0~git20130802

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
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 Digia.  For licensing terms and
 
14
** conditions see http://qt.digia.com/licensing.  For further information
 
15
** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
 
20
** Foundation and appearing in the file LICENSE.LGPL included in the
 
21
** packaging of this file.  Please review the following information to
 
22
** ensure the GNU Lesser General Public License version 2.1 requirements
 
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
24
**
 
25
** In addition, as a special exception, Digia gives you certain additional
 
26
** rights.  These rights are described in the Digia Qt LGPL Exception
 
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
28
**
 
29
** GNU General Public License Usage
 
30
** Alternatively, this file may be used under the terms of the GNU
 
31
** General Public License version 3.0 as published by the Free Software
 
32
** Foundation and appearing in the file LICENSE.GPL included in the
 
33
** packaging of this file.  Please review the following information to
 
34
** ensure the GNU General Public License version 3.0 requirements will be
 
35
** met: http://www.gnu.org/copyleft/gpl.html.
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
#include "qbluetoothtransferrequest.h"
 
43
#include "qbluetoothaddress.h"
 
44
#include "qbluetoothtransferrequest_p.h"
 
45
 
 
46
 
 
47
QT_BEGIN_NAMESPACE_BLUETOOTH
 
48
 
 
49
/*!
 
50
    \class QBluetoothTransferRequest
 
51
    \inmodule QtBluetooth
 
52
    \brief The QBluetoothTransferRequest class stores information about a
 
53
    data transfer request.
 
54
 
 
55
    QBluetoothTransferRequest is part of the Bluetooth Transfer API and is the class holding the
 
56
    information necessary to initiate a transfer over Bluetooth.
 
57
 
 
58
    \sa QBluetoothTransferReply, QBluetoothTransferManager
 
59
*/
 
60
 
 
61
/*!
 
62
    \enum QBluetoothTransferRequest::Attribute
 
63
 
 
64
    Attribute codes for QBluetoothTransferRequest and QBluetoothTransferReply.
 
65
 
 
66
    \value DescriptionAttribute A textual description of the object being transferred.
 
67
    May be displayed in the UI of the remote device.
 
68
    \value TimeAttribute        Time attribute of the object being transferred.
 
69
    \value TypeAttribute        MIME type of the object being transferred.
 
70
    \value LengthAttribute      Length in bytes of the object being transferred.
 
71
    \value NameAttribute        Name of the object being transferred. May be displayed in the UI of
 
72
                                the remote device.
 
73
*/
 
74
 
 
75
/*!
 
76
    Constructs a new Bluetooth transfer request to the device with \a address.
 
77
*/
 
78
QBluetoothTransferRequest::QBluetoothTransferRequest(const QBluetoothAddress &address)
 
79
:d_ptr(new QBluetoothTransferRequestPrivate)
 
80
{
 
81
    Q_D(QBluetoothTransferRequest);
 
82
 
 
83
    d->m_address = address;
 
84
}
 
85
 
 
86
/*!
 
87
    Constructs a new Bluetooth transfer request that is a copy of \a other.
 
88
*/
 
89
QBluetoothTransferRequest::QBluetoothTransferRequest(const QBluetoothTransferRequest &other)
 
90
:d_ptr(new QBluetoothTransferRequestPrivate)
 
91
{
 
92
    *this = other;
 
93
}
 
94
 
 
95
/*!
 
96
    Destorys the Bluetooth transfer request.
 
97
*/
 
98
QBluetoothTransferRequest::~QBluetoothTransferRequest()
 
99
{
 
100
    delete d_ptr;
 
101
}
 
102
 
 
103
/*!
 
104
    Returns the attribute associated with \a code. If the attribute has not been set, it
 
105
    returns \a defaultValue.
 
106
 
 
107
    \sa setAttribute(), QBluetoothTransferRequest::Attribute
 
108
*/
 
109
QVariant QBluetoothTransferRequest::attribute(Attribute code, const QVariant &defaultValue) const
 
110
{
 
111
    Q_D(const QBluetoothTransferRequest);
 
112
 
 
113
    if (d->m_parameters.contains((int)code)) {
 
114
        return d->m_parameters.value((int)code);
 
115
    } else {
 
116
        return defaultValue;
 
117
    }
 
118
}
 
119
 
 
120
/*!
 
121
    Sets the attribute associated with \a code to \a value. If the attribute is
 
122
    already set, the previous value is discarded. If \a value is an invalid QVariant, the attribute
 
123
    is unset.
 
124
 
 
125
    \sa attribute(), QBluetoothTransferRequest::Attribute
 
126
*/
 
127
void QBluetoothTransferRequest::setAttribute(Attribute code, const QVariant &value)
 
128
{
 
129
    Q_D(QBluetoothTransferRequest);
 
130
 
 
131
    d->m_parameters.insert((int)code, value);
 
132
}
 
133
 
 
134
/*!
 
135
    Returns the address associated with the Bluetooth transfer request.
 
136
*/
 
137
QBluetoothAddress QBluetoothTransferRequest::address() const
 
138
{
 
139
    Q_D(const QBluetoothTransferRequest);
 
140
 
 
141
    return d->m_address;
 
142
}
 
143
 
 
144
 
 
145
/*!
 
146
    Returns true if this object is not the same as \a other.
 
147
 
 
148
    \sa operator==()
 
149
*/
 
150
bool QBluetoothTransferRequest::operator!=(const QBluetoothTransferRequest &other) const
 
151
{
 
152
    return !(*this == other);
 
153
}
 
154
 
 
155
/*!
 
156
    Creates a copy of \a other.
 
157
*/
 
158
QBluetoothTransferRequest &QBluetoothTransferRequest::operator=(const QBluetoothTransferRequest &other)
 
159
{
 
160
    Q_D(QBluetoothTransferRequest);
 
161
 
 
162
    d->m_address = other.d_func()->m_address;
 
163
    d->m_parameters = other.d_func()->m_parameters;
 
164
 
 
165
    return *this;
 
166
}
 
167
 
 
168
/*!
 
169
    Returns true if this object is the same as \a other.
 
170
*/
 
171
bool QBluetoothTransferRequest::operator==(const QBluetoothTransferRequest &other) const
 
172
{
 
173
    Q_D(const QBluetoothTransferRequest);
 
174
    if (d->m_address == other.d_func()->m_address && d->m_parameters == other.d_func()->m_parameters) {
 
175
        return true;
 
176
    }
 
177
    return false;
 
178
}
 
179
 
 
180
QBluetoothTransferRequestPrivate::QBluetoothTransferRequestPrivate()
 
181
{
 
182
}
 
183
 
 
184
QT_END_NAMESPACE_BLUETOOTH