forked from qt-creator/qt-creator
Maemo: Replace boolean type by more fine-grained one.
We want to differentiate between "packaging files successfully created" and "packaging files were already there".
This commit is contained in:
@@ -236,7 +236,7 @@ void AbstractQt4MaemoTarget::handleTargetAdded(ProjectExplorer::Target *target)
|
||||
this, SLOT(handleTargetAdded(ProjectExplorer::Target*)));
|
||||
connect(project(), SIGNAL(aboutToRemoveTarget(ProjectExplorer::Target*)),
|
||||
SLOT(handleTargetToBeRemoved(ProjectExplorer::Target*)));
|
||||
if (!createTemplates())
|
||||
if (createTemplates() == ActionFailed)
|
||||
return;
|
||||
initPackagingSettingsFromOtherTarget();
|
||||
handleTargetAddedSpecial();
|
||||
@@ -266,14 +266,14 @@ void AbstractQt4MaemoTarget::handleTargetToBeRemoved(ProjectExplorer::Target *ta
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractQt4MaemoTarget::createTemplates()
|
||||
AbstractQt4MaemoTarget::ActionStatus AbstractQt4MaemoTarget::createTemplates()
|
||||
{
|
||||
QDir projectDir(project()->projectDirectory());
|
||||
if (!projectDir.exists(PackagingDirName)
|
||||
&& !projectDir.mkdir(PackagingDirName)) {
|
||||
raiseError(tr("Error creating Maemo packaging directory '%1'.")
|
||||
.arg(PackagingDirName));
|
||||
return false;
|
||||
return ActionFailed;
|
||||
}
|
||||
|
||||
return createSpecialTemplates();
|
||||
@@ -651,10 +651,10 @@ void AbstractDebBasedQt4MaemoTarget::handleDebianDirContentsChanged()
|
||||
emit debianDirContentsChanged();
|
||||
}
|
||||
|
||||
bool AbstractDebBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
AbstractQt4MaemoTarget::ActionStatus AbstractDebBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
{
|
||||
if (QFileInfo(debianDirPath()).exists())
|
||||
return true;
|
||||
return NoActionRequired;
|
||||
QDir projectDir(project()->projectDirectory());
|
||||
QProcess dh_makeProc;
|
||||
QString error;
|
||||
@@ -662,7 +662,7 @@ bool AbstractDebBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
if (!MaemoPackageCreationStep::preparePackagingProcess(&dh_makeProc, bc,
|
||||
projectDir.path() + QLatin1Char('/') + PackagingDirName, &error)) {
|
||||
raiseError(error);
|
||||
return false;
|
||||
return ActionFailed;
|
||||
}
|
||||
|
||||
const QString dhMakeDebianDir = projectDir.path() + QLatin1Char('/')
|
||||
@@ -675,7 +675,7 @@ bool AbstractDebBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
if (!dh_makeProc.waitForStarted()) {
|
||||
raiseError(tr("Unable to create Debian templates: dh_make failed (%1)")
|
||||
.arg(dh_makeProc.errorString()));
|
||||
return false;
|
||||
return ActionFailed;
|
||||
}
|
||||
dh_makeProc.write("\n"); // Needs user input.
|
||||
dh_makeProc.waitForFinished(-1);
|
||||
@@ -683,14 +683,14 @@ bool AbstractDebBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
|| dh_makeProc.exitCode() != 0) {
|
||||
raiseError(tr("Unable to create debian templates: dh_make failed (%1)")
|
||||
.arg(dh_makeProc.errorString()));
|
||||
return false;
|
||||
return ActionFailed;
|
||||
}
|
||||
|
||||
if (!QFile::rename(dhMakeDebianDir, debianDirPath())) {
|
||||
raiseError(tr("Unable to move new debian directory to '%1'.")
|
||||
.arg(QDir::toNativeSeparators(debianDirPath())));
|
||||
MaemoGlobal::removeRecursively(dhMakeDebianDir, error);
|
||||
return false;
|
||||
return ActionFailed;
|
||||
}
|
||||
|
||||
QDir debianDir(debianDirPath());
|
||||
@@ -704,7 +704,8 @@ bool AbstractDebBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
}
|
||||
}
|
||||
|
||||
return adaptRulesFile() && adaptControlFile();
|
||||
return adaptRulesFile() && adaptControlFile()
|
||||
? ActionSuccessful : ActionFailed;
|
||||
}
|
||||
|
||||
bool AbstractDebBasedQt4MaemoTarget::adaptRulesFile()
|
||||
@@ -881,14 +882,14 @@ bool AbstractRpmBasedQt4MaemoTarget::setShortDescriptionInternal(const QString &
|
||||
return setValueForTag(SummaryTag, description.toUtf8(), 0);
|
||||
}
|
||||
|
||||
bool AbstractRpmBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
AbstractQt4MaemoTarget::ActionStatus AbstractRpmBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
{
|
||||
if (QFileInfo(specFilePath()).exists())
|
||||
return true;
|
||||
return NoActionRequired;
|
||||
QSharedPointer<QFile> specFile
|
||||
= openFile(specFilePath(), QIODevice::WriteOnly, 0);
|
||||
if (!specFile)
|
||||
return false;
|
||||
return ActionFailed;
|
||||
QByteArray initialContent(
|
||||
"Name: %%name%%\n"
|
||||
"Summary: <insert short description here>\n"
|
||||
@@ -929,7 +930,8 @@ bool AbstractRpmBasedQt4MaemoTarget::createSpecialTemplates()
|
||||
"# Add post-uninstall scripts here."
|
||||
);
|
||||
initialContent.replace("%%name%%", project()->displayName().toUtf8());
|
||||
return specFile->write(initialContent) == initialContent.count();
|
||||
return specFile->write(initialContent) == initialContent.count()
|
||||
? ActionSuccessful : ActionFailed;
|
||||
}
|
||||
|
||||
void AbstractRpmBasedQt4MaemoTarget::handleTargetAddedSpecial()
|
||||
|
||||
@@ -85,6 +85,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
enum ActionStatus { NoActionRequired, ActionSuccessful, ActionFailed };
|
||||
|
||||
void initDeviceConfigurationsModel();
|
||||
void raiseError(const QString &reason);
|
||||
QSharedPointer<QFile> openFile(const QString &filePath,
|
||||
@@ -101,12 +103,13 @@ private:
|
||||
QString *error = 0)=0;
|
||||
virtual bool setPackageNameInternal(const QString &packageName)=0;
|
||||
virtual bool setShortDescriptionInternal(const QString &description)=0;
|
||||
virtual bool createSpecialTemplates()=0;
|
||||
virtual ActionStatus createSpecialTemplates()=0;
|
||||
virtual void handleTargetAddedSpecial()=0;
|
||||
virtual bool targetCanBeRemoved() const=0;
|
||||
virtual void removeTarget()=0;
|
||||
virtual QStringList packagingFiles() const=0;
|
||||
|
||||
bool createTemplates();
|
||||
ActionStatus createTemplates();
|
||||
bool initPackagingSettingsFromOtherTarget();
|
||||
virtual bool initAdditionalPackagingSettingsFromOtherTarget()=0;
|
||||
|
||||
@@ -152,11 +155,12 @@ private:
|
||||
virtual bool setPackageNameInternal(const QString &packageName);
|
||||
virtual bool setShortDescriptionInternal(const QString &description);
|
||||
|
||||
virtual bool createSpecialTemplates();
|
||||
virtual ActionStatus createSpecialTemplates();
|
||||
virtual void handleTargetAddedSpecial();
|
||||
virtual bool targetCanBeRemoved() const;
|
||||
virtual void removeTarget();
|
||||
virtual bool initAdditionalPackagingSettingsFromOtherTarget();
|
||||
virtual QStringList packagingFiles() const { return QStringList(debianDirPath()); }
|
||||
|
||||
QString changeLogFilePath() const;
|
||||
QString controlFilePath() const;
|
||||
@@ -200,11 +204,12 @@ private:
|
||||
QString *error = 0);
|
||||
virtual bool setPackageNameInternal(const QString &packageName);
|
||||
virtual bool setShortDescriptionInternal(const QString &description);
|
||||
virtual bool createSpecialTemplates();
|
||||
virtual ActionStatus createSpecialTemplates();
|
||||
virtual void handleTargetAddedSpecial();
|
||||
virtual bool targetCanBeRemoved() const;
|
||||
virtual void removeTarget();
|
||||
virtual bool initAdditionalPackagingSettingsFromOtherTarget();
|
||||
virtual QStringList packagingFiles() const { return QStringList(specFilePath()); }
|
||||
|
||||
virtual QString specFileName() const=0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user