From b61e6564934f43714d59a9439d65c801d2701852 Mon Sep 17 00:00:00 2001
From: ck <qt-info@nokia.com>
Date: Mon, 3 May 2010 16:56:38 +0200
Subject: [PATCH] Maemo: Preparation for deploying executable to arbitrary
 location.

Reviewed-by: kh1
---
 .../qt-maemo/maemopackagecontents.cpp         | 19 ++++++++++++++++---
 .../qt-maemo/maemopackagecontents.h           |  2 ++
 .../qt-maemo/maemopackagecreationstep.cpp     |  5 -----
 .../qt-maemo/maemopackagecreationstep.h       |  3 +--
 .../qt-maemo/maemoruncontrol.cpp              |  3 ++-
 5 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp
index ccb8f868f70..9522e7df583 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.cpp
@@ -32,8 +32,10 @@
 #include "maemopackagecreationstep.h"
 
 namespace {
-    const char * const MODIFIED_KEY =
-        "Qt4ProjectManager.BuildStep.MaemoPackage.Modified";
+    const char * const MODIFIED_KEY
+        = "Qt4ProjectManager.BuildStep.MaemoPackage.Modified";
+    const char * const REMOTE_EXE_KEY
+        = "Qt4ProjectManager.BuildStep.MaemoPackage.RemoteExe";
     const char * const LOCAL_FILES_KEY
         = "Qt4ProjectManager.BuildStep.MaemoPackage.LocalFiles";
     const char * const REMOTE_FILES_KEY
@@ -55,7 +57,7 @@ MaemoPackageContents::Deployable MaemoPackageContents::deployableAt(int row) con
     Q_ASSERT(row >= 0 && row < rowCount());
     return row == 0
         ? Deployable(m_packageStep->localExecutableFilePath(),
-                     m_packageStep->remoteExecutableFilePath())
+                     remoteExecutableFilePath())
         : m_deployables.at(row - 1);
 }
 
@@ -112,6 +114,7 @@ QVariantMap MaemoPackageContents::toMap() const
 {
     QVariantMap map;
     map.insert(MODIFIED_KEY, m_modified);
+    map.insert(REMOTE_EXE_KEY, remoteExecutableFilePath());
     QStringList localFiles;
     QStringList remoteFiles;
     foreach (const Deployable &p, m_deployables) {
@@ -126,6 +129,7 @@ QVariantMap MaemoPackageContents::toMap() const
 void MaemoPackageContents::fromMap(const QVariantMap &map)
 {
     m_modified = map.value(MODIFIED_KEY).toBool();
+    m_remoteExecutableFilePath = map.value(REMOTE_EXE_KEY).toString();
     const QStringList localFiles = map.value(LOCAL_FILES_KEY).toStringList();
     const QStringList remoteFiles = map.value(REMOTE_FILES_KEY).toStringList();
     if (localFiles.count() != remoteFiles.count())
@@ -135,5 +139,14 @@ void MaemoPackageContents::fromMap(const QVariantMap &map)
         m_deployables << Deployable(localFiles.at(i), remoteFiles.at(i));
 }
 
+QString MaemoPackageContents::remoteExecutableFilePath() const
+{
+    if (m_remoteExecutableFilePath.isEmpty()) {
+        m_remoteExecutableFilePath = QLatin1String("/usr/local/bin/")
+                                     + m_packageStep->executableFileName();
+    }
+    return m_remoteExecutableFilePath;
+}
+
 } // namespace Qt4ProjectManager
 } // namespace Internal
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h
index 8708d3a8fd2..6e50fd3885a 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecontents.h
@@ -71,6 +71,7 @@ public:
     void removeDeployableAt(int row);
     bool isModified() const { return m_modified; }
     void setUnModified() { m_modified = false; }
+    QString remoteExecutableFilePath() const;
 
 private:
     virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
@@ -86,6 +87,7 @@ private:
     const MaemoPackageCreationStep * const m_packageStep;
     QList<Deployable> m_deployables;
     bool m_modified;
+    mutable QString m_remoteExecutableFilePath;
 };
 
 } // namespace Qt4ProjectManager
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp
index 9916b4d2c0c..47a43892f54 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp
@@ -302,11 +302,6 @@ QString MaemoPackageCreationStep::packageFilePath() const
         % versionString() % QLatin1String("_armel.deb");
 }
 
-QString MaemoPackageCreationStep::remoteExecutableFilePath() const
-{
-    return QLatin1String("/usr/local/bin/") % executableFileName();
-}
-
 QString MaemoPackageCreationStep::versionString() const
 {
     return QLatin1String("_0.1");
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h
index 02f50c1a752..60f2bbce526 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h
@@ -64,8 +64,8 @@ public:
     MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig);
 
     QString packageFilePath() const;
-    QString remoteExecutableFilePath() const;
     QString localExecutableFilePath() const;
+    QString executableFileName() const;
     MaemoPackageContents *packageContents() const { return m_packageContents; }
 
 private:
@@ -83,7 +83,6 @@ private:
     bool runCommand(QProcess &proc, const QString &command);
     const Qt4BuildConfiguration *qt4BuildConfiguration() const;
     const MaemoToolChain *maemoToolChain() const;
-    QString executableFileName() const;
     QString maddeRoot() const;
     QString targetRoot() const;
     QString nativePath(const QFile &file) const;
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp
index aebf4cb5df6..6d9983666e3 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp
@@ -34,6 +34,7 @@
 
 #include "maemoruncontrol.h"
 
+#include "maemopackagecontents.h"
 #include "maemopackagecreationstep.h"
 #include "maemosshthread.h"
 #include "maemorunconfiguration.h"
@@ -200,7 +201,7 @@ QString AbstractMaemoRunControl::packageFilePath() const
 
 QString AbstractMaemoRunControl::executableFilePathOnTarget() const
 {
-    return m_runConfig->packageStep()->remoteExecutableFilePath();
+    return m_runConfig->packageStep()->packageContents()->remoteExecutableFilePath();
 }
 
 bool AbstractMaemoRunControl::isCleaning() const
-- 
GitLab