From 9fbb99e298aed79ae6a6f968594604699bb6c35d Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 4 Nov 2021 22:11:56 +0200 Subject: Windows: Use WinSparkle for automatic updates --- src/updater.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/updater.h | 28 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 src/updater.c create mode 100644 src/updater.h diff --git a/src/updater.c b/src/updater.c new file mode 100644 index 00000000..6c5d6eae --- /dev/null +++ b/src/updater.c @@ -0,0 +1,86 @@ +/* Copyright 2021 Jaakko Keränen + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#include "updater.h" + +static const char *signaturePublicKeyPem_ = +"-----BEGIN PUBLIC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n" +"7btKMnYNL99cMAjhgyDyh7mAOfOWv5rAgzDIMViRO+U7EZ+ZRR+ovnuWMMn1OZAA\n" +"aXDKDVffI0NSO+Aw3EDAL4LfZsOBkDS2N/2ESR+EoBtYqoI7YJ3iu1iEHp8WxCyA\n" +"4YdR7KTyioKNHjvC5EG2bvHtYfw6ng6zSOY=\n" +"-----END PUBLIC KEY-----"; + +#if defined (LAGRANGE_ENABLE_WINSPARKLE) +#include +#include + +void init_Updater(void) { + win_sparkle_set_appcast_url("https://etc.skyjake.fi/lagrange/appcast-windows.xml"); + win_sparkle_set_dsa_pub_pem(signaturePublicKeyPem_); + win_sparkle_init(); +} + +void deinit_Updater(void) { + win_sparkle_cleanup(); +} + +void checkNow_Updater(void) { + win_sparkle_check_update_with_ui(); +} + +#else +/* dummy as a fallback */ +void init_Updater(void) {} +void deinit_Updater(void) {} +void checkNow_Updater(void) {} +#endif diff --git a/src/updater.h b/src/updater.h new file mode 100644 index 00000000..00cb8b7f --- /dev/null +++ b/src/updater.h @@ -0,0 +1,28 @@ +/* Copyright 2021 Jaakko Keränen + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +#pragma once + +void init_Updater (void); +void deinit_Updater (void); + +void checkNow_Updater (void); -- cgit v1.2.3