forked from qt-creator/qt-creator
Maemo: Fix path to exectuable in desktop file when publishing.
This commit is contained in:
@@ -209,15 +209,15 @@ bool MaemoDeployableListModel::isEditable(const QModelIndex &index) const
|
|||||||
&& m_deployables.first().remoteDir.isEmpty();
|
&& m_deployables.first().remoteDir.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaemoDeployableListModel::hasDesktopFile() const
|
QString MaemoDeployableListModel::localDesktopFilePath() const
|
||||||
{
|
{
|
||||||
if (m_projectType == LibraryTemplate)
|
if (m_projectType == LibraryTemplate)
|
||||||
return false;
|
return QString();
|
||||||
foreach (const MaemoDeployable &d, m_deployables) {
|
foreach (const MaemoDeployable &d, m_deployables) {
|
||||||
if (QFileInfo(d.localFilePath).fileName() == m_projectName + QLatin1String(".desktop"))
|
if (QFileInfo(d.localFilePath).fileName() == m_projectName + QLatin1String(".desktop"))
|
||||||
return true;
|
return d.localFilePath;
|
||||||
}
|
}
|
||||||
return false;
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaemoDeployableListModel::addDesktopFile(QString &error)
|
bool MaemoDeployableListModel::addDesktopFile(QString &error)
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ public:
|
|||||||
QString applicationName() const { return m_targetInfo.target; }
|
QString applicationName() const { return m_targetInfo.target; }
|
||||||
bool hasTargetPath() const { return m_hasTargetPath; }
|
bool hasTargetPath() const { return m_hasTargetPath; }
|
||||||
bool canAddDesktopFile() const { return isApplicationProject() && !hasDesktopFile(); }
|
bool canAddDesktopFile() const { return isApplicationProject() && !hasDesktopFile(); }
|
||||||
bool hasDesktopFile() const;
|
QString localDesktopFilePath() const;
|
||||||
|
bool hasDesktopFile() const { return !localDesktopFilePath().isEmpty(); }
|
||||||
bool addDesktopFile(QString &error);
|
bool addDesktopFile(QString &error);
|
||||||
bool canAddIcon() const { return isApplicationProject() && remoteIconFilePath().isEmpty(); }
|
bool canAddIcon() const { return isApplicationProject() && remoteIconFilePath().isEmpty(); }
|
||||||
bool addIcon(const QString &fileName, QString &error);
|
bool addIcon(const QString &fileName, QString &error);
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
#include "maemopublisherfremantlefree.h"
|
#include "maemopublisherfremantlefree.h"
|
||||||
|
|
||||||
|
#include "maemodeployablelistmodel.h"
|
||||||
|
#include "maemodeploystep.h"
|
||||||
#include "maemoglobal.h"
|
#include "maemoglobal.h"
|
||||||
#include "maemopackagecreationstep.h"
|
#include "maemopackagecreationstep.h"
|
||||||
#include "maemopublishingfileselectiondialog.h"
|
#include "maemopublishingfileselectiondialog.h"
|
||||||
@@ -35,6 +37,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/ifile.h>
|
#include <coreplugin/ifile.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
#include <qt4projectmanager/qmakestep.h>
|
#include <qt4projectmanager/qmakestep.h>
|
||||||
#include <qt4projectmanager/qt4buildconfiguration.h>
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||||
|
|
||||||
@@ -125,8 +128,14 @@ void MaemoPublisherFremantleFree::createPackage()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit progressReport(tr("Cleaning up temporary directory ..."));
|
|
||||||
QString error;
|
QString error;
|
||||||
|
if (!updateDesktopFiles(&error)) {
|
||||||
|
finishWithFailure(error,
|
||||||
|
tr("Publishing failed: Could not create package."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit progressReport(tr("Cleaning up temporary directory ..."));
|
||||||
if (!MaemoPackageCreationStep::preparePackagingProcess(m_process,
|
if (!MaemoPackageCreationStep::preparePackagingProcess(m_process,
|
||||||
m_buildConfig, m_tmpProjectDir, &error)) {
|
m_buildConfig, m_tmpProjectDir, &error)) {
|
||||||
finishWithFailure(tr("Error preparing packaging process: %1").arg(error),
|
finishWithFailure(tr("Error preparing packaging process: %1").arg(error),
|
||||||
@@ -474,6 +483,67 @@ void MaemoPublisherFremantleFree::finishWithFailure(const QString &progressMsg,
|
|||||||
setState(Inactive);
|
setState(Inactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MaemoPublisherFremantleFree::updateDesktopFiles(QString *error) const
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
MaemoDeployStep * const deployStep
|
||||||
|
= MaemoGlobal::buildStep<MaemoDeployStep>(m_buildConfig->target()
|
||||||
|
->activeDeployConfiguration());
|
||||||
|
for (int i = 0; i < deployStep->deployables()->modelCount(); ++i) {
|
||||||
|
const MaemoDeployableListModel * const model
|
||||||
|
= deployStep->deployables()->modelAt(i);
|
||||||
|
QString desktopFilePath = model->localDesktopFilePath();
|
||||||
|
if (desktopFilePath.isEmpty())
|
||||||
|
continue;
|
||||||
|
desktopFilePath.replace(model->projectDir(), m_tmpProjectDir);
|
||||||
|
QFile desktopFile(desktopFilePath);
|
||||||
|
const QString executableFilePath = model->remoteExecutableFilePath();
|
||||||
|
if (executableFilePath.isEmpty()) {
|
||||||
|
qDebug("%s: Skipping subproject %s with missing deployment information.",
|
||||||
|
Q_FUNC_INFO, qPrintable(model->proFilePath()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!desktopFile.exists() || !desktopFile.open(QIODevice::ReadWrite)) {
|
||||||
|
success = false;
|
||||||
|
if (error) {
|
||||||
|
*error = tr("Failed to adapt desktop file '%1'.")
|
||||||
|
.arg(desktopFilePath);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QByteArray desktopFileContents = desktopFile.readAll();
|
||||||
|
bool fileNeedsUpdate = addOrReplaceDesktopFileValue(desktopFileContents,
|
||||||
|
"Exec", executableFilePath.toUtf8());
|
||||||
|
if (fileNeedsUpdate) {
|
||||||
|
desktopFile.resize(0);
|
||||||
|
desktopFile.write(desktopFileContents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MaemoPublisherFremantleFree::addOrReplaceDesktopFileValue(QByteArray &fileContent,
|
||||||
|
const QByteArray &key, const QByteArray &newValue) const
|
||||||
|
{
|
||||||
|
const int keyPos = fileContent.indexOf(key + '=');
|
||||||
|
if (keyPos == -1) {
|
||||||
|
if (!fileContent.endsWith('\n'))
|
||||||
|
fileContent += '\n';
|
||||||
|
fileContent += key + '=' + newValue + '\n';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
int nextNewlinePos = fileContent.indexOf('\n', keyPos);
|
||||||
|
if (nextNewlinePos == -1)
|
||||||
|
nextNewlinePos = fileContent.count();
|
||||||
|
const int replacePos = keyPos + key.count() + 1;
|
||||||
|
const int replaceCount = nextNewlinePos - replacePos;
|
||||||
|
const QByteArray &oldValue = fileContent.mid(replacePos, replaceCount);
|
||||||
|
if (oldValue == newValue)
|
||||||
|
return false;
|
||||||
|
fileContent.replace(replacePos, replaceCount, newValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void MaemoPublisherFremantleFree::setState(State newState)
|
void MaemoPublisherFremantleFree::setState(State newState)
|
||||||
{
|
{
|
||||||
if (m_state == newState)
|
if (m_state == newState)
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ private:
|
|||||||
void prepareToSendFile();
|
void prepareToSendFile();
|
||||||
void sendFile();
|
void sendFile();
|
||||||
void finishWithFailure(const QString &progressMsg, const QString &resultMsg);
|
void finishWithFailure(const QString &progressMsg, const QString &resultMsg);
|
||||||
|
bool updateDesktopFiles(QString *error = 0) const;
|
||||||
|
bool addOrReplaceDesktopFileValue(QByteArray &fileContent,
|
||||||
|
const QByteArray &key, const QByteArray &newValue) const;
|
||||||
|
|
||||||
const ProjectExplorer::Project * const m_project;
|
const ProjectExplorer::Project * const m_project;
|
||||||
bool m_doUpload;
|
bool m_doUpload;
|
||||||
|
|||||||
Reference in New Issue
Block a user