| 1 | # AutoUpdate Overview |
| 2 | Dolphin's autoupdate procedure is spread through a number of files; this overview describes the |
| 3 | update flow. |
| 4 | |
| 5 | ## General notes: |
| 6 | * The updater is only supported on Windows and MacOS. |
| 7 | * There are four update frequency tracks: Dev (updated every commit), Beta (a few times a year), |
| 8 | Stable (very rarely), and Disabled. |
| 9 | * Applications can't overwrite themselves so a separate application is responsible for actually |
| 10 | updating the Dolphin executable and other files. |
| 11 | * The updater application needs to be able to also update itself, so it creates a copy which |
| 12 | updates both Dolphin and the original updater. Every time Dolphin launches it deletes the |
| 13 | updater copy (if it exists). |
| 14 | |
| 15 | ## Class and file responsibilities: |
| 16 | * AutoUpdateChecker (UICommon/AutoUpdate.h): Checks if an update is available. |
| 17 | * Verifies the updater is supported on the user's platform and hasn't been disabled. |
| 18 | * Retrieves new version information from the update server. |
| 19 | * Copies the updater application and launches the copy. |
| 20 | * Updater (DolphinQt/Updater.h): Serves as the interface between AutoUpdateChecker and Qt. |
| 21 | * Spawns a background thread when Dolphin launches that calls AutoUpdateChecker. |
| 22 | * Creates the update prompt window when an update is available. |
| 23 | * If the user wants to update now, closes Dolphin. |
| 24 | * MacUpdater/main.m and MacUpdater/AppDelegate.mm: Entry point to MacOS updater. |
| 25 | * Converts command line arguments to vector\<string\> and passes them to |
| 26 | UpdaterCommon::RunUpdate(). |
| 27 | * WinUpdater/main.cpp: Entry point to Windows updater. |
| 28 | * Converts command line arguments to vector\<string\>. |
| 29 | * Checks if updater has write access to the Dolphin executable directory. If not, attempts |
| 30 | to relaunch itself with admin privileges (creating a User Account Control prompt). |
| 31 | * Passes argument vector to UpdaterCommon::RunUpdate(). |
| 32 | * UpdaterCommon/UpdaterCommon.cpp: Performs the actual update process. |
| 33 | * Manages updater UI. |
| 34 | * Fetches file manifests from update server for current and new versions. |
| 35 | * Calculates file diff between versions. |
| 36 | * Downloads and adds/replaces changed files and deletes removed files. |
| 37 | * Verifies file hashes. |
| 38 | * If the user updated immediately (rather than waiting for Dolphin to close before starting |
| 39 | the update), starts Dolphin again when the update is complete. |
| 40 | |
| 41 | ## Update flow: |
| 42 | * An update check is started in one of two ways: |
| 43 | * When Dolphin is launched (unless in NoGUI or batch mode): |
| 44 | * In main.cpp an instance of Updater is created and invokes start(), which is inherited |
| 45 | from QThread and creates a new thread which performs the check off the main thread. |
| 46 | * QThread::start() calls run() which is overridden in Updater and calls |
| 47 | AutoUpdateChecker::CheckForUpdate(). |
| 48 | * When the user selects Help -> "Check for Updates..." in the main menu: |
| 49 | * The menu option runs a callback to MenuBar::InstallUpdateManually(). |
| 50 | * The Config value for the update track is backed up to a temporary variable, then |
| 51 | overwritten with "dev" to force a check for the latest version. After the check |
| 52 | completes the original Config value is restored. |
| 53 | * Updater::CheckForUpdate() is called, which calls AutoUpdateChecker::CheckForUpdate(). |
| 54 | * AutoUpdateChecker::CheckForUpdate() checks if the selected track has a new version available. |
| 55 | * If not the check ends. If the user started it, returns to Updater::CheckForUpdate() which |
| 56 | tells the user they're up to date. |
| 57 | * Information about the update is passed to OnUpdateAvailable(), which is overridden by Updater. |
| 58 | * OnUpdateAvailable() creates a window displaying the update changelog and asks the user if they |
| 59 | want to update now, update after Dolphin closes, not update, or never auto-update. |
| 60 | * If the user wants to update AutoUpdateChecker::TriggerUpdate() is called. |
| 61 | * TriggerUpdate() builds the command line arguments for the updater process, creates a copy of |
| 62 | the updater executable, then runs the copy in a new process. |
| 63 | * TriggerUpdate() returns to OnUpdateAvailable(). If the user chose to update now, Dolphin's |
| 64 | main window is closed which results in the Dolphin process ending. |
| 65 | * The updater process begins. |
| 66 | * On MacOS (starts main() in MacUpdater/main.m): |
| 67 | * Checks that the process received command line arguments. If not it tells the user the |
| 68 | updater can't be launched directly and quits. |
| 69 | * Calls NSApplicationMain(), which passes control to the AppDelegate defined in |
| 70 | MacUpdater/AppDelegate.mm. |
| 71 | * The command line arguments are converted to a vector\<string\> |
| 72 | and passed to RunUpdater() in UpdaterCommon.h. |
| 73 | * On Windows (starts wWinMain() in WinUpdater/Main.cpp): |
| 74 | * Checks that the process received command line arguments. If not it tells the user the |
| 75 | updater can't be launched directly and quits. |
| 76 | * Attempts to open Updater.log in the same directory as Dolphin.exe. If this fails, |
| 77 | checks to see if the process has admin privileges. |
| 78 | * If not, attempts to relaunch the updater as admin. This will spawn a User Account |
| 79 | Control prompt. |
| 80 | * If the user declines the UAC prompt, or if the updater already has admin status, |
| 81 | the update aborts. |
| 82 | * Converts the command line arguments to a vector\<string\> and passes them to RunUpdater() |
| 83 | in UpdaterCommon.h. |
| 84 | * RunUpdater() parses and validates the command line arguments, hides the updater UI, then waits |
| 85 | for the Dolphin process to quit. |
| 86 | * RunUpdater() begins the actual update. |
| 87 | * Fetches file manifests from update server for current and new versions. |
| 88 | * Decompresses manifests and verifies their signatures. |
| 89 | * Downloads and adds/replaces changed files and deletes removed files. |
| 90 | * Verifies downloaded files match manifest hashes. |
| 91 | * If the user updated immediately (rather than waiting for Dolphin to close before starting |
| 92 | the update), Dolphin restarts. |
| 93 | * As part of Dolphin's normal startup process, the Updater copy is deleted. |