Coder Social home page Coder Social logo

qsimpleupdater's Introduction

QSimpleUpdater

Build Status

QSimpleUpdater is an implementation of an auto-updating system to be used with Qt projects. It allows you to easily check for updates, download them and install them. Additionally, the QSimpleUpdater allows you to check for updates for different "modules" of your application. Check the FAQ for more information.

Online documentation can be found here.

Downloading

Integrating QSimpleUpdater with your projects

  1. Copy the QSimpleUpdater folder in your "3rd-party" folder.
  2. Include the QSimpleUpdater project include (pri) file using the include() function.
  3. That's all! Check the tutorial project as a reference for your project.

FAQ

1. How does the QSimpleUpdater check for updates?

The QSimpleUpdater downloads an update definition file stored in JSON format. This file specifies the latest version, the download links and changelogs for each platform (you can also register your own platform easily if needed).

After downloading this file, the library analyzes the local version and the remote version. If the remote version is greater than the local version, then the library infers that there is an update available and notifies the user.

An example update definition file can be found here.

2. Can I customize the update notifications shown to the user?

Yes! You can "toggle" which notifications to show using the library's functions or re-implement by yourself the notifications by "reacting" to the signals emitted by the QSimpleUpdater.

QString url = "https://MyBadassApplication.com/updates.json";

QSimpleUpdater::getInstance()->setNotifyOnUpdate (url, true);
QSimpleUpdater::getInstance()->setNotifyOnFinish (url, false);

QSimpleUpdater::getInstance()->checkForUpdates (url);

3. Is the application able to download the updates directly?

Yes. If there is an update available, the library will prompt the user if he/she wants to download the update. You can enable or disable the integrated downloader with the following code:

QString url = "https://MyBadassApplication.com/updates.json";
QSimpleUpdater::getInstance()->setDownloaderEnabled (url, true);

4. Why do I need to specify an URL for each function of the library?

The QSimpleUpdater allows you to use different updater instances, which can be accessed with the URL of the update definitions. While it is not obligatory to use multiple updater instances, this can be useful for applications that make use of plugins or different modules.

Say that you are developing a game, in this case, you could use the following code:

// Update the game textures
QString textures_url = "https://MyBadassGame.com/textures.json"
QSimpleUpdater::getInstance()->setModuleName    (textures_url, "textures");
QSimpleUpdater::getInstance()->setModuleVersion (textures_url, "0.4");
QSimpleUpdater::getInstance()->checkForUpdates  (textures_url);

// Update the game sounds
QString sounds_url = "https://MyBadassGame.com/sounds.json"
QSimpleUpdater::getInstance()->setModuleName    (sounds_url, "sounds");
QSimpleUpdater::getInstance()->setModuleVersion (sounds_url, "0.6");
QSimpleUpdater::getInstance()->checkForUpdates  (sounds_url);

// Update the client (name & versions are already stored in qApp)
QString client_url = "https://MyBadassGame.com/client.json"
QSimpleUpdater::getInstance()->checkForUpdates (client_url);

License

QSimpleUpdater is free and open-source software, it is released under the MIT license.

qsimpleupdater's People

Contributors

alex-spataru avatar dail8859 avatar darktorres avatar essgeeeich avatar gmolini avatar itzurabhi avatar l-super avatar ultravires avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qsimpleupdater's Issues

Could I update the Qt dll by this library?

Thanks for sharing this cool library.

Operating is windows, Qt version is Qt5.6

The case is, I shift my app in a folder with Qt5 dll
I believe QSimpleUpdater will need dll of Qt5 to run
Could QSimpleUpdater able to update(replace) the dll under this case?

Edit :

The solution I am considering are

1 : use QSimpleUpdater to download all of the dll + exe(updater) from the url
2 : start the updater
3 : close the running application(myApp)
4 : updater copy the dll into the folder of myApp
5 : start myApp
6 : myApp detect the folder of updater
7 : delete the folder of updater

Problem downloading zip file

