Commit graph

116 commits

Author SHA1 Message Date
Robert Knight
7597dee64a Centralize the name of the updater application in AppInfo.h 2011-08-26 18:20:38 +01:00
Robert Knight
38c9cd9b41 Only try to link libdl on Unix platforms 2011-08-26 18:08:56 +01:00
Robert Knight
9391fb6b5e Add an old-school ASCII-art version of the update dialog as a fallback under Linux when GTK is not available.
If the GTK UI cannot be loaded, this will pop up a terminal displaying
progress information.  Hopefully users will find this mildly amusing.
2011-08-26 17:36:22 +01:00
Robert Knight
630d64e859 Make the GTK dependency optional at runtime on Linux
Build the GTK dialog as a separate shared library which
is embedded into the main updater binary.

At runtime the updater extracts the shared library and attempts to load it.
If this succeeds, the GTK UI is used, otherwise the updater will fall
back to something else - currently a silent install.
2011-08-26 16:59:03 +01:00
Robert Knight
93f58e77da Remove un-implemented updateRetryCancel() method from UpdateObserver
The current update dialogs do not support retry/cancel - if a file
cannot be installed the update will just fail with an error and
any partial install will be reverted.
2011-08-26 15:17:59 +01:00
Robert Knight
63f2480b90 Remove unused UpdateDialogGtk::restartApp() accessor 2011-08-26 15:06:02 +01:00
Robert Knight
04f8d7ec0b Fix unsigned/signed int comparison in FileOps::toUnixPathSeparators() 2011-08-26 14:15:22 +01:00
Robert Knight
adba463f61 Simplify cleanup of the updater's temporary directory
Following the change to FileOps::removeFile() to support 'removal'
of files that are in use in Windows, the cleanup of the updater's
temporary directory can be performed from the non-elevated updater
setup process once the main install process has returned.

This removes the --mode cleanup run mode in the updater.
2011-08-26 13:13:11 +01:00
Robert Knight
ef6809e0fe Fix updater cleanup of temporary directory on Windows
* On Windows FileOps::removeFile() fails for updater.exe
   since that file is in use by the current process.

   Whilst it is not possible to remove the file whilst it
   is in use, it can be moved or scheduled for deletion on reboot.

   This commit changes FilesOps::removeFile() to simulate the
   behavior of unlink() on Linux by moving in-use files to
   a temporary directory and then scheduling for them to
   be removed on restart.
2011-08-26 12:55:09 +01:00
Robert Knight
0134e7d53e Implement ProcessUtils::runSync() under Windows
This follows the existing async launching path and then uses
WaitForSingleObject / GetExitCodeProcess to wait for the process
and get its status.
2011-08-26 11:56:28 +01:00
Robert Knight
e5e163e6d5 Open log in append mode so that new entries are written at the end.
There is no locking on the Log file so conflicting updater processes
may corrupt each others' entries - although in practice this has not
been a problem yet.
2011-08-26 11:54:14 +01:00
Robert Knight
098c9cb194 When re-launching the application after an update is installed, do it from a non-elevated process.
Previously the application was restarted from the main install process, which may have
  been elevated.  The main application must be started from a non-elevated updater/updater.exe
  process otherwise the main app will inherit the elevated status from its parent.

  * Modify ProcessUtils::runElevated() to return the status code of the process
  * Change UpdateInstaller to run the main installation synchronously from the initial
    updater process in the case where elevation is not required.
  * Remove calls in main.cpp to relaunch the main application after the UI is closed.
2011-08-26 11:17:09 +01:00
Robert Knight
da2614d427 Change the syntax of the backwards-compatible update scripts.
Instead of moving the whole <update> section to an embedded <update-v3>
node, just use a different name for the <install> section since older
clients will ignore the new <packages> section.

For older clients:

 * The <install> section lists the packages to download.  This will exist
   in addition to the <packages> section.
 * The real <install> section listing the files to install is renamed to
   <install-v3>
2011-08-25 12:23:04 +01:00
Robert Knight
78b3c14260 Print a more useful message when an std::exception is thrown whilst running a test. 2011-08-25 11:52:02 +01:00
Robert Knight
62bf142f06 Fix ProcessUtils compilation on Linux/Mac
* Only compile the Windows command-line conversion function on Windows
2011-08-25 11:38:12 +01:00
Robert Knight
9fa311ebaf Use the embedded application icon for the Update Dialog window 2011-08-24 16:49:47 +01:00
Robert Knight
13b280a4fd Use the correct path to the application icon in updater.rc 2011-08-24 16:38:43 +01:00
Robert Knight
2a1db3927d Add icon to updater executable. Currently this is just the Mendeley Desktop icon. Untested. 2011-08-24 16:34:46 +01:00
Robert Knight
04c9c7204b Make updater.exe a WIN32 GUI application instead of a console application on Windows
* Add WIN32 flag to add_executable() so that cmake generates a GUI application
 * Add WinMain() entry point which converts the unicode command line arguments to ANSI and then calls the standard main() entry point.

 The unit test continues to pass although I am not sure whether
 converting command-line args from Unicode to ANSI will cause problems
 with filenames passed on the command-line that contain non-ANSI
 characters.
2011-08-24 16:11:53 +01:00
Robert Knight
bae300a6a7 Report an error on update installation if the update script cannot be read. 2011-08-24 12:59:51 +01:00
Robert Knight
557dc1273e Update the GTK UI for install errors to match the Mac and Windows UIs
* Display the error details in a message box
 * Set the progress label text appropriately in the event of an error
2011-08-24 12:15:02 +01:00
Robert Knight
ddff071b8c Fix progress percentage calculation broken in recent commit
Multiply the fractional value by 100 instead of multiplying the denominator
of the division operation by 100.
2011-08-24 11:53:13 +01:00
Robert Knight
b4311d79a9 Rename Dir to DirIterator 2011-08-24 11:53:02 +01:00
Robert Knight
887619f239 Add missing variable initialization in Dir class 2011-08-24 11:48:36 +01:00
Robert Knight
a2ea1841b3 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 11:45:05 +01:00
Robert Knight
3b1452cefe Build the updater with -Wconversion and fix several issues encountered in the process 2011-08-24 11:44:29 +01:00
Robert Knight
b0b3fc4eaa Fix compile errors reported by -Wall -Werror on Mac
Correct argument types and return a value from UpdateDialogCocoa::updateRetryCancel()
2011-08-24 11:30:06 +01:00
Robert Knight
1318576cea Fix comparison between pos and std::string::npos
std::string::npos is defined as the unsigned type size_t but given a value of -1,
resulting in a warning when trying to compare an unsigned int with a size_t.

Fix this by declaring pos as a size_t.
2011-08-24 11:28:32 +01:00
Robert Knight
d922fc3f7a Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 11:25:40 +01:00
Robert Knight
4897f2f8ed Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 11:25:25 +01:00
Robert Knight
f37d469078 Enable -Wall -Werror when building on Linux/Mac and fix several bugs discovered in the process.
* Fix ProcessUtils::runAsyncUnix() not returning a value
 * Fix UpdateDialogGtk::updateRetryCancel() not returning a value
 * Add missing includes in TestUpdaterOptions.cpp
 * Fix unsigned/signed int comparisons
2011-08-24 11:23:48 +01:00
Robert Knight
a6a94f7b10 Merge branch 'master' of ssh://files/git/desktop/standalone-updater 2011-08-24 11:19:29 +01:00
Robert Knight
22d0bd0939 Display details of any update failure in a message box instead of in the progress label on Mac.
This matches the Windows UI and a message box provides more space for text details than
a progress label.
2011-08-24 11:14:39 +01:00
Robert Knight
121b1c9126 Fix crash in Update Dialog on Mac if update installation fails due to use of uninitialized string variable. 2011-08-24 11:02:26 +01:00
Robert Knight
a42e9475b5 Disable the window close button in the update dialog on Mac.
This prevents the dialog being closed part-way through update installation,
leaving the user unable to restart the application afterwards by clicking
the 'Finish' button.
2011-08-24 10:56:08 +01:00
Robert Knight
91f402afa2 Fix warnings about conversion from string literal to char*
UpdaterOptions::parse() will probably not have a need to modify its
arguments but for consistency with the declaration of main() it takes a char*,
so strdup() the strings.
2011-08-24 10:52:07 +01:00
Robert Knight
4c574bde87 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 10:46:17 +01:00
Robert Knight
3a7b636f42 Fix possible out-of-bounds array access if an empty command-line argument is passed to ProcessUtils::runElevated() on Windows 2011-08-24 10:30:06 +01:00
Robert Knight
61e7561615 Refactor similar UpdateDialogGtk::Message and UpdateDialogWin32::Message class into a single shared UpdateMessage class. 2011-08-24 10:17:57 +01:00
Robert Knight
0ca5928f08 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 09:38:38 +01:00
Robert Knight
f4199ed706 Remove logging spam 2011-08-23 23:59:09 +01:00
Robert Knight
4f00c51c8f Write log output to a file instead of just stderr
* Log output to a file (currently update-log.txt in the updater's current directory)
 * Use correct stream type for Log::m_output
2011-08-23 23:54:37 +01:00
Robert Knight
a5bf5becad Aesthetic tweaks to the GTK version of the update dialog
* Make the window non-resizable
 * Left-align the label
 * Right-align the 'Finish' button
 * Center the window
2011-08-23 23:46:49 +01:00
Robert Knight
a8dcab1f00 Add handling in the UI for failed update installation under Windows.
In the event of a failed update, display the details in a message
 box and allow the user to restart the old application once the
 update has been reverted.

 Details of the problem will also be written to the log file.
2011-08-23 20:15:57 +01:00
Robert Knight
3a7d41e630 Avoid closing the updater dialog when the window close button is clicked.
This prevents the user closing the dialog whilst the update is in
progress.  Once the update has been installed, the user can click
the 'Finish' button to close the dialog and restart the application.
2011-08-23 20:03:55 +01:00
Robert Knight
448d43c5e0 Remove extra new line 2011-08-23 20:00:06 +01:00
Robert Knight
5cd7d22192 Add Windows implementation of updater dialog
The Windows implementation uses Win++, a thin header-only wrapper
 around the Windows API
2011-08-23 19:53:03 +01:00
Robert Knight
e294c35965 Rename UpdaterOptions::script to UpdaterOptions::scriptPath for clarity 2011-08-23 16:34:34 +01:00
Robert Knight
214f2273b9 Fix warning about object being leaked from update installer thread due to a missing autorelease pool
Allocate an NSAutoreleasePool in the updater thread and release it just
before the thread exits.
2011-08-23 16:30:17 +01:00
Robert Knight
ff21b77ec1 Add a Cocoa UI for the updater on Mac
* Link the updater application with the Cocoa framework on Mac

 * Construct a UI in code and display it when running the main install process.

   Usually UIs on Mac are contained in a .nib file created with Interface Builder
   but in this case the UI is created directly in code to meet the single-binary requirement,
   although it may be possible to bundle the .nib into the binary itself.
2011-08-23 16:20:23 +01:00