Skip to content

Commit

Permalink
Qt Plugin: use Application name instead of AppImage filename if given.
Browse files Browse the repository at this point in the history
  • Loading branch information
antony-jr committed Mar 10, 2021
1 parent a93e268 commit 04737aa
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 6 deletions.
10 changes: 10 additions & 0 deletions docs/ClassQAppImageUpdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ All methods in this class is [reentrant](https://doc.qt.io/qt-5/threads-reentran
| **void** | [setIcon(QByteArray)](#void-seticonqbytearray-icon) |
| **void** | [start(short)](#void-startshort-action) |
| **void** | [cancel()](#void-cancel) |
| **void** | [setApplicationName(const QString&)](#void-setapplicationname-qstring) |
| **void** | [setAppImage(const QString&)](#void-setappimageconst-qstring) |
| **void** | [setAppImage(QFile \*)](#void-setappimageqfile-) |
| **void** | [setShowLog(bool)](#void-setshowlogbool) |
Expand Down Expand Up @@ -199,6 +200,15 @@ Cancels the update.
Emits **canceled(short action)** signal when cancel was successfull.


### void setApplicationName(const QString&)
<p align="right"> <code>[SLOT]</code> </p>

Set a application name to use when display GUI dialogs if required.

> NOTE: This is optional. By default the GUI dialogs uses the AppImage filename.


### void setAppImage(const QString&)
<p align="right"> <code>[SLOT]</code> </p>

Expand Down
10 changes: 10 additions & 0 deletions docs/PluginInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ I'm not sure about other Qt bindings, So help is much welcomed.
| [setIcon(QByteArray)](#seticonqbytearray-icon) | Set Icon for GUI Update. |
| [start(short)](#startshort-action) | Starts the given action. |
| [cancel()](#cancel) | Cancels current update process. |
| [setApplicationName(QString)](#setapplicationnameqstring) | Sets the Application Name in GUI dialogs. |
| [setAppImagePath(QString)](#setappimagepathqstring) | Assume the given string as path to AppImage to update. |
| [setAppImageFile(QFile\*)](#setappimagefileqfile) | Assume the given QFile as the AppImage to update. |
| [setShowLog(bool)](#setshowlogbool) | If the given boolean is true then prints log. |
Expand Down Expand Up @@ -170,6 +171,15 @@ One has to use **getConstant(QString)** method to get a constant.
Cancels the current action.
Emits **canceled(short)** signal when cancel for a action was successfull.


### setApplicationName(QString)
<p align="right"> <code>[SLOT]</code> </p>

Sets the given string as the Application Name which will be used in GUI dialogs.

> NOTE: This is optional and by default the updater uses the AppImage filename.

### setAppImagePath(QString)
<p align="right"> <code>[SLOT]</code> </p>

Expand Down
1 change: 1 addition & 0 deletions include/qappimageupdateinterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class QAppImageUpdateInterface {
public Q_SLOTS:
virtual void setApplicationName(const QString&) = 0;
virtual void setGuiFlag(int) = 0;
virtual void setIcon(QByteArray) = 0;
virtual void setAppImagePath(const QString&) = 0;
Expand Down
1 change: 1 addition & 0 deletions include/qappimageupdateinterfaceimpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class QAppImageUpdateInterfaceImpl : public QObject, QAppImageUpdateInterface {
QAppImageUpdateInterfaceImpl(QObject *parent = nullptr);
~QAppImageUpdateInterfaceImpl();
public Q_SLOTS:
void setApplicationName(const QString&);
void setIcon(QByteArray);
void setGuiFlag(int);
void setAppImagePath(const QString&);
Expand Down
73 changes: 73 additions & 0 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Run it like so,
# docker run -v $PWD:/docker-share -it ubuntu:xenial bash scripts/docker_build.sh
# To get libQAppImageUpdate.so Qt Plugin.

# Install dependencies
apt update
apt upgrade -y
apt install software-properties-common build-essential libarchive13 libarchive-dev wget expat -y
add-apt-repository ppa:beineri/opt-qt563-xenial -y
apt-get update -qq
apt install libgl1-mesa-dev xvfb qt56base -y

cd /docker-share/
rm -rf build
mkdir build
cd build

# Build OpenSSL Static version
wget "https://www.openssl.org/source/openssl-1.1.1j.tar.gz"
tar -xf openssl-1.1.1j.tar.gz
cd openssl-1.1.1j
./config no-shared --prefix=/usr/ --openssldir=/usr/
make -j$(nproc)
make install -j$(nproc)
cd ..

# Install CURL
wget "https://curl.se/download/curl-7.75.0.tar.gz"
tar -xf curl-7.75.0.tar.gz
cd curl-7.75.0
,/configure
make -j$(nproc)
make install -j$(nproc)
cd ..

# Install CMake 3.19.6
wget "https://github.com/Kitware/CMake/releases/download/v3.19.6/cmake-3.19.6.tar.gz"
tar -xf cmake-3.19.6.tar.gz
cd cmake-3.19.6
./bootstrap
make -j$(nproc)
make install -j$(nproc)
cd ..

# Install Boost libraries
wget "https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz"
tar -xf boost_1_75_0.tar.gz
cd boost_1_75_0
./bootstrap.sh
cp b2 /usr/bin/
echo "using gcc ;" > ~/user-config.jam
export BOOST_ROOT=$PWD
export BOOST_BUILD_PATH=$PWD/tools/build
BOOST_ROOT=$PWD BOOST_BUILD_PATH=$PWD/tools/build b2 cxxflags="-std=c++14" variant=release link=static install -j$(nproc) --with-system --with-chrono --with-random > /dev/null
cd ..

# Install Torrent Rasterbar
wget "https://github.com/arvidn/libtorrent/releases/download/libtorrent-1.2.8/libtorrent-rasterbar-1.2.8.tar.gz"
tar -xvf libtorrent-rasterbar-1.2.8.tar.gz
cd libtorrent-rasterbar-1.2.8
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON .
make -j$(nproc)
make install -j$(nproc)
cd ..

# Now Build QAppImageUpdate Qt Plugin.
source /opt/qt56/bin/qt56-env.sh
cmake -DDECENTRALIZED_UPDATE_ENABLED=ON -DBUILD_AS_PLUGIN=ON ..
make -j$(nproc)

cp libQAppImageUpdate.* ..
cd ..
rm -rf build
16 changes: 10 additions & 6 deletions src/qappimageupdate_p.cc
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,9 @@ void QAppImageUpdatePrivate::handleGUIUpdateCheck(QJsonObject info) {
bool showNoUpdateDialog = n_GuiFlag & GuiFlag::NotifyWhenNoUpdateIsAvailable;
bool noConfirmTorrentUsage = n_GuiFlag & GuiFlag::NoConfirmTorrentUsage;
m_UpdaterDialog->setWindowTitle(QString::fromUtf8("Updating ") +
QFileInfo(localAppImagePath).baseName());
(m_ApplicationName.isEmpty() ?
QFileInfo(localAppImagePath).baseName() :
m_ApplicationName));

bool isUpdateAvailable = (localAppImageSHA1Hash != remoteTargetFileSHA1Hash);

Expand All @@ -886,7 +888,8 @@ void QAppImageUpdatePrivate::handleGUIUpdateCheck(QJsonObject info) {
box.setText(
QString::fromUtf8(
"It seems that the author of ") +
QFileInfo(localAppImagePath).baseName() +
(m_ApplicationName.isEmpty() ? QFileInfo(localAppImagePath).baseName() :
m_ApplicationName) +
QString::fromUtf8(" supports decentralized update via Bittorrent.") +
QString::fromUtf8(
" Do you agree to <b>use Bittorrent for decentralized update?</b> This is completely optional.") +
Expand Down Expand Up @@ -923,8 +926,9 @@ void QAppImageUpdatePrivate::handleGUIUpdateCheck(QJsonObject info) {
QMessageBox box(m_UpdaterDialog.data());
box.setWindowTitle(QString::fromUtf8("No Updates Available!"));
box.setText(
QString::fromUtf8("You are currently using the lastest version of ") +
QFileInfo(localAppImagePath).fileName() +
QString::fromUtf8("You are currently using the lastest version of ") +\
(m_ApplicationName.isEmpty() ? QFileInfo(localAppImagePath).fileName()
: m_ApplicationName ) +
QString::fromUtf8("."));
box.exec();
}
Expand Down Expand Up @@ -1135,7 +1139,7 @@ void QAppImageUpdatePrivate::handleGUIUpdateError(short ecode) {
box.setWindowTitle(QString::fromUtf8("Update Failed"));
box.setIcon(QMessageBox::Critical);
box.setText(QString::fromUtf8("Update failed for '") +
QFileInfo(m_CurrentAppImagePath).fileName() +
(m_ApplicationName.isEmpty() ? QFileInfo(m_CurrentAppImagePath).fileName() : m_ApplicationName) +
QString::fromUtf8("': ") + errorString);
box.exec();
}
Expand Down Expand Up @@ -1223,7 +1227,7 @@ void QAppImageUpdatePrivate::handleGUIUpdateFinished(QJsonObject info, QString o
QString::fromUtf8("New version is saved at: ") +
result["NewVersionPath"].toString());
box.setText(QString::fromUtf8("Update completed successfully for <b>") +
currentAppImageName +
(m_ApplicationName.isEmpty() ? currentAppImageName : m_ApplicationName) +
QString::fromUtf8("</b>, do you want to launch the new version? View details for more information."));
box.addButton(QMessageBox::Yes);
box.addButton(QMessageBox::No);
Expand Down
4 changes: 4 additions & 0 deletions src/qappimageupdateinterfaceimpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ QAppImageUpdateInterfaceImpl::QAppImageUpdateInterfaceImpl(QObject *parent)
QAppImageUpdateInterfaceImpl::~QAppImageUpdateInterfaceImpl() {
}

void QAppImageUpdateInterfaceImpl::setApplicationName(const QString &a) {
m_Private->setApplicationName(a);
}

void QAppImageUpdateInterfaceImpl::setIcon(QByteArray icon) {
m_Private->setIcon(icon);
}
Expand Down

0 comments on commit 04737aa

Please sign in to comment.