More do-release-upgrade progress
This commit is contained in:
parent
1821373141
commit
d71a36f0ef
@ -38,6 +38,9 @@ set(PROJECT_SOURCES
|
|||||||
src/conffilehandlerdialog.ui
|
src/conffilehandlerdialog.ui
|
||||||
src/ipcfilewatcher.h
|
src/ipcfilewatcher.h
|
||||||
src/ipcfilewatcher.cpp
|
src/ipcfilewatcher.cpp
|
||||||
|
src/releaseupgradewindow.h
|
||||||
|
src/releaseupgradewindow.cpp
|
||||||
|
src/releaseupgradewindow.ui
|
||||||
${TS_FILES}
|
${TS_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,6 +20,11 @@ It is highly recommended that you use a Lubuntu virtual machine for testing and
|
|||||||
|
|
||||||
Qt Creator is recommended for editing the code. It is present in Ubuntu's official repos and can be installed using `sudo apt install qtcreator`.
|
Qt Creator is recommended for editing the code. It is present in Ubuntu's official repos and can be installed using `sudo apt install qtcreator`.
|
||||||
|
|
||||||
|
## Config file format:
|
||||||
|
There's only one field here:
|
||||||
|
|
||||||
|
* nextDoReleaseUpgradeNotify=123456789 - Value is number of seconds since the UNIX epoch. Used to determine when to offer the user an upgrade.
|
||||||
|
|
||||||
## Missing features
|
## Missing features
|
||||||
|
|
||||||
* Double-clicking on a package doesn't show detailed information for it yet.
|
* Double-clicking on a package doesn't show detailed information for it yet.
|
||||||
|
@ -144,7 +144,7 @@ void AptManager::handleUpdateProcessBuffer()
|
|||||||
conffileList.append(confLine);
|
conffileList.append(confLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (line == "Lubuntu Update !!! NEW LTS RELEASE") {
|
} else if (line == "Lubuntu Update !!! NEW RELEASE") {
|
||||||
// Same busy-wait technique, but here we're just getting one extra line, the model code.
|
// Same busy-wait technique, but here we're just getting one extra line, the model code.
|
||||||
while (!aptProcess->canReadLine()) {
|
while (!aptProcess->canReadLine()) {
|
||||||
QThread::msleep(20);
|
QThread::msleep(20);
|
||||||
@ -152,14 +152,6 @@ void AptManager::handleUpdateProcessBuffer()
|
|||||||
aptProcess->readLine(lineBuf, 2048);
|
aptProcess->readLine(lineBuf, 2048);
|
||||||
QString ltsReleaseCode = QString(lineBuf);
|
QString ltsReleaseCode = QString(lineBuf);
|
||||||
emit newLtsRelease(ltsReleaseCode);
|
emit newLtsRelease(ltsReleaseCode);
|
||||||
} else if (line == "Lubuntu Update !!! NEW STABLE RELEASE") {
|
|
||||||
// Ditto
|
|
||||||
while (!aptProcess->canReadLine()) {
|
|
||||||
QThread::msleep(20);
|
|
||||||
}
|
|
||||||
aptProcess->readLine(lineBuf, 2048);
|
|
||||||
QString stableReleaseCode = QString(lineBuf);
|
|
||||||
emit newStableRelease(stableReleaseCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double percentageDone = (static_cast<double>(internalUpdateProgress) / (((internalUpdateInfo[0].count() + internalUpdateInfo[1].count()) * 4) + internalUpdateInfo[2].count())) * 100;
|
double percentageDone = (static_cast<double>(internalUpdateProgress) / (((internalUpdateInfo[0].count() + internalUpdateInfo[1].count()) * 4) + internalUpdateInfo[2].count())) * 100;
|
||||||
|
@ -152,14 +152,14 @@ elif [ "$1" = 'doupdate' ]; then
|
|||||||
|
|
||||||
if [ -n "$nextLTSReleaseYear" ]; then
|
if [ -n "$nextLTSReleaseYear" ]; then
|
||||||
if isReleaseSupported "$nextLTSReleaseYear" "$nextLTSReleaseMonth" "$metaReleaseData"; then
|
if isReleaseSupported "$nextLTSReleaseYear" "$nextLTSReleaseMonth" "$metaReleaseData"; then
|
||||||
echo 'Lubuntu Update !!! NEW LTS RELEASE';
|
echo 'Lubuntu Update !!! NEW RELEASE';
|
||||||
echo "$nextLTSReleaseYear.$nextLTSReleaseMonth";
|
echo "$nextLTSReleaseYear.$nextLTSReleaseMonth";
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! (((nextReleaseYear == nextLTSReleaseYear) && (nextReleaseMonth == nextLTSReleaseMonth))); then
|
if ! (((nextReleaseYear == nextLTSReleaseYear) && (nextReleaseMonth == nextLTSReleaseMonth))); then
|
||||||
if isReleaseSupported "$nextReleaseYear" "$nextReleaseMonth" "$metaReleaseData"; then
|
if isReleaseSupported "$nextReleaseYear" "$nextReleaseMonth" "$metaReleaseData"; then
|
||||||
echo 'Lubuntu Update !!! NEW STABLE RELEASE';
|
echo 'Lubuntu Update !!! NEW RELEASE';
|
||||||
echo "$nextReleaseYear.$nextReleaseMonth";
|
echo "$nextReleaseYear.$nextReleaseMonth";
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -25,8 +25,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(aptManager, &AptManager::progressUpdated, this, &MainWindow::onProgressUpdate);
|
connect(aptManager, &AptManager::progressUpdated, this, &MainWindow::onProgressUpdate);
|
||||||
connect(aptManager, &AptManager::logLineReady, this, &MainWindow::onLogLineReady);
|
connect(aptManager, &AptManager::logLineReady, this, &MainWindow::onLogLineReady);
|
||||||
connect(aptManager, &AptManager::conffileListReady, this, &MainWindow::onConffileListReady);
|
connect(aptManager, &AptManager::conffileListReady, this, &MainWindow::onConffileListReady);
|
||||||
connect(aptManager, &AptManager::newLtsRelease, this, &MainWindow::onNewLtsRelease);
|
connect(aptManager, &AptManager::newLtsRelease, this, &MainWindow::onNewRelease);
|
||||||
connect(aptManager, &AptManager::newStableRelease, this, &MainWindow::onNewStableRelease);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -179,19 +178,13 @@ void MainWindow::onConffileListReady(QStringList conffileList)
|
|||||||
aptManager->doneWithConffiles();
|
aptManager->doneWithConffiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onNewLtsRelease(QString code)
|
void MainWindow::onNewRelease(QString code)
|
||||||
{
|
{
|
||||||
newLtsReleaseAvailable = true;
|
releaseCodes.append(code);
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onNewStableRelease(QString code)
|
|
||||||
{
|
|
||||||
newStableReleaseAvailable = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::handleNewReleases()
|
void MainWindow::handleNewReleases()
|
||||||
{
|
{
|
||||||
// TODO: Write code that informs the user when a new release is available here
|
emit newReleaseAvailable(releaseCodes);
|
||||||
newLtsReleaseAvailable = false;
|
releaseCodes.clear();
|
||||||
newStableReleaseAvailable = false;
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void updatesInstalled();
|
void updatesInstalled();
|
||||||
void updatesRefreshed();
|
void updatesRefreshed();
|
||||||
|
void newReleaseAvailable(QStringList releaseCodes);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
@ -39,14 +40,12 @@ private slots:
|
|||||||
void onProgressUpdate(int progress);
|
void onProgressUpdate(int progress);
|
||||||
void onLogLineReady(QString logLine);
|
void onLogLineReady(QString logLine);
|
||||||
void onConffileListReady(QStringList conffileList);
|
void onConffileListReady(QStringList conffileList);
|
||||||
void onNewLtsRelease(QString code);
|
void onNewRelease(QString code);
|
||||||
void onNewStableRelease(QString code);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
AptManager *aptManager;
|
AptManager *aptManager;
|
||||||
bool newLtsReleaseAvailable = false;
|
QStringList releaseCodes;
|
||||||
bool newStableReleaseAvailable = false;
|
|
||||||
|
|
||||||
void handleNewReleases();
|
void handleNewReleases();
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "aptmanager.h"
|
#include "aptmanager.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -12,6 +15,32 @@ Orchestrator::Orchestrator(QObject *parent)
|
|||||||
checkTimer = new QTimer(); // every time this triggers, the apt database is checked for new updates
|
checkTimer = new QTimer(); // every time this triggers, the apt database is checked for new updates
|
||||||
trayIcon = new QSystemTrayIcon(); // this is shown to the user to offer updates
|
trayIcon = new QSystemTrayIcon(); // this is shown to the user to offer updates
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse the Lubuntu Update config file. It contains two critical pieces
|
||||||
|
* of info - when the system last offered the user a release upgrade,
|
||||||
|
* and whether the user has disabled release upgrade notifications.
|
||||||
|
*/
|
||||||
|
QFile configFile(QDir::homePath() + "/.config/lubuntu-update.conf");
|
||||||
|
bool success = configFile.open(QFile::ReadOnly);
|
||||||
|
if (success) {
|
||||||
|
char lineBuf[2048];
|
||||||
|
while (configFile.canReadLine()) {
|
||||||
|
configFile.readLine(lineBuf, 2048);
|
||||||
|
QString line(lineBuf);
|
||||||
|
line = line.trimmed();
|
||||||
|
QStringList lineParts = line.split("=");
|
||||||
|
if (lineParts.count() == 2) {
|
||||||
|
if (lineParts[0] == "nextDoReleaseUpgradeNotify") {
|
||||||
|
nextUpgradeCheck = QDateTime::fromSecsSinceEpoch(lineParts[1].toLongLong());
|
||||||
|
} else {
|
||||||
|
qWarning() << "Unrecognized config line: " << line;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qWarning() << "Wrong number of fields in line: " << line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connect(checkTimer, &QTimer::timeout, this, &Orchestrator::checkForUpdates);
|
connect(checkTimer, &QTimer::timeout, this, &Orchestrator::checkForUpdates);
|
||||||
connect(trayIcon, &QSystemTrayIcon::activated, this, &Orchestrator::displayUpdater);
|
connect(trayIcon, &QSystemTrayIcon::activated, this, &Orchestrator::displayUpdater);
|
||||||
connect(&updaterWindow, &MainWindow::updatesInstalled, this, &Orchestrator::handleUpdatesInstalled);
|
connect(&updaterWindow, &MainWindow::updatesInstalled, this, &Orchestrator::handleUpdatesInstalled);
|
||||||
@ -65,3 +94,46 @@ void Orchestrator::handleUpdatesRefreshed()
|
|||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
displayUpdater();
|
displayUpdater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Orchestrator::onNewReleaseAvailable(QStringList releaseCodes)
|
||||||
|
{
|
||||||
|
// First, determine what kinds of releases the user wants to see.
|
||||||
|
QFile druTypeFile("/etc/update-manager/release-upgrades");
|
||||||
|
bool success = druTypeFile.open(QFile::ReadOnly);
|
||||||
|
QString druType;
|
||||||
|
if (success) {
|
||||||
|
char lineBuf[2048];
|
||||||
|
while (druTypeFile.canReadLine()) {
|
||||||
|
druTypeFile.readLine(lineBuf, 2048);
|
||||||
|
QString line(lineBuf);
|
||||||
|
line = line.trimmed();
|
||||||
|
if (line == "Prompt=lts") {
|
||||||
|
druType="lts";
|
||||||
|
druTypeFile.close();
|
||||||
|
break;
|
||||||
|
} else if (line == "Prompt=none") {
|
||||||
|
// The user has disabled all upgrade prompts.
|
||||||
|
druTypeFile.close();
|
||||||
|
return;
|
||||||
|
} else if (line == "Prompt=normal") {
|
||||||
|
druType="normal";
|
||||||
|
druTypeFile.close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0;i < releaseCodes.count();i++) {
|
||||||
|
QStringList releaseCodeParts = releaseCodes[i].split('.');
|
||||||
|
if (releaseCodeParts.count() >= 2) {
|
||||||
|
int releaseYear = releaseCodeParts[0].toInt();
|
||||||
|
int releaseMonth = releaseCodeParts[1].toInt();
|
||||||
|
if (((releaseYear % 2 == 0) && (releaseMonth == 4)) || druType == "normal") {
|
||||||
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
if (nextUpgradeCheck < now) {
|
||||||
|
// TODO: attempt to show window here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
@ -22,12 +23,14 @@ private slots:
|
|||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
void handleUpdatesInstalled();
|
void handleUpdatesInstalled();
|
||||||
void handleUpdatesRefreshed();
|
void handleUpdatesRefreshed();
|
||||||
|
void onNewReleaseAvailable(QStringList releaseCodes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer *checkTimer;
|
QTimer *checkTimer;
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
QList<QStringList> updateInfo;
|
QList<QStringList> updateInfo;
|
||||||
MainWindow updaterWindow;
|
MainWindow updaterWindow;
|
||||||
|
QDateTime nextUpgradeCheck;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ORCHESTRATOR_H
|
#endif // ORCHESTRATOR_H
|
||||||
|
33
src/releaseupgradewindow.cpp
Normal file
33
src/releaseupgradewindow.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include "releaseupgradewindow.h"
|
||||||
|
#include "ui_releaseupgradewindow.h"
|
||||||
|
|
||||||
|
ReleaseUpgradeWindow::ReleaseUpgradeWindow(QString releaseCode, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::ReleaseUpgradeWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->upgradeLabel->setText(tr("An upgrade to Lubuntu %1 is available! Would you like to install this upgrade now?").arg(releaseCode));
|
||||||
|
connect(ui->upgradeButton, &QPushButton::clicked, this, &ReleaseUpgradeWindow::onUpgradeClicked);
|
||||||
|
connect(ui->remindButton, &QPushButton::clicked, this, &ReleaseUpgradeWindow::onRemindClicked);
|
||||||
|
connect(ui->declineButton, &QPushButton::clicked, this, &ReleaseUpgradeWindow::onDeclineClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseUpgradeWindow::~ReleaseUpgradeWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReleaseUpgradeWindow::onUpgradeClicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReleaseUpgradeWindow::onRemindClicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReleaseUpgradeWindow::onDeclineClicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
27
src/releaseupgradewindow.h
Normal file
27
src/releaseupgradewindow.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef RELEASEUPGRADEWINDOW_H
|
||||||
|
#define RELEASEUPGRADEWINDOW_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ReleaseUpgradeWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReleaseUpgradeWindow : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ReleaseUpgradeWindow(QString releaseCode, QWidget *parent = nullptr);
|
||||||
|
~ReleaseUpgradeWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onUpgradeClicked();
|
||||||
|
void onRemindClicked();
|
||||||
|
void onDeclineClicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::ReleaseUpgradeWindow *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RELEASEUPGRADEWINDOW_H
|
66
src/releaseupgradewindow.ui
Normal file
66
src/releaseupgradewindow.ui
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ReleaseUpgradeWindow</class>
|
||||||
|
<widget class="QDialog" name="ReleaseUpgradeWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>393</width>
|
||||||
|
<height>74</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="upgradeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>upgrade available</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>6</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="upgradeButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Upgrade Now</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="remindButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remind me later</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="declineButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Decline Upgrade</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
x
Reference in New Issue
Block a user