Commit graph

204 commits

Author SHA1 Message Date
Robert Knight
e9c94e99ad Add a note about the assumptions made by Log::writeToStream() with respect to multiple logging processes' clobbering each other's output. 2011-09-02 23:41:02 +01:00
Robert Knight
9c260bc114 Synchronize access to the log's output stream with a mutex and document the write() method as being thread-safe. 2011-09-02 23:32:45 +01:00
Robert Knight
2f89332824 Show a useful product name and description in the UAC prompt under Windows Vista/7
Add a VERSION_INFO section to the executable's resource file specifying
the product name and description.

The organization is currently set as 'Mendeley Ltd' - other projects
will want to customize this.

When the produced executable is digitally signed, the product name
and description are shown in the UAC prompt asking for admin
permissions.
2011-09-02 12:53:44 +01:00
Robert Knight
ea7fc49002 Add assert to check that the base path provided to FileUtils::makeAbsolute() is itself absolute. 2011-09-01 20:45:29 +01:00
Robert Knight
483ad4cee0 Fix UpdaterOptions test on Mac. On Mac /tmp is a symlink to /private/tmp 2011-09-01 20:39:56 +01:00
Robert Knight
6ca00a6449 If the --script argument passed to the updater is relative, interpret it as being relative to the package dir rather than the directory that the updater is run from.
Mendeley Desktop <= 1.0 clients pass a relative path for the script argument but
run the updater from the directory containing the main application binary instead
of the package dir.  The script argument, if relative, is therefore treated as
relative to the package directory.
2011-09-01 20:31:51 +01:00
Robert Knight
1fb6d03886 When a test comparison fails, print the actual and expected values that did not match instead of the expressions in the code.
This requires a specialization of TestUtils::toString() for each distinct type,
otherwise a generic message is used.
2011-09-01 19:54:58 +01:00
Robert Knight
b5edffc0b6 Interpret the CurrentDir=$DIR argument on the command line as being relative to the directory containing the main application binary
Mendeley Desktop <= 1.0 clients set CurrentDir to the directory containing the main
application binary rather than the root of the install directory.

Change the parsing in UpdaterOptions and adjust the test accordingly.
2011-09-01 19:53:15 +01:00
Robert Knight
7cd04905df Add missing include for Windows builds 2011-08-31 15:52:14 +01:00
Robert Knight
f16b6e9933 Fix compile errors due to size_t -> int/double conversion warnings on 64bit Linux 2011-08-31 12:55:22 +01:00
Robert Knight
cc387031d7 Make the GTK development libraries a build requirement on Linux and remove the ENABLE_GTK #ifdefs in main.cpp 2011-08-31 12:44:03 +01:00
Robert Knight
ea8fcb4e82 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-30 15:55:29 +01:00
Robert Knight
46a32fe229 Display an icon for the updater in the dock on Mac when the update dialog is being shown
* Embed the app icon in the updater executable on Mac and
   use it as the application's icon.

 * Transform the application from a background to a foreground app when the
   Mac dialog is shown, so that the dock icon is shown.

 * Forcibly give focus to the updater application so that the progress window
   gains focus when it is shown.

There is a remaining glitch with the application where the icon briefly transforms
back from the app icon to the terminal icon as the application shuts
down.  This presumably happens because the custom icon set on the NSApplication
is reset before the dock icon disappears.
2011-08-30 15:41:58 +01:00
Robert Knight
3c28b84080 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-30 12:37:55 +01:00
Robert Knight
e1b0b3266d Fix test linkage on Mac.
Link the test binaries to the Security/Cocoa frameworks.
2011-08-30 12:37:26 +01:00
Robert Knight
1c3cdde4c1 Fix FileUtils::touch() build on Mac.
The utimensat/futimens system calls were introduced in relatively recent Linux
kernels and are not available on Mac.  Use utimes/futimes instead - since
microsecond precision is fine for our needs.
2011-08-30 12:36:07 +01:00
Robert Knight
50faf07f00 Write log file to correct directory on Mac
* Move class to get the app data directory to a new StandardDirs class.
 * Setup an auto-release pool at the start/end of main() to catch objects
   allocated outside of the updater dialog.
2011-08-30 12:34:37 +01:00
Robert Knight
ef4dc40b52 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-30 11:22:41 +01:00
Robert Knight
1d2c02acf4 Add some documentation to the xterm update 'dialog' 2011-08-30 11:21:35 +01:00
Robert Knight
76f164e3c0 Fix 'Finish' button not being enabled if updater fails with an error reading the update script.
UpdateObserver::updateFinished() was not being called by UpdateInstaller.
Add a call to updateFinished() in UpdateInstaller::reportError()
2011-08-30 10:47:51 +01:00
Robert Knight
6d862cbba7 Fix Windows compile 2011-08-30 10:46:47 +01:00
Robert Knight
9d3c02e31c Store update-log.txt log file in the correct location under Windows
This is the same location that Mendeley Desktop stores its data files
($LOCAL_APPDATA/$ORGANIZATION_NAME/$APP_NAME)
2011-08-30 10:43:14 +01:00
Robert Knight
faddccc763 Touch the application's bundle directory on Mac OS X after installing updates.
This is necessary so that Launch Services in OS X picks up changes
to the Info.plist file describing various aspects of the application.

