1414#endif
1515
1616
17+ /**
18+ * An unknown error occurred while updating. The update was not installed.
19+ * This is a catch-all for errors that don't fit into the other categories.
20+ */
21+ #define SHOREBIRD_UPDATE_ERROR -1
22+
23+ /**
24+ * No update is available (e.g. the app is already up-to-date)
25+ */
26+ #define SHOREBIRD_NO_UPDATE 0
27+
28+ /**
29+ * An update was installed successfully. It will boot from the update on the
30+ * next app launch.
31+ */
32+ #define SHOREBIRD_UPDATE_INSTALLED 1
33+
34+ /**
35+ * An error occurred while updating. The update was not installed.
36+ */
37+ #define SHOREBIRD_UPDATE_HAD_ERROR 2
38+
39+ /**
40+ * The downloaded patch was not installed because it was invalid.
41+ */
42+ #define SHOREBIRD_UPDATE_IS_BAD_PATCH 3
43+
1744/**
1845 * Struct containing configuration parameters for the updater.
1946 * Passed to all updater functions.
@@ -69,6 +96,11 @@ typedef struct FileCallbacks {
6996 void (* close )(void * file_handle );
7097} FileCallbacks ;
7198
99+ typedef struct UpdateResult {
100+ int32_t status ;
101+ const char * message ;
102+ } UpdateResult ;
103+
72104#ifdef __cplusplus
73105extern "C" {
74106#endif // __cplusplus
@@ -114,7 +146,9 @@ SHOREBIRD_EXPORT char *shorebird_next_boot_patch_path(void);
114146 * If this function is called with a non-null pointer, it must be a pointer
115147 * returned by the updater library.
116148 */
117- SHOREBIRD_EXPORT void shorebird_free_string (char * c_string );
149+ SHOREBIRD_EXPORT void shorebird_free_string (const char * c_string );
150+
151+ SHOREBIRD_EXPORT void shorebird_free_update_result (struct UpdateResult * result );
118152
119153/**
120154 * Check for an update. Returns true if an update is available.
@@ -126,6 +160,12 @@ SHOREBIRD_EXPORT bool shorebird_check_for_update(void);
126160 */
127161SHOREBIRD_EXPORT void shorebird_update (void );
128162
163+ /**
164+ * Synchronously download an update if one is available.
165+ * Returns an [UpdateResult] indicating whether the update was successful.
166+ */
167+ SHOREBIRD_EXPORT const struct UpdateResult * shorebird_update_with_result (void );
168+
129169/**
130170 * Start a thread to download an update if one is available.
131171 */
0 commit comments