OSDN Git Service

RemoteLinux: Remote environment refactoring.
authorChristian Kandeler <christian.kandeler@nokia.com>
Wed, 27 Jul 2011 15:15:56 +0000 (17:15 +0200)
committerChristian Kandeler <christian.kandeler@nokia.com>
Wed, 27 Jul 2011 15:24:44 +0000 (17:24 +0200)
Removes Maemo dependencies from generic code.

Change-Id: I6348b452c3a5974b652a5c717ffd0818519f8d85
Reviewed-on: http://codereview.qt.nokia.com/2298
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
src/plugins/remotelinux/maemoglobal.cpp
src/plugins/remotelinux/maemoglobal.h
src/plugins/remotelinux/maemorunconfiguration.cpp
src/plugins/remotelinux/maemorunconfiguration.h
src/plugins/remotelinux/remotelinuxenvironmentreader.cpp
src/plugins/remotelinux/remotelinuxenvironmentreader.h
src/plugins/remotelinux/remotelinuxplugin.cpp
src/plugins/remotelinux/remotelinuxrunconfiguration.cpp
src/plugins/remotelinux/remotelinuxrunconfiguration.h
src/plugins/remotelinux/remotelinuxrunconfigurationwidget.cpp
src/plugins/remotelinux/remotelinuxruncontrol.cpp

index 1e39482..d65349b 100644 (file)
@@ -142,16 +142,6 @@ QString MaemoGlobal::remoteSudo(const QString &osType, const QString &uname)
     return QString(); // Using sudo would open a can of worms.
 }
 
-QString MaemoGlobal::remoteCommandPrefix(const QString &osType)
-{
-    QString prefix = QString::fromLocal8Bit("%1; ").arg(remoteSourceProfilesCommand());
-    if (osType != QLatin1String(Maemo5OsType)
-            && osType != QLatin1String(HarmattanOsType)) {
-        prefix += QLatin1String("DISPLAY=:0.0 ");
-    }
-    return prefix;
-}
-
 QString MaemoGlobal::remoteSourceProfilesCommand()
 {
     const QList<QByteArray> profiles = QList<QByteArray>() << "/etc/profile"
index 43edb9c..ea07e9d 100644 (file)
@@ -99,7 +99,6 @@ public:
     static QString devrootshPath();
     static int applicationIconSize(const QString &osType);
     static QString remoteSudo(const QString &osType, const QString &uname);
-    static QString remoteCommandPrefix(const QString &osType);
     static QString remoteSourceProfilesCommand();
     static PortList freePorts(const QSharedPointer<const LinuxDeviceConfiguration> &devConf,
         const QtSupport::BaseQtVersion *qtVersion);
index 80e3bdd..8cb33b6 100644 (file)
@@ -108,14 +108,21 @@ bool MaemoRunConfiguration::fromMap(const QVariantMap &map)
     return true;
 }
 
+QString MaemoRunConfiguration::environmentPreparationCommand() const
+{
+    return MaemoGlobal::remoteSourceProfilesCommand();
+}
+
 QString MaemoRunConfiguration::commandPrefix() const
 {
     if (!deviceConfig())
         return QString();
 
-    return QString::fromLocal8Bit("%1 %2")
-        .arg(MaemoGlobal::remoteCommandPrefix(deviceConfig()->osType()),
-             userEnvironmentChangesAsString());
+    QString prefix = environmentPreparationCommand() + QLatin1Char(';');
+    if (deviceConfig()->osType() == QLatin1String(MeeGoOsType))
+        prefix += QLatin1String("DISPLAY=:0.0 ");
+
+    return QString::fromLocal8Bit("%1 %2").arg(prefix, userEnvironmentChangesAsString());
 }
 
 PortList MaemoRunConfiguration::freePorts() const
index 012292c..7146f9c 100644 (file)
@@ -50,6 +50,7 @@ public:
     bool fromMap(const QVariantMap &map);
     bool isEnabled() const;
     QWidget *createConfigurationWidget();
+    QString environmentPreparationCommand() const;
     QString commandPrefix() const;
     PortList freePorts() const;
     DebuggingType debuggingType() const;
index 70ea6b0..b40f494 100644 (file)
@@ -31,7 +31,6 @@
 #include "remotelinuxenvironmentreader.h"
 
 #include "linuxdeviceconfiguration.h"
