Commit 057591e0 authored by Pawel Polanski's avatar Pawel Polanski
Browse files

If capabilities inside pro files do not match the dev cert an error is generated (SymbianOS)

parent 5ed78fb6
......@@ -132,6 +132,22 @@ S60CertificateInfo::CertificateState S60CertificateInfo::validateCertificate()
return result;
}
bool S60CertificateInfo::compareCapabilities(const QStringList &givenCaps, QStringList &unsupportedCaps) const
{
if (!m_certificate->isValid())
return false;
unsupportedCaps.clear();
if (capabilitiesSupported() == NoInformation)
return true;
QStringList capabilities(createCapabilityList(capabilitiesSupported()));
foreach (QString capability, givenCaps) {
if (!capabilities.contains(capability, Qt::CaseInsensitive))
unsupportedCaps << capability;
}
return true;
}
QString S60CertificateInfo::errorString() const
{
return m_errorString.isEmpty()?m_certificate->errorString():m_errorString;
......
......@@ -85,6 +85,8 @@ public:
QString errorString() const;
bool isDeveloperCertificate() const;
bool compareCapabilities(const QStringList &givenCaps, QStringList &unsupportedCaps) const;
private:
S60SymbianCertificate *m_certificate;
QString m_filePath;
......
......@@ -180,8 +180,12 @@ bool S60CreatePackageStep::init()
QList<Qt4ProFileNode *> nodes = pro->leafProFiles();
m_workingDirectories.clear();
foreach (Qt4ProFileNode *node, nodes)
QStringList projectCapabilities;
foreach (Qt4ProFileNode *node, nodes) {
projectCapabilities += node->symbianCapabilities();
m_workingDirectories << node->buildDir();
}
projectCapabilities.removeDuplicates();
m_makeCmd = qt4BuildConfiguration()->makeCommand();
if (!QFileInfo(m_makeCmd).isAbsolute()) {
......@@ -194,7 +198,7 @@ bool S60CreatePackageStep::init()
m_makeCmd = tmp;
}
if (signingMode() == SignCustom && !validateCustomSigningResources())
if (signingMode() == SignCustom && !validateCustomSigningResources(projectCapabilities))
return false;
m_environment = qt4BuildConfiguration()->environment();
......@@ -443,7 +447,7 @@ bool S60CreatePackageStep::createOnePackage()
return true;
}
bool S60CreatePackageStep::validateCustomSigningResources()
bool S60CreatePackageStep::validateCustomSigningResources(const QStringList &capabilitiesInPro)
{
Q_ASSERT(signingMode() == SignCustom);
......@@ -463,37 +467,50 @@ bool S60CreatePackageStep::validateCustomSigningResources()
"Please define certificate file in the project's options.").arg(customKeyPath());
if (!errorString.isEmpty()) {
emit addOutput(errorString, BuildStep::ErrorMessageOutput);
emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error,
errorString,
QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
reportPackageStepIssue(errorString, true);
return false;
}
QScopedPointer<S60CertificateInfo> certInfoPtr(new S60CertificateInfo(customSignaturePath()));
S60CertificateInfo::CertificateState certState = certInfoPtr.data()->validateCertificate();
switch (certState) {
case S60CertificateInfo::CertificateError:
emit addOutput(certInfoPtr.data()->errorString(), BuildStep::ErrorMessageOutput);
emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error,
certInfoPtr.data()->errorString(),
QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
reportPackageStepIssue(certInfoPtr.data()->errorString(), true);
return false;
case S60CertificateInfo::CertificateWarning:
emit addOutput(certInfoPtr.data()->errorString(), BuildStep::MessageOutput);
emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Warning,
certInfoPtr.data()->errorString(),
QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
reportPackageStepIssue(certInfoPtr.data()->errorString(), false);
break;
default:
break;
}
QStringList unsupportedCaps;
if (certInfoPtr.data()->compareCapabilities(capabilitiesInPro, unsupportedCaps)) {
if (!unsupportedCaps.isEmpty()) {
QString message = tr("The created package will not install on a "
"device as some of the defined capabilities "
"are not supported by the certificate: %1")
.arg(unsupportedCaps.join(" "));
reportPackageStepIssue(message, true);
return false;
}
} else
reportPackageStepIssue(certInfoPtr.data()->errorString(), false);
return true;
}
void S60CreatePackageStep::reportPackageStepIssue(const QString &message, bool isError )
{
emit addOutput(message, isError?
BuildStep::ErrorMessageOutput:
BuildStep::MessageOutput);
emit addTask(ProjectExplorer::Task(isError?
ProjectExplorer::Task::Error:
ProjectExplorer::Task::Warning,
message,
QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
void S60CreatePackageStep::packageWarningDialogDone()
{
......
......@@ -136,9 +136,10 @@ private:
void stdOutput(const QString &line);
void stdError(const QString &line);
void reportPackageStepIssue(const QString &message, bool isError );
void setupProcess();
bool createOnePackage();
bool validateCustomSigningResources();
bool validateCustomSigningResources(const QStringList &capabilitiesInPro);
QString generateKeyId(const QString &keyPath) const;
QString loadPassphraseForKey(const QString &keyId);
......
......@@ -1256,6 +1256,41 @@ QString Qt4ProFileNode::makefile() const
return m_varValues[Makefile].first();
}
QStringList Qt4ProFileNode::symbianCapabilities() const
{
QStringList lowerCasedResult;
QStringList all;
all << "LocalServices" << "UserEnvironment" << "NetworkServices"
<< "ReadUserData" << "WriteUserData" << "Location" << "SwEvent"
<< "SurroundingsDD" << "ProtServ" << "PowerMgmt" << "ReadDeviceData"
<< "WriteDeviceData" << "TrustedUI" << "NetworkControl"
<< "MultimediaDD"<< "CommDD" << "DiskAdmin" << "AllFiles" << "DRM" << "TCB";
foreach (const QString &cap, m_varValues[SymbianCapabilities]) {
QString capability = cap.toLower();
if (capability.startsWith("-")) {
lowerCasedResult.removeAll(capability.mid(1));
} else if (capability == "all") {
foreach (const QString &a, all)
if (!lowerCasedResult.contains(a, Qt::CaseInsensitive))
lowerCasedResult << a.toLower();
} else {
lowerCasedResult << cap;
}
}
QStringList result; //let's make the result pretty
int index;
foreach (QString lowerCase, lowerCasedResult) {
index = all.indexOf(lowerCase);
if (index != -1)
result << all.at(index);
else
result << lowerCase; //strange capability!
}
return result;
}
/*!
\class Qt4ProFileNode
Implements abstract ProjectNode class
......@@ -1706,9 +1741,15 @@ void Qt4ProFileNode::applyEvaluate(bool parseResult, bool async)
newVarValues[QmlImportPathVar] = m_readerExact->absolutePathValues(
QLatin1String("QML_IMPORT_PATH"), m_projectDir);
newVarValues[Makefile] = m_readerExact->values("MAKEFILE");
// We use the cumulative parse so that we get the capabilities for symbian even if
// a different target is selected and the capabilities are set in a symbian scope
newVarValues[SymbianCapabilities] = m_readerCumulative->values("TARGET.CAPABILITY");
if (m_varValues != newVarValues) {
m_varValues = newVarValues;
foreach (NodesWatcher *watcher, watchers())
if (Qt4NodesWatcher *qt4Watcher = qobject_cast<Qt4NodesWatcher*>(watcher))
emit qt4Watcher->variablesChanged(this, m_varValues, newVarValues);
......
......@@ -96,7 +96,8 @@ enum Qt4Variable {
LibDirectoriesVar,
ConfigVar,
QmlImportPathVar,
Makefile
Makefile,
SymbianCapabilities
};
class Qt4PriFileNode;
......@@ -294,6 +295,7 @@ public:
InstallsList installsList() const;
QString makefile() const;
QStringList symbianCapabilities() const;
void update();
void scheduleUpdate();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment