From db78293e7f13d53053f323487f96fa3c9ee477ad Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 27 Jun 2013 12:44:01 +0200 Subject: [PATCH] Generic Android error messages We want to give better feedback for installation problems and other issues. There may still be undiscovered ways to mess up the creator configuration, and we might find them after the string freeze. This adds a number of strings that we can use later. We can add new error codes after the string freeze (and even in patch releases). This means that even if we can't give people detailed help for their problem in the UI, at least we give them a googleable string. We can then add better messages for the new errors in the next minor release. Change-Id: Ida7921fce5142d55144b0ba022de04726872187a Reviewed-by: Daniel Teske --- src/plugins/android/android.pro | 2 + src/plugins/android/android.qbs | 2 + src/plugins/android/androiderrormessage.cpp | 74 +++++++++++++++++++++ src/plugins/android/androiderrormessage.h | 59 ++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 src/plugins/android/androiderrormessage.cpp create mode 100644 src/plugins/android/androiderrormessage.h diff --git a/src/plugins/android/android.pro b/src/plugins/android/android.pro index 4f8ee5406ce..109359a84e0 100644 --- a/src/plugins/android/android.pro +++ b/src/plugins/android/android.pro @@ -23,6 +23,7 @@ HEADERS += \ androiddeploystep.h \ androiddeploystepwidget.h \ androiddeploystepfactory.h \ + androiderrormessage.h \ androidglobal.h \ androidrunner.h \ androiddebugsupport.h \ @@ -59,6 +60,7 @@ SOURCES += \ androiddeploystep.cpp \ androiddeploystepwidget.cpp \ androiddeploystepfactory.cpp \ + androiderrormessage.cpp \ androidrunner.cpp \ androiddebugsupport.cpp \ androidqtversionfactory.cpp \ diff --git a/src/plugins/android/android.qbs b/src/plugins/android/android.qbs index b6707534857..9f230c76ca5 100644 --- a/src/plugins/android/android.qbs +++ b/src/plugins/android/android.qbs @@ -55,6 +55,8 @@ QtcPlugin { "androiddevice.h", "androiddevicefactory.cpp", "androiddevicefactory.h", + "androiderrormessage.h", + "androiderrormessage.cpp", "androidgdbserverkitinformation.cpp", "androidgdbserverkitinformation.h", "androidglobal.h", diff --git a/src/plugins/android/androiderrormessage.cpp b/src/plugins/android/androiderrormessage.cpp new file mode 100644 index 00000000000..86016c46358 --- /dev/null +++ b/src/plugins/android/androiderrormessage.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "androiderrormessage.h" + +#include + +namespace Android { +namespace Internal { + +QString AndroidErrorMessage::getMessage(ErrorCode errorCode, const QVariantList ¶meters) +{ + Q_UNUSED(parameters); + switch (errorCode) { + case SDKInstallationError: + return QObject::tr("Android: SDK installation error 0x%1").arg(errorCode, 0, 16); + + case NDKInstallationError: + return QObject::tr("Android: NDK installation error 0x%1").arg(errorCode, 0, 16); + + case JavaInstallationError: + return QObject::tr("Android: Java installation error 0x%1").arg(errorCode, 0, 16); + + case AntInstallationError: + return QObject::tr("Android: ant installation error 0x%1").arg(errorCode, 0, 16); + + case AdbInstallationError: + return QObject::tr("Android: adb installation error 0x%1").arg(errorCode, 0, 16); + + case DeviceConnectionError: + return QObject::tr("Android: Device connection error 0x%1").arg(errorCode, 0, 16); + + case DevicePermissionError: + return QObject::tr("Android: Device permission error 0x%1").arg(errorCode, 0, 16); + + case DeviceAuthorizationError: + return QObject::tr("Android: Device authorization error 0x%1").arg(errorCode, 0, 16); + + case DeviceAPILevelError: + return QObject::tr("Android: Device API level not supported: error 0x%1").arg(errorCode, 0, 16); + + default: + return QObject::tr("Android: Unknown error 0x%1").arg(errorCode, 0, 16); + } +} + +} // namespace Internal +} // namespace Android diff --git a/src/plugins/android/androiderrormessage.h b/src/plugins/android/androiderrormessage.h new file mode 100644 index 00000000000..0e061389a34 --- /dev/null +++ b/src/plugins/android/androiderrormessage.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef ANDROIDERRORMESSAGE_H +#define ANDROIDERRORMESSAGE_H + +#include + +namespace Android { +namespace Internal { + +class AndroidErrorMessage +{ +public: + enum ErrorCode { + UnknownError = 0x3000, + SDKInstallationError, + NDKInstallationError, + JavaInstallationError, + AntInstallationError, + AdbInstallationError, + DeviceConnectionError, + DevicePermissionError, + DeviceAuthorizationError, + DeviceAPILevelError + }; + static QString getMessage(ErrorCode errorCode, const QVariantList ¶meters = QVariantList()); +}; + +} // namespace Internal +} // namespace Android + +#endif // ANDROIDERRORMESSAGE_H