-#include "maemoglobal.h"
 #include "remotelinuxrunconfiguration.h"
 
 #include <utils/ssh/sshremoteprocessrunner.h>
@@ -53,7 +52,7 @@ RemoteLinuxEnvironmentReader::~RemoteLinuxEnvironmentReader()
 {
 }
 
-void RemoteLinuxEnvironmentReader::start()
+void RemoteLinuxEnvironmentReader::start(const QString &environmentSetupCommand)
 {
     if (!m_devConfig)
         return;
@@ -75,8 +74,8 @@ void RemoteLinuxEnvironmentReader::start()
     connect(m_remoteProcessRunner.data(),
         SIGNAL(processErrorOutputAvailable(QByteArray)), this,
         SLOT(remoteErrorOutput(QByteArray)));
-    const QByteArray remoteCall = MaemoGlobal::remoteSourceProfilesCommand()
-        .toUtf8() + "; env";
+    const QByteArray remoteCall
+        = QString(environmentSetupCommand + QLatin1String("; env")).toUtf8();
     m_remoteOutput.clear();
     m_remoteProcessRunner->run(remoteCall);
 }
index 94342d2..d99814d 100644 (file)
@@ -54,7 +54,7 @@ public:
     RemoteLinuxEnvironmentReader(QObject *parent, RemoteLinuxRunConfiguration *config);
     ~RemoteLinuxEnvironmentReader();
 
-    void start();
+    void start(const QString &environmentSetupCommand);
     void stop();
 
     Utils::Environment deviceEnvironment() const { return m_env; }
index 24c3629..e56c7c8 100644 (file)
@@ -39,7 +39,6 @@
 #include "maemoconstants.h"
 #include "maemodeploystepfactory.h"
 #include "linuxdeviceconfigurations.h"
-#include "maemoglobal.h"
 #include "maemopackagecreationfactory.h"
 #include "maemopublishingwizardfactories.h"
 #include "maemoqemumanager.h"
index 40ad622..e1a5442 100644 (file)
@@ -34,7 +34,6 @@
 
 #include "deploymentinfo.h"
 #include "linuxdeviceconfiguration.h"
-#include "maemoglobal.h"
 #include "maemoqtversion.h"
 #include "maemotoolchain.h"
 #include "qt4maemotarget.h"
@@ -261,10 +260,15 @@ QString RemoteLinuxRunConfiguration::arguments() const
     return m_d->arguments;
 }
 
+QString RemoteLinuxRunConfiguration::environmentPreparationCommand() const
+{
+    return QLatin1String("source /etc/profile; source $HOME/.profile");
+}
+
 QString RemoteLinuxRunConfiguration::commandPrefix() const
 {
     return QString::fromLocal8Bit("%1; DISPLAY=:0.0 %2")
-        .arg(MaemoGlobal::remoteSourceProfilesCommand(), userEnvironmentChangesAsString());
+        .arg(environmentPreparationCommand(), userEnvironmentChangesAsString());
 }
 
 QString RemoteLinuxRunConfiguration::localExecutableFilePath() const
index e9e0424..a8c0f81 100644 (file)
@@ -91,6 +91,7 @@ public:
 
     RemoteLinuxDeployConfiguration *deployConfig() const;
 
+    virtual QString environmentPreparationCommand() const;
     virtual QString commandPrefix() const;
     virtual PortList freePorts() const;
     virtual DebuggingType debuggingType() const;
index 893282e..346df27 100644 (file)
@@ -271,7 +271,7 @@ void RemoteLinuxRunConfigurationWidget::fetchEnvironment()
     disconnect(m_fetchEnv, SIGNAL(clicked()), this, SLOT(fetchEnvironment()));
     connect(m_fetchEnv, SIGNAL(clicked()), this, SLOT(stopFetchEnvironment()));
     m_fetchEnv->setText(tr("Cancel Fetch Operation"));
-    m_deviceEnvReader->start();
+    m_deviceEnvReader->start(m_runConfiguration->environmentPreparationCommand());
 }
 
 void RemoteLinuxRunConfigurationWidget::stopFetchEnvironment()
index 0504610..c37fbe9 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "remotelinuxruncontrol.h"
 
-#include "maemoglobal.h"
 #include "remotelinuxapplicationrunner.h"
 #include "remotelinuxrunconfiguration.h"