See https://bugzilla.mozilla.org/show_bug.cgi?id=600098 for an example
of the kind of issue that failure to do this can lead to.
2011-08-29 22:53:19 +01:00
Robert Knight
c20c452e98 Update the access/modification times of the existing file, if there is one, in FileUtils::touch()
This changes FileUtils::touch() to match the documentation for the 'touch' tool
on Unix.
2011-08-29 22:44:52 +01:00
Robert Knight
d7e3cc8d63 Rename FileOps to FileUtils for consistency with the ProcessUtils and StringUtils classes. 2011-08-29 22:27:55 +01:00
Robert Knight
cb1e1c612a Mark UpdateMessage::init() as private since it exists only as a helper for the constructors 2011-08-29 21:39:17 +01:00
Robert Knight
2c70cebd05 Make the GTK update dialog wider
gtk_window_set_default_size() has no effect when the dialog
is marked as non-resizable with gtk_window_set_resizable(),
so the minimum size is instead achieved by setting a minimum width
on the progress bar.
2011-08-29 20:20:42 +01:00
Robert Knight
c253cecfa6 If there is a problem installing the update, suggest that the user download a fresh copy from mendeley.com
* Centralize the error message text shown to the user in the event of a problem
   installing the update in AppInfo::updateErrorMessage() and add a section
   suggesting that the user should download a new copy from mendeley.com
2011-08-29 18:57:12 +01:00
Robert Knight
761a4c5d3b Move cmake code to generate a C++ source file from a binary data file into a helper module 2011-08-29 17:40:25 +01:00
Robert Knight
3c836c2d0c Minor formatting fix 2011-08-29 17:23:44 +01:00
Robert Knight
52fdee5a75 Remove duplicated code for getting the ID of the current process in Log.cpp.
Re-use the existing function from ProcessUtils
2011-08-29 17:22:06 +01:00
Robert Knight
7b29c29d85 Avoid trying to wait for the main app process to exit if no process ID for it is specified 2011-08-29 15:17:31 +01:00
Robert Knight
f9238f479b Log update installation details to update-log.txt in the correct Mendeley data directory under Linux 2011-08-29 14:44:08 +01:00
Robert Knight
0d22024b49 Add additional API documentation 2011-08-27 18:31:03 +01:00
Robert Knight
dc741814c9 Move the function used to obtain the log file path into AppInfo::logFilePath() since it will be application-specific. 2011-08-26 18:40:23 +01:00
Robert Knight
4391ea7a60 Fix Mac compilation
Use correct return type for ProcessUtils::runElevatedMac()
2011-08-26 18:35:25 +01:00
Robert Knight
8b757692b1 Replace "Mendeley Updater" string in UpdateDialogCocoa.mm with AppInfo::name() 2011-08-26 18:27:04 +01:00
Robert Knight
be2e0520ad Centralize the name of the application being updated in AppInfo.h
Also add AppInfo.h missing from previous commit.
2011-08-26 18:22:25 +01:00
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
Robert Knight
eeeafb2c1a Implement restart of main application once the update is installed.
* Add support for entries in the update script being marked with
   a boolean <is-main-binary> attribute which is set to true for the main binary.
 * In UpdateInstaller::restartMainApp(), look for the file marked with <is-main-binary>
   and restart it after installation.  With the current structure, this requires that
   the main binary is included in the update, which has always been the case up till now.

   If we find that we want to do updates that do not affect the main binary, the
   <is-main-binary> attribute could be replaced with a <main-binary> string value
   at the top of the XML file.
2011-08-23 12:59:04 +01:00
Robert Knight
96b76b0443 Fix incorrect signature for button clicked slot.
The first argument to the slot is the sender widget.
2011-08-23 12:51:35 +01:00
Robert Knight
85c4c58dc9 Add a basic GTK update installation dialog and a stub function in UpdateInstaller to restart the main app after the update is complete.
* Add optional GTK mode to the updater build.  This pulls in a large number of extra dependencies,
   but dependencies which should be fairly ubiquitous on Linux systems.  If these dependencies prove
   to be a problem we could look at providing an alternative, more basic UI and loading the appropriate
   UI dynamically.
 * Implement update progress dialog for GTK.  The dialog needs visual polish but is functional.
2011-08-23 12:29:47 +01:00
Robert Knight
f1367671b6 Use Windows/Unix versions of test binary names in test-update.rb depending on the host OS 2011-08-23 10:31:35 +01:00
Robert Knight
b43d9f33bf Add missing <string.h> include 2011-08-23 09:40:41 +01:00
Robert Knight
e02e0b21c9 Implement process elevation on Windows using code from existing updater 2011-08-22 19:32:01 +01:00
Robert Knight
25e5a1c66c Make FileOps::createSymLink() a no-op which logs a warning under Windows instead of reporting an error.
This allows the cross-platform unit test to pass on Windows, since it includes creation of a symlink.
2011-08-22 19:21:29 +01:00
Robert Knight
7c62b4c7af Fix argv[0] not being correctly set to binary path under Windows
Add the executable to the start of the command line for the new process in ProcessUtils::runAsync()
2011-08-22 19:17:35 +01:00
Robert Knight
66a6afcb01 Fix typo in FileOps::extractFromZip()
Use the correct parameter in the exception message.
2011-08-22 19:08:28 +01:00
Robert Knight
a056e631e4 Adjust the filename of the main app binary to app.exe in the test file_list.xml on Windows 2011-08-22 19:05:31 +01:00
Robert Knight
f35d935eab Add error code from GetLastError() to IOException::what() message 2011-08-22 18:57:03 +01:00
Robert Knight
50a21f004d Implement waiting for parent updater process to finish.
* Set the --wait argument when launching new updater processes with the ID of the process to wait for.
 * Add ProcessUtils::currentProcessId() utility method and PLATFORM_PID define
2011-08-22 18:46:03 +01:00