summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-03-05 12:22:22 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-03-06 11:32:30 +0000
commit6b2fd04b7be4494767b6092a030607010d91310c (patch)
tree229f5faf260ddb52c6129806956496c82eebbb00
parent0c626f290111a0dfed2e0faae98afb1b0ad9943c (diff)
Shift all OSX & iOS translations into C++ filev5.5.0-alpha1
lupdate cannot parse .mm files. Therefore tr markup must be inside of C++ files. Some error strings where slightly modified to make use of already existing translations for other backends such as Bluez and QNX. Change-Id: I97fe6cfe2227e32fdbc61edd253080a1cd68edc9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
-rw-r--r--src/bluetooth/osx/osxbt.pri3
-rw-r--r--src/bluetooth/osx/uistrings.cpp82
-rw-r--r--src/bluetooth/osx/uistrings_p.h91
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm14
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm16
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_osx.mm11
-rw-r--r--src/bluetooth/qbluetoothsocket_osx.mm17
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez.cpp2
-rw-r--r--src/bluetooth/qbluetoothtransferreply_osx.mm42
-rw-r--r--src/bluetooth/qlowenergycontroller_osx.mm9
10 files changed, 235 insertions, 52 deletions
diff --git a/src/bluetooth/osx/osxbt.pri b/src/bluetooth/osx/osxbt.pri
index 5f1dddec..06389fcc 100644
--- a/src/bluetooth/osx/osxbt.pri
+++ b/src/bluetooth/osx/osxbt.pri
@@ -1,3 +1,6 @@
+SOURCES += osx/uistrings.cpp
+PRIVATE_HEADERS += osx/uistrings_p.h
+
CONFIG(osx) {
PRIVATE_HEADERS += osx/osxbtutility_p.h \
osx/osxbtdevicepair_p.h \
diff --git a/src/bluetooth/osx/uistrings.cpp b/src/bluetooth/osx/uistrings.cpp
new file mode 100644
index 00000000..5684533e
--- /dev/null
+++ b/src/bluetooth/osx/uistrings.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "uistrings_p.h"
+
+// Translatable messages should go into this .cpp file for them to
+// be picked up by lupdate.
+
+QT_BEGIN_NAMESPACE
+
+const char DEV_DISCOVERY[] = "QBluetoothDeviceDiscoveryAgent";
+const char DD_POWERED_OFF[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Device is powered off");
+const char DD_INVALID_ADAPTER[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Cannot find valid Bluetooth adapter.");
+const char DD_IO[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Input Output Error");
+const char DD_NOTSUPPORTED[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Bluetooth LE is not supported");
+const char DD_UNKNOWN_ERROR[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Unknown error");
+const char DD_NOT_STARTED[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Cannot start device inquiry");
+const char DD_NOT_STARTED_LE[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Cannot start low energy device inquiry");
+const char DD_NOT_STOPPED[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Discovery cannot be stopped");
+
+const char SERVICE_DISCOVERY[] = "QBluetoothServiceDiscoveryAgent";
+const char SD_LOCAL_DEV_OFF[] = QT_TRANSLATE_NOOP("QBluetoothServiceDiscoveryAgent", "Local device is powered off");
+const char SD_MINIMAL_FAILED[] = QT_TRANSLATE_NOOP("QBluetoothServiceDiscoveryAgent", "Minimal service discovery failed");
+const char SD_INVALID_ADDRESS[] = QT_TRANSLATE_NOOP("QBluetoothServiceDiscoveryAgent", "Invalid Bluetooth adapter address");
+
+const char SOCKET[] = "QBluetoothSocket";
+const char SOC_NETWORK_ERROR[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Network Error");
+const char SOC_NOWRITE[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Cannot write while not connected");
+const char SOC_CONNECT_IN_PROGRESS[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Trying to connect while connection is in progress");
+const char SOC_SERVICE_NOT_FOUND[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Service cannot be found");
+const char SOC_INVAL_DATASIZE[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Invalid data/data size");
+const char SOC_NOREAD[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Cannot read while not connected");
+
+const char TRANSFER_REPLY[] = "QBluetoothTransferReply";
+const char TR_INVAL_TARGET[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Invalid target address");
+const char TR_SESSION_NO_START[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push session cannot be started");
+const char TR_CONNECT_FAILED[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push session cannot connect");
+const char TR_FILE_NOT_EXIST[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Source file does not exist");
+const char TR_NOT_READ_IODEVICE[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "QIODevice cannot be read. Make sure it is open for reading.");
+const char TR_SESSION_FAILED[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push session failed");
+const char TR_INVALID_DEVICE[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Invalid input device (null)");
+const char TR_OP_CANCEL[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Operation canceled");
+const char TR_IN_PROGRESS[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Transfer already started");
+const char TR_SERVICE_NO_FOUND[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push service not found");
+
+const char LE_CONTROLLER[] = "QLowEnergyController";
+const char LEC_RDEV_NO_FOUND[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Remote device cannot be found");
+const char LEC_NO_LOCAL_DEV[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Cannot find local adapter");
+const char LEC_IO_ERROR[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Error occurred during connection I/O");
+const char LEC_UNKNOWN_ERROR[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Unknown Error");
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/uistrings_p.h b/src/bluetooth/osx/uistrings_p.h
new file mode 100644
index 00000000..303bad89
--- /dev/null
+++ b/src/bluetooth/osx/uistrings_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TRANSLATIONS_H
+#define TRANSLATIONS_H
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+// QBluetoothDeviceDiscoveryAgent related strings
+extern const char DEV_DISCOVERY[];
+extern const char DD_POWERED_OFF[];
+extern const char DD_INVALID_ADAPTER[];
+extern const char DD_IO[];
+extern const char DD_NOTSUPPORTED[];
+extern const char DD_UNKNOWN_ERROR[];
+extern const char DD_NOT_STARTED[];
+extern const char DD_NOT_STARTED_LE[];
+extern const char DD_NOT_STOPPED[];
+
+// QBluetoothServiceDiscoveryAgent related strings
+extern const char SERVICE_DISCOVERY[];
+extern const char SD_LOCAL_DEV_OFF[];
+extern const char SD_MINIMAL_FAILED[];
+extern const char SD_INVALID_ADDRESS[];
+
+// QBluetoothSocket related strings
+extern const char SOCKET[];
+extern const char SOC_NETWORK_ERROR[];
+extern const char SOC_NOWRITE[];
+extern const char SOC_CONNECT_IN_PROGRESS[];
+extern const char SOC_SERVICE_NOT_FOUND[];
+extern const char SOC_INVAL_DATASIZE[];
+extern const char SOC_NOREAD[];
+
+// QBluetoothTransferReply related strings
+extern const char TRANSFER_REPLY[];
+extern const char TR_INVAL_TARGET[];
+extern const char TR_SESSION_NO_START[];
+extern const char TR_CONNECT_FAILED[];
+extern const char TR_FILE_NOT_EXIST[];
+extern const char TR_NOT_READ_IODEVICE[];
+extern const char TR_SESSION_FAILED[];
+extern const char TR_INVALID_DEVICE[];
+extern const char TR_OP_CANCEL[];
+extern const char TR_IN_PROGRESS[];
+extern const char TR_SERVICE_NO_FOUND[];
+
+// QLowEnergyController related strings
+extern const char LE_CONTROLLER[];
+extern const char LEC_RDEV_NO_FOUND[];
+extern const char LEC_NO_LOCAL_DEV[];
+extern const char LEC_IO_ERROR[];
+extern const char LEC_UNKNOWN_ERROR[];
+
+QT_END_NAMESPACE
+
+#endif // TRANSLATIONS_H
+
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm
index 1bce6400..85c9f0da 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm
@@ -36,6 +36,7 @@
#include "qbluetoothlocaldevice.h"
#include "qbluetoothdeviceinfo.h"
#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
#include "qbluetoothuuid.h"
#include <QtCore/qloggingcategory.h>
@@ -156,8 +157,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
// We can be here only if we have some kind of
// resource allocation error.
setError(QBluetoothDeviceDiscoveryAgent::UnknownError,
- QObject::tr("device discovery agent, failed to start: "
- "resource allocation error"));
+ QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STARTED);
emit q_ptr->error(lastError);
}
}
@@ -270,20 +270,20 @@ void QBluetoothDeviceDiscoveryAgentPrivate::setError(QBluetoothDeviceDiscoveryAg
errorString = QString();
break;
case QBluetoothDeviceDiscoveryAgent::PoweredOffError:
- errorString = QObject::tr("device discovery agent: adapter is powered off");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_POWERED_OFF);
break;
case QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError:
- errorString = QObject::tr("device discovery agent: invalid bluetooth adapter");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_INVALID_ADAPTER);
break;
case QBluetoothDeviceDiscoveryAgent::InputOutputError:
- errorString = QObject::tr("device discovery agent: input output error");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_IO);
break;
case QBluetoothDeviceDiscoveryAgent::UnsupportedPlatformError:
- errorString = QObject::tr("Bluetooth LE is not supported");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_NOTSUPPORTED);
break;
case QBluetoothDeviceDiscoveryAgent::UnknownError:
default:
- errorString = QObject::tr("device discovery agent: unknown error");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
}
}
}
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
index b6e32231..194eba07 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
@@ -38,6 +38,7 @@
#include "osx/osxbtsdpinquiry_p.h"
#include "qbluetoothdeviceinfo.h"
#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
#include "qbluetoothhostinfo.h"
#include "qbluetoothuuid.h"
@@ -206,7 +207,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
const IOReturn res = [inquiry start];
if (res != kIOReturnSuccess) {
- setError(res, QObject::tr("device discovery agent: failed to start"));
+ setError(res, QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STARTED));
agentState = NonActive;
emit q_ptr->error(lastError);
}
@@ -224,8 +225,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startLE()
// We can be here only if we have some kind of resource allocation error, so we
// do not emit finished, we emit error.
setError(QBluetoothDeviceDiscoveryAgent::UnknownError,
- QObject::tr("device discovery agent, LE mode: "
- "resource allocation error"));
+ QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STARTED_LE));
agentState = NonActive;
emit q_ptr->error(lastError);
}
@@ -250,7 +250,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::stop()
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to stop";
startPending = prevStart;
stopPending = false;
- setError(res, QObject::tr("device discovery agent: failed to stop"));
+ setError(res, QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STOPPED));
emit q_ptr->error(lastError);
}
} else {
@@ -357,17 +357,17 @@ void QBluetoothDeviceDiscoveryAgentPrivate::setError(QBluetoothDeviceDiscoveryAg
errorString = QString();
break;
case QBluetoothDeviceDiscoveryAgent::PoweredOffError:
- errorString = QObject::tr("device discovery agent: adapter is powered off");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_POWERED_OFF);
break;
case QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError:
- errorString = QObject::tr("device discovery agent: invalid bluetooth adapter");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_INVALID_ADAPTER);
break;
case QBluetoothDeviceDiscoveryAgent::InputOutputError:
- errorString = QObject::tr("device discovery agent: input output error");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_IO);
break;
case QBluetoothDeviceDiscoveryAgent::UnknownError:
default:
- errorString = QObject::tr("device discovery agent: unknown error");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
}
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
index faceabac..572e445e 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
@@ -37,6 +37,7 @@
#include "osx/osxbtsdpinquiry_p.h"
#include "qbluetoothhostinfo.h"
#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
#include <QtCore/qloggingcategory.h>
#include <QtCore/qscopedpointer.h>
@@ -176,7 +177,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::startServiceDiscovery()
discoveredDevices.clear();
if (singleDevice) {
error = QBluetoothServiceDiscoveryAgent::PoweredOffError;
- errorString = QBluetoothServiceDiscoveryAgent::tr("Local device is powered off");
+ errorString = QCoreApplication::translate(SERVICE_DISCOVERY, SD_LOCAL_DEV_OFF);
emit q_ptr->error(error);
}
@@ -250,7 +251,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryError(QBluetoothD
Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
error = QBluetoothServiceDiscoveryAgent::UnknownError;
- errorString = tr("Unknown error while scanning for devices");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
deviceDiscoveryAgent->stop();
deviceDiscoveryAgent.reset(Q_NULLPTR);
@@ -326,7 +327,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryError(IOBluetoothDevice *
// TODO: find a better mapping from IOReturn to QBluetoothServiceDiscoveryAgent::Error.
if (singleDevice) {
error = QBluetoothServiceDiscoveryAgent::UnknownError;
- errorString = QObject::tr("service discovery agent: unknown error");
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
emit q_ptr->error(error);
}
@@ -344,7 +345,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
if (!device || !device.services) {
if (singleDevice) {
error = QBluetoothServiceDiscoveryAgent::UnknownError;
- errorString = tr("service discovery agent: minimal service discovery failed");
+ errorString = QCoreApplication::translate(SERVICE_DISCOVERY, SD_MINIMAL_FAILED);
emit q_ptr->error(error);
}
} else {
@@ -431,7 +432,7 @@ QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoot
return;
}
d_ptr->error = InvalidBluetoothAdapterError;
- d_ptr->errorString = tr("Invalid Bluetooth adapter address");
+ d_ptr->errorString = QCoreApplication::translate(SERVICE_DISCOVERY, SD_INVALID_ADDRESS);
}
}
diff --git a/src/bluetooth/qbluetoothsocket_osx.mm b/src/bluetooth/qbluetoothsocket_osx.mm
index 2472cbee..62883247 100644
--- a/src/bluetooth/qbluetoothsocket_osx.mm
+++ b/src/bluetooth/qbluetoothsocket_osx.mm
@@ -42,6 +42,7 @@
#include "qbluetoothlocaldevice.h"
#include "qbluetoothdeviceinfo.h"
#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
#include "qbluetoothsocket.h"
#include <QtCore/qloggingcategory.h>
@@ -250,7 +251,7 @@ void QBluetoothSocketPrivate::_q_writeNotify()
status = [l2capChannel writeAsync:writeChunk.data() length:UInt16(size)];
if (status != kIOReturnSuccess) {
- errorString = QBluetoothSocket::tr("Network Error");
+ errorString = QCoreApplication::translate(SOCKET, SOC_NETWORK_ERROR);
q_ptr->setSocketError(QBluetoothSocket::NetworkError);
return;
} else {
@@ -386,7 +387,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
Q_ASSERT_X(maxSize > 0, Q_FUNC_INFO, "invalid data size");
if (state != QBluetoothSocket::ConnectedState) {
- errorString = tr("Cannot write while not connected");
+ errorString = QCoreApplication::translate(SOCKET, SOC_NOWRITE);
q_ptr->setSocketError(QBluetoothSocket::OperationError);
return -1;
}
@@ -445,7 +446,7 @@ void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, Op
{
if (state() != UnconnectedState && state() != ServiceLookupState) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called on a busy socket";
- d_ptr->errorString = tr("Trying to connect while connection is in progress");
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
setSocketError(OperationError);
return;
}
@@ -474,7 +475,7 @@ void QBluetoothSocket::connectToService(const QBluetoothAddress &address, const
{
if (state() != QBluetoothSocket::UnconnectedState) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called on a busy socket";
- d_ptr->errorString = tr("Trying to connect while connection is in progress");
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
setSocketError(QBluetoothSocket::OperationError);
return;
}
@@ -491,7 +492,7 @@ void QBluetoothSocket::connectToService(const QBluetoothAddress &address, quint1
{
if (state() != QBluetoothSocket::UnconnectedState) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called on a busy socket";
- d_ptr->errorString = tr("Trying to connect while connection is in progress");
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
setSocketError(OperationError);
return;
}
@@ -585,7 +586,7 @@ void QBluetoothSocket::serviceDiscovered(const QBluetoothServiceInfo &service)
void QBluetoothSocket::discoveryFinished()
{
- d_ptr->errorString = tr("Service cannot be found");
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_SERVICE_NOT_FOUND);
setSocketState(UnconnectedState);
setSocketError(ServiceNotFoundError);
}
@@ -642,7 +643,7 @@ quint16 QBluetoothSocket::peerPort() const
qint64 QBluetoothSocket::writeData(const char *data, qint64 maxSize)
{
if (!data || maxSize <= 0) {
- d_ptr->errorString = tr("Invalid data/data size");
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_INVAL_DATASIZE);
setSocketError(QBluetoothSocket::OperationError);
return -1;
}
@@ -653,7 +654,7 @@ qint64 QBluetoothSocket::writeData(const char *data, qint64 maxSize)
qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize)
{
if (state != QBluetoothSocket::ConnectedState) {
- errorString = tr("Cannot read while not connected");
+ errorString = QCoreApplication::translate(SOCKET, SOC_NOREAD);
q_ptr->setSocketError(QBluetoothSocket::OperationError);
return -1;
}
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
index 61bfb90d..f7f72873 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
@@ -385,7 +385,7 @@ void QBluetoothTransferReplyBluez::Error(const QDBusObjectPath &in0, const QStri
m_errorStr = tr("Could not open file for sending");
} else if (in1 == QStringLiteral("Operation canceled")) {
m_error = QBluetoothTransferReply::UserCanceledTransferError;
- m_errorStr = tr("Operation canceled");
+ m_errorStr = QBluetoothTransferReply::tr("Operation canceled");
} else {
m_error = QBluetoothTransferReply::UnknownError;
}
diff --git a/src/bluetooth/qbluetoothtransferreply_osx.mm b/src/bluetooth/qbluetoothtransferreply_osx.mm
index 2b5389fb..1b84626b 100644
--- a/src/bluetooth/qbluetoothtransferreply_osx.mm
+++ b/src/bluetooth/qbluetoothtransferreply_osx.mm
@@ -36,6 +36,7 @@
#include "osx/osxbtobexsession_p.h"
#include "qbluetoothserviceinfo.h"
#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
#include "qbluetoothuuid.h"
@@ -172,7 +173,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev
if (device.isNull() || !channelID) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid device address or port";
setReplyError(QBluetoothTransferReply::HostNotFoundError,
- QObject::tr("Invalid target address"));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
return;
}
@@ -182,7 +183,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate OSXBTOBEXSession object";
setReplyError(QBluetoothTransferReply::UnknownError,
- QObject::tr("Failed to create an OBEX session"));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SESSION_NO_START));
return;
}
@@ -199,7 +200,7 @@ void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &dev
if (error == QBluetoothTransferReply::NoError) {
// The error is not set yet.
error = QBluetoothTransferReply::SessionError;
- errorString = QObject::tr("OBEXConnect failed");
+ errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED);
}
requestComplete = true;
@@ -221,14 +222,13 @@ void QBluetoothTransferReplyOSXPrivate::sendPut()
if (file) {
if (!file->exists()) {
setReplyError(QBluetoothTransferReply::FileNotFoundError,
- QObject::tr("Source file does not exist"));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_FILE_NOT_EXIST));
return;
} else if (!file->isReadable()) {
file->open(QIODevice::ReadOnly);
if (!file->isReadable()) {
setReplyError(QBluetoothTransferReply::IODeviceNotReadableError,
- QObject::tr("File cannot be read. "
- "Make sure it is open for reading."));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_NOT_READ_IODEVICE));
return;
}
}
@@ -237,8 +237,7 @@ void QBluetoothTransferReplyOSXPrivate::sendPut()
} else {
if (!inputStream->isReadable()) {
setReplyError(QBluetoothTransferReply::IODeviceNotReadableError,
- QObject::tr("QIODevice cannot be read. "
- "Make sure it is open for reading."));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_NOT_READ_IODEVICE));
return;
}
@@ -253,7 +252,7 @@ void QBluetoothTransferReplyOSXPrivate::sendPut()
if ([session OBEXPutFile:inputStream withName:fileName] != kOBEXSuccess) {
// TODO: convert OBEXError into something reasonable?
setReplyError(QBluetoothTransferReply::SessionError,
- QObject::tr("OBEX put failed"));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SESSION_FAILED));
}
}
@@ -265,12 +264,12 @@ void QBluetoothTransferReplyOSXPrivate::OBEXConnectError(OBEXError errorCode, OB
if (session) {
setReplyError(QBluetoothTransferReply::SessionError,
- QObject::tr("OBEX connect failed"));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED));
} else {
// Else we're still in OBEXConnect, in a call-back
// and do not want to emit yet (will be done a bit later).
error = QBluetoothTransferReply::SessionError;
- errorString = QObject::tr("OBEX connect failed");
+ errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED);
requestComplete = true;
}
}
@@ -318,7 +317,7 @@ void QBluetoothTransferReplyOSXPrivate::OBEXPutError(OBEXError errorCode, OBEXOp
}
setReplyError(QBluetoothTransferReply::SessionError,
- QObject::tr("OBEX PUT command failed"));
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SESSION_FAILED));
}
void QBluetoothTransferReplyOSXPrivate::setReplyError(QBluetoothTransferReply::TransferError errorCode,
@@ -352,7 +351,7 @@ QBluetoothTransferReplyOSX::QBluetoothTransferReplyOSX(QIODevice *input,
} else {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid input stream (null)";
osx_d_ptr->requestComplete = true;
- osx_d_ptr->errorString = tr("Invalid input file (null)");
+ osx_d_ptr->errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_INVALID_DEVICE);
osx_d_ptr->error = FileNotFoundError;
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
Q_ARG(QBluetoothTransferReply::TransferError, FileNotFoundError));
@@ -393,7 +392,7 @@ bool QBluetoothTransferReplyOSX::abort()
// Not setReplyError, we emit finished only!
osx_d_ptr->requestComplete = true;
- osx_d_ptr->errorString = tr("Operation canceled");
+ osx_d_ptr->errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_OP_CANCEL);
osx_d_ptr->error = UserCanceledTransferError;
emit finished(this);
@@ -412,13 +411,15 @@ bool QBluetoothTransferReplyOSX::start()
// Step 0: find a channelID.
if (request().address().isNull()) {
qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid device address";
- osx_d_ptr->setReplyError(HostNotFoundError, tr("Invalid target address"));
+ osx_d_ptr->setReplyError(HostNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
return false;
}
return osx_d_ptr->startOPP(request().address());
} else {
- osx_d_ptr->setReplyError(UnknownError, tr("Transfer already started"));
+ osx_d_ptr->setReplyError(UnknownError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_IN_PROGRESS));
return false;
}
}
@@ -440,7 +441,8 @@ void QBluetoothTransferReplyOSX::serviceDiscoveryFinished()
osx_d_ptr->agent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
} else {
// No service record, no channel ID, no OBEX session.
- osx_d_ptr->setReplyError(HostNotFoundError, tr("OBEX/OPP serice not found"));
+ osx_d_ptr->setReplyError(HostNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SERVICE_NO_FOUND));
}
}
}
@@ -451,7 +453,8 @@ void QBluetoothTransferReplyOSX::serviceDiscoveryError(QBluetoothServiceDiscover
if (errorCode == QBluetoothServiceDiscoveryAgent::PoweredOffError) {
// There's nothing else we can do.
- osx_d_ptr->setReplyError(UnknownError, tr("Bluetooth adapter is powered off"));
+ osx_d_ptr->setReplyError(UnknownError,
+ QCoreApplication::translate(DEV_DISCOVERY, DD_POWERED_OFF));
return;
}
@@ -459,7 +462,8 @@ void QBluetoothTransferReplyOSX::serviceDiscoveryError(QBluetoothServiceDiscover
osx_d_ptr->minimalScan = false;
osx_d_ptr->agent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
} else {
- osx_d_ptr->setReplyError(HostNotFoundError, tr("Invalid target address"));
+ osx_d_ptr->setReplyError(HostNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
}
}
diff --git a/src/bluetooth/qlowenergycontroller_osx.mm b/src/bluetooth/qlowenergycontroller_osx.mm
index 6be8dd67..80a94d64 100644
--- a/src/bluetooth/qlowenergycontroller_osx.mm
+++ b/src/bluetooth/qlowenergycontroller_osx.mm
@@ -33,6 +33,7 @@
****************************************************************************/
#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
#include "qlowenergyserviceprivate_p.h"
#include "qlowenergycontroller_osx_p.h"
@@ -694,17 +695,17 @@ void QLowEnergyControllerPrivateOSX::setErrorDescription(QLowEnergyController::E
errorString.clear();
break;
case QLowEnergyController::UnknownRemoteDeviceError:
- errorString = QLowEnergyController::tr("Remote device cannot be found");
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_RDEV_NO_FOUND);
break;
case QLowEnergyController::InvalidBluetoothAdapterError:
- errorString = QLowEnergyController::tr("Cannot find local adapter");
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_NO_LOCAL_DEV);
break;
case QLowEnergyController::NetworkError:
- errorString = QLowEnergyController::tr("Error occurred during connection I/O");
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_IO_ERROR);
break;
case QLowEnergyController::UnknownError:
default:
- errorString = QLowEnergyController::tr("Unknown Error");
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_UNKNOWN_ERROR);
break;
}
}