PDA

View Full Version : automatic update example



nuliknol
24th February 2015, 20:40
Hi,
I have a client/server application. The server daemon is written in ansi C (gcc) and the Client app is written with QT 5.2
What I want to do, is the client to be auto-updatable. Lets say, current client version is 1.1.1 , when the next version comes up, say 1.1.2 , the client would check if there is any new version available for update, download the code and automatically update the application code.

Is there any example on how to do this ?
Or another question would be, how do I replace current class code with the new version of it ?

Will appreciate very much any help on this topic.

Regards
Nulik

jefftee
24th February 2015, 23:44
You didn't mention what platform(s) your app runs on. If it's Mac OSX, then Sparkle (http://sparkle-project.org/) is the definitive standard for apps to add auto-update functionality. There have been ports for Windows I believe, but not sure how widely adopted those are.

Rolling your own has been done been done many times of course and Qt offers the QNetwork* stuff that can simplify reading a file from a server to determine the latest available version of your application. The harder part to get right is the ability to install a new version of your app, terminate the running version, and start the newly installed version all without incident.

For your particular case, you'll want to make sure that you could auto-update the daemon to ensure it's compatible with the new client version, or else you will wind up with broken client/server interaction.

The way Sparkle works is that if downloads an XML file (RSS actually) that contains information about new version(s) of your program that are available. It then downloads the update and extracts it to a temporary version. There's a companion auto-update program that is then started which shuts down your running app and moves old version to the Trash and your newly unpacked temp version into the proper location, then launches your app again.

Hope that helps.

nuliknol
25th February 2015, 15:44
Thanks for you reply!
Yeah, I forgot to mention that the client side application is cross platform, for Windows, Linux, Mac OS and so on. Sparkle looks nice, but I guess I will have to write this functionality myself. So, the thing I need to do, is a copy of Sparkle , but cross platform, this way will avoid issues of replacing code at runtime, I would just terminate current program , launch "MySparkle", it would update the application libaries and relanuch it. Seems not so complicated.
Thanks again for the idea.
Regards

d_stranz
25th February 2015, 17:53
Google for WinSparkle. Written for Windoze, but comes with source code and may be cross-platform buildable.

atomic
25th February 2015, 19:46
Maybe Qt Installer Framework? http://doc.qt.io/qtinstallerframework/ifw-overview.html
I read that it can be used for updating app but I'm not sure.