Hi, basically i wanted to update the whole application with a github release link.
My json is configured properly, with the link being:
https://github.com/devolution2409/Lidl-Soundboard/releases/download/1.1.2/LIDL_Soundboard.zip

If i try to download the zip through the QSimpleUpdater, it will download a 1KB corrupted zip.
However, if i set QSimpleUpdater::getInstance()->setDownloaderEnabled(url,false);

The link will be opened in the default browser, and it will correctly download the 9MB file.

Am i doing something wrong?
Thanks in advance

Updater doesn't properly follow redirects

Windows 10
Qt 5.15.2
MSVC 2019 64-bit

I'm attempting to use this project and download an exe from a Github release (specifically https://github.com/dail8859/NotepadNext/releases/download/v0.4.1/NotepadNext-v0.4.1-Installer.exe). However when using this project as is, it downloads a 0 byte file, and also seems kick off two different downloads (two prompts for Click "OK" to begin installing the update).

As issues in this repo seem to indicate, this is related to network redirects. The example project in this repo does not have the issue since it directly accesses a URL with no redirect (i.e. https://raw.githubusercontent.com/alex-spataru/QSimpleUpdater/master/tutorial/download/YesItWorks.jpg)

Related issues: #13, #11
Probably related: #26

I've made some minor changes that seems to fix the immediate issue. I can create a PR if needed but I'll at least describe the changes if you want to make them directly.

Right after request is created:

QNetworkRequest request(url);

The policy needs set to follow redirects.

request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);

Also, to prevent the multiple downloads, this line needs removed:

connect(m_reply, SIGNAL(redirected(QUrl)), this, SLOT(startDownload(QUrl)));


No idea if this works on Qt6+

[improve] True filename

Use ContentDispositionHeader get filename.

connect( m_reply, SIGNAL( metaDataChanged() ), this,
             SLOT( metaDataChanged() ) );
void Downloader::metaDataChanged() {
    QString  filename;
    QVariant variant =
        m_reply->header( QNetworkRequest::ContentDispositionHeader );
    if ( variant.isValid() ) {
        QString contentDisposition =
            QByteArray::fromPercentEncoding( variant.toByteArray() )
                .constData();
        QRegularExpression      regExp( "(.*)filename=\"(?<filename>.*)\"" );
        QRegularExpressionMatch match = regExp.match( contentDisposition );
        if ( match.hasMatch() ) {
            filename = match.captured( "filename" );
        }
        if ( filename.isEmpty() ) {
            filename = "KapokUpdate.bin";
        }
        setFileName( filename );
    }
}

Issue downloading update on Windows

The test for download finished should be:
if (received >= total && total > 0 && this->m_reply->isFinished())
and not just:
if (received >= total && total > 0)
in the void Downloader::saveFile (qint64 received, qint64 total) function.

In my case I am not sure if there was a redirection or something, but the file was not downloading because of that on Windows. On Mac OS it was fine.

UnknownContentError in Update response

