OSDN Git Service

57f76790637378cbe24c565a92d69eb7bfb60d7c
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-s60 / s60createpackageparser.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #include "s60createpackageparser.h"
35
36 #include <projectexplorer/projectexplorerconstants.h>
37 #include <projectexplorer/taskwindow.h>
38
39 #include <QtCore/QDebug>
40
41 using namespace Qt4ProjectManager::Internal;
42
43 S60CreatePackageParser::S60CreatePackageParser(const QString &packageName) :
44     m_packageName(packageName),
45     m_needPassphrase(false)
46 {
47     setObjectName(QLatin1String("S60CreatePackageParser"));
48     m_signSis.setPattern("^(\\s*|\\(\\d+\\)\\s*:\\s*)(error\\s?:\\s?)+(.+)$");
49     m_signSis.setMinimal(true);
50     m_signSis.setCaseSensitivity(Qt::CaseInsensitive);
51 }
52
53 bool S60CreatePackageParser::parseLine(const QString &line)
54 {
55     if (line.startsWith("Patching: ")) {
56         m_patchingLines.append(line.mid(10).trimmed());
57         return true;
58     }
59     if (!m_patchingLines.isEmpty()) {
60         emit packageWasPatched(m_packageName, m_patchingLines);
61
62         QString lines = m_patchingLines.join("\n");
63         m_patchingLines.clear();
64         //: %1 package name, %2 will be replaced by a list of patching lines.
65         QString message = tr("The binary package '%1' was patched to be installable after being self-signed.\n%2\n"
66                              "Use a developer certificate or any other signing option to prevent "
67                              "this patching from happening.").
68                 arg(m_packageName, lines);
69         ProjectExplorer::Task task(ProjectExplorer::Task::Warning, message, QString(), -1,
70                                    ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
71
72         QTextLayout::FormatRange fr;
73         fr.start = message.indexOf(lines);
74         fr.length = lines.length();
75         fr.format.setFontItalic(true);
76         task.formats.append(fr);
77
78         emit addTask(task);
79     }
80
81     if (m_signSis.indexIn(line) > -1) {
82         QString errorMessage(m_signSis.cap(3));
83         if (errorMessage.contains(QLatin1String("bad password"))
84             || errorMessage.contains(QLatin1String("bad decrypt")))
85             m_needPassphrase = true;
86         else if (errorMessage.contains(QLatin1String("Cannot open file"))
87                  && errorMessage.contains(QLatin1String("smartinstaller")))
88             emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error,
89                                                tr("Cannot create Smart Installer package "
90                                                   "as the Smart Installer's base file is missing. "
91                                                   "Please ensure that it is located in the SDK."),
92                                                QString(), -1,
93                                                ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
94         else
95             emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, errorMessage, QString(), -1,
96                                                ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
97         return true;
98     }
99     return false;
100 }
101
102 void S60CreatePackageParser::stdOutput(const QString &line)
103 {
104     if (!parseLine(line))
105         IOutputParser::stdOutput(line);
106 }
107
108 void S60CreatePackageParser::stdError(const QString &line)
109 {
110     if (!parseLine(line))
111         IOutputParser::stdError(line);
112 }
113
114 bool S60CreatePackageParser::needPassphrase() const
115 {
116     return m_needPassphrase;
117 }
118
119 /* STDOUT:
120 make[1]: Entering directory `C:/temp/test/untitled131'
121 createpackage.bat -g  untitled131_template.pkg RELEASE-armv5
122 Auto-patching capabilities for self signed package.
123
124 Patching package file and relevant binaries...
125 Patching: Removed dependency to qt.sis (0x2001E61C) to avoid installation issues in case qt.sis is also patched.
126
127
128 NOTE: A patched package may not work as expected due to reduced capabilities and other modifications,
129       so it should not be used for any kind of Symbian signing or distribution!
130       Use a proper certificate to avoid the need to patch the package.
131
132 Processing untitled131_release-armv5.pkg...
133
134
135 and errors like:
136 (35) : error: Cannot find file : c:/QtSDK/Symbian/SDKs/Symbian3Qt471/epoc32/data/z/resource/apps/untitledSymbian.mif
137 */