More do-release-upgrade progress

ubuntu/noble
Aaron Rainbolt 11 months ago
parent 1821373141
commit d71a36f0ef

@ -38,6 +38,9 @@ set(PROJECT_SOURCES
src/conffilehandlerdialog.ui
src/ipcfilewatcher.h
src/ipcfilewatcher.cpp
src/releaseupgradewindow.h
src/releaseupgradewindow.cpp
src/releaseupgradewindow.ui
${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`.
## 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
* Double-clicking on a package doesn't show detailed information for it yet.

@ -144,7 +144,7 @@ void AptManager::handleUpdateProcessBuffer()
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.
while (!aptProcess->canReadLine()) {
QThread::msleep(20);
@ -152,14 +152,6 @@ void AptManager::handleUpdateProcessBuffer()
aptProcess->readLine(lineBuf, 2048);
QString ltsReleaseCode = QString(lineBuf);
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;

@ -152,14 +152,14 @@ elif [ "$1" = 'doupdate' ]; then
if [ -n "$nextLTSReleaseYear" ]; then
if isReleaseSupported "$nextLTSReleaseYear" "$nextLTSReleaseMonth" "$metaReleaseData"; then
echo 'Lubuntu Update !!! NEW LTS RELEASE';
echo 'Lubuntu Update !!! NEW RELEASE';
echo "$nextLTSReleaseYear.$nextLTSReleaseMonth";
fi
fi
if ! (((nextReleaseYear == nextLTSReleaseYear) && (nextReleaseMonth == nextLTSReleaseMonth))); then
if isReleaseSupported "$nextReleaseYear" "$nextReleaseMonth" "$metaReleaseData"; then
echo 'Lubuntu Update !!! NEW STABLE RELEASE';
echo 'Lubuntu Update !!! NEW RELEASE';
echo "$nextReleaseYear.$nextReleaseMonth";
fi
fi

@ -25,8 +25,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(aptManager, &AptManager::progressUpdated, this, &MainWindow::onProgressUpdate);
connect(aptManager, &AptManager::logLineReady, this, &MainWindow::onLogLineReady);
connect(aptManager, &AptManager::conffileListReady, this, &MainWindow::onConffileListReady);
connect(aptManager, &AptManager::newLtsRelease, this, &MainWindow::onNewLtsRelease);
connect(aptManager, &AptManager::newStableRelease, this, &MainWindow::onNewStableRelease);
connect(aptManager, &AptManager::newLtsRelease, this, &MainWindow::onNewRelease);
}
MainWindow::~MainWindow()
@ -179,19 +178,13 @@ void MainWindow::onConffileListReady(QStringList conffileList)
aptManager->doneWithConffiles();
}
void MainWindow::onNewLtsRelease(QString code)
void MainWindow::onNewRelease(QString code)
{
newLtsReleaseAvailable = true;
}
void MainWindow::onNewStableRelease(QString code)
{
newStableReleaseAvailable = true;
releaseCodes.append(code);
}
void MainWindow::handleNewReleases()
{
// TODO: Write code that informs the user when a new release is available here
newLtsReleaseAvailable = false;
newStableReleaseAvailable = false;
emit newReleaseAvailable(releaseCodes);
releaseCodes.clear();
}

@ -26,6 +26,7 @@ public:
signals:
void updatesInstalled();
void updatesRefreshed();
void newReleaseAvailable(QStringList releaseCodes);
protected slots:
void closeEvent(QCloseEvent *event) override;
@ -39,14 +40,12 @@ private slots:
void onProgressUpdate(int progress);
void onLogLineReady(QString logLine);
void onConffileListReady(QStringList conffileList);
void onNewLtsRelease(QString code);
void onNewStableRelease(QString code);
void onNewRelease(QString code);
private:
Ui::MainWindow *ui;
AptManager *aptManager;
bool newLtsReleaseAvailable = false;
bool newStableReleaseAvailable = false;
QStringList releaseCodes;
void handleNewReleases();
};

@ -2,6 +2,9 @@
#include "mainwindow.h"
#include "aptmanager.h"
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QIcon>
#include <QSystemTrayIcon>
#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
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(trayIcon, &QSystemTrayIcon::activated, this, &Orchestrator::displayUpdater);
connect(&updaterWindow, &MainWindow::updatesInstalled, this, &Orchestrator::handleUpdatesInstalled);
@ -65,3 +94,46 @@ void Orchestrator::handleUpdatesRefreshed()
checkForUpdates();
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 <QDateTime>
#include <QObject>
#include <QStringList>
@ -22,12 +23,14 @@ private slots:
void checkForUpdates();
void handleUpdatesInstalled();
void handleUpdatesRefreshed();
void onNewReleaseAvailable(QStringList releaseCodes);
private:
QTimer *checkTimer;
QSystemTrayIcon *trayIcon;
QList<QStringList> updateInfo;
MainWindow updaterWindow;
QDateTime nextUpgradeCheck;
};
#endif // ORCHESTRATOR_H

@ -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()
{
}

@ -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

@ -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…
Cancel
Save