From: Carl Hetherington Date: Sun, 29 Mar 2020 22:10:46 +0000 (+0200) Subject: Change internal name dist -> disk. X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=7c998afc2711a112dc70a0b247746932bc9ae4ea;hp=66188f33fbe6b042e765fdf6f73d51cba5ffd488;p=dcpomatic.git Change internal name dist -> disk. --- diff --git a/cscript b/cscript index e548df08c..f7d9ea0ba 100644 --- a/cscript +++ b/cscript @@ -196,8 +196,8 @@ deb_depends['unstable'].extend(['libboost-filesystem1.67.0', 'libx264-155', 'libcurl4']) -def build_dist(target): - # We can build dcpomatic2_dist on platforms that have Boost process and can build the lwext4 +def build_disk(target): + # We can build dcpomatic2_disk on platforms that have Boost process and can build the lwext4 # library. For now, just whitelist good ones here. # # - Lots of Linux distros don't have a new enough boost (1.64 or above) @@ -286,9 +286,9 @@ def make_spec(filename, version, target, options, requires=None): if options['variant'] == 'swaroop-studio': print('%{_bindir}/dcpomatic2_ecinema', file=f) print('%{_bindir}/dcpomatic2_uuid', file=f) - if os.path.exists(os.path.join(tools, "dcpomatic2_dist")): - print('%{_bindir}/dcpomatic2_dist', file=f) - print('%{_bindir}/dcpomatic2_dist_writer', file=f) + if os.path.exists(os.path.join(tools, "dcpomatic2_disk")): + print('%{_bindir}/dcpomatic2_disk', file=f) + print('%{_bindir}/dcpomatic2_disk_writer', file=f) print('%{_datadir}/applications/dcpomatic2.desktop', file=f) print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f) print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f) @@ -414,8 +414,8 @@ def configure_options(target, options): if target.debug and target.platform == 'windows': opt += ' --static-dcpomatic' - if build_dist(target): - opt += ' --enable-dist' + if build_disk(target): + opt += ' --enable-disk' return opt diff --git a/debian/rules b/debian/rules index 78bf3e852..c45682033 100755 --- a/debian/rules +++ b/debian/rules @@ -50,4 +50,4 @@ override_dh_shlibdeps: override_dh_fixperms: dh_fixperms --exclude usr/bin/dcpomatic2_uuid - dh_fixperms --exclude usr/bin/dcpomatic2_dist_writer + dh_fixperms --exclude usr/bin/dcpomatic2_disk_writer diff --git a/graphics/linux/128/dcpomatic2_disk.png b/graphics/linux/128/dcpomatic2_disk.png new file mode 100644 index 000000000..76e27f736 Binary files /dev/null and b/graphics/linux/128/dcpomatic2_disk.png differ diff --git a/graphics/linux/128/dcpomatic2_dist.png b/graphics/linux/128/dcpomatic2_dist.png deleted file mode 100644 index 76e27f736..000000000 Binary files a/graphics/linux/128/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/linux/16/dcpomatic2_disk.png b/graphics/linux/16/dcpomatic2_disk.png new file mode 100644 index 000000000..f842ea340 Binary files /dev/null and b/graphics/linux/16/dcpomatic2_disk.png differ diff --git a/graphics/linux/16/dcpomatic2_dist.png b/graphics/linux/16/dcpomatic2_dist.png deleted file mode 100644 index f842ea340..000000000 Binary files a/graphics/linux/16/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/linux/22/dcpomatic2_disk.png b/graphics/linux/22/dcpomatic2_disk.png new file mode 100644 index 000000000..9fbe61c05 Binary files /dev/null and b/graphics/linux/22/dcpomatic2_disk.png differ diff --git a/graphics/linux/22/dcpomatic2_dist.png b/graphics/linux/22/dcpomatic2_dist.png deleted file mode 100644 index 9fbe61c05..000000000 Binary files a/graphics/linux/22/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/linux/256/dcpomatic2_disk.png b/graphics/linux/256/dcpomatic2_disk.png new file mode 100644 index 000000000..2654d84c0 Binary files /dev/null and b/graphics/linux/256/dcpomatic2_disk.png differ diff --git a/graphics/linux/256/dcpomatic2_dist.png b/graphics/linux/256/dcpomatic2_dist.png deleted file mode 100644 index 2654d84c0..000000000 Binary files a/graphics/linux/256/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/linux/32/dcpomatic2_disk.png b/graphics/linux/32/dcpomatic2_disk.png new file mode 100644 index 000000000..7893e4c41 Binary files /dev/null and b/graphics/linux/32/dcpomatic2_disk.png differ diff --git a/graphics/linux/32/dcpomatic2_dist.png b/graphics/linux/32/dcpomatic2_dist.png deleted file mode 100644 index 7893e4c41..000000000 Binary files a/graphics/linux/32/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/linux/48/dcpomatic2_disk.png b/graphics/linux/48/dcpomatic2_disk.png new file mode 100644 index 000000000..8124195b4 Binary files /dev/null and b/graphics/linux/48/dcpomatic2_disk.png differ diff --git a/graphics/linux/48/dcpomatic2_dist.png b/graphics/linux/48/dcpomatic2_dist.png deleted file mode 100644 index 8124195b4..000000000 Binary files a/graphics/linux/48/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/linux/512/dcpomatic2_disk.png b/graphics/linux/512/dcpomatic2_disk.png new file mode 100644 index 000000000..9802ad6dc Binary files /dev/null and b/graphics/linux/512/dcpomatic2_disk.png differ diff --git a/graphics/linux/512/dcpomatic2_dist.png b/graphics/linux/512/dcpomatic2_dist.png deleted file mode 100644 index 9802ad6dc..000000000 Binary files a/graphics/linux/512/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/linux/64/dcpomatic2_disk.png b/graphics/linux/64/dcpomatic2_disk.png new file mode 100644 index 000000000..9cd6d12e3 Binary files /dev/null and b/graphics/linux/64/dcpomatic2_disk.png differ diff --git a/graphics/linux/64/dcpomatic2_dist.png b/graphics/linux/64/dcpomatic2_dist.png deleted file mode 100644 index 9cd6d12e3..000000000 Binary files a/graphics/linux/64/dcpomatic2_dist.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_128x128.png b/graphics/osx/dcpomatic2_disk.iconset/icon_128x128.png new file mode 100644 index 000000000..76e27f736 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_128x128.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_128x128@2x.png b/graphics/osx/dcpomatic2_disk.iconset/icon_128x128@2x.png new file mode 100644 index 000000000..76e27f736 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_128x128@2x.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_16x16.png b/graphics/osx/dcpomatic2_disk.iconset/icon_16x16.png new file mode 100644 index 000000000..f842ea340 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_16x16.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_16x16@2x.png b/graphics/osx/dcpomatic2_disk.iconset/icon_16x16@2x.png new file mode 100644 index 000000000..f842ea340 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_16x16@2x.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_256x256.png b/graphics/osx/dcpomatic2_disk.iconset/icon_256x256.png new file mode 100644 index 000000000..2654d84c0 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_256x256.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_256x256@2x.png b/graphics/osx/dcpomatic2_disk.iconset/icon_256x256@2x.png new file mode 100644 index 000000000..2654d84c0 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_256x256@2x.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_32x32.png b/graphics/osx/dcpomatic2_disk.iconset/icon_32x32.png new file mode 100644 index 000000000..7893e4c41 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_32x32.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_32x32@2x.png b/graphics/osx/dcpomatic2_disk.iconset/icon_32x32@2x.png new file mode 100644 index 000000000..7893e4c41 Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_32x32@2x.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_512x512.png b/graphics/osx/dcpomatic2_disk.iconset/icon_512x512.png new file mode 100644 index 000000000..9802ad6dc Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_512x512.png differ diff --git a/graphics/osx/dcpomatic2_disk.iconset/icon_512x512@2x.png b/graphics/osx/dcpomatic2_disk.iconset/icon_512x512@2x.png new file mode 100644 index 000000000..9802ad6dc Binary files /dev/null and b/graphics/osx/dcpomatic2_disk.iconset/icon_512x512@2x.png differ diff --git a/graphics/osx/dcpomatic2_dist.icns b/graphics/osx/dcpomatic2_dist.icns deleted file mode 100644 index df1b90cc2..000000000 Binary files a/graphics/osx/dcpomatic2_dist.icns and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_128x128.png b/graphics/osx/dcpomatic2_dist.iconset/icon_128x128.png deleted file mode 100644 index 76e27f736..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_128x128.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_128x128@2x.png b/graphics/osx/dcpomatic2_dist.iconset/icon_128x128@2x.png deleted file mode 100644 index 76e27f736..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_128x128@2x.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_16x16.png b/graphics/osx/dcpomatic2_dist.iconset/icon_16x16.png deleted file mode 100644 index f842ea340..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_16x16.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_16x16@2x.png b/graphics/osx/dcpomatic2_dist.iconset/icon_16x16@2x.png deleted file mode 100644 index f842ea340..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_16x16@2x.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_256x256.png b/graphics/osx/dcpomatic2_dist.iconset/icon_256x256.png deleted file mode 100644 index 2654d84c0..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_256x256.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_256x256@2x.png b/graphics/osx/dcpomatic2_dist.iconset/icon_256x256@2x.png deleted file mode 100644 index 2654d84c0..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_256x256@2x.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_32x32.png b/graphics/osx/dcpomatic2_dist.iconset/icon_32x32.png deleted file mode 100644 index 7893e4c41..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_32x32.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_32x32@2x.png b/graphics/osx/dcpomatic2_dist.iconset/icon_32x32@2x.png deleted file mode 100644 index 7893e4c41..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_32x32@2x.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_512x512.png b/graphics/osx/dcpomatic2_dist.iconset/icon_512x512.png deleted file mode 100644 index 9802ad6dc..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_512x512.png and /dev/null differ diff --git a/graphics/osx/dcpomatic2_dist.iconset/icon_512x512@2x.png b/graphics/osx/dcpomatic2_dist.iconset/icon_512x512@2x.png deleted file mode 100644 index 9802ad6dc..000000000 Binary files a/graphics/osx/dcpomatic2_dist.iconset/icon_512x512@2x.png and /dev/null differ diff --git a/graphics/src/dcpomatic2_disk.svg b/graphics/src/dcpomatic2_disk.svg new file mode 100644 index 000000000..0a022b71c --- /dev/null +++ b/graphics/src/dcpomatic2_disk.svg @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/graphics/src/dcpomatic2_dist.svg b/graphics/src/dcpomatic2_dist.svg deleted file mode 100644 index 0a022b71c..000000000 --- a/graphics/src/dcpomatic2_dist.svg +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff --git a/graphics/update b/graphics/update index a3546c9cf..9b75493db 100755 --- a/graphics/update +++ b/graphics/update @@ -12,7 +12,7 @@ if [ `basename $pwd` != "graphics" ]; then exit 1 fi -svg_apps="dcpomatic2_kdm dcpomatic2_server dcpomatic2_batch dcpomatic2_player dcpomatic2_playlist dcpomatic2_dist" +svg_apps="dcpomatic2_kdm dcpomatic2_server dcpomatic2_batch dcpomatic2_player dcpomatic2_playlist dcpomatic2_disk" if [ `uname -s` == "Darwin" ]; then # Convert OS X icons using OS X-only iconutil diff --git a/graphics/web/favicon-128x128.png b/graphics/web/favicon-128x128.png index 83a087be1..a78e5a230 100644 Binary files a/graphics/web/favicon-128x128.png and b/graphics/web/favicon-128x128.png differ diff --git a/graphics/web/favicon-16x16.png b/graphics/web/favicon-16x16.png index 6fa9cb28f..ec3726302 100644 Binary files a/graphics/web/favicon-16x16.png and b/graphics/web/favicon-16x16.png differ diff --git a/graphics/web/favicon-32x32.png b/graphics/web/favicon-32x32.png index 561f5946d..54658330f 100644 Binary files a/graphics/web/favicon-32x32.png and b/graphics/web/favicon-32x32.png differ diff --git a/graphics/web/favicon-64x64.png b/graphics/web/favicon-64x64.png index 46f4cf7da..59d009247 100644 Binary files a/graphics/web/favicon-64x64.png and b/graphics/web/favicon-64x64.png differ diff --git a/graphics/windows/dcpomatic2_disk.ico b/graphics/windows/dcpomatic2_disk.ico new file mode 100644 index 000000000..e092bce76 Binary files /dev/null and b/graphics/windows/dcpomatic2_disk.ico differ diff --git a/graphics/windows/dcpomatic2_dist.ico b/graphics/windows/dcpomatic2_dist.ico deleted file mode 100644 index e092bce76..000000000 Binary files a/graphics/windows/dcpomatic2_dist.ico and /dev/null differ diff --git a/platform/osx/dcpomatic2_disk.Info.plist.in b/platform/osx/dcpomatic2_disk.Info.plist.in new file mode 100644 index 000000000..177146894 --- /dev/null +++ b/platform/osx/dcpomatic2_disk.Info.plist.in @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + dcpomatic2_disk + CFBundleGetInfoString + DCP-o-matic 2 Disk Writer + CFBundleIconFile + dcpomatic2_disk.icns + CFBundleIdentifier + com.dcpomatic.disk + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + DCP-o-matic 2 Disk Writer + CFBundlePackageType + APPL + CFBundleShortVersions + @VERSION@ + CFBundleSignature + DOMC + CFBundleVersion + @VERSION@ + CFBundleAllowMixedLocalizations + + LSUIElement + 0 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/platform/osx/dcpomatic2_dist.Info.plist.in b/platform/osx/dcpomatic2_dist.Info.plist.in deleted file mode 100644 index 50a0466e0..000000000 --- a/platform/osx/dcpomatic2_dist.Info.plist.in +++ /dev/null @@ -1,36 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - dcpomatic2_dist - CFBundleGetInfoString - DCP-o-matic 2 Disk Writer - CFBundleIconFile - dcpomatic2_dist.icns - CFBundleIdentifier - com.dcpomatic.dist - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - DCP-o-matic 2 Disk Writer - CFBundlePackageType - APPL - CFBundleShortVersions - @VERSION@ - CFBundleSignature - DOMC - CFBundleVersion - @VERSION@ - CFBundleAllowMixedLocalizations - - LSUIElement - 0 - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/platform/osx/make_dmg.sh b/platform/osx/make_dmg.sh index 885fd5d60..a05212844 100644 --- a/platform/osx/make_dmg.sh +++ b/platform/osx/make_dmg.sh @@ -190,7 +190,7 @@ function copy_resources { cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_player.icns "$dest" cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_batch.icns "$dest" cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_playlist.icns "$dest" - cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_dist.icns "$dest" + cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_disk.icns "$dest" cp $prefix/src/dcpomatic/graphics/osx/preferences/colour_conversions.png "$dest" cp $prefix/src/dcpomatic/graphics/osx/preferences/defaults.png "$dest" cp $prefix/src/dcpomatic/graphics/osx/preferences/kdm_email.png "$dest" @@ -451,11 +451,11 @@ make_dmg "$appdir" "DCP-o-matic Playlist Editor" com.dcpomatic.playlist # DCP-o-matic Disk Writer setup "DCP-o-matic 2 Disk Writer.app" -copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_dist "$approot/MacOS" -copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_dist_writer "$approot/MacOS" -cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_dist.Info.plist "$approot/Info.plist" -rl=("$approot/MacOS/dcpomatic2_dist" "$approot/Frameworks/"*.dylib) +copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_disk "$approot/MacOS" +copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_disk_writer "$approot/MacOS" +cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_disk.Info.plist "$approot/Info.plist" +rl=("$approot/MacOS/dcpomatic2_disk" "$approot/Frameworks/"*.dylib) relink "${rl[@]}" -rl=("$approot/MacOS/dcpomatic2_dist_writer" "$approot/Frameworks/"*.dylib) +rl=("$approot/MacOS/dcpomatic2_disk_writer" "$approot/Frameworks/"*.dylib) relink "${rl[@]}" -make_dmg "$appdir" "DCP-o-matic Disk Writer" com.dcpomatic.dist +make_dmg "$appdir" "DCP-o-matic Disk Writer" com.dcpomatic.disk diff --git a/platform/osx/wscript b/platform/osx/wscript index e012b72c6..da20065f5 100644 --- a/platform/osx/wscript +++ b/platform/osx/wscript @@ -5,4 +5,4 @@ def build(bld): obj = bld(features='subst', source='dcpomatic2_batch.Info.plist.in', target='dcpomatic2_batch.Info.plist', version=bld.env.VERSION) obj = bld(features='subst', source='dcpomatic2_player.Info.plist.in', target='dcpomatic2_player.Info.plist', version=bld.env.VERSION) obj = bld(features='subst', source='dcpomatic2_playlist.Info.plist.in', target='dcpomatic2_playlist.Info.plist', version=bld.env.VERSION) - obj = bld(features='subst', source='dcpomatic2_dist.Info.plist.in', target='dcpomatic2_dist.Info.plist', version=bld.env.VERSION) + obj = bld(features='subst', source='dcpomatic2_disk.Info.plist.in', target='dcpomatic2_disk.Info.plist', version=bld.env.VERSION) diff --git a/platform/windows/dcpomatic2_disk_debug.bat b/platform/windows/dcpomatic2_disk_debug.bat new file mode 100644 index 000000000..f89a06add --- /dev/null +++ b/platform/windows/dcpomatic2_disk_debug.bat @@ -0,0 +1 @@ +gdb.exe -x gdb_script dcpomatic2_disk.exe > %HOMEPATH%/Documents/dcpomatic_debug_log.txt diff --git a/platform/windows/dcpomatic2_disk_writer.exe.manifest b/platform/windows/dcpomatic2_disk_writer.exe.manifest new file mode 100644 index 000000000..7d922a0db --- /dev/null +++ b/platform/windows/dcpomatic2_disk_writer.exe.manifest @@ -0,0 +1,12 @@ + + + + DCP-o-matic Disk Writer + + + + + + + + diff --git a/platform/windows/dcpomatic2_dist_debug.bat b/platform/windows/dcpomatic2_dist_debug.bat deleted file mode 100644 index 9893ccf66..000000000 --- a/platform/windows/dcpomatic2_dist_debug.bat +++ /dev/null @@ -1 +0,0 @@ -gdb.exe -x gdb_script dcpomatic2_dist.exe > %HOMEPATH%/Documents/dcpomatic_debug_log.txt diff --git a/platform/windows/dcpomatic2_dist_writer.exe.manifest b/platform/windows/dcpomatic2_dist_writer.exe.manifest deleted file mode 100644 index 2c861c766..000000000 --- a/platform/windows/dcpomatic2_dist_writer.exe.manifest +++ /dev/null @@ -1,12 +0,0 @@ - - - - DCP-o-matic Disk Writer - - - - - - - - diff --git a/platform/windows/dcpomatic_disk.rc b/platform/windows/dcpomatic_disk.rc new file mode 100644 index 000000000..e10e89e2f --- /dev/null +++ b/platform/windows/dcpomatic_disk.rc @@ -0,0 +1,2 @@ +id ICON "../../graphics/windows/dcpomatic2_disk.ico" +#include "wx-3.0/wx/msw/wx.rc" diff --git a/platform/windows/dcpomatic_disk_writer.rc b/platform/windows/dcpomatic_disk_writer.rc new file mode 100644 index 000000000..70138ed12 --- /dev/null +++ b/platform/windows/dcpomatic_disk_writer.rc @@ -0,0 +1,2 @@ +#include "winuser.h" +1 RT_MANIFEST "dcpomatic2_disk_writer.exe.manifest" diff --git a/platform/windows/dcpomatic_dist.rc b/platform/windows/dcpomatic_dist.rc deleted file mode 100644 index 7a7c41972..000000000 --- a/platform/windows/dcpomatic_dist.rc +++ /dev/null @@ -1,2 +0,0 @@ -id ICON "../../graphics/windows/dcpomatic2_dist.ico" -#include "wx-3.0/wx/msw/wx.rc" diff --git a/platform/windows/dcpomatic_dist_writer.rc b/platform/windows/dcpomatic_dist_writer.rc deleted file mode 100644 index 3e30d78fd..000000000 --- a/platform/windows/dcpomatic_dist_writer.rc +++ /dev/null @@ -1,2 +0,0 @@ -#include "winuser.h" -1 RT_MANIFEST "dcpomatic2_dist_writer.exe.manifest" diff --git a/platform/windows/wscript b/platform/windows/wscript index af55c26b5..77f9bd0cc 100644 --- a/platform/windows/wscript +++ b/platform/windows/wscript @@ -1,7 +1,7 @@ from __future__ import print_function import os -def write_installer(bits, windows_version, dcpomatic_version, debug, variant, dist): +def write_installer(bits, windows_version, dcpomatic_version, debug, variant, disk): try: os.makedirs('build/platform/windows') except: @@ -160,7 +160,7 @@ File "%cdist_deps%/bin/asdcp-carl.dll" File "%cdist_deps%/bin/kumu-carl.dll" """, file=f) - if dist: + if disk: print(""" File "%static_deps%/bin/libnanomsg.dll" File "%cdist_deps%/lib/libblockdev.dll" @@ -209,8 +209,8 @@ File "%cdist_deps%/src/openssl/apps/openssl.exe" print('File "%resources%/dcpomatic2_batch_debug.bat"', file=f) print('File "%resources%/dcpomatic2_kdm_debug.bat"', file=f) print('File "%resources%/dcpomatic2_player_debug.bat"', file=f) - if dist: - print('File "%resources%/dcpomatic2_dist_debug.bat"', file=f) + if disk: + print('File "%resources%/dcpomatic2_disk_debug.bat"', file=f) print('File "%mingw%/bin/gdb.exe"', file=f) else: print('File "%binaries%/src/wx/dcpomatic2-wx.dll"', file=f) @@ -341,11 +341,11 @@ File "%binaries%/src/tools/dcpomatic2_kdm.exe" File "%binaries%/src/tools/dcpomatic2_kdm_cli.exe" """, file=f) - if dist: + if disk: print(""" -File "%binaries%/src/tools/dcpomatic2_dist.exe" -File "%binaries%/src/tools/dcpomatic2_dist_writer.exe" -File "%resources%/dcpomatic2_dist_writer.exe.manifest" +File "%binaries%/src/tools/dcpomatic2_disk.exe" +File "%binaries%/src/tools/dcpomatic2_disk_writer.exe" +File "%resources%/dcpomatic2_disk_writer.exe.manifest" """, file=f) print(""" @@ -358,8 +358,8 @@ File "%binaries%/src/tools/dcpomatic2_playlist.exe" print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 debug\\DCP-o-matic 2 debug.lnk" "$INSTDIR\\bin\\dcpomatic2_debug.bat"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 debug\\DCP-o-matic 2 Batch Converter debug.lnk" "$INSTDIR\\bin\\dcpomatic2_batch_debug.bat" ""', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 debug\\DCP-o-matic 2 KDM Creator debug.lnk" "$INSTDIR\\bin\\dcpomatic2_kdm_debug.bat" ""', file=f) - if dist: - print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 debug\\DCP-o-matic 2 Disk Writer debug.lnk" "$INSTDIR\\bin\\dcpomatic2_dist_debug.bat" ""', file=f) + if disk: + print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 debug\\DCP-o-matic 2 Disk Writer debug.lnk" "$INSTDIR\\bin\\dcpomatic2_disk_debug.bat" ""', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 debug\\Uninstall DCP-o-matic 2 debug.lnk" "$INSTDIR\\Uninstall.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 debug\\DCP-o-matic 2 Player debug.lnk" "$INSTDIR\\bin\\dcpomatic2_player_debug.bat" ""', file=f) print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 debug" "DisplayName" "DCP-o-matic 2 debug (remove only)"', file=f) @@ -369,8 +369,8 @@ File "%binaries%/src/tools/dcpomatic2_playlist.exe" print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 Batch Converter.lnk" "$INSTDIR\\bin\\dcpomatic2_batch.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 KDM Creator.lnk" "$INSTDIR\\bin\\dcpomatic2_kdm.exe"', file=f) - if dist: - print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 Disk Writer.lnk" "$INSTDIR\\bin\\dcpomatic2_dist.exe"', file=f) + if disk: + print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 Disk Writer.lnk" "$INSTDIR\\bin\\dcpomatic2_disk.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2.lnk" "$INSTDIR\\Uninstall.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 Player.lnk" "$INSTDIR\\bin\\dcpomatic2_player.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 Playlist Editor.lnk" "$INSTDIR\\bin\\dcpomatic2_playlist.exe"', file=f) @@ -386,8 +386,8 @@ File "%binaries%/src/tools/dcpomatic2_playlist.exe" print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 debug.lnk" "$INSTDIR\\bin\\dcpomatic2_debug.bat" ""', file=f) print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Batch Converter debug.lnk" "$INSTDIR\\bin\\dcpomatic2_batch_debug.bat" ""', file=f) print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 KDM Creator debug.lnk" "$INSTDIR\\bin\\dcpomatic2_kdm_debug.bat" ""', file=f) - if dist: - print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Disk Writer debug.lnk" "$INSTDIR\\bin\\dcpomatic2_dist_debug.bat" ""', file=f) + if disk: + print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Disk Writer debug.lnk" "$INSTDIR\\bin\\dcpomatic2_disk_debug.bat" ""', file=f) else: print('Section "DCP-o-matic 2 desktop shortcuts" SEC_MASTER_DESKTOP', file=f) print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Player.lnk" "$INSTDIR\\bin\\dcpomatic2_player.exe"', file=f) @@ -395,8 +395,8 @@ File "%binaries%/src/tools/dcpomatic2_playlist.exe" print('CreateShortCut "$DESKTOP\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe" ""', file=f) print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Batch Converter.lnk" "$INSTDIR\\bin\\dcpomatic2_batch.exe"', file=f) print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 KDM Creator.lnk" "$INSTDIR\\bin\\dcpomatic2_kdm.exe"', file=f) - if dist: - print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Disk Writer.lnk" "$INSTDIR\\bin\\dcpomatic2_dist.exe"', file=f) + if disk: + print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Disk Writer.lnk" "$INSTDIR\\bin\\dcpomatic2_disk.exe"', file=f) print("SectionEnd", file=f) @@ -480,7 +480,7 @@ DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\U def build(bld): - write_installer(32, None, bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DIST) - write_installer(64, None, bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DIST) - write_installer(32, 'xp', bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DIST) - write_installer(64, 'xp', bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DIST) + write_installer(32, None, bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DISK) + write_installer(64, None, bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DISK) + write_installer(32, 'xp', bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DISK) + write_installer(64, 'xp', bld.env.VERSION, bld.env.DEBUG, bld.env.VARIANT, bld.env.ENABLE_DISK) diff --git a/run/dcpomatic_disk b/run/dcpomatic_disk new file mode 100755 index 000000000..990800461 --- /dev/null +++ b/run/dcpomatic_disk @@ -0,0 +1,28 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/Users/carl/Environments/dcpomatic/64/lib +if [ "$1" == "--debug" ]; then + shift + gdb --args build/src/tools/dcpomatic2_disk $* +elif [ "$1" == "--valgrind" ]; then + shift + valgrind --tool="memcheck" --suppressions=suppressions --track-fds=yes --show-leak-kinds=all --leak-check=full build/src/tools/dcpomatic2_disk $* +elif [ "$1" == "--callgrind" ]; then + shift + valgrind --tool="callgrind" build/src/tools/dcpomatic2_disk $* +elif [ "$1" == "--massif" ]; then + shift + valgrind --tool="massif" build/src/tools/dcpomatic2_disk $* +elif [ "$1" == "--i18n" ]; then + shift + LANGUAGE=de_DE.UTF8 LANG=de_DE.UTF8 LC_ALL=de_DE.UTF8 build/src/tools/dcpomatic2_disk "$*" +elif [ "$1" == "--perf" ]; then + shift + perf record build/src/tools/dcpomatic2_disk $* +elif [ "$1" == "--scaled" ]; then + shift + ~/src/run_scaled/run_scaled --sleep=5 --scale=0.5 build/src/tools/dcpomatic2_disk $* +else + build/src/tools/dcpomatic2_disk $* +fi diff --git a/run/dcpomatic_disk_writer b/run/dcpomatic_disk_writer new file mode 100755 index 000000000..58164e088 --- /dev/null +++ b/run/dcpomatic_disk_writer @@ -0,0 +1,31 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/Users/carl/Environments/dcpomatic/64/lib +exe=build/src/tools/dcpomatic2_disk_writer +sudo chown root:root $exe +sudo chmod 4755 $exe +if [ "$1" == "--debug" ]; then + shift + gdb --args $exe $* +elif [ "$1" == "--valgrind" ]; then + shift + valgrind --tool="memcheck" --suppressions=suppressions --track-fds=yes --show-leak-kinds=all --leak-check=full $exe $* +elif [ "$1" == "--callgrind" ]; then + shift + valgrind --tool="callgrind" $exe $* +elif [ "$1" == "--massif" ]; then + shift + valgrind --tool="massif" $exe $* +elif [ "$1" == "--i18n" ]; then + shift + LANGUAGE=de_DE.UTF8 LANG=de_DE.UTF8 LC_ALL=de_DE.UTF8 $exe "$*" +elif [ "$1" == "--perf" ]; then + shift + perf record $exe $* +elif [ "$1" == "--scaled" ]; then + shift + ~/src/run_scaled/run_scaled --sleep=5 --scale=0.5 $exe $* +else + $exe $* +fi diff --git a/run/dcpomatic_dist b/run/dcpomatic_dist deleted file mode 100755 index 0a243ea11..000000000 --- a/run/dcpomatic_dist +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/home/c.hetherington/lib:$LD_LIBRARY_PATH -export DYLD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/Users/carl/Environments/dcpomatic/64/lib -if [ "$1" == "--debug" ]; then - shift - gdb --args build/src/tools/dcpomatic2_dist $* -elif [ "$1" == "--valgrind" ]; then - shift - valgrind --tool="memcheck" --suppressions=suppressions --track-fds=yes --show-leak-kinds=all --leak-check=full build/src/tools/dcpomatic2_dist $* -elif [ "$1" == "--callgrind" ]; then - shift - valgrind --tool="callgrind" build/src/tools/dcpomatic2_dist $* -elif [ "$1" == "--massif" ]; then - shift - valgrind --tool="massif" build/src/tools/dcpomatic2_dist $* -elif [ "$1" == "--i18n" ]; then - shift - LANGUAGE=de_DE.UTF8 LANG=de_DE.UTF8 LC_ALL=de_DE.UTF8 build/src/tools/dcpomatic2_dist "$*" -elif [ "$1" == "--perf" ]; then - shift - perf record build/src/tools/dcpomatic2_dist $* -elif [ "$1" == "--scaled" ]; then - shift - ~/src/run_scaled/run_scaled --sleep=5 --scale=0.5 build/src/tools/dcpomatic2_dist $* -else - build/src/tools/dcpomatic2_dist $* -fi diff --git a/run/dcpomatic_dist_writer b/run/dcpomatic_dist_writer deleted file mode 100755 index abb3949d6..000000000 --- a/run/dcpomatic_dist_writer +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/home/c.hetherington/lib:$LD_LIBRARY_PATH -export DYLD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/Users/carl/Environments/dcpomatic/64/lib -exe=build/src/tools/dcpomatic2_dist_writer -sudo chown root:root $exe -sudo chmod 4755 $exe -if [ "$1" == "--debug" ]; then - shift - gdb --args $exe $* -elif [ "$1" == "--valgrind" ]; then - shift - valgrind --tool="memcheck" --suppressions=suppressions --track-fds=yes --show-leak-kinds=all --leak-check=full $exe $* -elif [ "$1" == "--callgrind" ]; then - shift - valgrind --tool="callgrind" $exe $* -elif [ "$1" == "--massif" ]; then - shift - valgrind --tool="massif" $exe $* -elif [ "$1" == "--i18n" ]; then - shift - LANGUAGE=de_DE.UTF8 LANG=de_DE.UTF8 LC_ALL=de_DE.UTF8 $exe "$*" -elif [ "$1" == "--perf" ]; then - shift - perf record $exe $* -elif [ "$1" == "--scaled" ]; then - shift - ~/src/run_scaled/run_scaled --sleep=5 --scale=0.5 $exe $* -else - $exe $* -fi diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index bd551e00c..aaba3aaaf 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -70,18 +70,18 @@ CopyToDriveJob::run () while (true) { bool formatting = false; string s = _nanomsg.blocking_get (); - if (s == DIST_WRITER_OK) { + if (s == DISK_WRITER_OK) { set_state (FINISHED_OK); return; - } else if (s == DIST_WRITER_ERROR) { + } else if (s == DISK_WRITER_ERROR) { string const m = _nanomsg.blocking_get (); string const n = _nanomsg.blocking_get (); throw CopyError (m, raw_convert(n)); - } else if (s == DIST_WRITER_FORMATTING) { + } else if (s == DISK_WRITER_FORMATTING) { sub ("Formatting drive"); set_progress_unknown (); formatting = true; - } else if (s == DIST_WRITER_PROGRESS) { + } else if (s == DISK_WRITER_PROGRESS) { if (formatting) { sub ("Copying DCP"); formatting = false; diff --git a/src/lib/cross.h b/src/lib/cross.h index 63e542dc9..20bab38a2 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -45,7 +45,7 @@ extern std::string cpu_info (); extern void run_ffprobe (boost::filesystem::path, boost::filesystem::path); extern std::list > mount_info (); extern boost::filesystem::path openssl_path (); -extern boost::filesystem::path dist_writer_path (); +extern boost::filesystem::path disk_writer_path (); #ifdef DCPOMATIC_OSX extern boost::filesystem::path app_contents (); #endif diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index 239d10c31..bf319bcac 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -141,9 +141,9 @@ openssl_path () } boost::filesystem::path -dist_writer_path () +disk_writer_path () { - return boost::dll::program_location().parent_path() / "dcpomatic2_dist_writer"; + return boost::dll::program_location().parent_path() / "dcpomatic2_disk_writer"; } /* Apparently there is no way to create an ofstream using a UTF-8 @@ -267,7 +267,7 @@ get_drives () boost::algorithm::split (bits, line, boost::is_any_of(" ")); if (bits.size() > 0 && boost::algorithm::starts_with(bits[0], "/dev/")) { mounted_devices.push_back(bits[0]); - LOG_DIST("Mounted device %1", bits[0]); + LOG_DISK("Mounted device %1", bits[0]); } } @@ -302,7 +302,7 @@ get_drives () } } drives.push_back(Drive("/dev/" + i->path().filename().string(), size, mounted, vendor, model)); - LOG_DIST("Block device %1 size %2 %3 vendor %4 model %5", name, size, mounted ? "mounted" : "not mounted", vendor.get_value_or("[none]"), model.get_value_or("[none]")); + LOG_DISK("Block device %1 size %2 %3 vendor %4 model %5", name, size, mounted ? "mounted" : "not mounted", vendor.get_value_or("[none]"), model.get_value_or("[none]")); } } diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index 115d3e91e..edc81fb59 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -128,11 +128,11 @@ openssl_path () } boost::filesystem::path -dist_writer_path () +disk_writer_path () { boost::filesystem::path path = app_contents(); path /= "MacOS"; - path /= "dcpomatic2_dist_writer"; + path /= "dcpomatic2_disk_writer"; return path; } diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc index 697b45ef0..169435a51 100644 --- a/src/lib/cross_windows.cc +++ b/src/lib/cross_windows.cc @@ -199,9 +199,9 @@ openssl_path () } boost::filesystem::path -dist_writer_path () +disk_writer_path () { - return executable_path() / "dcpomatic2_dist_writer.exe"; + return executable_path() / "dcpomatic2_disk_writer.exe"; } /* Apparently there is no way to create an ofstream using a UTF-8 @@ -360,7 +360,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data) BOOL r = SetupDiEnumDeviceInterfaces (device_info, device_info_data, &GUID_DEVICE_INTERFACE_DISK, 0, &device_interface_data); if (!r) { - LOG_DIST("SetupDiEnumDeviceInterfaces failed (%1)", GetLastError()); + LOG_DISK("SetupDiEnumDeviceInterfaces failed (%1)", GetLastError()); return optional(); } @@ -369,7 +369,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data) r = SetupDiGetDeviceInterfaceDetailW(device_info, &device_interface_data, 0, 0, &size, 0); PSP_DEVICE_INTERFACE_DETAIL_DATA_W device_detail_data = static_cast (malloc(size)); if (!device_detail_data) { - LOG_DIST_NC("malloc failed"); + LOG_DISK_NC("malloc failed"); return optional(); } @@ -378,7 +378,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data) /* And get the path */ r = SetupDiGetDeviceInterfaceDetailW (device_info, &device_interface_data, device_detail_data, size, &size, 0); if (!r) { - LOG_DIST_NC("SetupDiGetDeviceInterfaceDetailW failed"); + LOG_DISK_NC("SetupDiGetDeviceInterfaceDetailW failed"); free (device_detail_data); return optional(); } @@ -395,7 +395,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data) free (device_detail_data); if (device == INVALID_HANDLE_VALUE) { - LOG_DIST("CreateFileW failed with %1", GetLastError()); + LOG_DISK("CreateFileW failed with %1", GetLastError()); return optional(); } @@ -481,7 +481,7 @@ get_drives () /* Get a `device information set' containing information about all disks */ HDEVINFO device_info = SetupDiGetClassDevsA (&GUID_DEVICE_INTERFACE_DISK, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (device_info == INVALID_HANDLE_VALUE) { - LOG_DIST_NC ("SetupDiClassDevsA failed"); + LOG_DISK_NC ("SetupDiClassDevsA failed"); return drives; } @@ -493,7 +493,7 @@ get_drives () if (!SetupDiEnumDeviceInfo(device_info, i, &device_info_data)) { DWORD e = GetLastError(); if (e != ERROR_NO_MORE_ITEMS) { - LOG_DIST ("SetupDiEnumDeviceInfo failed (%1)", GetLastError()); + LOG_DISK ("SetupDiEnumDeviceInfo failed (%1)", GetLastError()); } break; } @@ -514,7 +514,7 @@ get_drives () ); if (device == INVALID_HANDLE_VALUE) { - LOG_DIST_NC("Could not open PHYSICALDRIVE"); + LOG_DISK_NC("Could not open PHYSICALDRIVE"); continue; } diff --git a/src/lib/dcpomatic_log.h b/src/lib/dcpomatic_log.h index f8dc03bc4..382a586d4 100644 --- a/src/lib/dcpomatic_log.h +++ b/src/lib/dcpomatic_log.h @@ -36,5 +36,5 @@ extern boost::shared_ptr dcpomatic_log; #define LOG_DEBUG_PLAYER(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DEBUG_PLAYER); #define LOG_DEBUG_THREED(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DEBUG_THREED); #define LOG_DEBUG_THREED_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_DEBUG_THREED); -#define LOG_DIST(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DIST); -#define LOG_DIST_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_DIST); +#define LOG_DISK(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DISK); +#define LOG_DISK_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_DISK); diff --git a/src/lib/disk_writer_messages.h b/src/lib/disk_writer_messages.h new file mode 100644 index 000000000..61cdbcfbd --- /dev/null +++ b/src/lib/disk_writer_messages.h @@ -0,0 +1,77 @@ +/* + Copyright (C) 2020 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +/* dcpomatic_disk_writer receives + +DCP pathname\n +Internal name of drive to write to\n + + Then responds with one of the following. +*/ + +/** Write finished and everything was OK, e.g. + +D\n + +*/ +#define DISK_WRITER_OK "D" + +/** There was an error. Following this will come + +error message\n +error number\n + +e.g. + +E\n +Disc full\n +42\n + +*/ +#define DISK_WRITER_ERROR "E" + +/** The disk writer is formatting the drive. It is not possible + * to give progress reports on this so the writer just tells us + * it's happening. This is finished when DISK_WRITER_PROGRESS + * messages start arriving + */ +#define DISK_WRITER_FORMATTING "F" + +/** Some progress has been made in the main "copy" part of the task. + * Following this will come + +progress as a float from 0 to 1\n + +e.g. + +P\n +0.3\n + +*/ +#define DISK_WRITER_PROGRESS "P" + +/** dcpomatic_disk_writer may also receive + +Q\n + +as a request to quit. +*/ +#define DISK_WRITER_QUIT "Q" + diff --git a/src/lib/dist_writer_messages.h b/src/lib/dist_writer_messages.h deleted file mode 100644 index d0a541ddd..000000000 --- a/src/lib/dist_writer_messages.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2020 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - -/* dcpomatic_dist_writer receives - -DCP pathname\n -Internal name of drive to write to\n - - Then responds with one of the following. -*/ - -/** Write finished and everything was OK, e.g. - -D\n - -*/ -#define DIST_WRITER_OK "D" - -/** There was an error. Following this will come - -error message\n -error number\n - -e.g. - -E\n -Disc full\n -42\n - -*/ -#define DIST_WRITER_ERROR "E" - -/** The disk writer is formatting the drive. It is not possible - * to give progress reports on this so the writer just tells us - * it's happening. This is finished when DIST_WRITER_PROGRESS - * messages start arriving - */ -#define DIST_WRITER_FORMATTING "F" - -/** Some progress has been made in the main "copy" part of the task. - * Following this will come - -progress as a float from 0 to 1\n - -e.g. - -P\n -0.3\n - -*/ -#define DIST_WRITER_PROGRESS "P" - -/** dcpomatic_dist_writer may also receive - -Q\n - -as a request to quit. -*/ -#define DIST_WRITER_QUIT "Q" - diff --git a/src/lib/log_entry.cc b/src/lib/log_entry.cc index eecd35f01..4aff47c73 100644 --- a/src/lib/log_entry.cc +++ b/src/lib/log_entry.cc @@ -32,7 +32,7 @@ int const LogEntry::TYPE_DEBUG_ENCODE = 0x010; int const LogEntry::TYPE_TIMING = 0x020; int const LogEntry::TYPE_DEBUG_EMAIL = 0x040; int const LogEntry::TYPE_DEBUG_PLAYER = 0x080; -int const LogEntry::TYPE_DIST = 0x100; +int const LogEntry::TYPE_DISK = 0x100; using std::string; diff --git a/src/lib/log_entry.h b/src/lib/log_entry.h index e8c97b790..d4992de86 100644 --- a/src/lib/log_entry.h +++ b/src/lib/log_entry.h @@ -36,7 +36,7 @@ public: static const int TYPE_TIMING; static const int TYPE_DEBUG_EMAIL; static const int TYPE_DEBUG_PLAYER; - static const int TYPE_DIST; + static const int TYPE_DISK; explicit LogEntry (int type); virtual ~LogEntry () {} diff --git a/src/lib/wscript b/src/lib/wscript index f2ad9714e..2c1b92005 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -204,7 +204,7 @@ def build(bld): if bld.env.VARIANT == 'swaroop-theater' or bld.env.VARIANT == 'swaroop-studio': obj.source += ' swaroop_spl.cc swaroop_spl_entry.cc' - if bld.env.ENABLE_DIST: + if bld.env.ENABLE_DISK: obj.source += ' copy_to_drive_job.cc' obj.uselib += ' LWEXT4 NANOMSG' if bld.env.TARGET_LINUX: diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc new file mode 100644 index 000000000..28945deff --- /dev/null +++ b/src/tools/dcpomatic_disk.cc @@ -0,0 +1,304 @@ +/* + Copyright (C) 2019-2020 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#include "wx/wx_signal_manager.h" +#include "wx/wx_util.h" +#include "wx/job_manager_view.h" +#include "wx/drive_wipe_warning_dialog.h" +#include "lib/file_log.h" +#include "lib/dcpomatic_log.h" +#include "lib/util.h" +#include "lib/config.h" +#include "lib/signal_manager.h" +#include "lib/cross.h" +#include "lib/copy_to_drive_job.h" +#include "lib/job_manager.h" +#include "lib/disk_writer_messages.h" +#include +#include +#ifdef DCPOMATIC_WINDOWS +#include +#endif +#ifdef DCPOMATIC_OSX +#include +#endif + +using std::string; +using std::exception; +using std::cout; +using std::cerr; +using std::runtime_error; +using boost::shared_ptr; + +class DOMFrame : public wxFrame +{ +public: + explicit DOMFrame (wxString const & title) + : wxFrame (0, -1, title) + , _nanomsg (true) + , _sizer (new wxBoxSizer(wxVERTICAL)) + { + /* Use a panel as the only child of the Frame so that we avoid + the dark-grey background on Windows. + */ + wxPanel* overall_panel = new wxPanel (this); + wxSizer* s = new wxBoxSizer (wxHORIZONTAL); + s->Add (overall_panel, 1, wxEXPAND); + SetSizer (s); + + wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + + int r = 0; + add_label_to_sizer (grid, overall_panel, _("DCP"), true, wxGBPosition(r, 0)); + wxBoxSizer* dcp_name_sizer = new wxBoxSizer (wxHORIZONTAL); + _dcp_name = new wxStaticText (overall_panel, wxID_ANY, wxEmptyString); + dcp_name_sizer->Add (_dcp_name, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_X_GAP); + _dcp_open = new wxButton (overall_panel, wxID_ANY, _("Open...")); + dcp_name_sizer->Add (_dcp_open, 0); + grid->Add (dcp_name_sizer, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND); + ++r; + + add_label_to_sizer (grid, overall_panel, _("Drive"), true, wxGBPosition(r, 0)); + wxBoxSizer* drive_sizer = new wxBoxSizer (wxHORIZONTAL); + _drive = new wxChoice (overall_panel, wxID_ANY); + drive_sizer->Add (_drive, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_X_GAP); + _drive_refresh = new wxButton (overall_panel, wxID_ANY, _("Refresh")); + drive_sizer->Add (_drive_refresh, 0); + grid->Add (drive_sizer, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND); + ++r; + + _jobs = new JobManagerView (overall_panel, false); + grid->Add (_jobs, wxGBPosition(r, 0), wxGBSpan(6, 2), wxEXPAND); + r += 6; + + _copy = new wxButton (overall_panel, wxID_ANY, _("Copy DCP")); + grid->Add (_copy, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND); + ++r; + + grid->AddGrowableCol (1); + + _dcp_open->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::open, this)); + _copy->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::copy, this)); + _drive->Bind (wxEVT_CHOICE, boost::bind(&DOMFrame::setup_sensitivity, this)); + _drive_refresh->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::drive_refresh, this)); + + _sizer->Add (grid, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER); + overall_panel->SetSizer (_sizer); + Fit (); + SetSize (768, GetSize().GetHeight() + 32); + + /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's + * a better place to put them. + */ + dcpomatic_log.reset(new FileLog(config_path() / "disk.log")); + dcpomatic_log->set_types (dcpomatic_log->types() | LogEntry::TYPE_DISK); + LOG_DISK_NC("dcpomatic_disk started"); + + drive_refresh (); + + Bind (wxEVT_SIZE, boost::bind (&DOMFrame::sized, this, _1)); + + JobManager::instance()->ActiveJobsChanged.connect(boost::bind(&DOMFrame::setup_sensitivity, this)); + +#ifdef DCPOMATIC_WINDOWS + /* We must use ::shell here, it seems, to avoid error code 740 (related to privilege escalation) */ + _writer = new boost::process::child (disk_writer_path(), boost::process::shell, boost::process::windows::hide); +#else + LOG_DISK("Starting writer process %1", disk_writer_path().string()); + _writer = new boost::process::child (disk_writer_path()); +#endif + } + + ~DOMFrame () + { + _nanomsg.blocking_send(DISK_WRITER_QUIT "\n"); + } + +private: + void sized (wxSizeEvent& ev) + { + _sizer->Layout (); + ev.Skip (); + } + + void open () + { + wxDirDialog* d = new wxDirDialog (this, _("Choose a DCP folder"), wxT(""), wxDD_DIR_MUST_EXIST); + int r = d->ShowModal (); + boost::filesystem::path const path (wx_to_std(d->GetPath())); + d->Destroy (); + + if (r != wxID_OK) { + return; + } + + _dcp_path = path; + _dcp_name->SetLabel (std_to_wx(_dcp_path->filename().string())); + setup_sensitivity (); + } + + void copy () + { + DCPOMATIC_ASSERT (_drive->GetSelection() != wxNOT_FOUND); + DCPOMATIC_ASSERT (static_cast(_dcp_path)); + DriveWipeWarningDialog* d = new DriveWipeWarningDialog (this, _drive->GetString(_drive->GetSelection())); + int const r = d->ShowModal (); + bool ok = r == wxID_OK && d->confirmed(); + d->Destroy (); + + if (!ok) { + return; + } + + JobManager::instance()->add(shared_ptr(new CopyToDriveJob(*_dcp_path, _drives[_drive->GetSelection()], _nanomsg))); + setup_sensitivity (); + } + + void drive_refresh () + { + int const sel = _drive->GetSelection (); + wxString current; + if (sel != wxNOT_FOUND) { + current = _drive->GetString (sel); + } + _drive->Clear (); + int re_select = wxNOT_FOUND; + int j = 0; + _drives.clear (); + BOOST_FOREACH (Drive i, get_drives()) { + if (!i.mounted()) { + _drives.push_back (i); + } + } + BOOST_FOREACH (Drive i, _drives) { + wxString const s = std_to_wx(i.description()); + if (s == current) { + re_select = j; + } + _drive->Append(s); + ++j; + } + _drive->SetSelection (re_select); + setup_sensitivity (); + } + + void setup_sensitivity () + { + _copy->Enable (static_cast(_dcp_path) && _drive->GetSelection() != wxNOT_FOUND && !JobManager::instance()->work_to_do()); + } + + wxStaticText* _dcp_name; + wxButton* _dcp_open; + wxChoice* _drive; + wxButton* _drive_refresh; + wxButton* _copy; + JobManagerView* _jobs; + boost::optional _dcp_path; + std::vector _drives; + boost::process::child* _writer; + Nanomsg _nanomsg; + wxSizer* _sizer; +}; + +class App : public wxApp +{ +public: + App () + : _frame (0) + {} + + bool OnInit () + { + try { + Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); + Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); + + SetAppName (_("DCP-o-matic Disk Writer")); + + if (!wxApp::OnInit()) { + return false; + } + +#ifdef DCPOMATIC_LINUX + unsetenv ("UBUNTU_MENUPROXY"); +#endif + +#ifdef __WXOSX__ + ProcessSerialNumber serial; + GetCurrentProcess (&serial); + TransformProcessType (&serial, kProcessTransformToForegroundApplication); +#endif + + dcpomatic_setup_path_encoding (); + + /* Enable i18n; this will create a Config object + to look for a force-configured language. This Config + object will be wrong, however, because dcpomatic_setup + hasn't yet been called and there aren't any filters etc. + set up yet. + */ + dcpomatic_setup_i18n (); + + /* Set things up, including filters etc. + which will now be internationalised correctly. + */ + dcpomatic_setup (); + + /* Force the configuration to be re-loaded correctly next + time it is needed. + */ + Config::drop (); + + _frame = new DOMFrame (_("DCP-o-matic Disk Writer")); + SetTopWindow (_frame); + + _frame->Show (); + + signal_manager = new wxSignalManager (this); + Bind (wxEVT_IDLE, boost::bind (&App::idle, this, _1)); + } + catch (exception& e) + { + error_dialog (0, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what())); + } + + return true; + } + + void config_failed_to_load () + { + message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); + } + + void config_warning (string m) + { + message_dialog (_frame, std_to_wx(m)); + } + + void idle (wxIdleEvent& ev) + { + signal_manager->ui_idle (); + ev.Skip (); + } + + DOMFrame* _frame; +}; + +IMPLEMENT_APP (App) diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc new file mode 100644 index 000000000..08f06ff02 --- /dev/null +++ b/src/tools/dcpomatic_disk_writer.cc @@ -0,0 +1,421 @@ +/* + Copyright (C) 2019-2020 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#include "lib/disk_writer_messages.h" +#include "lib/compose.hpp" +#include "lib/exceptions.h" +#include "lib/cross.h" +#include "lib/digester.h" +#include "lib/file_log.h" +#include "lib/dcpomatic_log.h" +#include "lib/nanomsg.h" +extern "C" { +#include +#include +#include +#include +#include +#include +} + +#ifdef DCPOMATIC_POSIX +#include +#include +#include +#endif + +#ifdef DCPOMATIC_OSX +#undef nil +extern "C" { +#include +} +#endif + +#ifdef DCPOMATIC_LINUX +#include +#include +extern "C" { +#include +} +#include +#endif + +#ifdef DCPOMATIC_WINDOWS +extern "C" { +#include +} +#endif + +#include +#include +#include +#include +#include + +using std::cin; +using std::min; +using std::string; +using std::runtime_error; +using std::exception; +using boost::optional; + +#ifdef DCPOMATIC_LINUX +static PolkitAuthority* polkit_authority = 0; +#endif +static boost::filesystem::path dcp_path; +static std::string device; +static uint64_t const block_size = 4096; +static Nanomsg* nanomsg = 0; + +static +void +count (boost::filesystem::path dir, uint64_t& total_bytes) +{ + using namespace boost::filesystem; + for (directory_iterator i = directory_iterator(dir); i != directory_iterator(); ++i) { + if (is_directory(*i)) { + count (*i, total_bytes); + } else { + total_bytes += file_size (*i); + } + } +} + +static +string +write (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total) +{ + ext4_file out; + int r = ext4_fopen(&out, to.generic_string().c_str(), "wb"); + if (r != EOK) { + throw CopyError (String::compose("Failed to open file %1", to.generic_string()), r); + } + + FILE* in = fopen_boost (from, "rb"); + if (!in) { + ext4_fclose (&out); + throw CopyError (String::compose("Failed to open file %1", from.string()), 0); + } + + uint8_t* buffer = new uint8_t[block_size]; + Digester digester; + + uint64_t remaining = file_size (from); + while (remaining > 0) { + uint64_t const this_time = min(remaining, block_size); + size_t read = fread (buffer, 1, this_time, in); + if (read != this_time) { + fclose (in); + ext4_fclose (&out); + delete[] buffer; + throw CopyError (String::compose("Short read; expected %1 but read %2", this_time, read), 0); + } + + digester.add (buffer, this_time); + + size_t written; + r = ext4_fwrite (&out, buffer, this_time, &written); + if (r != EOK) { + fclose (in); + ext4_fclose (&out); + delete[] buffer; + throw CopyError ("Write failed", r); + } + if (written != this_time) { + fclose (in); + ext4_fclose (&out); + delete[] buffer; + throw CopyError (String::compose("Short write; expected %1 but wrote %2", this_time, written), 0); + } + remaining -= this_time; + total_remaining -= this_time; + nanomsg->blocking_send(String::compose(DISK_WRITER_PROGRESS "\n%1\n", (1 - float(total_remaining) / total))); + } + + fclose (in); + ext4_fclose (&out); + delete[] buffer; + + return digester.get (); +} + +static +string +read (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total) +{ + ext4_file in; + LOG_DISK("Opening %1 for read", to.generic_string()); + int r = ext4_fopen(&in, to.generic_string().c_str(), "rb"); + if (r != EOK) { + throw VerifyError (String::compose("Failed to open file %1", to.generic_string()), r); + } + LOG_DISK("Opened %1 for read", to.generic_string()); + + uint8_t* buffer = new uint8_t[block_size]; + Digester digester; + + uint64_t remaining = file_size (from); + while (remaining > 0) { + uint64_t const this_time = min(remaining, block_size); + size_t read; + r = ext4_fread (&in, buffer, this_time, &read); + if (read != this_time) { + ext4_fclose (&in); + delete[] buffer; + throw VerifyError (String::compose("Short read; expected %1 but read %2", this_time, read), 0); + } + + digester.add (buffer, this_time); + remaining -= this_time; + total_remaining -= this_time; + nanomsg->blocking_send(String::compose(DISK_WRITER_PROGRESS "\n%1\n", (1 - float(total_remaining) / total))); + } + + ext4_fclose (&in); + delete[] buffer; + + return digester.get (); +} + + +/** @param from File to copy from. + * @param to Directory to copy to. + */ +static +void +copy (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total) +{ + LOG_DISK ("Copy %1 -> %2", from.string(), to.generic_string()); + + using namespace boost::filesystem; + + path const cr = to / from.filename(); + + if (is_directory(from)) { + int r = ext4_dir_mk (cr.generic_string().c_str()); + if (r != EOK) { + throw CopyError (String::compose("Failed to create directory %1", cr.generic_string()), r); + } + + for (directory_iterator i = directory_iterator(from); i != directory_iterator(); ++i) { + copy (i->path(), cr, total_remaining, total); + } + } else { + string const write_digest = write (from, cr, total_remaining, total); + LOG_DISK ("Wrote %1 %2 with %3", from.string(), cr.generic_string(), write_digest); + string const read_digest = read (from, cr, total_remaining, total); + LOG_DISK ("Read %1 %2 with %3", from.string(), cr.generic_string(), write_digest); + if (write_digest != read_digest) { + throw VerifyError ("Hash of written data is incorrect", 0); + } + } +} + +static +void +write () +try +{ +// ext4_dmask_set (DEBUG_ALL); + + /* We rely on static initialization for these */ + static struct ext4_fs fs; + static struct ext4_mkfs_info info; + info.block_size = 1024; + info.inode_size = 128; + info.journal = false; + +#ifdef WIN32 + file_windows_name_set(device.c_str()); + struct ext4_blockdev* bd = file_windows_dev_get(); +#else + file_dev_name_set (device.c_str()); + struct ext4_blockdev* bd = file_dev_get (); +#endif + + if (!bd) { + throw CopyError ("Failed to open drive", 0); + } + LOG_DISK_NC ("Opened drive"); + + struct ext4_mbr_parts parts; + parts.division[0] = 100; + parts.division[1] = 0; + parts.division[2] = 0; + parts.division[3] = 0; + +#ifdef DCPOMATIC_LINUX + PrivilegeEscalator e; +#endif + + /* XXX: not sure if disk_id matters */ + int r = ext4_mbr_write (bd, &parts, 0); + + if (r) { + throw CopyError ("Failed to write MBR", r); + } + LOG_DISK_NC ("Wrote MBR"); + +#ifdef DCPOMATIC_WINDOWS + struct ext4_mbr_bdevs bdevs; + r = ext4_mbr_scan (bd, &bdevs); + if (r != EOK) { + throw CopyError ("Failed to read MBR", r); + } + + file_windows_partition_set (bdevs.partitions[0].part_offset, bdevs.partitions[0].part_size); +#endif + +#ifdef DCPOMATIC_LINUX + /* Re-read the partition table */ + int fd = open(device.c_str(), O_RDONLY); + ioctl(fd, BLKRRPART, NULL); + close(fd); +#endif + +#ifdef DCPOMATIC_POSIX + string partition = device; + /* XXX: don't know if this logic is sensible */ + if (partition.size() > 0 && isdigit(partition[partition.length() - 1])) { + partition += "p1"; + } else { + partition += "1"; + } + file_dev_name_set (partition.c_str()); + bd = file_dev_get (); +#endif + + if (!bd) { + throw CopyError ("Failed to open partition", 0); + } + LOG_DISK_NC ("Opened partition"); + + nanomsg->blocking_send(DISK_WRITER_FORMATTING "\n"); + + r = ext4_mkfs(&fs, bd, &info, F_SET_EXT4); + if (r != EOK) { + throw CopyError ("Failed to make filesystem", r); + } + LOG_DISK_NC ("Made filesystem"); + + r = ext4_device_register(bd, "ext4_fs"); + if (r != EOK) { + throw CopyError ("Failed to register device", r); + } + LOG_DISK_NC ("Registered device"); + + r = ext4_mount("ext4_fs", "/mp/", false); + if (r != EOK) { + throw CopyError ("Failed to mount device", r); + } + LOG_DISK_NC ("Mounted device"); + + uint64_t total_bytes = 0; + count (dcp_path, total_bytes); + + /* XXX: this is a hack. We are going to "treat" every byte twice; write it, and then verify it. Double the + * bytes totals so that progress works itself out (assuming write is the same speed as read). + */ + total_bytes *= 2; + copy (dcp_path, "/mp", total_bytes, total_bytes); + + r = ext4_umount("/mp/"); + if (r != EOK) { + throw CopyError ("Failed to unmount device", r); + } + + nanomsg->blocking_send(DISK_WRITER_OK "\n"); +} catch (CopyError& e) { + LOG_DISK("CopyError: %1 %2", e.message(), e.number()); + nanomsg->blocking_send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number())); +} catch (VerifyError& e) { + LOG_DISK("VerifyError: %1 %2", e.message(), e.number()); + nanomsg->blocking_send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number())); +} catch (exception& e) { + LOG_DISK("Exception: %1", e.what()); + nanomsg->blocking_send(String::compose(DISK_WRITER_ERROR "\n%1\n0\n", e.what())); +} + +#ifdef DCPOMATIC_LINUX +static +void +polkit_callback (GObject *, GAsyncResult* res, gpointer) +{ + PolkitAuthorizationResult* result = polkit_authority_check_authorization_finish (polkit_authority, res, 0); + if (result && polkit_authorization_result_get_is_authorized(result)) { + write (); + } + if (result) { + g_object_unref (result); + } +} +#endif + +bool +idle () +{ + optional s = nanomsg->nonblocking_get (); + if (!s) { + return true; + } + + if (*s == "Q") { + exit (EXIT_SUCCESS); + } else if (*s == "W") { + dcp_path = nanomsg->blocking_get(); + device = nanomsg->blocking_get(); + + LOG_DISK ("Here we go writing %1 to %2", dcp_path, device); + +#ifdef DCPOMATIC_LINUX + polkit_authority = polkit_authority_get_sync (0, 0); + PolkitSubject* subject = polkit_unix_process_new (getppid()); + polkit_authority_check_authorization ( + polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, 0 + ); +#else + write (); +#endif + } + + return true; +} + +int +main () +{ + /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's + * a better place to put them. + */ + dcpomatic_log.reset(new FileLog(config_path() / "disk_writer.log")); + dcpomatic_log->set_types (dcpomatic_log->types() | LogEntry::TYPE_DISK); + LOG_DISK_NC("dcpomatic_disk_writer started"); + + try { + nanomsg = new Nanomsg (false); + } catch (runtime_error& e) { + LOG_DISK_NC("Could not set up nanomsg socket"); + exit (EXIT_FAILURE); + } + + Glib::RefPtr ml = Glib::MainLoop::create (); + Glib::signal_timeout().connect(sigc::ptr_fun(&idle), 500); + ml->run (); +} diff --git a/src/tools/dcpomatic_dist.cc b/src/tools/dcpomatic_dist.cc deleted file mode 100644 index 16228b09a..000000000 --- a/src/tools/dcpomatic_dist.cc +++ /dev/null @@ -1,304 +0,0 @@ -/* - Copyright (C) 2019-2020 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - -#include "wx/wx_signal_manager.h" -#include "wx/wx_util.h" -#include "wx/job_manager_view.h" -#include "wx/drive_wipe_warning_dialog.h" -#include "lib/file_log.h" -#include "lib/dcpomatic_log.h" -#include "lib/util.h" -#include "lib/config.h" -#include "lib/signal_manager.h" -#include "lib/cross.h" -#include "lib/copy_to_drive_job.h" -#include "lib/job_manager.h" -#include "lib/dist_writer_messages.h" -#include -#include -#ifdef DCPOMATIC_WINDOWS -#include -#endif -#ifdef DCPOMATIC_OSX -#include -#endif - -using std::string; -using std::exception; -using std::cout; -using std::cerr; -using std::runtime_error; -using boost::shared_ptr; - -class DOMFrame : public wxFrame -{ -public: - explicit DOMFrame (wxString const & title) - : wxFrame (0, -1, title) - , _nanomsg (true) - , _sizer (new wxBoxSizer(wxVERTICAL)) - { - /* Use a panel as the only child of the Frame so that we avoid - the dark-grey background on Windows. - */ - wxPanel* overall_panel = new wxPanel (this); - wxSizer* s = new wxBoxSizer (wxHORIZONTAL); - s->Add (overall_panel, 1, wxEXPAND); - SetSizer (s); - - wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - - int r = 0; - add_label_to_sizer (grid, overall_panel, _("DCP"), true, wxGBPosition(r, 0)); - wxBoxSizer* dcp_name_sizer = new wxBoxSizer (wxHORIZONTAL); - _dcp_name = new wxStaticText (overall_panel, wxID_ANY, wxEmptyString); - dcp_name_sizer->Add (_dcp_name, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_X_GAP); - _dcp_open = new wxButton (overall_panel, wxID_ANY, _("Open...")); - dcp_name_sizer->Add (_dcp_open, 0); - grid->Add (dcp_name_sizer, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND); - ++r; - - add_label_to_sizer (grid, overall_panel, _("Drive"), true, wxGBPosition(r, 0)); - wxBoxSizer* drive_sizer = new wxBoxSizer (wxHORIZONTAL); - _drive = new wxChoice (overall_panel, wxID_ANY); - drive_sizer->Add (_drive, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_X_GAP); - _drive_refresh = new wxButton (overall_panel, wxID_ANY, _("Refresh")); - drive_sizer->Add (_drive_refresh, 0); - grid->Add (drive_sizer, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND); - ++r; - - _jobs = new JobManagerView (overall_panel, false); - grid->Add (_jobs, wxGBPosition(r, 0), wxGBSpan(6, 2), wxEXPAND); - r += 6; - - _copy = new wxButton (overall_panel, wxID_ANY, _("Copy DCP")); - grid->Add (_copy, wxGBPosition(r, 0), wxGBSpan(1, 2), wxEXPAND); - ++r; - - grid->AddGrowableCol (1); - - _dcp_open->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::open, this)); - _copy->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::copy, this)); - _drive->Bind (wxEVT_CHOICE, boost::bind(&DOMFrame::setup_sensitivity, this)); - _drive_refresh->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::drive_refresh, this)); - - _sizer->Add (grid, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER); - overall_panel->SetSizer (_sizer); - Fit (); - SetSize (768, GetSize().GetHeight() + 32); - - /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's - * a better place to put them. - */ - dcpomatic_log.reset(new FileLog(config_path() / "dist.log")); - dcpomatic_log->set_types (dcpomatic_log->types() | LogEntry::TYPE_DIST); - LOG_DIST_NC("dcpomatic_dist started"); - - drive_refresh (); - - Bind (wxEVT_SIZE, boost::bind (&DOMFrame::sized, this, _1)); - - JobManager::instance()->ActiveJobsChanged.connect(boost::bind(&DOMFrame::setup_sensitivity, this)); - -#ifdef DCPOMATIC_WINDOWS - /* We must use ::shell here, it seems, to avoid error code 740 (related to privilege escalation) */ - _writer = new boost::process::child (dist_writer_path(), boost::process::shell, boost::process::windows::hide); -#else - LOG_DIST("Starting writer process %1", dist_writer_path().string()); - _writer = new boost::process::child (dist_writer_path()); -#endif - } - - ~DOMFrame () - { - _nanomsg.blocking_send(DIST_WRITER_QUIT "\n"); - } - -private: - void sized (wxSizeEvent& ev) - { - _sizer->Layout (); - ev.Skip (); - } - - void open () - { - wxDirDialog* d = new wxDirDialog (this, _("Choose a DCP folder"), wxT(""), wxDD_DIR_MUST_EXIST); - int r = d->ShowModal (); - boost::filesystem::path const path (wx_to_std(d->GetPath())); - d->Destroy (); - - if (r != wxID_OK) { - return; - } - - _dcp_path = path; - _dcp_name->SetLabel (std_to_wx(_dcp_path->filename().string())); - setup_sensitivity (); - } - - void copy () - { - DCPOMATIC_ASSERT (_drive->GetSelection() != wxNOT_FOUND); - DCPOMATIC_ASSERT (static_cast(_dcp_path)); - DriveWipeWarningDialog* d = new DriveWipeWarningDialog (this, _drive->GetString(_drive->GetSelection())); - int const r = d->ShowModal (); - bool ok = r == wxID_OK && d->confirmed(); - d->Destroy (); - - if (!ok) { - return; - } - - JobManager::instance()->add(shared_ptr(new CopyToDriveJob(*_dcp_path, _drives[_drive->GetSelection()], _nanomsg))); - setup_sensitivity (); - } - - void drive_refresh () - { - int const sel = _drive->GetSelection (); - wxString current; - if (sel != wxNOT_FOUND) { - current = _drive->GetString (sel); - } - _drive->Clear (); - int re_select = wxNOT_FOUND; - int j = 0; - _drives.clear (); - BOOST_FOREACH (Drive i, get_drives()) { - if (!i.mounted()) { - _drives.push_back (i); - } - } - BOOST_FOREACH (Drive i, _drives) { - wxString const s = std_to_wx(i.description()); - if (s == current) { - re_select = j; - } - _drive->Append(s); - ++j; - } - _drive->SetSelection (re_select); - setup_sensitivity (); - } - - void setup_sensitivity () - { - _copy->Enable (static_cast(_dcp_path) && _drive->GetSelection() != wxNOT_FOUND && !JobManager::instance()->work_to_do()); - } - - wxStaticText* _dcp_name; - wxButton* _dcp_open; - wxChoice* _drive; - wxButton* _drive_refresh; - wxButton* _copy; - JobManagerView* _jobs; - boost::optional _dcp_path; - std::vector _drives; - boost::process::child* _writer; - Nanomsg _nanomsg; - wxSizer* _sizer; -}; - -class App : public wxApp -{ -public: - App () - : _frame (0) - {} - - bool OnInit () - { - try { - Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); - Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); - - SetAppName (_("DCP-o-matic Disk Writer")); - - if (!wxApp::OnInit()) { - return false; - } - -#ifdef DCPOMATIC_LINUX - unsetenv ("UBUNTU_MENUPROXY"); -#endif - -#ifdef __WXOSX__ - ProcessSerialNumber serial; - GetCurrentProcess (&serial); - TransformProcessType (&serial, kProcessTransformToForegroundApplication); -#endif - - dcpomatic_setup_path_encoding (); - - /* Enable i18n; this will create a Config object - to look for a force-configured language. This Config - object will be wrong, however, because dcpomatic_setup - hasn't yet been called and there aren't any filters etc. - set up yet. - */ - dcpomatic_setup_i18n (); - - /* Set things up, including filters etc. - which will now be internationalised correctly. - */ - dcpomatic_setup (); - - /* Force the configuration to be re-loaded correctly next - time it is needed. - */ - Config::drop (); - - _frame = new DOMFrame (_("DCP-o-matic Disk Writer")); - SetTopWindow (_frame); - - _frame->Show (); - - signal_manager = new wxSignalManager (this); - Bind (wxEVT_IDLE, boost::bind (&App::idle, this, _1)); - } - catch (exception& e) - { - error_dialog (0, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what())); - } - - return true; - } - - void config_failed_to_load () - { - message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); - } - - void config_warning (string m) - { - message_dialog (_frame, std_to_wx(m)); - } - - void idle (wxIdleEvent& ev) - { - signal_manager->ui_idle (); - ev.Skip (); - } - - DOMFrame* _frame; -}; - -IMPLEMENT_APP (App) diff --git a/src/tools/dcpomatic_dist_writer.cc b/src/tools/dcpomatic_dist_writer.cc deleted file mode 100644 index f7ed50345..000000000 --- a/src/tools/dcpomatic_dist_writer.cc +++ /dev/null @@ -1,421 +0,0 @@ -/* - Copyright (C) 2019-2020 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - -#include "lib/dist_writer_messages.h" -#include "lib/compose.hpp" -#include "lib/exceptions.h" -#include "lib/cross.h" -#include "lib/digester.h" -#include "lib/file_log.h" -#include "lib/dcpomatic_log.h" -#include "lib/nanomsg.h" -extern "C" { -#include -#include -#include -#include -#include -#include -} - -#ifdef DCPOMATIC_POSIX -#include -#include -#include -#endif - -#ifdef DCPOMATIC_OSX -#undef nil -extern "C" { -#include -} -#endif - -#ifdef DCPOMATIC_LINUX -#include -#include -extern "C" { -#include -} -#include -#endif - -#ifdef DCPOMATIC_WINDOWS -extern "C" { -#include -} -#endif - -#include -#include -#include -#include -#include - -using std::cin; -using std::min; -using std::string; -using std::runtime_error; -using std::exception; -using boost::optional; - -#ifdef DCPOMATIC_LINUX -static PolkitAuthority* polkit_authority = 0; -#endif -static boost::filesystem::path dcp_path; -static std::string device; -static uint64_t const block_size = 4096; -static Nanomsg* nanomsg = 0; - -static -void -count (boost::filesystem::path dir, uint64_t& total_bytes) -{ - using namespace boost::filesystem; - for (directory_iterator i = directory_iterator(dir); i != directory_iterator(); ++i) { - if (is_directory(*i)) { - count (*i, total_bytes); - } else { - total_bytes += file_size (*i); - } - } -} - -static -string -write (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total) -{ - ext4_file out; - int r = ext4_fopen(&out, to.generic_string().c_str(), "wb"); - if (r != EOK) { - throw CopyError (String::compose("Failed to open file %1", to.generic_string()), r); - } - - FILE* in = fopen_boost (from, "rb"); - if (!in) { - ext4_fclose (&out); - throw CopyError (String::compose("Failed to open file %1", from.string()), 0); - } - - uint8_t* buffer = new uint8_t[block_size]; - Digester digester; - - uint64_t remaining = file_size (from); - while (remaining > 0) { - uint64_t const this_time = min(remaining, block_size); - size_t read = fread (buffer, 1, this_time, in); - if (read != this_time) { - fclose (in); - ext4_fclose (&out); - delete[] buffer; - throw CopyError (String::compose("Short read; expected %1 but read %2", this_time, read), 0); - } - - digester.add (buffer, this_time); - - size_t written; - r = ext4_fwrite (&out, buffer, this_time, &written); - if (r != EOK) { - fclose (in); - ext4_fclose (&out); - delete[] buffer; - throw CopyError ("Write failed", r); - } - if (written != this_time) { - fclose (in); - ext4_fclose (&out); - delete[] buffer; - throw CopyError (String::compose("Short write; expected %1 but wrote %2", this_time, written), 0); - } - remaining -= this_time; - total_remaining -= this_time; - nanomsg->blocking_send(String::compose(DIST_WRITER_PROGRESS "\n%1\n", (1 - float(total_remaining) / total))); - } - - fclose (in); - ext4_fclose (&out); - delete[] buffer; - - return digester.get (); -} - -static -string -read (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total) -{ - ext4_file in; - LOG_DIST("Opening %1 for read", to.generic_string()); - int r = ext4_fopen(&in, to.generic_string().c_str(), "rb"); - if (r != EOK) { - throw VerifyError (String::compose("Failed to open file %1", to.generic_string()), r); - } - LOG_DIST("Opened %1 for read", to.generic_string()); - - uint8_t* buffer = new uint8_t[block_size]; - Digester digester; - - uint64_t remaining = file_size (from); - while (remaining > 0) { - uint64_t const this_time = min(remaining, block_size); - size_t read; - r = ext4_fread (&in, buffer, this_time, &read); - if (read != this_time) { - ext4_fclose (&in); - delete[] buffer; - throw VerifyError (String::compose("Short read; expected %1 but read %2", this_time, read), 0); - } - - digester.add (buffer, this_time); - remaining -= this_time; - total_remaining -= this_time; - nanomsg->blocking_send(String::compose(DIST_WRITER_PROGRESS "\n%1\n", (1 - float(total_remaining) / total))); - } - - ext4_fclose (&in); - delete[] buffer; - - return digester.get (); -} - - -/** @param from File to copy from. - * @param to Directory to copy to. - */ -static -void -copy (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total) -{ - LOG_DIST ("Copy %1 -> %2", from.string(), to.generic_string()); - - using namespace boost::filesystem; - - path const cr = to / from.filename(); - - if (is_directory(from)) { - int r = ext4_dir_mk (cr.generic_string().c_str()); - if (r != EOK) { - throw CopyError (String::compose("Failed to create directory %1", cr.generic_string()), r); - } - - for (directory_iterator i = directory_iterator(from); i != directory_iterator(); ++i) { - copy (i->path(), cr, total_remaining, total); - } - } else { - string const write_digest = write (from, cr, total_remaining, total); - LOG_DIST ("Wrote %1 %2 with %3", from.string(), cr.generic_string(), write_digest); - string const read_digest = read (from, cr, total_remaining, total); - LOG_DIST ("Read %1 %2 with %3", from.string(), cr.generic_string(), write_digest); - if (write_digest != read_digest) { - throw VerifyError ("Hash of written data is incorrect", 0); - } - } -} - -static -void -write () -try -{ -// ext4_dmask_set (DEBUG_ALL); - - /* We rely on static initialization for these */ - static struct ext4_fs fs; - static struct ext4_mkfs_info info; - info.block_size = 1024; - info.inode_size = 128; - info.journal = false; - -#ifdef WIN32 - file_windows_name_set(device.c_str()); - struct ext4_blockdev* bd = file_windows_dev_get(); -#else - file_dev_name_set (device.c_str()); - struct ext4_blockdev* bd = file_dev_get (); -#endif - - if (!bd) { - throw CopyError ("Failed to open drive", 0); - } - LOG_DIST_NC ("Opened drive"); - - struct ext4_mbr_parts parts; - parts.division[0] = 100; - parts.division[1] = 0; - parts.division[2] = 0; - parts.division[3] = 0; - -#ifdef DCPOMATIC_LINUX - PrivilegeEscalator e; -#endif - - /* XXX: not sure if disk_id matters */ - int r = ext4_mbr_write (bd, &parts, 0); - - if (r) { - throw CopyError ("Failed to write MBR", r); - } - LOG_DIST_NC ("Wrote MBR"); - -#ifdef DCPOMATIC_WINDOWS - struct ext4_mbr_bdevs bdevs; - r = ext4_mbr_scan (bd, &bdevs); - if (r != EOK) { - throw CopyError ("Failed to read MBR", r); - } - - file_windows_partition_set (bdevs.partitions[0].part_offset, bdevs.partitions[0].part_size); -#endif - -#ifdef DCPOMATIC_LINUX - /* Re-read the partition table */ - int fd = open(device.c_str(), O_RDONLY); - ioctl(fd, BLKRRPART, NULL); - close(fd); -#endif - -#ifdef DCPOMATIC_POSIX - string partition = device; - /* XXX: don't know if this logic is sensible */ - if (partition.size() > 0 && isdigit(partition[partition.length() - 1])) { - partition += "p1"; - } else { - partition += "1"; - } - file_dev_name_set (partition.c_str()); - bd = file_dev_get (); -#endif - - if (!bd) { - throw CopyError ("Failed to open partition", 0); - } - LOG_DIST_NC ("Opened partition"); - - nanomsg->blocking_send(DIST_WRITER_FORMATTING "\n"); - - r = ext4_mkfs(&fs, bd, &info, F_SET_EXT4); - if (r != EOK) { - throw CopyError ("Failed to make filesystem", r); - } - LOG_DIST_NC ("Made filesystem"); - - r = ext4_device_register(bd, "ext4_fs"); - if (r != EOK) { - throw CopyError ("Failed to register device", r); - } - LOG_DIST_NC ("Registered device"); - - r = ext4_mount("ext4_fs", "/mp/", false); - if (r != EOK) { - throw CopyError ("Failed to mount device", r); - } - LOG_DIST_NC ("Mounted device"); - - uint64_t total_bytes = 0; - count (dcp_path, total_bytes); - - /* XXX: this is a hack. We are going to "treat" every byte twice; write it, and then verify it. Double the - * bytes totals so that progress works itself out (assuming write is the same speed as read). - */ - total_bytes *= 2; - copy (dcp_path, "/mp", total_bytes, total_bytes); - - r = ext4_umount("/mp/"); - if (r != EOK) { - throw CopyError ("Failed to unmount device", r); - } - - nanomsg->blocking_send(DIST_WRITER_OK "\n"); -} catch (CopyError& e) { - LOG_DIST("CopyError: %1 %2", e.message(), e.number()); - nanomsg->blocking_send(String::compose(DIST_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number())); -} catch (VerifyError& e) { - LOG_DIST("VerifyError: %1 %2", e.message(), e.number()); - nanomsg->blocking_send(String::compose(DIST_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number())); -} catch (exception& e) { - LOG_DIST("Exception: %1", e.what()); - nanomsg->blocking_send(String::compose(DIST_WRITER_ERROR "\n%1\n0\n", e.what())); -} - -#ifdef DCPOMATIC_LINUX -static -void -polkit_callback (GObject *, GAsyncResult* res, gpointer) -{ - PolkitAuthorizationResult* result = polkit_authority_check_authorization_finish (polkit_authority, res, 0); - if (result && polkit_authorization_result_get_is_authorized(result)) { - write (); - } - if (result) { - g_object_unref (result); - } -} -#endif - -bool -idle () -{ - optional s = nanomsg->nonblocking_get (); - if (!s) { - return true; - } - - if (*s == "Q") { - exit (EXIT_SUCCESS); - } else if (*s == "W") { - dcp_path = nanomsg->blocking_get(); - device = nanomsg->blocking_get(); - - LOG_DIST ("Here we go writing %1 to %2", dcp_path, device); - -#ifdef DCPOMATIC_LINUX - polkit_authority = polkit_authority_get_sync (0, 0); - PolkitSubject* subject = polkit_unix_process_new (getppid()); - polkit_authority_check_authorization ( - polkit_authority, subject, "com.dcpomatic.write-drive", 0, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, 0, polkit_callback, 0 - ); -#else - write (); -#endif - } - - return true; -} - -int -main () -{ - /* XXX: this is a hack, but I expect we'll need logs and I'm not sure if there's - * a better place to put them. - */ - dcpomatic_log.reset(new FileLog(config_path() / "dist_writer.log")); - dcpomatic_log->set_types (dcpomatic_log->types() | LogEntry::TYPE_DIST); - LOG_DIST_NC("dcpomatic_dist_writer started"); - - try { - nanomsg = new Nanomsg (false); - } catch (runtime_error& e) { - LOG_DIST_NC("Could not set up nanomsg socket"); - exit (EXIT_FAILURE); - } - - Glib::RefPtr ml = Glib::MainLoop::create (); - Glib::signal_timeout().connect(sigc::ptr_fun(&idle), 500); - ml->run (); -} diff --git a/src/tools/wscript b/src/tools/wscript index 3ff081522..c4fb7b820 100644 --- a/src/tools/wscript +++ b/src/tools/wscript @@ -32,7 +32,7 @@ def build(bld): uselib += 'AVUTIL SWSCALE SWRESAMPLE POSTPROC CURL BOOST_FILESYSTEM SSH ZIP CAIROMM FONTCONFIG PANGOMM SUB ' uselib += 'SNDFILE SAMPLERATE BOOST_REGEX ICU NETTLE RTAUDIO PNG ' - if bld.env.ENABLE_DIST: + if bld.env.ENABLE_DISK: if bld.env.TARGET_LINUX: uselib += 'POLKIT ' uselib += 'LWEXT4 NANOMSG ' @@ -47,8 +47,8 @@ def build(bld): cli_tools = ['dcpomatic_cli', 'dcpomatic_server_cli', 'server_test', 'dcpomatic_kdm_cli', 'dcpomatic_create', 'swaroop_dcpomatic_ecinema', 'swaroop_dcpomatic_uuid'] else: cli_tools = ['dcpomatic_cli', 'dcpomatic_server_cli', 'server_test', 'dcpomatic_kdm_cli', 'dcpomatic_create'] - if bld.env.ENABLE_DIST: - cli_tools.append('dcpomatic_dist_writer') + if bld.env.ENABLE_DISK: + cli_tools.append('dcpomatic_disk_writer') for t in cli_tools: obj = bld(features='cxx cxxprogram') @@ -56,9 +56,9 @@ def build(bld): obj.includes = ['..'] obj.use = ['libdcpomatic2'] obj.source = '%s.cc' % t - if bld.env.TARGET_WINDOWS and t == 'dcpomatic_dist_writer': + if bld.env.TARGET_WINDOWS and t == 'dcpomatic_disk_writer': obj.source += ' ../../platform/windows/%s.rc' % t - # Prevent a console window opening when we start dcpomatic2_dist_writer + # Prevent a console window opening when we start dcpomatic2_disk_writer bld.env.LINKFLAGS.append('-Wl,-subsystem,windows') obj.target = t.replace('dcpomatic', 'dcpomatic2').replace('swaroop_', '') if t == 'server_test': @@ -72,8 +72,8 @@ def build(bld): gui_tools = ['dcpomatic', 'dcpomatic_batch', 'dcpomatic_server', 'dcpomatic_kdm', 'dcpomatic_player', 'swaroop_dcpomatic_playlist'] else: gui_tools = ['dcpomatic', 'dcpomatic_batch', 'dcpomatic_server', 'dcpomatic_kdm', 'dcpomatic_player', 'dcpomatic_playlist'] - if bld.env.ENABLE_DIST: - gui_tools.append('dcpomatic_dist') + if bld.env.ENABLE_DISK: + gui_tools.append('dcpomatic_disk') for t in gui_tools: obj = bld(features='cxx cxxprogram') diff --git a/wscript b/wscript index b8253fe6a..825bd2ae3 100644 --- a/wscript +++ b/wscript @@ -74,7 +74,7 @@ def options(opt): opt.add_option('--force-cpp11', action='store_true', default=False, help='force use of C++11') opt.add_option('--variant', help='build variant (swaroop-studio, swaroop-theater)', choices=['swaroop-studio', 'swaroop-theater']) opt.add_option('--use-lld', action='store_true', default=False, help='use lld linker') - opt.add_option('--enable-dist', action='store_true', default=False, help='build dcpomatic2_dist tool; requires Boost process and lwext4 libraries') + opt.add_option('--enable-disk', action='store_true', default=False, help='build dcpomatic2_disk tool; requires Boost process and lwext4 libraries') def configure(conf): conf.load('compiler_cxx') @@ -91,7 +91,7 @@ def configure(conf): conf.env.VERSION = VERSION conf.env.DEBUG = conf.options.enable_debug conf.env.STATIC_DCPOMATIC = conf.options.static_dcpomatic - conf.env.ENABLE_DIST = conf.options.enable_dist + conf.env.ENABLE_DISK = conf.options.enable_disk if conf.options.install_prefix is None: conf.env.INSTALL_PREFIX = conf.env.PREFIX else: @@ -370,7 +370,7 @@ def configure(conf): conf.check_cfg(package='libpng', args='--cflags --libs', uselib_store='PNG', mandatory=True) # lwext4 - if conf.options.enable_dist: + if conf.options.enable_disk: conf.check_cxx(fragment=""" #include \n int main() { ext4_mount("ext4_fs", "/mp/", false); }\n @@ -380,11 +380,11 @@ def configure(conf): lib=['lwext4', 'blockdev'], uselib_store='LWEXT4') - if conf.env.TARGET_LINUX and conf.options.enable_dist: + if conf.env.TARGET_LINUX and conf.options.enable_disk: conf.check_cfg(package='polkit-gobject-1', args='--cflags --libs', uselib_store='POLKIT', mandatory=True) # nanomsg - if conf.options.enable_dist: + if conf.options.enable_disk: if conf.check_cfg(package='nanomsg', args='--cflags --libs', uselib_store='NANOMSG', mandatory=False) is None: conf.check_cfg(package='libnanomsg', args='--cflags --libs', uselib_store='NANOMSG', mandatory=True) @@ -534,7 +534,7 @@ def configure(conf): # Really just checking for the header here (there's no associated library) but the test # program has to link with boost_system so I'm doing it this way. - if conf.options.enable_dist: + if conf.options.enable_disk: deps = ['boost_system%s' % boost_lib_suffix] if conf.env.TARGET_WINDOWS: deps.append('ws2_32') @@ -695,7 +695,7 @@ def post(ctx): if ctx.cmd == 'install' and ctx.env.TARGET_LINUX: ctx.exec_command('/sbin/ldconfig') # setuid root executables - for e in ['dcpomatic2_uuid', 'dcpomatic2_dist_writer']: + for e in ['dcpomatic2_uuid', 'dcpomatic2_disk_writer']: # I can't find anything which tells me where things have been installed to, # so here's some nasty hacks to guess. debian = os.path.join(ctx.out_dir, '../debian/dcpomatic/usr/bin/%s' % e)