With Qt5.7 and Win10, QNetworkRequest(url()) returns UnknownContentError. To ensure response is correctly received, need to set user-agent string before making the request. Would be good to expose an API for it, or use some default string (like Mozilla/*).

Local file update

Hi! thanks for the great project!
I was wondering if it was possible to make the updater use a local updates.json that has a reference to a zip file written on the disk instead of downloading it from an online source.

this is the situation:

-> QApplication Folder
      -> UpdateFolder
              -> updates.json
              -> update.zip
      -> app files

Is it possible to use the QSimpleUpdater in this situation?

thank you so much

[Feature Request] CMake project support

I noticed that QSimpleUpdater supports project include in QMake projects, but a CMakeLists.txt isn't provided.
CMake is currently the recommended build system for new Qt projects, and I believe it would be more convinient for CMake users if they can include the project from a CMake package, instead of including the source files manually.

Unintentionally left semicolon

It seems like there's a dangling semicolon in this line:

uint difference = QDateTime::currentDateTime().toSecsSinceEpoch(); - m_startTime;
This might cause a wrong difference time calculation.

uint difference = QDateTime::currentDateTime().toSecsSinceEpoch(); - m_startTime;

Use with CMake project?

I tried including all the .h,.cpp,.ui and qrc in my cmake. It let me include the header and QSimpleUpdater *m_updater; but I got linker errors on compile.

Is there any instructions for using this project with CMake? I'd like to give it a try!

Consider an OSI-approved license

The BDAD license is quite hilarious. Sadly it's not OSI-approved, which makes it difficult to use it in other projects or package software using this library in Linux distributions.
Would you consider changing the license to an OSI-approved license like MIT or BSD?

Thanks!

Listing in QSimpleUpdater

Out of curiosity I just installed QSimpleUpdater with a single click through QtPods and it worked right out of the box. Would you mind if I list it as a package?

How to update some modules only?

This program is wonderful, and easy to use. But what if I want to update some modules of my installed program? It seems the QSimpleUpdater is just download and run the downloaded file?

And I want to download and replace the local files, can you write a guide or give some help? Thanks.

Qt Marketplace integration

Greetings to all project watchers (and happy new year),

I would like to integrate this library with Qt Marketplace, so that more Qt users would be able to use this library with their projects. However, I haven't really worked on improving/maintaining this library in the last two years (I was really busy with college, work & other projects). AFAIK, QSimpleUpdater still works for my projects, however, this may not be true for all users.

Before submitting a request with the Qt folks, I would like to know your opinions regarding this library, specifically:

  • Have you encountered any issues with the latest commit(s)?
  • Should we update/improve existing functionality?
  • What features should we add to the library?
  • What features should we remove from the library?
  • Should we add support for Qt 6 (or stick with Qt 5)?

Of course, any other opinions are very welcome. Hope everyone here is safe regarding the pandemic.

Custom JSON update

Hi! This project is pretty good, but I've got a one question. In case of custom JSON, there is no other way to do it, exclude to fork & re-write Updater::onReply function. Maybe the library contains other ways to do it?

Compile error with QT 5.5 and Visual Studio 2013

I get the following error building QSimpleUpdater:
cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\QSimpleUpdater.pdb -DUNICODE -DWIN32 -DQSU_SHARED -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I. -Iinclude -I..\..\..\..\Qt\5.5\Src\qtbase\include -I..\..\..\..\Qt\5.5\Src\qtbase\include\QtWidgets -I..\..\..\..\Qt\5.5\Src\qtbase\include\QtGui -I..\..\..\..\Qt\5.5\Src\qtbase\include\QtANGLE -I..\..\..\..\Qt\5.5\Src\qtbase\include\QtNetwork -I..\..\..\..\Qt\5.5\Src\qtbase\include\QtCore -Idebug -I. -I..\..\..\..\qt\5.5\src\qtbase\mkspecs\win32-msvc2013 -Fodebug\ @C:\Users\STEVEM~1\AppData\Local\Temp\nmCFBB.tmp Downloader.cpp src\Downloader.cpp(116) : error C2027: use of undefined type 'QDateTime' c:\qt\5.5\src\qtbase\include\qtcore\../../src/corelib/kernel/qmetatype.h(1873) : see declaration of 'QDateTime' src\Downloader.cpp(116) : error C2228: left of '.toTime_t' must have class/struct/union type is 'unknown-type' src\Downloader.cpp(116) : error C3861: 'currentDateTime': identifier not found src\Downloader.cpp(340) : error C2027: use of undefined type 'QDateTime' c:\qt\5.5\src\qtbase\include\qtcore\../../src/corelib/kernel/qmetatype.h(1873) : see declaration of 'QDateTime' src\Downloader.cpp(340) : error C2228: left of '.toTime_t' must have class/struct/union type is 'unknown-type' src\Downloader.cpp(340) : error C3861: 'currentDateTime': identifier not found NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\cl.EXE"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2' Stop.

I was able to fix it by adding #include <QDateTime> to Downloader.cpp. I would have created a pull request by I did not see a way to contribute to the project.

when i press check for update on my app i get this error qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No TLS backend is available
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No TLS backend is available
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No TLS backend is available
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No TLS backend is available
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: No functional TLS backend was found
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.