aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qt4projectmanager/qt-s60/s60createpackageparser.cpp
blob: 0a94564e694a2e41c73d2d5e83eff95dee25993b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/

#include "s60createpackageparser.h"

#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/taskwindow.h>

#include <QtCore/QDebug>

using namespace Qt4ProjectManager::Internal;

S60CreatePackageParser::S60CreatePackageParser(const QString &packageName) :
    m_packageName(packageName),
    m_needPassphrase(false)
{
    setObjectName(QLatin1String("S60CreatePackageParser"));
    m_signSis.setPattern("^(\\s*|\\(\\d+\\)\\s*:\\s*)(error\\s?:\\s?)+(.+)$");
    m_signSis.setMinimal(true);
    m_signSis.setCaseSensitivity(Qt::CaseInsensitive);
}

bool S60CreatePackageParser::parseLine(const QString &line)
{
    if (line.startsWith("Patching: ")) {
        m_patchingLines.append(line.mid(10).trimmed());
        return true;
    }
    if (!m_patchingLines.isEmpty()) {
        emit packageWasPatched(m_packageName, m_patchingLines);

        QString lines = m_patchingLines.join("\n");
        m_patchingLines.clear();
        //: %1 package name, %2 will be replaced by a list of patching lines.
        QString message = tr("The binary package '%1' was patched to be installable after being self-signed.\n%2\n"
                             "Use a developer certificate or any other signing option to prevent "
                             "this patching from happening.").
                arg(m_packageName, lines);
        ProjectExplorer::Task task(ProjectExplorer::Task::Warning, message, QString(), -1,
                                   ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);

        QTextLayout::FormatRange fr;
        fr.start = message.indexOf(lines);
        fr.length = lines.length();
        fr.format.setFontItalic(true);
        task.formats.append(fr);

        emit addTask(task);
    }

    if (m_signSis.indexIn(line) > -1) {
        QString errorMessage(m_signSis.cap(3));
        if (errorMessage.contains(QLatin1String("bad password"))
            || errorMessage.contains(QLatin1String("bad decrypt")))
            m_needPassphrase = true;
        else if (errorMessage.contains(QLatin1String("Cannot open file"))
                 && errorMessage.contains(QLatin1String("smartinstaller")))
            emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error,
                                               tr("Cannot create Smart Installer package "
                                                  "as the Smart Installer's base file is missing. "
                                                  "Please ensure that it is located in the SDK."),
                                               QString(), -1,
                                               ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
        else
            emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, errorMessage, QString(), -1,
                                               ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
        return true;
    }
    return false;
}

void S60CreatePackageParser::stdOutput(const QString &line)
{
    if (!parseLine(line))
        IOutputParser::stdOutput(line);
}

void S60CreatePackageParser::stdError(const QString &line)
{
    if (!parseLine(line))
        IOutputParser::stdError(line);
}

bool S60CreatePackageParser::needPassphrase() const
{
    return m_needPassphrase;
}

/* STDOUT:
make[1]: Entering directory `C:/temp/test/untitled131'
createpackage.bat -g  untitled131_template.pkg RELEASE-armv5
Auto-patching capabilities for self signed package.

Patching package file and relevant binaries...
Patching: Removed dependency to qt.sis (0x2001E61C) to avoid installation issues in case qt.sis is also patched.


NOTE: A patched package may not work as expected due to reduced capabilities and other modifications,
      so it should not be used for any kind of Symbian signing or distribution!
      Use a proper certificate to avoid the need to patch the package.

Processing untitled131_release-armv5.pkg...


and errors like:
(35) : error: Cannot find file : c:/QtSDK/Symbian/SDKs/Symbian3Qt471/epoc32/data/z/resource/apps/untitledSymbian.mif
*/