summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@nokia.com>2011-11-25 14:38:36 +0100
committerKarsten Heimrich <karsten.heimrich@nokia.com>2011-11-28 14:05:25 +0100
commitc4dc22c5fd76e8b028200d33553b97079adeaeb3 (patch)
treef5103704e8b00e767c0133d16c3c699785a7885a
parente9a5dce1593172a69fbcc1a8e2c62cc63d33b486 (diff)
Implement network settings dialog.
User settings are stored inside a network.xml file, e.g. proxy type, proxy authentification, repositories etc... Default repos are saved kind of encrypted inside the already existing ini file. Change-Id: Ie97f2e82af7faf4d15719c669a0fa4158b503ce3 Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
-rw-r--r--installerbuilder/installerbase/installerbase.pro8
-rw-r--r--installerbuilder/installerbase/settingsdialog.cpp361
-rw-r--r--installerbuilder/installerbase/settingsdialog.h136
-rw-r--r--installerbuilder/installerbase/settingsdialog.ui760
-rw-r--r--installerbuilder/installerbase/tabcontroller.cpp87
-rw-r--r--installerbuilder/installerbase/tabcontroller.h4
-rw-r--r--installerbuilder/libinstaller/libinstaller.pro8
-rw-r--r--installerbuilder/libinstaller/packagemanagercore.cpp15
-rw-r--r--installerbuilder/libinstaller/packagemanagercore.h3
-rw-r--r--installerbuilder/libinstaller/packagemanagercore_p.cpp196
-rw-r--r--installerbuilder/libinstaller/packagemanagercore_p.h5
11 files changed, 1524 insertions, 59 deletions
diff --git a/installerbuilder/installerbase/installerbase.pro b/installerbuilder/installerbase/installerbase.pro
index ab57df966..af5a4a96b 100644
--- a/installerbuilder/installerbase/installerbase.pro
+++ b/installerbuilder/installerbase/installerbase.pro
@@ -25,14 +25,18 @@ include(../libinstaller/libinstaller.pri)
QT += network
+FORMS += settingsdialog.ui
+
HEADERS += installerbase_p.h \
tabcontroller.h \
- installerbasecommons.h
+ installerbasecommons.h \
+ settingsdialog.h
SOURCES = installerbase.cpp \
installerbase_p.cpp \
tabcontroller.cpp \
- installerbasecommons.cpp
+ installerbasecommons.cpp \
+ settingsdialog.cpp
win32-msvc2005 {
CONFIG += embed_manifest_exe #msvc2008 is doing this automaticaly
diff --git a/installerbuilder/installerbase/settingsdialog.cpp b/installerbuilder/installerbase/settingsdialog.cpp
new file mode 100644
index 000000000..f4c5992ac
--- /dev/null
+++ b/installerbuilder/installerbase/settingsdialog.cpp
@@ -0,0 +1,361 @@
+/**************************************************************************
+**
+** This file is part of Installer Framework
+**
+** 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 "settingsdialog.h"
+#include "ui_settingsdialog.h"
+
+#include <packagemanagercore.h>
+
+#include <QtGui/QItemSelectionModel>
+#include <QtGui/QTreeWidget>
+
+
+// -- PasswordDelegate
+
+void PasswordDelegate::showPasswords(bool show)
+{
+ m_showPasswords = show;
+}
+
+void PasswordDelegate::disableEditing(bool disable)
+{
+ m_disabledEditor = disable;
+}
+
+QString PasswordDelegate::displayText(const QVariant &value, const QLocale &locale) const
+{
+ const QString tmp = QStyledItemDelegate::displayText(value, locale);
+ if (m_showPasswords)
+ return tmp;
+ return QString(tmp.length(), QChar(0x25CF));
+}
+
+QWidget *PasswordDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &)
+ const
+{
+ if (m_disabledEditor)
+ return 0;
+
+ QLineEdit *lineEdit = new QLineEdit(parent);
+ lineEdit->setEchoMode(m_showPasswords ? QLineEdit::Normal : QLineEdit::Password);
+ return lineEdit;
+}
+
+
+// -- RepositoryItem
+
+RepositoryItem::RepositoryItem(const QString &label)
+ : QTreeWidgetItem(QTreeWidgetItem::UserType)
+{
+ setText(0, label);
+ m_repo = QInstaller::Repository(QUrl(), true);
+}
+
+RepositoryItem::RepositoryItem(const QInstaller::Repository &repo)
+ : QTreeWidgetItem(QTreeWidgetItem::UserType)
+ , m_repo(repo)
+{
+ if (!repo.isDefault())
+ setFlags(flags() | Qt::ItemIsEditable);
+}
+
+QVariant RepositoryItem::data(int column, int role) const
+{
+ const QVariant &data = QTreeWidgetItem::data(column, role);
+
+ switch (role) {
+ case Qt::UserRole: {
+ if (column == 0)
+ return m_repo.isDefault();
+ } break;
+
+ case Qt::CheckStateRole: {
+ if (column == 1)
+ return (m_repo.isEnabled() ? Qt::Checked : Qt::Unchecked);
+ } break;
+
+ case Qt::EditRole:
+ case Qt::DisplayRole:{
+ switch (column) {
+ case 0:
+ return data.toString().isEmpty() ? QLatin1String(" ") : data;
+ case 2:
+ return m_repo.url().toString();
+ case 3:
+ return m_repo.username();
+ case 4:
+ return m_repo.password();
+ default:
+ break;
+ };
+ } break;
+ };
+
+ return data;
+}
+
+void RepositoryItem::setData(int column, int role, const QVariant &value)
+{
+ switch (role) {
+ case Qt::EditRole: {
+ switch (column) {
+ case 2:
+ m_repo.setUrl(value.toUrl());
+ break;
+ case 3:
+ m_repo.setUsername(value.toString());
+ break;
+ case 4:
+ m_repo.setPassword(value.toString());
+ break;
+ default:
+ break;
+ };
+ } break;
+
+ case Qt::CheckStateRole: {
+ if (column == 1)
+ m_repo.setEnabled(Qt::CheckState(value.toInt()) == Qt::Checked);
+ } break;
+
+ default:
+ break;
+ }
+ QTreeWidgetItem::setData(column, role, value);
+}
+
+QSet<QInstaller::Repository> RepositoryItem::repositories() const
+{
+ QSet<QInstaller::Repository> set;
+ for (int i = 0; i < childCount(); ++i) {
+ if (QTreeWidgetItem *item = child(i)) {
+ if (item->type() == QTreeWidgetItem::UserType) {
+ if (RepositoryItem *repoItem = static_cast<RepositoryItem*> (item))
+ set.insert(repoItem->repository());
+ }
+ }
+ }
+ return set;
+}
+
+
+// -- SettingsDialog
+
+SettingsDialog::SettingsDialog(QInstaller::PackageManagerCore *core, QWidget *parent)
+ : QDialog(parent)
+ , m_ui(new Ui::SettingsDialog)
+ , m_core(core)
+ , m_showPasswords(false)
+{
+ m_ui->setupUi(this);
+ setupRepositoriesTreeWidget();
+
+ const QInstaller::Settings &settings = m_core->settings();
+ switch (settings.proxyType()) {
+ case QInstaller::Settings::NoProxy:
+ m_ui->m_noProxySettings->setChecked(true);
+ break;
+ case QInstaller::Settings::SystemProxy:
+ m_ui->m_systemProxySettings->setChecked(true);
+ break;
+ case QInstaller::Settings::UserDefinedProxy:
+ m_ui->m_manualProxySettings->setChecked(true);
+ break;
+ default:
+ m_ui->m_noProxySettings->setChecked(true);
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown proxy type given!");
+ }
+
+ const QNetworkProxy &ftpProxy = settings.ftpProxy();
+ m_ui->m_ftpProxy->setText(ftpProxy.hostName());
+ m_ui->m_ftpProxyPort->setValue(ftpProxy.port());
+ m_ui->m_ftpProxyUser->setText(ftpProxy.user());
+ m_ui->m_ftpProxyPass->setText(ftpProxy.password());
+ m_ui->m_ftpProxyNeedsAuth->setChecked(!ftpProxy.user().isEmpty() | !ftpProxy.password().isEmpty());
+
+ const QNetworkProxy &httpProxy = settings.httpProxy();
+ m_ui->m_httpProxy->setText(httpProxy.hostName());
+ m_ui->m_httpProxyPort->setValue(httpProxy.port());
+ m_ui->m_httpProxyUser->setText(httpProxy.user());
+ m_ui->m_httpProxyPass->setText(httpProxy.password());
+ m_ui->m_httpProxyNeedsAuth->setChecked(!httpProxy.user().isEmpty() | !httpProxy.password().isEmpty());
+
+ connect(m_ui->m_addRepository, SIGNAL(clicked()), this, SLOT(addRepository()));
+ connect(m_ui->m_showPasswords, SIGNAL(clicked()), this, SLOT(updatePasswords()));
+ connect(m_ui->m_removeRepository, SIGNAL(clicked()), this, SLOT(removeRepository()));
+ connect(m_ui->m_useTmpRepositories, SIGNAL(clicked(bool)), this, SLOT(useTmpRepositories(bool)));
+ connect(m_ui->m_repositoriesView, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
+ this, SLOT(currentRepositoryChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
+
+ useTmpRepositories(settings.hasReplacementRepos());
+ m_ui->m_useTmpRepositories->setChecked(settings.hasReplacementRepos());
+ m_ui->m_repositoriesView->setCurrentItem(m_rootItems.at(settings.hasReplacementRepos()));
+}
+
+void SettingsDialog::accept()
+{
+ bool settingsChanged = false;
+ QInstaller::Settings newSettings;
+ const QInstaller::Settings &settings = m_core->settings();
+
+ // set possible updated default repositories
+ newSettings.setDefaultRepositories((dynamic_cast<RepositoryItem*> (m_rootItems.at(0)))->repositories());
+ settingsChanged |= (settings.defaultRepositories() != newSettings.defaultRepositories());
+
+ // set possible new temporary repositories
+ newSettings.setTemporaryRepositories((dynamic_cast<RepositoryItem*> (m_rootItems.at(1)))->repositories(),
+ m_ui->m_useTmpRepositories->isChecked());
+ settingsChanged |= (settings.temporaryRepositories() != newSettings.temporaryRepositories());
+ settingsChanged |= (settings.hasReplacementRepos() != newSettings.hasReplacementRepos());
+
+ // set possible new user repositories
+ newSettings.setUserRepositories((dynamic_cast<RepositoryItem*> (m_rootItems.at(2)))->repositories());
+ settingsChanged |= (settings.userRepositories() != newSettings.userRepositories());
+
+ // update proxy type
+ newSettings.setProxyType(QInstaller::Settings::NoProxy);
+ if (m_ui->m_systemProxySettings->isChecked())
+ newSettings.setProxyType(QInstaller::Settings::SystemProxy);
+ else if (m_ui->m_manualProxySettings->isChecked())
+ newSettings.setProxyType(QInstaller::Settings::UserDefinedProxy);
+ settingsChanged |= settings.proxyType() != newSettings.proxyType();
+
+ if (newSettings.proxyType() == QInstaller::Settings::UserDefinedProxy) {
+ // update ftp proxy settings
+ newSettings.setFtpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_ui->m_ftpProxy->text(),
+ m_ui->m_ftpProxyPort->value(), m_ui->m_ftpProxyUser->text(), m_ui->m_ftpProxyPass->text()));
+ settingsChanged |= (settings.ftpProxy() != newSettings.ftpProxy());
+
+ // update http proxy settings
+ newSettings.setHttpProxy(QNetworkProxy(QNetworkProxy::HttpProxy, m_ui->m_httpProxy->text(),
+ m_ui->m_httpProxyPort->value(), m_ui->m_httpProxyUser->text(), m_ui->m_httpProxyPass->text()));
+ settingsChanged |= (settings.httpProxy() != newSettings.httpProxy());
+ }
+
+ if (settingsChanged)
+ emit networkSettingsChanged(newSettings);
+
+ QDialog::accept();
+}
+
+// -- private slots
+
+void SettingsDialog::addRepository()
+{
+ int index = 0;
+ QTreeWidgetItem *parent = m_ui->m_repositoriesView->currentItem();
+ if (parent && !m_rootItems.contains(parent)) {
+ parent = parent->parent();
+ index = parent->indexOfChild(m_ui->m_repositoriesView->currentItem());
+ }
+
+ if (parent) {
+ RepositoryItem *item = new RepositoryItem(QInstaller::Repository());
+ parent->insertChild(index, item);
+ m_ui->m_repositoriesView->editItem(item, 2);
+ m_ui->m_repositoriesView->scrollToItem(item);
+ }
+}
+
+void SettingsDialog::updatePasswords()
+{
+ m_showPasswords = !m_showPasswords;
+ m_delegate->showPasswords(m_showPasswords);
+ m_ui->m_showPasswords->setText(m_showPasswords ? tr("Hide Passwords") : tr("Show Passwords"));
+
+ // force an tree view update so the delegate has to repaint
+ m_ui->m_repositoriesView->viewport()->update();
+}
+
+void SettingsDialog::removeRepository()
+{
+ QTreeWidgetItem *item = m_ui->m_repositoriesView->currentItem();
+ if (item && !m_rootItems.contains(item)) {
+ QTreeWidgetItem *parent = item->parent();
+ if (parent)
+ delete parent->takeChild(parent->indexOfChild(item));
+ }
+}
+
+void SettingsDialog::useTmpRepositories(bool use)
+{
+ m_rootItems.at(0)->setDisabled(use);
+ m_rootItems.at(2)->setDisabled(use);
+}
+
+void SettingsDialog::currentRepositoryChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
+{
+ Q_UNUSED(previous)
+ if (current) {
+ const int index = m_rootItems.at(0)->indexOfChild(current);
+ m_ui->m_removeRepository->setEnabled(!current->data(0, Qt::UserRole).toBool());
+ m_ui->m_addRepository->setEnabled((current != m_rootItems.at(0)) & (index == -1));
+ }
+}
+
+// -- private
+
+void SettingsDialog::setupRepositoriesTreeWidget()
+{
+ QTreeWidget *treeWidget = m_ui->m_repositoriesView;
+ treeWidget->header()->setVisible(true);
+ treeWidget->setHeaderLabels(QStringList() << QString() << tr("Use") << tr("Repository") << tr("Username")
+ << tr("Password"));
+ m_rootItems.append(new RepositoryItem(tr("Default repositories")));
+ m_rootItems.append(new RepositoryItem(tr("Temporary repositories")));
+ m_rootItems.append(new RepositoryItem(tr("User defined repositories")));
+ treeWidget->addTopLevelItems(m_rootItems);
+
+ const QInstaller::Settings &settings = m_core->settings();
+ insertRepositories(settings.userRepositories(), m_rootItems.at(2));
+ insertRepositories(settings.defaultRepositories(), m_rootItems.at(0));
+ insertRepositories(settings.temporaryRepositories(), m_rootItems.at(1));
+
+ treeWidget->expandAll();
+ for (int i = 0; i < treeWidget->model()->columnCount(); ++i)
+ treeWidget->resizeColumnToContents(i);
+
+ treeWidget->header()->setResizeMode(0, QHeaderView::Fixed);
+ treeWidget->header()->setResizeMode(1, QHeaderView::Fixed);
+ treeWidget->header()->setMinimumSectionSize(treeWidget->columnWidth(1));
+ treeWidget->setItemDelegateForColumn(0, new PasswordDelegate(treeWidget));
+ treeWidget->setItemDelegateForColumn(1, new PasswordDelegate(treeWidget));
+ treeWidget->setItemDelegateForColumn(4, m_delegate = new PasswordDelegate(treeWidget));
+ m_delegate->showPasswords(false);
+ m_delegate->disableEditing(false);
+}
+
+void SettingsDialog::insertRepositories(const QSet<QInstaller::Repository> repos, QTreeWidgetItem *rootItem)
+{
+ rootItem->setFirstColumnSpanned(true);
+ foreach (const QInstaller::Repository &repo, repos)
+ rootItem->addChild(new RepositoryItem(repo));
+}
diff --git a/installerbuilder/installerbase/settingsdialog.h b/installerbuilder/installerbase/settingsdialog.h
new file mode 100644
index 000000000..812fa7b3a
--- /dev/null
+++ b/installerbuilder/installerbase/settingsdialog.h
@@ -0,0 +1,136 @@
+/**************************************************************************
+**
+** This file is part of Installer Framework
+**
+** 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 SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include <common/repository.h>
+#include <settings.h>
+
+#include <QtGui/QDialog>
+#include <QtGui/QStyledItemDelegate>
+#include <QtGui/QTreeWidgetItem>
+
+QT_BEGIN_NAMESPACE
+class QLocale;
+class QVariant;
+QT_END_NAMESPACE
+
+namespace Ui {
+ class SettingsDialog;
+}
+
+namespace QInstaller {
+ class PackageManagerCore;
+}
+
+// -- PasswordDelegate
+
+class PasswordDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+
+public:
+ PasswordDelegate(QWidget *parent = 0)
+ : QStyledItemDelegate(parent)
+ , m_showPasswords(true)
+ , m_disabledEditor(true)
+ {}
+
+ void showPasswords(bool show);
+ void disableEditing(bool disable);
+
+protected:
+ QString displayText(const QVariant &value, const QLocale &locale) const;
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const;
+
+private:
+ bool m_showPasswords;
+ bool m_disabledEditor;
+};
+
+
+// -- RepositoryItem
+
+class RepositoryItem : public QTreeWidgetItem
+{
+public:
+ RepositoryItem(const QString &label);
+ RepositoryItem(const QInstaller::Repository &repo);
+
+ QVariant data(int column, int role) const;
+ void setData(int column, int role, const QVariant &value);
+
+ QSet<QInstaller::Repository> repositories() const;
+ QInstaller::Repository repository() const { return m_repo; }
+ void setRepository(const QInstaller::Repository &repo) { m_repo = repo; }
+
+private:
+ QInstaller::Repository m_repo;
+};
+
+
+// -- SettingsDialog
+
+class SettingsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SettingsDialog(QInstaller::PackageManagerCore *core, QWidget *parent = 0);
+
+public slots:
+ void accept();
+
+signals:
+ void networkSettingsChanged(const QInstaller::Settings &settings);
+
+private slots:
+ void addRepository();
+ void updatePasswords();
+ void removeRepository();
+ void useTmpRepositories(bool use);
+ void currentRepositoryChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
+
+private:
+ void setupRepositoriesTreeWidget();
+ void insertRepositories(const QSet<QInstaller::Repository> repos, QTreeWidgetItem *rootItem);
+
+private:
+ Ui::SettingsDialog *m_ui;
+ PasswordDelegate *m_delegate;
+ QInstaller::PackageManagerCore *m_core;
+
+ bool m_showPasswords;
+ QList<QTreeWidgetItem*> m_rootItems;
+};
+
+#endif // SETTINGSDIALOG_H
diff --git a/installerbuilder/installerbase/settingsdialog.ui b/installerbuilder/installerbase/settingsdialog.ui
new file mode 100644
index 000000000..a49c31757
--- /dev/null
+++ b/installerbuilder/installerbase/settingsdialog.ui
@@ -0,0 +1,760 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SettingsDialog</class>
+ <widget class="QDialog" name="SettingsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>491</width>
+ <height>387</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="m_network">
+ <attribute name="title">
+ <string>Network</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QRadioButton" name="m_noProxySettings">
+ <property name="text">
+ <string>No proxy</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="m_systemProxySettings">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>System proxy settings</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="m_manualProxySettings">
+ <property name="text">
+ <string>Manual proxy configuration</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="m_rootWidget" native="true">
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" name="m_httpRootLayout">
+ <item>
+ <layout class="QHBoxLayout" name="m_httpProxyLayout">
+ <item>
+ <widget class="QLabel" name="m_httpProxyLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Http proxy:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="m_httpProxy">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="m_httpProxyPortLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Port:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="m_httpProxyPort">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="m_httpProxyNeedsAuth">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Http proxy requieres authentication</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="m_httpAuthWidget" native="true">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="m_httpProxyUserLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Username:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="m_httpProxyUser">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="m_httpProxyPassLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="m_httpProxyPass">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="m_ftpRootLayout">
+ <item>
+ <layout class="QHBoxLayout" name="m_ftpProxyLayout">
+ <item>
+ <widget class="QLabel" name="m_ftpProxyLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Ftp proxy:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="m_ftpProxy">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="m_ftpProxyPortLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Port:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="m_ftpProxyPort">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="m_ftpProxyNeedsAuth">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Ftp proxy requieres authentication</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="m_ftpAuthWidget" native="true">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="m_ftpProxyUserLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Username:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="m_ftpProxyUser">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="m_ftpProxyPassLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="m_ftpProxyPass">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="m_repositories">
+ <attribute name="title">
+ <string>Repositories</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="m_httpAuthLabel">
+ <property name="text">
+ <string>Add Username and Password for authentication if needed.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="m_repositoriesView">
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="m_useTmpRepositories">
+ <property name="text">
+ <string>Use temporary repositories only</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="m_addRepository">
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_removeRepository">
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_showPasswords">
+ <property name="text">
+ <string>Show Passwords</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>269</x>
+ <y>422</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>337</x>
+ <y>422</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>104</x>
+ <y>74</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>121</x>
+ <y>97</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxy</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>232</x>
+ <y>77</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>232</x>
+ <y>97</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyPortLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>349</x>
+ <y>78</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>347</x>
+ <y>96</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyPort</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>392</x>
+ <y>74</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>392</x>
+ <y>96</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>61</x>
+ <y>76</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>109</x>
+ <y>243</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxy</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>204</x>
+ <y>78</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>203</x>
+ <y>248</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyPortLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>336</x>
+ <y>77</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>336</x>
+ <y>241</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyPort</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>406</x>
+ <y>78</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>380</x>
+ <y>252</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyNeedsAuth</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>53</x>
+ <y>75</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>100</x>
+ <y>129</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyNeedsAuth</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>88</x>
+ <y>74</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>95</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpAuthWidget</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>54</x>
+ <y>79</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>53</x>
+ <y>179</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_manualProxySettings</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpAuthWidget</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>73</x>
+ <y>76</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>56</x>
+ <y>298</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_ftpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyUserLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>82</x>
+ <y>283</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>77</x>
+ <y>303</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_ftpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyUser</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>180</x>
+ <y>284</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>170</x>
+ <y>304</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_ftpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyPass</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>224</x>
+ <y>283</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>223</x>
+ <y>330</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_ftpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_ftpProxyPassLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>317</x>
+ <y>282</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>122</x>
+ <y>335</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_httpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyUserLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>81</x>
+ <y>134</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>70</x>
+ <y>154</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_httpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyPassLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>87</x>
+ <y>137</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>84</x>
+ <y>186</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_httpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyUser</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>183</x>
+ <y>135</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>182</x>
+ <y>154</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_httpProxyNeedsAuth</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_httpProxyPass</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>287</x>
+ <y>134</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>285</x>
+ <y>182</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/installerbuilder/installerbase/tabcontroller.cpp b/installerbuilder/installerbase/tabcontroller.cpp
index 82bc3113f..5201fa6f6 100644
--- a/installerbuilder/installerbase/tabcontroller.cpp
+++ b/installerbuilder/installerbase/tabcontroller.cpp
@@ -31,7 +31,9 @@
**
**************************************************************************/
#include "tabcontroller.h"
+
#include "installerbasecommons.h"
+#include "settingsdialog.h"
#include <common/utils.h>
#include <component.h>
@@ -62,6 +64,9 @@ public:
QString m_controlScript;
QHash<QString, QString> m_params;
+
+ Settings m_settings;
+ bool m_networkSettingsChanged;
};
TabController::Private::Private()
@@ -71,6 +76,7 @@ TabController::Private::Private()
, m_introPageConnected(false)
, m_gui(0)
, m_core(0)
+ , m_networkSettingsChanged(false)
{
}
@@ -137,6 +143,9 @@ int TabController::init()
connect(introPage, SIGNAL(initUpdater()), this, SLOT(initUpdater()));
connect(introPage, SIGNAL(initUninstaller()), this, SLOT(initUninstaller()));
connect(introPage, SIGNAL(initPackageManager()), this, SLOT(initPackageManager()));
+
+ connect(d->m_gui, SIGNAL(currentIdChanged(int)), this, SLOT(onCurrentIdChanged(int)));
+ connect(d->m_gui, SIGNAL(settingsButtonClicked()), this, SLOT(onSettingsButtonClicked()));
}
d->m_updatesFetched = false;
@@ -153,6 +162,7 @@ int TabController::init()
int TabController::initUpdater()
{
+ onCurrentIdChanged(d->m_gui->currentId());
IntroductionPageImpl *introPage = introductionPage();
introPage->setMessage(QString());
@@ -167,7 +177,9 @@ int TabController::initUpdater()
}
d->m_gui->setWindowModality(Qt::WindowModal);
+ d->m_gui->init(); // Initialize/ reset the ui.
d->m_gui->show();
+ d->m_gui->setSettingsButtonEnabled(false);
if (!d->m_updatesFetched) {
d->m_updatesFetched = d->m_core->fetchRemotePackagesTree();
@@ -175,9 +187,8 @@ int TabController::initUpdater()
introPage->setErrorMessage(d->m_core->error());
}
- // Initialize the gui. Needs to be done after check repositories as only then the ui can handle
- // hide of pages depending on the components.
- d->m_gui->init();
+ // Needs to be done after check repositories as only then the ui can handle hide of pages depending on
+ // the components.
d->m_gui->callControlScriptMethod(QLatin1String("UpdaterSelectedCallback"));
d->m_gui->triggerControlScriptForCurrentPage();
@@ -190,11 +201,14 @@ int TabController::initUpdater()
else
introPage->setComplete(true);
}
+ d->m_gui->setSettingsButtonEnabled(true);
+
return d->m_core->status();
}
int TabController::initUninstaller()
{
+ onCurrentIdChanged(d->m_gui->currentId());
IntroductionPageImpl *introPage = introductionPage();
introPage->setMessage(QString());
@@ -210,6 +224,7 @@ int TabController::initUninstaller()
int TabController::initPackageManager()
{
+ onCurrentIdChanged(d->m_gui->currentId());
IntroductionPageImpl *introPage = introductionPage();
introPage->setMessage(QString());
@@ -228,28 +243,31 @@ int TabController::initPackageManager()
}
d->m_gui->setWindowModality(Qt::WindowModal);
+ d->m_gui->init(); // Initialize/ reset the ui.
d->m_gui->show();
+ d->m_gui->setSettingsButtonEnabled(false);
bool localPackagesTreeFetched = false;
if (!d->m_allPackagesFetched) {
// first try to fetch the server side packages tree
d->m_allPackagesFetched = d->m_core->fetchRemotePackagesTree();
- if (!d->m_core->isInstaller() && !d->m_allPackagesFetched) {
+ if (!d->m_allPackagesFetched) {
QString error = d->m_core->error();
- // if that fails, try to fetch local installed tree
- localPackagesTreeFetched = d->m_core->fetchLocalPackagesTree();
- if (localPackagesTreeFetched) {
- // if that succeeded, adjust error message
- error = QLatin1String("<font color=\"red\">") + error + tr(" Only local package management "
- "available.") + QLatin1String("</font>");
+ if (d->m_core->isPackageManager()) {
+ // if that fails and we're in maintenance mode, try to fetch local installed tree
+ localPackagesTreeFetched = d->m_core->fetchLocalPackagesTree();
+ if (localPackagesTreeFetched) {
+ // if that succeeded, adjust error message
+ error = QLatin1String("<font color=\"red\">") + error + tr(" Only local package "
+ "management available.") + QLatin1String("</font>");
+ }
}
introPage->setErrorMessage(error);
}
}
- // Initialize the gui. Needs to be done after check repositories as only then the ui can handle
- // hide of pages depending on the components.
- d->m_gui->init();
+ // Needs to be done after check repositories as only then the ui can handle hide of pages depending on
+ // the components.
d->m_gui->callControlScriptMethod(QLatin1String("PackageManagerSelectedCallback"));
d->m_gui->triggerControlScriptForCurrentPage();
@@ -262,6 +280,8 @@ int TabController::initPackageManager()
if (d->m_allPackagesFetched | localPackagesTreeFetched)
introPage->setComplete(true);
+ d->m_gui->setSettingsButtonEnabled(true);
+
return d->m_core->status();
}
@@ -270,11 +290,52 @@ int TabController::initPackageManager()
void TabController::restartWizard()
{
d->m_core->reset(d->m_params);
+ if (d->m_networkSettingsChanged) {
+ d->m_networkSettingsChanged = false;
+
+ d->m_core->settings().setFtpProxy(d->m_settings.ftpProxy());
+ d->m_core->settings().setHttpProxy(d->m_settings.httpProxy());
+ d->m_core->settings().setProxyType(d->m_settings.proxyType());
+
+ d->m_core->settings().setUserRepositories(d->m_settings.userRepositories());
+ d->m_core->settings().setDefaultRepositories(d->m_settings.defaultRepositories());
+ d->m_core->settings().setTemporaryRepositories(d->m_settings.temporaryRepositories(),
+ d->m_settings.hasReplacementRepos());
+ d->m_core->networkSettingsChanged();
+ }
// restart and switch back to intro page
QTimer::singleShot(0, this, SLOT(init()));
}
+void TabController::onSettingsButtonClicked()
+{
+ SettingsDialog dialog(d->m_core);
+ connect (&dialog, SIGNAL(networkSettingsChanged(QInstaller::Settings)), this,
+ SLOT(onNetworkSettingsChanged(QInstaller::Settings)));
+ dialog.exec();
+
+ if (d->m_networkSettingsChanged) {
+ d->m_core->setCanceled();
+ QTimer::singleShot(0, d->m_gui, SLOT(restart()));
+ QTimer::singleShot(100, this, SLOT(restartWizard()));
+ }
+}
+
+void TabController::onCurrentIdChanged(int newId)
+{
+ if (d->m_gui && d->m_core) {
+ d->m_gui->showSettingsButton((newId == PackageManagerCore::Introduction) &
+ (!d->m_core->isOfflineOnly()) & (!d->m_core->isUninstaller()));
+ }
+}
+
+void TabController::onNetworkSettingsChanged(const QInstaller::Settings &settings)
+{
+ d->m_settings = settings;
+ d->m_networkSettingsChanged = true;
+}
+
// -- private
IntroductionPageImpl *TabController::introductionPage() const
diff --git a/installerbuilder/installerbase/tabcontroller.h b/installerbuilder/installerbase/tabcontroller.h
index 4ce02f435..39353ccfc 100644
--- a/installerbuilder/installerbase/tabcontroller.h
+++ b/installerbuilder/installerbase/tabcontroller.h
@@ -32,6 +32,7 @@
namespace QInstaller {
class PackageManagerGui;
class PackageManagerCore;
+ class Settings;
}
class IntroductionPageImpl;
@@ -59,6 +60,9 @@ public Q_SLOTS:
private Q_SLOTS:
void restartWizard();
+ void onSettingsButtonClicked();
+ void onCurrentIdChanged(int newId);
+ void onNetworkSettingsChanged(const QInstaller::Settings &settings);
private:
IntroductionPageImpl *introductionPage() const;
diff --git a/installerbuilder/libinstaller/libinstaller.pro b/installerbuilder/libinstaller/libinstaller.pro
index dae985890..bcf64b026 100644
--- a/installerbuilder/libinstaller/libinstaller.pro
+++ b/installerbuilder/libinstaller/libinstaller.pro
@@ -100,7 +100,8 @@ HEADERS += $$PWD/packagemanagercore.h \
updatecreatorsettingsfrom21to22operation.h \
qprocesswrapper.h \
qsettingswrapper.h \
- constants.h
+ constants.h \
+ packagemanagerproxyfactory.h
SOURCES += $$PWD/packagemanagercore.cpp \
$$PWD/packagemanagercore_p.cpp \
@@ -166,7 +167,8 @@ SOURCES += $$PWD/packagemanagercore.cpp \
qprocesswrapper.cpp \
templates.cpp \
qsettingswrapper.cpp \
- settings.cpp
+ settings.cpp \
+ packagemanagerproxyfactory.cpp
macx {
HEADERS += macrelocateqt.h \
@@ -200,3 +202,5 @@ TRANSLATIONS += translations/de_de.ts \
RESOURCES += ../common/openssl.qrc \
resources/patch_file_lists.qrc
+
+
diff --git a/installerbuilder/libinstaller/packagemanagercore.cpp b/installerbuilder/libinstaller/packagemanagercore.cpp
index fd3ff0cb4..fa65a44b8 100644
--- a/installerbuilder/libinstaller/packagemanagercore.cpp
+++ b/installerbuilder/libinstaller/packagemanagercore.cpp
@@ -605,6 +605,19 @@ LocalPackagesHash PackageManagerCore::localInstalledPackages()
return d->localInstalledPackages();
}
+void PackageManagerCore::networkSettingsChanged()
+{
+ cancelMetaInfoJob();
+
+ d->m_updates = false;
+ d->m_repoFetched = false;
+ d->m_updateSourcesAdded = false;
+
+ if (d->isUpdater() || d->isPackageManager())
+ d->writeMaintenanceConfigFiles();
+ KDUpdater::FileDownloaderFactory::instance().setProxyFactory(proxyFactory());
+}
+
KDUpdater::FileDownloaderProxyFactory *PackageManagerCore::proxyFactory() const
{
if (d->m_proxyFactory)
@@ -996,7 +1009,7 @@ QList<Component*> PackageManagerCore::dependencies(const Component *component, Q
return result;
}
-const Settings &PackageManagerCore::settings() const
+Settings &PackageManagerCore::settings() const
{
return d->m_settings;
}
diff --git a/installerbuilder/libinstaller/packagemanagercore.h b/installerbuilder/libinstaller/packagemanagercore.h
index ef460fa17..d9ae85076 100644
--- a/installerbuilder/libinstaller/packagemanagercore.h
+++ b/installerbuilder/libinstaller/packagemanagercore.h
@@ -94,6 +94,7 @@ public:
bool fetchLocalPackagesTree();
LocalPackagesHash localInstalledPackages();
+ void networkSettingsChanged();
KDUpdater::FileDownloaderProxyFactory *proxyFactory() const;
void setProxyFactory(KDUpdater::FileDownloaderProxyFactory *factory);
@@ -197,7 +198,7 @@ public:
Q_INVOKABLE bool isProcessRunning(const QString &name) const;
- const Settings &settings() const;
+ Settings &settings() const;
Q_INVOKABLE bool addWizardPage(QInstaller::Component *component, const QString &name, int page);
Q_INVOKABLE bool removeWizardPage(QInstaller::Component *component, const QString &name);
diff --git a/installerbuilder/libinstaller/packagemanagercore_p.cpp b/installerbuilder/libinstaller/packagemanagercore_p.cpp
index bf3773a26..d3a632d62 100644
--- a/installerbuilder/libinstaller/packagemanagercore_p.cpp
+++ b/installerbuilder/libinstaller/packagemanagercore_p.cpp
@@ -60,6 +60,9 @@
#include <QtCore/QFutureWatcher>
#include <QtCore/QTemporaryFile>
+#include <QtXml/QXmlStreamReader>
+#include <QtXml/QXmlStreamWriter>
+
#include <errno.h>
namespace QInstaller {
@@ -567,9 +570,9 @@ void PackageManagerCorePrivate::initialize()
if (!m_core->isInstaller()) {
#ifdef Q_WS_MAC
- readUninstallerIniFile(QCoreApplication::applicationDirPath() + QLatin1String("/../../.."));
+ readMaintenanceConfigFiles(QCoreApplication::applicationDirPath() + QLatin1String("/../../.."));
#else
- readUninstallerIniFile(QCoreApplication::applicationDirPath());
+ readMaintenanceConfigFiles(QCoreApplication::applicationDirPath());
#endif
}
@@ -721,22 +724,162 @@ QString PackageManagerCorePrivate::uninstallerName() const
return QString::fromLatin1("%1/%2").arg(targetDir()).arg(filename);
}
-void PackageManagerCorePrivate::readUninstallerIniFile(const QString &targetDir)
+static QNetworkProxy readProxy(QXmlStreamReader &reader)
+{
+ QNetworkProxy proxy(QNetworkProxy::HttpProxy);
+ while (reader.readNextStartElement()) {
+ if (reader.name() == QLatin1String("Host"))
+ proxy.setHostName(reader.readElementText());
+ else if (reader.name() == QLatin1String("Port"))
+ proxy.setPort(reader.readElementText().toInt());
+ else if (reader.name() == QLatin1String("Username"))
+ proxy.setUser(reader.readElementText());
+ else if (reader.name() == QLatin1String("Password"))
+ proxy.setPassword(reader.readElementText());
+ else
+ reader.skipCurrentElement();
+ }
+ return proxy;
+}
+
+static QSet<Repository> readRepositories(QXmlStreamReader &reader, bool isDefault)
+{
+ QSet<Repository> set;
+ while (reader.readNextStartElement()) {
+ if (reader.name() == QLatin1String("Repository")) {
+ Repository repo(QString(), isDefault);
+ while (reader.readNextStartElement()) {
+ if (reader.name() == QLatin1String("Host"))
+ repo.setUrl(reader.readElementText());
+ else if (reader.name() == QLatin1String("Username"))
+ repo.setUsername(reader.readElementText());
+ else if (reader.name() == QLatin1String("Password"))
+ repo.setPassword(reader.readElementText());
+ else if (reader.name() == QLatin1String("Enabled"))
+ repo.setEnabled(bool(reader.readElementText().toInt()));
+ else
+ reader.skipCurrentElement();
+ }
+ set.insert(repo);
+ } else {
+ reader.skipCurrentElement();
+ }
+ }
+ return set;
+}
+
+void PackageManagerCorePrivate::writeMaintenanceConfigFiles()
{
- const QString iniPath = targetDir + QLatin1Char('/') + m_settings.uninstallerIniFile();
+ // write current state (variables) to the uninstaller ini file
+ const QString iniPath = targetDir() + QLatin1Char('/') + m_settings.uninstallerIniFile();
+
+ QVariantHash vars;
QSettingsWrapper cfg(iniPath, QSettingsWrapper::IniFormat);
+ foreach (const QString &key, m_vars.keys()) {
+ if (key != scRunProgramDescription && key != scRunProgram)
+ vars.insert(key, m_vars.value(key));
+ }
+ cfg.setValue(QLatin1String("Variables"), vars);
+
+ QVariantList repos;
+ foreach (const Repository &repo, m_settings.defaultRepositories())
+ repos.append(QVariant().fromValue(repo));
+ cfg.setValue(QLatin1String("DefaultRepositories"), repos);
+
+ cfg.sync();
+ if (cfg.status() != QSettingsWrapper::NoError) {
+ const QString reason = cfg.status() == QSettingsWrapper::AccessError ? tr("Access error")
+ : tr("Format error");
+ throw Error(tr("Could not write installer configuration to %1: %2").arg(iniPath, reason));
+ }
+
+ QFile file(targetDir() + QLatin1Char('/') + QLatin1String("network.xml"));
+ if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+ QXmlStreamWriter writer(&file);
+ writer.setCodec("UTF-8");
+ writer.setAutoFormatting(true);
+ writer.writeStartDocument();
+
+ writer.writeStartElement(QLatin1String("Network"));
+ writer.writeTextElement(QLatin1String("ProxyType"), QString::number(m_settings.proxyType()));
+ writer.writeStartElement(QLatin1String("Ftp"));
+ const QNetworkProxy &ftpProxy = m_settings.ftpProxy();
+ writer.writeTextElement(QLatin1String("Host"), ftpProxy.hostName());
+ writer.writeTextElement(QLatin1String("Port"), QString::number(ftpProxy.port()));
+ writer.writeTextElement(QLatin1String("Username"), ftpProxy.user());
+ writer.writeTextElement(QLatin1String("Password"), ftpProxy.password());
+ writer.writeEndElement();
+ writer.writeStartElement(QLatin1String("Http"));
+ const QNetworkProxy &httpProxy = m_settings.httpProxy();
+ writer.writeTextElement(QLatin1String("Host"), httpProxy.hostName());
+ writer.writeTextElement(QLatin1String("Port"), QString::number(httpProxy.port()));
+ writer.writeTextElement(QLatin1String("Username"), httpProxy.user());
+ writer.writeTextElement(QLatin1String("Password"), httpProxy.password());
+ writer.writeEndElement();
+
+ writer.writeStartElement(QLatin1String("Repositories"));
+ foreach (const Repository &repo, m_settings.userRepositories()) {
+ writer.writeStartElement(QLatin1String("Repository"));
+ writer.writeTextElement(QLatin1String("Host"), repo.url().toString());
+ writer.writeTextElement(QLatin1String("Username"), repo.username());
+ writer.writeTextElement(QLatin1String("Password"), repo.password());
+ writer.writeTextElement(QLatin1String("Enabled"), QString::number(repo.isEnabled()));
+ writer.writeEndElement();
+ }
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+}
+
+void PackageManagerCorePrivate::readMaintenanceConfigFiles(const QString &targetDir)
+{
+ QSettingsWrapper cfg(targetDir + QLatin1Char('/') + m_settings.uninstallerIniFile(),
+ QSettingsWrapper::IniFormat);
const QVariantHash vars = cfg.value(QLatin1String("Variables")).toHash();
- QHash<QString, QVariant>::ConstIterator it = vars.constBegin();
- while (it != vars.constEnd()) {
+ for (QHash<QString, QVariant>::ConstIterator it = vars.constBegin(); it != vars.constEnd(); ++it)
m_vars.insert(it.key(), it.value().toString());
- ++it;
- }
- QSet<Repository> repositories;
- const QStringList list = cfg.value(scRepositories).toStringList();
- foreach (const QString &url, list)
- repositories.insert(Repository(url, false));
- m_settings.addUserRepositories(repositories);
+ QSet<Repository> repos;
+ const QVariantList variants = cfg.value(QLatin1String("DefaultRepositories")).toList();
+ foreach (const QVariant &variant, variants)
+ repos.insert(variant.value<Repository>());
+ if (!repos.isEmpty())
+ m_settings.setDefaultRepositories(repos);
+
+ QFile file(targetDir + QLatin1String("/network.xml"));
+ if (!file.open(QIODevice::ReadOnly))
+ return;
+
+ QXmlStreamReader reader(&file);
+ while (!reader.atEnd()) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement: {
+ if (reader.name() == QLatin1String("Network")) {
+ while (reader.readNextStartElement()) {
+ const QStringRef name = reader.name();
+ if (name == QLatin1String("Ftp")) {
+ m_settings.setFtpProxy(readProxy(reader));
+ } else if (name == QLatin1String("Http")) {
+ m_settings.setHttpProxy(readProxy(reader));
+ } else if (reader.name() == QLatin1String("Repositories")) {
+ m_settings.addUserRepositories(readRepositories(reader, false));
+ } else if (name == QLatin1String("ProxyType")) {
+ m_settings.setProxyType(Settings::ProxyType(reader.readElementText().toInt()));
+ } else {
+ reader.skipCurrentElement();
+ }
+ }
+ }
+ } break;
+
+ case QXmlStreamReader::Invalid: {
+ qDebug() << reader.errorString();
+ } break;
+
+ default:
+ break;
+ }
+ }
}
void PackageManagerCorePrivate::callBeginInstallation(const QList<Component*> &componentList)
@@ -960,32 +1103,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
performedOperations.append(takeOwnedOperation(op));
}
- {
- // write current state (variables) to the uninstaller ini file
- const QString iniPath = targetDir() + QLatin1Char('/') + m_settings.uninstallerIniFile();
- QSettingsWrapper cfg(iniPath, QSettingsWrapper::IniFormat);
- QVariantHash vars;
- QHash<QString, QString>::ConstIterator it = m_vars.constBegin();
- while (it != m_vars.constEnd()) {
- const QString &key = it.key();
- if (key != scRunProgramDescription && key != scRunProgram)
- vars.insert(key, it.value());
- ++it;
- }
- cfg.setValue(QLatin1String("Variables"), vars);
-
- QStringList list;
- foreach (const Repository &repository, m_settings.userRepositories())
- list.append(repository.url().toString());
- cfg.setValue(scRepositories, list);
-
- cfg.sync();
- if (cfg.status() != QSettingsWrapper::NoError) {
- const QString reason = cfg.status() == QSettingsWrapper::AccessError ? tr("Access error")
- : tr("Format error");
- throw Error(tr("Could not write installer configuration to %1: %2").arg(iniPath, reason));
- }
- }
+ writeMaintenanceConfigFiles();
#ifdef Q_WS_MAC
// if it is a bundle, we need some stuff in it...
diff --git a/installerbuilder/libinstaller/packagemanagercore_p.h b/installerbuilder/libinstaller/packagemanagercore_p.h
index b7bf07342..05596d870 100644
--- a/installerbuilder/libinstaller/packagemanagercore_p.h
+++ b/installerbuilder/libinstaller/packagemanagercore_p.h
@@ -92,7 +92,10 @@ public:
QString uninstallerName() const;
QString installerBinaryPath() const;
- void readUninstallerIniFile(const QString &targetDir);
+
+ void writeMaintenanceConfigFiles();
+ void readMaintenanceConfigFiles(const QString &targetDir);
+
void writeUninstaller(OperationList performedOperations);
QString componentsXmlPath() const;