forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Windows): integrate WinSparkle autoupdate framework (onivim#2497)
* Vendor: vendor WinSparkle 0.7.0 * [Broken] Sparkle: bind to WinSparkle * Sparkle: integrate WinSparkle * Release.js: prettier * Release.js: ENV fix for shell on Windows * Setup Template: remove skipifsilent * Sparkle: separate Sparkle and WinSparkle * Release.js: return output from winShell * WinSparkle: hookup close callback * Release.js: prettier * WinSparkle: move Windows-specific includes under ifdef * WinSparkle: remove unused variable * Revert whitespace changes * WinSparkle: copy URL string from OCaml * ThirdPartyLicenses: add Sparkle and WinSparkle * WinSparkle: use CAML alloc functions to move string * WinSparkle: use more up-to-date OCaml FFI functions Co-authored-by: Bryan Phelps <[email protected]> Co-authored-by: Bryan Phelps <[email protected]>
- Loading branch information
1 parent
1c28993
commit fed99ec
Showing
25 changed files
with
1,157 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
let init: unit => unit; | ||
|
||
module Updater: { | ||
type t; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#include "config.h" | ||
|
||
#include <caml/alloc.h> | ||
#include <caml/callback.h> | ||
#include <caml/memory.h> | ||
#include <caml/mlvalues.h> | ||
#include <caml/threads.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#ifdef USE_WIN_SPARKLE | ||
|
||
#include <windows.h> | ||
#include <shlwapi.h> | ||
|
||
#include "winsparkle.h" | ||
|
||
void oni2_WinSparkleCloseCallback() { | ||
static const value *closeCallback; | ||
if (closeCallback == NULL) { | ||
closeCallback = caml_named_value("oni2_close"); | ||
} | ||
|
||
if (closeCallback != NULL) { | ||
caml_c_thread_register(); | ||
caml_acquire_runtime_system(); | ||
caml_callback(*closeCallback, Val_unit); | ||
caml_release_runtime_system(); | ||
} | ||
} | ||
|
||
CAMLprim value oni2_SparkleInit() { | ||
CAMLparam0(); | ||
|
||
char iniPath[MAX_PATH]; | ||
|
||
GetModuleFileName(NULL, iniPath, MAX_PATH); | ||
PathRemoveFileSpec(iniPath); | ||
|
||
strcat(iniPath, "\\Oni2.ini"); | ||
char version[16]; | ||
wchar_t versionWide[16]; | ||
|
||
|
||
GetPrivateProfileString("Application", "Version", "", version, 16, iniPath); | ||
|
||
mbstowcs(versionWide, version, 16); | ||
|
||
win_sparkle_set_app_details(L"Outrun Labs LLC", L"Onivim 2", versionWide); | ||
win_sparkle_set_shutdown_request_callback(oni2_WinSparkleCloseCallback); | ||
win_sparkle_init(); | ||
|
||
CAMLreturn(Val_unit); | ||
} | ||
|
||
// On WinSparkle, there is no instance -- the library just uses global variables. | ||
// So here we just return a basic `unit` | ||
CAMLprim value oni2_SparkleGetSharedInstance() { | ||
CAMLparam0(); | ||
|
||
CAMLreturn(Val_unit); | ||
} | ||
|
||
// This function doesn't make too much sense since we lose the OOP aspect on | ||
// Windows, so it's basically a noop. | ||
CAMLprim value oni2_SparkleDebugToString(value vData) { | ||
CAMLparam1(vData); | ||
CAMLlocal1(vStr); | ||
|
||
vStr = caml_copy_string("Unimplemented"); | ||
|
||
CAMLreturn(vStr); | ||
} | ||
|
||
// Again, this function doesn't make much sense on Windows, so it's a noop. | ||
CAMLprim value oni2_SparkleDebugLog(value vData) { | ||
CAMLparam1(vData); | ||
|
||
CAMLreturn(Val_unit); | ||
} | ||
|
||
CAMLprim value oni2_SparkleSetFeedURL(value vUpdater, value vUrlStr) { | ||
CAMLparam2(vUpdater, vUrlStr); | ||
|
||
char *urlStr = caml_stat_strdup(String_val(vUrlStr)); | ||
|
||
win_sparkle_set_appcast_url(urlStr); | ||
|
||
CAMLreturn(Val_unit); | ||
} | ||
|
||
CAMLprim value oni2_SparkleGetFeedURL(value vUpdater) { | ||
CAMLparam1(vUpdater); | ||
CAMLlocal1(vStr); | ||
|
||
vStr = caml_copy_string("Unimplemented"); | ||
|
||
CAMLreturn(vStr); | ||
} | ||
|
||
CAMLprim value oni2_SparkleSetAutomaticallyChecksForUpdates(value vUpdater, value vChecks) { | ||
CAMLparam2(vUpdater, vChecks); | ||
|
||
win_sparkle_set_automatic_check_for_updates(Bool_val(vChecks)); | ||
|
||
CAMLreturn(Val_unit); | ||
} | ||
|
||
CAMLprim value oni2_SparkleGetAutomaticallyChecksForUpdates(value vUpdater) { | ||
CAMLparam1(vUpdater); | ||
|
||
int checks = win_sparkle_get_automatic_check_for_updates(); | ||
|
||
CAMLreturn(Val_bool(checks)); | ||
} | ||
|
||
CAMLprim value oni2_SparkleCheckForUpdates(value vUpdater) { | ||
CAMLparam1(vUpdater); | ||
|
||
win_sparkle_check_update_with_ui(); | ||
|
||
CAMLreturn(Val_unit); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Maintainer: | ||
|
||
Vaclav Slavik <[email protected]> | ||
|
||
|
||
Contributors: | ||
|
||
Kohan Ikin <[email protected]> | ||
Christian L. Jacobsen <[email protected]> | ||
Littleboy <[email protected]> | ||
Vasco Veloso | ||
Jonas Emanuel Mueller <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright (c) 2009-2020 Vaclav Slavik | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
||
|
||
|
||
This product includes software developed by the OpenSSL Project | ||
for use in the OpenSSL Toolkit (http://www.openssl.org/). |
Oops, something went wrong.