summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Molkentin <daniel.molkentin@nokia.com>2011-09-08 16:04:27 +0200
committerEike Ziller <eike.ziller@nokia.com>2011-09-19 13:51:53 +0200
commit793031c7ba64ca7ba67c6a555bbab49ae2ec0b85 (patch)
treead42dc2f6c5f4cb695055999652a6b96dd311940
parentac2bc6f39ad51b8936679183066cbe2a43972b88 (diff)
downloadqt-creator-793031c7ba64ca7ba67c6a555bbab49ae2ec0b85.tar.gz
Make Qt Installer Framework Update Notifier part of QtCreator.
Always compile but never run it unless UPDATEINFO_DISABLE is being set to 'false' via qmake or environment. Change-Id: Ie53fb2ea99bfebac1b6f416939554f25a5e481a7 Reviewed-on: http://codereview.qt-project.org/4483 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com> Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
-rw-r--r--src/plugins/plugins.pro6
-rw-r--r--src/plugins/updateinfo/UpdateInfo.pluginspec.in19
-rw-r--r--src/plugins/updateinfo/images/update_available_logo.pngbin0 -> 2447 bytes
-rw-r--r--src/plugins/updateinfo/updateinfo.pro21
-rw-r--r--src/plugins/updateinfo/updateinfo.qrc5
-rw-r--r--src/plugins/updateinfo/updateinfo_dependencies.pri2
-rw-r--r--src/plugins/updateinfo/updateinfobutton.cpp79
-rw-r--r--src/plugins/updateinfo/updateinfobutton.h54
-rw-r--r--src/plugins/updateinfo/updateinfoplugin.cpp223
-rw-r--r--src/plugins/updateinfo/updateinfoplugin.h73
10 files changed, 481 insertions, 1 deletions
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 0981fd9b7a..bc5ac35c15 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -45,7 +45,8 @@ SUBDIRS = plugin_coreplugin \
plugin_qmlprofiler \
plugin_remotelinux \
plugin_qttest \
- plugin_valgrind
+ plugin_valgrind \
+ plugin_updateinfo
linux-* {
SUBDIRS += debugger/ptracepreload.pro
@@ -80,6 +81,9 @@ include (debugger/lldb/guest/qtcreator-lldb.pri)
plugin_coreplugin.subdir = coreplugin
+plugin_updateinfo.subdir = updateinfo
+plugin_updateinfo.depends = plugin_coreplugin
+
plugin_welcome.subdir = welcome
plugin_welcome.depends = plugin_coreplugin
plugin_welcome.depends += plugin_projectexplorer
diff --git a/src/plugins/updateinfo/UpdateInfo.pluginspec.in b/src/plugins/updateinfo/UpdateInfo.pluginspec.in
new file mode 100644
index 0000000000..89ce6f0c77
--- /dev/null
+++ b/src/plugins/updateinfo/UpdateInfo.pluginspec.in
@@ -0,0 +1,19 @@
+<plugin name=\"UpdateInfo\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\" experimental=\"$$UPDATEINFO_DISABLE\">
+ <vendor>Nokia Corporation</vendor>
+ <copyright>(C) 2011 Nokia Corporation</copyright>
+ <license>
+Commercial Usage
+
+Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
+
+GNU Lesser General Public License Usage
+
+Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. 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.
+ </license>
+ <category>Qt Creator</category>
+ <description>Displays Update-Infos for Qt Installer Framework-based Updaters.</description>
+ <url>http://qt.nokia.com</url>
+ <dependencyList>
+ <dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
+ </dependencyList>
+</plugin>
diff --git a/src/plugins/updateinfo/images/update_available_logo.png b/src/plugins/updateinfo/images/update_available_logo.png
new file mode 100644
index 0000000000..df59e15f9b
--- /dev/null
+++ b/src/plugins/updateinfo/images/update_available_logo.png
Binary files differ
diff --git a/src/plugins/updateinfo/updateinfo.pro b/src/plugins/updateinfo/updateinfo.pro
new file mode 100644
index 0000000000..cefdfa11b4
--- /dev/null
+++ b/src/plugins/updateinfo/updateinfo.pro
@@ -0,0 +1,21 @@
+TARGET = UpdateInfo
+TEMPLATE = lib
+QT += network xml
+
+HEADERS += updateinfoplugin.h \
+ updateinfo_global.h \
+ updateinfobutton.h
+SOURCES += updateinfoplugin.cpp \
+ updateinfobutton.cpp
+FORMS +=
+RESOURCES += updateinfo.qrc
+
+PROVIDER = Nokia
+
+isEmpty(UPDATEINFO_DISABLE):UPDATEINFO_DISABLE=$$(UPDATEINFO_DISABLE)
+isEmpty(UPDATEINFO_DISABLE):UPDATEINFO_DISABLE = "true"
+else:UPDATEINFO_DISABLE = "false"
+
+include(../../qtcreatorplugin.pri)
+
+include(updateinfo_dependencies.pri)
diff --git a/src/plugins/updateinfo/updateinfo.qrc b/src/plugins/updateinfo/updateinfo.qrc
new file mode 100644
index 0000000000..6db2c80c30
--- /dev/null
+++ b/src/plugins/updateinfo/updateinfo.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/updateinfo">
+ <file>images/update_available_logo.png</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/updateinfo/updateinfo_dependencies.pri b/src/plugins/updateinfo/updateinfo_dependencies.pri
new file mode 100644
index 0000000000..09a760d031
--- /dev/null
+++ b/src/plugins/updateinfo/updateinfo_dependencies.pri
@@ -0,0 +1,2 @@
+include(../../libs/extensionsystem/extensionsystem.pri)
+include(../../plugins/coreplugin/coreplugin.pri)
diff --git a/src/plugins/updateinfo/updateinfobutton.cpp b/src/plugins/updateinfo/updateinfobutton.cpp
new file mode 100644
index 0000000000..df5357da82
--- /dev/null
+++ b/src/plugins/updateinfo/updateinfobutton.cpp
@@ -0,0 +1,79 @@
+/**************************************************************************
+**
+** 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 info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "updateinfobutton.h"
+
+#include <coreplugin/coreconstants.h>
+#include <utils/stylehelper.h>
+
+#include <QtGui/QIcon>
+#include <QtGui/QPainter>
+
+
+namespace UpdateInfo {
+namespace Internal {
+
+UpdateInfoButton::UpdateInfoButton(QWidget *parent) :
+ QAbstractButton(parent)
+{
+ setIcon(QIcon(QLatin1String(":/updateinfo/images/update_available_logo.png")));
+}
+
+//copied from fancytoolbutton
+QSize UpdateInfoButton::minimumSizeHint() const
+{
+ return QSize(8, 8);
+}
+
+//copied from fancytoolbutton
+QSize UpdateInfoButton::sizeHint() const
+{
+ return iconSize().expandedTo(QSize(64, 38));
+}
+
+//copied from fancytoolbutton and removed unused things
+void UpdateInfoButton::paintEvent(QPaintEvent *event)
+{
+ Q_UNUSED(event)
+ QPainter painter(this);
+
+ QRect iconRect(0, 0, Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE);
+
+
+ iconRect.moveCenter(rect().center());
+ Utils::StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, isEnabled() ? QIcon::Normal : QIcon::Disabled);
+
+}
+
+
+} //Internal
+} //namespace UpdateInfo
diff --git a/src/plugins/updateinfo/updateinfobutton.h b/src/plugins/updateinfo/updateinfobutton.h
new file mode 100644
index 0000000000..39548a4c92
--- /dev/null
+++ b/src/plugins/updateinfo/updateinfobutton.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+**
+** 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 info@qt.nokia.com.
+**
+**************************************************************************/
+
+#ifndef UPDATEINFOBUTTON_H
+#define UPDATEINFOBUTTON_H
+
+#include <QtGui/QAbstractButton>
+
+namespace UpdateInfo {
+namespace Internal {
+
+class UpdateInfoButton : public QAbstractButton
+{
+ Q_OBJECT
+public:
+ explicit UpdateInfoButton(QWidget *parent = 0);
+ void paintEvent(QPaintEvent *event);
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+};
+
+} //namespace Internal
+} //namespace UpdateInfo
+
+#endif // UPDATEINFOBUTTON_H
diff --git a/src/plugins/updateinfo/updateinfoplugin.cpp b/src/plugins/updateinfo/updateinfoplugin.cpp
new file mode 100644
index 0000000000..b233dc9f6a
--- /dev/null
+++ b/src/plugins/updateinfo/updateinfoplugin.cpp
@@ -0,0 +1,223 @@
+/**************************************************************************
+**
+** 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 info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "updateinfoplugin.h"
+#include "updateinfobutton.h"
+
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/modemanager.h>
+#include <coreplugin/progressmanager/progressmanager.h>
+#include <coreplugin/progressmanager/futureprogress.h>
+
+#include <qtconcurrentrun.h>
+
+#include <QtCore/QtPlugin>
+#include <QtCore/QProcess>
+#include <QtCore/QTimer>
+#include <QtCore/QTimerEvent>
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+#include <QtCore/QThread>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QProcess>
+#include <QtXml/QDomDocument>
+#include <QtGui/QMessageBox>
+#include <QtGui/QMenu>
+#include <QtCore/QFutureWatcher>
+
+namespace {
+ static const quint32 OneMinute = 60000;
+}
+
+namespace UpdateInfo {
+namespace Internal {
+
+class UpdateInfoPluginPrivate
+{
+public:
+ UpdateInfoPluginPrivate()
+ : startUpdaterAction(0),
+ currentTimerId(0),
+ progressUpdateInfoButton(0),
+ checkUpdateInfoWatcher(0)
+ {}
+ ~UpdateInfoPluginPrivate()
+ {
+ }
+
+ QAction *startUpdaterAction;
+ QString updaterProgram;
+ QString updaterCheckOnlyArgument;
+ QString updaterRunUiArgument;
+ int currentTimerId;
+ QFuture<QDomDocument> lastCheckUpdateInfoTask;
+ QPointer<Core::FutureProgress> updateInfoProgress;
+ UpdateInfoButton *progressUpdateInfoButton;
+ QFutureWatcher<QDomDocument> *checkUpdateInfoWatcher;
+};
+
+
+UpdateInfoPlugin::UpdateInfoPlugin()
+ : d(new UpdateInfoPluginPrivate)
+{
+}
+
+UpdateInfoPlugin::~UpdateInfoPlugin()
+{
+ delete d;
+}
+
+void UpdateInfoPlugin::startCheckTimer(uint milliseconds)
+{
+ if (d->currentTimerId != 0) {
+ stopCurrentCheckTimer();
+ }
+ d->currentTimerId = startTimer(milliseconds);
+}
+
+void UpdateInfoPlugin::stopCurrentCheckTimer()
+{
+ killTimer(d->currentTimerId);
+}
+
+
+/*! Initializes the plugin. Returns true on success.
+ Plugins want to register objects with the plugin manager here.
+
+ \a error_message can be used to pass an error message to the plugin system,
+ if there was any.
+*/
+bool UpdateInfoPlugin::initialize(const QStringList & /* arguments */, QString * /* errorMessage */)
+{
+ d->checkUpdateInfoWatcher = new QFutureWatcher<QDomDocument>(this);
+ connect(d->checkUpdateInfoWatcher, SIGNAL(finished()), this, SLOT(reactOnUpdaterOutput()));
+
+ QSettings *settings = Core::ICore::instance()->settings();
+ d->updaterProgram = settings->value(QLatin1String("Updater/Application")).toString();
+ d->updaterCheckOnlyArgument = settings->value(QLatin1String("Updater/CheckOnlyArgument")).toString();
+ d->updaterRunUiArgument = settings->value(QLatin1String("Updater/RunUiArgument")).toString();
+
+ Core::ICore* const core = Core::ICore::instance();
+ Core::ActionManager* const actionManager = core->actionManager();
+ Core::ActionContainer* const helpActionContainer = actionManager->actionContainer(Core::Constants::M_HELP);
+
+ helpActionContainer->menu()->addAction(tr("Start Updater"), this, SLOT(startUpdaterUiApplication()));
+
+ //wait some time before we want to have the first check
+ if (!d->updaterProgram.isEmpty() && QFile::exists(d->updaterProgram)) {
+ startCheckTimer(OneMinute / 10);
+ }
+ return true;
+}
+
+QDomDocument UpdateInfoPlugin::checkForUpdates()
+{
+ if (QThread::currentThread() == QCoreApplication::instance()->thread()) {
+ qWarning() << Q_FUNC_INFO << " Was not designed to run in main/gui thread -> it is using updaterProcess.waitForFinished()";
+ }
+
+ //starting
+ QProcess updaterProcess;
+
+ updaterProcess.start(d->updaterProgram,
+ QStringList() << d->updaterCheckOnlyArgument);
+ updaterProcess.waitForFinished();
+
+ //process return value
+ if (updaterProcess.exitStatus() == QProcess::CrashExit) {
+ qWarning() << "Get update info application crashed.";
+ //return; //maybe there is some output
+ }
+ QString updaterOutput = updaterProcess.readAllStandardOutput();
+ QDomDocument updatesDomDocument;
+ updatesDomDocument.setContent(updaterOutput);
+
+ return updatesDomDocument;
+}
+
+
+void UpdateInfoPlugin::reactOnUpdaterOutput()
+{
+ QDomDocument updatesDomDocument = d->checkUpdateInfoWatcher->result();
+
+ if (updatesDomDocument.isNull() ||
+ !updatesDomDocument.firstChildElement().hasChildNodes())
+ { // no updates are available
+ startCheckTimer(60 * OneMinute);
+ } else {
+ //added the current almost finished task to the progressmanager
+ d->updateInfoProgress = Core::ICore::instance()->progressManager()->addTask(
+ d->lastCheckUpdateInfoTask, tr("Update"), QLatin1String("Update.GetInfo"), Core::ProgressManager::KeepOnFinish);
+
+ d->updateInfoProgress->setKeepOnFinish(Core::FutureProgress::KeepOnFinish);
+
+ d->progressUpdateInfoButton = new UpdateInfoButton();
+ //the old widget is deleted inside this function
+ //and the current widget becomes a child of updateInfoProgress
+ d->updateInfoProgress->setWidget(d->progressUpdateInfoButton);
+
+ //d->progressUpdateInfoButton->setText(tr("Update")); //we have this information over the progressbar
+ connect(d->progressUpdateInfoButton, SIGNAL(released()),
+ this, SLOT(startUpdaterUiApplication()));
+ }
+}
+
+void UpdateInfoPlugin::startUpdaterUiApplication()
+{
+ QProcess::startDetached(d->updaterProgram, QStringList() << d->updaterRunUiArgument);
+ if (!d->updateInfoProgress.isNull()) {
+ d->updateInfoProgress->setKeepOnFinish(Core::FutureProgress::HideOnFinish); //this is fading out the last updateinfo
+ }
+ startCheckTimer(OneMinute);
+}
+
+void UpdateInfoPlugin::timerEvent(QTimerEvent *event)
+{
+ if (event->timerId() == d->currentTimerId && !d->lastCheckUpdateInfoTask.isRunning())
+ {
+ stopCurrentCheckTimer();
+ d->lastCheckUpdateInfoTask = QtConcurrent::run(this, &UpdateInfoPlugin::checkForUpdates);
+ d->checkUpdateInfoWatcher->setFuture(d->lastCheckUpdateInfoTask);
+ }
+}
+
+void UpdateInfoPlugin::extensionsInitialized()
+{
+}
+
+} //namespace Internal
+} //namespace UpdateInfo
+
+Q_EXPORT_PLUGIN(UpdateInfo::Internal::UpdateInfoPlugin)
diff --git a/src/plugins/updateinfo/updateinfoplugin.h b/src/plugins/updateinfo/updateinfoplugin.h
new file mode 100644
index 0000000000..27a78d16a1
--- /dev/null
+++ b/src/plugins/updateinfo/updateinfoplugin.h
@@ -0,0 +1,73 @@
+/**************************************************************************
+**
+** 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 info@qt.nokia.com.
+**
+**************************************************************************/
+
+#ifndef UPDATEINFOPLUGIN_H
+#define UPDATEINFOPLUGIN_H
+
+#include <extensionsystem/iplugin.h>
+
+#include <QtXml/QDomDocument>
+
+namespace UpdateInfo {
+namespace Internal {
+
+class UpdateInfoPluginPrivate;
+
+class UpdateInfoPlugin : public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+public:
+ UpdateInfoPlugin();
+ virtual ~UpdateInfoPlugin();
+
+ virtual bool initialize(const QStringList &arguments, QString *errorMessage);
+
+ virtual void extensionsInitialized();
+
+private slots:
+ void startUpdaterUiApplication();
+ void reactOnUpdaterOutput();
+
+protected:
+ void timerEvent(QTimerEvent *event);
+
+private:
+ void startCheckTimer(uint milliseconds);
+ void stopCurrentCheckTimer();
+ QDomDocument checkForUpdates();
+ UpdateInfoPluginPrivate *d;
+};
+
+} // namespace Internal
+} // namespace UpdateInfo
+
+#endif // UPDATEINFOPLUGIN_H