forked from qt-creator/qt-creator
Maemo: Check some meta information before publishing.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "maemoglobal.h"
|
||||
#include "maemopackagecreationstep.h"
|
||||
#include "maemopublishingfileselectiondialog.h"
|
||||
#include "maemotemplatesmanager.h"
|
||||
#include "maemotoolchain.h"
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
@@ -102,8 +103,17 @@ void MaemoPublisherFremantleFree::cancel()
|
||||
|
||||
void MaemoPublisherFremantleFree::createPackage()
|
||||
{
|
||||
// Step 1: Copy project directory.
|
||||
setState(CopyingProjectDir);
|
||||
|
||||
const QStringList &problems = findProblems();
|
||||
if (!problems.isEmpty()) {
|
||||
const QLatin1String separator("\n- ");
|
||||
finishWithFailure(tr("The project is missing some information "
|
||||
"important to publishing:") + separator + problems.join(separator),
|
||||
tr("Publishing failed: Missing project information."));
|
||||
return;
|
||||
}
|
||||
|
||||
m_tmpProjectDir = tmpDirContainer() + QLatin1Char('/')
|
||||
+ m_project->displayName();
|
||||
if (QFileInfo(tmpDirContainer()).exists()) {
|
||||
@@ -544,6 +554,25 @@ bool MaemoPublisherFremantleFree::addOrReplaceDesktopFileValue(QByteArray &fileC
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList MaemoPublisherFremantleFree::findProblems() const
|
||||
{
|
||||
QStringList problems;
|
||||
const MaemoTemplatesManager * const templatesManager
|
||||
= MaemoTemplatesManager::instance();
|
||||
const QString &description = templatesManager
|
||||
->controlFileFieldValue(m_project, QLatin1String("Description"));
|
||||
if (description.trimmed().isEmpty()) {
|
||||
problems << tr("The package description is empty.");
|
||||
} else if (description.contains(QLatin1String("insert up to"))) {
|
||||
problems << tr("The package description is '%1', which is probably "
|
||||
"not what you want.").arg(description);
|
||||
}
|
||||
if (templatesManager->controlFileFieldValue(m_project,
|
||||
QLatin1String("XB-Maemo-Icon-26")).trimmed().isEmpty())
|
||||
problems << tr("You have not set an icon for the package manager.");
|
||||
return problems;
|
||||
}
|
||||
|
||||
void MaemoPublisherFremantleFree::setState(State newState)
|
||||
{
|
||||
if (m_state == newState)
|
||||
|
||||
@@ -99,6 +99,7 @@ private:
|
||||
bool updateDesktopFiles(QString *error = 0) const;
|
||||
bool addOrReplaceDesktopFileValue(QByteArray &fileContent,
|
||||
const QByteArray &key, const QByteArray &newValue) const;
|
||||
QStringList findProblems() const;
|
||||
|
||||
const ProjectExplorer::Project * const m_project;
|
||||
bool m_doUpload;
|
||||
|
||||
@@ -588,6 +588,24 @@ QString MaemoTemplatesManager::controlFilePath(const Project *project) const
|
||||
return debianDirPath(project) + QLatin1String("/control");
|
||||
}
|
||||
|
||||
QString MaemoTemplatesManager::controlFileFieldValue(const Project *project,
|
||||
const QString &key) const
|
||||
{
|
||||
QFile controlFile(controlFilePath(project));
|
||||
if (!controlFile.open(QIODevice::ReadOnly))
|
||||
return QString();
|
||||
const QByteArray &contents = controlFile.readAll();
|
||||
const int keyPos = contents.indexOf(key.toUtf8() + ':');
|
||||
if (keyPos == -1)
|
||||
return QString();
|
||||
const int valueStartPos = keyPos + key.length() + 1;
|
||||
int valueEndPos = contents.indexOf('\n', keyPos);
|
||||
if (valueEndPos == -1)
|
||||
valueEndPos = contents.count();
|
||||
return QString::fromUtf8(contents.mid(valueStartPos,
|
||||
valueEndPos - valueStartPos));
|
||||
}
|
||||
|
||||
void MaemoTemplatesManager::raiseError(const QString &reason)
|
||||
{
|
||||
QMessageBox::critical(0, tr("Error creating Maemo templates"), reason);
|
||||
|
||||
@@ -71,6 +71,9 @@ public:
|
||||
bool setPackageManagerIcon(const ProjectExplorer::Project *project,
|
||||
const QString &iconFilePath, QString *error) const;
|
||||
|
||||
QString controlFileFieldValue(const ProjectExplorer::Project *project,
|
||||
const QString &key) const;
|
||||
|
||||
signals:
|
||||
void debianDirContentsChanged(const ProjectExplorer::Project *project);
|
||||
void changeLogChanged(const ProjectExplorer::Project *project);
|
||||
|
||||
Reference in New Issue
Block a user