Maemo: Make SSH connection error messages a bit more helpful.

Task-number: QTCREATORBUG-3225
This commit is contained in:
Christian Kandeler
2010-11-30 10:55:44 +01:00
parent 80f640fbb3
commit 8a89a8bd8e
4 changed files with 38 additions and 8 deletions

View File

@@ -335,12 +335,15 @@ void MaemoDeployStep::start()
void MaemoDeployStep::handleConnectionFailure() void MaemoDeployStep::handleConnectionFailure()
{ {
if (m_state != Inactive) { if (m_state == Inactive)
raiseError(tr("Could not connect to host: %1") return;
.arg(m_connection->errorString()));
const QString errorMsg = m_state == Connecting
? MaemoGlobal::failedToConnectToServerMessage(m_connection, deviceConfig())
: tr("Connection error: %1").arg(m_connection->errorString());
raiseError(errorMsg);
setState(Inactive); setState(Inactive);
} }
}
void MaemoDeployStep::handleSftpChannelInitialized() void MaemoDeployStep::handleSftpChannelInitialized()
{ {

View File

@@ -29,6 +29,9 @@
#include "maemoglobal.h" #include "maemoglobal.h"
#include "maemodeviceconfigurations.h"
#include <coreplugin/ssh/sshconnection.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
@@ -79,6 +82,23 @@ QString MaemoGlobal::remoteEnvironment(const QList<Utils::EnvironmentItem> &list
return env.mid(0, env.size() - 1); return env.mid(0, env.size() - 1);
} }
QString MaemoGlobal::failedToConnectToServerMessage(const Core::SshConnection::Ptr &connection,
const MaemoDeviceConfig &deviceConfig)
{
QString errorMsg = TR("Could not connect to host: %1")
.arg(connection->errorString());
if (deviceConfig.type == MaemoDeviceConfig::Simulator) {
if (connection->errorState() == Core::SshTimeoutError
|| connection->errorState() == Core::SshSocketError) {
errorMsg += TR("\nDid you start Qemu?");
}
} else if (connection->errorState() == Core::SshTimeoutError) {
errorMsg += TR("\nIs the device connected and set up for network access?");
}
return errorMsg;
}
bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error) bool MaemoGlobal::removeRecursively(const QString &filePath, QString &error)
{ {
QFileInfo fileInfo(filePath); QFileInfo fileInfo(filePath);

View File

@@ -37,6 +37,7 @@
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QSharedPointer>
#define ASSERT_STATE_GENERIC(State, expected, actual) \ #define ASSERT_STATE_GENERIC(State, expected, actual) \
MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO) MaemoGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)
@@ -46,8 +47,11 @@ class QProcess;
class QString; class QString;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core { class SshConnection; }
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
class MaemoDeviceConfig;
class MaemoGlobal class MaemoGlobal
{ {
@@ -57,6 +61,8 @@ public:
static QString remoteCommandPrefix(const QString &commandFilePath); static QString remoteCommandPrefix(const QString &commandFilePath);
static QString remoteEnvironment(const QList<Utils::EnvironmentItem> &list); static QString remoteEnvironment(const QList<Utils::EnvironmentItem> &list);
static QString remoteSourceProfilesCommand(); static QString remoteSourceProfilesCommand();
static QString failedToConnectToServerMessage(const QSharedPointer<Core::SshConnection> &connection,
const MaemoDeviceConfig &deviceConfig);
static bool removeRecursively(const QString &filePath, QString &error); static bool removeRecursively(const QString &filePath, QString &error);
static void callMaddeShellScript(QProcess &proc, const QString &maddeRoot, static void callMaddeShellScript(QProcess &proc, const QString &maddeRoot,

View File

@@ -152,9 +152,10 @@ void MaemoSshRunner::handleConnectionFailure()
if (m_state == Inactive) if (m_state == Inactive)
qWarning("Unexpected state %d in %s.", m_state, Q_FUNC_INFO); qWarning("Unexpected state %d in %s.", m_state, Q_FUNC_INFO);
const QString errorTemplate = m_state == Connecting const QString errorMsg = m_state == Connecting
? tr("Could not connect to host: %1") : tr("Connection failed: %1"); ? MaemoGlobal::failedToConnectToServerMessage(m_connection, m_devConfig)
emitError(errorTemplate.arg(m_connection->errorString())); : tr("Connection error: %1").arg(m_connection->errorString());
emitError(errorMsg);
} }
void MaemoSshRunner::cleanup() void MaemoSshRunner::cleanup()