Compare commits

...

1943 Commits

Author SHA1 Message Date
Jonas Kvinge
3b72a12540 Release 1.0.13 2023-01-09 22:46:59 +01:00
Strawbs Bot
38a1b7765a Update translations 2023-01-09 01:09:50 +01:00
Jonas Kvinge
02f2b8b6f0 CueParser: Detect encoding 2023-01-08 23:40:56 +01:00
Jonas Kvinge
7bfa75102c Remove QRegularExpressionMatch include 2023-01-08 23:24:25 +01:00
Jonas Kvinge
b0f3e7351c Update Changelog 2023-01-08 18:36:32 +01:00
Jonas Kvinge
b5fa401db9 Collection: Make sure RunQuery does not access collection items
- Rename `QueryOptions` to `CollectionFilterOptions`.
- Create new class `CollectionQueryOptions` for passing options from model to `CollectionQuery`.
- Rename `Directory` to `CollectionDirectory`.

Fixes #1095
2023-01-08 18:16:16 +01:00
Jonas Kvinge
41f2710dea GstEnginePipeline: Use linear volume 2023-01-08 15:25:24 +01:00
Jonas Kvinge
f19dda57f0 gstfastspectrum: Use static_cast 2023-01-08 06:21:34 +01:00
Jonas Kvinge
cc4a99ad80 CollectionModel: Close database with same mutex 2023-01-07 23:57:23 +01:00
Jonas Kvinge
1c1a3fc417 ResizableTextEdit: Don't delete setText 2023-01-07 23:38:59 +01:00
Jonas Kvinge
e97be5850b CollectionModel: Change while to for loop 2023-01-07 23:26:36 +01:00
Jonas Kvinge
2c302654b7 CollectionBackendInterface: Initialize filetype 2023-01-07 23:19:37 +01:00
Jonas Kvinge
3ee4dc77b2 Update Changelog 2023-01-06 23:14:28 +01:00
Jonas Kvinge
db55f314c9 Settings: Require tab icons to be minimum 32 2023-01-04 21:24:57 +01:00
Jonas Kvinge
0b536b287f MainWindow: Require tab icons to be minimum 32
Fixes #1084
2023-01-04 21:24:39 +01:00
Jonas Kvinge
6f298a9917 Use system icons for tabbar
Fixes #1093
2023-01-04 17:53:28 +01:00
Jonas Kvinge
70f829a2e5 PlaylistParser: Fix saving relative playlists to new files
Fixes #1092
2023-01-04 17:40:54 +01:00
Jonas Kvinge
1dfe07003f GstEnginePipeline: Set and notify volume only when changed
Another fix for #1089
2023-01-03 21:32:20 +01:00
Jonas Kvinge
286b908062 SliderSlider: Rename `value to new_value` 2023-01-03 19:53:53 +01:00
Jonas Kvinge
4ec028e736 GstEnginePipeline: Change callback ID's to long 2023-01-03 19:51:23 +01:00
Strawbs Bot
35a6d1437a Update translations 2023-01-03 01:01:50 +01:00
Jonas Kvinge
7e3cb3de89 OrganizeFormat: Parse the file path as a single block to avoid splitting brackets
Fixes #1091
2023-01-02 22:23:49 +01:00
Jonas Kvinge
bd945039f1 Turn on git revision 2023-01-02 22:10:13 +01:00
Jonas Kvinge
46743c8f15 Release 1.0.12 2023-01-02 18:56:51 +01:00
Jonas Kvinge
9b75284447 Update Changelog 2023-01-02 18:56:51 +01:00
Strawbs Bot
dca3b0052a Update translations 2023-01-02 01:02:18 +01:00
Jonas Kvinge
6d05bb2de5 GstEnginePipeline: Remove upstream events and buffer probes
Also rename some variables and callback functions

Possible fix for #1090
2023-01-02 00:06:18 +01:00
Jonas Kvinge
8b2e8d3804 OSDPretty: Change pensize back to 2
Removes workaround from commit 91eee99bab
2023-01-01 22:51:49 +01:00
Jonas Kvinge
1a2ab19ab4 GstEnginePipeline: Ignore core error when next song is set
Fixes #958
2023-01-01 20:25:57 +01:00
Jonas Kvinge
04f010aa7b Move SliderSlider and PrettySlider into own files 2023-01-01 18:45:21 +01:00
Jonas Kvinge
25323b4a3a VolumeSlider: Fix infinite loop when adjusting volume using mouse wheel
Fixes #1089
2023-01-01 17:46:26 +01:00
Jonas Kvinge
f353c022f6 LocalRedirectServer: Cast sizeof to int 2023-01-01 16:02:56 +01:00
Jonas Kvinge
9d8b3d3428 ContextView: Fix parameters for `IconLoader::Load()` 2023-01-01 16:02:17 +01:00
Strawbs Bot
e4b06772c0 Update translations 2023-01-01 01:08:45 +01:00
Jonas Kvinge
a2b5c3ea08 Remove settings for changing palette colors
Fixes #1087
2022-12-31 18:20:28 +01:00
Jonas Kvinge
f632e95600 Turn on git revision 2022-12-30 22:47:49 +01:00
Jonas Kvinge
4b5da8c6d4 Release 1.0.11 2022-12-30 18:52:59 +01:00
Jonas Kvinge
77d7ffd10a Update Changelog 2022-12-30 18:52:34 +01:00
Jonas Kvinge
d2f720011a macdeployqt: Disable libgstgme 2022-12-29 22:26:21 +01:00
Jonas Kvinge
6329a7711d Fix includes 2022-12-29 21:39:03 +01:00
Jonas Kvinge
fd14d044e3 CI: Bump macOS version to 11 2022-12-29 20:32:54 +01:00
Strawbs Bot
6368d507e1 Update translations 2022-12-29 01:06:59 +01:00
Jonas Kvinge
205b7f2401 Split utilities functions into separate files 2022-12-28 22:53:59 +01:00
Strawbs Bot
f7d10f9530 Update translations 2022-12-28 01:19:59 +01:00
Jonas Kvinge
66154bb51e Song: Add xesam:userRating in Song::ToXesam 2022-12-27 21:18:40 +01:00
Jonas Kvinge
fac4ad5313 Scrobbler: Allow album artists to be "Various Artists"
Fixes #1082
2022-12-27 21:15:20 +01:00
Jonas Kvinge
fee63891ac FilesystemMusicStorage: QFile::moveToTrash recursively moves files to trash 2022-12-27 20:59:09 +01:00
Strawbs Bot
efa979ee03 Update translations 2022-12-27 01:01:39 +01:00
Jonas Kvinge
c756346357 GstEnginePipeline: Add audio converter for sink 2022-12-11 01:14:17 +01:00
Strawbs Bot
cc95db25cc Update translations 2022-12-11 01:05:26 +01:00
Jonas Kvinge
44970c3321 GstEnginePipeline: Use converter for event probe 2022-12-11 00:21:16 +01:00
Jonas Kvinge
43c7934af7 Mpris2: Use art manual or automatic directly when available
Fixes #1079
2022-12-10 23:22:46 +01:00
Jonas Kvinge
3e7b51163c Don't use system icons for tabbar
Fixes #1084
2022-12-10 18:49:01 +01:00
Jonas Kvinge
4d5f8a53f0 CI: Remove unneeded "shell: bash" 2022-12-05 18:14:40 +01:00
Jonas Kvinge
0b73ca8318 CI: Add Remove Fedora 35 and add 38 2022-12-05 18:07:27 +01:00
Jonas Kvinge
754cfc3bfd Mpris2: Rename function parameter variable 2022-12-04 21:42:36 +01:00
Jonas Kvinge
2ed1a5c06a Add keywords to desktop file 2022-12-04 21:36:45 +01:00
Jonas Kvinge
b2073df3c3 GstEnginePipeline: Detect if autoaudiosink has volume
Fixes #1037
2022-12-04 08:37:33 +01:00
Jonas Kvinge
6267edaa81 Update Changelog 2022-12-04 03:18:04 +01:00
Jonas Kvinge
292f2de3e6 GstEnginePipeline: Add more info when ignoring error 2022-12-04 03:18:04 +01:00
Strawbs Bot
7803dc8be3 Update translations 2022-12-04 02:44:03 +01:00
Jonas Kvinge
2a1260b79e PlaylistParser: Resolve symbolic links when creating relative paths
Fixes #1071
2022-12-04 00:18:55 +01:00
Jonas Kvinge
f9ec438b7f Don't remove disc from album title when creating cover hash
Fixes #1069
2022-12-03 23:23:18 +01:00
Jonas Kvinge
de544c4856 CI: Fix Fedora 37 build 2022-12-03 13:06:21 +01:00
Jonas Kvinge
55e04dd520 Player: Fix volume adjustment 2022-12-03 05:29:39 +01:00
Jonas Kvinge
b2d06f900b GstEnginePipeline: Correct parameter name for SetFaderVolume function 2022-12-03 04:47:41 +01:00
Jonas Kvinge
b92ec71810 Use system volume when possible
Fixes #1037
2022-12-03 04:33:22 +01:00
Jonas Kvinge
3a4199240e Change constexpr to const 2022-11-27 03:27:40 +01:00
Jonas Kvinge
157de12bdf Improve Tidal and Qobuz request 2022-11-27 01:28:29 +01:00
Jonas Kvinge
7c0c9fccdb Organize: Don't allow organizing files without unique tags
Fixes #1077
2022-11-26 23:37:41 +01:00
Jonas Kvinge
2cb29d06b3 EditTagDialog: Disable fields for unsupported tags 2022-11-23 22:06:45 +01:00
Jonas Kvinge
1fdeb50d93 TagReaderTagLib: Don't use TPE1 as performer for ID3 tags
Fixes #1076
2022-11-23 00:03:23 +01:00
Jonas Kvinge
f59632ae59 TagReaderTest: Add tests for reading and writing compilation tag 2022-11-22 21:27:26 +01:00
Jonas Kvinge
67b503da44 TagReaderTagLib: Fix compilation tag read/write for MP4
Partial fix for #1076
2022-11-22 21:09:18 +01:00
Jonas Kvinge
a351de6904 TagReaderTagLib: Fix saving FMPS_Playcount
Fixes #1074
2022-11-22 19:34:11 +01:00
Jonas Kvinge
f94742abd5 EditTagDialog: Fix tab order
Fixes #1075
2022-11-22 19:06:40 +01:00
Jonas Kvinge
891182637e Update README.md 2022-11-21 23:40:30 +01:00
bhrgunatha
086681c915 Add spacefm support to core/utilities.cpp OpenInFileManager 2022-11-19 12:36:21 +01:00
Strawbs Bot
3970d2d02b Update translations 2022-11-17 01:01:49 +01:00
Jonas Kvinge
2b3fddd015 main: Set PULSE_PROP_media.role 2022-11-17 00:59:22 +01:00
Jonas Kvinge
30fa0480a3 main: Set PULSE_PROP_application.icon_name
Fixes #1066
2022-11-17 00:57:10 +01:00
Jonas Kvinge
320a81ce69 main: Use capitalized name in g_set_application_name()
Partial fix for #1066
2022-11-16 23:53:53 +01:00
Jonas Kvinge
950411ef56 ResizableTextEdit: Force updating geometry
Possible fix for
2022-11-16 21:10:30 +01:00
Strawbs Bot
cb9cf084c0 Update translations 2022-11-12 01:01:38 +01:00
Strawbs Bot
bb18af09ae Update translations 2022-11-11 01:12:18 +01:00
Jonas Kvinge
049bf0c7f9 TrackSlider: Remove extra parentheses 2022-11-10 19:19:33 +01:00
Jonas Kvinge
ebc73ef775 CI: Move macOS remove problematic files step 2022-11-10 01:03:50 +01:00
Strawbs Bot
1bd6f59355 Update translations 2022-11-10 01:01:50 +01:00
Jonas Kvinge
c16396a690 GstEnginePipeline: Log pipeline initialized 2022-11-09 22:42:43 +01:00
Strawbs Bot
32a9fe3e9c Update translations 2022-10-30 01:01:54 +02:00
Jonas Kvinge
f48d133bc6 TidalRequest: Fix returning empty results 2022-10-30 00:17:38 +02:00
Jonas Kvinge
0678526d7d CI: Build on FreeBSD with Qt 6 2022-10-29 22:16:15 +02:00
Jonas Kvinge
26d3e8371f CollectionWatcher: Only run periodic scan when monitoring is on 2022-10-29 19:12:04 +02:00
Jonas Kvinge
6768f614c7 GstEngine: Call SetState right before setFuture 2022-10-29 18:45:09 +02:00
Jonas Kvinge
171dc84df1 GstEngine: Use QUrl::clear() 2022-10-29 18:43:49 +02:00
Jonas Kvinge
5ca6513c04 TidalRequest: Only return error when no songs are received
Fixes #1061
2022-10-28 21:46:14 +02:00
Strawbs Bot
41aeb0ac80 Update translations 2022-10-27 01:01:24 +02:00
Strawbs Bot
f871c4adef Update translations 2022-10-25 01:01:27 +02:00
Jonas Kvinge
ad4d0e89b1 Turn off git revision 2022-10-22 10:14:20 +02:00
Jonas Kvinge
0d0c49caa1 Release 1.0.10 2022-10-21 23:39:59 +02:00
Jonas Kvinge
7cbc7bdcfb Update Changelog 2022-10-21 23:38:29 +02:00
Jonas Kvinge
6b46c8ed4a CI: Fix macOS build 2022-10-21 22:14:38 +02:00
Jonas Kvinge
e33ffd1c8a MusixmatchLyricsProvider: Fix error message 2022-10-21 20:54:16 +02:00
Strawbs Bot
8dce9cc938 Update translations 2022-10-21 01:02:47 +02:00
Jonas Kvinge
f06218f8e3 Qobuz: Add option for base64 app secret 2022-10-20 20:47:06 +02:00
Strawbs Bot
5711eef2be Update translations 2022-10-20 01:20:20 +02:00
Jonas Kvinge
db6aac603c nsi: Bump icu 2022-10-19 19:23:54 +02:00
Jonas Kvinge
f10e928106 Organize: Only load embedded cover if the destination is a device 2022-10-19 18:37:49 +02:00
Jonas Kvinge
99d963b99c MusicStorage: Add source 2022-10-19 18:36:33 +02:00
Jonas Kvinge
5d35c22238 OrganizeDialog: Use QUrl::isLocalFile 2022-10-19 18:34:30 +02:00
Jonas Kvinge
54fc11a235 CollectionBackend: Rename source accessor 2022-10-19 17:11:56 +02:00
Jonas Kvinge
ec99df3144 Create common class for Musixmatch 2022-10-18 22:49:15 +02:00
Jonas Kvinge
d722035883 VLCEngine: Only emit stopped when still playing
VLC sends the stopped signal too late, the player has already moved on based on the end reached signal. Emitting Stopped afterwards will interrupt the player in the middle of the song change.

Fixes #1054
2022-10-18 20:12:21 +02:00
Jonas Kvinge
52139fbaa0 Player: Reverse if 2022-10-18 20:09:38 +02:00
Jonas Kvinge
88854eb558 nsi: Bump libunistring 2022-10-17 21:41:14 +02:00
Jonas Kvinge
c82bba01ee MusixmatchLyricsProvider: Remove unused declaration 2022-10-17 20:34:51 +02:00
Jonas Kvinge
eaa33a03d7 MusixmatchLyricsProvider: Use API for lyrics search when possible 2022-10-17 20:29:44 +02:00
Jonas Kvinge
89e8518f31 GeniusLyricsProvider: Make private 2022-10-17 20:28:51 +02:00
Jonas Kvinge
c7bf2e1da8 LyricsProvider: Add missing newline 2022-10-16 22:52:06 +02:00
Jonas Kvinge
bf904a6afa LyricsProvider: Parse multiple sections of the same tag 2022-10-16 01:27:54 +02:00
Jonas Kvinge
43c14ae71b Replace pragma once with header guards for consistency
Only 2 headers have this.
2022-10-15 19:54:09 +02:00
Jonas Kvinge
4abb8ef3c9 Update Changelog 2022-10-15 14:39:49 +02:00
Jonas Kvinge
e46b92dd7d GeniusLyricsProvider: Use new function for parsing HTML 2022-10-15 14:34:09 +02:00
Jonas Kvinge
1a25faa5b9 LyricsProvider: Add function for parsing lyrics from HTML 2022-10-15 14:33:35 +02:00
Strawbs Bot
3f4bf5f512 Update translations 2022-10-14 01:18:29 +02:00
Jonas Kvinge
ae7dbf15ed nsi: Remove avresample-4.dll 2022-10-14 00:10:30 +02:00
Jonas Kvinge
b22320c48f Replace typedef with using 2022-10-13 22:39:31 +02:00
Jonas Kvinge
61204e8d35 CMakeLists: cmake_minimum_required before project 2022-10-13 21:41:46 +02:00
Jonas Kvinge
b0704c654c utilities_test: Fix QByteArray conversion 2022-10-13 21:37:11 +02:00
Strawbs Bot
f40f8a8873 Update translations 2022-10-13 01:01:31 +02:00
Jonas Kvinge
560a7db506 Update .clang-format 2022-10-12 21:28:14 +02:00
Strawbs Bot
15baa8f70e Update translations 2022-10-12 01:01:48 +02:00
Jonas Kvinge
97a7637294 FileView: Use QFileIconProvider instead of QAbstractFileIconProvider
Fixes compile with Qt 5
2022-10-12 00:36:16 +02:00
Jonas Kvinge
3454656207 PlaylistContainer: Fix search field crash on macOS
Fixes #1053
2022-10-12 00:11:12 +02:00
Iridias
7dff6f26bc FileView: Create new file icon provider if icons are missing 2022-10-11 23:52:00 +02:00
Jonas Kvinge
9e835a23fd Rename QSearchField 2022-10-11 23:34:22 +02:00
Jonas Kvinge
c0259fb6ce CI: Remove unused macOS brew packages 2022-10-11 00:27:26 +02:00
Jonas Kvinge
acf106220b CI: Upgrade packages for macOS 2022-10-10 22:31:35 +02:00
Strawbs Bot
5d4dc9c907 Update translations 2022-10-10 01:02:17 +02:00
Jonas Kvinge
2b9a56af7f Update Changelog 2022-10-09 22:18:20 +02:00
Jonas Kvinge
f1e3ac65ac TidalRequest: Simplify no results
Fixes #1047
2022-10-09 22:07:59 +02:00
Jonas Kvinge
143f72cf6b PlaylistView: Fix scaling mid bar for currently playing track
Fixes #1051
2022-10-09 21:41:16 +02:00
Jonas Kvinge
5c8e49296c CI: Add Fedora 37 2022-10-05 00:08:09 +02:00
Jonas Kvinge
b2558b703c nsi: Add jpeg62.dll for MSVC 2022-10-02 22:33:36 +02:00
Jonas Kvinge
bf9d87106e CI: Build Jammy with Qt 6 2022-10-02 19:38:22 +02:00
Jonas Kvinge
5b7f507d9b Windows7ThumbBar: Use QString length instead of count 2022-10-01 14:03:28 +02:00
Jonas Kvinge
59a7835ace CI: Fix if lines 2022-10-01 01:40:32 +02:00
Jonas Kvinge
2495838fe3 CI: Use matrix 2022-09-30 23:58:25 +02:00
Jonas Kvinge
bab687bedf Add USE_RPATH option 2022-09-30 01:00:29 +02:00
Jonas Kvinge
6467c3c8ee Update CMakeLists.txt 2022-09-30 01:00:15 +02:00
Jonas Kvinge
66c2b7aaa6 Update Version.cmake 2022-09-30 00:59:33 +02:00
Jonas Kvinge
ab72c52661 CI: Remove custom libsoup step for macOS 2022-09-29 22:33:47 +02:00
Jonas Kvinge
f0bf1b8a54 Rename CI 2022-09-29 22:32:04 +02:00
Strawbs Bot
119251719f Update translations 2022-09-24 01:01:45 +02:00
Jonas Kvinge
0348400132 ContextView: Remove use of fixed font
Fixes #1040
2022-09-23 18:10:01 +02:00
Jonas Kvinge
813473805b CI: Get latest MSVC dependencies 2022-09-17 01:45:42 +02:00
Strawbs Bot
fe6368561b Update translations 2022-09-17 01:01:19 +02:00
Strawbs Bot
7ff06f424d Update translations 2022-09-15 01:01:21 +02:00
Jonas Kvinge
31958592c7 main: Always create initial style settings 2022-09-13 22:44:24 +02:00
Jonas Kvinge
adc21f4f75 Remove subdir for generated dbus files 2022-09-13 17:53:57 +02:00
Strawbs Bot
9cecd89d6f Update translations 2022-09-13 01:26:32 +02:00
Jonas Kvinge
d866b9b4d4 Update definitions i CMakeLists 2022-09-12 23:20:07 +02:00
Jonas Kvinge
93f12baf51 Fix narrowing conversions in connects 2022-09-12 23:18:54 +02:00
Jonas Kvinge
78d6fd634b Fix casts from QByteArray 2022-09-12 22:39:08 +02:00
Strawbs Bot
b5fc19f08a Update translations 2022-09-12 01:01:20 +02:00
Jonas Kvinge
2dae6a6546 nsi: Update flac dll version 2022-09-10 23:52:27 +02:00
Jonas Kvinge
b6bba46391 CI: Update vmactions/freebsd-vm 2022-09-09 23:02:28 +02:00
Jonas Kvinge
b791d97116 CI: Use variable for workspace 2022-09-09 22:40:37 +02:00
Strawbs Bot
6aa8255f34 Update translations 2022-09-08 01:01:22 +02:00
Jonas Kvinge
98e2140761 Turn on git revision 2022-09-04 00:48:35 +02:00
Jonas Kvinge
a59e064778 Release 1.0.9 2022-09-03 20:40:14 +02:00
Jonas Kvinge
655c4c66a7 Update Changelog 2022-09-03 20:34:25 +02:00
Jonas Kvinge
407c128f65 GstStartup: Set LIBSOUP3_LIBRARY_PATH for macOS 2022-09-03 00:19:25 +02:00
Jonas Kvinge
59a261a5be main: Add Frameworks to library paths for macOS 2022-09-03 00:19:25 +02:00
Jonas Kvinge
ba4e1afefe CI: Compile entire gstreamer from source for macOS 2022-09-02 23:55:25 +02:00
Jonas Kvinge
98b53b81d8 Update Changelog 2022-09-01 22:06:00 +02:00
Jonas Kvinge
8270cc0aa2 macdeploycheck: Fail on parse error 2022-09-01 21:58:11 +02:00
Jonas Kvinge
74207b1a87 Update ISSUE_TEMPLATE.md 2022-09-01 21:35:33 +02:00
Jonas Kvinge
77983445ce debian: Fix icu dependency 2022-09-01 19:18:40 +02:00
Ondrej Mosnáček
162190bcb8 Mark collectionmodel_test as not requiring GUI
The test doesn't seem to acually need gui_required = true, so set it to
false.
2022-08-31 12:40:46 -07:00
Jonas Kvinge
86b92b20b7 macdeployqt: Add back extra changeInstallName 2022-08-30 21:35:11 +02:00
Jonas Kvinge
2f5b60d548 macdeployqt: Fix deploying libgcc
Fixes #1025
2022-08-30 19:33:59 +02:00
Jonas Kvinge
c19661c977 macdeploycheck: Fix check for libgcc 2022-08-30 19:32:59 +02:00
Jonas Kvinge
82d101ca27 macdeployqt: Merge changes from upstream 2022-08-30 17:48:16 +02:00
Jonas Kvinge
32f9c4e670 GstEnginePipeline: Parse album from stream title tag
Fixes #1023
2022-08-30 16:56:08 +02:00
Jonas Kvinge
34c7225ab7 Turn back git revision 2022-08-29 22:05:07 +02:00
Jonas Kvinge
b02eb502e4 Release 1.0.8 2022-08-29 17:54:05 +02:00
Jonas Kvinge
7d6b3dfd20 Update maketarball.sh.in 2022-08-29 17:53:49 +02:00
Strawbs Bot
3ac39968d2 Update translations 2022-08-29 01:16:24 +02:00
Jonas Kvinge
2b24ac54a0 Remove unused includes 2022-08-28 03:09:33 +02:00
Jonas Kvinge
6da6b794c7 VolumeSlider: Remove unused Background and Foreground 2022-08-28 02:52:40 +02:00
Jonas Kvinge
ed689e27c9 Transcoder: Change return type for QueuedJobsCount to qint64 2022-08-28 02:51:10 +02:00
Jonas Kvinge
186f9c3f18 SmartPlaylistWizard: Add missing override 2022-08-28 02:50:33 +02:00
Jonas Kvinge
42cdde3203 SmartPlaylistsViewContainer: Add missing override 2022-08-28 02:50:17 +02:00
Jonas Kvinge
b9091702e9 SmartPlaylistSearchTermWidget: Add missing override 2022-08-28 02:50:02 +02:00
Jonas Kvinge
d42ecbe74e SmartPlaylistQueryWizardPlugin: Add missing override 2022-08-28 02:49:45 +02:00
Jonas Kvinge
e6c5446d63 PlaylistQueryGenerator: Add missing override 2022-08-28 02:49:30 +02:00
Jonas Kvinge
cc277211b3 LibreFMScrobbler: Call base class for ReloadSettings 2022-08-28 02:48:47 +02:00
Jonas Kvinge
6703c15c52 RadioPlaylistItem: Fix header guard comment 2022-08-28 02:48:22 +02:00
Jonas Kvinge
4ecdaf573e MoodbarRenderer: Remove unused kNumHues 2022-08-28 02:47:45 +02:00
Jonas Kvinge
71ec3e61be signalchecker: Remove useless return 2022-08-28 02:46:23 +02:00
Jonas Kvinge
216fdb2393 FileSystemWatcherInterface: Change signal to non const 2022-08-28 02:45:56 +02:00
Jonas Kvinge
c39acc6e3c Database: Remove useless return 2022-08-28 02:45:34 +02:00
Jonas Kvinge
d97b0478a7 Fix typos 2022-08-28 02:44:37 +02:00
Jonas Kvinge
d15d64eb67 nsi: Add nghttp2.dll for MSVC 2022-08-27 23:43:39 +02:00
Jonas Kvinge
3acd2656ee Update Changelog 2022-08-27 23:14:56 +02:00
Jonas Kvinge
a4b003534a CI: Switch to libsoup 3 2022-08-27 19:36:29 +02:00
Jonas Kvinge
8752538a02 nsi: Switch to libsoup 3 2022-08-27 19:36:29 +02:00
Strawbs Bot
bde435753a Update translations 2022-08-25 01:02:52 +02:00
Jonas Kvinge
d347e6fc5f Add setting for turning off HTTP/2 2022-08-24 20:34:10 +02:00
Jonas Kvinge
27b01d3642 Analyzer::Base: Set Qt::WA_OpaquePaintEvent 2022-08-24 20:32:08 +02:00
Jonas Kvinge
b78677e285 nsi: Use libsoup 2 2022-08-22 23:19:49 +02:00
Jonas Kvinge
f8f6c74bcb CI: Use libsoup 2 2022-08-22 23:19:40 +02:00
Strawbs Bot
7ce123939b Update translations 2022-08-21 01:19:35 +02:00
Jonas Kvinge
e7b02cfb15 TagReaderGME: Use UTF-16 2022-08-21 00:36:06 +02:00
Jonas Kvinge
5931077b08 macdeployqt: Add GStreamer GME plugin 2022-08-20 19:52:32 +02:00
Jonas Kvinge
a521bdc0e3 TagReaderGME: Compare file extension case-insensitive 2022-08-20 19:08:58 +02:00
Eoin O'Neill
80da565609 Initial support for GME's VGM/SPC playback and tag management.
Co-Authored-By: Jonas Kvinge <jonas@jkvinge.net>
2022-08-20 18:33:13 +02:00
Jonas Kvinge
6bc46e4598 CollectionModel: Make separate_albums_by_grouping optional 2022-08-20 16:47:09 +02:00
Jonas Kvinge
6562258db5 CollectionModel: Make separating albums by grouping optional
Fixes #1018
2022-08-20 14:51:19 +02:00
Jonas Kvinge
c219995218 Update .gitignore 2022-08-19 21:15:08 +02:00
Jonas Kvinge
62035431ed Install Visual C++ runtime 2022-08-18 22:47:34 +02:00
Jonas Kvinge
fa1fbca7dc DirectSoundDeviceFinder: Remove __attribute__((stdcall)) 2022-08-15 19:55:55 +02:00
Strawbs Bot
391b7476b3 Update translations 2022-08-15 01:01:37 +02:00
Jonas Kvinge
9c04ce665f DirectSoundDeviceFinder: Add CALLBACK to EnumerateCallback 2022-08-14 10:37:31 +02:00
Jonas Kvinge
dd87268197 CI: Build Windows x86 2022-08-14 10:37:31 +02:00
Jonas Kvinge
8d9af59db2 MainWindow: Use different Sparkle URL for x86 2022-08-14 10:37:31 +02:00
Strawbs Bot
1b754a35ff Update translations 2022-08-14 01:01:17 +02:00
Jonas Kvinge
7230f91f61 CI: Update actions 2022-08-10 21:32:18 +02:00
Strawbs Bot
93edfc315c Update translations 2022-08-10 01:01:34 +02:00
Strawbs Bot
74c8269531 Update translations 2022-08-09 18:02:04 +02:00
Jonas Kvinge
acb6c0fc83 Use PlaylistFilter directly 2022-08-09 17:23:46 +02:00
Jonas Kvinge
553d4cce93 PlaylistContainer: Translate Undo/Redo
Fixes #1017
2022-08-09 17:04:59 +02:00
Jonas Kvinge
ca81f144e6 README: Add ICU to dependencies 2022-08-08 00:37:37 +02:00
Jonas Kvinge
ec84960347 nsi: Move icu to common files 2022-08-08 00:37:19 +02:00
Jonas Kvinge
38db0764af Require ICU 2022-08-07 20:23:23 +02:00
Jonas Kvinge
a647f63bb0 CI: Add macOS 2022-08-07 17:35:53 +02:00
Jonas Kvinge
5b7087cc9e nsi: Add files for MSVC 2022-08-07 12:32:31 +02:00
Jonas Kvinge
1a6fcd5da6 QSearchField: Replace use of C-style cast 2022-08-07 05:14:38 +02:00
Jonas Kvinge
e31dd9f553 MacSystemTrayIcon: Replace use of C-style cast 2022-08-07 05:14:05 +02:00
Jonas Kvinge
22844716d1 RadioView: Remove duplicate double clicked
Already done in AutoExpandingTreeView::ItemDoubleClicked

Fixes #1015
2022-08-07 02:40:09 +02:00
Jonas Kvinge
6abed76f70 nsi: Add gme 2022-08-06 17:02:00 +02:00
Jonas Kvinge
72ff502e0f OSDDBus: Set timeout 2022-07-31 03:28:13 +02:00
Jonas Kvinge
2b781df32b CI: Use openSUSE Leap 15.4 for source builder 2022-07-29 16:27:21 +02:00
Strawbs Bot
bf601c3906 Update translations 2022-07-29 01:25:43 +02:00
Jonas Kvinge
b753e0ebb0 CI: Remove macOS 2022-07-28 16:56:35 +02:00
Jonas Kvinge
564211aceb Prefer ICU to transliterate characters when available
Fixes #1008
2022-07-28 16:31:16 +02:00
Strawbs Bot
538c759fef Update translations 2022-07-28 01:02:19 +02:00
Jonas Kvinge
95edc34100 Update README and issue template 2022-07-27 20:43:03 +02:00
Jonas Kvinge
98682a2da9 Use C++17 fallthrough 2022-07-26 20:37:06 +02:00
Jonas Kvinge
33581fa61d PlaylistContainer: Fix filter text when switching playlist
Fixes #1005
2022-07-26 07:35:43 +02:00
Jonas Kvinge
b02e0aae98 PlaylistListSortFilterModel: Add header guard 2022-07-26 07:33:11 +02:00
Jonas Kvinge
6fa4e1cb6d Turn on git revision 2022-07-25 23:37:33 +02:00
Jonas Kvinge
9f2ec22e95 Release 1.0.7 2022-07-25 21:45:27 +02:00
Jonas Kvinge
65b2e506b1 CI: Remove Ubuntu Impish 2022-07-25 17:29:35 +02:00
Jonas Kvinge
8bc07b5286 nsi: Add libgpg-error-0.dll 2022-07-25 15:51:05 +02:00
Jonas Kvinge
fe0af63795 Update Changelog 2022-07-25 15:28:25 +02:00
Jonas Kvinge
44ce7f4c67 CI: Disable audio cd for Windows MinGW build 2022-07-25 15:27:17 +02:00
Jonas Kvinge
252936134b nsi: Remove gstwinrt-1.0-0.dll 2022-07-25 04:25:08 +02:00
Jonas Kvinge
e255b06945 macdeployqt: Update gstreamer plugins 2022-07-25 03:56:38 +02:00
Jonas Kvinge
d726568a23 nsi: Add gstwavenc 2022-07-25 03:55:38 +02:00
Jonas Kvinge
66880a6de7 nsi: Update gstreamer plugins 2022-07-25 03:23:34 +02:00
Jonas Kvinge
fda622a0c0 Update Changelog 2022-07-24 23:44:54 +02:00
Jonas Kvinge
efa7d10f40 nsi: Add twolame 2022-07-21 03:04:48 +02:00
Strawbs Bot
348a3fabab Update translations 2022-07-21 01:09:44 +02:00
Jonas Kvinge
1bbaee605c PlaylistParser: Check file extension case-insensitive 2022-07-20 14:56:55 +02:00
Jonas Kvinge
22edf7a2b3 TagReaderTagParser: Fix reading and writing rating 2022-07-20 11:44:46 +02:00
Jonas Kvinge
3ffcc29249 Add back save all playlists action 2022-07-20 01:09:00 +02:00
Jonas Kvinge
21f1fe52c0 Remove save all playlists action
It's hard-coded to m3u, needs a new select directory dialog with option to select different playlist formats.

Fixes #987
2022-07-18 22:56:32 +02:00
Jonas Kvinge
99840c9e4f Turn on git revision 2022-07-18 00:40:00 +02:00
Jonas Kvinge
3194fe7d8e Release 1.0.6 2022-07-17 23:36:45 +02:00
Jonas Kvinge
81df72b0cb Update debian/copyright 2022-07-17 21:47:35 +02:00
Jonas Kvinge
57b056ac43 WorkerPool: Search for tagreader in libexec 2022-07-17 17:21:11 +02:00
Jonas Kvinge
c5876d0d48 Update Changelog 2022-07-17 01:53:39 +02:00
Jonas Kvinge
b5e65401b6 Update Changelog 2022-07-17 01:52:21 +02:00
Jonas Kvinge
ebea5b48ea Update Changelog 2022-07-17 01:50:58 +02:00
Jonas Kvinge
7d081e581a CI: Remove extra Qt 6 repo 2022-07-17 01:16:06 +02:00
Jonas Kvinge
5e819cf04b Remove defining _WIN32_WINNT 2022-07-17 01:16:10 +02:00
Jonas Kvinge
fd9ab43681 Windows7ThumbBar: Create taskbar list once 2022-07-17 00:13:37 +02:00
Jonas Kvinge
4935cdc722 Transcoder: Formatting 2022-07-16 16:31:04 +02:00
Jonas Kvinge
26a3c7ad6a Transcoder: Fix caps leak 2022-07-16 16:10:49 +02:00
Strawbs Bot
c358216ad9 Update translations 2022-07-16 01:01:40 +02:00
Yaroslav Chvanov
bb9302143c Send the media player name and version to ListenBrainz 2022-07-15 20:50:00 +02:00
Yaroslav Chvanov
3a73553aac Send more information to ListenBrainz
- Track duration and number.
- Player name and version.
2022-07-15 20:50:00 +02:00
Strawbs Bot
6447a17e3e Update translations 2022-07-15 01:01:45 +02:00
Jonas Kvinge
4bd5c8ffb3 EditTagDialog: Remove useless HTML 2022-07-14 23:56:00 +02:00
Jonas Kvinge
89f137b211 SmartPlaylistSearchTermWidget: Remove tr from Strawberry 2022-07-14 23:41:38 +02:00
Strawbs Bot
3425572c66 Update translations
Fixes #994
2022-07-14 22:09:06 +02:00
Jonas Kvinge
ad50875f9c SnapDialog: Remove HTML tag from tr text 2022-07-14 22:04:23 +02:00
Strawbs Bot
34e5645dab Update translations 2022-07-14 20:54:57 +02:00
Jonas Kvinge
e8ae91c230 nsi: Add pcre2-8 2022-07-13 17:25:14 +02:00
Jonas Kvinge
44b83994fa Remove libpcre-1.dll 2022-07-13 16:58:28 +02:00
Jonas Kvinge
201f585350 CI: Use official Qt 6 repo for Leap 15.3 and 15.4 2022-07-11 23:12:26 +02:00
Strawbs Bot
e4d2f1925e Update translations 2022-07-11 01:04:46 +02:00
Jonas Kvinge
658c116eac Utilities: Remove unnecessary constData() in Sha1CoverHash 2022-07-10 19:14:05 +02:00
Jonas Kvinge
dbbedee77f CollectionBackendTest: Remove invalid song test 2022-07-10 19:09:09 +02:00
Jonas Kvinge
16ac9ea061 TagReaderTest: Remove use of deprecated QCryptographicHash constructor 2022-07-10 19:08:43 +02:00
Jonas Kvinge
6afbc71b4a Remove old schemas 2022-07-10 18:57:00 +02:00
Jonas Kvinge
71263863ad Allow invalid ctime/mtime
Possible fix for #815 and #947
2022-07-10 03:24:02 +02:00
Jonas Kvinge
05232065f8 schema: Remove DEFAULT for TEXT 2022-07-10 01:56:39 +02:00
Jonas Kvinge
f289ae4143 Add Ubuntu Kinetic 2022-07-08 19:36:43 +02:00
Jonas Kvinge
91703ecec4 macdeployqt: Add hls plugin 2022-07-07 21:47:05 +02:00
Strawbs Bot
6fb0858b87 Update translations 2022-07-04 01:01:17 +02:00
Jonas Kvinge
f1c6620df9 Add Wiki link to README 2022-07-02 22:38:55 +02:00
Jonas Kvinge
08fed9a5ee CI: Update libsoup dll 2022-07-02 10:21:15 +02:00
Jonas Kvinge
eb28b3b05b Update libsoup in nsi 2022-07-01 23:33:19 +02:00
Strawbs Bot
f0c354b0c9 Update translations 2022-07-01 01:01:44 +02:00
Yaroslav Chvanov
07d88e86a2 Add support for prefer album artist option to ListenBrainz 2022-06-30 21:59:30 +02:00
Jonas Kvinge
f41a3b9bb2 CommandlineOptions: Change quint64 to quint32 to match operator>>
Fixes #986
2022-06-24 17:18:54 +02:00
Jonas Kvinge
bfd9e76f40 Remove capture of ‘this’ via ‘[=]’ 2022-06-20 23:52:18 +02:00
Strawbs Bot
38ce208a43 Update translations 2022-06-18 01:01:29 +02:00
Jonas Kvinge
fcd148b8d5 Playlist: Fix "Stop after this track" greys out next track in dynamic mode
Fixes #912
2022-06-16 17:53:07 +02:00
Ondrej Mosnacek
fc6c3774b0 README: Exclude unsupported repos in the repology badge
Showing them provides little value, as they are no longer maintained
and thus expected to contain outdated packages.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-06-15 17:12:43 +02:00
Chongo Bong
18023d2e18 Update desktop file action, use play/pause instead of play and pause
Condenses it a bit. looks cleaner, yet provides the same functionality as before.
2022-06-15 17:08:15 +02:00
Strawbs Bot
467e834ad6 Update translations 2022-06-15 01:01:41 +02:00
Jonas Kvinge
629d9e7ae0 FileViewList: Sort files with QCollator in numeric mode
Fixes #977
2022-06-14 17:21:59 +02:00
Jonas Kvinge
4487d292e8 Set C standard to C99 for MSVC 2022-06-14 16:16:49 +02:00
Jonas Kvinge
76711b9a66 Set C standard to C17 2022-06-13 21:20:41 +02:00
Jonas Kvinge
b54c749e43 Replace use of C-style casts 2022-06-13 00:40:31 +02:00
Jonas Kvinge
d82fd421ed Replace use of C-style casts 2022-06-13 00:23:42 +02:00
Jonas Kvinge
abdcadb5fa Flush correct queue 2022-06-12 02:28:02 +02:00
Jonas Kvinge
fa3891e383 Use list instead of map for songs in internet search
Fixes issues with sorting
2022-06-12 01:59:46 +02:00
Strawbs Bot
f1dc0f95c8 Update translations 2022-06-12 01:28:33 +02:00
Jonas Kvinge
5c721d243a Turn on git revision 2022-06-11 00:27:38 +02:00
Jonas Kvinge
2770384f1f Release 1.0.5 2022-06-10 21:50:35 +02:00
Jonas Kvinge
f4e5b83039 Replace use of C-style casts 2022-06-10 02:30:39 +02:00
Jonas Kvinge
124681605b Change -Wno-old-style-cast to -Wold-style-cast 2022-06-10 01:23:55 +02:00
Jonas Kvinge
a217faae7c OSDPretty: Remove use of C-style cast 2022-06-10 00:47:11 +02:00
Jonas Kvinge
184c39bbb7 Update Changelog 2022-06-10 00:01:21 +02:00
Jonas Kvinge
508e2a70bb Update Changelog 2022-06-09 23:38:25 +02:00
Jonas Kvinge
5aac56fe96 ContextView: Cleanup spacers 2022-06-09 23:09:41 +02:00
Strawbs Bot
dab7dad966 Update translations 2022-06-09 01:02:32 +02:00
Jonas Kvinge
25e48d6cae Add option for disabling bars on currently playing track
Fixes #972
2022-06-09 00:50:21 +02:00
Jonas Kvinge
9b743e55d1 ContextView: Update album width from context 2022-06-09 00:46:39 +02:00
Jonas Kvinge
dc1f9edfaf Organize: Only notify song path changed for collection and device songs 2022-06-07 22:43:39 +02:00
Strawbs Bot
b6b68edf1e Update translations 2022-06-07 01:01:51 +02:00
Jonas Kvinge
a2320b99ae ContextView: Use fixed size to avoid scrollbar issues 2022-06-06 20:54:15 +02:00
Jonas Kvinge
be01e28068 ContextAlbum: Use sizeHint() 2022-06-06 18:24:00 +02:00
Jonas Kvinge
d6084083a5 Update data/style/strawberry.css 2022-06-06 18:23:34 +02:00
Jonas Kvinge
019bf5102c ResizableTextEdit: Add Q_OBJECT macro 2022-06-06 18:23:12 +02:00
Jonas Kvinge
a1633224d1 CI: Add g++ for debian/ubuntu 2022-06-06 18:22:06 +02:00
Strawbs Bot
e62bd26cb9 Update translations 2022-06-06 01:26:37 +02:00
Jonas Kvinge
c29f517292 Update debian/control.in 2022-06-05 23:47:04 +02:00
Jonas Kvinge
d80144f80c Remove -fpermissive 2022-06-05 23:19:40 +02:00
Jonas Kvinge
4733c84a86 ContextAlbum: Move rescaling back to paintevent 2022-06-05 19:02:34 +02:00
Jonas Kvinge
23f3d2095b ContextAlbum: Improve album cover fading 2022-06-05 18:20:44 +02:00
Jonas Kvinge
4f1f2b6fc6 ContextView: Change condition for showing context menu 2022-06-05 18:19:14 +02:00
Jonas Kvinge
1ea70b085f Context: Remove albums 2022-06-05 11:58:53 +02:00
Jonas Kvinge
6c0b395f4a Add option for overwriting playcounts
Fixes #962
2022-06-05 04:59:50 +02:00
Jonas Kvinge
0ee67f186f Remove widgets/resizabletextedit.h from CMakeLists.txt 2022-06-05 04:57:58 +02:00
Jonas Kvinge
d133addbaa Context: Use custom textedits instead of labels
Also improve album cover scaling

Fixes #965
2022-06-05 04:41:36 +02:00
Jonas Kvinge
683991b1c9 Add ResizableTextEdit 2022-06-05 04:41:36 +02:00
Strawbs Bot
32ac02007b Update translations 2022-06-05 01:01:44 +02:00
Jonas Kvinge
d716617ae0 FancyTabWidget: Make sure context menu does not popup outside of tabbar 2022-06-05 00:25:48 +02:00
Jonas Kvinge
26e1f015d2 Add streaming to description in CMakeLists.txt 2022-06-04 16:16:19 +02:00
Jonas Kvinge
1c94093a4b Update debian/copyright 2022-06-04 16:16:19 +02:00
Strawbs Bot
27eccd456a Update translations 2022-06-04 01:02:03 +02:00
Jonas Kvinge
eed4447560 Update protobuf in nsi 2022-05-31 19:02:31 +02:00
Jonas Kvinge
3c8d0ebd52 CollectionModel: Use grouping in all album groupings 2022-05-31 00:53:47 +02:00
Jonas Kvinge
7ec0d2f2cc Update fftw3 in nsi 2022-05-22 02:14:07 +02:00
Strawbs Bot
35da91a997 Update translations 2022-05-22 01:02:14 +02:00
Jonas Kvinge
788747c071 MainWindow: Remove unnecessary hide() 2022-05-21 19:12:53 +02:00
Jonas Kvinge
36eb131289 MainWindow: Remove QEvent::spontaneous() check in close event
Fixes #964
2022-05-21 19:12:53 +02:00
Jonas Kvinge
f231f28818 Move QGuiApplication::setQuitOnLastWindowClosed before QApplication 2022-05-21 19:12:53 +02:00
Strawbs Bot
aebdc89f77 Update translations 2022-05-20 01:04:44 +02:00
Jonas Kvinge
4a3a379871 Increase icons to include 128x128 and set global application icon
Fixes #954
2022-05-19 22:02:35 +02:00
Jonas Kvinge
a7f27add2d Combine definitions 2022-05-17 23:40:53 +02:00
Strawbs Bot
cd1d4247cf Update translations 2022-05-16 01:01:29 +02:00
Strawbs Bot
6d618c4b78 Update translations 2022-05-14 01:11:35 +02:00
Jonas Kvinge
ad469531ff SPFParser: Use percent-encoding for image too 2022-05-13 23:36:38 +02:00
Jonas Kvinge
cf9b4b1246 XSPFParser: Use percent-encoding when loading and saving playlists
Fixes #821
2022-05-13 23:32:35 +02:00
Jonas Kvinge
18a2692dc1 PlaylistParser: Refactor code and exclude CUE from save playlist filters
Fixes #953
2022-05-13 23:14:56 +02:00
Jonas Kvinge
a2dad982f8 Move sqlrow to core 2022-05-13 18:15:04 +02:00
Jonas Kvinge
8f27b6a4c9 CI: Update Fedora 2022-05-10 01:06:04 +02:00
Jonas Kvinge
21c4022fca PlaylistView: Fix invalidating cached pixmap on scroll
Fixes #952
2022-05-09 23:46:33 +02:00
Jonas Kvinge
237933855a Remove unused PKGBUILD file 2022-05-06 18:31:32 +02:00
Jonas Kvinge
dff7068a03 Move debian configuration to separate CMakeLists.txt 2022-05-06 18:26:46 +02:00
Jonas Kvinge
8f28a85a6d RadioParadiseService: Change URLs to https 2022-05-06 18:07:20 +02:00
Jonas Kvinge
2414eb2598 GstEnginePipeline: Replace char with int8_t in HandoffCallback 2022-05-06 17:42:08 +02:00
Strawbs Bot
4851f6bffd Update translations 2022-05-06 01:01:57 +02:00
Jonas Kvinge
948be36d3c SmartPlaylistSearchTerm: Move value assigment
Mistake done in commit 3f3ae7c38f
2022-05-05 20:41:30 +02:00
Jonas Kvinge
edd088927d macdeployqt: List missing gstreamer plugins instead of failing
Fixes #936
2022-05-04 23:11:53 +02:00
Jonas Kvinge
4cfe8dd95e nsi: Fix pcre2 dll for debug 2022-05-03 20:08:40 +02:00
Jonas Kvinge
e1ce81c5bf Update pcre2 filename in nsi 2022-04-30 21:03:09 +02:00
Jonas Kvinge
0f40b5f022 VLCEngine: Fix track progress
Fixes #941
2022-04-29 00:09:29 +02:00
FireFragment
94c5ffa92e Allow setting blur amount of background image up to 100px 2022-04-27 20:53:29 +02:00
FireFragment
3c9bf56767 Improve CMake error message in case of missing libvlc
When running CMake with VLC installed, but without libvlc there pops out following error message:
 > You need to have eithoer GStreamer or VLC to compile!

This may be confusing for some users, because they might have VLC already installed, but not libvlc. This commit fixes it.
2022-04-26 17:39:07 +02:00
Jonas Kvinge
9024acb16e debian: Add qt6-qpa-plugins to depends
Fixes #937
2022-04-23 23:48:16 +02:00
Jonas Kvinge
7732402122 Add ffmpeg to MSVC 2022-04-23 18:06:38 +02:00
Jonas Kvinge
2059bce6a7 Add Qt 6 support to debian files 2022-04-23 02:15:22 +02:00
Jonas Kvinge
499c86a8b8 Add safe git directory 2022-04-20 01:23:02 +02:00
Strawbs Bot
ef084eb145 Update translations 2022-04-20 01:02:20 +02:00
Jonas Kvinge
3f3ae7c38f SmartPlaylistSearchTerm: Fix filetype search 2022-04-19 23:11:13 +02:00
Strawbs Bot
83d762287f Update translations 2022-04-18 01:01:58 +02:00
Strawbs Bot
5af0acf147 Update translations 2022-04-16 01:05:16 +02:00
Jonas Kvinge
907dfee6f7 Utilities: Use inconv with MSVC 2022-04-15 17:44:04 +02:00
Strawbs Bot
d587d24603 Update translations 2022-04-15 01:03:02 +02:00
Jonas Kvinge
c246b8f164 GstEngine: Show debug information in error dialog 2022-04-14 20:56:57 +02:00
Strawbs Bot
deecafa053 Update translations 2022-04-11 01:02:28 +02:00
Jonas Kvinge
f8810106a2 Turn on git revision 2022-04-10 17:34:26 +02:00
Jonas Kvinge
8e35fbe532 Release 1.0.4 2022-04-10 14:08:25 +02:00
Jonas Kvinge
b1fdccde6e ContextView: Specify alternative fonts for no song playing 2022-04-10 14:05:51 +02:00
Jonas Kvinge
6741f100a1 Update Changelog 2022-04-10 12:19:23 +02:00
Jonas Kvinge
e05e9ea1b2 timeconstants: Use constexpr 2022-04-08 17:35:44 +02:00
Jonas Kvinge
197341de5e Update debian/copyright-scan-patterns.yml 2022-04-08 17:35:31 +02:00
Jonas Kvinge
2933482be3 Update debian/copyright 2022-04-08 17:35:23 +02:00
Jonas Kvinge
c7ce23239f Disable gstwasapi2 in nsi 2022-04-07 23:18:08 +02:00
Jonas Kvinge
79115f7439 Update README and issue template 2022-04-07 01:22:21 +02:00
Jonas Kvinge
4457103672 Add pcre2 to nsi for MSVC 2022-04-06 23:23:20 +02:00
Jonas Kvinge
d204875f72 globalshortcut-x11: Fix minor code issues 2022-04-06 21:22:10 +02:00
Strawbs Bot
c690e73b1a Update translations 2022-04-05 01:02:10 +02:00
Jonas Kvinge
b5d39c5f21 Context: Remove use of custom font
Fixes #932
2022-04-04 20:26:38 +02:00
Strawbs Bot
7f8834cb04 Update translations 2022-04-04 01:02:50 +02:00
Jonas Kvinge
0dab7e293c GstEngine: Append "2" to wasapi2sink output description 2022-04-02 01:37:43 +02:00
Jonas Kvinge
8f016880af globalshortcut-win: Register 0-9 as num keys too 2022-04-02 00:43:41 +02:00
Jonas Kvinge
f471462a84 AnalyzerBase: Refactor code 2022-04-01 22:30:22 +02:00
Strawbs Bot
58eec8df1e Update translations 2022-03-30 01:02:21 +02:00
Jonas Kvinge
2655b8b43a TagReaderTagLib: Replace use of QByteArray::count() 2022-03-29 01:43:07 +02:00
Jonas Kvinge
ea86c043a4 AlsaPCMDeviceFinder: Fix use of deleted memory 2022-03-29 01:23:35 +02:00
Strawbs Bot
c1faa616bc Update translations 2022-03-29 01:04:21 +02:00
Strawbs Bot
a68bf5a30d Update translations 2022-03-28 01:02:14 +02:00
Jonas Kvinge
9568b8e0e5 Add hls to nsi 2022-03-28 00:34:20 +02:00
Jonas Kvinge
b34321ef87 GlobalShortcutsManager: Translate shortcuts
Fixes #928
2022-03-27 14:31:58 +02:00
Strawbs Bot
4971f1c5bf Update translations 2022-03-27 01:04:49 +01:00
Maxime Haselbauer
962b52bd5b Add save all playlists action 2022-03-26 22:38:21 +01:00
Jonas Kvinge
9449bfa414 Update protobuf in nsi 2022-03-26 21:02:56 +01:00
Strawbs Bot
5b8e9066c6 Update translations 2022-03-26 01:03:00 +01:00
Jonas Kvinge
8690be7fd2 Use separate sparkle feed for mingw and msvc 2022-03-25 21:38:37 +01:00
Jonas Kvinge
497267016b Turn on git revision 2022-03-25 01:22:31 +01:00
Jonas Kvinge
0468f850c2 Release 1.0.3 2022-03-24 21:23:36 +01:00
Jonas Kvinge
b9e7d4e30c Update Changelog 2022-03-24 21:21:24 +01:00
Jonas Kvinge
0e7734b555 Update README.md 2022-03-24 20:32:50 +01:00
Jonas Kvinge
e81dcce5b3 Update nsi for msvc dependencies 2022-03-23 19:13:40 +01:00
Strawbs Bot
38bd1f7e1c Update translations 2022-03-23 01:16:48 +01:00
Jonas Kvinge
36ad9704a2 Update libspeex for msvc in nsi 2022-03-22 21:24:54 +01:00
Jonas Kvinge
a6c05df362 Formatting 2022-03-22 21:19:59 +01:00
Jonas Kvinge
f6b70fda71 Formatting 2022-03-22 21:09:05 +01:00
Jonas Kvinge
8cb4e75f70 Update nsi for msvc dependencies 2022-03-22 17:32:49 +01:00
Jonas Kvinge
da1815ac2b Qobuz: Fix albums request limited to 50 albums
Fixes #922
2022-03-21 21:54:27 +01:00
Jonas Kvinge
f7357f2d10 Add libbrotlienc.dll to nsi 2022-03-21 21:30:33 +01:00
Jonas Kvinge
d9c92c5ddd CI: Use new MSVC dependencies 2022-03-21 18:37:31 +01:00
Jonas Kvinge
c82bdb6405 Add musepack, bs2b, faac and faad to nsi for msvc 2022-03-19 20:15:56 +01:00
Jonas Kvinge
eec8ee5830 Add qtsparkle for msvc in nsi 2022-03-17 14:46:12 +01:00
Strawbs Bot
e67eb3c0d8 Update translations 2022-03-17 01:02:02 +01:00
Jonas Kvinge
9c101759f6 CI: Update CI for MSVC dependencies 2022-03-17 00:06:18 +01:00
Jonas Kvinge
a55ee92590 Update nsi for MSVC library changes 2022-03-17 00:05:27 +01:00
Jonas Kvinge
5ccfc97dab Database: Fix schema update with Windows line-endings 2022-03-17 00:04:12 +01:00
Jonas Kvinge
d6dd88ec3d Add registry inetc plugin to nsi 2022-03-14 22:13:14 +01:00
Strawbs Bot
8557d83599 Update translations 2022-03-13 01:02:01 +01:00
Jonas Kvinge
94cf1f8698 macdeployqt: Remove optional plugins 2022-03-11 20:45:15 +01:00
Strawbs Bot
9ada35c3a3 Update translations 2022-03-11 01:03:01 +01:00
Jonas Kvinge
79b0c906fa CI: Fix path to gst-plugin-scanner for macOS 2022-03-10 22:14:51 +01:00
Jonas Kvinge
a0688f1dba CI: Fix path to gst-plugin-scanner for macOS 2022-03-10 21:09:12 +01:00
Jonas Kvinge
f91e8fecee CI: Reduce installed macports packages 2022-03-10 16:24:01 +01:00
Jonas Kvinge
1b363babe2 Use our own macOS dependencies 2022-03-10 15:51:07 +01:00
Jonas Kvinge
73843cb54d Switch back to libsoup 2 in nsi
libsoup 3.0 currently has issues with gstreamer
2022-03-08 21:53:10 +01:00
Jonas Kvinge
a2ccfc2116 Add libgioopenssl.dll to nsi 2022-03-07 22:32:50 +01:00
Jonas Kvinge
fe104e2bad Update gstreamer plugins in nsi 2022-03-07 19:28:38 +01:00
Jonas Kvinge
35e3e9f4ff RPM spec: Update release for OpenMandriva 2022-03-06 14:05:07 +01:00
Jonas Kvinge
b2a1cd9716 CI: Add openSUSE Leap 15.4 2022-03-05 21:26:51 +01:00
Jonas Kvinge
14f58eae4b CI: Add Fedora 36 2022-03-05 21:26:24 +01:00
Jonas Kvinge
5cec000618 Add fdk-aac to nsi 2022-03-05 12:15:48 +01:00
Jonas Kvinge
4805a5287d CI: Remove Ubuntu Hirsute 2022-03-05 03:27:09 +01:00
Jonas Kvinge
4789dc5b30 Add bs2b to nsi 2022-03-05 01:55:05 +01:00
Jonas Kvinge
5a35099043 Add support for bs2b
Improve headphone listening of stereo audio records
2022-03-05 01:30:49 +01:00
Strawbs Bot
4cd0128919 Update translations 2022-03-02 01:02:32 +01:00
Jonas Kvinge
61e9b80f67 Song: Remove playlists from accepted file extensions
Fixes #909
2022-03-01 21:26:08 +01:00
Strawbs Bot
dcd881ba6c Update translations 2022-02-23 01:02:20 +01:00
Strawbs Bot
d40a67ce68 Update translations 2022-02-22 01:02:35 +01:00
Jonas Kvinge
1c1e7ca62a nsi: Move libmpg123-0.dll to common files 2022-02-21 20:47:11 +01:00
Jonas Kvinge
d3831d511b nsi: Move libmpg123-0.dll to common files 2022-02-21 20:45:26 +01:00
Jonas Kvinge
0942e93144 Add mpg123 plugin to nsi 2022-02-21 20:33:10 +01:00
Jonas Kvinge
98d3eba8e8 AlbumCoverLoader: Use char for QString::remove() 2022-02-21 20:22:47 +01:00
Jonas Kvinge
ff3db03696 AlbumCoverLoader: Remove slash and backslash from cover filename
Fixes #903
2022-02-21 20:21:06 +01:00
Strawbs Bot
3608c31d22 Update translations 2022-02-21 01:03:09 +01:00
Jonas Kvinge
8d504d9cee Turn on git revision 2022-02-20 21:47:24 +01:00
Jonas Kvinge
782921f6e0 Release 1.0.2 2022-02-20 16:58:08 +01:00
Jonas Kvinge
0694aabb45 Update Changelog 2022-02-20 16:57:20 +01:00
Jonas Kvinge
604b35dfde Update 3rdparty/README.md 2022-02-17 22:14:05 +01:00
Strawbs Bot
4c308bf5d0 Update translations 2022-02-17 01:03:19 +01:00
Jonas Kvinge
7a53ca7f8e Scrobbler: Add extra submit delay on error
Fixes #898
2022-02-16 17:46:40 +01:00
Jonas Kvinge
7c51f04140 Update Changelog 2022-02-15 23:33:09 +01:00
Jonas Kvinge
488b326e0f globalshortcut-x11: Use XDefaultRootWindow with Qt >= 6.2 2022-02-14 22:50:28 +01:00
Strawbs Bot
1e0c0a35ba Update translations 2022-02-13 01:01:50 +01:00
Jonas Kvinge
bf044c1ccc CI: Switch to OpenMandriva Lx 4.2 2022-02-11 23:05:24 +01:00
Jonas Kvinge
c9caa7f034 Mpris2: Fix incorrect rounding when setting volume
Fixes #894
2022-02-11 20:26:41 +01:00
Jonas Kvinge
1b8966b3a4 globalshortcut-x11: Use private header for accessing app root window
QX11Application Currently lacks a method for this.

Fixes #893
2022-02-11 02:32:19 +01:00
Jonas Kvinge
01d4d404c0 globalshortcut-x11: Formatting 2022-02-11 02:32:09 +01:00
Jonas Kvinge
354bbf820f globalshortcut-x11: Drop use of variable for display 2022-02-11 02:31:45 +01:00
Strawbs Bot
7620f9ebbe Update translations 2022-02-09 01:04:47 +01:00
Jonas Kvinge
9c2c668a04 Add MSVC builder to CI 2022-02-08 23:22:50 +01:00
Jonas Kvinge
b6f5a5712b QobuzRequest: Fix setting composer and performer
Fixes #891
2022-02-08 21:28:11 +01:00
Jonas Kvinge
9e9df6eb16 Remove Fedora 36 2022-02-08 20:36:56 +01:00
Jonas Kvinge
f510c993a6 Remove openSUSE Leap 15.4 2022-02-08 20:36:20 +01:00
Jonas Kvinge
8ddcbaac27 Update nsi 2022-02-08 16:33:39 +01:00
Jonas Kvinge
3fcab72900 Change debug to uppercase in nsi 2022-02-07 23:55:49 +01:00
Jonas Kvinge
70aa2233e2 Change path to lockedlist in nsi 2022-02-07 23:46:24 +01:00
Jonas Kvinge
8123a2924d Update .gitignore 2022-02-07 22:46:01 +01:00
Jonas Kvinge
dd3c308b09 Only include qtsparkle directories when HAVE_QTSPARKLE is set 2022-02-07 21:17:36 +01:00
Jonas Kvinge
e56ca2ffd6 Update nsi for MSVC builds 2022-02-07 20:56:32 +01:00
Strawbs Bot
57c98c363c Update translations 2022-02-07 01:02:46 +01:00
Jonas Kvinge
2211508061 Transcoder: Use g_free 2022-02-06 18:47:23 +01:00
Jonas Kvinge
848e41919d SongLoader: Use g_free 2022-02-06 18:46:59 +01:00
Jonas Kvinge
dac613a8bb MoodbarPipeline: Use g_free 2022-02-06 18:37:11 +01:00
Jonas Kvinge
a1735278df Add 3rdparty getopt for MSVC 2022-02-06 17:29:07 +01:00
Jonas Kvinge
3730bd04a4 Add protobuf include dirs 2022-02-06 08:41:05 +01:00
Jonas Kvinge
eee3445d2f Silence some conversion warnings 2022-02-06 04:19:45 +01:00
Jonas Kvinge
8bf473dc3a SingleApplication: Simplify code 2022-02-06 04:18:59 +01:00
Jonas Kvinge
e106dda794 SingleApplication: Make const 2022-02-06 04:18:40 +01:00
Jonas Kvinge
fc35d2a35c Collection: Add I/O priority and thread priority to initialization list 2022-02-06 04:14:02 +01:00
Strawbs Bot
aef9ff0d38 Update translations 2022-02-06 01:03:48 +01:00
Jonas Kvinge
192fb46d1d Use deleteLater() for Subsonic, Tidal and QObuz requests 2022-02-06 00:58:50 +01:00
Jonas Kvinge
1dd4eb05f2 Update SingleApplication 2022-02-06 00:07:15 +01:00
Jonas Kvinge
79f0c494fa Update Changelog 2022-02-05 19:37:32 +01:00
Jonas Kvinge
7caeb47637 GstEnginePipeline: Use std::shared_ptr with deleteLater() for fader timeline
Fixes #890
2022-02-05 19:33:21 +01:00
Jonas Kvinge
ffef339ebd TrackSliderSlider: Fix compile with Qt 5 2022-02-05 19:06:58 +01:00
Jonas Kvinge
817153b20b SingleApplication: Remove use of deprecated QCryptographicHash::addData 2022-02-05 18:58:43 +01:00
Jonas Kvinge
686eb2e786 TrackSliderSlider: Use different constructor for QMouseEvent 2022-02-05 18:54:00 +01:00
Jonas Kvinge
53d5192477 Allow deleting CUE songs 2022-02-05 15:56:18 +01:00
Strawbs Bot
a172f5fe85 Update translations 2022-02-05 01:02:55 +01:00
Jonas Kvinge
288408795b Disable open audio CD menu when compiled without audio CD support 2022-02-04 19:45:30 +01:00
Jonas Kvinge
4b5a811b08 CI: Copy libsoup-3.0-0.dll 2022-02-04 19:09:53 +01:00
Jonas Kvinge
c1259d8b6e EditTagDialog: Add scrollarea
Fixes #888
2022-02-04 19:08:04 +01:00
Jonas Kvinge
3acbe431f7 Replace non-translated characters with underscore 2022-02-04 19:07:15 +01:00
Jonas Kvinge
40f381257d Use libsoup3 in nsi 2022-02-04 01:36:17 +01:00
Strawbs Bot
beec983f21 Update translations 2022-02-04 01:01:49 +01:00
Strawbs Bot
d20750012e Update translations 2022-01-31 01:21:46 +01:00
Jonas Kvinge
e31c9d74fa Add advanced settings for configuring collection watcher 2022-01-30 04:24:33 +01:00
Jonas Kvinge
78adc388df SubsonicRequest: Make sure covers are only requested once per cover ID
Fixes #885
2022-01-30 02:30:51 +01:00
Jonas Kvinge
609413cda4 SubsonicRequest: Fix requesting album covers 2022-01-30 01:56:29 +01:00
Jonas Kvinge
63e5d6a94a Require Qt 5.9 2022-01-29 21:33:33 +01:00
Jonas Kvinge
fd5970b647 Player: Don't set volume lower than 0 or higher than 100.
Fixes #884
2022-01-29 20:32:33 +01:00
Strawbs Bot
af38b8f92b Update translations 2022-01-29 01:32:04 +01:00
Jonas Kvinge
e676e65f9e Update Changelog 2022-01-29 00:31:28 +01:00
Jonas Kvinge
4c479301ff Register MtpConnection as metatype
Fixes:

```
00:13:02.210 WARN  unknown                          QObject::connect: Cannot queue arguments of type 'MtpConnection*'
00:13:02.210 WARN  unknown                          (Make sure 'MtpConnection*' is registered using qRegisterMetaType().)
```
2022-01-29 00:17:37 +01:00
Jonas Kvinge
98178947ae GioLister: Use nullptr 2022-01-29 00:07:00 +01:00
Jonas Kvinge
0dbf3b462b CollectionWatcher: Remove broken nomedia/nomusic handling
It causes songs to be stuck when adding a nomedia file to an existing
directory.
2022-01-28 23:56:10 +01:00
Jonas Kvinge
cd9f8b569b CollectionWatcher: Ignore temp files 2022-01-28 23:53:58 +01:00
Jonas Kvinge
6b23728efa Fix deleting songs from filesystemdevices 2022-01-28 23:32:49 +01:00
Jonas Kvinge
ff0f7ee483 SubsonicSettingsPage: Remove insecure from hex description 2022-01-28 22:35:58 +01:00
Jonas Kvinge
74498c3ac9 Remove remaining sparkle integration 2022-01-28 21:26:37 +01:00
Jonas Kvinge
7a61e740e8 Subsonic: Add button to delete songs
Fixes #883
2022-01-28 21:26:28 +01:00
Enrique Garcia
81e6b55c39 subsonic configuration: use the entered password when clicking Test 2022-01-22 14:11:37 +01:00
Jonas Kvinge
e439ac0e0e Update to ffmpeg 5 in nsi 2022-01-19 21:20:51 +01:00
Jonas Kvinge
7b9d784a64 AnalyzerBase: Remove obsolete code 2022-01-17 22:45:19 +01:00
Jonas Kvinge
56b2630a1c Fix QToolButton stylesheet for Qt 5 2022-01-16 17:53:57 +01:00
Strawbs Bot
6d5597a732 Update translations 2022-01-16 01:03:01 +01:00
Jonas Kvinge
c0a9345358 Add OpenMandriva to CI 2022-01-15 19:47:43 +01:00
Jonas Kvinge
2e4ad81fff Fix copying sparkle 2022-01-15 14:50:33 +01:00
Jonas Kvinge
1aad85a4f9 Add openmandriva support to rpm spec 2022-01-15 14:43:06 +01:00
Jonas Kvinge
fbd2993239 Remove use of sparkle 2022-01-15 02:24:48 +01:00
Jonas Kvinge
203228bd05 Remove use of brew install --cask 2022-01-15 02:20:54 +01:00
Strawbs Bot
da7edebe90 Update translations 2022-01-15 01:03:39 +01:00
Jonas Kvinge
c7444a189e Replace SUUpdater with SPUStandardUpdaterController 2022-01-15 00:04:21 +01:00
Jonas Kvinge
29235c5fa6 Update stylesheet to use property name for popupMode on QToolButton 2022-01-14 23:25:36 +01:00
Strawbs Bot
bf8374ff9f Update translations 2022-01-14 01:01:58 +01:00
Strawbs Bot
ba05e85e48 Update translations 2022-01-12 01:35:28 +01:00
WGH
a9aab0702c GIOLister: ignore system mounts as defined by GIO
Strawberry has some heuristics to exclude things
like the root mount, /boot, tmpfs, etc. from the devices list.

However, it's somewhat incomplete. GIO (GLib component)
has more complete definition of "internal system mounts"
that should not be presented to the user.

Additionally, don't try to query filesystems free/total size
if it's internal, as that triggers automounting for autofs
filesystems (#410).
2022-01-11 18:05:09 +01:00
Strawbs Bot
b5cf83d501 Update translations 2022-01-11 01:02:44 +01:00
Jonas Kvinge
1cc2e6303a Show menu when clicking icon for collection and internet search tool buttons 2022-01-10 22:51:27 +01:00
Jonas Kvinge
4509a07fff Add openSUSE Leap 15.4 2022-01-09 12:19:13 +01:00
Jonas Kvinge
ea419f6d40 Add Ubuntu Jammy 2022-01-09 03:26:33 +01:00
Jonas Kvinge
c9b6707468 Add Debian Bookworm 2022-01-09 03:26:33 +01:00
Jonas Kvinge
cf512a35a7 Add Fedora 36 2022-01-09 03:26:33 +01:00
Strawbs Bot
bdd3e5343d Update translations 2022-01-09 01:02:36 +01:00
Jonas Kvinge
80fd8cd338 Log Qt version on startup 2022-01-08 21:33:14 +01:00
Jonas Kvinge
eb48592083 Turn on git revision 2022-01-08 21:33:06 +01:00
Jonas Kvinge
a45cb25002 Release 1.0.1 2022-01-08 15:20:32 +01:00
Jonas Kvinge
21ec116769 Update Changelog 2022-01-08 14:42:53 +01:00
Jonas Kvinge
1d4775a94b Simplify stylesheet on QToolButton 2022-01-08 13:18:54 +01:00
Jonas Kvinge
4cde9a7e9e Fix padding on toolbuttons with menu button popup
Fixes #795
2022-01-08 13:10:48 +01:00
Jonas Kvinge
709ba72777 CollectionWatcher: Exclude hidden files 2022-01-07 21:16:38 +01:00
Strawbs Bot
0e56b8c575 Update translations 2022-01-07 01:05:42 +01:00
Jonas Kvinge
558a087e37 CollectionWatcher: Resume collection scan when adding directory 2022-01-06 23:29:20 +01:00
Jonas Kvinge
7d96fe8b65 CollectionWatcher: Abort collection scan on exit 2022-01-06 23:14:10 +01:00
Jonas Kvinge
2f3e8986ab AlbumCoverChoiceController: Clear manually set cover when setting embedded cover
Possible fix for #858
2022-01-06 02:14:33 +01:00
Strawbs Bot
df359ba0fa Update translations 2022-01-06 01:09:25 +01:00
Jonas Kvinge
31fa60884f Tagreader: Fix comment 2022-01-06 00:08:48 +01:00
Jonas Kvinge
15be227920 TagReader: Various fixes to embedded cover handling
- Add support for saving embedded for Opus
- Fix deleting cover for Ogg Vorbis, Opus and Speex
- Don't load empty covers
2022-01-06 00:06:20 +01:00
Jonas Kvinge
fdedfd54c7 Moodbar: Disable moodbar loader for CUE songs 2022-01-05 18:59:14 +01:00
Strawbs Bot
7d55eb4b44 Update translations 2022-01-03 12:42:15 +01:00
Jonas Kvinge
61ac7ae31e GeniusLyricsProvider: Move index past start tag 2022-01-02 21:47:16 +01:00
Jonas Kvinge
353e141036 Add Qt 5 warning 2022-01-02 14:48:45 +01:00
Jonas Kvinge
cb4332842f Save MP4 tags as UTF-8
Fixes #830
2022-01-02 02:47:42 +01:00
Jonas Kvinge
004d219c97 CollectionWatcher: Fix notify on path change, improve debug output
Possible fix for #860
2022-01-01 01:32:41 +01:00
Jonas Kvinge
94561e6815 Windows: Include ibgstxingmux.dll in installer 2021-12-27 18:12:55 +01:00
Jonas Kvinge
ce3af4961b GeniusLyricsProvider: Fix parsing of different HTML pages 2021-12-19 20:59:38 +01:00
Jonas Kvinge
bbd81e7d9c kglobalaccel: Attempt to register media shortcuts too 2021-12-18 20:18:37 +01:00
Jonas Kvinge
8b1d198efd Remove unused Avahi 2021-12-18 19:46:23 +01:00
Jonas Kvinge
7a3bafc961 Add Tumbleweed to CI 2021-12-18 13:00:33 +01:00
Jonas Kvinge
512eed9b04 Remove CMake release config from strawberry.spec 2021-12-14 22:16:44 +01:00
Strawbs Bot
38adf640e9 Update translations 2021-12-13 01:02:34 +01:00
Jonas Kvinge
f4d8d73970 Always save metadata in playlist for Tidal, Qobuz and Subsonic songs
Fixes #851
2021-12-12 01:43:46 +01:00
Strawbs Bot
5a50285dee Update translations 2021-12-08 12:29:11 +01:00
Jonas Kvinge
ca4ea0719f Playlist: Fix updating summary after reloading items
Fixes #848
2021-12-08 01:35:49 +01:00
Strawbs Bot
4c6251bf28 Update translations 2021-11-29 01:02:44 +01:00
Alexey Vazhnov
22c12c7366 Add dist/scripts/import-from-clementine.sh
Shell script for importing database from Clementine.

Fixes #838
Fixes #248
2021-11-28 13:14:45 +01:00
Jonas Kvinge
8f49d1591f Support more CUE filenames
Fixes #835
2021-11-27 20:28:00 +01:00
Jonas Kvinge
a97dbab2ae CollectionWatcher: Rename fileinfo variable 2021-11-27 19:25:25 +01:00
Jonas Kvinge
4cb8261d3b CueParser: Fix parsing tracks with 1-digit minutes
Fixes #836
2021-11-27 18:15:03 +01:00
Strawbs Bot
059e2d740f Update translations 2021-11-22 01:02:26 +01:00
Strawbs Bot
587d1c9d74 Add Spanish (Mexico) 2021-11-20 17:28:02 +01:00
Strawbs Bot
ab56c96170 Add Spanish (Argentina) 2021-11-20 17:27:23 +01:00
Strawbs Bot
efa4270429 Add Spanish/Spain 2021-11-20 17:14:43 +01:00
Strawbs Bot
0fbe5d888a Update translations 2021-11-13 01:02:59 +01:00
Strawbs Bot
b68f81179e Update translations 2021-11-11 01:05:36 +01:00
Jonas Kvinge
6a8c1af5f9 GstEnginePipeline: Set port-pattern for jackaudiosink 2021-11-11 00:58:00 +01:00
Jonas Kvinge
98f287559b GstEngine: Allow custom device for jackaudiosink 2021-11-11 00:58:00 +01:00
Strawbs Bot
1a53d85f6a Update translations 2021-11-10 01:19:03 +01:00
Jonas Kvinge
05b168aa04 Fix incorrect playlist column filesize for streams 2021-11-09 21:16:44 +01:00
Jonas Kvinge
a68d856074 AlbumCoverLoader: Change ID to quint64 2021-11-09 20:48:43 +01:00
Jonas Kvinge
d5dac9c6cc Add musicbrainz icon 2021-11-09 20:07:48 +01:00
Adam Hill
e9f7f42c03 PlaylistView: Fix for currenttrack_bar blocky rendering 2021-11-09 19:45:41 +01:00
Uint
7b8265d4a3 Prevent filtering when filter toolbar is hidden, clear when disabled 2021-11-09 19:41:23 +01:00
Jonas Kvinge
5715f4c2cb Remove use of macros in Song and TagReader 2021-11-09 19:34:43 +01:00
Jonas Kvinge
350debb66c Utilities: Add static_cast in Hmac() 2021-11-09 19:34:43 +01:00
Jonas Kvinge
267cd3660b InternetSearchSortModel: Replace use of macro 2021-11-09 19:34:43 +01:00
Jonas Kvinge
bc1c0c3c6d SqlQuery: Add more BindValue methods 2021-11-09 19:34:43 +01:00
Jonas Kvinge
c420f69da8 SqlRow: Replace class with a new that takes values by column field name 2021-11-09 19:34:43 +01:00
Jonas Kvinge
2151d96303 Use PlaylistItemList 2021-11-09 19:34:43 +01:00
Jonas Kvinge
c48c65d0ce InternetService: Change parameters to const 2021-11-09 19:34:43 +01:00
Jonas Kvinge
1c0b706b94 TranscoderOptionsVorbis: Remove use of macros 2021-11-09 19:34:43 +01:00
Jonas Kvinge
2dca3d6f5a gstfastspectrum: Remove some macros 2021-11-09 19:34:43 +01:00
Jonas Kvinge
0992636f8c playlistparsers: Change qt_endl macro to constexpr 2021-11-09 19:34:43 +01:00
Jonas Kvinge
86d3f2b4ed SliderSlider: Remove unused macros 2021-11-09 19:34:43 +01:00
Jonas Kvinge
b78b4038f6 InternetService: Fix overloaded signal 2021-11-09 19:34:43 +01:00
Jonas Kvinge
84c14349dc ContextAlbumsModel: Remove unused SqlRow 2021-11-09 19:34:43 +01:00
Strawbs Bot
9916e34006 Update translations 2021-11-09 01:05:40 +01:00
Jonas Kvinge
a729b42e5d Tidal: Fix reading keyId 2021-11-08 20:44:12 +01:00
Jonas Kvinge
01f8129ed0 Improve URL handler, return error for encrypted Tidal streams 2021-11-08 20:25:22 +01:00
Jonas Kvinge
fd85763fb4 Tidal: Make sure OAuth is enabled when sending access token 2021-11-08 19:47:17 +01:00
Jonas Kvinge
c278ffe2cb CI: Remove Windows Qt 5 builder 2021-11-05 21:41:30 +01:00
Jonas Kvinge
902c76a781 Remove Qt 5 support from Windows nsi 2021-11-05 21:38:09 +01:00
Jonas Kvinge
4daed0070a WorkerPool: Add missing config.h include 2021-11-04 00:42:49 +01:00
Jonas Kvinge
a4d055b3ac Remove obsolete cmake version check 2021-11-04 00:05:06 +01:00
Jonas Kvinge
e6ae6c6f04 Remove Fedora 33 2021-11-03 22:11:17 +01:00
Jonas Kvinge
de54ceeb40 Add Fedora 35 to CI 2021-11-03 21:21:12 +01:00
Strawbs Bot
77fe00df30 Update translations 2021-11-03 01:02:23 +01:00
Strawbs Bot
4ae3e63dea Update translations 2021-11-01 01:20:05 +01:00
Jonas Kvinge
3329839dbe CollectionWatcher: Add overwrite_rating_ to initialization list 2021-10-31 23:26:22 +01:00
Jonas Kvinge
ca10920bb5 Add option for overwriting database rating 2021-10-31 23:24:32 +01:00
Jonas Kvinge
b41957ce5c Add back css style for QToolButton only on macOS
Fixes #819
2021-10-31 16:55:33 +01:00
Jonas Kvinge
3db6699018 WorkerPool: Use variable 2021-10-31 14:48:42 +01:00
Jonas Kvinge
5284ca90ef Forward messages from tagreader worker process on Windows 2021-10-31 13:51:23 +01:00
Jonas Kvinge
628cdff4fa TagReaderTagParser: Return false from SaveSongPlaycountToFile 2021-10-31 13:19:52 +01:00
Jonas Kvinge
af0c6f9233 Logging: Use stdout unless critical or fatal, and flush stream 2021-10-31 13:18:26 +01:00
Jonas Kvinge
7697bbfa4e Logging: Formatting 2021-10-31 13:18:26 +01:00
buckmelanoma
642a455a9c Add icon mappings for download and scrobble
Adds mappings for download (Cover Manager) and scrobble (Import data from last.fm):
2021-10-31 02:23:15 +01:00
Strawbs Bot
6abfa2859b Update translations 2021-10-31 01:20:21 +02:00
buckmelanoma
20c2225d8f Add icon names for missing Tools menu entries
I noticed the abort_collection_scan and console menu entries were missing matching icons.  This change adds appropriate icons for each action.
2021-10-31 00:37:57 +02:00
Jonas Kvinge
5e7759b697 Utilities: Change return type for GetThreadId and SetThreadIOPriority to long 2021-10-31 00:26:02 +02:00
Jonas Kvinge
1ce8d2b31d RadioView: Remove overloaded signal 2021-10-31 00:24:16 +02:00
Jonas Kvinge
9fbecb5af6 macdeployqt: Use static QFile::exists() 2021-10-30 19:23:08 +02:00
Jonas Kvinge
1223469be9 Song: Add playcount and rating to Song::IsMetadataEqual() 2021-10-30 19:06:46 +02:00
Jonas Kvinge
5eae3ddd8a Use float for rating 2021-10-30 18:53:14 +02:00
Jonas Kvinge
3d0b6e6ea1 TagReader: Check for valid file times
Fixes #815
2021-10-30 17:57:13 +02:00
Jonas Kvinge
c6c53548ac GstEnginePipeline: Return true from BusCallback 2021-10-30 17:55:18 +02:00
Jonas Kvinge
3efe2d1e05 Initialize to 0 2021-10-30 17:10:05 +02:00
buckmelanoma
7c87b53517 PlaylistView: Use SmoothPixmapTransform when drawing play icon
Fixes #794
2021-10-30 03:36:17 +02:00
Jonas Kvinge
a461c97bcf IconLoader: Log when icon fails to load 2021-10-30 03:34:52 +02:00
Jonas Kvinge
67a6d6c1e3 LyricsFetcher: Change request ID to quint64 2021-10-30 03:15:03 +02:00
Jonas Kvinge
8b8e427a2b DeleteFiles: Fix compile with older Qt versions 2021-10-30 03:13:55 +02:00
Jonas Kvinge
7d5c263ab2 FHT: Change to static_cast double 2021-10-30 03:13:12 +02:00
Jonas Kvinge
79ac53b2d9 Fix narrowing conversions 2021-10-30 02:21:29 +02:00
Jonas Kvinge
a704412dee ContextAlbumsModel: Use const_iterator 2021-10-30 02:05:55 +02:00
Jonas Kvinge
24e2338769 ScrobblingAPI20: Add clazy:exclude=range-loop-detach 2021-10-30 02:02:37 +02:00
Jonas Kvinge
bc240f82ef SomaFMService: Add clazy:exclude=function-args-by-ref 2021-10-30 02:01:48 +02:00
Jonas Kvinge
a2ad68406d RadioView: Add clazy:exclude=reserve-candidates 2021-10-30 02:01:14 +02:00
Jonas Kvinge
3d807d2331 FilterParser: Add iter_ and end_ to initialization list 2021-10-30 02:00:26 +02:00
Jonas Kvinge
e6a7b484ba OSDBase: Remove redundant initialization 2021-10-30 01:59:51 +02:00
Jonas Kvinge
a62371829f Add ui_ to initialization list 2021-10-30 01:58:47 +02:00
Jonas Kvinge
fb98336713 Udisks2Lister: Remove redundant initialization 2021-10-30 01:58:01 +02:00
Jonas Kvinge
ebadb4db0a Use const_iterator 2021-10-30 01:57:12 +02:00
Jonas Kvinge
9a480eb710 SqlQuery: Make QSqlDatabase parameter const reference 2021-10-30 01:33:16 +02:00
Jonas Kvinge
03ecde8b83 Add default to switch 2021-10-30 01:08:35 +02:00
Strawbs Bot
0291b78bfa Update translations 2021-10-30 01:02:38 +02:00
Jonas Kvinge
377e6fad25 gstmoodbar: Formatting 2021-10-30 00:48:58 +02:00
Jonas Kvinge
e75c955a68 mac_startup: Remove unused functions 2021-10-30 00:48:58 +02:00
buckmelanoma
6df356327d Add 2px of padding for edit-clear icon
edit-clear icon tends to sit on left side of frame.  adding 2 px makes it look nicer.
2021-10-29 17:52:43 +02:00
buckmelanoma
7a57586f90 Map edit-clear-list system icons
Use system edit-clear-list icons when enabled instead of defaulting to edit-clear-locationbar-ltr.png
2021-10-29 17:52:43 +02:00
Strawbs Bot
1e2bad270d Update translations 2021-10-29 01:02:58 +02:00
Strawbs Bot
688d983b25 Update translations 2021-10-28 01:02:41 +02:00
Jonas Kvinge
fa834a76ef ContextView: Avoid unnecessary album resize 2021-10-27 22:16:48 +02:00
Jonas Kvinge
5cb88efc38 Remove debug line 2021-10-26 23:54:27 +02:00
Jonas Kvinge
6b64c43851 TagReaderTagLib: Read FMPS_Rating for MPEG ID3v2 tag 2021-10-26 01:10:01 +02:00
Jonas Kvinge
704e6c5448 TagReaderTagLib: Use double for ratings to match Song 2021-10-26 00:24:03 +02:00
Jonas Kvinge
072d7379df TagReaderTagLib: Add checks for nullptr 2021-10-26 00:02:36 +02:00
Strawbs Bot
df1b756a43 Update translations 2021-10-25 01:13:11 +02:00
Jonas Kvinge
30269d9d95 Organize: Remove unused "mark as listened" option 2021-10-24 23:19:01 +02:00
Jonas Kvinge
d29a1de980 Allow users to select native notifications on Windows
Setting will fallback to system tray notifications which are
native notifications on Windows.
2021-10-24 23:09:20 +02:00
Jonas Kvinge
57f5ccff81 InternetSearchView: Change tool button popup mode back to InstantPopup 2021-10-24 22:05:10 +02:00
buckmelanoma
69374bfa11 Revert collection options QToolButton mode
Changing this button type fixed the arrow problem but has a side effect of making the button only clickable on the arrow portion.   #795 fixed the issue with styling on QToolButtons and ends up fixing this issue too.  Therefore the change to MenuButtonPopup should be reverted in order to restore the original functionality.
2021-10-24 20:11:27 +02:00
Jonas Kvinge
d9fd330216 Update Changelog 2021-10-24 18:32:14 +02:00
Jonas Kvinge
312f62d98f Fix stop after this track button with Qt 6
Fixes #795
2021-10-24 18:15:42 +02:00
buckmelanoma
0d408055b2 Add settings to enable/disable playlist toolbar 2021-10-24 17:04:35 +02:00
Jonas Kvinge
496ae42d72 EditTagDialog: Change return to continue in EditTagDialog::SongRated 2021-10-24 16:11:53 +02:00
Jonas Kvinge
3ab86543ad Add support for saving playcounts and ratings to tags 2021-10-24 16:08:17 +02:00
Jonas Kvinge
ce7926cfa4 Update libffi in nsi 2021-10-23 11:35:52 +02:00
Strawbs Bot
48c81b188c Update translations 2021-10-23 01:02:17 +02:00
Luna
21b241bbbe add release info 2021-10-22 23:25:19 +02:00
Luna
934d6fc267 add oars content rating 2021-10-22 23:25:19 +02:00
Luna
a0ce2daa2e add type to appdata.xml 2021-10-22 23:25:19 +02:00
Jonas Kvinge
006d77239b Update protobuf in nsi 2021-10-21 18:40:04 +02:00
Jonas Kvinge
303d31bde7 Update Windows dependencies 2021-10-19 23:56:24 +02:00
Strawbs Bot
737fbeccde Update translations 2021-10-19 01:02:20 +02:00
Jonas Kvinge
ec17dc9830 TagReaderClient: Sort functions 2021-10-18 23:15:50 +02:00
Strawbs Bot
0f710ea3be Update translations 2021-10-18 01:01:58 +02:00
Jonas Kvinge
bd4eec4527 Song: Only merge user set playcount and rating if set
Fixes #790
2021-10-18 00:39:26 +02:00
Jonas Kvinge
c78252e0d5 Add dates to Changelog
Fixes #803
2021-10-17 20:30:57 +02:00
Jonas Kvinge
b1f70982bf Make playlist column text elided
Fixes #801
2021-10-17 02:33:26 +02:00
Strawbs Bot
6128fb4f19 Update translations 2021-10-17 01:10:41 +02:00
Jonas Kvinge
ee915254e7 Song: Sort code in Song::ToProtobuf() 2021-10-17 00:34:33 +02:00
Jonas Kvinge
d835d4aae6 Add rating to Song::InitFromProtobuf and Song::ToProtobuf 2021-10-17 00:27:31 +02:00
Jonas Kvinge
5945d0ebee Read rating from tags
Fixes #790
2021-10-16 23:33:03 +02:00
Jonas Kvinge
3d3aacdcb1 InternetSearchView: Change popupmode for toolbutton to QToolButton::MenuButtonPopup 2021-10-16 22:41:14 +02:00
Jonas Kvinge
c3ce6cff72 GstEngine: Move CreateElement() to GstEnginePipeline 2021-10-16 21:28:56 +02:00
Jonas Kvinge
6d7a01fb4e Logging: Remove custom debug level for gst pipeline 2021-10-16 21:25:36 +02:00
Jonas Kvinge
8582e09e73 CI: Remove Ubuntu Groovy and add Impish 2021-10-16 14:30:45 +02:00
buckmelanoma
90744f2965 Fix filter menu button arrow overlap
Change collection filter menu button's popupMode to MenuButtonPopup to prevent arrow overlapping with button icon
2021-10-16 13:21:15 +02:00
Jonas Kvinge
03d0776fdc Turn on git revision 2021-10-15 00:02:06 +02:00
Jonas Kvinge
9d18f40c5f Release 1.0.0 2021-10-14 20:50:41 +02:00
Jonas Kvinge
47e771ee37 Update Changelog 2021-10-14 20:50:20 +02:00
Jonas Kvinge
20760dcf0e Fix FreeBSD CI 2021-10-13 19:30:46 +02:00
Strawbs Bot
2edf12e4cd Update translations 2021-10-13 01:16:38 +02:00
Jonas Kvinge
c946c1d1c4 Player: Don't preload next song while playing module music
Workaround bug in GStreamer

Fixes #787
Fixes #772
2021-10-12 22:59:23 +02:00
Jonas Kvinge
bb5fe5a6d1 Add Song::is_module_music() 2021-10-12 22:58:39 +02:00
Jonas Kvinge
814d2fa9fc MainWindow: Use Song::PrettyTitle() in debug message 2021-10-12 22:57:59 +02:00
Jonas Kvinge
10d89cb6a6 FileView: Add module music formats to file filter 2021-10-12 21:44:30 +02:00
Jonas Kvinge
a6569d09ac Read XM and IT module music 2021-10-12 21:43:46 +02:00
staticssleever668
b38ad81928 Remove use of C-style casts 2021-10-12 18:50:17 +02:00
Jonas Kvinge
637772f8f0 GstEnginePipeline: Convert S24_32LE for analyzer 2021-10-12 18:46:12 +02:00
Jonas Kvinge
0093eb6c2c GstEnginePipeline: Refactor code 2021-10-12 18:36:58 +02:00
Jonas Kvinge
f3b70d1cb2 GstEnginePipeline: Rename variable 2021-10-12 18:36:13 +02:00
Strawbs Bot
5152f57f6e Update translations 2021-10-11 01:02:01 +02:00
Jonas Kvinge
e6112a311d Add openmpt to nsi 2021-10-10 23:31:08 +02:00
Jonas Kvinge
e069d069d2 GstEngine: Remove unused variables 2021-10-10 21:12:31 +02:00
Jonas Kvinge
fd74bbc868 Remove unused GstElementDeleter 2021-10-10 16:33:07 +02:00
Strawbs Bot
3b37aea3da Update translations 2021-10-10 01:02:39 +02:00
Jonas Kvinge
2fd4bbbd49 Update Changelog 2021-10-09 22:25:27 +02:00
Jonas Kvinge
17226b524b SubsonicSettingsPage: Rename HTTP2 to HTTP/2 2021-10-09 16:38:13 +02:00
Jonas Kvinge
f38b33ee50 Scrobbler: Use seconds instead of minutes for submit delay 2021-10-09 14:05:05 +02:00
Jonas Kvinge
0da0e0a6db macdeployqt: Fix typo 2021-10-09 01:50:19 +02:00
Jonas Kvinge
de2b6d1dee macdeployqt: Replace QSet with QList 2021-10-09 01:50:19 +02:00
Jonas Kvinge
c9a501ddc8 Update README.md 2021-10-09 00:39:11 +02:00
Jonas Kvinge
c5babbbb22 Update README.md 2021-10-09 00:34:28 +02:00
Jonas Kvinge
1fd0d1a330 macdeployqt: Remove FinalCheck from header 2021-10-08 23:47:33 +02:00
Jonas Kvinge
84d9b30fec macdeployqt: Replace bearer with tls 2021-10-08 23:40:41 +02:00
Jonas Kvinge
d0f1522f0d GstEnginePipeline: Use gst_bus_remove_watch to remove bus watch 2021-10-08 23:39:29 +02:00
Jonas Kvinge
6b2e25122d nsi: Remove tls dir 2021-10-07 23:48:23 +02:00
Strawbs Bot
ce3026f91c Update translations 2021-10-06 01:02:49 +02:00
Jonas Kvinge
4b384b3b59 Update ccpp.yml 2021-10-04 11:51:16 +02:00
Strawbs Bot
da7605a234 Update translations 2021-10-03 01:08:24 +02:00
Jonas Kvinge
3abdec1b91 Add qopensslbackend.dll to nsi and CI 2021-10-01 23:52:59 +02:00
Strawbs Bot
ef34199887 Update translations 2021-10-01 01:02:14 +02:00
Jonas Kvinge
08eca88e2f Add require for qt6-network-tls to RPM spec 2021-09-30 22:54:08 +02:00
Strawbs Bot
4636cc74dc Update translations 2021-09-29 01:03:09 +02:00
Jonas Kvinge
4cc54a2f05 PlaylistTabBar: Hide star option with clicked outside of a tab 2021-09-28 22:19:31 +02:00
Jonas Kvinge
9bd728889b PlaylistTabBar: Add right click option to star playlist
Fixes #782
2021-09-28 22:14:25 +02:00
Adam Hill
d870115467 Set SmoothPixmapTransform for playing-widget and context album art display 2021-09-28 21:52:31 +02:00
Jonas Kvinge
2b445fb563 StyleSheetLoader: Cleanup code and add workaround for macOS dark theme
Fixes #778
2021-09-28 17:25:22 +02:00
Strawbs Bot
44a3bad278 Update translations 2021-09-28 01:12:34 +02:00
Jonas Kvinge
8d2615547d Add keyboard shortcut for focusing search fields
Fixes #779
2021-09-27 21:42:30 +02:00
Jonas Kvinge
3292db8b77 Add missing override 2021-09-27 21:41:45 +02:00
Jonas Kvinge
8c6ad52437 Organize: Update collection directory ID and song path immediately
Fixes #781
2021-09-27 19:30:31 +02:00
Jonas Kvinge
62e53b53f0 Replace assert with Q_ASSERT 2021-09-27 19:30:31 +02:00
Strawbs Bot
35db157617 Update translations 2021-09-27 01:22:03 +02:00
Jonas Kvinge
cfb137a94b DeviceDatabaseBackend: Fix GetAllDevices() 2021-09-26 21:38:06 +02:00
Jonas Kvinge
9b4a33a612 MPris2: Remove static 2021-09-26 20:14:11 +02:00
Jonas Kvinge
918b7c1e03 Move chrono include 2021-09-26 20:06:04 +02:00
Jonas Kvinge
8fb354705c Update Changelog 2021-09-26 19:03:01 +02:00
Jonas Kvinge
b3826064b7 Bump device schema version 2021-09-26 18:35:03 +02:00
Jonas Kvinge
acba68dab9 MergedProxyModel: Add FIXME 2021-09-26 18:34:44 +02:00
Jonas Kvinge
32ea709350 Subsonic: Turn off HTTP/2 setting by default 2021-09-26 16:50:41 +02:00
Jonas Kvinge
c15dfc7c5d Subsonic: Make HTTP/2 setting visible with Qt 5.15.0 and higher 2021-09-26 16:49:53 +02:00
Jonas Kvinge
92f6a0c6c8 Add mod and s3m to filetypes 2021-09-26 16:23:02 +02:00
Jonas Kvinge
0235be538b Moodbar: Check for nullptr 2021-09-26 14:42:24 +02:00
Jonas Kvinge
abf19e7a27 Moodbar: Use gst_element_link_many 2021-09-26 14:42:05 +02:00
Jonas Kvinge
1d3540dca6 Remove unused MoodbarPipeline::IsAvailable function 2021-09-26 14:41:36 +02:00
Jonas Kvinge
ddfc9d911b Extend unit tests 2021-09-26 01:15:17 +02:00
Strawbs Bot
b952256988 Update translations 2021-09-26 01:02:42 +02:00
Jonas Kvinge
71868936d1 Subsonic: Use common static function CreateUrl() 2021-09-25 01:18:40 +02:00
Strawbs Bot
23ef4fb132 Update translations 2021-09-22 01:04:55 +02:00
Jonas Kvinge
f74f2ca3ef Subsonic: Remove redundant null check 2021-09-21 01:36:38 +02:00
Jonas Kvinge
f4f005cdd6 Subsonic: Fix auth method for URL handler 2021-09-21 01:30:01 +02:00
Jonas Kvinge
3137652280 Use ParamList 2021-09-21 01:30:01 +02:00
Strawbs Bot
88c6f0340a Update translations 2021-09-21 01:01:57 +02:00
Strawbs Bot
86146c7292 Update translations 2021-09-20 01:20:57 +02:00
Tom Kranz
fad39b6d67 Store Tidal MPEG-DASH file in data uri 2021-09-19 19:56:22 +02:00
Jonas Kvinge
09a9330f3e Show error when reading or saving album covers 2021-09-19 19:31:34 +02:00
Jonas Kvinge
d2d7f32c45 Add new method for updating songs based on song ID
Show status updating database.

Fixes #750
2021-09-19 15:43:36 +02:00
Tom Kranz
120b18b399 Use XSPF image elements as manually set artwork 2021-09-19 13:40:42 +02:00
Jonas Kvinge
32b9e6b73d Make error dialog larger 2021-09-18 17:12:59 +02:00
Jonas Kvinge
8d6e5272b9 Update protobuf in nsi 2021-09-17 01:35:20 +02:00
Strawbs Bot
b6f90a9715 Update translations 2021-09-15 01:02:18 +02:00
Jonas Kvinge
e3d0b777fc Add algorithm include 2021-09-14 22:57:09 +02:00
Jonas Kvinge
79a8450462 SpotifyCoverProvider: Fix trying to set timer to minus value 2021-09-14 22:12:28 +02:00
EmmanuelMess
1a967597e8 Fix roundings with lround() 2021-09-14 21:29:29 +02:00
Jonas Kvinge
d5b0794b00 Remove unneeded this 2021-09-13 20:49:33 +02:00
Jonas Kvinge
d78ee3d62b Fix total playlist length for songs without length 2021-09-13 20:46:55 +02:00
Strawbs Bot
03037a9a6b Update translations 2021-09-13 01:12:16 +02:00
Emmanuel
0637b65846 Fix a few narrowing conversions (#761)
* Fix narrowing conversion in album cover loader

* Fix narrowing conversions in discogs cover provider

* Fix narrowing conversions in spotify cover provider

* Add explicit conversion in moodbarbuilder

* Fix narrowing conversions in osd dbus

* Make WordyTimeNanosec use unsigned quint64

* Fix narrowing conversions in song

* Fix narrowing conversions in qobuz stream url request

* Make ConnectionInfo.msgLen use unsigned quint64

* Make AnalizerBase.timeout to signed int

* Fix narrowing conversions in album cover fetcher

* Make fht type be unsigned int

* Correct for type in blockanalizer and use std::fill where possible

* Revert "Fix narrowing conversions in song"

This reverts commit 3de291394d.
2021-09-12 21:24:22 +02:00
Jonas Kvinge
e77e914f44 Escape ampersands in playlist tabs
Fixes #760
2021-09-12 21:19:58 +02:00
EmmanuelMess
68c44daef2 Fix SingleApplication static functions called from instance 2021-09-10 18:44:36 +02:00
Strawbs Bot
8ca0b54b18 Update translations 2021-09-10 01:21:33 +02:00
Jonas Kvinge
b77d01baca CI: Use new image for Windows build 2021-09-09 23:06:59 +02:00
Jonas Kvinge
cd509bbbdc Update nsi for OpenSSL 3 2021-09-09 22:05:53 +02:00
Jonas Kvinge
24a3ac9811 Use static QMetaObject::invokeMethod 2021-09-09 21:53:14 +02:00
Jonas Kvinge
d35d3aabc3 Show error dialog for failed SQL queries 2021-09-09 21:45:46 +02:00
Jonas Kvinge
9e624a6c0d Remove openSUSE 15.2 from CI 2021-09-07 01:16:02 +02:00
Strawbs Bot
9823cd25d2 Update translations 2021-09-07 01:01:55 +02:00
Jonas Kvinge
416a8c8f5d Context: Hide albums widget in constructor 2021-09-07 00:10:05 +02:00
Strawbs Bot
c55bdd423e Update translations 2021-09-06 01:02:08 +02:00
Jonas Kvinge
e45e202c5e Subsonic: Make network replies timeout after 30 seconds
Fixes #754
2021-09-05 21:47:00 +02:00
Jonas Kvinge
2280a30ba9 Subsonic: Minor code style fix 2021-09-05 21:46:41 +02:00
Jonas Kvinge
9ac7518156 Subsonic: Remove obsolete return 2021-09-05 21:46:16 +02:00
Jonas Kvinge
0e6dbaf71a Settings: Fix loading subsonic auth method setting 2021-09-05 21:35:21 +02:00
Strawbs Bot
fe018ff8f7 Update translations 2021-09-02 01:03:13 +02:00
Jonas Kvinge
9b01e09302 GlobalShortcutsManager: Minor code fixes 2021-09-02 00:52:44 +02:00
Jonas Kvinge
3127474fd7 GlobalShortcutsManager: Fix reading settings 2021-09-02 00:52:21 +02:00
Jonas Kvinge
b849edfcca GlobalShortcutsBackend: Fix type return 2021-09-01 22:37:08 +02:00
Jonas Kvinge
20a23c2868 Various cleanup to global shortcuts code 2021-09-01 21:37:11 +02:00
Jonas Kvinge
49d9ded684 Fix null pointer crash
Possible fix for #752
2021-09-01 16:37:34 +02:00
Jonas Kvinge
fc57b437c2 Fix radio items leak 2021-08-31 22:45:28 +02:00
Jonas Kvinge
1ba20561ed Fix global shortcuts memory leak 2021-08-31 21:21:59 +02:00
Strawbs Bot
2c8b26e091 Update translations 2021-08-31 01:02:17 +02:00
Jonas Kvinge
62d2a97f38 Add make deploy to macOS CI 2021-08-30 18:13:29 +02:00
Strawbs Bot
44aa292bb5 Update translations 2021-08-30 01:02:16 +02:00
Strawbs Bot
5273b52c31 Update translations 2021-08-26 01:04:00 +02:00
Jonas Kvinge
f143efb810 Revert "Use std::as_const"
This reverts commit 0b15e29324.
2021-08-25 03:47:50 +02:00
Jonas Kvinge
978fb06349 clazy:exclude=range-loop-reference 2021-08-25 03:45:12 +02:00
Jonas Kvinge
e274e8070d Update Changelog 2021-08-25 03:19:42 +02:00
Jonas Kvinge
46bd5b42fa Use 4arg connect 2021-08-25 03:08:30 +02:00
Jonas Kvinge
0b15e29324 Use std::as_const 2021-08-25 03:00:34 +02:00
Jonas Kvinge
75b6669371 Simplify return 2021-08-25 02:58:54 +02:00
Jonas Kvinge
c1c34017e4 Remove get() 2021-08-25 02:58:20 +02:00
Jonas Kvinge
ed08818b6f Use multi-arg 2021-08-25 02:57:57 +02:00
Jonas Kvinge
71adfc0a74 Use std::chrono_literals 2021-08-25 02:57:09 +02:00
Jonas Kvinge
49ccbddb17 Add Q_DISABLE_COPY 2021-08-25 02:56:30 +02:00
Jonas Kvinge
be3c7eef60 Use default 2021-08-25 02:55:54 +02:00
Jonas Kvinge
336c6cdd9d Use 4arg connect 2021-08-25 02:55:00 +02:00
Jonas Kvinge
709a706853 Delete mimedata when returning early 2021-08-25 02:38:58 +02:00
Jonas Kvinge
dad62faf88 Use fully-qualified parameter for signal 2021-08-25 02:36:18 +02:00
Jonas Kvinge
6e0a5fb5c6 Make const 2021-08-25 02:29:05 +02:00
Jonas Kvinge
4b9551d27f Simplify if statement 2021-08-25 02:28:41 +02:00
Strawbs Bot
2a67bc9926 Update translations 2021-08-25 01:16:47 +02:00
Jonas Kvinge
d02241d32c Fix compile with MSVC 2021-08-24 21:49:06 +02:00
Strawbs Bot
55e038d345 Update translations 2021-08-24 01:08:33 +02:00
Jonas Kvinge
ea2bfbda44 Formatting 2021-08-23 21:21:08 +02:00
Jonas Kvinge
ed7794f396 macdeployqt: Replace foreach with C++11 for loop 2021-08-23 01:44:35 +02:00
Strawbs Bot
086646f311 Update translations 2021-08-23 01:02:20 +02:00
Jonas Kvinge
ad169ca5a5 Remove unneeded namespace prefix 2021-08-22 23:29:44 +02:00
Jonas Kvinge
671e636aef Remove some uses of auto 2021-08-22 23:27:25 +02:00
Jonas Kvinge
72d381e9ed Replace qAsConst with C++17 std::as_const 2021-08-22 23:26:53 +02:00
Jonas Kvinge
c076933b52 Use FREEBSD variable 2021-08-22 23:22:15 +02:00
Jonas Kvinge
fdb5c813ad Use actions/checkout@v1.2.0 for FreeBSD too 2021-08-20 22:36:44 +02:00
Strawbs Bot
1bda6633b1 Update translations 2021-08-20 01:02:15 +02:00
Jonas Kvinge
249a5bf3b7 macOS deploy CI improvements 2021-08-19 22:59:38 +02:00
Jonas Kvinge
679b468618 macdeployqt: Fix QLibraryInfo::LibraryExecutablesPath with Qt 5 2021-08-19 20:27:21 +02:00
Jonas Kvinge
cf2a0af3d9 Fix macdeploycheck link directories 2021-08-19 20:24:11 +02:00
Jonas Kvinge
82be53224d Simplify libgpod link directories 2021-08-19 20:23:20 +02:00
Jonas Kvinge
9cc995cb52 Add macdeploycheck 2021-08-19 19:17:43 +02:00
Jonas Kvinge
42d414797a macdeployqt: Formatting 2021-08-19 19:17:43 +02:00
Jonas Kvinge
b071a4df70 macdeployqt: Simplify code in changeInstallName 2021-08-19 19:17:43 +02:00
Jonas Kvinge
46d927291c macdeployqt: Adapt upstream change 2021-08-19 19:17:43 +02:00
Jonas Kvinge
50ab01d9c9 macdeployqt: Remove unused option to specify plugins dir 2021-08-19 19:17:43 +02:00
Jonas Kvinge
dc8fe63acf Add script to copy gstreamer plugins on macOS 2021-08-19 19:17:43 +02:00
Jonas Kvinge
4fc5863888 Add taglib and tagparser link directories 2021-08-19 19:17:43 +02:00
Jonas Kvinge
e2d8149dcf Formatting 2021-08-19 19:17:43 +02:00
Jonas Kvinge
5f156d6bab Only read local files in SongLoader::EffectiveSongLoad 2021-08-19 19:17:43 +02:00
Strawbs Bot
816cdcf4bf Update translations 2021-08-16 01:01:43 +02:00
Jonas Kvinge
75c94ae092 Always look for qpa/qplatformnativeinterface.h 2021-08-14 20:00:27 +02:00
Jonas Kvinge
ecf2c50a26 Use QX11Application with Qt >= 6.2, use QX11Info with Qt 5 2021-08-14 17:06:40 +02:00
Jonas Kvinge
cecb9293f6 Add QRegularExpression::CaseInsensitiveOption 2021-08-13 23:33:41 +02:00
Jonas Kvinge
1ebfa0ad7e Song::kAlbumRemoveDisc is already QRegularExpression 2021-08-13 23:32:54 +02:00
Jonas Kvinge
35c7b57308 Allow fading when a ALSA PCM device is selected 2021-08-13 22:39:34 +02:00
Strawbs Bot
36bfeffbcc Update translations 2021-08-13 01:03:08 +02:00
Jonas Kvinge
e6858719c9 Reduce network access managers 2021-08-12 23:00:42 +02:00
Strawbs Bot
f2d52f83fe Update translations 2021-08-10 01:02:54 +02:00
Jonas Kvinge
f1d3cadb3b Add better logging for file open and write errors 2021-08-09 23:32:26 +02:00
Jonas Kvinge
7d61d8e646 Replace C-style cast with reinterpret_cast 2021-08-09 23:32:09 +02:00
Jonas Kvinge
6ede400f3a CMakeLists.txt formatting 2021-08-07 03:02:36 +02:00
Strawbs Bot
78de45fee2 Update translations 2021-08-07 01:01:40 +02:00
Jonas Kvinge
4559e33331 Update .github/workflows/ccpp.yml 2021-08-01 15:32:51 +02:00
Jonas Kvinge
43875dd3fe Remove Fedora 35 from CI
It's broken.
2021-08-01 08:41:12 +02:00
Jonas Kvinge
fa10384a92 Add FreeBSD to CI 2021-08-01 08:32:50 +02:00
Strawbs Bot
7e144da6b9 Update translations 2021-07-31 01:02:51 +02:00
Jonas Kvinge
54af17e7bf Remove linker hack 2021-07-30 23:01:44 +02:00
Jonas Kvinge
d4a9f5bb2e Replace Iconv_LIBRARY with Iconv_LIBRARIES 2021-07-30 23:01:07 +02:00
Jonas Kvinge
8040813da8 Remove QUIET from find_package for Backtrace and Iconv 2021-07-30 23:00:34 +02:00
Jonas Kvinge
871e40c5c0 Update Changelog 2021-07-30 21:17:53 +02:00
Jonas Kvinge
7ce922b084 Simplify CMake by using macros 2021-07-30 21:17:50 +02:00
Jonas Kvinge
0c9989695a Subsonic: Use 500 albums per request
Fixes #740
2021-07-30 21:17:44 +02:00
Jonas Kvinge
88d7cb3ed5 Add MD5 token authentication for Subsonic 2021-07-30 21:16:41 +02:00
Strawbs Bot
5b7fc80f26 Update translations 2021-07-29 01:15:44 +02:00
Jonas Kvinge
553e8baa8b Fix async song load
Fixes #739
2021-07-28 22:25:33 +02:00
Jonas Kvinge
62a5031ccf Delay pause on resume playback 2021-07-23 21:54:46 +02:00
Jonas Kvinge
4abac65316 Properly disconnect PlaylistManager::AllPlaylistsLoaded on resume 2021-07-23 21:54:21 +02:00
Jonas Kvinge
c6e42e1032 Reset play offset when switching song while paused
Fixes #735
2021-07-23 21:32:12 +02:00
Jonas Kvinge
a353631892 Code tidy 2021-07-23 21:30:08 +02:00
Jonas Kvinge
f144c982e3 Minor CMakeLists.txt cleanup 2021-07-21 17:45:22 +02:00
Jonas Kvinge
16625b1dc7 Move some files from ext to src 2021-07-21 17:29:16 +02:00
Jonas Kvinge
78ccce7d1a Change USE_BUNDLE default 2021-07-21 17:29:16 +02:00
Strawbs Bot
ffba5f7d31 Update translations 2021-07-19 01:01:56 +02:00
Jonas Kvinge
2cb8fa62df Remove duplicate TAGLIB_LIBRARY_DIRS 2021-07-18 16:38:20 +02:00
Jonas Kvinge
853b936cdd Revert "Add sudo"
This reverts commit 4f0fdbab62.
2021-07-18 15:34:07 +02:00
Jonas Kvinge
4f0fdbab62 Add sudo 2021-07-18 15:33:13 +02:00
Jonas Kvinge
190b23b702 Fix build with macports 2021-07-18 15:23:57 +02:00
Strawbs Bot
e0bb79b2c4 Update translations 2021-07-15 01:03:31 +02:00
Jonas Kvinge
2eab763d74 Check that QIODevice::open() is successful, and explicitly call close() 2021-07-14 20:52:57 +02:00
Jonas Kvinge
f64c1dd9e5 Update Changelog 2021-07-14 13:12:20 +02:00
Jonas Kvinge
fab1d94d34 Delay resume playback on startup to make sure Tidal login is refreshed 2021-07-14 13:02:54 +02:00
Jonas Kvinge
facf49b2b7 Spotify: Decrease login delay on startup 2021-07-14 13:02:12 +02:00
Jonas Kvinge
da86b86776 Rename variable 2021-07-14 12:53:28 +02:00
Jonas Kvinge
a79d9d4e77 Move beginInsertRows() 2021-07-14 12:26:48 +02:00
Jonas Kvinge
d9e378211a Fix sorting of radios 2021-07-14 11:22:24 +02:00
Strawbs Bot
99fbbf70de Update translations 2021-07-14 01:03:06 +02:00
Jonas Kvinge
50a616457d Add missing const 2021-07-13 23:25:44 +02:00
Jonas Kvinge
2ad30ebe88 Add missing Qt::CaseInsensitive 2021-07-13 23:25:36 +02:00
Jonas Kvinge
68dbc29f2c Use QString::compare with Qt::CaseInsensitive to reduce allocations 2021-07-13 23:18:12 +02:00
Strawbs Bot
a87863229f Update translations 2021-07-13 01:07:37 +02:00
Jonas Kvinge
f39ffcb997 Simplify if condition 2021-07-12 13:45:51 +02:00
Jonas Kvinge
f20bb388be Rename variable 2021-07-12 13:27:14 +02:00
Jonas Kvinge
fc45015b13 Remove unused variable 2021-07-12 13:26:41 +02:00
Jonas Kvinge
7a5f047f8e Add parent to RadioMimeData 2021-07-12 13:26:20 +02:00
Jonas Kvinge
4251bee3ca Change some uses of QMap to QHash 2021-07-12 08:28:52 +02:00
Jonas Kvinge
f02741284c Tagparser: Fix reading and writing year/originalyear 2021-07-12 07:54:01 +02:00
Jonas Kvinge
fec7419fcc Make const 2021-07-12 07:38:49 +02:00
Jonas Kvinge
e8694531f6 Iterate QMap values 2021-07-12 07:34:20 +02:00
Jonas Kvinge
461491f742 Use multiarg 2021-07-12 07:33:40 +02:00
Jonas Kvinge
af29acf462 tagparser: Save release and record date 2021-07-12 07:32:41 +02:00
Jonas Kvinge
b47f29e87c tagparser: Parse tracks when saving 2021-07-12 07:32:17 +02:00
Jonas Kvinge
fc8ec6d7fa Replace INSTANTIATE_TEST_CASE_P with INSTANTIATE_TEST_SUITE_P 2021-07-12 05:51:01 +02:00
Jonas Kvinge
1d4c736cfa Initialize container to nullptr 2021-07-12 05:51:01 +02:00
Strawbs Bot
600450082a Update translations 2021-07-12 01:18:19 +02:00
Jonas Kvinge
c6da0864f2 Use std::make_shared 2021-07-11 19:57:18 +02:00
Jonas Kvinge
10fc6b4562 Fix tagreader test compile error with tagparser 2021-07-11 19:56:21 +02:00
Jonas Kvinge
e48b7d83a3 Formatting 2021-07-11 09:49:38 +02:00
Jonas Kvinge
a6742d401c Formatting 2021-07-11 07:40:57 +02:00
Jonas Kvinge
87b9a8c4c8 Use RadioPlaylistItem 2021-07-11 07:39:27 +02:00
Jonas Kvinge
134dc55891 Rename RadioView::SetModel 2021-07-11 05:53:10 +02:00
Jonas Kvinge
295cf98e70 Add missing override 2021-07-11 05:30:35 +02:00
Jonas Kvinge
7333155b8c Edit tab order in scrobbler settings 2021-07-11 05:23:37 +02:00
Jonas Kvinge
3960c7d8e6 Add SomaFM and Radio Paradise to scrobbler sources 2021-07-11 05:18:56 +02:00
Jonas Kvinge
b053f99690 Add Song::is_radio() 2021-07-11 05:18:39 +02:00
Jonas Kvinge
5700c3f72e Change GStreamer text 2021-07-11 05:17:45 +02:00
Jonas Kvinge
cdb3729a88 Use Song::SourceFromURL in SongLoader::AddAsRawStream 2021-07-11 05:17:17 +02:00
Jonas Kvinge
c33f2a1d27 Unref bus in SongLoader::LoadRemote() 2021-07-11 04:58:37 +02:00
Jonas Kvinge
9b9a32b053 tagparser: Fix opening file readonly 2021-07-11 04:36:44 +02:00
Jonas Kvinge
95eec369b5 Fix includes 2021-07-11 02:31:15 +02:00
Jonas Kvinge
5d5860683b Add missing includes 2021-07-11 02:29:24 +02:00
Jonas Kvinge
434b31b932 Formatting 2021-07-11 02:27:26 +02:00
Jonas Kvinge
f69e42e520 Use Q_ASSERT 2021-07-11 02:27:03 +02:00
Jonas Kvinge
c5cadfe0c6 Fix memory leak in InternetSearchView::ResultsContextMenuEvent 2021-07-11 01:52:21 +02:00
Jonas Kvinge
f21be30004 Use static QPixmapCache everywhere 2021-07-11 01:43:52 +02:00
Jonas Kvinge
b8b21d53e1 Use static QPixmapCache 2021-07-11 01:32:51 +02:00
Jonas Kvinge
09ec39c87a Remove unused functions from RadioService 2021-07-11 01:20:42 +02:00
Jonas Kvinge
dbf18db3a3 No need to pass Application to RadioBackend 2021-07-11 01:12:50 +02:00
Jonas Kvinge
d8f0ae0980 Remove unused variable 2021-07-11 01:11:25 +02:00
Jonas Kvinge
09bbf1f4d7 Add radios 2021-07-11 01:08:06 +02:00
Strawbs Bot
d07aff9872 Update translations 2021-07-11 01:02:12 +02:00
Jonas Kvinge
4cb3f9d177 Close files in song loader 2021-07-11 00:45:30 +02:00
Jonas Kvinge
c1a815778b Formatting 2021-07-10 21:52:21 +02:00
Jonas Kvinge
5b003b09ac Make CollectionBackendInterface to PlaylistParser optional 2021-07-10 21:52:01 +02:00
Jonas Kvinge
22d0697c77 Use Song::is_stream 2021-07-10 21:50:23 +02:00
Jonas Kvinge
432b0f3e54 songloader: Make sure timeout timer is started from correct thread 2021-07-10 21:48:31 +02:00
Jonas Kvinge
2bee41e90e Fix compile of Utilities::Hmac with Qt 6.3 2021-07-07 23:54:21 +02:00
Jonas Kvinge
2a7312f2b4 Fix tagreader test 2021-07-07 23:46:21 +02:00
Strawbs Bot
f5091339ad Update translations 2021-07-06 01:02:54 +02:00
Jonas Kvinge
3d06d68196 Fix broken context albums 2021-07-04 17:34:42 +02:00
Strawbs Bot
1a643bfa8c Update translations 2021-07-03 01:20:53 +02:00
Jonas Kvinge
cd82b0a669 Fix spelling and typos 2021-07-02 18:45:53 +02:00
Jonas Kvinge
57312e29e2 Build with tagparser on openSUSE 2021-07-02 11:25:02 +02:00
Jonas Kvinge
592df4819b Update Changelog 2021-07-02 02:26:34 +02:00
Jonas Kvinge
f36997c7c5 Close MediaFileInfo 2021-07-02 01:39:21 +02:00
Jonas Kvinge
b1640d3626 Remove tagparser/abstractattachment.h include 2021-07-02 01:38:56 +02:00
Jonas Kvinge
825c62c62b Fix typo in TagReaderTagLib constructor and destructor 2021-07-02 01:26:48 +02:00
Jonas Kvinge
a4b0c6f37d Remove unused QVector include 2021-07-02 01:26:32 +02:00
Jonas Kvinge
239b88aa3b Add support for TagParser as an alternative to TagLib 2021-07-02 01:16:46 +02:00
Jonas Kvinge
88819611f4 Remove TagLib dependency from Song class 2021-07-02 01:16:46 +02:00
Jonas Kvinge
e6ff8368a9 Fix filefilter 2021-07-02 01:16:46 +02:00
Jonas Kvinge
8315f572ea Remove default parameter 2021-07-02 01:16:46 +02:00
Strawbs Bot
89e2070419 Update translations 2021-07-02 01:04:47 +02:00
Jonas Kvinge
b5f4df0912 Refactor subsonic, tidal and qobuz code 2021-07-01 02:02:02 +02:00
Jonas Kvinge
b9f3f80d50 Use std::make_unique / std::make_shared 2021-07-01 02:02:02 +02:00
Jonas Kvinge
0e8ae1a206 Change to std::shared_ptr 2021-07-01 02:02:02 +02:00
Jonas Kvinge
32729174bb Make CollectionModelTest constructor public 2021-07-01 02:02:02 +02:00
Jonas Kvinge
2cf6fe8da7 Fix ConcurrentRunTest 2021-07-01 02:02:02 +02:00
Strawbs Bot
929b031f09 Update translations 2021-07-01 01:03:41 +02:00
Jonas Kvinge
57a36491ee Remove mpris.cpp and mpris.h 2021-06-30 16:26:07 +02:00
Jonas Kvinge
f3a8dde5f0 Use std::make_shared 2021-06-30 16:15:55 +02:00
Jonas Kvinge
ffa2489998 Formatting 2021-06-30 16:15:55 +02:00
Strawbs Bot
6cd7bcdae6 Update translations 2021-06-28 01:07:32 +02:00
Jonas Kvinge
e4f684f411 Change const_iterator to iterator 2021-06-28 00:27:28 +02:00
Jonas Kvinge
fdc9a71f9e Use protected kApiUrl 2021-06-28 00:21:50 +02:00
Jonas Kvinge
bb134ee7ac Rename NeedLogin to set_need_login 2021-06-28 00:21:50 +02:00
Jonas Kvinge
18dc6f3c88 Remove unused variables in InternetCollectionViewContainer 2021-06-28 00:21:50 +02:00
Jonas Kvinge
9327fd3aa1 Formatting 2021-06-28 00:21:50 +02:00
Jonas Kvinge
aa859b9002 Remove dead code 2021-06-28 00:21:50 +02:00
Jonas Kvinge
20a15ecd35 Replace while with for loop 2021-06-28 00:21:50 +02:00
Jonas Kvinge
062c59b321 Rename FindSongs 2021-06-28 00:21:50 +02:00
Jonas Kvinge
9ace66edb7 Rename CollectionFilterWidget::SetCollectionModel to CollectionFilterWidget::Init 2021-06-28 00:21:50 +02:00
Jonas Kvinge
a97d784f26 Rename filter to search_field 2021-06-28 00:21:50 +02:00
Jonas Kvinge
a2e7173983 Rename filter to filter_widget 2021-06-28 00:21:50 +02:00
Jonas Kvinge
0869651dc3 Change parameter order of CollectionBackend::Init 2021-06-28 00:21:50 +02:00
Strawbs Bot
ca42286354 Update translations 2021-06-26 01:07:31 +02:00
Jonas Kvinge
174bfcc597 Use higher resolution images from last.fm API 2021-06-25 22:41:17 +02:00
Jonas Kvinge
244d25ce53 Fix compile with Qt 5 2021-06-25 18:46:45 +02:00
Jonas Kvinge
8287efd51f Remove silencing -Wclazy-qt6-deprecated-api-fixes to workaround clazy bugs 2021-06-25 18:19:37 +02:00
Jonas Kvinge
df31b5d59f Replace Q_ENUMS with Q_ENUM 2021-06-25 18:06:30 +02:00
Jonas Kvinge
53cc47a8b1 Use localhost directly as redirect for scrobbling API 2.0 2021-06-25 16:04:19 +02:00
Jonas Kvinge
55f8294a38 Remove escape characters from playlist filter string
Fixes #728
2021-06-25 12:01:05 +02:00
Strawbs Bot
67a5e3f37e Update translations 2021-06-23 01:16:19 +02:00
Jonas Kvinge
06cd2f3a57 Remove static from IsMacAccessibilityEnabled 2021-06-22 16:17:51 +02:00
Jonas Kvinge
d614a94203 Remove const from SingleApplication methods 2021-06-22 16:15:04 +02:00
Jonas Kvinge
f66aca2164 Remove static from OSDPretty::current_screen 2021-06-22 14:17:24 +02:00
Jonas Kvinge
b071ecb45e Formatting 2021-06-22 14:04:42 +02:00
Jonas Kvinge
83a70fecca Use QWidget::tr() 2021-06-22 14:04:42 +02:00
Jonas Kvinge
dbc7c224c1 Fix setting PID 2021-06-22 14:04:42 +02:00
Jonas Kvinge
7876f9a8a5 Remove unneeded QFont in parameter initialization list 2021-06-22 14:04:42 +02:00
Jonas Kvinge
215057ce6f Remove unneeded get() 2021-06-22 14:04:42 +02:00
Jonas Kvinge
6d8b0b3ab6 Simplify return 2021-06-22 14:04:42 +02:00
Jonas Kvinge
e5c85ddd32 Pass task ID to SetTaskBlocksCollectionScans 2021-06-22 14:04:42 +02:00
Jonas Kvinge
6bf3c34fe5 Fix parameter name mismatch 2021-06-22 14:04:42 +02:00
Jonas Kvinge
584f5e5935 Change bool/int condition 2021-06-22 14:04:42 +02:00
Jonas Kvinge
58a5367015 Make const 2021-06-22 14:04:42 +02:00
Jonas Kvinge
8c2b907ff5 Make static 2021-06-22 14:04:42 +02:00
Strawbs Bot
e3ab0c0192 Update translations 2021-06-22 01:05:22 +02:00
Jonas Kvinge
8572e3eabb Fix volume slider regression 2021-06-21 20:21:40 +02:00
Jonas Kvinge
d4f10c61ef Change lambda capture 2021-06-21 20:10:02 +02:00
Jonas Kvinge
59e11d6caa Remove reference 2021-06-21 20:00:31 +02:00
Jonas Kvinge
67778198de Formatting 2021-06-21 19:55:47 +02:00
Jonas Kvinge
ebfd8cd6f7 Initialize variables and formatting 2021-06-21 19:55:18 +02:00
Jonas Kvinge
83b54f2ae6 Formatting 2021-06-21 19:54:42 +02:00
Jonas Kvinge
7ea60ed178 Update copyrights 2021-06-21 19:54:12 +02:00
Jonas Kvinge
c61d1ce6b4 Use std::any_of 2021-06-21 19:52:37 +02:00
Jonas Kvinge
6a7959547e Change CoverProvider quality return type to float 2021-06-21 18:16:04 +02:00
Jonas Kvinge
af3834672e Remove unneeded break 2021-06-21 18:14:59 +02:00
Jonas Kvinge
f95ff6cb89 Formatting 2021-06-21 16:08:53 +02:00
Jonas Kvinge
e85c13b3fe Change switch to if statement 2021-06-21 15:44:13 +02:00
Jonas Kvinge
ed09627fdb Use std::make_unique 2021-06-21 15:40:44 +02:00
Jonas Kvinge
99ba2c2e8b Make playlist parameter to queue not optional 2021-06-21 15:40:44 +02:00
Jonas Kvinge
589bdf5dcd Use default 2021-06-21 15:40:44 +02:00
Jonas Kvinge
1abbd5ecbc Pass parent to queue 2021-06-21 15:40:44 +02:00
Strawbs Bot
7619e8427a Update translations 2021-06-21 01:17:51 +02:00
Jonas Kvinge
069e24d713 Fix compile 2021-06-21 00:29:38 +02:00
Jonas Kvinge
8e9b45f80f Add override 2021-06-20 23:57:19 +02:00
Jonas Kvinge
2d604a80c9 Change 0 to nullptr 2021-06-20 23:56:56 +02:00
Jonas Kvinge
1f59a1b952 unsigned long int 2021-06-20 23:56:33 +02:00
Jonas Kvinge
6e5ff01db5 Remove unused variables 2021-06-20 23:55:59 +02:00
Jonas Kvinge
50be44adf8 Add namespace comments 2021-06-20 23:55:02 +02:00
Jonas Kvinge
e1bf4347ab Fix uninitialized variables 2021-06-20 23:53:28 +02:00
Jonas Kvinge
3a3305c020 Uppercase literal suffix 2021-06-20 23:49:04 +02:00
Jonas Kvinge
a83f174e1a Remove unused settingsdialog variable 2021-06-20 19:47:38 +02:00
Jonas Kvinge
1295033fae Clang-Tidy and Clazy fixes 2021-06-20 19:04:08 +02:00
Jonas Kvinge
755abec636 Use QProcess::startCommand with Qt 6 2021-06-20 02:48:58 +02:00
Jonas Kvinge
310995fb87 Use static QFileInfo::exists 2021-06-20 02:26:30 +02:00
Jonas Kvinge
bee30e572f Fix incorrect use of return 2021-06-20 02:25:36 +02:00
Jonas Kvinge
cd37a40bab Only link to chromaprint when song fingerprinting or musicbrainz is enabled 2021-06-16 22:54:23 +02:00
Jonas Kvinge
8699790e78 Always call QFutureWatcher::setFuture after connects 2021-06-16 00:30:21 +02:00
Strawbs Bot
d2d3f58a14 Update translations 2021-06-15 01:03:14 +02:00
Jonas Kvinge
081df59ed7 Only call QSystemTrayIcon::isSystemTrayAvailable once
Workaround file descriptor leak

Fixes #724
2021-06-15 00:25:54 +02:00
Strawbs Bot
ec3bcdcb26 Update translations 2021-06-14 01:02:38 +02:00
Jonas Kvinge
8265cf8a6a Use selected plug devices when loading automatic/custom device 2021-06-14 00:18:14 +02:00
Jonas Kvinge
dfb53fb3dd Change regex for CARD and DEV in ALSA devices 2021-06-13 23:58:47 +02:00
Jonas Kvinge
705fc920e5 Fix 2021-06-13 23:44:15 +02:00
Jonas Kvinge
99764741e4 Fix detecting ALSA PCM devices 2021-06-13 23:42:08 +02:00
Jonas Kvinge
35b3bc4522 Handle some chromaprinter error cases 2021-06-13 23:18:22 +02:00
Jonas Kvinge
91eee99bab Increase pen size for OSD Pretty border
Workaround for QTBUG-93476

Fixes #708
2021-06-13 20:56:14 +02:00
Jonas Kvinge
e56defdc50 Formatting 2021-06-13 20:55:37 +02:00
Jonas Kvinge
fbe4d3ce9f Add Subsonic option to turn off HTTP2
Fixes #718
2021-06-13 19:55:45 +02:00
Strawbs Bot
8cf5707575 Update translations 2021-06-13 01:16:37 +02:00
Jonas Kvinge
f786a17014 Formatting 2021-06-12 20:53:23 +02:00
Jonas Kvinge
427b9c1ebc Formatting 2021-06-12 19:22:38 +02:00
Jonas Kvinge
141957e4b5 Remove godaddy certificate 2021-06-12 19:14:47 +02:00
Jonas Kvinge
b911f4f34e Formatting 2021-06-12 16:06:41 +02:00
Jonas Kvinge
0caf76dfae Remove unneeded includes 2021-06-12 16:06:41 +02:00
Jonas Kvinge
00f09168d7 Update Changelog 2021-06-12 16:06:41 +02:00
Strawbs Bot
d636359c10 Update translations 2021-06-11 01:16:45 +02:00
Jonas Kvinge
8fd32aba4f Improve resume playback on startup, re-request stream URL when unpausing
Fixes #270
2021-06-10 23:14:05 +02:00
Strawbs Bot
9db59d5deb Update translations 2021-06-09 01:03:30 +02:00
Jonas Kvinge
d98321c703 Use newer compiler with Qt 6 on openSUSE Leap 2021-06-08 23:43:14 +02:00
Jonas Kvinge
a6424c005f Add Gui to QT_COMPONENTS 2021-06-08 22:49:34 +02:00
Jonas Kvinge
80d127c277 Use fingerprints from database if available when fetching tags from MusicBrainz 2021-06-08 20:59:56 +02:00
Strawbs Bot
3ca0c828c6 Update translations 2021-06-07 01:01:41 +02:00
Strawbs Bot
d3a8e03b2c Add Portuguese (Brazil) 2021-06-06 01:47:57 +02:00
Strawbs Bot
6e75de0dcb Add Chinese 2021-06-06 01:43:49 +02:00
Strawbs Bot
a7bed9741a Add Catalan 2021-06-06 01:42:38 +02:00
Strawbs Bot
f70e52a7a5 Add Japanese 2021-06-06 01:38:22 +02:00
Strawbs Bot
95d7de0654 Add Dutch 2021-06-06 01:36:50 +02:00
Strawbs Bot
3398d25b35 Add Ukrainian 2021-06-06 01:35:40 +02:00
Strawbs Bot
80a4a43680 Add Finnish 2021-06-06 01:34:54 +02:00
Strawbs Bot
01ac61f38c Update translations 2021-06-06 01:23:21 +02:00
Jonas Kvinge
a98be36684 Set DEFAULT '' for all TEXT 2021-06-06 00:36:35 +02:00
Jonas Kvinge
7f085c4012 Check fingerprint for NULL 2021-06-06 00:26:11 +02:00
Jonas Kvinge
5f008d1560 Edit collection settings tab order 2021-06-05 22:34:32 +02:00
Jonas Kvinge
0782b579d5 Update README and Changelog 2021-06-05 22:30:15 +02:00
Jonas Kvinge
f8ed2afef1 Add song fingerprinting and tracking
Fixes #296
2021-06-05 21:56:40 +02:00
Jonas Kvinge
a883508eca Fix marking CUE songs available 2021-06-05 02:50:20 +02:00
Jonas Kvinge
a4a20ec220 Make sure schedule playlist save timer is started from correct thread 2021-06-05 00:07:15 +02:00
Jonas Kvinge
faed63712f Remove Fedora 32 and CentOS 8 from CI 2021-06-04 00:25:11 +02:00
Jonas Kvinge
0032ec5036 Don't log access tokens 2021-06-04 00:15:35 +02:00
Strawbs Bot
9df24a841f Update translations 2021-06-02 01:01:56 +02:00
Jonas Kvinge
d2aa4ff2bd Remove duplicate line 2021-06-01 23:16:04 +02:00
Jonas Kvinge
171db01401 Set default for original year 2021-05-31 19:07:55 +02:00
Strawbs Bot
0112f1e11d Update translations 2021-05-31 01:01:58 +02:00
Jonas Kvinge
8f7b09b58e Update Changelog 2021-05-30 20:57:54 +02:00
Strawbs Bot
479c2b6cec Update translations 2021-05-30 01:25:46 +02:00
Jonas Kvinge
e6f50e6637 Strip mimetype when downloading covers 2021-05-29 23:27:40 +02:00
Jonas Kvinge
548f8bf23e Fix macOS compile 2021-05-29 22:47:53 +02:00
Jonas Kvinge
b6bfe81f9a Use HAVE_X11_GLOBALSHORTCUTS 2021-05-29 22:20:46 +02:00
Jonas Kvinge
ab95bcc028 Change text PulseAudio 2021-05-29 21:52:52 +02:00
Jonas Kvinge
8b7b3df0a3 Fix Qt 5 compile 2021-05-29 20:54:01 +02:00
Jonas Kvinge
69a6416146 Change to uppercase 2021-05-29 20:37:58 +02:00
Jonas Kvinge
1ced4e277b Add global shortcuts support on MATE 2021-05-29 20:35:55 +02:00
Jonas Kvinge
0c5236ebcb Fix crash when no system tray is available 2021-05-29 18:52:47 +02:00
Jonas Kvinge
66c55c5007 Remove remaining HAVE_X11EXTRAS 2021-05-29 18:36:58 +02:00
Jonas Kvinge
7f5a0f1b0c Update RPM spec, man page and debian control 2021-05-29 00:57:25 +02:00
Jonas Kvinge
0c766938f1 Update appdata 2021-05-29 00:49:27 +02:00
Jonas Kvinge
1455e87aef Update appdata 2021-05-29 00:48:23 +02:00
Jonas Kvinge
7c50eef8ad Add Fedora 35 2021-05-28 23:39:30 +02:00
Jonas Kvinge
aa9f972ccf Update Changelog 2021-05-26 17:05:07 +02:00
Strawbs Bot
45df99bb56 Update translations 2021-05-26 13:00:30 +02:00
Strawbs Bot
a2968e57cf Update translations 2021-05-21 01:15:12 +02:00
Jonas Kvinge
67f831beba Refactor systemtrayicon code 2021-05-20 21:40:08 +02:00
Jonas Kvinge
264d47caf4 Change playlist tabbar favorite tooltip 2021-05-20 17:12:28 +02:00
Jonas Kvinge
ef72b3273e Move private Qt GUI include 2021-05-20 17:10:08 +02:00
jonas@jkvinge.net
7d3ade7ae1 Automatically detect Qt version 2021-05-17 00:56:04 +02:00
Strawbs Bot
59897fdf55 Update translations 2021-05-14 01:02:10 +02:00
jonas@jkvinge.net
0b4ea04c91 Update protobuf dll in nsi 2021-05-13 21:06:43 +02:00
jonas@jkvinge.net
094b3b4636 Update Dmg.cmake: Move depends for macdeployqt 2021-05-13 12:18:06 +02:00
jonas@jkvinge.net
0298beeb06 Fix macOS build 2021-05-13 02:17:58 +02:00
Strawbs Bot
971542d6bc Update translations 2021-05-13 01:26:18 +02:00
jonas@jkvinge.net
5bdbc9f40d Add CMake test for Qt sqlite support 2021-05-13 00:18:06 +02:00
jonas@jkvinge.net
efcd35d4a1 Remove use of X11Extras and WinExtras
Modules are deprecated in Qt 6
See: QTBUG-83251
2021-05-12 23:15:04 +02:00
Strawbs Bot
a01541d7ca Update translations 2021-05-12 01:05:21 +02:00
jonas@jkvinge.net
7d96d7c066 Update README 2021-05-11 22:06:09 +02:00
jonas@jkvinge.net
639ea35921 Use wchar version of GetDiskFreeSpaceEx on Windows Qt 5 2021-05-11 20:32:28 +02:00
jonas@jkvinge.net
dee1905e16 Make the default tabbbar background color lighter
Fixes #711
2021-05-11 20:10:31 +02:00
jonas@jkvinge.net
1803705749 Add option to turn off playlist alternating row colors 2021-05-11 19:40:47 +02:00
jonas@jkvinge.net
5d96ee5492 Add ALSA PCM devices and option to set channels
Fixes #262
2021-05-11 19:14:00 +02:00
jonas@jkvinge.net
4a0a1a32a4 Rename ENABLE_CHROMAPRINT to ENABLE_MUSICBRAINZ 2021-05-10 21:17:50 +02:00
Strawbs Bot
c2108a35d0 Update translations 2021-05-09 01:01:51 +02:00
jonas@jkvinge.net
31ecdbae18 Update protobuf dll in nsi 2021-05-08 01:56:42 +02:00
jonas@jkvinge.net
e9c733e78f Turn off -Werror for Windows build in CI 2021-05-08 01:56:42 +02:00
Strawbs Bot
2320c5e04c Update translations 2021-05-08 01:01:55 +02:00
Jonas Kvinge
fb7b3b0295 Revert "Shuffle all songs instead of from the current to the end"
This reverts commit 316a3d51ee.
2021-05-04 23:16:18 +02:00
Jonas Kvinge
316a3d51ee Shuffle all songs instead of from the current to the end
Fixes #707
2021-05-04 22:48:18 +02:00
Jonas Kvinge
240dcf2e5c Improve device icon loading 2021-05-04 21:55:19 +02:00
Strawbs Bot
5fbdbffa23 Update translations 2021-05-04 01:04:38 +02:00
Jonas Kvinge
932c8b65fb Add Ubuntu Hirsute to CI 2021-05-03 23:33:59 +02:00
Strawbs Bot
e18e174947 Update translations 2021-05-02 01:02:16 +02:00
Jonas Kvinge
f2c7df3a3b Build on macOS with libgpod 2021-05-01 22:12:13 +02:00
Jonas Kvinge
2b15dae806 Strip misc from song title when sending now playing 2021-05-01 18:19:08 +02:00
Jonas Kvinge
2625d72818 Don't strip off "Live" from song title 2021-05-01 18:03:26 +02:00
Strawbs Bot
a8b4d72421 Update translations 2021-04-27 01:06:58 +02:00
Jonas Kvinge
88562890ae Use int in MainWindow::UpdateTrackSliderPosition 2021-04-26 23:36:59 +02:00
Jonas Kvinge
86c267eb89 Seconds is already qint64 2021-04-26 23:13:37 +02:00
Jonas Kvinge
3d1928cca9 Fix typo 2021-04-26 23:12:59 +02:00
Jonas Kvinge
8c64d3b55c Do most item reloading in the background, schedule playlist saving 2021-04-26 22:57:08 +02:00
Jonas Kvinge
41b238e87b Formatting 2021-04-26 22:56:14 +02:00
Jonas Kvinge
da83025fb0 Update temporary metadata when reloading song
Possible fix for #697
2021-04-26 20:33:57 +02:00
Jonas Kvinge
84d3b190c8 Update Changelog 2021-04-25 21:20:43 +02:00
Strawbs Bot
272fc5a72d Update translations 2021-04-25 01:04:39 +02:00
Strawbs Bot
0f709059e3 Update translations 2021-04-24 01:02:19 +02:00
Jonas Kvinge
0f91bb28a9 Remove CircleCI 2021-04-23 21:09:11 +02:00
Jonas Kvinge
63d75a8e17 Build common DMG for all macOS versions 2021-04-23 21:08:23 +02:00
Strawbs Bot
be95d8409b Update translations 2021-04-23 01:02:57 +02:00
Jonas Kvinge
9d3000498b Add setting for setting reply gain fallback gain 2021-04-22 21:55:26 +02:00
Jonas Kvinge
48f8468e65 Change direction to out for signals 2021-04-22 21:54:45 +02:00
Jonas Kvinge
9b60559855 Use QFile::encodeName() in Song::InitFromFilePartial
Fixes #693
2021-04-21 20:11:37 +02:00
Jonas Kvinge
e97acf7938 Fix errors in D-Bus XMLs 2021-04-21 16:05:23 +02:00
Jonas Kvinge
1cfb92e75c Remove quotation mark from org.gnome.SettingsDaemon.MediaKeys.xml 2021-04-21 16:00:34 +02:00
Strawbs Bot
4c617ccd49 Update translations 2021-04-19 01:01:46 +02:00
Jonas Kvinge
494517e767 Turn back git revision 2021-04-18 22:07:43 +02:00
Jonas Kvinge
655c872ac9 Release 0.9.3 2021-04-18 18:44:43 +02:00
Strawbs Bot
cb0f2b48fd Update translations 2021-04-18 01:03:10 +02:00
Strawbs Bot
20a84bdefc Update translations 2021-04-17 01:02:28 +02:00
Jonas Kvinge
83ad7d4935 Set exit before quit is called 2021-04-16 18:34:38 +02:00
Jonas Kvinge
ae2ca175d3 Fix remembering hidden state
Prevent SetHiddenInTray() or Exit() from being called again after
qApp->quit() in MainWindow::closeEvent()
2021-04-16 18:27:24 +02:00
Jonas Kvinge
c855108b94 Update Changelog 2021-04-15 21:06:19 +02:00
Strawbs Bot
5e80b694c2 Update translations 2021-04-15 01:02:00 +02:00
Jonas Kvinge
99640aa2ad Add Windows Qt 6 build to CI 2021-04-14 21:11:01 +02:00
Jonas Kvinge
4c0f7c3dd4 Add commandline option to resize window 2021-04-14 19:50:38 +02:00
Jonas Kvinge
2a8490ef31 Use modern user interface and locked list also for uninstalling 2021-04-14 18:07:23 +02:00
Jonas Kvinge
43dc694963 Include gst-discoverer-1.0.exe in windows setup 2021-04-14 16:56:30 +02:00
Strawbs Bot
e03ee00554 Update translations 2021-04-14 01:02:25 +02:00
Jonas Kvinge
01a07ec0e8 Enable stream discoverer on all systems
Fixes #689
2021-04-14 00:16:37 +02:00
Jonas Kvinge
74b7738a9d Create GLib main event loop on non-glib systems 2021-04-14 00:16:07 +02:00
Jonas Kvinge
10aaaebc38 Enable stream discoverer on all Unix except macOS 2021-04-13 22:11:44 +02:00
Jonas Kvinge
a8d072150d Remove avresample-4.dll from nsi 2021-04-13 19:11:48 +02:00
Jonas Kvinge
7877bb7956 Add setting for OSD Pretty fading 2021-04-13 17:27:10 +02:00
Strawbs Bot
bd31e3df89 Update translations 2021-04-13 01:01:55 +02:00
Jonas Kvinge
531e97b499 Only use QPlatformNativeInterface on X11 2021-04-12 19:40:34 +02:00
Jonas Kvinge
43876e967a Enable Qt6WinExtras.dll in nsi 2021-04-12 15:41:28 +02:00
Jonas Kvinge
efaf917939 Add pragma unused 2021-04-11 19:16:07 +02:00
Jonas Kvinge
7d3ceb7d8c Fix Tidal authentication on macOS 2021-04-11 18:33:35 +02:00
Jonas Kvinge
201ac47943 Add new screenshot 2021-04-11 09:11:24 +02:00
Jonas Kvinge
5a70285c10 Update Changelog 2021-04-11 03:24:21 +02:00
Jonas Kvinge
e13c27d32c Allow editing of playlist metadata for streams 2021-04-11 02:01:53 +02:00
Strawbs Bot
9c9b673eeb Update translations 2021-04-11 01:13:36 +02:00
Jonas Kvinge
7323fe0000 Fix queued item painting 2021-04-11 01:03:02 +02:00
Jonas Kvinge
460d045cbe Fix rescan when collection directory is removed and added 2021-04-11 01:01:57 +02:00
Jonas Kvinge
4983c1cfc9 FIx tidal search field not showing on macOS 2021-04-10 09:56:59 +02:00
Jonas Kvinge
c7bc9d471a Allow keep running option on macOS too 2021-04-10 08:22:08 +02:00
Jonas Kvinge
a36b91ffe8 Cast to quint32 2021-04-10 08:21:58 +02:00
Jonas Kvinge
88da0db0f7 Update copyrights 2021-04-10 07:32:38 +02:00
Jonas Kvinge
816c2b0ca8 Use qint32 for unique worker number 2021-04-10 07:20:36 +02:00
Jonas Kvinge
d6ff68339b Use qint64 for unique worker number 2021-04-10 07:02:08 +02:00
Jonas Kvinge
fdf483c98b Update README.md 2021-04-10 06:36:18 +02:00
Jonas Kvinge
eb020c1cb8 Register tidal URL scheme on macOS 2021-04-10 06:04:31 +02:00
Jonas Kvinge
6fa331ad06 Make macdeployqt work with Qt 5 too 2021-04-10 03:28:38 +02:00
Jonas Kvinge
5a58ac2845 Make CollectionQuery subclass QSqlQuery, don't copy QSqlQuery 2021-04-10 03:21:05 +02:00
Strawbs Bot
0c4edc4d17 Update translations 2021-04-09 01:02:09 +02:00
Jonas Kvinge
b5cea4c27e Make enabling FTS3 non-fatal 2021-04-08 22:33:43 +02:00
Jonas Kvinge
b7de5d6df3 Only enable FTS3 when schema needs upgrading 2021-04-08 22:13:21 +02:00
Strawbs Bot
d7310ba307 Update translations 2021-04-07 01:03:08 +02:00
Jonas Kvinge
cabb94b856 Move taglib include dir to system include dirs 2021-04-05 22:25:52 +02:00
Jonas Kvinge
82b649f67d Move taglib include dir to system include dirs 2021-04-05 22:22:25 +02:00
Strawbs Bot
8753782a0c Update translations 2021-04-04 01:02:57 +02:00
Strawbs Bot
566a139edc Update translations 2021-04-02 01:03:04 +02:00
Jonas Kvinge
39dda0f16b Check that rating position is to the right or left of the rectangle.
Adapted from Clementine.

Author: Jim Broadus
2021-04-02 00:47:53 +02:00
Jonas Kvinge
bddb371e31 Fix open in file browser when inode/directory mimetype is set to thunar
Fixes #677
2021-04-01 18:31:19 +02:00
Jonas Kvinge
128223a28a Add setting for configuring the color for the currently playing song
Fixes #676
2021-04-01 02:18:15 +02:00
Jonas Kvinge
45b9d0553f Update FUNDING.yml 2021-04-01 00:27:54 +02:00
Jonas Kvinge
a87f0e0475 Also strip variables with uppercase letters in OpenInFileManager() 2021-03-31 23:14:16 +02:00
Jonas Kvinge
beacea0482 Improve macdeployqt patch 2021-03-31 01:00:51 +02:00
Jonas Kvinge
85b59e79d3 Update ccpp.yml 2021-03-30 20:41:13 +02:00
Jonas Kvinge
9a947c5544 Use LockedList nsis plugin 2021-03-30 20:35:48 +02:00
Strawbs Bot
e4cebf4cbe Update translations 2021-03-30 01:03:27 +02:00
Jonas Kvinge
f63e05b7d4 Use QString::SkipEmptyParts for older Qt versions 2021-03-29 22:45:01 +02:00
Jonas Kvinge
84b7fa02bb Strip all variables from command in OpenInFileManager
Fixes #674
2021-03-29 22:37:55 +02:00
Strawbs Bot
36e597a045 Update translations 2021-03-29 01:28:10 +02:00
Strawbs Bot
f760b3f271 Update translations 2021-03-27 01:12:06 +01:00
Jonas Kvinge
d4c8fa6a24 Use const QJsonValueRef 2021-03-26 23:55:55 +01:00
Jonas Kvinge
c6604734c9 Remove using std::placeholders 2021-03-26 23:33:56 +01:00
Jonas Kvinge
91ab8e22b7 Use QJsonValueRef 2021-03-26 22:10:43 +01:00
Jonas Kvinge
14fb647647 Fix uninitialized variables 2021-03-26 21:30:13 +01:00
Jonas Kvinge
8a39a43ad5 Make sure QCache::insert is successful
Otherwise object is deleted by QCache::insert
2021-03-26 21:07:47 +01:00
Jonas Kvinge
a3d23a6f57 Turn back git revision 2021-03-26 20:35:18 +01:00
Jonas Kvinge
ae5da12afb Release 0.9.2 2021-03-25 23:24:16 +01:00
Jonas Kvinge
a3042b8f79 Update Changelog 2021-03-25 23:23:35 +01:00
Jonas Kvinge
29cbfe7c1a Change last played to qint64 2021-03-25 23:23:13 +01:00
Strawbs Bot
1ddc3292cc Update translations 2021-03-25 01:03:59 +01:00
Jonas Kvinge
658e1d122e Remove set current to all artists when opening cover manager
Caused sluggish opening
2021-03-24 22:30:58 +01:00
Jonas Kvinge
d936a080db Check for empty image 2021-03-24 22:30:37 +01:00
Jonas Kvinge
2a92af1e09 Change static_cast 2021-03-24 22:29:56 +01:00
Jonas Kvinge
9cde537066 Fix moodbar 2021-03-23 01:44:00 +01:00
Strawbs Bot
ffc5446914 Update translations 2021-03-22 01:23:51 +01:00
Jonas Kvinge
5f70b32795 Remove unused using std::shared_ptr 2021-03-21 20:23:42 +01:00
Jonas Kvinge
6b6117653a Allow audio formats unsupported by taglib to be added
Fixes #669
2021-03-21 19:19:35 +01:00
Jonas Kvinge
59bffed47f Use static_cast 2021-03-21 18:53:02 +01:00
Jonas Kvinge
f91a679cdf Add override 2021-03-21 18:40:33 +01:00
Jonas Kvinge
66b8d27d66 Change to QList 2021-03-21 06:26:48 +01:00
Jonas Kvinge
1219f504ea Update CI 2021-03-21 06:09:24 +01:00
Jonas Kvinge
ee5a191e39 Change to qint64 2021-03-21 06:07:11 +01:00
Jonas Kvinge
f577aa8d4f Update Changelog 2021-03-21 04:55:59 +01:00
Jonas Kvinge
2436c87372 Use variable 2021-03-21 04:55:00 +01:00
Jonas Kvinge
e90b5e63e5 Move variable 2021-03-21 04:49:22 +01:00
Jonas Kvinge
78588d8cdf Fix various clazy warnings 2021-03-21 04:47:11 +01:00
Jonas Kvinge
20c1c1d4be Remove unused variables 2021-03-21 04:43:55 +01:00
Jonas Kvinge
329dfb21b9 These don't need to be slots 2021-03-21 04:38:47 +01:00
Jonas Kvinge
02c30211a7 Call AbstractMessageHandler::AbortAll 2021-03-21 04:37:30 +01:00
Jonas Kvinge
645da2713d Remove emit from slots 2021-03-21 04:36:54 +01:00
Jonas Kvinge
20c5a79efa Fix playlist tabbar close and save 2021-03-21 04:28:22 +01:00
Jonas Kvinge
b224aeb0d8 Use 4arg connects for networkreplies 2021-03-21 00:37:17 +01:00
Jonas Kvinge
73eebd6162 Set album cover filename by pattern as default when saving cover to album directory 2021-03-20 23:13:54 +01:00
Strawbs Bot
99a1851f4d Update translations 2021-03-20 23:02:12 +01:00
Jonas Kvinge
d9d89d0927 Update Changelog 2021-03-20 21:21:36 +01:00
Jonas Kvinge
54f2aa5f77 Update copyrights 2021-03-20 21:14:47 +01:00
Jonas Kvinge
d022e9dd00 Close the file 2021-03-20 19:23:33 +01:00
Jonas Kvinge
17cf8ec1c6 Move declaration 2021-03-20 19:11:05 +01:00
Jonas Kvinge
c4a6d81cda Fix copying album covers to iPod
Cover file was deleted too soon.
File needs to be accessible until itdb_write is called.

Fixes #663
2021-03-20 19:00:42 +01:00
Jonas Kvinge
66ed485803 Check for existence of directory 2021-03-20 18:58:38 +01:00
Jonas Kvinge
6de585d1c8 Make sure process files isn't again called after finishing 2021-03-20 15:22:21 +01:00
Jonas Kvinge
9498638988 Make macdeployqt use environment variables for gstreamer 2021-03-20 14:19:49 +01:00
Jonas Kvinge
87dad82210 Update README.md 2021-03-19 00:35:13 +01:00
Jonas Kvinge
e37aec16ac Enable tumbleweed 2021-03-19 00:25:33 +01:00
Jonas Kvinge
6fb48af598 Fix macOS deployment 2021-03-18 23:08:50 +01:00
Jonas Kvinge
8193be36e5 Use a modified version of macdeployqt 2021-03-17 21:12:12 +01:00
Jonas Kvinge
a7df2bc4fb Use original file when loading cover from file in album cover manager 2021-03-16 17:18:11 +01:00
Jonas Kvinge
5eda028af3 Minor code improvements to album cover loader 2021-03-16 17:17:22 +01:00
Jonas Kvinge
f77475dbfe Specifically set get image 2021-03-16 17:16:40 +01:00
Jonas Kvinge
96c1a35c8e Use macdeploy.py for Qt plugins 2021-03-16 17:13:33 +01:00
Jonas Kvinge
0ef26be03f Remove DEBUG define 2021-03-16 17:12:44 +01:00
Jonas Kvinge
f5bb15f72e Fix QSearchField on macOS 2021-03-15 22:38:06 +01:00
Jonas Kvinge
d84aebd8f4 Format code 2021-03-15 22:37:49 +01:00
Jonas Kvinge
7d8d9f4c4d Format code 2021-03-14 23:20:16 +01:00
Jonas Kvinge
61b201810d Fix marking songs available 2021-03-14 23:08:05 +01:00
Jonas Kvinge
c75db8dc60 Turn back git revision 2021-03-14 02:32:42 +01:00
Jonas Kvinge
e0bf4091dd Update Changelog 2021-03-13 16:17:06 +01:00
Jonas Kvinge
1d89c46638 Release 0.9.1 2021-03-13 16:01:02 +01:00
Jonas Kvinge
88797424f1 Ignore empty lyrics from musixmatch 2021-03-13 15:58:34 +01:00
Jonas Kvinge
e0c57e77a9 Disable failed tagreader checksum test 2021-03-13 15:28:51 +01:00
Jonas Kvinge
e15a99f39f Remove Test from QT_LIBRARIES 2021-03-13 15:26:49 +01:00
Jonas Kvinge
9723c3606a Remove BUILD_TESTS cmake option 2021-03-13 15:18:38 +01:00
Jonas Kvinge
d2385d9287 Update Changelog 2021-03-13 15:18:09 +01:00
Jonas Kvinge
2695169514 Add type to metadata bundle to avoid updating previous song when it shouldn't 2021-03-13 03:14:30 +01:00
Jonas Kvinge
efcdfdf612 Remove unused include for macOS 2021-03-13 02:00:38 +01:00
Jonas Kvinge
f77e7334c5 Set album cover loader options in edit tag dialog 2021-03-13 01:52:37 +01:00
Jonas Kvinge
9079a7988c Turn off frame in edit tag dialog 2021-03-13 01:43:30 +01:00
Jonas Kvinge
5256d795b1 Fix tagreader process not starting on Windows in release build 2021-03-09 22:45:15 +01:00
Strawbs Bot
24a765814a Update translations 2021-03-08 01:12:33 +01:00
Jonas Kvinge
ef18a00362 Use mouse event variable 2021-03-07 23:26:08 +01:00
Jonas Kvinge
1823786344 Show fullsize cover on doubleclick in edit tag dialog 2021-03-07 23:23:58 +01:00
Jonas Kvinge
548a1f30ca Support saving by filename in SaveAndSetCover 2021-03-07 23:03:02 +01:00
Jonas Kvinge
e63859442a Ignore drop event in album cover manager
Fixes strange case where albums are duplicated by drag/drop.
2021-03-07 22:59:08 +01:00
Jonas Kvinge
69032db3c3 Remove unused function 2021-03-07 07:20:29 +01:00
Jonas Kvinge
d3e5b1b4e0 Move comment 2021-03-07 07:05:02 +01:00
Jonas Kvinge
e2cd68e3e8 Fix saving existing cover from file embedded for multiple albums 2021-03-07 07:01:22 +01:00
Jonas Kvinge
3e6029d33c Clear art automatic when embedded cover is deleted 2021-03-07 05:43:56 +01:00
Jonas Kvinge
89f1f8e6dc Check for empty art automatic 2021-03-07 05:41:49 +01:00
Jonas Kvinge
cff25374b5 Fix collection update for art_manual 2021-03-07 05:37:07 +01:00
Jonas Kvinge
04bbff338d Fix deleting multiple covers in album cover manager 2021-03-07 03:43:49 +01:00
Jonas Kvinge
bbcd6a3261 Fix saving empty cleared cover 2021-03-07 03:42:11 +01:00
Jonas Kvinge
e587e8cfc8 Use original file when loading cover from file in tag editor 2021-03-07 02:36:50 +01:00
Jonas Kvinge
869f8cf380 Enable cover actions based on current cover 2021-03-07 02:34:17 +01:00
Jonas Kvinge
1ff6ba9480 Only enable album cover options for collection songs 2021-03-07 01:49:38 +01:00
Jonas Kvinge
5807bee23b Load album cover controller settings when album cover manager is opened 2021-03-07 00:54:20 +01:00
Jonas Kvinge
b5bafbf23a Lowercase file extension 2021-03-07 00:53:33 +01:00
Jonas Kvinge
3954ccab8a Revert "Update libsoup in nsi"
This reverts commit 57207a72ea.
2021-03-05 00:02:37 +01:00
Strawbs Bot
24eb9d9e14 Update translations 2021-03-04 23:01:42 +01:00
Jonas Kvinge
57207a72ea Update libsoup in nsi 2021-03-04 22:04:16 +01:00
Jonas Kvinge
8771911931 Remove brew update and upgrade step 2021-03-04 01:35:36 +01:00
Jonas Kvinge
7b2411eec5 Change to info log 2021-03-04 01:14:06 +01:00
Jonas Kvinge
49a0b0bff2 Show info logging when debugging is off 2021-03-04 01:06:02 +01:00
Jonas Kvinge
3cea7ee1b9 Update Changelog 2021-03-03 22:18:04 +01:00
Jonas Kvinge
d366c1ac64 Update README.md 2021-03-03 22:02:41 +01:00
Jonas Kvinge
315858e410 Add sudo 2021-03-03 17:29:37 +01:00
Jonas Kvinge
a53965b824 Create symbolic link to make macdeployqt find plugins 2021-03-03 02:04:19 +01:00
Jonas Kvinge
cf973c3f25 Add REQUIRED to find_program for macdeployqt and createdmg 2021-03-03 02:03:52 +01:00
Jonas Kvinge
db09144624 Switch macOS builds to Qt 6 2021-03-03 00:43:47 +01:00
Jonas Kvinge
32b94555c3 Remove 3rdparty taglib 2021-02-27 16:55:41 +01:00
Jonas Kvinge
f507fef40d Use Leap 15.2 for Qt 6 build 2021-02-27 15:23:28 +01:00
Jonas Kvinge
d5caff58c7 Fix cover delete in edit tag dialog 2021-02-27 02:12:26 +01:00
Jonas Kvinge
ab4c725217 Fix embedded album cover default in edit tag dialog 2021-02-27 01:32:45 +01:00
Jonas Kvinge
901ba9cf13 Add QMap include 2021-02-27 01:02:37 +01:00
Jonas Kvinge
19b1bc6b3e Fix saving cover for multiple albums 2021-02-27 00:58:43 +01:00
Jonas Kvinge
c623ea7c2a Use reference 2021-02-26 23:10:36 +01:00
Jonas Kvinge
72e61106a9 Remove unused include 2021-02-26 22:15:04 +01:00
Jonas Kvinge
e15e7f0942 Fix compile with Qt 5
Forgot to test the changes from the last commit with Qt 5
2021-02-26 22:01:45 +01:00
Jonas Kvinge
133f094d72 Add support for saving embedded album covers
Fixes #286
2021-02-26 21:03:51 +01:00
Jonas Kvinge
e4c89c1aed Update ccpp.yml 2021-02-23 16:04:13 +01:00
Jonas Kvinge
193cf1c750 Rename protobuf namespace
Fixes #654
2021-02-20 17:06:55 +01:00
Jonas Kvinge
75c2a630f6 Bump protobuf version in NSI 2021-02-20 16:26:23 +01:00
Jonas Kvinge
3a7cecac31 Change message reply ID's back to int32
Fixes #653
2021-02-20 16:16:17 +01:00
Jonas Kvinge
0ab214fd5d Add methods to tagreader for saving embedded art 2021-02-16 22:50:35 +01:00
Jonas Kvinge
eb603e942f Move semaphore release 2021-02-16 18:53:51 +01:00
Jonas Kvinge
b1e1c704b1 Use QTimer::singleShot() to delay signal from MessageReply 2021-02-16 18:50:43 +01:00
Jonas Kvinge
f908336ec6 Add back old MPEG::File::File constructor
The unit tests still uses it.

Fixes #650
2021-02-15 21:47:50 +01:00
Strawbsbot
3ff97e43e1 Update translations 2021-02-15 10:15:23 +01:00
Jonas Kvinge
622434b457 Remove Fedora 34 from CI 2021-02-14 22:28:42 +01:00
Jonas Kvinge
877319a8e5 taglib: Change while to for loop in TableOfContentsFrame 2021-02-13 00:41:49 +01:00
Jonas Kvinge
295db43bca taglib: Remove unused methods 2021-02-13 00:31:54 +01:00
Jonas Kvinge
4285f43316 taglib: Make Frame::asProperties virtual 2021-02-13 00:15:51 +01:00
Jonas Kvinge
29e8316527 Add missing static_cast 2021-02-11 22:33:54 +01:00
Jonas Kvinge
2b988b8ab1 Handle more gstreamer errors as non-fatal
Adds GST_RESOURCE_ERROR_OPEN_READ and GST_STREAM_ERROR_TYPE_NOT_FOUND

Fixes #648
2021-02-11 22:23:54 +01:00
Jonas Kvinge
0abf991b05 Add back Big Sur to CI 2021-02-10 22:20:42 +01:00
Jonas Kvinge
7fc5b70553 Remove const reference from signals 2021-02-10 18:32:10 +01:00
Jonas Kvinge
b3681002a7 Change int to qint64 2021-02-10 18:27:40 +01:00
Strawbsbot
1f9af7a1e4 Update translations 2021-02-06 03:54:07 +01:00
Jonas Kvinge
9ed184edbf Simplify code 2021-02-06 00:32:01 +01:00
Jonas Kvinge
89572b07fb Remove default argument 2021-02-06 00:30:40 +01:00
Jonas Kvinge
443578e0ee Merge pull request #644 from gavinhoward/master
Fix playlist saving
2021-02-04 01:20:03 +01:00
Gavin Howard
0f96daec9a Fix playlist saving
The fix came from a suggestion by Jonas; I just tested it.
2021-02-03 16:38:24 -07:00
Strawbs Bot
59412c54de Update translations 2021-02-03 01:15:47 +01:00
Jonas Kvinge
16ca55e4ec Update Changelog 2021-02-02 21:41:31 +01:00
Jonas Kvinge
03959a68d5 Formatting 2021-02-02 21:08:58 +01:00
Jonas Kvinge
59b48ceb4a Use std::make_shared 2021-02-02 21:08:12 +01:00
Strawbs Bot
d499bfab8a Update translations 2021-02-02 01:02:36 +01:00
Strawbs Bot
b7b2b5089f Update translations 2021-02-01 01:43:46 +01:00
Jonas Kvinge
fcb417af17 Fix 'Except between tracks on the same album' backend fade option
Fixes #642
2021-01-30 23:16:19 +01:00
Jonas Kvinge
28c130a910 Add this as context to lambda connection 2021-01-30 22:42:21 +01:00
Jonas Kvinge
57a5eabd8f Use this and watcher instead of = 2021-01-30 22:41:57 +01:00
Jonas Kvinge
88874f0dcd Remove NewClosure 2021-01-30 21:53:53 +01:00
Jonas Kvinge
98d5e27a8c Remove use of NewClosure for playback resume 2021-01-30 21:52:17 +01:00
Jonas Kvinge
576956fa1d Use QTimer::singleShot directly for database backup 2021-01-30 21:51:32 +01:00
Jonas Kvinge
be051a4bb1 Use timers for submitting scrobbles 2021-01-30 21:50:28 +01:00
Jonas Kvinge
cc6c7430d4 Use a QTimer for writing scrobbler cache 2021-01-30 21:48:45 +01:00
Jonas Kvinge
477ee14b6d Remove unused waitforsignal class 2021-01-30 16:17:11 +01:00
Jonas Kvinge
2539b2333c Use new connect syntax in global shortcuts manager 2021-01-30 14:28:03 +01:00
Jonas Kvinge
ebf6ba9ca1 Use new connect syntax in DoAfter() 2021-01-30 14:27:25 +01:00
Jonas Kvinge
60528525e0 Use QObject::connect() everywhere for consistency 2021-01-29 18:53:20 +01:00
Jonas Kvinge
cb5a7f8c9d Replace NewClosure with lamdas 2021-01-29 18:47:50 +01:00
Jonas Kvinge
fd9c6d460a Fix lamda connect for audio CD tracks load finished 2021-01-29 18:45:09 +01:00
Jonas Kvinge
fa5b135439 Always add libdl.dll to Windows installer 2021-01-29 17:11:13 +01:00
Jonas Kvinge
9f5249e5b8 Make playlist moodbar column respect moodbar enabled setting 2021-01-28 21:43:06 +01:00
Jonas Kvinge
819800d3a4 Revert some lambda connects back to NewClosure 2021-01-28 21:22:50 +01:00
Jonas Kvinge
8ac5b55b3a Revert "Add macOS bigsur"
This reverts commit abe1079328.
2021-01-28 20:55:00 +01:00
Jonas Kvinge
abe1079328 Add macOS bigsur 2021-01-28 20:54:02 +01:00
Jonas Kvinge
775c62fbb4 Remove macOS bigsur builder as the CI is currently broken 2021-01-28 20:51:40 +01:00
Jonas Kvinge
daff2c1f84 Add option to append explicit to album titles for Tidal 2021-01-28 19:55:28 +01:00
Jonas Kvinge
1ea8b064cc Read/save vorbis comment grouping tag
Fixes #639
2021-01-28 18:11:49 +01:00
Strawbs Bot
a0e030a6ee Update translations 2021-01-28 01:02:00 +01:00
Strawbs Bot
690eb343ea Update translations 2021-01-27 01:22:31 +01:00
Jonas Kvinge
ad5e476920 Fix compile without moodbar
Fixes #638
2021-01-26 22:34:31 +01:00
Jonas Kvinge
2a92ce867a Rename global shortcuts classes 2021-01-26 20:48:51 +01:00
Jonas Kvinge
bf7c8df353 Connection syntax migration (#637) 2021-01-26 16:48:04 +01:00
Strawbs Bot
d57f6303f4 Update translations 2021-01-26 01:02:23 +01:00
Jonas Kvinge
9c6c26f424 Delete TagCompletionModel 2021-01-26 00:40:06 +01:00
Jonas Kvinge
00a98f6e30 Update Changelog 2021-01-25 23:39:18 +01:00
Jonas Kvinge
50d83dc070 Fix memory leak when moodbar is disabled
Only call MoodbarLoader::Load when moodbar is enabled.
2021-01-25 22:35:56 +01:00
Jonas Kvinge
010a0cc2a7 Fix playlist filter with Qt 6 2021-01-20 20:18:29 +01:00
Jonas Kvinge
71728bb3fe Remove snap 2021-01-20 20:07:21 +01:00
Strawbs Bot
fc1537fde8 Update translations 2021-01-17 01:02:48 +01:00
Jonas Kvinge
6e40f639b7 Turn off undo/redo stack for QTextDocument in playwidget details 2021-01-16 03:12:34 +01:00
Jonas Kvinge
21c5a97d15 Fix total album count 2021-01-15 21:17:32 +01:00
Jonas Kvinge
8a4d78ae4d Update Changelog 2021-01-14 21:33:18 +01:00
Strawbs Bot
001964f2f4 Update translations 2021-01-13 01:10:30 +01:00
Jonas Kvinge
a6a29d5c5a Set limits for collection pixmap cache based on size unit 2021-01-12 20:36:10 +01:00
Jonas Kvinge
706308cefd Update debian/copyright 2021-01-11 16:50:39 +01:00
Jonas Kvinge
72b194cd7e Rename network to networkaccessmanager 2021-01-11 16:48:46 +01:00
Jonas Kvinge
b85819ed9d Decode HTML entities in lyrics 2021-01-11 16:05:39 +01:00
Strawbs Bot
c5cd648b5d Update translations 2021-01-11 01:02:20 +01:00
Strawbs Bot
3743408543 Update translations 2021-01-10 01:05:51 +01:00
Jonas Kvinge
fd251c6e61 Use helper function for collection model container keys 2021-01-09 21:03:35 +01:00
Strawbs Bot
b7ab6c5c3e Update translations 2021-01-09 01:02:46 +01:00
Jonas Kvinge
5659fd5839 Use mimetype instead of description from stream discoverer when available 2021-01-08 22:38:37 +01:00
Jonas Kvinge
4dcd3e95df Append album ID to collection model container nodes 2021-01-08 22:35:07 +01:00
Mikalai Daronin
57709413e1 Add SPMediaKeyTap back (#621) 2021-01-06 14:46:21 +01:00
Jonas Kvinge
fb634bc2d4 Let watcher handle update of collection songs when organizing
Fixes bug duplicating songs in the db when moving songs across collection id's.

Fixes #623
2021-01-05 22:14:18 +01:00
Edgar Salgado
18a67e1f20 Last.fm last played date import: change date if it is newer than the … (#625)
* Last.fm last played date import: change date if it is newer than the one in database

* Last.fm lastplayed: make it more consistent with the code
2021-01-04 20:43:43 +01:00
Strawbs Bot
b4c2ae251b Update translations 2020-12-30 01:07:43 +01:00
Jonas Kvinge
bfaabafbfa Remove some unused utilities functions 2020-12-29 23:13:22 +01:00
Jonas Kvinge
c213d5b8d9 Find program create-dmg 2020-12-28 21:28:45 +01:00
Jonas Kvinge
50beda6621 Use same macdeployqt on Qt 5 and 6 2020-12-28 20:54:19 +01:00
Jonas Kvinge
8ea359ec8a Pass char16_t to QString::fromUtf16() 2020-12-28 20:33:09 +01:00
Strawbs Bot
c983c8e447 Update translations 2020-12-27 01:02:06 +01:00
Strawbs Bot
af96ce3e82 Update translations 2020-12-26 01:02:38 +01:00
Strawbs Bot
6a5928863c Update translations 2020-12-25 01:08:33 +01:00
Jonas Kvinge
514becc53a Bundle strawberry-tagreader on macOS using macdeployqt 2020-12-24 22:05:22 +01:00
Jonas Kvinge
1b140535a8 Add worker debug 2020-12-24 20:44:16 +01:00
Jonas Kvinge
cb5222e4d6 Fix albumcover searcher dialog not showing up on macOS 2020-12-24 16:56:00 +01:00
Jonas Kvinge
b6a9e1a996 Include cpu architecture in macOS dmg filename 2020-12-24 15:34:21 +01:00
Jonas Kvinge
b58a7c32c2 Update make dmg for Qt 6 2020-12-24 15:24:48 +01:00
Jonas Kvinge
fa0fd6b7d0 Ignore deprecated QString::fromUtf16() 2020-12-24 15:23:35 +01:00
Jonas Kvinge
057ec49a3e Remove hack in MergedProxyModel and use QAbstractProxyModel::modelAboutToBeReset() 2020-12-24 12:33:05 +01:00
Jonas Kvinge
3ae9092226 Prefer native notifications instead of D-Bus on macOS 2020-12-23 20:25:23 +01:00
Jonas Kvinge
351999a01b Use setContentsMargins 2020-12-23 20:24:37 +01:00
Jonas Kvinge
e407080057 Remove explicit for song 2020-12-23 20:24:15 +01:00
Jonas Kvinge
fa0bd8d31a Link Sparkle 2020-12-23 16:55:35 +01:00
Strawbs Bot
9b5fdb1345 Update translations 2020-12-23 01:02:31 +01:00
Jonas Kvinge
47fd30c23f Ignore NSUserNotificationCenter deprecation 2020-12-22 20:37:39 +01:00
Jonas Kvinge
ad469e4f61 Switch to official opensuse repo for Qt 6 build 2020-12-22 17:09:03 +01:00
Jonas Kvinge
eaed953614 Compile with -Werror 2020-12-22 16:34:59 +01:00
Jonas Kvinge
977ac16a1e Fix sparkle installation 2020-12-22 16:33:51 +01:00
Jonas Kvinge
c7986e4277 Build source and binary packages in same command 2020-12-22 16:32:09 +01:00
Jonas Kvinge
aff8fa1968 Seperate debugsource and debuginfo rpm 2020-12-22 16:30:47 +01:00
Strawbs Bot
0af767fff0 Update translations 2020-12-22 01:06:44 +01:00
Strawbs Bot
a928aa61ca Update translations 2020-12-21 01:02:14 +01:00
Jonas Kvinge
30cb0b1cae QNetworkRequest::Http2AllowedAttribute require Qt 5.15 2020-12-20 07:42:14 +01:00
Jonas Kvinge
32ae3cd567 QNetworkRequest::Http2AllowedAttribute require Qt 5.14 2020-12-20 07:24:44 +01:00
Jonas Kvinge
91b9602e12 Dont use empty lyrics from API 2020-12-20 07:09:12 +01:00
Jonas Kvinge
124eba6800 Remove mageia from CI 2020-12-20 06:58:43 +01:00
Jonas Kvinge
a5ab8ddf8b Disable http2 for musixmatch 2020-12-20 06:51:36 +01:00
Jonas Kvinge
1444a1578a Search all unicode letters in musixmatch cover search 2020-12-20 06:40:45 +01:00
Jonas Kvinge
5b8894b0ff Search all unicode letters in musixmatch lyrics search 2020-12-20 06:16:08 +01:00
Strawbs Bot
a4329dd9a0 Update translations 2020-12-20 01:02:08 +01:00
Jonas Kvinge
1cab25aa7d Turn back git revision 2020-12-19 22:18:28 +01:00
Jonas Kvinge
d3faf18251 Fix typo 2020-12-19 17:42:24 +01:00
Jonas Kvinge
ddcc296af4 Release 0.8.5 2020-12-19 17:38:24 +01:00
Jonas Kvinge
ee765bc210 Update strawberry.spec 2020-12-17 22:49:57 +01:00
Jonas Kvinge
630c67f7d0 Remove -U__STRICT_ANSI__ from compile flags 2020-12-17 19:47:46 +01:00
Jonas Kvinge
e78bb1b29c Use directsoundsink by default because of buggy wasapi plugin 2020-12-13 21:56:25 +01:00
Strawbs Bot
db312a7380 Update translations 2020-12-13 01:02:57 +01:00
Jonas Kvinge
48b4cbe1b9 Update ccpp.yml 2020-12-12 19:05:21 +01:00
Jonas Kvinge
edb1d4c747 Append Qt5 to Windows setups 2020-12-12 12:51:23 +01:00
Jonas Kvinge
128935b55e Use LPCSTR in RegisterWindowMessageA 2020-12-12 12:51:01 +01:00
Jonas Kvinge
d5a0d67c7b Use ScopedWCharArray 2020-12-12 12:50:33 +01:00
Jonas Kvinge
a86640fdee Exclude Windows from find D-Bus in CMake 2020-12-12 12:49:41 +01:00
Jonas Kvinge
03291b27d1 Mark unused 2020-12-12 12:49:35 +01:00
Strawbs Bot
acf81f116f Update translations 2020-12-12 00:51:58 +01:00
Jonas Kvinge
6564c405c1 Update Changelog 2020-12-12 00:50:46 +01:00
Jonas Kvinge
1bd586268c Update some copyrights 2020-12-12 00:33:27 +01:00
Jonas Kvinge
497952611d Fix HTML escaping for custom OSD notifications
Fixes #618
2020-12-11 23:59:38 +01:00
Jonas Kvinge
9149d1baa3 Add back mistakenly removed QT_MIN_VERSION in CMakeLists.txt 2020-12-11 21:01:51 +01:00
Jonas Kvinge
66c60ac5c7 Add back CentOS 8 to CI 2020-12-09 21:44:47 +01:00
Strawbs Bot
971fad4560 Update translations 2020-12-09 19:33:33 +01:00
Jonas Kvinge
8ed1ce4103 Move ThreadSafeNetworkDiskCache to own file 2020-12-09 18:41:07 +01:00
Jonas Kvinge
3112c34d11 Change to NetworkAccessManager 2020-12-09 18:39:37 +01:00
Jonas Kvinge
7ebf3cecc6 Only include Rpm.cmake and Deb.cmake on Linux 2020-12-09 18:29:30 +01:00
Jonas Kvinge
660fa99f9c Simplify Rpm.cmake 2020-12-09 18:09:49 +01:00
Jonas Kvinge
a997e53d8b Update RPM spec for Qt 6 2020-12-09 01:29:38 +01:00
Jonas Kvinge
1d1dd583e2 Remove CentOS from CI 2020-12-08 15:59:53 +01:00
Jonas Kvinge
d490b29265 Use regex 2020-12-07 22:43:00 +01:00
Jonas Kvinge
e8ca64f16b Replace empty quotes with empty strings for values in CUE parser 2020-12-07 22:34:55 +01:00
Jonas Kvinge
380aa7d884 Only set disc and year in CUE parser when valid 2020-12-07 21:57:15 +01:00
Jonas Kvinge
0a31a94ee8 Change double-click in cover manager to open fullsize cover
Fixes #612
2020-12-07 17:23:08 +01:00
Jonas Kvinge
e1d50ce28f Make URL in scrobbler settings clickable 2020-12-07 17:21:34 +01:00
Jonas Kvinge
38cc39f23d Workaround udisks2 mountpoint issue with Qt 6 2020-12-06 18:46:30 +01:00
Jonas Kvinge
8110035d71 Remove unref 2020-12-06 18:45:37 +01:00
Jonas Kvinge
9af409d6d6 Make sure URL is valid in giolister 2020-12-06 18:45:17 +01:00
Jonas Kvinge
8646829853 Update .travis.yml 2020-12-06 11:16:15 +01:00
Jonas Kvinge
b9e87813b1 Add back Travis-CI 2020-12-06 06:45:08 +01:00
Strawbs Bot
138e032746 Update translations 2020-12-05 01:03:29 +01:00
Jonas Kvinge
d94c6b5aba Set active playlist when playlist doubleclick behaviour is enqueue
Fixes #610
2020-12-04 22:11:35 +01:00
Jonas Kvinge
7c03a39316 Update Changelog 2020-12-04 19:38:00 +01:00
Jonas Kvinge
c482e264f4 Rename variable 2020-12-04 19:13:21 +01:00
Nicolas Toussaint
3a9a1f0a94 add CLI play-playlist option, to play given playlist name. (#608)
* add CLI play-playlist option, to play given playlist name.

* Apply MR change requests
2020-12-04 19:08:41 +01:00
Jonas Kvinge
5b5f728f49 Update README.md 2020-12-03 22:24:57 +01:00
Jonas Kvinge
179aac6b35 Update FUNDING.yml 2020-12-03 22:16:22 +01:00
Strawbs Bot
25de9126ca Update translations 2020-11-30 01:19:32 +01:00
Jonas Kvinge
87be5662ad Update .circleci/config.yml 2020-11-29 16:05:02 +01:00
Jonas Kvinge
053a59e3f4 Update .github/workflows/ccpp.yml 2020-11-29 16:03:44 +01:00
Jonas Kvinge
250857b3d4 Update .circleci/config.yml 2020-11-29 07:54:42 +01:00
Jonas Kvinge
dc288c584c Search qpa/qplatformnativeinterface.h for both Qt 5 and 6 2020-11-29 07:50:08 +01:00
Jonas Kvinge
fc02543f15 Make X11Extras and WinExtras optional
The initial release of Qt 6 does not have these.

These modules are not important.
X11Extras is only used for X11 global shortcuts, which in most cases is
overriden by KDE or Gnome shortcuts anyway.
It is also used in OSD Pretty to detect transparency, but this can be
done using private GUI headers instead.

WinExtras is only used in OSD Pretty to make it transparent.
2020-11-29 07:41:30 +01:00
Jonas Kvinge
0808db706f Remove libgstrealmedia.dylib from macdeploy 2020-11-29 06:43:24 +01:00
Strawbs Bot
1e649fc565 Update translations 2020-11-29 01:02:57 +01:00
Strawbs Bot
c523e959d7 Update translations 2020-11-27 01:02:59 +01:00
Strawbs Bot
1422f988c1 Update translations 2020-11-26 01:02:53 +01:00
Strawbs Bot
e86252b934 Update translations 2020-11-25 01:02:17 +01:00
Jonas Kvinge
e9c59b5c31 Add gst-launch-1.0.exe to windows setup 2020-11-24 15:45:24 +01:00
Strawbs Bot
f7bddee0ce Update translations 2020-11-24 01:05:32 +01:00
Jonas Kvinge
d56b76c9e3 Save both ID3v1 and ID3v2
Fixes #598
2020-11-23 22:25:47 +01:00
Jonas Kvinge
a41353ed03 Update progress even if QDateTime::fromString() fails 2020-11-23 21:54:58 +01:00
Strawbs Bot
7ea12cf2f9 Update translations 2020-11-23 01:05:20 +01:00
Jonas Kvinge
5bc5170112 Remove travis 2020-11-22 20:01:45 +01:00
Jonas Kvinge
946ed0c0b5 Check for valid datetime when importing last played 2020-11-22 19:01:53 +01:00
Jonas Kvinge
fcd4e5aca2 Save and restore geometry in edit tag dialog 2020-11-22 03:37:15 +01:00
Jonas Kvinge
6ab6e6d3a8 Format code 2020-11-22 03:36:46 +01:00
Strawbs Bot
0893d01b4a Update translations 2020-11-22 01:02:49 +01:00
Jonas Kvinge
bf04c45ebf Remove unused live scanning option 2020-11-21 09:40:48 +01:00
Jonas Kvinge
2786a1a97e Remove required version from cmake files 2020-11-21 07:41:43 +01:00
Strawbs Bot
cd9a4f1aa9 Update translations 2020-11-21 01:16:20 +01:00
Jonas Kvinge
91e5cafe76 Remove disabling repeat and shuffle buttons
It's more confusing than helpful
2020-11-20 21:48:10 +01:00
Jonas Kvinge
47754951f0 Format code 2020-11-20 21:47:01 +01:00
Strawbs Bot
fbef8ef32e Update translations 2020-11-20 01:08:25 +01:00
Jonas Kvinge
abd5bf3158 Update .github/workflows/ccpp.yml 2020-11-19 21:25:40 +01:00
Jonas Kvinge
fd024368a3 Update .github/workflows/ccpp.yml 2020-11-19 21:24:30 +01:00
Jonas Kvinge
cf4856a0c9 Fix signal not always emitted from messagreply 2020-11-19 18:29:03 +01:00
Jonas Kvinge
1b791c82fc Use qint64 for message request ID 2020-11-19 18:26:50 +01:00
Jonas Kvinge
3a27a3e868 Format code 2020-11-19 18:22:57 +01:00
Jonas Kvinge
7e6c16b287 Change progress and max progress to qint64 in taskmanager 2020-11-19 18:14:42 +01:00
Jonas Kvinge
f877639ed7 Fix repeat/shuffle disabled when a dynamic playlist is open
Fixes #593
2020-11-19 18:12:48 +01:00
Strawbs Bot
846309d4dd Add Swedish 2020-11-19 01:19:58 +01:00
Strawbs Bot
f2239ddfdf Update translations 2020-11-19 01:02:47 +01:00
Jonas Kvinge
742d455b0e Build on Big Sur 2020-11-18 22:48:16 +01:00
Strawbs Bot
20b08a78e7 Update translations 2020-11-18 01:17:34 +01:00
Jonas Kvinge
042da74955 Change return type of qHash with Qt 6 to size_t 2020-11-17 01:22:38 +01:00
Jonas Kvinge
4dcae4ce21 Use QChar::unicode() 2020-11-17 01:22:00 +01:00
Jonas Kvinge
fa0f07f553 Use QString::number() 2020-11-17 01:21:38 +01:00
Jonas Kvinge
39792d76cf Fix PlaylistGenerator::type() 2020-11-17 01:20:45 +01:00
Strawbs Bot
d181ee9101 Update translations 2020-11-17 01:02:12 +01:00
Jonas Kvinge
335ba1a5b0 Disable tagreader checksum tests
These don't match anymore because tags are now removed.
2020-11-15 12:17:35 +01:00
Jonas Kvinge
4934a360f1 Turn back git revision 2020-11-15 12:16:44 +01:00
Strawbs Bot
0559a4c6f2 Update translations 2020-11-15 01:03:31 +01:00
Jonas Kvinge
fc07919a75 Release 0.8.4 2020-11-15 00:31:32 +01:00
Jonas Kvinge
d7661edf67 Update Changelog 2020-11-15 00:20:16 +01:00
Jonas Kvinge
1c91693294 Ignore org.kde.kglobalaccel.NoSuchComponent error 2020-11-15 00:20:08 +01:00
Jonas Kvinge
3fc3cbc6d5 Update protobuf dll in nsi 2020-11-14 19:13:40 +01:00
Jonas Kvinge
11b5895e69 Update ccpp.yml 2020-11-14 18:36:59 +01:00
Jonas Kvinge
b4c614edbf Set volume bit 2020-11-14 04:36:38 +01:00
Jonas Kvinge
deddaed04a Remove use of std::bind where possible 2020-11-14 02:13:22 +01:00
Jonas Kvinge
a155e503f4 Never use reference when iterating QJsonArray 2020-11-13 21:10:50 +01:00
Jonas Kvinge
c0663bc19f Use reference 2020-11-13 20:34:29 +01:00
Strawbs Bot
7ffa51b83d Update translations 2020-11-13 01:02:53 +01:00
Jonas Kvinge
6d397b9988 Fix smart playlist by filename 2020-11-12 20:47:13 +01:00
Jonas Kvinge
571a7fa26b Fix single letter collection nodes showing before dividers 2020-11-12 20:30:58 +01:00
Jonas Kvinge
b3b5a38c3a Minor code style fix 2020-11-11 22:55:56 +01:00
Jonas Kvinge
a4b115f89b Update Changelog 2020-11-11 22:51:55 +01:00
Strawbs Bot
3d672bb145 Update translations 2020-11-11 01:03:35 +01:00
Jonas Kvinge
15b656b753 Merge pull request #587 from fbugno/issue515
Fix HiDPI scaling for glow animation and drag over playlist
2020-11-10 22:52:08 +01:00
Felipe Bugno
f5785db163 Code style changes to match the existing code
This changes the style of the private variable and the call
convention of the inherited functions.
2020-11-10 17:55:00 -03:00
Jonas Kvinge
1ff1bf3292 Only call deleteLater when proxystyle is set 2020-11-10 19:06:26 +01:00
Felipe Bugno
b062febea0 Fix HiDPI scaling for glow animation and drag over playlist
This set the proper scaling and pixel ratio of QPixmap widgets
used as cached objects.

Most of cached objects uses a custom QPaint instead of the default
painter object from the parent widget. The problem is that, unlike
the painter from the parent object, set by the main application,
and that has DPI and scaling settings from the device, these custom
QPainters don't know about the underlying device, thus uses a
scale of 1 to render artifacts.

When a cached object "edited" by a custom QPaint along his pipeline
where used on a paint or drawrow routine, his stored image is distorted
and burred in a effort to resize it to the display configuration.
2020-11-09 21:49:22 -03:00
Strawbs Bot
35301dc79e Update translations 2020-11-10 01:02:36 +01:00
Jonas Kvinge
30c336726b Only backup database if schema version is correct 2020-11-09 23:10:43 +01:00
Jonas Kvinge
3821680817 Increase sqlite busy timeout to 30 seconds
Possible fix for #533
2020-11-09 22:49:33 +01:00
Jonas Kvinge
74242ea24f Fix shortcut settings on macOS and Windows 2020-11-09 20:20:31 +01:00
Jonas Kvinge
73c7024e11 Dont return from SongSaveComplete early, needs to free TagReaderReply 2020-11-09 19:17:31 +01:00
Strawbs Bot
bbdec92dc6 Update translations 2020-11-09 01:01:55 +01:00
Jonas Kvinge
b4c289101c Strip summary but encode message 2020-11-08 21:54:16 +01:00
Jonas Kvinge
722d0797f6 Use QString::toHtmlEscaped() 2020-11-08 17:52:29 +01:00
Jonas Kvinge
deb27d5b55 Replace '&' with '&amp;' in D-BUS OSD messages 2020-11-08 14:24:09 +01:00
Jonas Kvinge
9cc4ffdf6e Only strip '&' from D-Bus OSD messages 2020-11-08 13:46:17 +01:00
Strawbs Bot
c76d63d1d9 Update translations 2020-11-08 13:32:51 +01:00
Jonas Kvinge
21bb4f33ad Update Changelog 2020-11-08 04:05:39 +01:00
Jonas Kvinge
2897b881d6 Only override fancy tabwidget style with adwaita 2020-11-08 04:04:37 +01:00
Jonas Kvinge
e9b89d0929 Simplify FancyTabWidget override 2020-11-08 03:23:18 +01:00
Jonas Kvinge
e801254b2e Log used style 2020-11-08 03:22:38 +01:00
Jonas Kvinge
6f49918ee9 Update Changelog 2020-11-08 02:10:20 +01:00
Jonas Kvinge
0ae7c18f1f Add setting to set style 2020-11-08 02:04:24 +01:00
Jonas Kvinge
c9c3fb396a Move ComboBoxLoadFromSettings function to settingspage 2020-11-08 02:02:48 +01:00
Strawbs Bot
91db4f1934 Update translations 2020-11-08 01:02:31 +01:00
Jonas Kvinge
9bbed6e95c Use QClipboard::setText instead of QClipboard::setMimeData
Fixes #581

Fixes clipboard copying on Windows too
2020-11-08 00:51:24 +01:00
Strawbs Bot
748bc27b25 Update translations 2020-11-06 11:50:48 +01:00
Jonas Kvinge
f42708e8bc Remove qt6-qt5compat-devel from ccpp.yml 2020-11-05 22:30:37 +01:00
Jonas Kvinge
160e4570a2 Use C++17 (#579)
* Use C++17

* Replace std::random_shuffle with std::shuffle

* Add random include
2020-11-05 22:28:49 +01:00
Jonas Kvinge
6272965143 Update Changelog 2020-11-05 00:10:16 +01:00
Jonas Kvinge
1e9613bf7f Update ccpp.yml 2020-11-04 23:45:40 +01:00
Jonas Kvinge
a061dac298 Check network proxy mode 2020-11-04 22:22:26 +01:00
Jonas Kvinge
914dee8571 Pass network proxy settings to gstreamer
Fixes #558
2020-11-04 22:16:20 +01:00
yavuzmert
47e2905edf Re-enable progress on system tray icon (#578)
* Re-enable progress on system tray icon

* fix copy-paste typo in mac sources

* Make tray icon progress optional

* Move tray icon progress setting control to MainWindow

* Move trayicon settings to behavioursettings

Co-authored-by: Yavuz Mert <yavuz.mert@darkbluesystems.net>
2020-11-04 21:01:04 +01:00
Jonas Kvinge
ee6675aee0 No longer need Core5Compat 2020-11-04 18:17:33 +01:00
Jonas Kvinge
62e0d9fe64 Remove all uses of QTextCodec 2020-11-04 18:16:23 +01:00
Jonas Kvinge
a174c142c1 Remove unused linked list includes 2020-11-04 18:06:36 +01:00
Jonas Kvinge
95afc5fdec Keep tabs in the middle on macOS 2020-11-04 18:05:58 +01:00
Strawbs Bot
04d69f66c0 Update translations 2020-11-04 01:02:16 +01:00
Jonas Kvinge
0347141edd Update snap dialog 2020-11-03 19:32:32 +01:00
Jonas Kvinge
1d6baae6e0 Set ssl-strict false in songloader too 2020-11-03 18:48:35 +01:00
yavuzmert
fb0f48f08a Make context view top label selectable (#576)
Co-authored-by: Yavuz Mert <yavuz.mert@darkbluesystems.net>
2020-11-03 01:34:09 +01:00
Jonas Kvinge
76e5e03d31 Change copy command in snap dialog 2020-11-02 21:26:20 +01:00
Jonas Kvinge
4cab743634 Center playlist tabbar star icon
Fixes #574
2020-11-02 17:57:12 +01:00
Jonas Kvinge
7c10ec97b7 Remove unused parameter 2020-11-02 17:47:16 +01:00
Jonas Kvinge
8718a16889 Star/unstar playlist with doubleclick 2020-11-02 17:45:29 +01:00
Strawbs Bot
75a0b924c3 Update translations 2020-11-02 01:02:00 +01:00
Jonas Kvinge
83a90e0c05 Make tabbar style hack less intrusive 2020-11-01 21:54:23 +01:00
Strawbs Bot
e5eadd1315 Update translations 2020-10-31 14:34:41 +01:00
Jonas Kvinge
f0142d90d4 Update comment 2020-10-31 14:27:53 +01:00
Jonas Kvinge
cabd6e6e9d Override QStyle::subElementRect in fancy tabbar to fix style problems
Something is causing the contents of the tabbar to be stretched from top to bottom with space between icons and text.
You can see this on the default Fedora (Gnome) installation.
Also fixes the tabbar on macOS where the content was in the middle instead of the top.
2020-10-31 14:05:06 +01:00
Jonas Kvinge
4804a05736 Remove fixed width in about dialog as it crashes on wayland 2020-10-31 02:41:42 +01:00
Jonas Kvinge
c258e5a3af Add KDE global shortcuts
Fixes #572
2020-10-31 02:08:19 +01:00
Jonas Kvinge
e8492940a5 Add -fPIC compiler flag for Redhat/Fedora/CentOS
Fixes #573
2020-10-30 18:12:42 +01:00
Jonas Kvinge
4bccb1ab47 Only save as ID3v2, and remove empty tags
Fixes #571
2020-10-29 18:47:09 +01:00
Strawbs Bot
b6d219e232 Update translations 2020-10-28 17:50:58 +01:00
Jonas Kvinge
23ee17594d Simplify CMake Qt 2020-10-27 20:54:25 +01:00
Jonas Kvinge
d9d39d8e25 Only override MainWindow::nativeEvent for Windows 2020-10-27 20:17:28 +01:00
Jonas Kvinge
224d5d46c1 Set QApplication::setQuitOnLastWindowClosed to false 2020-10-27 20:01:07 +01:00
Jonas Kvinge
09e0059930 Resize organize window when copying to device
Fixes #566
2020-10-27 17:50:16 +01:00
Jonas Kvinge
0ddff2b087 Fix stupid bug 2020-10-27 17:47:40 +01:00
Jonas Kvinge
2e6a29eacc Remove ifdef HAVE_GSTREAMER
Fixes #568
2020-10-27 17:17:12 +01:00
Jonas Kvinge
ad2fb82aa9 Don't edit playlist name on doubleclick in playlists view
Fixes #567
2020-10-27 17:11:17 +01:00
Strawbs Bot
a3f91c11e8 Update translations 2020-10-26 01:02:24 +01:00
Jonas Kvinge
a50c978ce3 Fix cancelling logout when window is maxmimized
Fixes #565
2020-10-25 19:59:27 +01:00
Strawbs Bot
27d6f881cd Update translations 2020-10-25 01:04:50 +02:00
Jonas Kvinge
944cd020af Only strip problematic characters when saving a playlist 2020-10-25 01:01:43 +02:00
Jonas Kvinge
bbe5d64b99 Add info about backing up configuration to snap dialog 2020-10-25 01:01:16 +02:00
Jonas Kvinge
f7b36ac4c7 Replace use of QVariant::type() with Qt 6 2020-10-24 03:32:40 +02:00
Jonas Kvinge
1d555ca17e Turn back git revision 2020-10-24 03:30:21 +02:00
Jonas Kvinge
f91b6c3468 Release 0.8.3 2020-10-24 01:32:25 +02:00
Jonas Kvinge
abe6eeb350 Update Changelog 2020-10-23 19:35:07 +02:00
Jonas Kvinge
64f90a7912 Remove Qt MacExtras, no longer used 2020-10-22 23:11:44 +02:00
Jonas Kvinge
5733966843 Dont reset settingspage changed status when window is shown
This is done by Init in Load() when the settings is opened.
2020-10-22 20:25:31 +02:00
Jonas Kvinge
eb1344fcec Unref caps in HandoffCallback 2020-10-22 17:49:13 +02:00
Strawbs Bot
c5fb29f00e Update translations 2020-10-22 01:02:03 +02:00
Jonas Kvinge
63135b9c54 Engine will never be in playing state on error 2020-10-21 23:27:15 +02:00
Jonas Kvinge
f7c666584e Remove debug line 2020-10-21 21:33:26 +02:00
Jonas Kvinge
6834324de2 Add more unit tests for organizeformat 2020-10-21 21:32:30 +02:00
Jonas Kvinge
3a0d59e66f Only append path if not empty 2020-10-21 21:32:12 +02:00
Jonas Kvinge
ffd2e2188a Fix crash with empty APE tag for MPC files 2020-10-21 20:29:06 +02:00
Jonas Kvinge
0e8d5bdc5d Fix crash with empty APE tag for WavPack and APE files 2020-10-21 20:27:43 +02:00
Jonas Kvinge
14806f6614 Update Changelog 2020-10-21 19:57:00 +02:00
Jonas Kvinge
00ece83b9d Tidal: Set default quality to lossless 2020-10-21 19:56:37 +02:00
Jonas Kvinge
8197ae2a2d Tidal: Guess filetype by filename extension in URL when missing codec. 2020-10-21 01:12:46 +02:00
Strawbs Bot
5fe658bb16 Update translations 2020-10-21 01:02:16 +02:00
Jonas Kvinge
617179f0c6 Always set state to NULL in destructor 2020-10-21 00:32:55 +02:00
Jonas Kvinge
95ac85f642 Move stream discoverer from pipeline to engine
Fixes #491
2020-10-21 00:07:58 +02:00
Jonas Kvinge
ca8877ad47 Revert gst_discoverer_stop 2020-10-20 18:47:40 +02:00
Jonas Kvinge
6d8f31048c Add call to gst_discoverer_stop
Stream discoverer currently only works on Linux
2020-10-20 18:28:09 +02:00
Jonas Kvinge
ac859eb576 Make sure we query empty instead of null 2020-10-20 17:14:38 +02:00
Jonas Kvinge
2dfa171b6a Save effective_albumartist as empty istead of null
Since we use the metadata now instead of the container keys for queries in
the model, there is a regression when the values are null.
2020-10-20 17:12:28 +02:00
Jonas Kvinge
6f72e3e2ea Always append divider key to sort text if the key is a digit 2020-10-20 17:11:14 +02:00
Strawbs Bot
c2b73ae963 Update translations 2020-10-20 01:04:50 +02:00
Jonas Kvinge
6c50077409 Fix concurrentrun test 2020-10-19 22:33:08 +02:00
Jonas Kvinge
06746449a1 Disable TestContainerNodes 2020-10-19 22:32:50 +02:00
Jonas Kvinge
da7b8edf51 Revert back to using PathWithoutFilenameExtension in organizedialog 2020-10-19 21:35:39 +02:00
Jonas Kvinge
6e29b41f23 Update Changelog 2020-10-19 21:07:25 +02:00
Jonas Kvinge
912bb069af Fix updating album cover to collection for edit tag dialog 2020-10-19 21:05:59 +02:00
Jonas Kvinge
6b2d7a67d8 Use Utilities::FiddleFileExtension in organize 2020-10-19 19:56:40 +02:00
Jonas Kvinge
dbb8ec0290 Remove debug in bus callbacks 2020-10-19 19:09:48 +02:00
Strawbs Bot
60b32760f2 Update translations 2020-10-19 01:03:27 +02:00
Jonas Kvinge
73a40bcb49 Update Changelog 2020-10-18 17:08:28 +02:00
Jonas Kvinge
0e258a5a32 Remove unused utilities functions 2020-10-18 14:12:01 +02:00
Jonas Kvinge
7ca65c81d8 Use QFileInfo instead of custom functions 2020-10-18 14:07:48 +02:00
Jonas Kvinge
2ad1a60e59 Use correct file extension in organize preview and resulting filename
Fixes #564
2020-10-18 13:24:33 +02:00
Jonas Kvinge
cf17ff4478 Update Changelog 2020-10-18 00:29:28 +02:00
Jonas Kvinge
fffc3aac68 Update Changelog 2020-10-17 21:11:06 +02:00
Jonas Kvinge
295ac3c458 Add back thumbbar 2020-10-17 21:10:57 +02:00
Jonas Kvinge
b6693a71f9 Rename initialise to initialize 2020-10-17 17:29:09 +02:00
Jonas Kvinge
5b21118a8c Replace gst_tag_list_free with gst_tag_list_unref 2020-10-17 04:54:46 +02:00
Jonas Kvinge
0235b19801 Only update buttons once 2020-10-17 04:21:11 +02:00
Jonas Kvinge
7426399aa2 Enable thumbbar for debug build 2020-10-17 03:41:28 +02:00
Jonas Kvinge
6861b0d668 Possible fix Windows thumbbar 2020-10-17 03:37:39 +02:00
Jonas Kvinge
c30fb0d38c Log errors in MM device finder 2020-10-17 03:19:13 +02:00
Jonas Kvinge
e45521c6c0 Fix updating playing widget song details in small mode 2020-10-16 23:57:18 +02:00
Strawbs Bot
d11fe8d4fc Update translations 2020-10-16 01:01:51 +02:00
Jonas Kvinge
8e83e63e3d Add snap warning dialog 2020-10-15 21:47:52 +02:00
Jonas Kvinge
c8fd0ac4b3 Update snapcraft.yaml 2020-10-15 18:51:21 +02:00
Jonas Kvinge
d78419eb33 Enable WASAPI plugin
Fixes #283
2020-10-15 16:08:59 +02:00
Jonas Kvinge
e44a3d013d Disable windows thumbbar
Fixes stability issues with WASAPI
2020-10-15 16:07:20 +02:00
Jonas Kvinge
aeb0d05017 Add CoInitializeEx() to mmdevice finder and refactor code 2020-10-15 16:06:07 +02:00
Jonas Kvinge
62702e4b3d Add space 2020-10-14 22:53:58 +02:00
Jonas Kvinge
5146cdfa2f Improve windows thumbbar code 2020-10-14 22:53:08 +02:00
Jonas Kvinge
246e7018c3 Remove concurrentrun.h 2020-10-14 22:50:19 +02:00
Jonas Kvinge
24286dbe9d Use QtConcurrent::run directly 2020-10-14 22:49:37 +02:00
Jonas Kvinge
2f442dfbe1 Ignore return value 2020-10-14 22:38:32 +02:00
Jonas Kvinge
b2fb01ee9c Use QtConcurrent 2020-10-14 22:35:54 +02:00
Jonas Kvinge
45e0a9a4ef Remove build-snap from CI 2020-10-14 18:36:29 +02:00
Jonas Kvinge
675b7b4bf4 Fix CI 2020-10-14 18:05:04 +02:00
Jonas Kvinge
be7a35443e Add gdb to nsi 2020-10-14 16:55:17 +02:00
Strawbs Bot
9918615fcd Update translations 2020-10-14 01:02:02 +02:00
Jonas Kvinge
4b72ef77c1 Turn back git revision 2020-10-14 00:26:35 +02:00
Jonas Kvinge
e427c61fbb Release 0.8.2 2020-10-13 18:03:05 +02:00
Jonas Kvinge
c78e8937d5 Update ISSUE_TEMPLATE.md 2020-10-13 01:50:32 +02:00
Jonas Kvinge
5d63f7a93d Update ISSUE_TEMPLATE.md 2020-10-13 01:50:03 +02:00
Jonas Kvinge
46551ada7f Update Changelog 2020-10-13 01:47:22 +02:00
Jonas Kvinge
83f17a37b1 Use format only when available 2020-10-13 01:38:09 +02:00
Strawbs Bot
9e23e0a623 Update translations 2020-10-13 01:05:54 +02:00
Jonas Kvinge
4a53d4f043 Ignore "IDirectSoundBuffer_GetStatus The operation completed successfully"
Fixes #557
2020-10-13 00:49:34 +02:00
Jonas Kvinge
0fd61945c7 Fix saving initial settings 2020-10-12 17:20:18 +02:00
Strawbs Bot
e3624eed30 Update translations 2020-10-12 01:03:47 +02:00
Jonas Kvinge
1923c8be0c Remove unused includes 2020-10-11 01:31:12 +02:00
Jonas Kvinge
a3e37fbfe2 Remove use of HTML in system tray icon tooltip 2020-10-11 01:29:26 +02:00
Jonas Kvinge
318c3bb422 Check if QNetworkRequest::ContentTypeHeader is filetype everwhere 2020-10-11 01:08:42 +02:00
Strawbs Bot
db96e24028 Update translations 2020-10-11 01:02:04 +02:00
Jonas Kvinge
cc2cce66df Make const 2020-10-11 00:07:38 +02:00
Jonas Kvinge
7afeabd288 Subsonic: Read created from album too
Fixes #526
2020-10-11 00:05:06 +02:00
Jonas Kvinge
eb43a812d6 Fix saving subsonic cover when ContentTypeHeader returns filetype 2020-10-10 23:46:29 +02:00
Jonas Kvinge
12cbcdb6f4 Fix SQL query by song id when song id is a string 2020-10-10 23:44:42 +02:00
Jonas Kvinge
a2e35e30dc Use lowercase for divider keys sort text
Fixes #556
2020-10-10 18:44:57 +02:00
Jonas Kvinge
b6ff7e6b47 Fix transition to next song in CUE files
Fixes #552
2020-10-10 01:57:02 +02:00
Jonas Kvinge
6dba40c6bb Turn back git revision 2020-10-10 01:21:13 +02:00
Jonas Kvinge
896da46422 Release 0.8.1 2020-10-09 21:38:00 +02:00
Jonas Kvinge
7c07f5eb2a Add clang-format file 2020-10-09 21:02:18 +02:00
Strawbs Bot
298cff37de Update translations 2020-10-09 01:01:57 +02:00
Jonas Kvinge
8add802fe9 Update Changelog 2020-10-08 19:42:33 +02:00
Jonas Kvinge
6d080a0d59 Fix crash when copying a closed playlist to a device
Fixes #551
2020-10-08 19:19:39 +02:00
Jonas Kvinge
f0ae1051ee Only set art manual for temporary metadata when temp metadata is set 2020-10-08 19:14:56 +02:00
Strawbs Bot
1ad0ffeaa6 Update translations 2020-10-08 01:02:36 +02:00
Jonas Kvinge
45b44d012d Fix source for CUE songs in collection watcher 2020-10-07 23:27:58 +02:00
Jonas Kvinge
cb6cbb9ee5 Remove unused screensaver classes 2020-10-07 22:10:31 +02:00
Jonas Kvinge
013a0d9cb0 Remove commented line 2020-10-07 21:28:52 +02:00
Jonas Kvinge
8abb3ea225 Fix backend settings tab order 2020-10-07 20:43:15 +02:00
Jonas Kvinge
74a5233b5d Replace use of deprecated gstreamer low-percent
- Add settings for low-watermark and high-watermark
- Add button to reset buffer settings to defaults
2020-10-07 20:29:26 +02:00
Strawbs Bot
cd695a4522 Update translations 2020-10-06 01:02:00 +02:00
Jonas Kvinge
eec4b2cc0e Call QLocalSocket::flush() after QLocalSocket::waitForBytesWritten() 2020-10-05 22:05:37 +02:00
Jonas Kvinge
616875d0d2 Log when sending message to primary instance fails 2020-10-05 22:04:58 +02:00
Jonas Kvinge
eb749bd76f Fix compile 2020-10-05 21:40:31 +02:00
Jonas Kvinge
7d1e404efd Fix header guard 2020-10-05 21:34:45 +02:00
Jonas Kvinge
4a01a578d1 Update singleapplication 2020-10-05 21:31:03 +02:00
Jonas Kvinge
393a2e0ea0 Set hide to false when window is shown 2020-10-05 19:08:09 +02:00
Jonas Kvinge
8e21decb8d Add WASAPI plugin to own setup file
Seem to still be stability issues.
2020-10-04 19:24:08 +02:00
Jonas Kvinge
22bfbab832 Add check for desktop notifications service version 2020-10-04 04:38:46 +02:00
Jonas Kvinge
28d0cc8795 Format singleapplication sources 2020-10-04 02:18:10 +02:00
Jonas Kvinge
51f2383a07 Remove lyrics from fandom.com
API no longer exists.
2020-10-04 02:13:06 +02:00
Jonas Kvinge
a6426c6eba Update Changelog 2020-10-04 02:00:12 +02:00
Jonas Kvinge
0631da6c8e Register Tidal URL Scheme in Windows installer 2020-10-04 01:59:40 +02:00
Jonas Kvinge
3960239cfe Add back WASAPI plugin again 2020-10-03 20:30:14 +02:00
Jonas Kvinge
b16e48af6f Add back WASAPI plugin again 2020-10-03 20:29:05 +02:00
Jonas Kvinge
4d3950565a Remove scangiomodulepath.cpp from CMakeLists.txt 2020-10-03 20:10:38 +02:00
Jonas Kvinge
8d24bc50c9 Change GST to GStreamer in debug logging 2020-10-03 20:08:33 +02:00
Jonas Kvinge
458efe9168 Remove gstreamer registry workaround for Windows 2020-10-03 20:05:30 +02:00
Jonas Kvinge
ae940a8681 Fix PRODUCT_NAME 2020-10-03 19:37:29 +02:00
Jonas Kvinge
d76b223b7c Fix typo 2020-10-03 19:36:10 +02:00
Jonas Kvinge
7243d5f7cb Add WASAPI plugin to own setup 2020-10-03 19:29:04 +02:00
Jonas Kvinge
387f74f66a Revert "Add back WASAPI plugin"
This reverts commit a553693f34.
2020-10-03 17:38:31 +02:00
Jonas Kvinge
61ffb7d97a Unref bus 2020-10-03 13:09:09 +02:00
Jonas Kvinge
a553693f34 Add back WASAPI plugin
Fixes #283
2020-10-03 02:03:37 +02:00
Jonas Kvinge
cdcfd64ec4 Possible fix for WASAPI crashes 2020-10-03 01:58:52 +02:00
Jonas Kvinge
7f4302ba20 Update Changelog 2020-10-02 22:09:40 +02:00
Jonas Kvinge
0d94f2d376 Update README 2020-10-02 22:09:33 +02:00
Jonas Kvinge
c1eb20a20b Force inform in Player::NextItem 2020-10-02 20:38:14 +02:00
Jonas Kvinge
634db67685 Change branch to master 2020-10-02 19:29:55 +02:00
Jonas Kvinge
86648258a3 Add CI for snap 2020-10-02 19:29:26 +02:00
Jonas Kvinge
287f0a3739 Remove redundant check for isNull() 2020-10-02 19:27:47 +02:00
Strawbs Bot
8f42df209a Update translations 2020-10-02 01:07:32 +02:00
Jonas Kvinge
390fd64a74 Save initial settings 2020-10-01 22:04:38 +02:00
Jonas Kvinge
48ee471def Remove force inform in PreviousItem 2020-10-01 20:30:31 +02:00
Jonas Kvinge
e862afcb78 Log song change 2020-10-01 20:09:36 +02:00
Jonas Kvinge
872da05ff6 Inform of song change on play restart, add playlist auto sorting.
Fixes #511
2020-10-01 19:58:16 +02:00
Jonas Kvinge
d09e2daf00 Mark backend settings changed if loaded engine, output or device does
not match the configured.
2020-10-01 19:53:07 +02:00
Jonas Kvinge
e2d5b44b0a Hide certain playlist list context menu options when items are not selected 2020-10-01 19:49:06 +02:00
Jonas Kvinge
52d42ef2a8 Use BUILD_WITH_QT6 2020-10-01 19:47:21 +02:00
Jonas Kvinge
b6abc34461 Set CollectionWatcher::sValidImages directly 2020-10-01 19:45:10 +02:00
Jonas Kvinge
ae6a50626d Change Qt 5/6 option 2020-10-01 19:43:39 +02:00
Jonas Kvinge
8f9dbfee2c Replace QMacCocoaViewContainer with QWidget::createWindowContainer 2020-10-01 19:40:55 +02:00
Jonas Kvinge
c71ccda967 Remove '&' in OSD messages
Causes weird problems with previous text getting stuck.
2020-10-01 19:39:49 +02:00
Strawbs Bot
0f284f2e1d Update translations 2020-10-01 01:01:35 +02:00
Jonas Kvinge
45ac80dd8c Change order of artist - title when song is paused/stopped in OSD 2020-09-30 01:14:00 +02:00
Jonas Kvinge
09cdba4b3d Fix minor code issues 2020-09-30 01:02:41 +02:00
Jonas Kvinge
d94ee8863c Fix playing widget stuck on error 2020-09-30 00:44:40 +02:00
Jonas Kvinge
cc8ced6430 Disable live scanning option 2020-09-30 00:03:06 +02:00
Jonas Kvinge
cdb144e6a6 Update Changelog 2020-09-29 23:26:55 +02:00
Jonas Kvinge
58fb8643c6 Fix typo in README 2020-09-29 23:26:26 +02:00
Jonas Kvinge
b81cfa8acb Update stream url to avoid requesting it twice 2020-09-29 23:03:50 +02:00
Jonas Kvinge
938ee20f1f Make sure song changed is only called once 2020-09-29 22:40:43 +02:00
Jonas Kvinge
d02dc54c1b Log remote cover loading 2020-09-29 22:30:44 +02:00
Jonas Kvinge
8680a54ae4 Only draw text when show/hide timeline is finished 2020-09-29 20:22:11 +02:00
Jonas Kvinge
30001be0ee Show song in OSD when pausing and stopping 2020-09-29 19:27:35 +02:00
Jonas Kvinge
4614cb5ec1 Make sure same cover isn't loaded twice 2020-09-29 17:51:31 +02:00
Jonas Kvinge
e390f3a399 Clear now playing in MainWindow::MediaPlaying() instead
Fixes #548
2020-09-29 17:38:00 +02:00
Jonas Kvinge
e22d463d11 Use QFileInfo::completeBaseName() instead of QFileInfo::baseName()
Fixes #550
2020-09-29 17:30:21 +02:00
Jonas Kvinge
5877aa822c Don't reset playing widget timeline 2020-09-29 01:07:04 +02:00
Strawbs Bot
a2915913bb Update translations 2020-09-29 01:02:40 +02:00
Jonas Kvinge
a8b40747b2 Attempt to improve playing widget up/down 2020-09-28 20:09:23 +02:00
Jonas Kvinge
b63030d302 Don't send now playing twice
Fixes #548
2020-09-28 17:47:45 +02:00
Strawbs Bot
4457e416db Update translations 2020-09-26 01:01:50 +02:00
Pascal Below
c7c1a8ede1 SubsonicRequest: create cover directory if it doesn't exist (#547) 2020-09-25 15:46:25 +02:00
Jonas Kvinge
fd1e9d7fb0 Fix clearing sent in scrobbler cache 2020-09-24 17:02:43 +02:00
Strawbs Bot
59a6d2317b Update translations 2020-09-24 01:02:04 +02:00
Jonas Kvinge
531c171542 Merge branch 'debian' into master 2020-09-23 19:06:22 +02:00
Jonas Kvinge
0c743452b0 Only compile Subsonic scrobbler when compiled with Subsonic support 2020-09-23 18:55:22 +02:00
Jonas Kvinge
4893d3da1f Add back debian bullseye and add dh-make to ubuntu too 2020-09-23 18:42:56 +02:00
Jonas Kvinge
5cdc24bfb0 Reload Subsonic scrobbler settings 2020-09-23 18:31:09 +02:00
Jonas Kvinge
523cdca449 Add back dh-make 2020-09-23 18:23:59 +02:00
Jonas Kvinge
09537d73da Remove debian bullseye CI 2020-09-23 18:10:13 +02:00
Jonas Kvinge
99c0c0b3b1 Update Changelog 2020-09-23 17:59:51 +02:00
Pascal Below
45bc353341 Add Subsonic scrobble support (#545)
* add SubsonicScrobbler, add Scrobble method in SubsonicService

* new class SubsonicScrobbleRequest, use queue again, clean up

* add checkbox to enable server-side scrobbling to Subsonic settings page

* Check serversidescrobbling in SubsonicScrobbler::ReloadSettings instead of SubsonicService

TODO: SubsonicScrobbler::ReloadSettings needs to be called when
SubsonicSettings change.
2020-09-23 17:55:12 +02:00
Strawbs Bot
b2fc41a911 Update translations 2020-09-23 01:02:50 +02:00
Jonas Kvinge
ebefe8b6d2 Update copyright 2020-09-23 00:55:34 +02:00
Jonas Kvinge
9e3508134b Add compilation to edit tag dialog 2020-09-23 00:52:41 +02:00
Jonas Kvinge
3166ca2127 Use QRecursiveMutex 2020-09-22 18:58:44 +02:00
Jonas Kvinge
204508478f Don't ignore closeevent if already hidden
Possible fix for #277
2020-09-22 18:40:37 +02:00
Strawbs Bot
51ce674c97 Update translations 2020-09-22 01:02:29 +02:00
Jonas Kvinge
6fcde9fe5f Add qobuz to scrobbler settings 2020-09-22 00:00:02 +02:00
Jonas Kvinge
c688e3431d Fix debian builds 2020-09-20 15:55:25 +02:00
Jonas Kvinge
230376c7f3 Ignore unused variable in MoveToTrashRecursive 2020-09-20 14:55:52 +02:00
Jonas Kvinge
91d0a2cd0c Fix uninitialized variable 2020-09-19 02:10:16 +02:00
Jonas Kvinge
1ffd010e4a Add windows.h include to MM device finder
Fixes compile error with mingw-w64 8.0.0
2020-09-19 02:06:15 +02:00
Strawbs Bot
ae366e141f Update translations 2020-09-19 01:01:38 +02:00
Strawbs Bot
eb869c6e97 Update translations 2020-09-18 01:08:32 +02:00
Jonas Kvinge
b559f7cd16 Fix minor code issues 2020-09-17 18:12:14 +02:00
Jonas Kvinge
375d32f08e Add missing utilities include 2020-09-17 18:01:24 +02:00
Jonas Kvinge
89d6b7cec0 Add smart playlists, ratings and Qobuz
Fixes #259
Fixes #264
2020-09-17 17:50:17 +02:00
Jonas Kvinge
fdf96e8342 Update README 2020-09-17 17:49:39 +02:00
Jonas Kvinge
c5d73d7b09 Update Changelog 2020-09-17 17:49:25 +02:00
Jonas Kvinge
34b4cc2d9e Remove unused function 2020-09-17 17:28:32 +02:00
Jonas Kvinge
40ed17e609 Change defaults for context 2020-09-17 17:12:01 +02:00
Jonas Kvinge
673d76af45 Change defaults for Tidal 2020-09-17 17:07:54 +02:00
Jonas Kvinge
c13fb6f9d5 Use QLibraryInfo::path with Qt 6 2020-09-17 17:00:45 +02:00
Jonas Kvinge
424b1e7d1f Fix strawberry.spec for Mageia 2020-09-17 16:28:16 +02:00
Jonas Kvinge
e80c9c4101 Fix strawberry.spec for CentOS and Mageia 2020-09-16 19:21:37 +02:00
Jonas Kvinge
f75c3633e9 Add Fedora 34 CI 2020-09-16 18:11:34 +02:00
Jonas Kvinge
d535cd8276 Add Fedora 33 to CI 2020-09-16 18:08:33 +02:00
Jonas Kvinge
c13f6ab2af Remove brew unlink python@2 2020-09-16 18:05:49 +02:00
Jonas Kvinge
d2a30bfb78 Simplify strawberry.spec 2020-09-16 18:03:34 +02:00
Jonas Kvinge
e5b17092b4 Fix stretchheaderview column widths too wide 2020-09-16 00:01:16 +02:00
Strawbs Bot
466cb4c78b Update translations 2020-09-15 01:01:29 +02:00
Strawbs Bot
9722e1ddc4 Update translations 2020-09-13 01:01:42 +02:00
Jonas Kvinge
e3a9b0b943 Use collection settings for group by settings 2020-09-12 15:48:26 +02:00
Jonas Kvinge
d668a8aee2 Change sort text for divider keys
Fixes problems on Windows with specific regionale settings, where
divider keys are all on the top, while albums are on the bottom
2020-09-12 13:30:45 +02:00
Strawbs Bot
75dc0aafcf Update translations 2020-09-12 01:02:03 +02:00
Jonas Kvinge
41b94233c6 Add group by version check in internet search view too 2020-09-12 00:32:50 +02:00
Jonas Kvinge
52cff01b9c Fix group by version 2020-09-12 00:18:08 +02:00
Jonas Kvinge
372fc6603d Update .github/workflows/ccpp.yml 2020-09-11 23:35:21 +02:00
Jonas Kvinge
9221797c9d Add sqlite3.exe to nsi 2020-09-11 22:58:56 +02:00
Strawbs Bot
7501131558 Update translations 2020-09-11 01:04:26 +02:00
Jonas Kvinge
bba7be99a3 Remove override.h 2020-09-10 23:41:53 +02:00
Jonas Kvinge
abb95534d0 Add musepack to macdeploy 2020-09-10 23:06:10 +02:00
Jonas Kvinge
0b7b4c12e4 Add test for collection model container nodes 2020-09-10 22:13:20 +02:00
Jonas Kvinge
4056f00169 Only initialize translations in test when compiled with translations 2020-09-10 22:11:40 +02:00
Jonas Kvinge
10303cb9c0 Use unique keys for all container nodes in collection model
Fixes #539 and probably many more issues with the model.
2020-09-10 22:09:24 +02:00
Jonas Kvinge
e3587d369e Add const 2020-09-10 22:05:12 +02:00
Jonas Kvinge
2a048502cc Add PlaylistItem::NewFromSong function 2020-09-10 22:04:11 +02:00
Jonas Kvinge
cac01fbde9 Dont seperate compilation albums by directory in GetAlbums
Fixes issue where multi-disc albums are showing more than once in cover
manager.
2020-09-10 21:27:07 +02:00
Jonas Kvinge
2d2ce191ec Change gstreamer libraries in macdeploy 2020-09-10 19:15:06 +02:00
Jonas Kvinge
6380cb8458 Add brew upgrade step in CI 2020-09-10 19:14:33 +02:00
Jonas Kvinge
48e0e6af71 Ignore Radio Paradise "commercial" break for cover and lyrics search 2020-09-10 17:17:55 +02:00
Jonas Kvinge
b756bccc7a Link to iconv to fix compile on Windows 2020-09-10 17:14:14 +02:00
Jonas Kvinge
ae8eed7a67 Add ffmpeg to nsi 2020-09-10 17:12:18 +02:00
Strawbs Bot
ae4882bec3 Update translations 2020-09-10 01:03:26 +02:00
Strawbs Bot
1379741859 Update translations 2020-09-09 01:02:25 +02:00
Jonas Kvinge
b45c7ace78 Fix show equalizer signal slot connect 2020-09-08 18:12:18 +02:00
Strawbs Bot
3843d9f55b Update translations 2020-09-06 01:02:20 +02:00
Jonas Kvinge
f3422cb2fe Call raise() on dialogs to make sure they are on top
Fixes #535
2020-09-05 19:54:21 +02:00
Jonas Kvinge
73692797dc Fix QWidget::enterEvent with Qt 6 2020-09-05 19:20:43 +02:00
Jonas Kvinge
31dd910289 Make sure albums in cover manager are unique
Fixes #529
2020-09-05 18:59:35 +02:00
Jonas Kvinge
da51580299 Fix year - album collection grouping
Fixes #534
2020-09-05 17:26:42 +02:00
Strawbs Bot
9db148b1ec Update translations 2020-09-05 01:03:16 +02:00
Jonas Kvinge
091b1b8209 Use QKeyCombination with Qt 6 2020-09-04 23:00:42 +02:00
Jonas Kvinge
900a4071ed Use bytearray for qChecksum with Qt 6 2020-09-04 21:54:59 +02:00
Jonas Kvinge
df4b2f7938 Add icon for edit tag playlist right click menu actions
Fixes #531
2020-09-04 20:55:57 +02:00
Jonas Kvinge
803f44d9bc Disable use system icons setting for macOS and Windows
Fixes #532
2020-09-04 20:51:43 +02:00
Jonas Kvinge
4b67aee020 Use | operator for QShortcut 2020-09-04 20:43:02 +02:00
Jonas Kvinge
71dc47d6c9 Use deleteLater() when destroying lazy initialized objects
Fixes #530
2020-09-04 20:25:46 +02:00
Strawbs Bot
9cb305fb0d Update translations 2020-09-04 01:02:02 +02:00
Jonas Kvinge
1672130486 Merge compilation off/off
Fixes #528
2020-09-03 19:20:59 +02:00
Jonas Kvinge
8e135e3e79 Set compilation for "Various Artists" in album artist tag too 2020-09-03 19:20:11 +02:00
Jonas Kvinge
aa1a4f6ea5 Update verify icons script 2020-09-03 17:04:40 +02:00
Jonas Kvinge
ba34cf5258 Possible fix for crash when deleting queued songs from playlist
See #527
2020-09-03 16:59:18 +02:00
Strawbs Bot
647089d2a8 Update translations 2020-09-03 01:02:25 +02:00
Jonas Kvinge
5211508eb4 Add multimedia-player-ipod-standard-black.png 2020-09-02 23:20:01 +02:00
Jonas Kvinge
e6f05ae465 Make sure icon exists in GuessIconForPath 2020-09-02 20:40:07 +02:00
Jonas Kvinge
a9193f9b76 Move itdb_device_free 2020-09-02 20:03:22 +02:00
Jonas Kvinge
e373a17cd3 Fallback to device-ipod for ipod icon name 2020-09-02 19:36:47 +02:00
Jonas Kvinge
ebab9b7e4a Delete deviceinfo using parent object 2020-09-02 19:35:13 +02:00
Jonas Kvinge
6de0399807 Guess icon for device in udisks2 lister 2020-09-02 19:34:46 +02:00
Strawbs Bot
5cc7bb80f6 Update translations 2020-09-02 01:11:51 +02:00
Jonas Kvinge
6e0bd9b3f8 Add override to LastFMImportDialog::closeEvent() 2020-09-01 22:27:34 +02:00
Jonas Kvinge
d1943f72d3 Remove use of Qt::AA_UseHighDpiPixmaps with Qt 6 2020-09-01 21:05:07 +02:00
Jonas Kvinge
81709873bd Use art_manual for itdb thumbnail 2020-09-01 20:59:19 +02:00
Jonas Kvinge
f6bb7cd8ed Only include Dmg.cmake on macOS 2020-09-01 20:40:14 +02:00
Jonas Kvinge
d1c19e431c Add check for gdk-pixbuf-2.0 2020-09-01 20:27:05 +02:00
Jonas Kvinge
9ab2dde8ab Read tumbnails from itdb tracks 2020-09-01 01:04:01 +02:00
Jonas Kvinge
71559bb125 Turn pretty covers on by default in collection model 2020-09-01 01:02:02 +02:00
Strawbs Bot
ae4c95262c Update translations 2020-09-01 01:01:45 +02:00
Jonas Kvinge
dbbf07c9c1 Specify JPG when saving cover to temp file for iPod's 2020-08-31 20:13:53 +02:00
Jonas Kvinge
ab8cd619d5 Save cover image to file before copying to iPod
Fixes #519
2020-08-31 18:38:54 +02:00
Jonas Kvinge
c30ad2819d Disable use of HTML in system tray tooltip on Cinnamon 2020-08-31 18:06:37 +02:00
Jonas Kvinge
311e91797a Update ISSUE_TEMPLATE.md 2020-08-31 17:53:46 +02:00
Jonas Kvinge
52be4df355 Use only one issue template 2020-08-31 17:52:16 +02:00
Jonas Kvinge
0364e81050 Remove mageia from Circle CI 2020-08-31 17:15:31 +02:00
Jonas Kvinge
2d49b71bc9 Read song creation time from subsonic API
Fixes #526
2020-08-31 17:05:09 +02:00
Jonas Kvinge
a18a4bdf31 Set wordwrap 2020-08-31 16:25:01 +02:00
Strawbs Bot
d3acbe8288 Update translations 2020-08-31 01:04:42 +02:00
Jonas Kvinge
22afcbcbb6 Only allow playlist editing if song is editable
Set proper flags in model instead of overriding edit in view.

Proper fix for #524
2020-08-30 22:23:38 +02:00
Jonas Kvinge
495c6bc21c Remove unused StyleHelper::drawIconWithShadow function 2020-08-30 21:51:26 +02:00
Jonas Kvinge
cfd1fe59f3 Only allow playlist editing if song is editable.
Fixes #524
2020-08-30 21:40:04 +02:00
Jonas Kvinge
c46cf5bc84 Check for missing lyrics 2020-08-30 21:13:31 +02:00
Jonas Kvinge
a8742557bd Add lyrics from fandom.com 2020-08-30 21:06:58 +02:00
Jonas Kvinge
3bea58cf56 Fix resetting last.fm import dialog on close when finished 2020-08-30 18:28:51 +02:00
Jonas Kvinge
5aaa5231b8 Add Last.fm import
Fixes #247
2020-08-30 18:09:13 +02:00
Jonas Kvinge
82d10dd7cb Remove debug line 2020-08-30 01:59:26 +02:00
Jonas Kvinge
841065fb91 Load icons for buttons before setting enabled/disabled
Fixes #500
2020-08-30 01:57:21 +02:00
Strawbs Bot
c7146ef138 Update translations 2020-08-30 01:02:19 +02:00
Jonas Kvinge
08f32d1de6 Refactor playlist view/header code
- Don't reload all settings when changing playlists
- Fix initial playlist header columns sizes
- Properly reset header state when resetting columns
2020-08-29 19:55:00 +02:00
Jonas Kvinge
4c3f86aa4d Remove use of Qt::AA_EnableHighDpiScaling with Qt 6 2020-08-29 19:18:56 +02:00
Jonas Kvinge
445cf22333 Use deleteLater 2020-08-29 16:24:40 +02:00
Strawbs Bot
4919de647a Update translations 2020-08-28 01:01:40 +02:00
Jonas Kvinge
77fae99528 Fix spacing for sources in scrobbling settings
Fixes #523
2020-08-27 23:36:09 +02:00
Jonas Kvinge
10bd4b40b9 Switch branch for macOS upload 2020-08-27 22:51:34 +02:00
Jonas Kvinge
9d8e6bb253 Merge branch 'macos' into master 2020-08-27 22:50:11 +02:00
Jonas Kvinge
49c71ecfad Update macOS CI 2020-08-27 22:11:19 +02:00
Strawbs Bot
d18834b415 Update translations 2020-08-27 01:02:03 +02:00
Jonas Kvinge
e52cda193e Replace QAbstractItemView::viewOptions with initViewItemOption 2020-08-26 23:35:33 +02:00
Jonas Kvinge
0d5edd35ea Register ColumnAlignmentMap 2020-08-26 22:36:09 +02:00
Strawbs Bot
f3f51c3d9d Update translations 2020-08-26 01:08:17 +02:00
Jonas Kvinge
1431916183 Add setting for enabling scrobbling based on song source
Fixes #416
2020-08-25 23:44:27 +02:00
Jonas Kvinge
ae48008803 Remove use of qRegisterMetaTypeStreamOperators with Qt 6 2020-08-25 22:48:21 +02:00
Jonas Kvinge
5664813931 Remove Mageia from GitHub CI 2020-08-25 21:57:09 +02:00
Jonas Kvinge
3948af80b8 Fix pixelated source icon for currently playing song in playlist 2020-08-25 21:51:23 +02:00
Strawbs Bot
343d6f9aff Update translations 2020-08-24 01:03:49 +02:00
Jonas Kvinge
51b379502f Always use qint32 for QDBusArgument 2020-08-23 21:55:34 +02:00
Jonas Kvinge
82142751de Improve playlist autoscrolling
Fixes #420
2020-08-23 19:37:24 +02:00
Jonas Kvinge
4e5755f218 Refactor some functions 2020-08-23 19:17:50 +02:00
Jonas Kvinge
2f4f29517e Create new contructor for UrlHandler 2020-08-23 18:52:30 +02:00
Strawbs Bot
e8a073651f Update translations 2020-08-23 05:53:13 +02:00
Jonas Kvinge
d23da7a612 Replace Qt::MidButton with Qt::MiddleButton 2020-08-23 03:27:24 +02:00
Jonas Kvinge
1ae4938da3 Register D-Bus metatype for QImage if system has D-Bus 2020-08-23 03:20:53 +02:00
Jonas Kvinge
b5e27d4d69 Declare QDBusArgument for QImage in osddbus.h 2020-08-23 03:19:40 +02:00
Jonas Kvinge
d74fc8d1ce Fix macoOS builds in Travis CI 2020-08-22 14:02:12 +02:00
Jonas Kvinge
c5d9a41967 Remove tumbleweed from CircleCI 2020-08-22 00:27:12 +02:00
Jonas Kvinge
7e3042c4f4 Remove AA_DontShowIconsInMenus
Possible fix for #516
2020-08-21 23:40:44 +02:00
Jonas Kvinge
1291dadbd6 Replace use of QStringRef 2020-08-21 22:39:01 +02:00
Jonas Kvinge
f645099a39 Remove FMPS parser 2020-08-21 22:38:40 +02:00
Jonas Kvinge
8f32038891 Add missing musicstorage include 2020-08-19 22:35:35 +02:00
Jonas Kvinge
a6fb1dcdf9 Add missing QWindow include 2020-08-19 22:35:22 +02:00
Jonas Kvinge
f01b469f3f Allow to delete files permanently in fileview with Qt < 5.15 2020-08-19 22:25:05 +02:00
Jonas Kvinge
47884919c8 Only show delete files option in setting with Qt >= 5.15 2020-08-19 22:11:03 +02:00
Jonas Kvinge
653a35496d Add optional delete from disk in collection and playlist
Fixes #284
2020-08-19 22:02:35 +02:00
Jonas Kvinge
9b14df6b27 Use static_cast in QComboBox::findData 2020-08-16 18:22:10 +02:00
Jonas Kvinge
09813f3c5a Turn back git revision 2020-08-16 03:02:27 +02:00
Jonas Kvinge
7d76b7e4c2 Update protobuf version in nsi 2020-08-15 23:15:51 +02:00
1410 changed files with 152329 additions and 109854 deletions

View File

@@ -1,603 +0,0 @@
version: 2.1
commands:
cmake:
description: Configure build
steps:
- run:
name: Configure build
command: cmake ..
working_directory: build
build_source:
description: Create source tarball
steps:
- run:
name: Create source tarball
command: ../dist/scripts/maketarball.sh
working_directory: build
build_rpm:
description: Build RPM
steps:
- run:
name: Create RPM build sources directories
command: mkdir -p ~/rpmbuild/SOURCES /usr/src/packages/SOURCES
- run:
name: Copy source tarball 1
command: cp strawberry-*.tar.xz ~/rpmbuild/SOURCES/
working_directory: build
- run:
name: Copy source tarball 2
command: cp strawberry-*.tar.xz /usr/src/packages/SOURCES/
working_directory: build
- run:
name: Build RPM
command: rpmbuild -ba ../dist/unix/strawberry.spec
working_directory: build
build_deb:
description: Build Deb
steps:
- run:
name: make deb
command: dpkg-buildpackage -b -d -uc -us -nc -j2
install_opensuse_dependencies:
description: Install openSUSE dependencies
steps:
- run:
name: Update packages
command: zypper --non-interactive --gpg-auto-import-keys ref
- run:
name: Install openSUSE dependencies
command: >
zypper --non-interactive --gpg-auto-import-keys install
lsb-release
rpm-build
git
tar
make
cmake
gcc
gcc-c++
gettext-tools
glibc-devel
libboost_headers-devel
boost-devel
glib2-devel
glib2-tools
dbus-1-devel
alsa-devel
libnotify-devel
libgnutls-devel
protobuf-devel
sqlite3-devel
libpulse-devel
gstreamer-devel
gstreamer-plugins-base-devel
vlc-devel
libQt5Core-devel
libQt5Gui-devel
libQt5Widgets-devel
libQt5Concurrent-devel
libQt5Network-devel
libQt5Sql-devel
libQt5DBus-devel
libQt5Test-devel
libqt5-qtx11extras-devel
libqt5-qtbase-common-devel
libQt5Sql5-sqlite
libqt5-linguist-devel
libcdio-devel
libgpod-devel
libmtp-devel
libchromaprint-devel
desktop-file-utils
update-desktop-files
appstream-glib
hicolor-icon-theme
install_fedora_dependencies:
description: Install Fedora dependencies
steps:
- run:
name: Update packages
command: yum update --assumeyes
- run:
name: Upgrade packages
command: yum upgrade --assumeyes
- run:
name: Install Fedora dependencies
command: >
dnf install --assumeyes
@development-tools
redhat-lsb-core
git
glibc
gcc-c++
rpmdevtools
make
cmake
pkgconfig
glib
man
tar
gettext
openssh
boost-devel
dbus-devel
protobuf-devel
protobuf-compiler
sqlite-devel
alsa-lib-devel
pulseaudio-libs-devel
libnotify-devel
gnutls-devel
qt5-qtbase-devel
qt5-qtx11extras-devel
qt5-qttools-devel
gstreamer1-devel
gstreamer1-plugins-base-devel
taglib-devel
libcdio-devel
libgpod-devel
libmtp-devel
libchromaprint-devel
fftw-devel
desktop-file-utils
libappstream-glib
hicolor-icon-theme
install_centos_dependencies:
description: Install CentOS dependencies
steps:
- run:
name: Install epel-release
command: dnf install -y epel-release
- run:
name: Install epel-release-latest-8.noarch.rpm
command: dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
- run:
name: Install config-manager
command: dnf install -y 'dnf-command(config-manager)'
- run:
name: PowerTools
command: dnf config-manager --set-enabled PowerTools
- run:
name: DNF Clean All
command: dnf clean all
- run:
name: Update packages
command: dnf update -y
- run:
name: Install CentOS dependencies
command: >
dnf install -y
glibc
gcc-c++
make
libtool
cmake3
rpmdevtools
redhat-lsb-core
git
man
tar
gettext
boost-devel
fuse-devel
dbus-devel
libnotify-devel
gnutls-devel
sqlite-devel
protobuf-devel
protobuf-compiler
alsa-lib-devel
pulseaudio-libs-devel
qt5-devel
qt5-qtbase-devel
qt5-qtx11extras-devel
qt5-qttools-devel
fftw-devel
libchromaprint-devel
libcdio-devel
libgpod-devel
libmtp-devel
libjpeg-devel
cairo-devel
dbus-x11
xorg-x11-server-Xvfb
xorg-x11-xauth
vim-common
desktop-file-utils
libappstream-glib
appstream-data
hicolor-icon-theme
python3-pip
python3-devel
gstreamer1-devel
gstreamer1-plugins-base-devel
install_mageia_dependencies:
description: Install Mageia dependencies
steps:
- run:
name: Update packages
command: urpmi.update --auto -a
- run:
name: Configure auto update
command: urpmi --auto --auto-update
- run:
name: Install dependencies
command: >
urpmi --auto --force
urpmi-debuginfo-install
git
tar
rpmdevtools
make
cmake
glibc
binutils
gcc-c++
man
gettext
notification-daemon
dbus-devel
libgnutls-devel
lib64boost-devel
lib64protobuf-devel
protobuf-compiler
lib64sqlite3-devel
lib64alsa2-devel
lib64pulseaudio-devel
lib64notify-devel
lib64qt5core-devel
lib64qt5gui-devel
lib64qt5widgets-devel
lib64qt5network-devel
lib64qt5concurrent-devel
lib64qt5sql-devel
lib64qt5dbus-devel
lib64qt5x11extras-devel
lib64qt5help-devel
libqt5test-devel
lib64gstreamer1.0-devel
lib64gstreamer-plugins-base1.0-devel
lib64cdio-devel
lib64gpod-devel
lib64mtp-devel
lib64raw1394-devel
lib64chromaprint-devel
libfftw-devel
desktop-file-utils
appstream-util
libappstream-glib8
hicolor-icon-theme
qt5ct
lib64mesaegl1
install_debian_dependencies:
description: Install Debian dependencies
steps:
- run:
name: Install Debian dependencies
command: >
apt-get update && apt-get install -y
build-essential
ssh
git
make
cmake
gcc
pkg-config
fakeroot
gettext
lsb-release
libglib2.0-dev
dpkg-dev
libdbus-1-dev
libboost-dev
libprotobuf-dev
protobuf-compiler
libsqlite3-dev
libgnutls28-dev
libasound2-dev
libpulse-dev
qtbase5-dev
qtbase5-dev-tools
qtbase5-private-dev
libqt5x11extras5-dev
qttools5-dev
libgstreamer1.0-dev
libgstreamer-plugins-base1.0-dev
gstreamer1.0-alsa
gstreamer1.0-pulseaudio
libchromaprint-dev
libfftw3-dev
libcdio-dev
libmtp-dev
libgpod-dev
install_ubuntu_dependencies:
description: Install Ubuntu dependencies
steps:
- run:
name: Setup environment
command: |
echo 'export DEBIAN_FRONTEND=noninteractive' >> $BASH_ENV
source $BASH_ENV
- run:
name: Install Ubuntu dependencies
command: >
apt-get update && apt-get install -y
build-essential
ssh
git
make
cmake
pkg-config
gcc
fakeroot
wget
curl
gettext
lsb-release
dpkg-dev
libglib2.0-dev
libboost-dev
libdbus-1-dev
libprotobuf-dev
protobuf-compiler
libsqlite3-dev
libgnutls28-dev
libasound2-dev
libpulse-dev
qtbase5-dev
qtbase5-dev-tools
qtbase5-private-dev
libqt5x11extras5-dev
qttools5-dev
libgstreamer1.0-dev
libgstreamer-plugins-base1.0-dev
libgstreamer-plugins-good1.0-dev
gstreamer1.0-alsa
gstreamer1.0-pulseaudio
libchromaprint-dev
libfftw3-dev
libcdio-dev
libmtp-dev
libgpod-dev
jobs:
build_source:
docker:
- image: opensuse/leap:15.1
steps:
- install_opensuse_dependencies
- checkout
- cmake
- build_source
build_opensuse_tumbleweed:
docker:
- image: opensuse/tumbleweed
environment:
RPM_BUILD_NCPUS: "2"
steps:
- run:
name: Update packages
command: zypper --non-interactive --gpg-auto-import-keys ref
- run:
name: Upgrade packages
command: zypper --non-interactive --gpg-auto-import-keys dup
- install_opensuse_dependencies
- checkout
- cmake
- build_source
- build_rpm
build_opensuse_lp151:
docker:
- image: opensuse/leap:15.1
environment:
RPM_BUILD_NCPUS: "2"
steps:
- install_opensuse_dependencies
- checkout
- cmake
- build_source
- build_rpm
build_opensuse_lp152:
docker:
- image: opensuse/leap:15.2
environment:
RPM_BUILD_NCPUS: "2"
steps:
- install_opensuse_dependencies
- checkout
- cmake
- build_source
- build_rpm
build_fedora_31:
docker:
- image: fedora:31
environment:
RPM_BUILD_NCPUS: "2"
steps:
- install_fedora_dependencies
- checkout
- cmake
- build_source
- build_rpm
build_fedora_32:
docker:
- image: fedora:32
environment:
RPM_BUILD_NCPUS: "2"
steps:
- install_fedora_dependencies
- checkout
- cmake
- build_source
- build_rpm
build_centos_8:
docker:
- image: centos:8
environment:
RPM_BUILD_NCPUS: "2"
steps:
- install_centos_dependencies
- checkout
- cmake
- build_source
- build_rpm
build_mageia_7:
docker:
- image: mageia:7
environment:
RPM_BUILD_NCPUS: "2"
steps:
- install_mageia_dependencies
- checkout
- cmake
- build_source
- build_rpm
build_debian_buster:
docker:
- image: debian:buster
steps:
- install_debian_dependencies
- checkout
- cmake
- build_deb
build_debian_bullseye:
docker:
- image: debian:bullseye
steps:
- install_debian_dependencies
- checkout
- cmake
- build_deb
build_ubuntu_bionic:
docker:
- image: ubuntu:bionic
steps:
- install_ubuntu_dependencies
- checkout
- cmake
- build_deb
build_ubuntu_focal:
docker:
- image: ubuntu:focal
steps:
- install_ubuntu_dependencies
- checkout
- cmake
- build_deb
build_ubuntu_groovy:
docker:
- image: ubuntu:groovy
steps:
- install_ubuntu_dependencies
- checkout
- cmake
- build_deb
workflows:
version: 2
build_all:
jobs:
- build_source:
filters:
tags:
only: /.*/
- build_opensuse_tumbleweed:
filters:
tags:
only: /.*/
- build_opensuse_lp151:
filters:
tags:
only: /.*/
- build_opensuse_lp152:
filters:
tags:
only: /.*/
- build_fedora_31:
filters:
tags:
only: /.*/
- build_fedora_32:
filters:
tags:
only: /.*/
- build_mageia_7:
filters:
tags:
only: /.*/
- build_centos_8:
filters:
tags:
only: /.*/
- build_debian_buster:
filters:
tags:
only: /.*/
- build_debian_bullseye:
filters:
tags:
only: /.*/
- build_ubuntu_bionic:
filters:
tags:
only: /.*/
- build_ubuntu_focal:
filters:
tags:
only: /.*/
- build_ubuntu_groovy:
filters:
tags:
only: /.*/

216
.clang-format Normal file
View File

@@ -0,0 +1,216 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentExternBlock: AfterExternBlock
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 100
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 0
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyBreakComment: 0
PenaltyBreakFirstLessLess: 0
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 0
PenaltyBreakTemplateDeclaration: 0
PenaltyExcessCharacter: 0
PenaltyReturnTypeOnItsOwnLine: 0
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: false
RemoveBracesLLVM: false
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: false
SortJavaStaticImport: Before
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

2
.github/FUNDING.yml vendored
View File

@@ -1 +1,3 @@
github: jonaski
patreon: jonaskvinge
custom: https://paypal.me/jonaskvinge

View File

@@ -7,7 +7,9 @@ assignees: ''
---
For general technical questions and help with technical issues please use the forum on https://forum.strawberrymusicplayer.org/
- [ ] I have checked the [FAQ](https://wiki.strawberrymusicplayer.org/wiki/FAQ) for answers.
- [ ] I have checked the [Changelog](https://github.com/strawberrymusicplayer/strawberry/blob/master/Changelog) that the issue is not already fixed.
- [ ] I believe this issue is a bug, and not a general technical issue, question or feature requests that can be discussed on the [forum](https://forum.strawberrymusicplayer.org/).
**Describe the bug**
A clear and concise description of what the bug is.

1054
.github/workflows/build.yml vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

41
.gitignore vendored
View File

@@ -65,19 +65,6 @@ ui_*.h
*.moc
*.qm
# QtCreator
CMakeLists.txt.user*
*.pro.user
*.pro.user.*
*creator.user*
target_wrapper.*
compile_commands.json
*.kdev4
*.vscode
*.code-workspace
*.sublime-workspace
# Temporary files
*~
*.autosave
@@ -105,17 +92,29 @@ Thumbs.db
# Stuff in dist
maketarball.sh
changelog
PKGBUILD
# Translations
translations.pot
zanata.xml
.zanata-cache/
# Snap
parts/
prime/
stage/
*.snap
/snap/.snapcraft/
/*_source.tar.bz2
# QtCreator
CMakeLists.txt.user*
*.pro.user
*.pro.user.*
*creator.user*
target_wrapper.*
compile_commands.json
*.kdev4
*.vscode
*.code-workspace
*.sublime-workspace
# MSVC
CMakeSettings.json
/.vs
/out
# CLion
/.idea

View File

@@ -1,61 +0,0 @@
sudo: required
language: C++
os:
- osx
services:
- docker
compiler:
- gcc
before_install:
- if ! [ "$DEPLOY_KEY_ENC" == "" ]; then
echo $DEPLOY_KEY_ENC | base64 --decode | openssl aes-256-cbc -K $encrypted_83a41ac424a6_key -iv $encrypted_83a41ac424a6_iv -out ~/.ssh/id_rsa -d ;
chmod 600 ~/.ssh/id_rsa ;
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
docker build -f Dockerfile -t strawberry-build . || travis_terminate 1;
docker run --name build -itd strawberry-build /bin/bash || travis_terminate 1;
docker exec build git clone https://github.com/strawberrymusicplayer/strawberry;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
git fetch --unshallow || travis_terminate 1;
git pull || travis_terminate 1;
brew unlink python@2 || travis_terminate 1;
brew install glib pkgconfig libffi protobuf protobuf-c qt gettext gnutls fftw sqlite chromaprint zlib taglib;
brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav;
brew install libcdio libmtp;
brew install create-dmg;
brew cask install sparkle;
sudo ln -s /usr/local/Caskroom/sparkle/$(ls /usr/local/Caskroom/sparkle | head -n1)/Sparkle.framework /Library/Frameworks/Sparkle.framework;
sudo ln -s /usr/local/Caskroom/sparkle/$(ls /usr/local/Caskroom/sparkle | head -n1)/Sparkle.framework.dSYM /Library/Frameworks/Sparkle.framework.dSYM;
export Qt5_DIR=/usr/local/opt/qt5/lib/cmake;
export Qt5LinguistTools_DIR=/usr/local/opt/qt5/lib/cmake/Qt5LinguistTools;
export PATH="/usr/local/opt/gettext/bin:$PATH";
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig/:/usr/local/opt/zlib/lib/pkgconfig:$PKG_CONFIG_PATH";
ls /usr/local/lib/gstreamer-1.0;
fi
before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build cmake -Hstrawberry -Bbuild ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; cd build; cmake .. -DUSE_BUNDLE=ON ; fi
script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build make -C build -j8 ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
make -j8 || travis_terminate 1;
make install || travis_terminate 1;
make dmg;
fi
after_success:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ls -lh strawberry*.dmg; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC_FOR_BUILD" == "gcc" ]] && [ -f ~/.ssh/id_rsa ]; then
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
rsync -e "ssh -o StrictHostKeyChecking=no" -va strawberry*.dmg travis@echoes.jkvinge.net:/home/travis/builds/macos;
elif [[ "$TRAVIS_BRANCH" == "macos" ]]; then
rsync -e "ssh -o StrictHostKeyChecking=no" -va strawberry*.dmg travis@echoes.jkvinge.net:/home/travis/builds/macos;
fi
fi
branches:
except:
- # Do not build tags that we create when we upload to GitHub Releases
- /^(?i:continuous)$/

42
3rdparty/README.md vendored
View File

@@ -12,31 +12,19 @@ It is included here because it is not packed by distros and is also used on macO
URL: https://github.com/itay-grudev/SingleApplication
taglib
SPMediaKeyTap
-------------
Used on macOS to exclusively enable strawberry to grab global media shortcuts.
Can safely be deleted on other platforms.
macdeployqt
-----------
A modified version of Qt's official macdeployqt utility that fixes some issues,
this version also deploys gstreamer plugins.
Can safely be deleted on other platforms.
getopt
------
TagLib is a library for reading and editing the meta-data of several popular audio formats. It is also used
by Strawberry to identify audio files. It is important that it is kept up-to-date for Strawberry to function
correctly.
It is kept in 3rdparty because there currently is no official release of TagLib with the features and bugfixes
that are in the official repository. And also because some distros use older, or unpatched versions.
There is a bug in the latest version (1.11.1) corrupting Ogg files,
see: https://github.com/taglib/taglib/issues/864
If you decide to use the systems taglib, make sure it has been patched with the following commit:
https://github.com/taglib/taglib/commit/9336c82da3a04552168f208cd7a5fa4646701ea4
The current taglib in 3rdparty also has the following features:
- Audio file detection by content.
- DSF and DSDIFF support
URL: https://github.com/taglib/taglib
utf8-cpp
--------
This is 2 header files used by taglib, but kept in a separate directory because it is maintained by others.
URL: http://utfcpp.sourceforge.net/
getopt included only when compiling with MSVC on Windows.

11
3rdparty/SPMediaKeyTap/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,11 @@
set(SPMEDIAKEY-SOURCES
SPMediaKeyTap.m
)
set(SPMEDIAKEY-HEADERS
SPMediaKeyTap.h
)
ADD_LIBRARY(SPMediaKeyTap STATIC
${SPMEDIAKEY-SOURCES}
)

8
3rdparty/SPMediaKeyTap/LICENSE vendored Normal file
View File

@@ -0,0 +1,8 @@
Copyright (c) 2011, Joachim Bengtsson
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

12
3rdparty/SPMediaKeyTap/README.md vendored Normal file
View File

@@ -0,0 +1,12 @@
SPMediaKeyTap
=============
`SPMediaKeyTap` abstracts a `CGEventHook` and other nastiness in order to give you a relatively simple API to receive media key events (prev/next/playpause, on F7 to F9 on modern MacBook Pros) exclusively, without them reaching other applications like iTunes. `SPMediaKeyTap` is clever enough to resign its exclusive lock on media keys by looking for which application was active most recently: if that application is in `SPMediaKeyTap`'s whitelist, it will resign the keys. This is similar to the behavior of Apple's applications collaborating on media key handling exclusivity, but unfortunately, Apple is not exposing any APIs allowing third-parties to join in on this collaboration.
For now, the whitelist is just a hardcoded array in `+[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers]`. If your app starts using `SPMediaKeyTap`, please [mail me](mailto:nevyn@spotify.com) your bundle ID, and I'll include it in the canonical repository. This is a bad solution; a better solution would be to use distributed notifications to collaborate in creating this whitelist at runtime. Hopefully someone'll have the time and energy to write this soon.
In `Example/SPMediaKeyTapExampleAppDelegate.m` is an example of both how you use `SPMediaKeyTap`, and how you handle the semi-private `NSEvent` subtypes involved in media keys, including on how to fall back to non-event tap handling of these events.
`SPMediaKeyTap` and other `CGEventHook`s on the event type `NSSystemDefined` is known to interfere with each other and applications doing weird stuff with mouse input, because mouse clicks are also part of the `NSSystemDefined` category. The single issue we have had reported here at Spotify is Adobe Fireworks, in which item selection stops working with `SPMediaKeyTap` is active.
`SPMediaKeyTap` requires 10.5 to work, and disables itself on 10.4.

53
3rdparty/SPMediaKeyTap/SPMediaKeyTap.h vendored Normal file
View File

@@ -0,0 +1,53 @@
/*
Copyright (c) 2011, Joachim Bengtsson
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Neither the name of the organization nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Cocoa/Cocoa.h>
#import <IOKit/hidsystem/ev_keymap.h>
// http://overooped.com/post/2593597587/mediakeys
#define SPSystemDefinedEventMediaKeys 8
@interface SPMediaKeyTap : NSObject
- (id)initWithDelegate:(id)delegate;
+ (BOOL)usesGlobalMediaKeyTap;
- (BOOL)startWatchingMediaKeys;
- (void)stopWatchingMediaKeys;
- (void)handleAndReleaseMediaKeyEvent:(NSEvent *)event;
@end
@interface NSObject (SPMediaKeyTapDelegate)
- (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern NSString *kIgnoreMediaKeysDefaultsKey;
#ifdef __cplusplus
}
#endif

361
3rdparty/SPMediaKeyTap/SPMediaKeyTap.m vendored Normal file
View File

@@ -0,0 +1,361 @@
/*
Copyright (c) 2011, Joachim Bengtsson
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Neither the name of the organization nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Copyright (c) 2010 Spotify AB
#import "SPMediaKeyTap.h"
// Define to enable app list debug output
// #define DEBUG_SPMEDIAKEY_APPLIST 1
NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
@interface SPMediaKeyTap () {
CFMachPortRef _eventPort;
CFRunLoopSourceRef _eventPortSource;
CFRunLoopRef _tapThreadRL;
NSThread *_tapThread;
BOOL _shouldInterceptMediaKeyEvents;
id _delegate;
// The app that is frontmost in this list owns media keys
NSMutableArray<NSRunningApplication *> *_mediaKeyAppList;
}
- (BOOL)shouldInterceptMediaKeyEvents;
- (void)setShouldInterceptMediaKeyEvents:(BOOL)newSetting;
- (void)startWatchingAppSwitching;
- (void)stopWatchingAppSwitching;
- (void)eventTapThread;
@end
static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon);
// Inspired by http://gist.github.com/546311
@implementation SPMediaKeyTap
#pragma mark -
#pragma mark Setup and teardown
- (id)initWithDelegate:(id)delegate
{
self = [super init];
if (self) {
_delegate = delegate;
[self startWatchingAppSwitching];
_mediaKeyAppList = [NSMutableArray new];
}
return self;
}
- (void)dealloc
{
[self stopWatchingMediaKeys];
[self stopWatchingAppSwitching];
[super dealloc];
}
- (void)startWatchingAppSwitching
{
// Listen to "app switched" event, so that we don't intercept media keys if we
// weren't the last "media key listening" app to be active
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(frontmostAppChanged:)
name:NSWorkspaceDidActivateApplicationNotification
object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(appTerminated:)
name:NSWorkspaceDidTerminateApplicationNotification
object:nil];
}
- (void)stopWatchingAppSwitching
{
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
}
- (BOOL)startWatchingMediaKeys
{
// Prevent having multiple mediaKeys threads
[self stopWatchingMediaKeys];
[self setShouldInterceptMediaKeyEvents:YES];
// Add an event tap to intercept the system defined media key events
_eventPort = CGEventTapCreate(kCGSessionEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionDefault,
CGEventMaskBit(NX_SYSDEFINED),
tapEventCallback,
(__bridge void * __nullable)(self));
// Can be NULL if the app has no accessibility access permission
if (_eventPort == NULL)
return NO;
_eventPortSource = CFMachPortCreateRunLoopSource(kCFAllocatorSystemDefault, _eventPort, 0);
assert(_eventPortSource != NULL);
if (_eventPortSource == NULL)
return NO;
// Let's do this in a separate thread so that a slow app doesn't lag the event tap
_tapThread = [[NSThread alloc] initWithTarget:self
selector:@selector(eventTapThread)
object:nil];
[_tapThread start];
return YES;
}
- (void)stopWatchingMediaKeys
{
// Shut down tap thread
if(_tapThreadRL){
CFRunLoopStop(_tapThreadRL);
_tapThreadRL = nil;
}
// Remove tap port
if(_eventPort){
CFMachPortInvalidate(_eventPort);
CFRelease(_eventPort);
_eventPort = nil;
}
// Remove tap source
if(_eventPortSource){
CFRelease(_eventPortSource);
_eventPortSource = nil;
}
}
#pragma mark -
#pragma mark Accessors
+ (BOOL)usesGlobalMediaKeyTap
{
#ifdef _DEBUG
// breaking in gdb with a key tap inserted sometimes locks up all mouse and keyboard input forever, forcing reboot
return NO;
#else
// XXX(nevyn): MediaKey event tap doesn't work on 10.4, feel free to figure out why if you have the energy.
return
![[NSUserDefaults standardUserDefaults] boolForKey:kIgnoreMediaKeysDefaultsKey]
&& floor(NSAppKitVersionNumber) >= 949/*NSAppKitVersionNumber10_5*/;
#endif
}
+ (NSArray*)mediaKeyUserBundleIdentifiers
{
return [NSArray arrayWithObjects:
[[NSBundle mainBundle] bundleIdentifier], // your app
@"com.spotify.client",
@"com.apple.iTunes",
@"com.apple.QuickTimePlayerX",
@"com.apple.quicktimeplayer",
@"com.apple.iWork.Keynote",
@"com.apple.iPhoto",
@"org.videolan.vlc",
@"com.apple.Aperture",
@"com.plexsquared.Plex",
@"com.soundcloud.desktop",
@"org.niltsh.MPlayerX",
@"com.ilabs.PandorasHelper",
@"com.mahasoftware.pandabar",
@"com.bitcartel.pandorajam",
@"org.clementine-player.clementine",
@"fm.last.Last.fm",
@"fm.last.Scrobbler",
@"com.beatport.BeatportPro",
@"com.Timenut.SongKey",
@"com.macromedia.fireworks", // the tap messes up their mouse input
@"at.justp.Theremin",
@"ru.ya.themblsha.YandexMusic",
@"com.jriver.MediaCenter18",
@"com.jriver.MediaCenter19",
@"com.jriver.MediaCenter20",
@"co.rackit.mate",
@"com.ttitt.b-music",
@"com.beardedspice.BeardedSpice",
@"com.plug.Plug",
@"com.plug.Plug2",
@"com.netease.163music",
@"org.quodlibet.quodlibet",
nil
];
}
- (BOOL)shouldInterceptMediaKeyEvents
{
BOOL shouldIntercept = NO;
@synchronized(self) {
shouldIntercept = _shouldInterceptMediaKeyEvents;
}
return shouldIntercept;
}
- (void)pauseTapOnTapThread:(NSNumber *)yeahno
{
CGEventTapEnable(self->_eventPort, [yeahno boolValue]);
}
- (void)setShouldInterceptMediaKeyEvents:(BOOL)newSetting
{
BOOL oldSetting;
@synchronized(self) {
oldSetting = _shouldInterceptMediaKeyEvents;
_shouldInterceptMediaKeyEvents = newSetting;
}
if(_tapThreadRL && oldSetting != newSetting) {
[self performSelector:@selector(pauseTapOnTapThread:)
onThread:_tapThread
withObject:@(newSetting)
waitUntilDone:NO];
}
}
#pragma mark -
#pragma mark Event tap callbacks
// Note: method called on background thread
static CGEventRef tapEventCallback2(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
{
#pragma unused(proxy)
SPMediaKeyTap *self = (__bridge SPMediaKeyTap *)refcon;
if(type == kCGEventTapDisabledByTimeout) {
NSLog(@"Media key event tap was disabled by timeout");
CGEventTapEnable(self->_eventPort, TRUE);
return event;
} else if(type == kCGEventTapDisabledByUserInput) {
// Was disabled manually by -[pauseTapOnTapThread]
return event;
}
NSEvent *nsEvent = nil;
@try {
nsEvent = [NSEvent eventWithCGEvent:event];
}
@catch (NSException * e) {
NSLog(@"Strange CGEventType: %d: %@", type, e);
assert(0);
return event;
}
if (type != NX_SYSDEFINED || [nsEvent subtype] != SPSystemDefinedEventMediaKeys)
return event;
int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);
if (keyCode != NX_KEYTYPE_PLAY && keyCode != NX_KEYTYPE_FAST && keyCode != NX_KEYTYPE_REWIND && keyCode != NX_KEYTYPE_PREVIOUS && keyCode != NX_KEYTYPE_NEXT)
return event;
if (![self shouldInterceptMediaKeyEvents])
return event;
[self performSelectorOnMainThread:@selector(handleAndReleaseMediaKeyEvent:) withObject:nsEvent waitUntilDone:NO];
return NULL;
}
static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
{
@autoreleasepool {
CGEventRef ret = tapEventCallback2(proxy, type, event, refcon);
return ret;
}
}
- (void)handleAndReleaseMediaKeyEvent:(NSEvent *)event
{
[_delegate mediaKeyTap:self receivedMediaKeyEvent:event];
}
- (void)eventTapThread
{
_tapThreadRL = CFRunLoopGetCurrent();
CFRunLoopAddSource(_tapThreadRL, _eventPortSource, kCFRunLoopCommonModes);
CFRunLoopRun();
}
#pragma mark -
#pragma mark Task switching callbacks
- (void)mediaKeyAppListChanged
{
#ifdef DEBUG_SPMEDIAKEY_APPLIST
[self debugPrintAppList];
#endif
if([_mediaKeyAppList count] == 0)
return;
NSRunningApplication *thisApp = [NSRunningApplication currentApplication];
NSRunningApplication *otherApp = [_mediaKeyAppList firstObject];
BOOL isCurrent = [thisApp isEqual:otherApp];
[self setShouldInterceptMediaKeyEvents:isCurrent];
}
- (void)frontmostAppChanged:(NSNotification *)notification
{
NSRunningApplication *app = [notification.userInfo objectForKey:NSWorkspaceApplicationKey];
if (app.bundleIdentifier == nil)
return;
if (![[SPMediaKeyTap mediaKeyUserBundleIdentifiers] containsObject:app.bundleIdentifier])
return;
[_mediaKeyAppList removeObject:app];
[_mediaKeyAppList insertObject:app atIndex:0];
[self mediaKeyAppListChanged];
}
- (void)appTerminated:(NSNotification *)notification
{
NSRunningApplication *app = [notification.userInfo objectForKey:NSWorkspaceApplicationKey];
[_mediaKeyAppList removeObject:app];
[self mediaKeyAppListChanged];
}
#ifdef DEBUG_SPMEDIAKEY_APPLIST
- (void)debugPrintAppList
{
NSMutableString *list = [NSMutableString stringWithCapacity:255];
for (NSRunningApplication *app in _mediaKeyAppList) {
[list appendFormat:@" - %@\n", app.bundleIdentifier];
}
NSLog(@"List: \n%@", list);
}
#endif
@end

2
3rdparty/getopt/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
add_library(getopt STATIC getopt.c)
target_include_directories(getopt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

562
3rdparty/getopt/getopt.c vendored Normal file
View File

@@ -0,0 +1,562 @@
/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $ */
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
/*
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
#ifdef REPLACE_GETOPT
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */
#undef optreset /* see getopt.h */
#define optreset __mingw_optreset
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#endif
#define PRINT_ERROR ((opterr) && (*options != ':'))
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
/* return values */
#define BADCH (int)'?'
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#ifndef __CYGWIN__
#define __progname __argv[0]
#else
extern char __declspec(dllimport) *__progname;
#endif
#ifdef __CYGWIN__
static char EMSG[] = "";
#else
#define EMSG ""
#endif
static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int);
static int parse_long_options(char * const *, const char *,
const struct option *, int *, int);
static int gcd(int, int);
static void permute_args(int, int, int, char * const *);
static char *place = EMSG; /* option letter processing */
/* XXX: set optreset to 1 rather than these two */
static int nonopt_start = -1; /* first non option argument (for permute) */
static int nonopt_end = -1; /* first option after non options (for permute) */
/* Error messages */
static const char recargchar[] = "option requires an argument -- %c";
static const char recargstring[] = "option requires an argument -- %s";
static const char ambig[] = "ambiguous option -- %.*s";
static const char noarg[] = "option doesn't take an argument -- %.*s";
static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
static void
_vwarnx(const char *fmt,va_list ap)
{
(void)fprintf(stderr,"%s: ",__progname);
if (fmt != NULL)
(void)vfprintf(stderr,fmt,ap);
(void)fprintf(stderr,"\n");
}
static void
warnx(const char *fmt,...)
{
va_list ap;
va_start(ap,fmt);
_vwarnx(fmt,ap);
va_end(ap);
}
/*
* Compute the greatest common divisor of a and b.
*/
static int
gcd(int a, int b)
{
int c;
c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return (b);
}
/*
* Exchange the block from nonopt_start to nonopt_end with the block
* from nonopt_end to opt_end (keeping the same order of arguments
* in each block).
*/
static void
permute_args(int panonopt_start, int panonopt_end, int opt_end,
char * const *nargv)
{
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
char *swap;
/*
* compute lengths of blocks and number and size of cycles
*/
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts, nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end+i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
/* LINTED const cast */
((char **) nargv)[pos] = nargv[cstart];
/* LINTED const cast */
((char **)nargv)[cstart] = swap;
}
}
}
/*
* parse_long_options --
* Parse long options in argc/argv argument vector.
* Returns -1 if short_too is set and the option does not match long_options.
*/
static int
parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
size_t current_argv_len;
int i, ambiguous, match;
#define IDENTICAL_INTERPRETATION(_x, _y) \
(long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
long_options[(_x)].flag == long_options[(_y)].flag && \
long_options[(_x)].val == long_options[(_y)].val)
current_argv = place;
match = -1;
ambiguous = 0;
optind++;
if ((has_equal = strchr(current_argv, '=')) != NULL) {
/* argument found (--option=arg) */
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
if (strncmp(current_argv, long_options[i].name,
current_argv_len))
continue;
if (strlen(long_options[i].name) == current_argv_len) {
/* exact match */
match = i;
ambiguous = 0;
break;
}
/*
* If this is a known short option, don't allow
* a partial match of a single character.
*/
if (short_too && current_argv_len == 1)
continue;
if (match == -1) /* partial match */
match = i;
else if (!IDENTICAL_INTERPRETATION(i, match))
ambiguous = 1;
}
if (ambiguous) {
/* ambiguous abbreviation */
if (PRINT_ERROR)
warnx(ambig, (int)current_argv_len,
current_argv);
optopt = 0;
return (BADCH);
}
if (match != -1) { /* option found */
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg, (int)current_argv_len,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
return (BADARG);
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
if (has_equal)
optarg = has_equal;
else if (long_options[match].has_arg ==
required_argument) {
/*
* optional argument doesn't use next nargv
*/
optarg = nargv[optind++];
}
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
/*
* Missing argument; leading ':' indicates no error
* should be generated.
*/
if (PRINT_ERROR)
warnx(recargstring,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
--optind;
return (BADARG);
}
} else { /* unknown option */
if (short_too) {
--optind;
return (-1);
}
if (PRINT_ERROR)
warnx(illoptstring, current_argv);
optopt = 0;
return (BADCH);
}
if (idx)
*idx = match;
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
return (0);
} else
return (long_options[match].val);
#undef IDENTICAL_INTERPRETATION
}
/*
* getopt_internal --
* Parse argc/argv argument vector. Called by user level routines.
*/
static int
getopt_internal(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx, int flags)
{
char *oli; /* option letter list index */
int optchar, short_too;
static int posixly_correct = -1;
if (options == NULL)
return (-1);
/*
* XXX Some GNU programs (like cvs) set optind to 0 instead of
* XXX using optreset. Work around this braindamage.
*/
if (optind == 0)
optind = optreset = 1;
/*
* Disable GNU extensions if POSIXLY_CORRECT is set or options
* string begins with a '+'.
*
* CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or
* optreset != 0 for GNU compatibility.
*/
if (posixly_correct == -1 || optreset != 0)
posixly_correct = (GetEnvironmentVariableW(L"POSIXLY_CORRECT", NULL, 0) != 0);
if (*options == '-')
flags |= FLAG_ALLARGS;
else if (posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
if (*options == '+' || *options == '-')
options++;
optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
start:
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc) { /* end of argument vector */
place = EMSG;
if (nonopt_end != -1) {
/* do permutation, if we have to */
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
else if (nonopt_start != -1) {
/*
* If we skipped non-options, set optind
* to the first of them.
*/
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
if (*(place = nargv[optind]) != '-' ||
(place[1] == '\0' && strchr(options, '-') == NULL)) {
place = EMSG; /* found non-option */
if (flags & FLAG_ALLARGS) {
/*
* GNU extension:
* return non-option as argument to option 1
*/
optarg = nargv[optind++];
return (INORDER);
}
if (!(flags & FLAG_PERMUTE)) {
/*
* If no permutation wanted, stop parsing
* at first non-option.
*/
return (-1);
}
/* do permutation */
if (nonopt_start == -1)
nonopt_start = optind;
else if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
nonopt_start = optind -
(nonopt_end - nonopt_start);
nonopt_end = -1;
}
optind++;
/* process next argument */
goto start;
}
if (nonopt_start != -1 && nonopt_end == -1)
nonopt_end = optind;
/*
* If we have "-" do nothing, if "--" we are done.
*/
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
optind++;
place = EMSG;
/*
* We found an option (--), so if we skipped
* non-options, we have to permute.
*/
if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
}
/*
* Check long options if:
* 1) we were passed some
* 2) the arg is not just "-"
* 3) either the arg starts with -- we are getopt_long_only()
*/
if (long_options != NULL && place != nargv[optind] &&
(*place == '-' || (flags & FLAG_LONGONLY))) {
short_too = 0;
if (*place == '-')
place++; /* --foo long option */
else if (*place != ':' && strchr(options, *place) != NULL)
short_too = 1; /* could be short option too */
optchar = parse_long_options(nargv, options, long_options,
idx, short_too);
if (optchar != -1) {
place = EMSG;
return (optchar);
}
}
if ((optchar = (int)*place++) == (int)':' ||
(optchar == (int)'-' && *place != '\0') ||
(oli = strchr(options, optchar)) == NULL) {
/*
* If the user specified "-" and '-' isn't listed in
* options, return -1 (non-option) as per POSIX.
* Otherwise, it is an unknown option character (or ':').
*/
if (optchar == (int)'-' && *place == '\0')
return (-1);
if (!*place)
++optind;
if (PRINT_ERROR)
warnx(illoptchar, optchar);
optopt = optchar;
return (BADCH);
}
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
/* -W long-option */
if (*place) /* no space */
/* NOTHING */;
else if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else /* white space */
place = nargv[optind];
optchar = parse_long_options(nargv, options, long_options,
idx, 0);
place = EMSG;
return (optchar);
}
if (*++oli != ':') { /* doesn't take argument */
if (!*place)
++optind;
} else { /* takes (optional) argument */
optarg = NULL;
if (*place) /* no white space */
optarg = place;
else if (oli[1] != ':') { /* arg not optional */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else
optarg = nargv[optind];
}
place = EMSG;
++optind;
}
/* dump back option letter */
return (optchar);
}
#ifdef REPLACE_GETOPT
/*
* getopt --
* Parse argc/argv argument vector.
*
* [eventually this will replace the BSD getopt]
*/
int
getopt(int nargc, char * const *nargv, const char *options)
{
/*
* We don't pass FLAG_PERMUTE to getopt_internal() since
* the BSD getopt(3) (unlike GNU) has never done this.
*
* Furthermore, since many privileged programs call getopt()
* before dropping privileges it makes sense to keep things
* as simple (and bug-free) as possible.
*/
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
}
#endif /* REPLACE_GETOPT */
/*
* getopt_long --
* Parse argc/argv argument vector.
*/
int
getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE));
}
/*
* getopt_long_only --
* Parse argc/argv argument vector.
*/
int
getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE|FLAG_LONGONLY));
}

95
3rdparty/getopt/getopt.h vendored Normal file
View File

@@ -0,0 +1,95 @@
#ifndef __GETOPT_H__
/**
* DISCLAIMER
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
*
* The mingw-w64 runtime package and its code is distributed in the hope that it
* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#define __GETOPT_H__
/* All the headers include this file. */
#include <crtdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int optind; /* index of first non-option in argv */
extern int optopt; /* single option character, as parsed */
extern int opterr; /* flag to enable built-in diagnostics... */
/* (user may set to zero, to suppress) */
extern char *optarg; /* pointer to argument of current option */
extern int getopt(int nargc, char * const *nargv, const char *options);
#ifdef _BSD_SOURCE
/*
* BSD adds the non-standard `optreset' feature, for reinitialisation
* of `getopt' parsing. We support this feature, for applications which
* proclaim their BSD heritage, before including this header; however,
* to maintain portability, developers are advised to avoid it.
*/
# define optreset __mingw_optreset
extern int optreset;
#endif
#ifdef __cplusplus
}
#endif
/*
* POSIX requires the `getopt' API to be specified in `unistd.h';
* thus, `unistd.h' includes this header. However, we do not want
* to expose the `getopt_long' or `getopt_long_only' APIs, when
* included in this manner. Thus, close the standard __GETOPT_H__
* declarations block, and open an additional __GETOPT_LONG_H__
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
* to declare the extended API.
*/
#endif /* !defined(__GETOPT_H__) */
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
#define __GETOPT_LONG_H__
#ifdef __cplusplus
extern "C" {
#endif
struct option /* specification for a long form option... */
{
const char *name; /* option name, without leading hyphens */
int has_arg; /* does it take an argument? */
int *flag; /* where to save its status, or NULL */
int val; /* its associated status value */
};
enum /* permitted values for its `has_arg' field... */
{
no_argument = 0, /* option never takes an argument */
required_argument, /* option always requires an argument */
optional_argument /* option may take an argument */
};
extern int getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
/*
* Previous MinGW implementation had...
*/
#ifndef HAVE_DECL_GETOPT
/*
* ...for the long form API only; keep this for compatibility.
*/
# define HAVE_DECL_GETOPT 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */

7
3rdparty/macdeployqt/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,7 @@
add_executable(macdeployqt main.cpp shared.cpp)
target_link_libraries(macdeployqt PRIVATE
"-framework AppKit"
${QtCore_LIBRARIES}
)
#execute_process(COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/macdeployqt ${CMAKE_BINARY_DIR})

286
3rdparty/macdeployqt/main.cpp vendored Normal file
View File

@@ -0,0 +1,286 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#undef QT_NO_DEBUG_OUTPUT
#undef QT_NO_WARNING_OUTPUT
#undef QT_NO_INFO_OUTPUT
#include <QCoreApplication>
#include <QDir>
#include <QLibraryInfo>
#include "shared.h"
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QString appBundlePath;
if (argc > 1)
appBundlePath = QString::fromLocal8Bit(argv[1]);
if (argc < 2 || appBundlePath.startsWith("-")) {
qDebug() << "Usage: macdeployqt app-bundle [options]";
qDebug() << "";
qDebug() << "Options:";
qDebug() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug";
qDebug() << " -no-plugins : Skip plugin deployment";
qDebug() << " -dmg : Create a .dmg disk image";
qDebug() << " -no-strip : Don't run 'strip' on the binaries";
qDebug() << " -use-debug-libs : Deploy with debug versions of frameworks and plugins (implies -no-strip)";
qDebug() << " -executable=<path> : Let the given executable use the deployed frameworks too";
qDebug() << " -qmldir=<path> : Scan for QML imports in the given path";
qDebug() << " -qmlimport=<path> : Add the given path to the QML module search locations";
qDebug() << " -always-overwrite : Copy files even if the target file exists";
qDebug() << " -codesign=<ident> : Run codesign with the given identity on all executables";
qDebug() << " -hardened-runtime : Enable Hardened Runtime when code signing";
qDebug() << " -timestamp : Include a secure timestamp when code signing (requires internet connection)";
qDebug() << " -sign-for-notarization=<ident>: Activate the necessary options for notarization (requires internet connection)";
qDebug() << " -appstore-compliant : Skip deployment of components that use private API";
qDebug() << " -libpath=<path> : Add the given path to the library search path";
qDebug() << " -fs=<filesystem> : Set the filesystem used for the .dmg disk image (defaults to HFS+)";
qDebug() << "";
qDebug() << "macdeployqt takes an application bundle as input and makes it";
qDebug() << "self-contained by copying in the Qt frameworks and plugins that";
qDebug() << "the application uses.";
qDebug() << "";
qDebug() << "Plugins related to a framework are copied in with the";
qDebug() << "framework. The accessibility, image formats, and text codec";
qDebug() << "plugins are always copied, unless \"-no-plugins\" is specified.";
qDebug() << "";
qDebug() << "Qt plugins may use private API and will cause the app to be";
qDebug() << "rejected from the Mac App store. MacDeployQt will print a warning";
qDebug() << "when known incompatible plugins are deployed. Use -appstore-compliant ";
qDebug() << "to skip these plugins. Currently two SQL plugins are known to";
qDebug() << "be incompatible: qsqlodbc and qsqlpsql.";
qDebug() << "";
qDebug() << "See the \"Deploying Applications on OS X\" topic in the";
qDebug() << "documentation for more information about deployment on OS X.";
return 1;
}
appBundlePath = QDir::cleanPath(appBundlePath);
if (!QDir(appBundlePath).exists()) {
qDebug() << "Error: Could not find app bundle" << appBundlePath;
return 1;
}
bool plugins = true;
bool dmg = false;
QByteArray filesystem("HFS+");
bool useDebugLibs = false;
extern bool runStripEnabled;
extern bool alwaysOwerwriteEnabled;
extern QStringList librarySearchPath;
QStringList additionalExecutables;
bool qmldirArgumentUsed = false;
QStringList qmlDirs;
QStringList qmlImportPaths;
extern bool runCodesign;
extern QString codesignIdentiy;
extern bool hardenedRuntime;
extern bool appstoreCompliant;
extern bool deployFramework;
extern bool secureTimestamp;
for (int i = 2; i < argc; ++i) {
QByteArray argument = QByteArray(argv[i]);
if (argument == QByteArray("-no-plugins")) {
LogDebug() << "Argument found:" << argument;
plugins = false;
} else if (argument == QByteArray("-dmg")) {
LogDebug() << "Argument found:" << argument;
dmg = true;
} else if (argument == QByteArray("-no-strip")) {
LogDebug() << "Argument found:" << argument;
runStripEnabled = false;
} else if (argument == QByteArray("-use-debug-libs")) {
LogDebug() << "Argument found:" << argument;
useDebugLibs = true;
runStripEnabled = false;
} else if (argument.startsWith(QByteArray("-verbose"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf("=");
bool ok = false;
int number = argument.mid(index+1).toInt(&ok);
if (!ok)
LogError() << "Could not parse verbose level";
else
logLevel = number;
} else if (argument.startsWith(QByteArray("-executable"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
LogError() << "Missing executable path";
else
additionalExecutables << argument.mid(index+1);
} else if (argument.startsWith(QByteArray("-qmldir"))) {
LogDebug() << "Argument found:" << argument;
qmldirArgumentUsed = true;
int index = argument.indexOf('=');
if (index == -1)
LogError() << "Missing qml directory path";
else
qmlDirs << argument.mid(index+1);
} else if (argument.startsWith(QByteArray("-qmlimport"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
LogError() << "Missing qml import path";
else
qmlImportPaths << argument.mid(index+1);
} else if (argument.startsWith(QByteArray("-libpath"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
LogError() << "Missing library search path";
else
librarySearchPath << argument.mid(index+1);
} else if (argument == QByteArray("-always-overwrite")) {
LogDebug() << "Argument found:" << argument;
alwaysOwerwriteEnabled = true;
} else if (argument.startsWith(QByteArray("-codesign"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf("=");
if (index < 0 || index >= argument.size()) {
LogError() << "Missing code signing identity";
} else {
runCodesign = true;
codesignIdentiy = argument.mid(index+1);
}
} else if (argument.startsWith(QByteArray("-sign-for-notarization"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf("=");
if (index < 0 || index >= argument.size()) {
LogError() << "Missing code signing identity";
} else {
runCodesign = true;
hardenedRuntime = true;
secureTimestamp = true;
codesignIdentiy = argument.mid(index+1);
}
} else if (argument.startsWith(QByteArray("-hardened-runtime"))) {
LogDebug() << "Argument found:" << argument;
hardenedRuntime = true;
} else if (argument.startsWith(QByteArray("-timestamp"))) {
LogDebug() << "Argument found:" << argument;
secureTimestamp = true;
} else if (argument == QByteArray("-appstore-compliant")) {
LogDebug() << "Argument found:" << argument;
appstoreCompliant = true;
// Undocumented option, may not work as intended
} else if (argument == QByteArray("-deploy-framework")) {
LogDebug() << "Argument found:" << argument;
deployFramework = true;
} else if (argument.startsWith(QByteArray("-fs"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
LogError() << "Missing filesystem type";
else
filesystem = argument.mid(index+1);
} else if (argument.startsWith("-")) {
LogError() << "Unknown argument" << argument << "\n";
return 1;
}
}
DeploymentInfo deploymentInfo = deployQtFrameworks(appBundlePath, additionalExecutables, useDebugLibs);
if (deploymentInfo.isDebug)
useDebugLibs = true;
if (deployFramework && deploymentInfo.isFramework)
fixupFramework(appBundlePath);
// Convenience: Look for .qml files in the current directory if no -qmldir specified.
if (qmlDirs.isEmpty()) {
QDir dir;
if (!dir.entryList(QStringList() << QStringLiteral("*.qml")).isEmpty()) {
qmlDirs += QStringLiteral(".");
}
}
if (!qmlDirs.isEmpty()) {
bool ok = deployQmlImports(appBundlePath, deploymentInfo, qmlDirs, qmlImportPaths);
if (!ok && qmldirArgumentUsed)
return 1; // exit if the user explicitly asked for qml import deployment
// Update deploymentInfo.deployedFrameworks - the QML imports
// may have brought in extra frameworks as dependencies.
deploymentInfo.deployedFrameworks += findAppFrameworkNames(appBundlePath);
deploymentInfo.deployedFrameworks =
QSet<QString>(deploymentInfo.deployedFrameworks.begin(),
deploymentInfo.deployedFrameworks.end()).values();
}
// Handle plugins
if (plugins) {
// Set the plugins search directory
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
deploymentInfo.pluginPath = QLibraryInfo::path(QLibraryInfo::PluginsPath);
#else
deploymentInfo.pluginPath = QLibraryInfo::location(QLibraryInfo::PluginsPath);
#endif
// Sanity checks
if (deploymentInfo.pluginPath.isEmpty()) {
LogError() << "Missing Qt plugins path\n";
return 1;
}
if (!QDir(deploymentInfo.pluginPath).exists()) {
LogError() << "Plugins path does not exist" << deploymentInfo.pluginPath << "\n";
return 1;
}
// Deploy plugins
Q_ASSERT(!deploymentInfo.pluginPath.isEmpty());
if (!deploymentInfo.pluginPath.isEmpty()) {
LogNormal();
deployPlugins(appBundlePath, deploymentInfo, useDebugLibs);
createQtConf(appBundlePath);
}
}
if (runStripEnabled)
stripAppBinary(appBundlePath);
if (runCodesign)
codesign(codesignIdentiy, appBundlePath);
if (dmg) {
LogNormal();
createDiskImage(appBundlePath, filesystem);
}
return 0;
}

1802
3rdparty/macdeployqt/shared.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

141
3rdparty/macdeployqt/shared.h vendored Normal file
View File

@@ -0,0 +1,141 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef MAC_DEPLOMYMENT_SHARED_H
#define MAC_DEPLOMYMENT_SHARED_H
#include <QString>
#include <QStringList>
#include <QDebug>
#include <QSet>
#include <QVersionNumber>
extern int logLevel;
#define LogError() if (logLevel < 0) {} else qDebug() << "ERROR:"
#define LogWarning() if (logLevel < 1) {} else qDebug() << "WARNING:"
#define LogNormal() if (logLevel < 2) {} else qDebug() << "Log:"
#define LogDebug() if (logLevel < 3) {} else qDebug() << "Log:"
extern bool runStripEnabled;
class FrameworkInfo
{
public:
bool isDylib;
QString frameworkDirectory;
QString frameworkName;
QString frameworkPath;
QString binaryDirectory;
QString binaryName;
QString binaryPath;
QString rpathUsed;
QString version;
QString installName;
QString deployedInstallName;
QString sourceFilePath;
QString frameworkDestinationDirectory;
QString binaryDestinationDirectory;
bool isDebugLibrary() const
{
return binaryName.endsWith(QStringLiteral("_debug"));
}
};
class DylibInfo
{
public:
QString binaryPath;
QVersionNumber currentVersion;
QVersionNumber compatibilityVersion;
};
class OtoolInfo
{
public:
QString installName;
QString binaryPath;
QVersionNumber currentVersion;
QVersionNumber compatibilityVersion;
QList<DylibInfo> dependencies;
};
bool operator==(const FrameworkInfo &a, const FrameworkInfo &b);
QDebug operator<<(QDebug debug, const FrameworkInfo &info);
class ApplicationBundleInfo
{
public:
QString path;
QString binaryPath;
QStringList libraryPaths;
};
class DeploymentInfo
{
public:
QString qtPath;
QString pluginPath;
QStringList deployedFrameworks;
QList<QString> rpathsUsed;
bool useLoaderPath;
bool isFramework;
bool isDebug;
bool containsModule(const QString &module, const QString &libInFix) const;
};
inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info);
OtoolInfo findDependencyInfo(const QString &binaryPath);
FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundlePath, const QList<QString> &rpaths, bool useDebugLibs);
QString findAppBinary(const QString &appBundlePath);
QList<FrameworkInfo> getQtFrameworks(const QString &path, const QString &appBundlePath, const QList<QString> &rpaths, bool useDebugLibs);
QList<FrameworkInfo> getQtFrameworks(const QStringList &otoolLines, const QString &appBundlePath, const QList<QString> &rpaths, bool useDebugLibs);
QString copyFramework(const FrameworkInfo &framework, const QString path);
DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringList &additionalExecutables, bool useDebugLibs);
DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, bool useLoaderPath);
void createQtConf(const QString &appBundlePath);
void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs);
bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs, QStringList &qmlImportPaths);
void changeIdentification(const QString &id, const QString &binaryPath);
void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath);
void runStrip(const QString &binaryPath);
void stripAppBinary(const QString &bundlePath);
QString findAppBinary(const QString &appBundlePath);
QStringList findAppFrameworkNames(const QString &appBundlePath);
QStringList findAppFrameworkPaths(const QString &appBundlePath);
void codesignFile(const QString &identity, const QString &filePath);
QSet<QString> codesignBundle(const QString &identity,
const QString &appBundlePath,
QList<QString> additionalBinariesContainingRpaths);
void codesign(const QString &identity, const QString &appBundlePath);
void createDiskImage(const QString &appBundlePath, const QString &filesystemType);
void fixupFramework(const QString &appBundlePath);
#endif

View File

@@ -1,26 +1,15 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.7)
include(CheckIncludeFiles)
include(CheckFunctionExists)
if(CMAKE_VERSION VERSION_GREATER 3.0)
check_function_exists(geteuid HAVE_GETEUID)
check_function_exists(getpwuid HAVE_GETPWUID)
endif()
check_function_exists(geteuid HAVE_GETEUID)
check_function_exists(getpwuid HAVE_GETPWUID)
set(SINGLEAPP-SOURCES singleapplication.cpp singleapplication_p.cpp)
set(SINGLEAPP-MOC-HEADERS singleapplication.h singleapplication_p.h)
if(WITH_QT6)
qt6_wrap_cpp(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
else()
qt5_wrap_cpp(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
endif()
qt_wrap_cpp(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
add_library(singleapplication STATIC ${SINGLEAPP-SOURCES} ${SINGLEAPP-SOURCES-MOC})
target_include_directories(singleapplication SYSTEM PRIVATE
${QtCore_INCLUDE_DIRS}
${QtWidgets_INCLUDE_DIRS}
${QtNetwork_INCLUDE_DIRS}
)
target_include_directories(singleapplication PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
@@ -33,16 +22,8 @@ target_link_libraries(singleapplication PRIVATE
set(SINGLECOREAPP-SOURCES singlecoreapplication.cpp singlecoreapplication_p.cpp)
set(SINGLECOREAPP-MOC-HEADERS singlecoreapplication.h singlecoreapplication_p.h)
if(WITH_QT6)
qt6_wrap_cpp(SINGLECOREAPP-SOURCES-MOC ${SINGLECOREAPP-MOC-HEADERS})
else()
qt5_wrap_cpp(SINGLECOREAPP-SOURCES-MOC ${SINGLECOREAPP-MOC-HEADERS})
endif()
qt_wrap_cpp(SINGLECOREAPP-SOURCES-MOC ${SINGLECOREAPP-MOC-HEADERS})
add_library(singlecoreapplication STATIC ${SINGLECOREAPP-SOURCES} ${SINGLECOREAPP-SOURCES-MOC})
target_include_directories(singlecoreapplication SYSTEM PRIVATE
${QtCore_INCLUDE_DIRS}
${QtNetwork_INCLUDE_DIRS}
)
target_include_directories(singlecoreapplication PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) Itay Grudev 2015 - 2016
Copyright (c) Itay Grudev 2015 - 2020
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,8 @@
SingleApplication
=================
[![CI](https://github.com/itay-grudev/SingleApplication/workflows/CI:%20Build%20Test/badge.svg)](https://github.com/itay-grudev/SingleApplication/actions)
This is a replacement of the QtSingleApplication for `Qt5`.
This is a replacement of the QtSingleApplication for `Qt5` and `Qt6`.
Keeps the Primary Instance of your Application and kills each subsequent
instances. It can (if enabled) spawn secondary (non-related to the primary)
@@ -15,18 +16,6 @@ class you specify via the `QAPPLICATION_CLASS` macro (`QCoreApplication` is the
default). Further usage is similar to the use of the `Q[Core|Gui]Application`
classes.
The library sets up a `QLocalServer` and a `QSharedMemory` block. The first
instance of your Application is your Primary Instance. It would check if the
shared memory block exists and if not it will start a `QLocalServer` and listen
for connections. Each subsequent instance of your application would check if the
shared memory block exists and if it does, it will connect to the QLocalServer
to notify the primary instance that a new instance had been started, after which
it would terminate with status code `0`. In the Primary Instance
`SingleApplication` would emit the `instanceStarted()` signal upon detecting
that a new instance had been started.
The library uses `stdlib` to terminate the program with the `exit()` function.
You can use the library as if you use any other `QCoreApplication` derived
class:
@@ -43,24 +32,49 @@ int main( int argc, char* argv[] )
```
To include the library files I would recommend that you add it as a git
submodule to your project and include it's contents with a `.pri` file. Here is
how:
submodule to your project. Here is how:
```bash
git submodule add git@github.com:itay-grudev/SingleApplication.git singleapplication
git submodule add https://github.com/itay-grudev/SingleApplication.git singleapplication
```
Then include the `singleapplication.pri` file in your `.pro` project file. Also
don't forget to specify which `QCoreApplication` class your app is using if it
is not `QCoreApplication`.
**Qmake:**
Then include the `singleapplication.pri` file in your `.pro` project file.
```qmake
include(singleapplication/singleapplication.pri)
DEFINES += QAPPLICATION_CLASS=QApplication
```
**CMake:**
Then include the subdirectory in your `CMakeLists.txt` project file.
```cmake
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(src/third-party/singleapplication)
target_link_libraries(${PROJECT_NAME} SingleApplication::SingleApplication)
```
The library sets up a `QLocalServer` and a `QSharedMemory` block. The first
instance of your Application is your Primary Instance. It would check if the
shared memory block exists and if not it will start a `QLocalServer` and listen
for connections. Each subsequent instance of your application would check if the
shared memory block exists and if it does, it will connect to the QLocalServer
to notify the primary instance that a new instance had been started, after which
it would terminate with status code `0`. In the Primary Instance
`SingleApplication` would emit the `instanceStarted()` signal upon detecting
that a new instance had been started.
The library uses `stdlib` to terminate the program with the `exit()` function.
Also don't forget to specify which `QCoreApplication` class your app is using if it
is not `QCoreApplication` as in examples above.
The `Instance Started` signal
------------------------
-----------------------------
The SingleApplication class implements a `instanceStarted()` signal. You can
bind to that signal to raise your application's window when a new instance had
@@ -125,13 +139,22 @@ app.isSecondary();
*__Note:__ If your Primary Instance is terminated a newly launched instance
will replace the Primary one even if the Secondary flag has been set.*
Examples
--------
There are three examples provided in this repository:
* Basic example that prevents a secondary instance from starting [`examples/basic`](https://github.com/itay-grudev/SingleApplication/tree/master/examples/basic)
* An example of a graphical application raising it's parent window [`examples/calculator`](https://github.com/itay-grudev/SingleApplication/tree/master/examples/calculator)
* A console application sending the primary instance it's command line parameters [`examples/sending_arguments`](https://github.com/itay-grudev/SingleApplication/tree/master/examples/sending_arguments)
API
---
### Members
```cpp
SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 100 )
SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 100, QString userData = QString() )
```
Depending on whether `allowSecondary` is set, this constructor may terminate
@@ -140,7 +163,7 @@ can be specified to set whether the SingleApplication block should work
user-wide or system-wide. Additionally the `Mode::SecondaryNotification` may be
used to notify the primary instance whenever a secondary instance had been
started (disabled by default). `timeout` specifies the maximum time in
milliseconds to wait for blocking operations.
milliseconds to wait for blocking operations. Setting `userData` provides additional data that will isolate this instance from other instances that do not have the same (or any) user data set.
*__Note:__ `argc` and `argv` may be changed as Qt removes arguments that it
recognizes.*
@@ -159,7 +182,8 @@ bool SingleApplication::sendMessage( QByteArray message, int timeout = 100 )
```
Sends `message` to the Primary Instance. Uses `timeout` as a the maximum timeout
in milliseconds for blocking functions
in milliseconds for blocking functions. Returns `true` if the message has been sent
successfully. If the message can't be sent or the function timeouts - returns `false`.
---
@@ -192,6 +216,22 @@ qint64 SingleApplication::primaryPid()
Returns the process ID (PID) of the primary instance.
---
```cpp
QString SingleApplication::primaryUser()
```
Returns the username the primary instance is running as.
---
```cpp
QString SingleApplication::currentUser()
```
Returns the username the current instance is running as.
### Signals
```cpp

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2018
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -35,113 +35,131 @@
#include <limits>
#include <QtGlobal>
#include <QCoreApplication>
#include <QApplication>
#include <QThread>
#include <QSharedMemory>
#include <QLocalSocket>
#include <QByteArray>
#include <QElapsedTimer>
#include <QtDebug>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#else
# include <QDateTime>
#endif
#include "singleapplication.h"
#include "singleapplication_p.h"
/**
* @brief Constructor.
* Checks and fires up LocalServer or closes the program if another instance already exists
* @brief Constructor. Checks and fires up LocalServer or closes the program if another instance already exists
* @param argc
* @param argv
* @param {bool} allowSecondaryInstances
* @param allowSecondary Whether to enable secondary instance support
* @param options Optional flags to toggle specific behaviour
* @param timeout Maximum time blocking functions are allowed during app load
*/
SingleApplication::SingleApplication(int &argc, char *argv[], bool allowSecondary, Options options, int timeout)
: app_t(argc, argv), d_ptr(new SingleApplicationPrivate(this)) {
SingleApplication::SingleApplication(int &argc, char *argv[], const bool allowSecondary, const Options options, const int timeout)
: app_t(argc, argv),
d_ptr(new SingleApplicationPrivate(this)) {
Q_D(SingleApplication);
// Store the current mode of the program
d->options = options;
d->options_ = options;
// Generating an application ID used for identifying the shared memory block and QLocalServer
d->genBlockServerName();
// To mitigate QSharedMemory issues with large amount of processes attempting to attach at the same time
SingleApplicationPrivate::randomSleep();
#ifdef Q_OS_UNIX
// By explicitly attaching it and then deleting it we make sure that the
// memory is deleted even after the process has crashed on Unix.
d->memory = new QSharedMemory(d->blockServerName);
d->memory->attach();
delete d->memory;
// By explicitly attaching it and then deleting it we make sure that the memory is deleted even after the process has crashed on Unix.
d->memory_ = new QSharedMemory(d->blockServerName_);
d->memory_->attach();
delete d->memory_;
#endif
// Guarantee thread safe behaviour with a shared memory block.
d->memory = new QSharedMemory(d->blockServerName);
d->memory_ = new QSharedMemory(d->blockServerName_);
// Create a shared memory block
if (d->memory->create(sizeof(InstancesInfo))) {
if (d->memory_->create(sizeof(InstancesInfo))) {
// Initialize the shared memory block
d->memory->lock();
if (!d->memory_->lock()) {
qCritical() << "SingleApplication: Unable to lock memory block after create.";
abortSafely();
}
d->initializeMemoryBlock();
d->memory->unlock();
}
else {
// Attempt to attach to the memory segment
if (! d->memory->attach()) {
qCritical() << "SingleApplication: Unable to attach to shared memory block.";
qCritical() << d->memory->errorString();
delete d;
::exit(EXIT_FAILURE);
if (d->memory_->error() == QSharedMemory::AlreadyExists) {
// Attempt to attach to the memory segment
if (!d->memory_->attach()) {
qCritical() << "SingleApplication: Unable to attach to shared memory block.";
abortSafely();
}
if (!d->memory_->lock()) {
qCritical() << "SingleApplication: Unable to lock memory block after attach.";
abortSafely();
}
}
else {
qCritical() << "SingleApplication: Unable to create block.";
abortSafely();
}
}
InstancesInfo* inst = static_cast<InstancesInfo*>(d->memory->data());
InstancesInfo *instance = static_cast<InstancesInfo*>(d->memory_->data());
QElapsedTimer time;
time.start();
// Make sure the shared memory block is initialised and in consistent state
while (true) {
d->memory->lock();
if (d->blockChecksum() == inst->checksum) break;
forever {
// If the shared memory block's checksum is valid continue
if (d->blockChecksum() == instance->checksum) break;
// If more than 5s have elapsed, assume the primary instance crashed and assume it's position
if (time.elapsed() > 5000) {
qWarning() << "SingleApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure.";
d->initializeMemoryBlock();
}
d->memory->unlock();
// Random sleep here limits the probability of a collision between two racing apps
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QThread::sleep(QRandomGenerator::global()->bounded(8u, 18u));
#else
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
QThread::sleep(8 + static_cast<unsigned long>(static_cast <float>(qrand()) / RAND_MAX * 10));
#endif
// Otherwise wait for a random period and try again.
// The random sleep here limits the probability of a collision between two racing apps and allows the app to initialise faster
if (!d->memory_->unlock()) {
qDebug() << "SingleApplication: Unable to unlock memory for random wait.";
qDebug() << d->memory_->errorString();
}
SingleApplicationPrivate::randomSleep();
if (!d->memory_->lock()) {
qCritical() << "SingleApplication: Unable to lock memory after random wait.";
abortSafely();
}
}
if (inst->primary == false) {
if (!instance->primary) {
d->startPrimary();
d->memory->unlock();
if (!d->memory_->unlock()) {
qDebug() << "SingleApplication: Unable to unlock memory after primary start.";
qDebug() << d->memory_->errorString();
}
return;
}
// Check if another instance can be started
if (allowSecondary) {
inst->secondary += 1;
inst->checksum = d->blockChecksum();
d->instanceNumber = inst->secondary;
d->startSecondary();
if (d->options & Mode::SecondaryNotification) {
if (d->options_ & Mode::SecondaryNotification) {
d->connectToPrimary(timeout, SingleApplicationPrivate::SecondaryInstance);
}
d->memory->unlock();
if (!d->memory_->unlock()) {
qDebug() << "SingleApplication: Unable to unlock memory after secondary start.";
qDebug() << d->memory_->errorString();
}
return;
}
d->memory->unlock();
if (!d->memory_->unlock()) {
qDebug() << "SingleApplication: Unable to unlock memory at end of execution.";
qDebug() << d->memory_->errorString();
}
d->connectToPrimary(timeout, SingleApplicationPrivate::NewInstance);
@@ -151,35 +169,73 @@ SingleApplication::SingleApplication(int &argc, char *argv[], bool allowSecondar
}
/**
* @brief Destructor
*/
SingleApplication::~SingleApplication() {
Q_D(SingleApplication);
delete d;
}
bool SingleApplication::isPrimary() {
Q_D(SingleApplication);
return d->server != nullptr;
/**
* Checks if the current application instance is primary.
* @return Returns true if the instance is primary, false otherwise.
*/
bool SingleApplication::isPrimary() const {
Q_D(const SingleApplication);
return d->server_ != nullptr;
}
bool SingleApplication::isSecondary() {
Q_D(SingleApplication);
return d->server == nullptr;
/**
* Checks if the current application instance is secondary.
* @return Returns true if the instance is secondary, false otherwise.
*/
bool SingleApplication::isSecondary() const {
Q_D(const SingleApplication);
return d->server_ == nullptr;
}
quint32 SingleApplication::instanceId() {
Q_D(SingleApplication);
return d->instanceNumber;
/**
* Allows you to identify an instance by returning unique consecutive instance ids.
* It is reset when the first (primary) instance of your app starts and only incremented afterwards.
* @return Returns a unique instance id.
*/
quint32 SingleApplication::instanceId() const {
Q_D(const SingleApplication);
return d->instanceNumber_;
}
qint64 SingleApplication::primaryPid() {
Q_D(SingleApplication);
/**
* Returns the OS PID (Process Identifier) of the process running the primary instance.
* Especially useful when SingleApplication is coupled with OS. specific APIs.
* @return Returns the primary instance PID.
*/
qint64 SingleApplication::primaryPid() const {
Q_D(const SingleApplication);
return d->primaryPid();
}
bool SingleApplication::sendMessage(QByteArray message, int timeout) {
/**
* Returns the username the primary instance is running as.
* @return Returns the username the primary instance is running as.
*/
QString SingleApplication::primaryUser() const {
Q_D(const SingleApplication);
return d->primaryUser();
}
/**
* Returns the username the current instance is running as.
* @return Returns the username the current instance is running as.
*/
QString SingleApplication::currentUser() const {
return SingleApplicationPrivate::getUsername();
}
/**
* Sends message to the Primary Instance.
* @param message The message to send.
* @param timeout the maximum timeout in milliseconds for blocking functions.
* @return true if the message was sent successfully, false otherwise.
*/
bool SingleApplication::sendMessage(const QByteArray &message, const int timeout) {
Q_D(SingleApplication);
@@ -187,11 +243,24 @@ bool SingleApplication::sendMessage(QByteArray message, int timeout) {
if (isPrimary()) return false;
// Make sure the socket is connected
d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect);
if (!d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect)) {
return false;
}
d->socket->write(message);
bool dataWritten = d->socket->waitForBytesWritten(timeout);
d->socket->flush();
return dataWritten;
return d->writeConfirmedMessage(timeout, message);
}
/**
* Cleans up the shared memory block and exits with a failure.
* This function halts program execution.
*/
void SingleApplication::abortSafely() {
Q_D(SingleApplication);
qCritical() << "SingleApplication: " << d->memory_->error() << d->memory_->errorString();
delete d;
::exit(EXIT_FAILURE);
}

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2018
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,16 +42,15 @@
class SingleApplicationPrivate;
/**
* @brief The SingleApplication class handles multipe instances of the same
* Application
* @see QCoreApplication
* @brief The SingleApplication class handles multiple instances of the same Application
* @see QApplication
*/
class SingleApplication : public QApplication {
class SingleApplication : public QApplication { // clazy:exclude=ctor-missing-parent-argument
Q_OBJECT
typedef QApplication app_t;
using app_t = QApplication;
public:
public:
/**
* @brief Mode of operation of SingleApplication.
* Whether the block should be user-wide or system-wide and whether the
@@ -63,11 +62,11 @@ public:
* @enum
*/
enum Mode {
User = 1 << 0,
System = 1 << 1,
SecondaryNotification = 1 << 2,
ExcludeAppVersion = 1 << 3,
ExcludeAppPath = 1 << 4
User = 1 << 0,
System = 1 << 1,
SecondaryNotification = 1 << 2,
ExcludeAppVersion = 1 << 3,
ExcludeAppPath = 1 << 4
};
Q_DECLARE_FLAGS(Options, Mode)
@@ -89,34 +88,45 @@ public:
* operations. It does not guarantee that the SingleApplication
* initialisation will be completed in given time, though is a good hint.
* Usually 4*timeout would be the worst case (fail) scenario.
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
*/
explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
explicit SingleApplication(int &argc, char *argv[], const bool allowSecondary = false, const Options options = Mode::User, const int timeout = 1000);
~SingleApplication() override;
/**
* @brief Returns if the instance is the primary instance
* @returns {bool}
*/
bool isPrimary();
bool isPrimary() const;
/**
* @brief Returns if the instance is a secondary instance
* @returns {bool}
*/
bool isSecondary();
bool isSecondary() const;
/**
* @brief Returns a unique identifier for the current instance
* @returns {qint32}
*/
quint32 instanceId();
quint32 instanceId() const;
/**
* @brief Returns the process ID (PID) of the primary instance
* @returns {qint64}
*/
qint64 primaryPid();
qint64 primaryPid() const;
/**
* @brief Returns the username of the user running the primary instance
* @returns {QString}
*/
QString primaryUser() const;
/**
* @brief Returns the username of the current user
* @returns {QString}
*/
QString currentUser() const;
/**
* @brief Sends a message to the primary instance. Returns true on success.
@@ -125,18 +135,18 @@ public:
* @note sendMessage() will return false if invoked from the primary
* instance.
*/
bool sendMessage( QByteArray message, int timeout = 1000 );
bool sendMessage(const QByteArray &message, const int timeout = 1000);
signals:
void instanceStarted();
void receivedMessage( quint32 instanceId, QByteArray message );
void receivedMessage(quint32 instanceId, QByteArray message);
private:
SingleApplicationPrivate *d_ptr;
Q_DECLARE_PRIVATE(SingleApplication)
void abortSafely();
};
Q_DECLARE_OPERATORS_FOR_FLAGS(SingleApplication::Options)
#endif // SINGLEAPPLICATION_H
#endif // SINGLEAPPLICATION_H

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2018
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -44,6 +44,16 @@
# include <pwd.h>
#endif
#ifdef Q_OS_WIN
# ifndef NOMINMAX
# define NOMINMAX 1
# endif
# include <windows.h>
# include <lmcons.h>
#endif
#include <QObject>
#include <QThread>
#include <QIODevice>
#include <QSharedMemory>
#include <QByteArray>
@@ -51,60 +61,108 @@
#include <QCryptographicHash>
#include <QLocalServer>
#include <QLocalSocket>
#include <QDir>
#include <QElapsedTimer>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#else
# include <QDateTime>
#endif
#include "singleapplication.h"
#include "singleapplication_p.h"
#ifdef Q_OS_WIN
# include <windows.h>
# include <lmcons.h>
#endif
SingleApplicationPrivate::SingleApplicationPrivate(SingleApplication *_q_ptr)
: q_ptr(_q_ptr),
memory(nullptr),
socket(nullptr),
server(nullptr),
instanceNumber(-1)
{}
SingleApplicationPrivate::SingleApplicationPrivate(SingleApplication *ptr)
: q_ptr(ptr),
memory_(nullptr),
socket_(nullptr),
server_(nullptr),
instanceNumber_(-1) {}
SingleApplicationPrivate::~SingleApplicationPrivate() {
if (socket != nullptr) {
socket->close();
delete socket;
if (socket_ != nullptr) {
socket_->close();
delete socket_;
socket_ = nullptr;
}
memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
if (server != nullptr) {
server->close();
delete server;
inst->primary = false;
inst->primaryPid = -1;
inst->checksum = blockChecksum();
}
memory->unlock();
if (memory_ != nullptr) {
memory_->lock();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
if (server_ != nullptr) {
server_->close();
delete server_;
instance->primary = false;
instance->primaryPid = -1;
instance->primaryUser[0] = '\0';
instance->checksum = blockChecksum();
}
memory_->unlock();
delete memory;
delete memory_;
memory_ = nullptr;
}
}
QString SingleApplicationPrivate::getUsername() {
#ifdef Q_OS_UNIX
QString username;
#if defined(HAVE_GETEUID) && defined(HAVE_GETPWUID)
struct passwd *pw = getpwuid(geteuid());
if (pw) {
username = QString::fromLocal8Bit(pw->pw_name);
}
#endif
if (username.isEmpty()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
username = qEnvironmentVariable("USER");
#else
username = QString::fromLocal8Bit(qgetenv("USER"));
#endif
}
return username;
#endif
#ifdef Q_OS_WIN
wchar_t username[UNLEN + 1];
// Specifies size of the buffer on input
DWORD usernameLength = UNLEN + 1;
if (GetUserNameW(username, &usernameLength)) {
return QString::fromWCharArray(username);
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
return qEnvironmentVariable("USERNAME");
#else
return QString::fromLocal8Bit(qgetenv("USERNAME"));
#endif
#endif
}
void SingleApplicationPrivate::genBlockServerName() {
QCryptographicHash appData(QCryptographicHash::Sha256);
appData.addData("SingleApplication", 17);
appData.addData("SingleApplication");
appData.addData(SingleApplication::app_t::applicationName().toUtf8());
appData.addData(SingleApplication::app_t::organizationName().toUtf8());
appData.addData(SingleApplication::app_t::organizationDomain().toUtf8());
if (!(options & SingleApplication::Mode::ExcludeAppVersion)) {
if (!(options_ & SingleApplication::Mode::ExcludeAppVersion)) {
appData.addData(SingleApplication::app_t::applicationVersion().toUtf8());
}
if (! (options & SingleApplication::Mode::ExcludeAppPath)) {
#ifdef Q_OS_WIN
if (!(options_ & SingleApplication::Mode::ExcludeAppPath)) {
#if defined(Q_OS_UNIX)
const QByteArray appImagePath = qgetenv("APPIMAGE");
if (appImagePath.isEmpty()) {
appData.addData(SingleApplication::app_t::applicationFilePath().toUtf8());
}
else {
appData.addData(appImagePath);
};
#elif defined(Q_OS_WIN)
appData.addData(SingleApplication::app_t::applicationFilePath().toLower().toUtf8());
#else
appData.addData(SingleApplication::app_t::applicationFilePath().toUtf8());
@@ -112,197 +170,235 @@ void SingleApplicationPrivate::genBlockServerName() {
}
// User level block requires a user specific data in the hash
if (options & SingleApplication::Mode::User) {
#ifdef Q_OS_UNIX
QByteArray username;
#if defined(HAVE_GETEUID) && defined(HAVE_GETPWUID)
struct passwd *pw = getpwuid(geteuid());
if (pw) {
username = pw->pw_name;
}
#endif
if (username.isEmpty()) username = qgetenv("USER");
appData.addData(username);
#endif
#ifdef Q_OS_WIN
wchar_t username [ UNLEN + 1 ];
// Specifies size of the buffer on input
DWORD usernameLength = UNLEN + 1;
if (GetUserNameW(username, &usernameLength)) {
appData.addData(QString::fromWCharArray(username).toUtf8());
}
else {
appData.addData(qgetenv("USERNAME"));
}
#endif
if (options_ & SingleApplication::Mode::User) {
appData.addData(getUsername().toUtf8());
}
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with server naming requirements.
blockServerName = appData.result().toBase64().replace("/", "_");
blockServerName_ = appData.result().toBase64().replace("/", "_");
}
void SingleApplicationPrivate::initializeMemoryBlock() {
void SingleApplicationPrivate::initializeMemoryBlock() const {
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
inst->primary = false;
inst->secondary = 0;
inst->primaryPid = -1;
inst->checksum = blockChecksum();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
instance->primary = false;
instance->secondary = 0;
instance->primaryPid = -1;
instance->primaryUser[0] = '\0';
instance->checksum = blockChecksum();
}
void SingleApplicationPrivate::startPrimary() {
Q_Q(SingleApplication);
// Reset the number of connections
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
instance->primary = true;
instance->primaryPid = QCoreApplication::applicationPid();
qstrncpy(instance->primaryUser, getUsername().toUtf8().data(), sizeof(instance->primaryUser));
instance->checksum = blockChecksum();
instanceNumber_ = 0;
// Successful creation means that no main process exists
// So we start a QLocalServer to listen for connections
QLocalServer::removeServer(blockServerName);
server = new QLocalServer();
QLocalServer::removeServer(blockServerName_);
server_ = new QLocalServer();
// Restrict access to the socket according to the
// SingleApplication::Mode::User flag on User level or no restrictions
if (options & SingleApplication::Mode::User) {
server->setSocketOptions(QLocalServer::UserAccessOption);
// Restrict access to the socket according to the SingleApplication::Mode::User flag on User level or no restrictions
if (options_ & SingleApplication::Mode::User) {
server_->setSocketOptions(QLocalServer::UserAccessOption);
}
else {
server->setSocketOptions(QLocalServer::WorldAccessOption);
server_->setSocketOptions(QLocalServer::WorldAccessOption);
}
server->listen(blockServerName);
QObject::connect(server, &QLocalServer::newConnection, this, &SingleApplicationPrivate::slotConnectionEstablished);
// Reset the number of connections
InstancesInfo* inst = static_cast <InstancesInfo*>(memory->data());
inst->primary = true;
inst->primaryPid = q->applicationPid();
inst->checksum = blockChecksum();
instanceNumber = 0;
server_->listen(blockServerName_);
QObject::connect(server_, &QLocalServer::newConnection, this, &SingleApplicationPrivate::slotConnectionEstablished);
}
void SingleApplicationPrivate::startSecondary() {}
void SingleApplicationPrivate::startSecondary() {
void SingleApplicationPrivate::connectToPrimary(const int msecs, const ConnectionType connectionType) {
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
instance->secondary += 1;
instance->checksum = blockChecksum();
instanceNumber_ = instance->secondary;
}
bool SingleApplicationPrivate::connectToPrimary(const int timeout, const ConnectionType connectionType) {
QElapsedTimer time;
time.start();
// Connect to the Local Server of the Primary Instance if not already connected.
if (socket == nullptr) {
socket = new QLocalSocket();
if (socket_ == nullptr) {
socket_ = new QLocalSocket();
}
// If already connected - we are done;
if (socket->state() == QLocalSocket::ConnectedState)
return;
if (socket_->state() == QLocalSocket::ConnectedState) return true;
// If not connect
if (socket->state() == QLocalSocket::UnconnectedState ||
socket->state() == QLocalSocket::ClosingState) {
socket->connectToServer(blockServerName);
}
if (socket_->state() != QLocalSocket::ConnectedState) {
// Wait for being connected
if (socket->state() == QLocalSocket::ConnectingState) {
socket->waitForConnected(msecs);
forever {
randomSleep();
if (socket_->state() != QLocalSocket::ConnectingState) {
socket_->connectToServer(blockServerName_);
}
if (socket_->state() == QLocalSocket::ConnectingState) {
socket_->waitForConnected(static_cast<int>(timeout - time.elapsed()));
}
// If connected break out of the loop
if (socket_->state() == QLocalSocket::ConnectedState) break;
// If elapsed time since start is longer than the method timeout return
if (time.elapsed() >= timeout) return false;
}
}
// Initialisation message according to the SingleApplication protocol
if (socket->state() == QLocalSocket::ConnectedState) {
// Notify the parent that a new instance had been started;
QByteArray initMsg;
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
QByteArray initMsg;
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
writeStream.setVersion(QDataStream::Qt_5_8);
writeStream.setVersion(QDataStream::Qt_5_6);
writeStream << blockServerName_.toLatin1();
writeStream << static_cast<quint8>(connectionType);
writeStream << instanceNumber_;
writeStream << blockServerName.toLatin1();
writeStream << static_cast<quint8>(connectionType);
writeStream << instanceNumber;
quint16 checksum = qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length()));
writeStream << checksum;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
quint16 checksum = qChecksum(QByteArray(initMsg, static_cast<quint32>(initMsg.length())));
#else
quint16 checksum = qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length()));
#endif
// The header indicates the message length that follows
QByteArray header;
QDataStream headerStream(&header, QIODevice::WriteOnly);
writeStream << checksum;
headerStream.setVersion(QDataStream::Qt_5_6);
return writeConfirmedMessage(static_cast<int>(timeout - time.elapsed()), initMsg);
headerStream << static_cast <quint64>(initMsg.length());
}
socket->write(header);
socket->write(initMsg);
socket->flush();
socket->waitForBytesWritten(msecs);
void SingleApplicationPrivate::writeAck(QLocalSocket *sock) {
sock->putChar('\n');
}
bool SingleApplicationPrivate::writeConfirmedMessage(const int timeout, const QByteArray &msg) const {
QElapsedTimer time;
time.start();
// Frame 1: The header indicates the message length that follows
QByteArray header;
QDataStream headerStream(&header, QIODevice::WriteOnly);
headerStream.setVersion(QDataStream::Qt_5_8);
headerStream << static_cast<quint64>(msg.length());
if (!writeConfirmedFrame(static_cast<int>(timeout - time.elapsed()), header)) {
return false;
}
}
quint16 SingleApplicationPrivate::blockChecksum() {
return qChecksum(static_cast <const char *>(memory->data()), offsetof(InstancesInfo, checksum));
// Frame 2: The message
return writeConfirmedFrame(static_cast<int>(timeout - time.elapsed()), msg);
}
qint64 SingleApplicationPrivate::primaryPid() {
bool SingleApplicationPrivate::writeConfirmedFrame(const int timeout, const QByteArray &msg) const {
qint64 pid;
socket_->write(msg);
socket_->flush();
memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
pid = inst->primaryPid;
memory->unlock();
bool result = socket_->waitForReadyRead(timeout);
if (result) {
socket_->read(1);
return true;
}
return false;
}
quint16 SingleApplicationPrivate::blockChecksum() const {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
quint16 checksum = qChecksum(QByteArray(static_cast<const char*>(memory_->constData()), offsetof(InstancesInfo, checksum)));
#else
quint16 checksum = qChecksum(static_cast<const char*>(memory_->constData()), offsetof(InstancesInfo, checksum));
#endif
return checksum;
}
qint64 SingleApplicationPrivate::primaryPid() const {
memory_->lock();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
qint64 pid = instance->primaryPid;
memory_->unlock();
return pid;
}
QString SingleApplicationPrivate::primaryUser() const {
memory_->lock();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
QByteArray username = instance->primaryUser;
memory_->unlock();
return QString::fromUtf8(username);
}
/**
* @brief Executed when a connection has been made to the LocalServer
*/
void SingleApplicationPrivate::slotConnectionEstablished() {
QLocalSocket *nextConnSocket = server->nextPendingConnection();
connectionMap.insert(nextConnSocket, ConnectionInfo());
QLocalSocket *nextConnSocket = server_->nextPendingConnection();
connectionMap_.insert(nextConnSocket, ConnectionInfo());
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
[nextConnSocket, this]() {
auto &info = connectionMap[nextConnSocket];
Q_EMIT this->slotClientConnectionClosed(nextConnSocket, info.instanceId);
}
);
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, this, [nextConnSocket, this]() {
const ConnectionInfo &info = connectionMap_[nextConnSocket];
slotClientConnectionClosed(nextConnSocket, info.instanceId);
});
QObject::connect(nextConnSocket, &QLocalSocket::disconnected,
[nextConnSocket, this](){
connectionMap.remove(nextConnSocket);
nextConnSocket->deleteLater();
}
);
QObject::connect(nextConnSocket, &QLocalSocket::disconnected, nextConnSocket, &QLocalSocket::deleteLater);
QObject::connect(nextConnSocket, &QLocalSocket::readyRead,
[nextConnSocket, this]() {
auto &info = connectionMap[nextConnSocket];
switch(info.stage) {
case StageHeader:
readInitMessageHeader(nextConnSocket);
QObject::connect(nextConnSocket, &QLocalSocket::destroyed, this, [nextConnSocket, this]() {
connectionMap_.remove(nextConnSocket);
});
QObject::connect(nextConnSocket, &QLocalSocket::readyRead, this, [nextConnSocket, this]() {
const ConnectionInfo &info = connectionMap_[nextConnSocket];
switch (info.stage) {
case StageInitHeader:
readMessageHeader(nextConnSocket, StageInitBody);
break;
case StageBody:
case StageInitBody:
readInitMessageBody(nextConnSocket);
break;
case StageConnected:
Q_EMIT this->slotDataAvailable(nextConnSocket, info.instanceId);
case StageConnectedHeader:
readMessageHeader(nextConnSocket, StageConnectedBody);
break;
case StageConnectedBody:
this->slotDataAvailable(nextConnSocket, info.instanceId);
break;
default:
break;
};
}
);
};
});
}
void SingleApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
void SingleApplicationPrivate::readMessageHeader(QLocalSocket *sock, const SingleApplicationPrivate::ConnectionStage nextStage) {
if (!connectionMap.contains(sock)) {
if (!connectionMap_.contains(sock)) {
return;
}
@@ -311,40 +407,42 @@ void SingleApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
}
QDataStream headerStream(sock);
headerStream.setVersion(QDataStream::Qt_5_6);
headerStream.setVersion(QDataStream::Qt_5_8);
// Read the header to know the message length
quint64 msgLen = 0;
headerStream >> msgLen;
ConnectionInfo &info = connectionMap[sock];
info.stage = StageBody;
ConnectionInfo &info = connectionMap_[sock];
info.stage = nextStage;
info.msgLen = msgLen;
if (sock->bytesAvailable() >= static_cast<qint64>(msgLen)) {
readInitMessageBody(sock);
writeAck(sock);
}
bool SingleApplicationPrivate::isFrameComplete(QLocalSocket *sock) {
if (!connectionMap_.contains(sock)) {
return false;
}
const ConnectionInfo &info = connectionMap_[sock];
return (sock->bytesAvailable() >= static_cast<qint64>(info.msgLen));
}
void SingleApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
Q_Q(SingleApplication);
if (!connectionMap.contains(sock)) {
return;
}
ConnectionInfo &info = connectionMap[sock];
if (sock->bytesAvailable() < static_cast<qint64>(info.msgLen)) {
if (!isFrameComplete(sock)) {
return;
}
// Read the message body
QByteArray msgBytes = sock->read(info.msgLen);
QByteArray msgBytes = sock->readAll();
QDataStream readStream(msgBytes);
readStream.setVersion(QDataStream::Qt_5_6);
readStream.setVersion(QDataStream::Qt_5_8);
// server name
QByteArray latin1Name;
@@ -354,7 +452,7 @@ void SingleApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
ConnectionType connectionType = InvalidConnection;
quint8 connTypeVal = InvalidConnection;
readStream >> connTypeVal;
connectionType = static_cast <ConnectionType>(connTypeVal);
connectionType = static_cast<ConnectionType>(connTypeVal);
// instance id
quint32 instanceId = 0;
@@ -364,38 +462,65 @@ void SingleApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
quint16 msgChecksum = 0;
readStream >> msgChecksum;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const quint16 actualChecksum = qChecksum(QByteArray(msgBytes, static_cast<quint32>(msgBytes.length() - sizeof(quint16))));
#else
const quint16 actualChecksum = qChecksum(msgBytes.constData(), static_cast<quint32>(msgBytes.length() - sizeof(quint16)));
#endif
bool isValid = readStream.status() == QDataStream::Ok && QLatin1String(latin1Name) == blockServerName && msgChecksum == actualChecksum;
bool isValid = readStream.status() == QDataStream::Ok && QLatin1String(latin1Name) == blockServerName_ && msgChecksum == actualChecksum;
if (!isValid) {
sock->close();
return;
}
ConnectionInfo &info = connectionMap_[sock];
info.instanceId = instanceId;
info.stage = StageConnected;
info.stage = StageConnectedHeader;
if (connectionType == NewInstance || (connectionType == SecondaryInstance && options & SingleApplication::Mode::SecondaryNotification)) {
Q_EMIT q->instanceStarted();
if (connectionType == NewInstance || (connectionType == SecondaryInstance && options_ & SingleApplication::Mode::SecondaryNotification)) {
emit q->instanceStarted();
}
if (sock->bytesAvailable() > 0) {
Q_EMIT this->slotDataAvailable(sock, instanceId);
}
writeAck(sock);
}
void SingleApplicationPrivate::slotDataAvailable(QLocalSocket *dataSocket, const quint32 instanceId) {
Q_Q(SingleApplication);
Q_EMIT q->receivedMessage(instanceId, dataSocket->readAll());
if (!isFrameComplete(dataSocket)) {
return;
}
const QByteArray message = dataSocket->readAll();
writeAck(dataSocket);
ConnectionInfo &info = connectionMap_[dataSocket];
info.stage = StageConnectedHeader;
emit q->receivedMessage(instanceId, message);
}
void SingleApplicationPrivate::slotClientConnectionClosed(QLocalSocket *closedSocket, const quint32 instanceId) {
if (closedSocket->bytesAvailable() > 0)
Q_EMIT slotDataAvailable(closedSocket, instanceId);
if (closedSocket->bytesAvailable() > 0) {
slotDataAvailable(closedSocket, instanceId);
}
}
void SingleApplicationPrivate::randomSleep() {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QThread::msleep(QRandomGenerator::global()->bounded(8U, 18U));
#else
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
QThread::msleep(qrand() % 11 + 8);
#endif
}

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2016
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +36,8 @@
#include <QtGlobal>
#include <QObject>
#include <QMap>
#include <QString>
#include <QHash>
#include "singleapplication.h"
@@ -48,18 +49,20 @@ struct InstancesInfo {
bool primary;
quint32 secondary;
qint64 primaryPid;
char primaryUser[128];
quint16 checksum;
};
struct ConnectionInfo {
explicit ConnectionInfo() : msgLen(0), instanceId(0), stage(0) {}
qint64 msgLen;
quint64 msgLen;
quint32 instanceId;
quint8 stage;
};
class SingleApplicationPrivate : public QObject {
Q_OBJECT
public:
enum ConnectionType : quint8 {
InvalidConnection = 0,
@@ -68,33 +71,41 @@ class SingleApplicationPrivate : public QObject {
Reconnect = 3
};
enum ConnectionStage : quint8 {
StageHeader = 0,
StageBody = 1,
StageConnected = 2,
StageInitHeader = 0,
StageInitBody = 1,
StageConnectedHeader = 2,
StageConnectedBody = 3,
};
Q_DECLARE_PUBLIC(SingleApplication)
explicit SingleApplicationPrivate(SingleApplication *_q_ptr);
explicit SingleApplicationPrivate(SingleApplication *ptr);
~SingleApplicationPrivate() override;
static QString getUsername();
void genBlockServerName();
void initializeMemoryBlock();
void initializeMemoryBlock() const;
void startPrimary();
void startSecondary();
void connectToPrimary(const int msecs, const ConnectionType connectionType);
quint16 blockChecksum();
qint64 primaryPid();
void readInitMessageHeader(QLocalSocket *socket);
bool connectToPrimary(const int timeout, const ConnectionType connectionType);
quint16 blockChecksum() const;
qint64 primaryPid() const;
QString primaryUser() const;
bool isFrameComplete(QLocalSocket *sock);
void readMessageHeader(QLocalSocket *socket, const ConnectionStage nextStage);
void readInitMessageBody(QLocalSocket *socket);
void writeAck(QLocalSocket *sock);
bool writeConfirmedFrame(const int timeout, const QByteArray &msg) const;
bool writeConfirmedMessage(const int timeout, const QByteArray &msg) const;
static void randomSleep();
SingleApplication *q_ptr;
QSharedMemory *memory;
QLocalSocket *socket;
QLocalServer *server;
quint32 instanceNumber;
QString blockServerName;
SingleApplication::Options options;
QMap<QLocalSocket*, ConnectionInfo> connectionMap;
QSharedMemory *memory_;
QLocalSocket *socket_;
QLocalServer *server_;
quint32 instanceNumber_;
QString blockServerName_;
SingleApplication::Options options_;
QHash<QLocalSocket*, ConnectionInfo> connectionMap_;
public slots:
void slotConnectionEstablished();

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2018
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,106 +42,124 @@
#include <QByteArray>
#include <QElapsedTimer>
#include <QtDebug>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#else
# include <QDateTime>
#endif
#include "singlecoreapplication.h"
#include "singlecoreapplication_p.h"
/**
* @brief Constructor. Checks and fires up LocalServer or closes the program
* if another instance already exists
* @brief Constructor. Checks and fires up LocalServer or closes the program if another instance already exists
* @param argc
* @param argv
* @param {bool} allowSecondaryInstances
* @param allowSecondary Whether to enable secondary instance support
* @param options Optional flags to toggle specific behaviour
* @param timeout Maximum time blocking functions are allowed during app load
*/
SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], bool allowSecondary, Options options, int timeout)
: app_t(argc, argv), d_ptr(new SingleCoreApplicationPrivate(this)) {
SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], const bool allowSecondary, const Options options, const int timeout)
: app_t(argc, argv),
d_ptr(new SingleCoreApplicationPrivate(this)) {
Q_D(SingleCoreApplication);
// Store the current mode of the program
d->options = options;
d->options_ = options;
// Generating an application ID used for identifying the shared memory block and QLocalServer
d->genBlockServerName();
// To mitigate QSharedMemory issues with large amount of processes attempting to attach at the same time
SingleCoreApplicationPrivate::randomSleep();
#ifdef Q_OS_UNIX
// By explicitly attaching it and then deleting it we make sure that the
// memory is deleted even after the process has crashed on Unix.
d->memory = new QSharedMemory(d->blockServerName);
d->memory->attach();
delete d->memory;
// By explicitly attaching it and then deleting it we make sure that the memory is deleted even after the process has crashed on Unix.
d->memory_ = new QSharedMemory(d->blockServerName_);
d->memory_->attach();
delete d->memory_;
#endif
// Guarantee thread safe behaviour with a shared memory block.
d->memory = new QSharedMemory(d->blockServerName);
d->memory_ = new QSharedMemory(d->blockServerName_);
// Create a shared memory block
if (d->memory->create(sizeof(InstancesInfo))) {
if (d->memory_->create(sizeof(InstancesInfo))) {
// Initialize the shared memory block
d->memory->lock();
if (!d->memory_->lock()) {
qCritical() << "SingleCoreApplication: Unable to lock memory block after create.";
abortSafely();
}
d->initializeMemoryBlock();
d->memory->unlock();
}
else {
// Attempt to attach to the memory segment
if (!d->memory->attach()) {
qCritical() << "SingleCoreApplication: Unable to attach to shared memory block.";
qCritical() << d->memory->errorString();
delete d;
::exit(EXIT_FAILURE);
if (d->memory_->error() == QSharedMemory::AlreadyExists) {
// Attempt to attach to the memory segment
if (!d->memory_->attach()) {
qCritical() << "SingleCoreApplication: Unable to attach to shared memory block.";
abortSafely();
}
if (!d->memory_->lock()) {
qCritical() << "SingleCoreApplication: Unable to lock memory block after attach.";
abortSafely();
}
}
else {
qCritical() << "SingleCoreApplication: Unable to create block.";
abortSafely();
}
}
InstancesInfo* inst = static_cast<InstancesInfo*>(d->memory->data());
InstancesInfo *instance = static_cast<InstancesInfo*>(d->memory_->data());
QElapsedTimer time;
time.start();
// Make sure the shared memory block is initialised and in consistent state
while (true) {
d->memory->lock();
if(d->blockChecksum() == inst->checksum) break;
forever {
// If the shared memory block's checksum is valid continue
if (d->blockChecksum() == instance->checksum) break;
// If more than 5s have elapsed, assume the primary instance crashed and assume it's position
if (time.elapsed() > 5000) {
qWarning() << "SingleCoreApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure.";
d->initializeMemoryBlock();
}
d->memory->unlock();
// Random sleep here limits the probability of a collision between two racing apps
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QThread::sleep(QRandomGenerator::global()->bounded(8u, 18u));
#else
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
QThread::sleep(8 + static_cast<unsigned long>(static_cast <float>(qrand()) / RAND_MAX * 10));
#endif
// Otherwise wait for a random period and try again.
// The random sleep here limits the probability of a collision between two racing apps and allows the app to initialise faster
if (!d->memory_->unlock()) {
qDebug() << "SingleCoreApplication: Unable to unlock memory for random wait.";
qDebug() << d->memory_->errorString();
}
SingleCoreApplicationPrivate::randomSleep();
if (!d->memory_->lock()) {
qCritical() << "SingleCoreApplication: Unable to lock memory after random wait.";
abortSafely();
}
}
if (inst->primary == false) {
if (!instance->primary) {
d->startPrimary();
d->memory->unlock();
if (!d->memory_->unlock()) {
qDebug() << "SingleCoreApplication: Unable to unlock memory after primary start.";
qDebug() << d->memory_->errorString();
}
return;
}
// Check if another instance can be started
if (allowSecondary) {
inst->secondary += 1;
inst->checksum = d->blockChecksum();
d->instanceNumber = inst->secondary;
d->startSecondary();
if(d->options & Mode::SecondaryNotification) {
if (d->options_ & Mode::SecondaryNotification) {
d->connectToPrimary(timeout, SingleCoreApplicationPrivate::SecondaryInstance);
}
d->memory->unlock();
if (!d->memory_->unlock()) {
qDebug() << "SingleCoreApplication: Unable to unlock memory after secondary start.";
qDebug() << d->memory_->errorString();
}
return;
}
d->memory->unlock();
if (!d->memory_->unlock()) {
qDebug() << "SingleCoreApplication: Unable to unlock memory at end of execution.";
qDebug() << d->memory_->errorString();
}
d->connectToPrimary(timeout, SingleCoreApplicationPrivate::NewInstance);
@@ -151,47 +169,98 @@ SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], bool allow
}
/**
* @brief Destructor
*/
SingleCoreApplication::~SingleCoreApplication() {
Q_D(SingleCoreApplication);
delete d;
}
bool SingleCoreApplication::isPrimary() {
Q_D(SingleCoreApplication);
return d->server != nullptr;
/**
* Checks if the current application instance is primary.
* @return Returns true if the instance is primary, false otherwise.
*/
bool SingleCoreApplication::isPrimary() const {
Q_D(const SingleCoreApplication);
return d->server_ != nullptr;
}
bool SingleCoreApplication::isSecondary() {
Q_D(SingleCoreApplication);
return d->server == nullptr;
/**
* Checks if the current application instance is secondary.
* @return Returns true if the instance is secondary, false otherwise.
*/
bool SingleCoreApplication::isSecondary() const {
Q_D(const SingleCoreApplication);
return d->server_ == nullptr;
}
quint32 SingleCoreApplication::instanceId() {
Q_D(SingleCoreApplication);
return d->instanceNumber;
/**
* Allows you to identify an instance by returning unique consecutive instance ids.
* It is reset when the first (primary) instance of your app starts and only incremented afterwards.
* @return Returns a unique instance id.
*/
quint32 SingleCoreApplication::instanceId() const {
Q_D(const SingleCoreApplication);
return d->instanceNumber_;
}
qint64 SingleCoreApplication::primaryPid() {
Q_D(SingleCoreApplication);
/**
* Returns the OS PID (Process Identifier) of the process running the primary instance.
* Especially useful when SingleCoreApplication is coupled with OS. specific APIs.
* @return Returns the primary instance PID.
*/
qint64 SingleCoreApplication::primaryPid() const {
Q_D(const SingleCoreApplication);
return d->primaryPid();
}
bool SingleCoreApplication::sendMessage(QByteArray message, int timeout) {
/**
* Returns the username the primary instance is running as.
* @return Returns the username the primary instance is running as.
*/
QString SingleCoreApplication::primaryUser() const {
Q_D(const SingleCoreApplication);
return d->primaryUser();
}
/**
* Returns the username the current instance is running as.
* @return Returns the username the current instance is running as.
*/
QString SingleCoreApplication::currentUser() const {
return SingleCoreApplicationPrivate::getUsername();
}
/**
* Sends message to the Primary Instance.
* @param message The message to send.
* @param timeout the maximum timeout in milliseconds for blocking functions.
* @return true if the message was sent successfully, false otherwise.
*/
bool SingleCoreApplication::sendMessage(const QByteArray &message, const int timeout) {
Q_D(SingleCoreApplication);
// Nobody to connect to
if(isPrimary()) return false;
if (isPrimary()) return false;
// Make sure the socket is connected
d->connectToPrimary(timeout, SingleCoreApplicationPrivate::Reconnect);
if (!d->connectToPrimary(timeout, SingleCoreApplicationPrivate::Reconnect)) {
return false;
}
d->socket->write(message);
bool dataWritten = d->socket->waitForBytesWritten(timeout);
d->socket->flush();
return dataWritten;
return d->writeConfirmedMessage(timeout, message);
}
/**
* Cleans up the shared memory block and exits with a failure.
* This function halts program execution.
*/
void SingleCoreApplication::abortSafely() {
Q_D(SingleCoreApplication);
qCritical() << "SingleCoreApplication: " << d->memory_->error() << d->memory_->errorString();
delete d;
::exit(EXIT_FAILURE);
}

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2018
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -42,16 +42,15 @@
class SingleCoreApplicationPrivate;
/**
* @brief The SingleCoreApplication class handles multiple instances of the same
* Application
* @brief The SingleCoreApplication class handles multiple instances of the same Application
* @see QCoreApplication
*/
class SingleCoreApplication : public QCoreApplication {
class SingleCoreApplication : public QCoreApplication { // clazy:exclude=ctor-missing-parent-argument
Q_OBJECT
typedef QCoreApplication app_t;
using app_t = QCoreApplication;
public:
public:
/**
* @brief Mode of operation of SingleCoreApplication.
* Whether the block should be user-wide or system-wide and whether the
@@ -63,11 +62,11 @@ public:
* @enum
*/
enum Mode {
User = 1 << 0,
System = 1 << 1,
SecondaryNotification = 1 << 2,
ExcludeAppVersion = 1 << 3,
ExcludeAppPath = 1 << 4
User = 1 << 0,
System = 1 << 1,
SecondaryNotification = 1 << 2,
ExcludeAppVersion = 1 << 3,
ExcludeAppPath = 1 << 4
};
Q_DECLARE_FLAGS(Options, Mode)
@@ -89,34 +88,45 @@ public:
* operations. It does not guarantee that the SingleCoreApplication
* initialisation will be completed in given time, though is a good hint.
* Usually 4*timeout would be the worst case (fail) scenario.
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
*/
explicit SingleCoreApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
explicit SingleCoreApplication(int &argc, char *argv[], const bool allowSecondary = false, const Options options = Mode::User, const int timeout = 1000);
~SingleCoreApplication() override;
/**
* @brief Returns if the instance is the primary instance
* @returns {bool}
*/
bool isPrimary();
bool isPrimary() const;
/**
* @brief Returns if the instance is a secondary instance
* @returns {bool}
*/
bool isSecondary();
bool isSecondary() const;
/**
* @brief Returns a unique identifier for the current instance
* @returns {qint32}
*/
quint32 instanceId();
quint32 instanceId() const;
/**
* @brief Returns the process ID (PID) of the primary instance
* @returns {qint64}
*/
qint64 primaryPid();
qint64 primaryPid() const;
/**
* @brief Returns the username of the user running the primary instance
* @returns {QString}
*/
QString primaryUser() const;
/**
* @brief Returns the username of the current user
* @returns {QString}
*/
QString currentUser() const;
/**
* @brief Sends a message to the primary instance. Returns true on success.
@@ -125,17 +135,18 @@ public:
* @note sendMessage() will return false if invoked from the primary
* instance.
*/
bool sendMessage( QByteArray message, int timeout = 1000 );
bool sendMessage(const QByteArray &message, const int timeout = 1000);
signals:
void instanceStarted();
void receivedMessage( quint32 instanceId, QByteArray message );
void receivedMessage(quint32 instanceId, QByteArray message);
private:
private:
SingleCoreApplicationPrivate *d_ptr;
Q_DECLARE_PRIVATE(SingleCoreApplication)
void abortSafely();
};
Q_DECLARE_OPERATORS_FOR_FLAGS(SingleCoreApplication::Options)
#endif // SINGLECOREAPPLICATION_H
#endif // SINGLECOREAPPLICATION_H

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2018
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -44,6 +44,16 @@
# include <pwd.h>
#endif
#ifdef Q_OS_WIN
# ifndef NOMINMAX
# define NOMINMAX 1
# endif
# include <windows.h>
# include <lmcons.h>
#endif
#include <QObject>
#include <QThread>
#include <QIODevice>
#include <QSharedMemory>
#include <QByteArray>
@@ -51,60 +61,108 @@
#include <QCryptographicHash>
#include <QLocalServer>
#include <QLocalSocket>
#include <QDir>
#include <QElapsedTimer>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
# include <QRandomGenerator>
#else
# include <QDateTime>
#endif
#include "singlecoreapplication.h"
#include "singlecoreapplication_p.h"
#ifdef Q_OS_WIN
# include <windows.h>
# include <lmcons.h>
#endif
SingleCoreApplicationPrivate::SingleCoreApplicationPrivate(SingleCoreApplication *_q_ptr)
: q_ptr(_q_ptr),
memory(nullptr),
socket(nullptr),
server(nullptr),
instanceNumber(-1)
{}
SingleCoreApplicationPrivate::SingleCoreApplicationPrivate(SingleCoreApplication *ptr)
: q_ptr(ptr),
memory_(nullptr),
socket_(nullptr),
server_(nullptr),
instanceNumber_(-1) {}
SingleCoreApplicationPrivate::~SingleCoreApplicationPrivate() {
if (socket != nullptr) {
socket->close();
delete socket;
if (socket_ != nullptr) {
socket_->close();
delete socket_;
socket_ = nullptr;
}
memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
if (server != nullptr) {
server->close();
delete server;
inst->primary = false;
inst->primaryPid = -1;
inst->checksum = blockChecksum();
}
memory->unlock();
if (memory_ != nullptr) {
memory_->lock();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
if (server_ != nullptr) {
server_->close();
delete server_;
instance->primary = false;
instance->primaryPid = -1;
instance->primaryUser[0] = '\0';
instance->checksum = blockChecksum();
}
memory_->unlock();
delete memory;
delete memory_;
memory_ = nullptr;
}
}
QString SingleCoreApplicationPrivate::getUsername() {
#ifdef Q_OS_UNIX
QString username;
#if defined(HAVE_GETEUID) && defined(HAVE_GETPWUID)
struct passwd *pw = getpwuid(geteuid());
if (pw) {
username = QString::fromLocal8Bit(pw->pw_name);
}
#endif
if (username.isEmpty()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
username = qEnvironmentVariable("USER");
#else
username = QString::fromLocal8Bit(qgetenv("USER"));
#endif
}
return username;
#endif
#ifdef Q_OS_WIN
wchar_t username[UNLEN + 1];
// Specifies size of the buffer on input
DWORD usernameLength = UNLEN + 1;
if (GetUserNameW(username, &usernameLength)) {
return QString::fromWCharArray(username);
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
return qEnvironmentVariable("USERNAME");
#else
return QString::fromLocal8Bit(qgetenv("USERNAME"));
#endif
#endif
}
void SingleCoreApplicationPrivate::genBlockServerName() {
QCryptographicHash appData(QCryptographicHash::Sha256);
appData.addData("SingleApplication", 17);
appData.addData("SingleApplication");
appData.addData(SingleCoreApplication::app_t::applicationName().toUtf8());
appData.addData(SingleCoreApplication::app_t::organizationName().toUtf8());
appData.addData(SingleCoreApplication::app_t::organizationDomain().toUtf8());
if (!(options & SingleCoreApplication::Mode::ExcludeAppVersion)) {
if (!(options_ & SingleCoreApplication::Mode::ExcludeAppVersion)) {
appData.addData(SingleCoreApplication::app_t::applicationVersion().toUtf8());
}
if (!(options & SingleCoreApplication::Mode::ExcludeAppPath)) {
#ifdef Q_OS_WIN
if (!(options_ & SingleCoreApplication::Mode::ExcludeAppPath)) {
#if defined(Q_OS_UNIX)
const QByteArray appImagePath = qgetenv("APPIMAGE");
if (appImagePath.isEmpty()) {
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toUtf8());
}
else {
appData.addData(appImagePath);
};
#elif defined(Q_OS_WIN)
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toLower().toUtf8());
#else
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toUtf8());
@@ -112,197 +170,235 @@ void SingleCoreApplicationPrivate::genBlockServerName() {
}
// User level block requires a user specific data in the hash
if (options & SingleCoreApplication::Mode::User) {
#ifdef Q_OS_UNIX
QByteArray username;
#if defined(HAVE_GETEUID) && defined(HAVE_GETPWUID)
struct passwd *pw = getpwuid(geteuid());
if (pw) {
username = pw->pw_name;
}
#endif
if (username.isEmpty()) username = qgetenv("USER");
appData.addData(username);
#endif
#ifdef Q_OS_WIN
wchar_t username [ UNLEN + 1 ];
// Specifies size of the buffer on input
DWORD usernameLength = UNLEN + 1;
if (GetUserNameW(username, &usernameLength)) {
appData.addData(QString::fromWCharArray(username).toUtf8());
}
else {
appData.addData(qgetenv("USERNAME"));
}
#endif
if (options_ & SingleCoreApplication::Mode::User) {
appData.addData(getUsername().toUtf8());
}
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with server naming requirements.
blockServerName = appData.result().toBase64().replace("/", "_");
blockServerName_ = appData.result().toBase64().replace("/", "_");
}
void SingleCoreApplicationPrivate::initializeMemoryBlock() {
void SingleCoreApplicationPrivate::initializeMemoryBlock() const {
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
inst->primary = false;
inst->secondary = 0;
inst->primaryPid = -1;
inst->checksum = blockChecksum();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
instance->primary = false;
instance->secondary = 0;
instance->primaryPid = -1;
instance->primaryUser[0] = '\0';
instance->checksum = blockChecksum();
}
void SingleCoreApplicationPrivate::startPrimary() {
Q_Q(SingleCoreApplication);
// Reset the number of connections
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
instance->primary = true;
instance->primaryPid = QCoreApplication::applicationPid();
qstrncpy(instance->primaryUser, getUsername().toUtf8().data(), sizeof(instance->primaryUser));
instance->checksum = blockChecksum();
instanceNumber_ = 0;
// Successful creation means that no main process exists
// So we start a QLocalServer to listen for connections
QLocalServer::removeServer(blockServerName);
server = new QLocalServer();
QLocalServer::removeServer(blockServerName_);
server_ = new QLocalServer();
// Restrict access to the socket according to the
// SingleCoreApplication::Mode::User flag on User level or no restrictions
if (options & SingleCoreApplication::Mode::User) {
server->setSocketOptions(QLocalServer::UserAccessOption);
// Restrict access to the socket according to the SingleCoreApplication::Mode::User flag on User level or no restrictions
if (options_ & SingleCoreApplication::Mode::User) {
server_->setSocketOptions(QLocalServer::UserAccessOption);
}
else {
server->setSocketOptions(QLocalServer::WorldAccessOption);
server_->setSocketOptions(QLocalServer::WorldAccessOption);
}
server->listen(blockServerName);
QObject::connect(server, &QLocalServer::newConnection, this, &SingleCoreApplicationPrivate::slotConnectionEstablished);
// Reset the number of connections
InstancesInfo* inst = static_cast <InstancesInfo*>(memory->data());
inst->primary = true;
inst->primaryPid = q->applicationPid();
inst->checksum = blockChecksum();
instanceNumber = 0;
server_->listen(blockServerName_);
QObject::connect(server_, &QLocalServer::newConnection, this, &SingleCoreApplicationPrivate::slotConnectionEstablished);
}
void SingleCoreApplicationPrivate::startSecondary() {}
void SingleCoreApplicationPrivate::startSecondary() {
void SingleCoreApplicationPrivate::connectToPrimary(const int msecs, const ConnectionType connectionType) {
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
instance->secondary += 1;
instance->checksum = blockChecksum();
instanceNumber_ = instance->secondary;
}
bool SingleCoreApplicationPrivate::connectToPrimary(const int timeout, const ConnectionType connectionType) {
QElapsedTimer time;
time.start();
// Connect to the Local Server of the Primary Instance if not already connected.
if (socket == nullptr) {
socket = new QLocalSocket();
if (socket_ == nullptr) {
socket_ = new QLocalSocket();
}
// If already connected - we are done;
if (socket->state() == QLocalSocket::ConnectedState)
return;
if (socket_->state() == QLocalSocket::ConnectedState) return true;
// If not connect
if (socket->state() == QLocalSocket::UnconnectedState ||
socket->state() == QLocalSocket::ClosingState) {
socket->connectToServer(blockServerName);
}
if (socket_->state() != QLocalSocket::ConnectedState) {
// Wait for being connected
if (socket->state() == QLocalSocket::ConnectingState) {
socket->waitForConnected(msecs);
forever {
randomSleep();
if (socket_->state() != QLocalSocket::ConnectingState) {
socket_->connectToServer(blockServerName_);
}
if (socket_->state() == QLocalSocket::ConnectingState) {
socket_->waitForConnected(static_cast<int>(timeout - time.elapsed()));
}
// If connected break out of the loop
if (socket_->state() == QLocalSocket::ConnectedState) break;
// If elapsed time since start is longer than the method timeout return
if (time.elapsed() >= timeout) return false;
}
}
// Initialisation message according to the SingleCoreApplication protocol
if (socket->state() == QLocalSocket::ConnectedState) {
// Notify the parent that a new instance had been started;
QByteArray initMsg;
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
QByteArray initMsg;
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
writeStream.setVersion(QDataStream::Qt_5_8);
writeStream.setVersion(QDataStream::Qt_5_6);
writeStream << blockServerName_.toLatin1();
writeStream << static_cast<quint8>(connectionType);
writeStream << instanceNumber_;
writeStream << blockServerName.toLatin1();
writeStream << static_cast<quint8>(connectionType);
writeStream << instanceNumber;
quint16 checksum = qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length()));
writeStream << checksum;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
quint16 checksum = qChecksum(QByteArray(initMsg, static_cast<quint32>(initMsg.length())));
#else
quint16 checksum = qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length()));
#endif
// The header indicates the message length that follows
QByteArray header;
QDataStream headerStream(&header, QIODevice::WriteOnly);
writeStream << checksum;
headerStream.setVersion(QDataStream::Qt_5_6);
return writeConfirmedMessage(static_cast<int>(timeout - time.elapsed()), initMsg);
headerStream << static_cast <quint64>(initMsg.length());
}
socket->write(header);
socket->write(initMsg);
socket->flush();
socket->waitForBytesWritten(msecs);
void SingleCoreApplicationPrivate::writeAck(QLocalSocket *sock) {
sock->putChar('\n');
}
bool SingleCoreApplicationPrivate::writeConfirmedMessage(const int timeout, const QByteArray &msg) const {
QElapsedTimer time;
time.start();
// Frame 1: The header indicates the message length that follows
QByteArray header;
QDataStream headerStream(&header, QIODevice::WriteOnly);
headerStream.setVersion(QDataStream::Qt_5_8);
headerStream << static_cast<quint64>(msg.length());
if (!writeConfirmedFrame(static_cast<int>(timeout - time.elapsed()), header)) {
return false;
}
}
quint16 SingleCoreApplicationPrivate::blockChecksum() {
return qChecksum(static_cast <const char*> (memory->data()), offsetof(InstancesInfo, checksum));
// Frame 2: The message
return writeConfirmedFrame(static_cast<int>(timeout - time.elapsed()), msg);
}
qint64 SingleCoreApplicationPrivate::primaryPid() {
bool SingleCoreApplicationPrivate::writeConfirmedFrame(const int timeout, const QByteArray &msg) const {
qint64 pid;
socket_->write(msg);
socket_->flush();
memory->lock();
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
pid = inst->primaryPid;
memory->unlock();
bool result = socket_->waitForReadyRead(timeout);
if (result) {
socket_->read(1);
return true;
}
return false;
}
quint16 SingleCoreApplicationPrivate::blockChecksum() const {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
quint16 checksum = qChecksum(QByteArray(static_cast<const char*>(memory_->constData()), offsetof(InstancesInfo, checksum)));
#else
quint16 checksum = qChecksum(static_cast<const char*>(memory_->constData()), offsetof(InstancesInfo, checksum));
#endif
return checksum;
}
qint64 SingleCoreApplicationPrivate::primaryPid() const {
memory_->lock();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
qint64 pid = instance->primaryPid;
memory_->unlock();
return pid;
}
QString SingleCoreApplicationPrivate::primaryUser() const {
memory_->lock();
InstancesInfo *instance = static_cast<InstancesInfo*>(memory_->data());
QByteArray username = instance->primaryUser;
memory_->unlock();
return QString::fromUtf8(username);
}
/**
* @brief Executed when a connection has been made to the LocalServer
*/
void SingleCoreApplicationPrivate::slotConnectionEstablished() {
QLocalSocket *nextConnSocket = server->nextPendingConnection();
connectionMap.insert(nextConnSocket, ConnectionInfo());
QLocalSocket *nextConnSocket = server_->nextPendingConnection();
connectionMap_.insert(nextConnSocket, ConnectionInfo());
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
[nextConnSocket, this]() {
auto &info = connectionMap[nextConnSocket];
Q_EMIT this->slotClientConnectionClosed(nextConnSocket, info.instanceId);
}
);
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, this, [nextConnSocket, this]() {
const ConnectionInfo &info = connectionMap_[nextConnSocket];
slotClientConnectionClosed(nextConnSocket, info.instanceId);
});
QObject::connect(nextConnSocket, &QLocalSocket::disconnected,
[nextConnSocket, this](){
connectionMap.remove(nextConnSocket);
nextConnSocket->deleteLater();
}
);
QObject::connect(nextConnSocket, &QLocalSocket::disconnected, nextConnSocket, &QLocalSocket::deleteLater);
QObject::connect(nextConnSocket, &QLocalSocket::readyRead,
[nextConnSocket, this]() {
auto &info = connectionMap[nextConnSocket];
switch(info.stage) {
case StageHeader:
readInitMessageHeader(nextConnSocket);
QObject::connect(nextConnSocket, &QLocalSocket::destroyed, this, [nextConnSocket, this]() {
connectionMap_.remove(nextConnSocket);
});
QObject::connect(nextConnSocket, &QLocalSocket::readyRead, this, [nextConnSocket, this]() {
const ConnectionInfo &info = connectionMap_[nextConnSocket];
switch (info.stage) {
case StageInitHeader:
readMessageHeader(nextConnSocket, StageInitBody);
break;
case StageBody:
case StageInitBody:
readInitMessageBody(nextConnSocket);
break;
case StageConnected:
Q_EMIT this->slotDataAvailable(nextConnSocket, info.instanceId);
case StageConnectedHeader:
readMessageHeader(nextConnSocket, StageConnectedBody);
break;
case StageConnectedBody:
this->slotDataAvailable(nextConnSocket, info.instanceId);
break;
default:
break;
};
}
);
};
});
}
void SingleCoreApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
void SingleCoreApplicationPrivate::readMessageHeader(QLocalSocket *sock, SingleCoreApplicationPrivate::ConnectionStage nextStage) {
if (!connectionMap.contains(sock)) {
if (!connectionMap_.contains(sock)) {
return;
}
@@ -311,40 +407,42 @@ void SingleCoreApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
}
QDataStream headerStream(sock);
headerStream.setVersion(QDataStream::Qt_5_6);
headerStream.setVersion(QDataStream::Qt_5_8);
// Read the header to know the message length
quint64 msgLen = 0;
headerStream >> msgLen;
ConnectionInfo &info = connectionMap[sock];
info.stage = StageBody;
ConnectionInfo &info = connectionMap_[sock];
info.stage = nextStage;
info.msgLen = msgLen;
if (sock->bytesAvailable() >= static_cast<qint64>(msgLen)) {
readInitMessageBody(sock);
writeAck(sock);
}
bool SingleCoreApplicationPrivate::isFrameComplete(QLocalSocket *sock) {
if (!connectionMap_.contains(sock)) {
return false;
}
ConnectionInfo &info = connectionMap_[sock];
return (sock->bytesAvailable() >= static_cast<qint64>(info.msgLen));
}
void SingleCoreApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
Q_Q(SingleCoreApplication);
if (!connectionMap.contains(sock)) {
return;
}
ConnectionInfo &info = connectionMap[sock];
if (sock->bytesAvailable() < static_cast<qint64>(info.msgLen)) {
if (!isFrameComplete(sock)) {
return;
}
// Read the message body
QByteArray msgBytes = sock->read(info.msgLen);
QByteArray msgBytes = sock->readAll();
QDataStream readStream(msgBytes);
readStream.setVersion(QDataStream::Qt_5_6);
readStream.setVersion(QDataStream::Qt_5_8);
// server name
QByteArray latin1Name;
@@ -354,7 +452,7 @@ void SingleCoreApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
ConnectionType connectionType = InvalidConnection;
quint8 connTypeVal = InvalidConnection;
readStream >> connTypeVal;
connectionType = static_cast <ConnectionType>(connTypeVal);
connectionType = static_cast<ConnectionType>(connTypeVal);
// instance id
quint32 instanceId = 0;
@@ -364,38 +462,65 @@ void SingleCoreApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
quint16 msgChecksum = 0;
readStream >> msgChecksum;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const quint16 actualChecksum = qChecksum(QByteArray(msgBytes, static_cast<quint32>(msgBytes.length() - sizeof(quint16))));
#else
const quint16 actualChecksum = qChecksum(msgBytes.constData(), static_cast<quint32>(msgBytes.length() - sizeof(quint16)));
#endif
bool isValid = readStream.status() == QDataStream::Ok && QLatin1String(latin1Name) == blockServerName && msgChecksum == actualChecksum;
bool isValid = readStream.status() == QDataStream::Ok && QLatin1String(latin1Name) == blockServerName_ && msgChecksum == actualChecksum;
if (!isValid) {
sock->close();
return;
}
ConnectionInfo &info = connectionMap_[sock];
info.instanceId = instanceId;
info.stage = StageConnected;
info.stage = StageConnectedHeader;
if (connectionType == NewInstance || (connectionType == SecondaryInstance && options & SingleCoreApplication::Mode::SecondaryNotification)) {
Q_EMIT q->instanceStarted();
if (connectionType == NewInstance || (connectionType == SecondaryInstance && options_ & SingleCoreApplication::Mode::SecondaryNotification)) {
emit q->instanceStarted();
}
if (sock->bytesAvailable() > 0) {
Q_EMIT this->slotDataAvailable(sock, instanceId);
}
writeAck(sock);
}
void SingleCoreApplicationPrivate::slotDataAvailable(QLocalSocket *dataSocket, const quint32 instanceId) {
Q_Q(SingleCoreApplication);
Q_EMIT q->receivedMessage(instanceId, dataSocket->readAll());
if (!isFrameComplete(dataSocket)) {
return;
}
const QByteArray message = dataSocket->readAll();
writeAck(dataSocket);
ConnectionInfo &info = connectionMap_[dataSocket];
info.stage = StageConnectedHeader;
emit q->receivedMessage(instanceId, message);
}
void SingleCoreApplicationPrivate::slotClientConnectionClosed(QLocalSocket *closedSocket, const quint32 instanceId) {
if (closedSocket->bytesAvailable() > 0)
Q_EMIT slotDataAvailable(closedSocket, instanceId);
if (closedSocket->bytesAvailable() > 0) {
slotDataAvailable(closedSocket, instanceId);
}
}
void SingleCoreApplicationPrivate::randomSleep() {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QThread::msleep(QRandomGenerator::global()->bounded(8U, 18U));
#else
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
QThread::msleep(qrand() % 11 + 8);
#endif
}

View File

@@ -1,6 +1,6 @@
// The MIT License (MIT)
//
// Copyright (c) Itay Grudev 2015 - 2016
// Copyright (c) Itay Grudev 2015 - 2020
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +36,8 @@
#include <QtGlobal>
#include <QObject>
#include <QMap>
#include <QString>
#include <QHash>
#include "singlecoreapplication.h"
@@ -48,18 +49,20 @@ struct InstancesInfo {
bool primary;
quint32 secondary;
qint64 primaryPid;
char primaryUser[128];
quint16 checksum;
};
struct ConnectionInfo {
explicit ConnectionInfo() : msgLen(0), instanceId(0), stage(0) {}
qint64 msgLen;
quint64 msgLen;
quint32 instanceId;
quint8 stage;
};
class SingleCoreApplicationPrivate : public QObject {
Q_OBJECT
public:
enum ConnectionType : quint8 {
InvalidConnection = 0,
@@ -68,33 +71,41 @@ class SingleCoreApplicationPrivate : public QObject {
Reconnect = 3
};
enum ConnectionStage : quint8 {
StageHeader = 0,
StageBody = 1,
StageConnected = 2,
StageInitHeader = 0,
StageInitBody = 1,
StageConnectedHeader = 2,
StageConnectedBody = 3,
};
Q_DECLARE_PUBLIC(SingleCoreApplication)
explicit SingleCoreApplicationPrivate(SingleCoreApplication *_q_ptr);
explicit SingleCoreApplicationPrivate(SingleCoreApplication *ptr);
~SingleCoreApplicationPrivate() override;
static QString getUsername();
void genBlockServerName();
void initializeMemoryBlock();
void initializeMemoryBlock() const;
void startPrimary();
void startSecondary();
void connectToPrimary(const int msecs, const ConnectionType connectionType);
quint16 blockChecksum();
qint64 primaryPid();
void readInitMessageHeader(QLocalSocket *socket);
bool connectToPrimary(const int timeout, const ConnectionType connectionType);
quint16 blockChecksum() const;
qint64 primaryPid() const;
QString primaryUser() const;
bool isFrameComplete(QLocalSocket *sock);
void readMessageHeader(QLocalSocket *socket, const ConnectionStage nextStage);
void readInitMessageBody(QLocalSocket *socket);
void writeAck(QLocalSocket *sock);
bool writeConfirmedFrame(const int timeout, const QByteArray &msg) const;
bool writeConfirmedMessage(const int timeout, const QByteArray &msg) const;
static void randomSleep();
SingleCoreApplication *q_ptr;
QSharedMemory *memory;
QLocalSocket *socket;
QLocalServer *server;
quint32 instanceNumber;
QString blockServerName;
SingleCoreApplication::Options options;
QMap<QLocalSocket*, ConnectionInfo> connectionMap;
QSharedMemory *memory_;
QLocalSocket *socket_;
QLocalServer *server_;
quint32 instanceNumber_;
QString blockServerName_;
SingleCoreApplication::Options options_;
QHash<QLocalSocket*, ConnectionInfo> connectionMap_;
public slots:
void slotConnectionEstablished();

View File

@@ -1,402 +0,0 @@
cmake_minimum_required(VERSION 3.0)
set(TAGLIB_SOVERSION_CURRENT 17)
set(TAGLIB_SOVERSION_REVISION 0)
set(TAGLIB_SOVERSION_AGE 16)
math(EXPR TAGLIB_SOVERSION_MAJOR "${TAGLIB_SOVERSION_CURRENT} - ${TAGLIB_SOVERSION_AGE}")
math(EXPR TAGLIB_SOVERSION_MINOR "${TAGLIB_SOVERSION_AGE}")
math(EXPR TAGLIB_SOVERSION_PATCH "${TAGLIB_SOVERSION_REVISION}")
include(ConfigureChecks.cmake)
set(TESTS_DIR "${CMAKE_SOURCE_DIR}/tests/taglib/")
configure_file(taglib-config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/taglib-config.h")
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-DTAGLIB_STATIC)
set(tag_HDRS
tag.h
fileref.h
audioproperties.h
taglib_export.h
toolkit/taglib.h
toolkit/tstring.h
toolkit/tlist.h
toolkit/tlist.tcc
toolkit/tstringlist.h
toolkit/tstringhandler.h
toolkit/tbytevector.h
toolkit/tbytevectorlist.h
toolkit/tbytevectorstream.h
toolkit/tiostream.h
toolkit/tfile.h
toolkit/tfilestream.h
toolkit/tmap.h
toolkit/tmap.tcc
toolkit/tpicture.h
toolkit/tpicturemap.h
toolkit/tpropertymap.h
toolkit/trefcounter.h
toolkit/tdebuglistener.h
mpeg/mpegfile.h
mpeg/mpegproperties.h
mpeg/mpegheader.h
mpeg/xingheader.h
mpeg/id3v1/id3v1tag.h
mpeg/id3v1/id3v1genres.h
mpeg/id3v2/id3v2.h
mpeg/id3v2/id3v2extendedheader.h
mpeg/id3v2/id3v2frame.h
mpeg/id3v2/id3v2header.h
mpeg/id3v2/id3v2synchdata.h
mpeg/id3v2/id3v2footer.h
mpeg/id3v2/id3v2framefactory.h
mpeg/id3v2/id3v2tag.h
mpeg/id3v2/frames/attachedpictureframe.h
mpeg/id3v2/frames/commentsframe.h
mpeg/id3v2/frames/eventtimingcodesframe.h
mpeg/id3v2/frames/generalencapsulatedobjectframe.h
mpeg/id3v2/frames/ownershipframe.h
mpeg/id3v2/frames/popularimeterframe.h
mpeg/id3v2/frames/privateframe.h
mpeg/id3v2/frames/relativevolumeframe.h
mpeg/id3v2/frames/synchronizedlyricsframe.h
mpeg/id3v2/frames/textidentificationframe.h
mpeg/id3v2/frames/uniquefileidentifierframe.h
mpeg/id3v2/frames/unknownframe.h
mpeg/id3v2/frames/unsynchronizedlyricsframe.h
mpeg/id3v2/frames/urllinkframe.h
mpeg/id3v2/frames/chapterframe.h
mpeg/id3v2/frames/tableofcontentsframe.h
mpeg/id3v2/frames/podcastframe.h
ogg/oggfile.h
ogg/oggpage.h
ogg/oggpageheader.h
ogg/xiphcomment.h
ogg/vorbis/vorbisfile.h
ogg/vorbis/vorbisproperties.h
ogg/flac/oggflacfile.h
ogg/speex/speexfile.h
ogg/speex/speexproperties.h
ogg/opus/opusfile.h
ogg/opus/opusproperties.h
flac/flacfile.h
flac/flacpicture.h
flac/flacproperties.h
flac/flacmetadatablock.h
ape/apefile.h
ape/apeproperties.h
ape/apetag.h
ape/apefooter.h
ape/apeitem.h
mpc/mpcfile.h
mpc/mpcproperties.h
wavpack/wavpackfile.h
wavpack/wavpackproperties.h
trueaudio/trueaudiofile.h
trueaudio/trueaudioproperties.h
riff/rifffile.h
riff/aiff/aifffile.h
riff/aiff/aiffproperties.h
riff/wav/wavfile.h
riff/wav/wavproperties.h
riff/wav/infotag.h
asf/asffile.h
asf/asfproperties.h
asf/asftag.h
asf/asfattribute.h
asf/asfpicture.h
mp4/mp4file.h
mp4/mp4atom.h
mp4/mp4tag.h
mp4/mp4item.h
mp4/mp4properties.h
mp4/mp4coverart.h
mod/modfilebase.h
mod/modfile.h
mod/modtag.h
mod/modproperties.h
it/itfile.h
it/itproperties.h
s3m/s3mfile.h
s3m/s3mproperties.h
xm/xmfile.h
xm/xmproperties.h
dsf/dsffile.h
dsf/dsfproperties.h
dsdiff/dsdifffile.h
dsdiff/dsdiffproperties.h
dsdiff/dsdiffdiintag.h
)
set(mpeg_SRCS
mpeg/mpegfile.cpp
mpeg/mpegproperties.cpp
mpeg/mpegheader.cpp
mpeg/xingheader.cpp
)
set(id3v1_SRCS
mpeg/id3v1/id3v1tag.cpp
mpeg/id3v1/id3v1genres.cpp
)
set(id3v2_SRCS
mpeg/id3v2/id3v2framefactory.cpp
mpeg/id3v2/id3v2synchdata.cpp
mpeg/id3v2/id3v2tag.cpp
mpeg/id3v2/id3v2header.cpp
mpeg/id3v2/id3v2frame.cpp
mpeg/id3v2/id3v2footer.cpp
mpeg/id3v2/id3v2extendedheader.cpp
)
set(frames_SRCS
mpeg/id3v2/frames/attachedpictureframe.cpp
mpeg/id3v2/frames/commentsframe.cpp
mpeg/id3v2/frames/eventtimingcodesframe.cpp
mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp
mpeg/id3v2/frames/ownershipframe.cpp
mpeg/id3v2/frames/popularimeterframe.cpp
mpeg/id3v2/frames/privateframe.cpp
mpeg/id3v2/frames/relativevolumeframe.cpp
mpeg/id3v2/frames/synchronizedlyricsframe.cpp
mpeg/id3v2/frames/textidentificationframe.cpp
mpeg/id3v2/frames/uniquefileidentifierframe.cpp
mpeg/id3v2/frames/unknownframe.cpp
mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp
mpeg/id3v2/frames/urllinkframe.cpp
mpeg/id3v2/frames/chapterframe.cpp
mpeg/id3v2/frames/tableofcontentsframe.cpp
mpeg/id3v2/frames/podcastframe.cpp
)
set(ogg_SRCS
ogg/oggfile.cpp
ogg/oggpage.cpp
ogg/oggpageheader.cpp
ogg/xiphcomment.cpp
)
set(vorbis_SRCS
ogg/vorbis/vorbisfile.cpp
ogg/vorbis/vorbisproperties.cpp
)
set(flacs_SRCS
flac/flacfile.cpp
flac/flacpicture.cpp
flac/flacproperties.cpp
flac/flacmetadatablock.cpp
flac/flacunknownmetadatablock.cpp
)
set(oggflacs_SRCS
ogg/flac/oggflacfile.cpp
)
set(mpc_SRCS
mpc/mpcfile.cpp
mpc/mpcproperties.cpp
)
set(mp4_SRCS
mp4/mp4file.cpp
mp4/mp4atom.cpp
mp4/mp4tag.cpp
mp4/mp4item.cpp
mp4/mp4properties.cpp
mp4/mp4coverart.cpp
)
set(ape_SRCS
ape/apetag.cpp
ape/apefooter.cpp
ape/apeitem.cpp
ape/apefile.cpp
ape/apeproperties.cpp
)
set(wavpack_SRCS
wavpack/wavpackfile.cpp
wavpack/wavpackproperties.cpp
)
set(speex_SRCS
ogg/speex/speexfile.cpp
ogg/speex/speexproperties.cpp
)
set(opus_SRCS
ogg/opus/opusfile.cpp
ogg/opus/opusproperties.cpp
)
set(trueaudio_SRCS
trueaudio/trueaudiofile.cpp
trueaudio/trueaudioproperties.cpp
)
set(asf_SRCS
asf/asftag.cpp
asf/asffile.cpp
asf/asfproperties.cpp
asf/asfattribute.cpp
asf/asfpicture.cpp
)
set(riff_SRCS
riff/rifffile.cpp
)
set(aiff_SRCS
riff/aiff/aifffile.cpp
riff/aiff/aiffproperties.cpp
)
set(wav_SRCS
riff/wav/wavfile.cpp
riff/wav/wavproperties.cpp
riff/wav/infotag.cpp
)
set(mod_SRCS
mod/modfilebase.cpp
mod/modfile.cpp
mod/modtag.cpp
mod/modproperties.cpp
)
set(s3m_SRCS
s3m/s3mfile.cpp
s3m/s3mproperties.cpp
)
set(it_SRCS
it/itfile.cpp
it/itproperties.cpp
)
set(xm_SRCS
xm/xmfile.cpp
xm/xmproperties.cpp
)
set(dsf_SRCS
dsf/dsffile.cpp
dsf/dsfproperties.cpp
)
set(dsdiff_SRCS
dsdiff/dsdifffile.cpp
dsdiff/dsdiffproperties.cpp
dsdiff/dsdiffdiintag.cpp
)
set(toolkit_SRCS
toolkit/taglib.cpp
toolkit/tstring.cpp
toolkit/tstringlist.cpp
toolkit/tstringhandler.cpp
toolkit/tbytevector.cpp
toolkit/tbytevectorlist.cpp
toolkit/tbytevectorstream.cpp
toolkit/tiostream.cpp
toolkit/tfile.cpp
toolkit/tfilestream.cpp
toolkit/tdebug.cpp
toolkit/tpicture.cpp
toolkit/tpicturemap.cpp
toolkit/tpropertymap.cpp
toolkit/trefcounter.cpp
toolkit/tdebuglistener.cpp
toolkit/tzlib.cpp
)
set(tag_LIB_SRCS
${mpeg_SRCS}
${id3v1_SRCS}
${id3v2_SRCS}
${frames_SRCS}
${ogg_SRCS}
${vorbis_SRCS}
${oggflacs_SRCS}
${mpc_SRCS}
${ape_SRCS}
${toolkit_SRCS}
${flacs_SRCS}
${wavpack_SRCS}
${speex_SRCS}
${trueaudio_SRCS}
${riff_SRCS}
${aiff_SRCS} ${wav_SRCS}
${asf_SRCS}
${mp4_SRCS}
${mod_SRCS}
${s3m_SRCS}
${it_SRCS}
${xm_SRCS}
${opus_SRCS}
${dsf_SRCS}
${dsdiff_SRCS}
${zlib_SRCS}
tag.cpp
tagunion.cpp
fileref.cpp
audioproperties.cpp
tagutils.cpp
)
add_library(tag STATIC ${tag_LIB_SRCS} ${tag_HDRS})
target_include_directories(tag PRIVATE
${ZLIB_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/toolkit
${CMAKE_CURRENT_SOURCE_DIR}/asf
${CMAKE_CURRENT_SOURCE_DIR}/mpeg
${CMAKE_CURRENT_SOURCE_DIR}/ogg
${CMAKE_CURRENT_SOURCE_DIR}/ogg/flac
${CMAKE_CURRENT_SOURCE_DIR}/flac
${CMAKE_CURRENT_SOURCE_DIR}/mpc
${CMAKE_CURRENT_SOURCE_DIR}/mp4
${CMAKE_CURRENT_SOURCE_DIR}/ogg/vorbis
${CMAKE_CURRENT_SOURCE_DIR}/ogg/speex
${CMAKE_CURRENT_SOURCE_DIR}/ogg/opus
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2/frames
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v1
${CMAKE_CURRENT_SOURCE_DIR}/ape
${CMAKE_CURRENT_SOURCE_DIR}/wavpack
${CMAKE_CURRENT_SOURCE_DIR}/trueaudio
${CMAKE_CURRENT_SOURCE_DIR}/riff
${CMAKE_CURRENT_SOURCE_DIR}/riff/aiff
${CMAKE_CURRENT_SOURCE_DIR}/riff/wav
${CMAKE_CURRENT_SOURCE_DIR}/mod
${CMAKE_CURRENT_SOURCE_DIR}/s3m
${CMAKE_CURRENT_SOURCE_DIR}/it
${CMAKE_CURRENT_SOURCE_DIR}/xm
${CMAKE_CURRENT_SOURCE_DIR}/dsf
${CMAKE_CURRENT_SOURCE_DIR}/dsdiff
${CMAKE_SOURCE_DIR}/3rdparty
)
target_link_libraries(tag PRIVATE ${ZLIB_LIBRARIES})
set_target_properties(tag PROPERTIES
VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH}
SOVERSION ${TAGLIB_SOVERSION_MAJOR}
DEFINE_SYMBOL MAKE_TAGLIB_LIB
LINK_INTERFACE_LIBRARIES ""
)
foreach(header ${tag_HDRS})
get_filename_component(header_name ${header} NAME)
configure_file(
"${header}"
"${CMAKE_CURRENT_BINARY_DIR}/headers/taglib/${header_name}"
COPYONLY
)
endforeach()

View File

@@ -1,502 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -1,216 +0,0 @@
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
# Check if the size of numeric types are suitable.
check_type_size("short" SIZEOF_SHORT)
if(NOT SIZEOF_SHORT EQUAL 2)
message(FATAL_ERROR "TagLib requires that short is 16-bit wide.")
endif()
check_type_size("int" SIZEOF_INT)
if(NOT SIZEOF_INT EQUAL 4)
message(FATAL_ERROR "TagLib requires that int is 32-bit wide.")
endif()
check_type_size("long long" SIZEOF_LONGLONG)
if(NOT SIZEOF_LONGLONG EQUAL 8)
message(FATAL_ERROR "TagLib requires that long long is 64-bit wide.")
endif()
check_type_size("wchar_t" SIZEOF_WCHAR_T)
if(SIZEOF_WCHAR_T LESS 2)
message(FATAL_ERROR "TagLib requires that wchar_t is sufficient to store a UTF-16 char.")
endif()
check_type_size("float" SIZEOF_FLOAT)
if(NOT SIZEOF_FLOAT EQUAL 4)
message(FATAL_ERROR "TagLib requires that float is 32-bit wide.")
endif()
check_type_size("double" SIZEOF_DOUBLE)
if(NOT SIZEOF_DOUBLE EQUAL 8)
message(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
endif()
# Determine which kind of atomic operations your compiler supports.
check_cxx_source_compiles("
#include <atomic>
int main() {
std::atomic_int x(1);
++x;
--x;
return 0;
}
" HAVE_STD_ATOMIC)
if(NOT HAVE_STD_ATOMIC)
check_cxx_source_compiles("
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" HAVE_GCC_ATOMIC)
if(NOT HAVE_GCC_ATOMIC)
check_cxx_source_compiles("
#include <libkern/OSAtomic.h>
int main() {
volatile int32_t x;
OSAtomicIncrement32Barrier(&x);
int32_t y = OSAtomicDecrement32Barrier(&x);
return 0;
}
" HAVE_MAC_ATOMIC)
if(NOT HAVE_MAC_ATOMIC)
check_cxx_source_compiles("
#include <windows.h>
int main() {
volatile LONG x;
InterlockedIncrement(&x);
LONG y = InterlockedDecrement(&x);
return 0;
}
" HAVE_WIN_ATOMIC)
if(NOT HAVE_WIN_ATOMIC)
check_cxx_source_compiles("
#include <ia64intrin.h>
int main() {
volatile int x;
__sync_add_and_fetch(&x, 1);
int y = __sync_sub_and_fetch(&x, 1);
return 0;
}
" HAVE_IA64_ATOMIC)
endif()
endif()
endif()
endif()
# Determine which kind of byte swap functions your compiler supports.
check_cxx_source_compiles("
int main() {
__builtin_bswap16(0);
__builtin_bswap32(0);
__builtin_bswap64(0);
return 0;
}
" HAVE_GCC_BYTESWAP)
if(NOT HAVE_GCC_BYTESWAP)
check_cxx_source_compiles("
#include <byteswap.h>
int main() {
__bswap_16(0);
__bswap_32(0);
__bswap_64(0);
return 0;
}
" HAVE_GLIBC_BYTESWAP)
if(NOT HAVE_GLIBC_BYTESWAP)
check_cxx_source_compiles("
#include <stdlib.h>
int main() {
_byteswap_ushort(0);
_byteswap_ulong(0);
_byteswap_uint64(0);
return 0;
}
" HAVE_MSC_BYTESWAP)
if(NOT HAVE_MSC_BYTESWAP)
check_cxx_source_compiles("
#include <libkern/OSByteOrder.h>
int main() {
OSSwapInt16(0);
OSSwapInt32(0);
OSSwapInt64(0);
return 0;
}
" HAVE_MAC_BYTESWAP)
if(NOT HAVE_MAC_BYTESWAP)
check_cxx_source_compiles("
#include <sys/endian.h>
int main() {
swap16(0);
swap32(0);
swap64(0);
return 0;
}
" HAVE_OPENBSD_BYTESWAP)
endif()
endif()
endif()
endif()
# Determine whether your compiler supports some safer version of vsprintf.
check_cxx_source_compiles("
#include <cstdio>
#include <cstdarg>
int main() {
char buf[20];
va_list args;
vsnprintf(buf, 20, \"%d\", args);
return 0;
}
" HAVE_VSNPRINTF)
if(NOT HAVE_VSNPRINTF)
check_cxx_source_compiles("
#include <cstdio>
#include <cstdarg>
int main() {
char buf[20];
va_list args;
vsprintf_s(buf, \"%d\", args);
return 0;
}
" HAVE_VSPRINTF_S)
endif()
# Determine whether your compiler supports ISO _strdup.
check_cxx_source_compiles("
#include <cstring>
int main() {
_strdup(0);
return 0;
}
" HAVE_ISO_STRDUP)
# Determine whether zlib is installed.
if(NOT ZLIB_SOURCE)
find_package(ZLIB)
if(ZLIB_FOUND)
set(HAVE_ZLIB 1)
else()
set(HAVE_ZLIB 0)
endif()
endif()
# Determine whether CppUnit is installed.
if(BUILD_TESTS AND NOT BUILD_SHARED_LIBS)
find_package(CppUnit)
if(NOT CppUnit_FOUND)
message(STATUS "CppUnit not found, disabling tests.")
set(BUILD_TESTS OFF)
endif()
endif()
# Detect WinRT mode
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(PLATFORM WINRT 1)
endif()

View File

@@ -1,26 +0,0 @@
# TagLib
[![Build Status](https://travis-ci.org/taglib/taglib.svg?branch=master)](https://travis-ci.org/taglib/taglib)
### TagLib Audio Metadata Library
http://taglib.org/
TagLib is a library for reading and editing the metadata of several
popular audio formats. Currently it supports both ID3v1 and [ID3v2][]
for MP3 files, [Ogg Vorbis][] comments and ID3 tags
in [FLAC][], MPC, Speex, WavPack, TrueAudio, WAV, AIFF, MP4, APE,
DSF, DFF, and ASF files.
TagLib is distributed under the [GNU Lesser General Public License][]
(LGPL) and [Mozilla Public License][] (MPL). Essentially that means that
it may be used in proprietary applications, but if changes are made to
TagLib they must be contributed back to the project. Please review the
licenses if you are considering using TagLib in your project.
[ID3v2]: http://www.id3.org
[Ogg Vorbis]: http://vorbis.com/
[FLAC]: https://xiph.org/flac/
[GNU Lesser General Public License]: http://www.gnu.org/licenses/lgpl.html
[Mozilla Public License]: http://www.mozilla.org/MPL/MPL-1.1.html

View File

@@ -1,170 +0,0 @@
================================================================================
= APE Tag Specification, Version 2.000
================================================================================
Original Content (C) 2004, Frank Klemm <frank.klemm@elster.offl.uni-jena.de>
Formatting / Editing (C) 2004, Scott Wheeler <wheeler@kde.org>
================================================================================
= Contents
================================================================================
1 - APE Tag General Structure
2 - APE Tag Header / Footer Format
3 - APE Tag Flags
4 - APE Tag Item Format
5 - APE Tag Item Supported Keys
6 - APE Tag Item Content
7 - Data Types
7.1 - Data Types / UTF-8
7.2 - Data Types / Dates
7.3 - Data Types / Timestamps
================================================================================
= 1 - APE Tag General Structure
================================================================================
Member of Basic Components of SV8 Stream Note:
It is strongly recommended that the data size be stored in the tags. The size
should normally be in the roughly one kilobyte, never more than 8 kilobytes.
Larger data should be stored externally using link entries. Linked data is much
easier to process by normal programs, so for instance JPEG data should not be
included inside the audio file.
APE Tag Version 2.000 (with header, recommended):
/================================\
| APE Tag Header | 32 bytes |
|-------------------|------------|
| APE Tag Item 1 | > 10 bytes |
| APE Tag Item 2 | > 10 bytes |
| APE Tag Item n-1 | > 10 bytes |
| APE Tag Item n | > 10 bytes |
|-------------------|------------|
| APE Tag Footer | 32 bytes |
\================================/
APE tag items should be sorted ascending by size. When streaming, parts of the
APE tag may be dropped to reduce the danger of drop outs between tracks. This
is not required, but is strongly recommended. It would be desirable for the i
tems to be sorted by importance / size, but this is not feasible. This
convention should only be broken when adding less important small items and it
is not desirable to rewrite the entire tag. An APE tag at the end of a file
(the recommended location) must have at least a footer; an APE tag at the
beginning of a file (strongly discouraged) must have at least a header.
APE Tag Version 1.000 (without header, deprecated)
/================================\
| APE Tag Item 1 | > 10 bytes |
| APE Tag Item 2 | > 10 bytes |
| APE Tag Item n-1 | > 10 bytes |
| APE Tag Item n | > 10 bytes |
|-------------------|------------|
| APE Tag Footer | 32 bytes |
\================================/
================================================================================
= 2 - APE Tag Header / Footer Format
================================================================================
Contains number, length and attributes of all tag items
Header and Footer are different in 1 bit in the Tags Flags to distinguish
between them.
Member of APE Tag 2.0
/===========================================================================\
| Preamble | 8 bytes | { 'A', 'P', 'E', 'T', 'A', 'G', 'E', 'X' } |
|----------------|---------|------------------------------------------------|
| Version Number | 4 bytes | 1000 = Version 1.000, 2000 = Version 2.000 |
|----------------|---------|------------------------------------------------|
| Tag Size | 4 bytes | Tag size in bytes including footer and all tag |
| | | items excluding the header (for 1.000 |
| | | compatibility) |
|----------------|---------|------------------------------------------------|
| Item Count | 4 bytes | Number of items in the tag |
|----------------|---------|------------------------------------------------|
| Tag Flags | 4 bytes | Global flags |
|----------------|---------|------------------------------------------------|
| Reserved | 8 bytes | Must be zeroed |
\===========================================================================/
================================================================================
= 3 - APE Tag Flags
================================================================================
The general flag structure for either items or headers / footers is the same.
Bits 31, 30 and 29 are specific to headers / footers, whereas 2 through 0 are
item specific.
Note: APE Tags from Version 1.0 do not use any of the following. All flags in
that version are zeroed and ignored when reading.
/=================================================================\
| Contains Header | Bit 31 | 1 - has header | 0 - no header |
|-----------------|-------------|---------------------------------|
| Contains Footer | Bit 30 | 1 - has footer | 0 - no footer |
|-----------------|-------------|---------------------------------|
| Is Header | Bit 29 | 1 - is header | 0 - is footer |
|-----------------|-------------|---------------------------------|
| Undefined | Bits 28 - 3 | Undefined, must be zeroed |
|-----------------|-------------|---------------------------------|
| Encoding | Bits 2 - 1 | 00 - UTF-8 |
| | | 01 - Binary Data * |
| | | 10 - External Reference ** |
| | | 11 - Reserved |
|-----------------|-------------|---------------------------------|
| Read Only | Bit 0 | 1 - read only | 0 - read/write |
\=================================================================/
(*) Should be ignored by tools for editing text values
(**) Allowed external reference formats:
- http://host/directory/filename.ext
- ftp://host/directory/filename.ext
- filename.ext
- /directory/filename.ext
- DRIVE:/directory/filename.ext
Note: External references are also UTF-8 encoded.
================================================================================
= 4 - APE Tag Item Format
================================================================================
APE Tag Items are stored as key-value pairs. APE Tags Item Key are case
sensitive, however it is illegal to use keys which only differ in case and
it is recommended that tag reading not be case sensitive.
Every key can only occur (at most) once. It is not possible to repeat a key
to signify updated contents.
Tags can be partially or completely repeated in the streaming format. This
makes it possible to display an artist and / or title if it was missed at the
beginning of the stream. It is recommended that the important information like
artist, album and title should occur approximately every 2 minutes in the
stream and again 5 to 10 seconds before the end. However, care should be tak
en not to replicate this information too often or during passages with high
bitrate demands to avoid unnecessary drop-outs.
/==============================================================================\
| Content Size | 4 bytes | Length of the value in bytes |
|----------------|---------------|---------------------------------------------|
| Flags | 4 bytes | Item flags |
|----------------|---------------|---------------------------------------------|
| Key | 2 - 255 bytes | Item key |
|----------------|---------------|---------------------------------------------|
| Key Terminator | 1 byte | Null byte that indicates the end of the key |
|----------------|---------------|---------------------------------------------|
| Value | variable | Content (formatted according to the flags) |
\==============================================================================/
================================================================================
Sections 5 - 7 haven't yet been converted from:
http://www.personal.uni-jena.de/~pfk/mpp/sv8/apetag.html

View File

@@ -1,291 +0,0 @@
/***************************************************************************
copyright : (C) 2010 by Alex Novichkov
email : novichko@atnet.ru
copyright : (C) 2006 by Lukáš Lalinský
email : lalinsky@gmail.com
(original WavPack implementation)
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.org
(original MPC implementation)
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "tbytevector.h"
#include "tstring.h"
#include "tdebug.h"
#include "tagunion.h"
#include "id3v1tag.h"
#include "id3v2header.h"
#include "tpropertymap.h"
#include "tagutils.h"
#include "apefile.h"
#include "apetag.h"
#include "apefooter.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
enum { ApeAPEIndex = 0,
ApeID3v1Index = 1 };
}
class APE::File::FilePrivate {
public:
FilePrivate() : APELocation(-1),
APESize(0),
ID3v1Location(-1),
ID3v2Location(-1),
ID3v2Size(0) {}
long long APELocation;
long long APESize;
long long ID3v1Location;
std::unique_ptr<ID3v2::Header> ID3v2Header;
long long ID3v2Location;
long long ID3v2Size;
DoubleTagUnion tag;
std::unique_ptr<AudioProperties> properties;
};
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
bool APE::File::isSupported(IOStream *stream) {
// An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede.
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
return (buffer.find("MAC ") == 0);
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
APE::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
if (isOpen())
read(readProperties);
}
APE::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
if (isOpen())
read(readProperties);
}
APE::File::~File() {
delete d;
}
Strawberry_TagLib::TagLib::Tag *APE::File::tag() const {
return &d->tag;
}
PropertyMap APE::File::setProperties(const PropertyMap &properties) {
if (ID3v1Tag())
ID3v1Tag()->setProperties(properties);
return APETag(true)->setProperties(properties);
}
APE::AudioProperties *APE::File::audioProperties() const {
return d->properties.get();
}
bool APE::File::save() {
if (readOnly()) {
debug("APE::File::save() -- File is read only.");
return false;
}
// Update ID3v1 tag
if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
// ID3v1 tag is not empty. Update the old one or create a new one.
if (d->ID3v1Location >= 0) {
seek(d->ID3v1Location);
}
else {
seek(0, End);
d->ID3v1Location = tell();
}
writeBlock(ID3v1Tag()->render());
}
else {
// ID3v1 tag is empty. Remove the old one.
if (d->ID3v1Location >= 0) {
truncate(d->ID3v1Location);
d->ID3v1Location = -1;
}
}
// Update APE tag
if (APETag() && !APETag()->isEmpty()) {
// APE tag is not empty. Update the old one or create a new one.
if (d->APELocation < 0) {
if (d->ID3v1Location >= 0)
d->APELocation = d->ID3v1Location;
else
d->APELocation = length();
}
const ByteVector data = APETag()->render();
insert(data, d->APELocation, d->APESize);
if (d->ID3v1Location >= 0)
d->ID3v1Location += (static_cast<long>(data.size()) - d->APESize);
d->APESize = data.size();
}
else {
// APE tag is empty. Remove the old one.
if (d->APELocation >= 0) {
removeBlock(d->APELocation, d->APESize);
if (d->ID3v1Location >= 0)
d->ID3v1Location -= d->APESize;
d->APELocation = -1;
d->APESize = 0;
}
}
return true;
}
ID3v1::Tag *APE::File::ID3v1Tag(bool create) {
return d->tag.access<ID3v1::Tag>(ApeID3v1Index, create);
}
APE::Tag *APE::File::APETag(bool create) {
return d->tag.access<APE::Tag>(ApeAPEIndex, create);
}
void APE::File::strip(int tags) {
if (tags & ID3v1)
d->tag.set(ApeID3v1Index, nullptr);
if (tags & APE)
d->tag.set(ApeAPEIndex, nullptr);
if (!ID3v1Tag())
APETag(true);
}
bool APE::File::hasAPETag() const {
return (d->APELocation >= 0);
}
bool APE::File::hasID3v1Tag() const {
return (d->ID3v1Location >= 0);
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void APE::File::read(bool readProperties) {
// Look for an ID3v2 tag
d->ID3v2Location = Utils::findID3v2(this);
if (d->ID3v2Location >= 0) {
seek(d->ID3v2Location);
d->ID3v2Header.reset(new ID3v2::Header(readBlock(ID3v2::Header::size())));
d->ID3v2Size = d->ID3v2Header->completeTagSize();
}
// Look for an ID3v1 tag
d->ID3v1Location = Utils::findID3v1(this);
if (d->ID3v1Location >= 0)
d->tag.set(ApeID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
// Look for an APE tag
d->APELocation = Utils::findAPE(this, d->ID3v1Location);
if (d->APELocation >= 0) {
d->tag.set(ApeAPEIndex, new APE::Tag(this, d->APELocation));
d->APESize = APETag()->footer()->completeTagSize();
d->APELocation = d->APELocation + APE::Footer::size() - d->APESize;
}
if (d->ID3v1Location < 0)
APETag(true);
// Look for APE audio properties
if (readProperties) {
long long streamLength;
if (d->APELocation >= 0)
streamLength = d->APELocation;
else if (d->ID3v1Location >= 0)
streamLength = d->ID3v1Location;
else
streamLength = length();
if (d->ID3v2Location >= 0) {
seek(d->ID3v2Location + d->ID3v2Size);
streamLength -= (d->ID3v2Location + d->ID3v2Size);
}
else {
seek(0);
}
d->properties.reset(new AudioProperties(this, streamLength));
}
}

View File

@@ -1,214 +0,0 @@
/***************************************************************************
copyright : (C) 2010 by Alex Novichkov
email : novichko@atnet.ru
copyright : (C) 2006 by Lukáš Lalinský
email : lalinsky@gmail.com
(original WavPack implementation)
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.org
(original MPC implementation)
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_APEFILE_H
#define TAGLIB_APEFILE_H
#include "tfile.h"
#include "taglib_export.h"
#include "apeproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
class Tag;
namespace ID3v1 {
class Tag;
}
namespace APE {
class Tag;
}
//! An implementation of APE metadata
/*!
* This is implementation of APE metadata.
*
* This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream properties from the file.
*
*/
namespace APE {
//! An implementation of TagLib::File with APE specific methods
/*!
* This implements and provides an interface for APE files to the
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
* the abstract TagLib::File API as well as providing some additional information specific to APE files.
*
*/
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
public:
/*!
* This set of flags is used for various operations and is suitable for being OR-ed together.
*/
enum TagTypes {
//! Empty set. Matches no tag types.
NoTags = 0x0000,
//! Matches ID3v1 tags.
ID3v1 = 0x0001,
//! Matches APE tags.
APE = 0x0002,
//! Matches all tag types.
AllTags = 0xffff
};
/*!
* Constructs an APE file from \a file.
* If \a readProperties is true the file's audio properties will also be read.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Constructs an APE file from \a stream.
* If \a readProperties is true the file's audio properties will also be read.
*
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
~File() override;
/*!
* Returns the Tag for this file. This will be an APE tag, an ID3v1 tag or a combination of the two.
*/
Strawberry_TagLib::TagLib::Tag *tag() const override;
/*!
* Implements the unified property interface -- import function.
* Creates an APEv2 tag if necessary.
* A potentially existing ID3v1 tag will be updated as well.
*/
PropertyMap setProperties(const PropertyMap&) override;
/*!
* Returns the APE::AudioProperties for this file.
* If no audio properties were read then this will return a null pointer.
*/
AudioProperties *audioProperties() const override;
/*!
* Saves the file.
*
* \note According to the official Monkey's Audio SDK, an APE file
* can only have either ID3V1 or APE tags, so a parameter is used here.
*/
bool save() override;
/*!
* Returns a pointer to the ID3v1 tag of the file.
*
* If \a create is false (the default) this may return a null pointer if there is no valid ID3v1 tag.
* If \a create is true it will create an ID3v1 tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v1 tag.
* Use hasID3v1Tag() to check if the file on disk actually has an ID3v1 tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
* It will be deleted when the file (object) is destroyed.
*
* \see hasID3v1Tag()
*/
ID3v1::Tag *ID3v1Tag(bool create = false);
/*!
* Returns a pointer to the APE tag of the file.
*
* If \a create is false (the default) this may return a null pointer if there is no valid APE tag.
* If \a create is true it will create an APE tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the file on disk has an APE tag.
* Use hasAPETag() to check if the file on disk actually has an APE tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
* It will be deleted when the file (object) is destroyed.
*
* \see hasAPETag()
*/
APE::Tag *APETag(bool create = false);
/*!
* This will remove the tags that match the OR-ed together TagTypes from the file.
* By default it removes all tags.
*
* \note This will also invalidate pointers to the tags as their memory will be freed.
* \note In order to make the removal permanent save() still needs to be called
*/
void strip(int tags = AllTags);
/*!
* Returns whether or not the file on disk actually has an APE tag.
*
* \see APETag()
*/
bool hasAPETag() const;
/*!
* Returns whether or not the file on disk actually has an ID3v1 tag.
*
* \see ID3v1Tag()
*/
bool hasID3v1Tag() const;
/*!
* Returns whether or not the given \a stream can be opened as an APE file.
*
* \note This method is designed to do a quick check.
* The result may not necessarily be correct.
*/
static bool isSupported(IOStream *stream);
private:
File(const File &);
File &operator=(const File &);
void read(bool readProperties);
class FilePrivate;
FilePrivate *d;
};
} // namespace APE
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,215 +0,0 @@
/***************************************************************************
copyright : (C) 2004 by Allan Sandfeld Jensen
(C) 2002 - 2008 by Scott Wheeler (id3v2header.cpp)
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <iostream>
#include <bitset>
#include "tstring.h"
#include "tdebug.h"
#include "apefooter.h"
using namespace Strawberry_TagLib::TagLib;
using namespace APE;
class APE::Footer::FooterPrivate {
public:
FooterPrivate() : version(0),
footerPresent(true),
headerPresent(false),
isHeader(false),
itemCount(0),
tagSize(0) {}
unsigned int version;
bool footerPresent;
bool headerPresent;
bool isHeader;
unsigned int itemCount;
unsigned int tagSize;
};
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
unsigned int APE::Footer::size() {
return 32;
}
ByteVector APE::Footer::fileIdentifier() {
return ByteVector("APETAGEX");
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
APE::Footer::Footer() : d(new FooterPrivate()) {
}
APE::Footer::Footer(const ByteVector &data) : d(new FooterPrivate()) {
parse(data);
}
APE::Footer::~Footer() {
delete d;
}
unsigned int APE::Footer::version() const {
return d->version;
}
bool APE::Footer::headerPresent() const {
return d->headerPresent;
}
bool APE::Footer::footerPresent() const {
return d->footerPresent;
}
bool APE::Footer::isHeader() const {
return d->isHeader;
}
void APE::Footer::setHeaderPresent(bool b) const {
d->headerPresent = b;
}
unsigned int APE::Footer::itemCount() const {
return d->itemCount;
}
void APE::Footer::setItemCount(unsigned int s) {
d->itemCount = s;
}
unsigned int APE::Footer::tagSize() const {
return d->tagSize;
}
unsigned int APE::Footer::completeTagSize() const {
if (d->headerPresent)
return d->tagSize + size();
else
return d->tagSize;
}
void APE::Footer::setTagSize(unsigned int s) {
d->tagSize = s;
}
void APE::Footer::setData(const ByteVector &data) {
parse(data);
}
ByteVector APE::Footer::renderFooter() const {
return render(false);
}
ByteVector APE::Footer::renderHeader() const {
if (!d->headerPresent)
return ByteVector();
else
return render(true);
}
////////////////////////////////////////////////////////////////////////////////
// protected members
////////////////////////////////////////////////////////////////////////////////
void APE::Footer::parse(const ByteVector &data) {
if (data.size() < size())
return;
// The first eight bytes, data[0..7], are the File Identifier, "APETAGEX".
// Read the version number
d->version = data.toUInt32LE(8);
// Read the tag size
d->tagSize = data.toUInt32LE(12);
// Read the item count
d->itemCount = data.toUInt32LE(16);
// Read the flags
std::bitset<32> flags(TAGLIB_CONSTRUCT_BITSET(data.toUInt32LE(20)));
d->headerPresent = flags[31];
d->footerPresent = !flags[30];
d->isHeader = flags[29];
}
ByteVector APE::Footer::render(bool isHeader) const {
ByteVector v;
// add the file identifier -- "APETAGEX"
v.append(fileIdentifier());
// add the version number -- we always render a 2.000 tag regardless of what
// the tag originally was.
v.append(ByteVector::fromUInt32LE(2000));
// add the tag size
v.append(ByteVector::fromUInt32LE(d->tagSize));
// add the item count
v.append(ByteVector::fromUInt32LE(d->itemCount));
// render and add the flags
std::bitset<32> flags;
flags[31] = d->headerPresent;
flags[30] = false; // footer is always present
flags[29] = isHeader;
v.append(ByteVector::fromUInt32LE(flags.to_ulong()));
// add the reserved 64bit
v.append(ByteVector::fromUInt64BE(0));
return v;
}

View File

@@ -1,175 +0,0 @@
/***************************************************************************
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_APEFOOTER_H
#define TAGLIB_APEFOOTER_H
#include "tbytevector.h"
#include "taglib_export.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace APE {
//! An implementation of APE footers
/*!
* This class implements APE footers (and headers).
* It attempts to follow, both semantically and programmatically,
* the structure specified in the APE v2.0 standard.
* The API is based on the properties of APE footer and headers specified there.
*
*/
class TAGLIB_EXPORT Footer {
public:
/*!
* Constructs an empty APE footer.
*/
explicit Footer();
/*!
* Constructs an APE footer based on \a data. parse() is called immediately.
*/
explicit Footer(const ByteVector &data);
/*!
* Destroys the footer.
*/
virtual ~Footer();
/*!
* Returns the version number. (Note: This is the 1000 or 2000.)
*/
unsigned int version() const;
/*!
* Returns true if a header is present in the tag.
*/
bool headerPresent() const;
/*!
* Returns true if a footer is present in the tag.
*/
bool footerPresent() const;
/*!
* Returns true this is actually the header.
*/
bool isHeader() const;
/*!
* Sets whether the header should be rendered or not
*/
void setHeaderPresent(bool b) const;
/*!
* Returns the number of items in the tag.
*/
unsigned int itemCount() const;
/*!
* Set the item count to \a s.
* \see itemCount()
*/
void setItemCount(unsigned int s);
/*!
* Returns the tag size in bytes.
* This is the size of the frame content and footer.
* The size of the \e entire tag will be this plus the header size, if present.
*
* \see completeTagSize()
*/
unsigned int tagSize() const;
/*!
* Returns the tag size, including if present, the header
* size.
*
* \see tagSize()
*/
unsigned int completeTagSize() const;
/*!
* Set the tag size to \a s.
* \see tagSize()
*/
void setTagSize(unsigned int s);
/*!
* Returns the size of the footer. Presently this is always 32 bytes.
*/
static unsigned int size();
/*!
* Returns the string used to identify an APE tag inside of a file.
* Presently this is always "APETAGEX".
*/
static ByteVector fileIdentifier();
/*!
* Sets the data that will be used as the footer. 32 bytes,
* starting from \a data will be used.
*/
void setData(const ByteVector &data);
/*!
* Renders the footer back to binary format.
*/
ByteVector renderFooter() const;
/*!
* Renders the header corresponding to the footer.
* If headerPresent is set to false, it returns an empty ByteVector.
*/
ByteVector renderHeader() const;
protected:
/*!
* Called by setData() to parse the footer data.
* It makes this information available through the public API.
*/
void parse(const ByteVector &data);
/*!
* Called by renderFooter and renderHeader
*/
ByteVector render(bool isHeader) const;
private:
Footer(const Footer &);
Footer &operator=(const Footer &);
class FooterPrivate;
FooterPrivate *d;
};
} // namespace APE
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,271 +0,0 @@
/***************************************************************************
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "tbytevectorlist.h"
#include "tdebug.h"
#include "apeitem.h"
using namespace Strawberry_TagLib::TagLib;
using namespace APE;
struct ItemData {
ItemData() : type(Item::Text), readOnly(false) {}
Item::ItemTypes type;
String key;
ByteVector value;
StringList text;
bool readOnly;
};
class APE::Item::ItemPrivate {
public:
ItemPrivate() : data(new ItemData()) {}
std::shared_ptr<ItemData> data;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
APE::Item::Item() : d(new ItemPrivate()) {}
APE::Item::Item(const String &key, const String &value) : d(new ItemPrivate()) {
d->data->key = key;
d->data->text.append(value);
}
APE::Item::Item(const String &key, const StringList &values) : d(new ItemPrivate()) {
d->data->key = key;
d->data->text = values;
}
APE::Item::Item(const String &key, const ByteVector &value, bool binary) : d(new ItemPrivate()) {
d->data->key = key;
if (binary) {
d->data->type = Binary;
d->data->value = value;
}
else {
d->data->text.append(value);
}
}
APE::Item::Item(const Item &item) : d(new ItemPrivate(*item.d)) {}
APE::Item::~Item() {
delete d;
}
Item &APE::Item::operator=(const Item &item) {
Item(item).swap(*this);
return *this;
}
void APE::Item::swap(Item &item) {
using std::swap;
swap(d, item.d);
}
void APE::Item::setReadOnly(bool readOnly) {
d->data->readOnly = readOnly;
}
bool APE::Item::isReadOnly() const {
return d->data->readOnly;
}
void APE::Item::setType(APE::Item::ItemTypes val) {
d->data->type = val;
}
APE::Item::ItemTypes APE::Item::type() const {
return d->data->type;
}
String APE::Item::key() const {
return d->data->key;
}
ByteVector APE::Item::binaryData() const {
return d->data->value;
}
void APE::Item::setBinaryData(const ByteVector &value) {
d->data->type = Binary;
d->data->value = value;
d->data->text.clear();
}
void APE::Item::setKey(const String &key) {
d->data->key = key;
}
void APE::Item::setValue(const String &value) {
d->data->type = Text;
d->data->text = value;
d->data->value.clear();
}
void APE::Item::setValues(const StringList &value) {
d->data->type = Text;
d->data->text = value;
d->data->value.clear();
}
void APE::Item::appendValue(const String &value) {
d->data->type = Text;
d->data->text.append(value);
d->data->value.clear();
}
void APE::Item::appendValues(const StringList &values) {
d->data->type = Text;
d->data->text.append(values);
d->data->value.clear();
}
int APE::Item::size() const {
size_t result = 8 + d->data->key.size() + 1;
switch (d->data->type) {
case Text:
if (!d->data->text.isEmpty()) {
StringList::ConstIterator it = d->data->text.begin();
result += it->data(String::UTF8).size();
it++;
for (; it != d->data->text.end(); ++it)
result += 1 + it->data(String::UTF8).size();
}
break;
case Binary:
case Locator:
result += d->data->value.size();
break;
}
return result;
}
StringList APE::Item::values() const {
return d->data->text;
}
String APE::Item::toString() const {
if (d->data->type == Text && !isEmpty())
return d->data->text.front();
else
return String();
}
bool APE::Item::isEmpty() const {
switch (d->data->type) {
case Text:
if (d->data->text.isEmpty())
return true;
if (d->data->text.size() == 1 && d->data->text.front().isEmpty())
return true;
return false;
case Binary:
case Locator:
return d->data->value.isEmpty();
default:
return false;
}
}
void APE::Item::parse(const ByteVector &data) {
// 11 bytes is the minimum size for an APE item
if (data.size() < 11) {
debug("APE::Item::parse() -- no data in item");
return;
}
const unsigned int valueLength = data.toUInt32LE(0);
const unsigned int flags = data.toUInt32LE(4);
// An item key can contain ASCII characters from 0x20 up to 0x7E, not UTF-8.
// We assume that the validity of the given key has been checked.
d->data->key = String(&data[8], String::Latin1);
const ByteVector value = data.mid(8 + d->data->key.size() + 1, valueLength);
setReadOnly(flags & 1);
setType(ItemTypes((flags >> 1) & 3));
if (Text == d->data->type)
d->data->text = StringList(ByteVectorList::split(value, '\0'), String::UTF8);
else
d->data->value = value;
}
ByteVector APE::Item::render() const {
ByteVector data;
unsigned int flags = ((d->data->readOnly) ? 1 : 0) | (d->data->type << 1);
ByteVector value;
if (isEmpty())
return data;
if (d->data->type == Text) {
StringList::ConstIterator it = d->data->text.begin();
value.append(it->data(String::UTF8));
it++;
for (; it != d->data->text.end(); ++it) {
value.append('\0');
value.append(it->data(String::UTF8));
}
d->data->value = value;
}
else
value.append(d->data->value);
data.append(ByteVector::fromUInt32LE(value.size()));
data.append(ByteVector::fromUInt32LE(flags));
data.append(d->data->key.data(String::Latin1));
data.append(ByteVector('\0'));
data.append(value);
return data;
}

View File

@@ -1,207 +0,0 @@
/***************************************************************************
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_APEITEM_H
#define TAGLIB_APEITEM_H
#include "tbytevector.h"
#include "tstring.h"
#include "tstringlist.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace APE {
//! An implementation of APE-items
/*!
* This class provides the features of items in the APEv2 standard.
*/
class TAGLIB_EXPORT Item {
public:
/*!
* Enum of types an Item can have. The value of 3 is reserved.
*/
enum ItemTypes {
//! Item contains text information coded in UTF-8
Text = 0,
//! Item contains binary information
Binary = 1,
//! Item is a locator of external stored information
Locator = 2
};
/*!
* Constructs an empty item.
*/
explicit Item();
/*!
* Constructs a text item with \a key and \a values.
*/
explicit Item(const String &key, const String &values);
/*!
* Constructs a text item with \a key and \a values.
*/
explicit Item(const String &key, const StringList &values);
/*!
* Constructs an item with \a key and \a value.
* If \a binary is true a Binary item will be created, otherwise \a value will be interpreted as text
*/
explicit Item(const String &key, const ByteVector &value, bool binary);
/*!
* Construct an item as a copy of \a item.
*/
Item(const Item &item);
/*!
* Destroys the item.
*/
virtual ~Item();
/*!
* Copies the contents of \a item into this item.
*/
Item &operator=(const Item &item);
/*!
* Exchanges the content of this item by the content of \a item.
*/
void swap(Item &item);
/*!
* Returns the key.
*/
String key() const;
/*!
* Returns the binary value.
* If the item type is not \a Binary, always returns an empty ByteVector.
*/
ByteVector binaryData() const;
/*!
* Set the binary value to \a value
* The item's type will also be set to \a Binary
*/
void setBinaryData(const ByteVector &value);
/*!
* Sets the key for the item to \a key.
*/
void setKey(const String &key);
/*!
* Sets the text value of the item to \a value and clears any previous contents.
*
* \see toString()
*/
void setValue(const String &value);
/*!
* Sets the text value of the item to the list of values in \a value and clears any previous contents.
*
* \see toStringList()
*/
void setValues(const StringList &values);
/*!
* Appends \a value to create (or extend) the current list of text values.
*
* \see toString()
*/
void appendValue(const String &value);
/*!
* Appends \a values to extend the current list of text values.
*
* \see toStringList()
*/
void appendValues(const StringList &values);
/*!
* Returns the size of the full item.
*/
int size() const;
/*!
* Returns the value as a single string. In case of multiple strings, the first is returned.
* If the data type is not \a Text, always returns an empty String.
*/
String toString() const;
/*!
* Returns the list of text values. If the data type is not \a Text, always returns an empty StringList.
*/
StringList values() const;
/*!
* Render the item to a ByteVector.
*/
ByteVector render() const;
/*!
* Parse the item from the ByteVector \a data.
*/
void parse(const ByteVector &data);
/*!
* Set the item to read-only.
*/
void setReadOnly(bool readOnly);
/*!
* Return true if the item is read-only.
*/
bool isReadOnly() const;
/*!
* Sets the type of the item to \a type.
*
* \see ItemTypes
*/
void setType(ItemTypes type);
/*!
* Returns the type of the item.
*/
ItemTypes type() const;
/*!
* Returns if the item has any real content.
*/
bool isEmpty() const;
private:
class ItemPrivate;
ItemPrivate *d;
};
} // namespace APE
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,227 +0,0 @@
/***************************************************************************
copyright : (C) 2010 by Alex Novichkov
email : novichko@atnet.ru
copyright : (C) 2006 by Lukáš Lalinský
email : lalinsky@gmail.com
(original WavPack implementation)
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tstring.h"
#include "tdebug.h"
#include "id3v2tag.h"
#include "apeproperties.h"
#include "apefile.h"
#include "apetag.h"
#include "apefooter.h"
using namespace Strawberry_TagLib::TagLib;
class APE::AudioProperties::AudioPropertiesPrivate {
public:
explicit AudioPropertiesPrivate() : length(0),
bitrate(0),
sampleRate(0),
channels(0),
version(0),
bitsPerSample(0),
sampleFrames(0) {}
int length;
int bitrate;
int sampleRate;
int channels;
int version;
int bitsPerSample;
unsigned int sampleFrames;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
APE::AudioProperties::AudioProperties(File *file, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
read(file, streamLength);
}
APE::AudioProperties::~AudioProperties() {
delete d;
}
int APE::AudioProperties::lengthInSeconds() const {
return d->length / 1000;
}
int APE::AudioProperties::lengthInMilliseconds() const {
return d->length;
}
int APE::AudioProperties::bitrate() const {
return d->bitrate;
}
int APE::AudioProperties::sampleRate() const {
return d->sampleRate;
}
int APE::AudioProperties::channels() const {
return d->channels;
}
int APE::AudioProperties::version() const {
return d->version;
}
int APE::AudioProperties::bitsPerSample() const {
return d->bitsPerSample;
}
unsigned int APE::AudioProperties::sampleFrames() const {
return d->sampleFrames;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
namespace {
int headerVersion(const ByteVector &header) {
if (header.size() < 6 || !header.startsWith("MAC "))
return -1;
return header.toUInt16LE(4);
}
} // namespace
void APE::AudioProperties::read(File *file, long long streamLength) {
// First, we assume that the file pointer is set at the first descriptor.
long long offset = file->tell();
int version = headerVersion(file->readBlock(6));
// Next, we look for the descriptor.
if (version < 0) {
offset = file->find("MAC ", offset);
file->seek(offset);
version = headerVersion(file->readBlock(6));
}
if (version < 0) {
debug("APE::AudioProperties::read() -- APE descriptor not found");
return;
}
d->version = version;
if (d->version >= 3980)
analyzeCurrent(file);
else
analyzeOld(file);
if (d->sampleFrames > 0 && d->sampleRate > 0) {
const double length = d->sampleFrames * 1000.0 / d->sampleRate;
d->length = static_cast<int>(length + 0.5);
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
}
}
void APE::AudioProperties::analyzeCurrent(File *file) {
// Read the descriptor
file->seek(2, File::Current);
const ByteVector descriptor = file->readBlock(44);
if (descriptor.size() < 44) {
debug("APE::AudioProperties::analyzeCurrent() -- descriptor is too short.");
return;
}
const unsigned int descriptorBytes = descriptor.toUInt32LE(0);
if ((descriptorBytes - 52) > 0)
file->seek(descriptorBytes - 52, File::Current);
// Read the header
const ByteVector header = file->readBlock(24);
if (header.size() < 24) {
debug("APE::AudioProperties::analyzeCurrent() -- MAC header is too short.");
return;
}
// Get the APE info
d->channels = header.toUInt16LE(18);
d->sampleRate = header.toUInt32LE(20);
d->bitsPerSample = header.toUInt16LE(16);
const unsigned int totalFrames = header.toUInt32LE(12);
if (totalFrames == 0)
return;
const unsigned int blocksPerFrame = header.toUInt32LE(4);
const unsigned int finalFrameBlocks = header.toUInt32LE(8);
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
}
void APE::AudioProperties::analyzeOld(File *file) {
const ByteVector header = file->readBlock(26);
if (header.size() < 26) {
debug("APE::AudioProperties::analyzeOld() -- MAC header is too short.");
return;
}
const unsigned int totalFrames = header.toUInt32LE(18);
// Fail on 0 length APE files (catches non-finalized APE files)
if (totalFrames == 0)
return;
const short compressionLevel = header.toUInt32LE(0);
unsigned int blocksPerFrame;
if (d->version >= 3950)
blocksPerFrame = 73728 * 4;
else if (d->version >= 3900 || (d->version >= 3800 && compressionLevel == 4000))
blocksPerFrame = 73728;
else
blocksPerFrame = 9216;
// Get the APE info
d->channels = header.toUInt16LE(4);
d->sampleRate = header.toUInt32LE(6);
const unsigned int finalFrameBlocks = header.toUInt32LE(22);
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
// Get the bit depth from the RIFF-fmt chunk.
file->seek(16, File::Current);
const ByteVector fmt = file->readBlock(28);
if (fmt.size() < 28 || !fmt.startsWith("WAVEfmt ")) {
debug("APE::AudioProperties::analyzeOld() -- fmt header is too short.");
return;
}
d->bitsPerSample = fmt.toUInt16LE(26);
}

View File

@@ -1,118 +0,0 @@
/***************************************************************************
copyright : (C) 2010 by Alex Novichkov
email : novichko@atnet.ru
copyright : (C) 2006 by Lukáš Lalinský
email : lalinsky@gmail.com
(original WavPack implementation)
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_APEPROPERTIES_H
#define TAGLIB_APEPROPERTIES_H
#include "taglib_export.h"
#include "audioproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace APE {
class File;
//! An implementation of audio property reading for APE
/*!
* This reads the data from an APE stream found in the AudioProperties API.
*/
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
public:
/*!
* Create an instance of APE::AudioProperties with the data read from the APE::File \a file.
*/
explicit AudioProperties(File *file, long long streamLength, ReadStyle style = Average);
/*!
* Destroys this APE::AudioProperties instance.
*/
~AudioProperties() override;
/*!
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
*
* \see lengthInMilliseconds()
*/
int lengthInSeconds() const override;
/*!
* Returns the length of the file in milliseconds.
*
* \see lengthInSeconds()
*/
int lengthInMilliseconds() const override;
/*!
* Returns the average bit rate of the file in kb/s.
*/
int bitrate() const override;
/*!
* Returns the sample rate in Hz.
*/
int sampleRate() const override;
/*!
* Returns the number of audio channels.
*/
int channels() const override;
/*!
* Returns the number of bits per audio sample.
*/
int bitsPerSample() const;
/*!
* Returns the total number of audio samples in file.
*/
unsigned int sampleFrames() const;
/*!
* Returns APE version.
*/
int version() const;
private:
void read(File *file, long long streamLength);
void analyzeCurrent(File *file);
void analyzeOld(File *file);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace APE
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,519 +0,0 @@
/***************************************************************************
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5130)
// Sun Studio finds multiple specializations of Map because
// it considers specializations with and without class types
// to be different; this define forces Map to use only the
// specialization with the class keyword.
# define WANT_CLASS_INSTANTIATION_OF_MAP (1)
#endif
#include "tfile.h"
#include "tstring.h"
#include "tmap.h"
#include "tpicturemap.h"
#include "tpropertymap.h"
#include "tdebug.h"
#include "tutils.h"
#include "apetag.h"
#include "apefooter.h"
#include "apeitem.h"
using namespace Strawberry_TagLib::TagLib;
using namespace APE;
namespace {
const unsigned int MinKeyLength = 2;
const unsigned int MaxKeyLength = 255;
bool isKeyValid(const ByteVector &key) {
const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", nullptr };
// only allow printable ASCII including space (32..126)
for (ByteVector::ConstIterator it = key.begin(); it != key.end(); ++it) {
const int c = static_cast<unsigned char>(*it);
if (c < 32 || c > 126)
return false;
}
const String upperKey = String(key).upper();
for (size_t i = 0; invalidKeys[i] != nullptr; ++i) {
if (upperKey == invalidKeys[i])
return false;
}
return true;
}
} // namespace
class APE::Tag::TagPrivate {
public:
TagPrivate() : file(nullptr), footerLocation(0) {}
File *file;
long long footerLocation;
Footer footer;
ItemListMap itemListMap;
};
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
APE::Tag::Tag() : d(new TagPrivate()) {}
APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long long footerLocation) : d(new TagPrivate()) {
d->file = file;
d->footerLocation = footerLocation;
read();
}
APE::Tag::~Tag() {
delete d;
}
ByteVector APE::Tag::fileIdentifier() {
return ByteVector::fromCString("APETAGEX");
}
String APE::Tag::title() const {
if (d->itemListMap["TITLE"].isEmpty())
return String();
return d->itemListMap["TITLE"].values().toString();
}
String APE::Tag::artist() const {
if (d->itemListMap["ARTIST"].isEmpty())
return String();
return d->itemListMap["ARTIST"].values().toString();
}
String APE::Tag::album() const {
if (d->itemListMap["ALBUM"].isEmpty())
return String();
return d->itemListMap["ALBUM"].values().toString();
}
String APE::Tag::comment() const {
if (d->itemListMap["COMMENT"].isEmpty())
return String();
return d->itemListMap["COMMENT"].values().toString();
}
String APE::Tag::genre() const {
if (d->itemListMap["GENRE"].isEmpty())
return String();
return d->itemListMap["GENRE"].values().toString();
}
unsigned int APE::Tag::year() const {
if (d->itemListMap["YEAR"].isEmpty())
return 0;
return d->itemListMap["YEAR"].toString().toInt();
}
unsigned int APE::Tag::track() const {
if (d->itemListMap["TRACK"].isEmpty())
return 0;
return d->itemListMap["TRACK"].toString().toInt();
}
Strawberry_TagLib::TagLib::PictureMap APE::Tag::pictures() const {
PictureMap map;
if (d->itemListMap.contains(FRONT_COVER)) {
Item front = d->itemListMap[FRONT_COVER];
if (Item::Binary == front.type()) {
ByteVector picture = front.binaryData();
const size_t index = picture.find('\0');
if (index < picture.size()) {
ByteVector desc = picture.mid(0, index + 1);
String mime = "image/jpeg";
ByteVector data = picture.mid(index + 1);
Picture p(data, Picture::FrontCover, mime, desc);
map.insert(p);
}
}
}
if (d->itemListMap.contains(BACK_COVER)) {
Item back = d->itemListMap[BACK_COVER];
if (Item::Binary == back.type()) {
ByteVector picture = back.binaryData();
const size_t index = picture.find('\0');
if (index < picture.size()) {
ByteVector desc = picture.mid(0, index + 1);
String mime = "image/jpeg";
ByteVector data = picture.mid(index + 1);
Picture p(data, Picture::BackCover, mime, desc);
map.insert(p);
}
}
}
return PictureMap(map);
}
void APE::Tag::setTitle(const String &s) {
addValue("TITLE", s, true);
}
void APE::Tag::setArtist(const String &s) {
addValue("ARTIST", s, true);
}
void APE::Tag::setAlbum(const String &s) {
addValue("ALBUM", s, true);
}
void APE::Tag::setComment(const String &s) {
addValue("COMMENT", s, true);
}
void APE::Tag::setGenre(const String &s) {
addValue("GENRE", s, true);
}
void APE::Tag::setYear(unsigned int i) {
if (i == 0)
removeItem("YEAR");
else
addValue("YEAR", String::number(i), true);
}
void APE::Tag::setTrack(unsigned int i) {
if (i == 0)
removeItem("TRACK");
else
addValue("TRACK", String::number(i), true);
}
void APE::Tag::setPictures(const PictureMap &l) {
removeItem(FRONT_COVER);
removeItem(BACK_COVER);
for (PictureMap::ConstIterator pictureMapIt = l.begin(); pictureMapIt != l.end(); ++pictureMapIt) {
Picture::Type type = pictureMapIt->first;
if (Picture::FrontCover != type && Picture::BackCover != type) {
std::cout << "APE: Trying to add a picture with wrong type" << std::endl;
continue;
}
const char *id;
switch (type) {
case Picture::FrontCover:
id = FRONT_COVER;
break;
case Picture::BackCover:
id = BACK_COVER;
break;
default:
id = FRONT_COVER;
break;
}
PictureList list = pictureMapIt->second;
for (PictureList::ConstIterator pictureListIt = list.begin(); pictureListIt != list.end(); ++pictureListIt) {
Picture picture = *pictureListIt;
if (d->itemListMap.contains(id)) {
std::cout << "APE: Already added a picture of type "
<< id
<< " '"
<< picture.description()
<< "' "
<< "and next are being ignored"
<< std::endl;
break;
}
ByteVector data = picture.description().data(String::Latin1).append('\0').append(picture.data());
Item item;
item.setKey(id);
item.setType(Item::Binary);
item.setBinaryData(data);
setItem(item.key(), item);
}
}
}
namespace {
// conversions of tag keys between what we use in PropertyMap and what's usual
// for APE tags
// usual, APE
const char *keyConversions[][2] = { { "TRACKNUMBER", "TRACK" },
{ "DATE", "YEAR" },
{ "ALBUMARTIST", "ALBUM ARTIST" },
{ "DISCNUMBER", "DISC" },
{ "REMIXER", "MIXARTIST" } };
const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]);
} // namespace
PropertyMap APE::Tag::properties() const {
PropertyMap properties;
ItemListMap::ConstIterator it = itemListMap().begin();
for (; it != itemListMap().end(); ++it) {
String tagName = it->first.upper();
// if the item is Binary or Locator, or if the key is an invalid string,
// add to unsupportedData
if (it->second.type() != Item::Text || tagName.isEmpty()) {
properties.unsupportedData().append(it->first);
}
else {
// Some tags need to be handled specially
for (size_t i = 0; i < keyConversionsSize; ++i) {
if (tagName == keyConversions[i][1])
tagName = keyConversions[i][0];
}
properties[tagName].append(it->second.values());
}
}
return properties;
}
void APE::Tag::removeUnsupportedProperties(const StringList &properties) {
StringList::ConstIterator it = properties.begin();
for (; it != properties.end(); ++it)
removeItem(*it);
}
PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) {
PropertyMap properties(origProps); // make a local copy that can be modified
// see comment in properties()
for (size_t i = 0; i < keyConversionsSize; ++i)
if (properties.contains(keyConversions[i][0])) {
properties.insert(keyConversions[i][1], properties[keyConversions[i][0]]);
properties.erase(keyConversions[i][0]);
}
// first check if tags need to be removed completely
StringList toRemove;
ItemListMap::ConstIterator remIt = itemListMap().begin();
for (; remIt != itemListMap().end(); ++remIt) {
String key = remIt->first.upper();
// only remove if a) key is valid, b) type is text, c) key not contained in new properties
if (!key.isEmpty() && remIt->second.type() == APE::Item::Text && !properties.contains(key))
toRemove.append(remIt->first);
}
for (StringList::ConstIterator removeIt = toRemove.begin(); removeIt != toRemove.end(); removeIt++)
removeItem(*removeIt);
// now sync in the "forward direction"
PropertyMap::ConstIterator it = properties.begin();
PropertyMap invalid;
for (; it != properties.end(); ++it) {
const String &tagName = it->first;
if (!checkKey(tagName))
invalid.insert(it->first, it->second);
else if (!(itemListMap().contains(tagName)) || !(itemListMap()[tagName].values() == it->second)) {
if (it->second.isEmpty())
removeItem(tagName);
else {
StringList::ConstIterator valueIt = it->second.begin();
addValue(tagName, *valueIt, true);
++valueIt;
for (; valueIt != it->second.end(); ++valueIt)
addValue(tagName, *valueIt, false);
}
}
}
return invalid;
}
bool APE::Tag::checkKey(const String &key) {
if (key.size() < MinKeyLength || key.size() > MaxKeyLength)
return false;
return isKeyValid(key.data(String::UTF8));
}
APE::Footer *APE::Tag::footer() const {
return &d->footer;
}
const APE::ItemListMap &APE::Tag::itemListMap() const {
return d->itemListMap;
}
void APE::Tag::removeItem(const String &key) {
d->itemListMap.erase(key.upper());
}
void APE::Tag::addValue(const String &key, const String &value, bool replace) {
if (replace)
removeItem(key);
if (value.isEmpty())
return;
// Text items may contain more than one value.
// Binary or locator items may have only one value, hence always replaced.
ItemListMap::Iterator it = d->itemListMap.find(key.upper());
if (it != d->itemListMap.end() && it->second.type() == Item::Text)
it->second.appendValue(value);
else
setItem(key, Item(key, value));
}
void APE::Tag::setData(const String &key, const ByteVector &value) {
removeItem(key);
if (value.isEmpty())
return;
setItem(key, Item(key, value, true));
}
void APE::Tag::setItem(const String &key, const Item &item) {
if (!checkKey(key)) {
debug("APE::Tag::setItem() - Couldn't set an item due to an invalid key.");
return;
}
d->itemListMap[key.upper()] = item;
}
bool APE::Tag::isEmpty() const {
return d->itemListMap.isEmpty();
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
void APE::Tag::read() {
if (d->file && d->file->isValid()) {
d->file->seek(d->footerLocation);
d->footer.setData(d->file->readBlock(Footer::size()));
if (d->footer.tagSize() <= Footer::size() ||
d->footer.tagSize() > static_cast<unsigned long>(d->file->length()))
return;
d->file->seek(d->footerLocation + Footer::size() - d->footer.tagSize());
parse(d->file->readBlock(d->footer.tagSize() - Footer::size()));
}
}
ByteVector APE::Tag::render() const {
ByteVector data;
unsigned int itemCount = 0;
for (ItemListMap::ConstIterator it = d->itemListMap.begin(); it != d->itemListMap.end(); ++it) {
data.append(it->second.render());
itemCount++;
}
d->footer.setItemCount(itemCount);
d->footer.setTagSize(data.size() + Footer::size());
d->footer.setHeaderPresent(true);
return d->footer.renderHeader() + data + d->footer.renderFooter();
}
void APE::Tag::parse(const ByteVector &data) {
// 11 bytes is the minimum size for an APE item
if (data.size() < 11)
return;
size_t pos = 0;
for (unsigned int i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) {
const size_t nullPos = data.find('\0', pos + 8);
if (nullPos == ByteVector::npos()) {
debug("APE::Tag::parse() - Couldn't find a key/value separator. Stopped parsing.");
return;
}
const size_t keyLength = nullPos - pos - 8;
const size_t valLegnth = data.toUInt32LE(pos);
if (keyLength >= MinKeyLength && keyLength <= MaxKeyLength && isKeyValid(data.mid(pos + 8, keyLength))) {
APE::Item item;
item.parse(data.mid(pos));
d->itemListMap.insert(item.key().upper(), item);
}
else {
debug("APE::Tag::parse() - Skipped an item due to an invalid key.");
}
pos += keyLength + valLegnth + 9;
}
}

View File

@@ -1,216 +0,0 @@
/***************************************************************************
copyright : (C) 2004 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_APETAG_H
#define TAGLIB_APETAG_H
#include "tag.h"
#include "tbytevector.h"
#include "tmap.h"
#include "tstring.h"
#include "taglib_export.h"
#include "apeitem.h"
#define FRONT_COVER "COVER ART (FRONT)"
#define BACK_COVER "COVER ART (BACK)"
namespace Strawberry_TagLib {
namespace TagLib {
class File;
//! An implementation of the APE tagging format
namespace APE {
class Footer;
/*!
* A mapping between a list of item names, or keys, and the associated item.
*
* \see APE::Tag::itemListMap()
*/
typedef Map<String, Item> ItemListMap;
//! An APE tag implementation
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
public:
/*!
* Create an APE tag with default values.
*/
explicit Tag();
/*!
* Create an APE tag and parse the data in \a file with APE footer at
* \a tagOffset.
*/
explicit Tag(Strawberry_TagLib::TagLib::File *file, long long footerLocation);
/*!
* Destroys this Tag instance.
*/
~Tag() override;
/*!
* Renders the in memory values to a ByteVector suitable for writing to the file.
*/
ByteVector render() const;
/*!
* Returns the string "APETAGEX" suitable for usage in locating the tag in a file.
*/
static ByteVector fileIdentifier();
// Reimplementations.
String title() const override;
String artist() const override;
String album() const override;
String comment() const override;
String genre() const override;
unsigned int year() const override;
unsigned int track() const override;
/**
* @brief pictures
* According to :
* http://www.hydrogenaud.io/forums/index.php?showtopic=40603&st=50&p=504669&#entry504669
* http://git.videolan.org/?p=vlc.git;a=blob;f=modules/meta_engine/taglib.cpp
* @return
*/
PictureMap pictures() const override;
void setTitle(const String &s) override;
void setArtist(const String &s) override;
void setAlbum(const String &s) override;
void setComment(const String &s) override;
void setGenre(const String &s) override;
void setYear(unsigned int i) override;
void setTrack(unsigned int i) override;
void setPictures(const PictureMap &l) override;
/*!
* Implements the unified tag dictionary interface -- export function.
* APE tags are perfectly compatible with the dictionary interface because they
* support both arbitrary tag names and multiple values.
* Currently only APE items of type *Text* are handled by the dictionary interface; all *Binary*
* and *Locator* items will be put into the unsupportedData list and can be
* deleted on request using removeUnsupportedProperties().
* The same happens to Text items if their key is invalid for PropertyMap (which should actually never happen).
*
* The only conversion done by this export function is to rename the APE tags
* TRACK to TRACKNUMBER, YEAR to DATE, and ALBUM ARTIST to ALBUMARTIST,
* respectively, in order to be compliant with the names used in other formats.
*/
PropertyMap properties() const override;
void removeUnsupportedProperties(const StringList &properties) override;
/*!
* Implements the unified tag dictionary interface -- import function.
* The same comments as for the export function apply; additionally note that the APE tag
* specification requires keys to have between 2 and 16 printable ASCII characters
* with the exception of the fixed strings "ID3", "TAG", "OGGS", and "MP+".
*/
PropertyMap setProperties(const PropertyMap &) override;
/*!
* Check if the given String is a valid APE tag key.
*/
static bool checkKey(const String &);
/*!
* Returns a pointer to the tag's footer.
*/
Footer *footer() const;
/*!
* Returns a reference to the item list map.
* This is an ItemListMap of all of the items in the tag.
*
* This is the most powerful structure for accessing the items of the tag.
*
* APE tags are case-insensitive, all keys in this map have been converted
* to upper case.
*
* \warning You should not modify this data structure directly, instead
* use setItem() and removeItem().
*/
const ItemListMap &itemListMap() const;
/*!
* Removes the \a key item from the tag
*/
void removeItem(const String &key);
/*!
* Adds to the text item specified by \a key the data \a value.
* If \a replace is true, then all of the other values on the same key will be removed first.
* If a binary item exists for \a key it will be removed first.
*/
void addValue(const String &key, const String &value, bool replace = true);
/*!
* Set the binary data for the key specified by \a item to \a value
* This will convert the item to type \a Binary if it isn't already and all of the other values on the same key will be removed.
*/
void setData(const String &key, const ByteVector &value);
/*!
* Sets the \a key item to the value of \a item. If an item with the \a key is already present, it will be replaced.
*/
void setItem(const String &key, const Item &item);
/*!
* Returns true if the tag does not contain any data.
*/
bool isEmpty() const override;
protected:
/*!
* Reads from the file specified in the constructor.
*/
void read();
/*!
* Parses the body of the tag in \a data.
*/
void parse(const ByteVector &data);
private:
Tag(const Tag &);
Tag &operator=(const Tag &);
class TagPrivate;
TagPrivate *d;
};
} // namespace APE
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,328 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "taglib.h"
#include "tdebug.h"
#include "asfattribute.h"
#include "asffile.h"
#include "asfutils.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
struct AttributeData {
explicit AttributeData() : numericValue(0), stream(0), language(0) {}
ASF::Attribute::AttributeTypes type;
String stringValue;
ByteVector byteVectorValue;
ASF::Picture pictureValue;
unsigned long long numericValue;
int stream;
int language;
};
} // namespace
class ASF::Attribute::AttributePrivate {
public:
AttributePrivate() : data(new AttributeData()) {
data->pictureValue = ASF::Picture::fromInvalid();
}
std::shared_ptr<AttributeData> data;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
ASF::Attribute::Attribute() : d(new AttributePrivate()) {
d->data->type = UnicodeType;
}
ASF::Attribute::Attribute(const ASF::Attribute &other) : d(new AttributePrivate(*other.d)) {}
ASF::Attribute::Attribute(const String &value) : d(new AttributePrivate()) {
d->data->type = UnicodeType;
d->data->stringValue = value;
}
ASF::Attribute::Attribute(const ByteVector &value) : d(new AttributePrivate()) {
d->data->type = BytesType;
d->data->byteVectorValue = value;
}
ASF::Attribute::Attribute(const ASF::Picture &value) : d(new AttributePrivate()) {
d->data->type = BytesType;
d->data->pictureValue = value;
}
ASF::Attribute::Attribute(unsigned int value) : d(new AttributePrivate()) {
d->data->type = DWordType;
d->data->numericValue = value;
}
ASF::Attribute::Attribute(unsigned long long value) : d(new AttributePrivate()) {
d->data->type = QWordType;
d->data->numericValue = value;
}
ASF::Attribute::Attribute(unsigned short value) : d(new AttributePrivate()) {
d->data->type = WordType;
d->data->numericValue = value;
}
ASF::Attribute::Attribute(bool value) : d(new AttributePrivate()) {
d->data->type = BoolType;
d->data->numericValue = value;
}
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) {
Attribute(other).swap(*this);
return *this;
}
void ASF::Attribute::swap(Attribute &other) {
using std::swap;
swap(d, other.d);
}
ASF::Attribute::~Attribute() {
delete d;
}
ASF::Attribute::AttributeTypes ASF::Attribute::type() const {
return d->data->type;
}
String ASF::Attribute::toString() const {
return d->data->stringValue;
}
ByteVector ASF::Attribute::toByteVector() const {
if (d->data->pictureValue.isValid())
return d->data->pictureValue.render();
return d->data->byteVectorValue;
}
unsigned short ASF::Attribute::toBool() const {
return d->data->numericValue ? 1 : 0;
}
unsigned short ASF::Attribute::toUShort() const {
return static_cast<unsigned short>(d->data->numericValue);
}
unsigned int ASF::Attribute::toUInt() const {
return static_cast<unsigned int>(d->data->numericValue);
}
unsigned long long ASF::Attribute::toULongLong() const {
return static_cast<unsigned long long>(d->data->numericValue);
}
ASF::Picture ASF::Attribute::toPicture() const {
return d->data->pictureValue;
}
String ASF::Attribute::parse(ASF::File &f, int kind) {
unsigned int size, nameLength;
String name;
d->data->pictureValue = Picture::fromInvalid();
// extended content descriptor
if (kind == 0) {
nameLength = readWORD(&f);
name = readString(&f, nameLength);
d->data->type = ASF::Attribute::AttributeTypes(readWORD(&f));
size = readWORD(&f);
}
// metadata & metadata library
else {
int temp = readWORD(&f);
// metadata library
if (kind == 2) {
d->data->language = temp;
}
d->data->stream = readWORD(&f);
nameLength = readWORD(&f);
d->data->type = ASF::Attribute::AttributeTypes(readWORD(&f));
size = readDWORD(&f);
name = readString(&f, nameLength);
}
if (kind != 2 && size > 65535) {
debug("ASF::Attribute::parse() -- Value larger than 64kB");
}
switch (d->data->type) {
case WordType:
d->data->numericValue = readWORD(&f);
break;
case BoolType:
if (kind == 0) {
d->data->numericValue = (readDWORD(&f) != 0);
}
else {
d->data->numericValue = (readWORD(&f) != 0);
}
break;
case DWordType:
d->data->numericValue = readDWORD(&f);
break;
case QWordType:
d->data->numericValue = readQWORD(&f);
break;
case UnicodeType:
d->data->stringValue = readString(&f, size);
break;
case BytesType:
case GuidType:
d->data->byteVectorValue = f.readBlock(size);
break;
}
if (d->data->type == BytesType && name == "WM/Picture") {
d->data->pictureValue.parse(d->data->byteVectorValue);
if (d->data->pictureValue.isValid()) {
d->data->byteVectorValue.clear();
}
}
return name;
}
int ASF::Attribute::dataSize() const {
switch (d->data->type) {
case WordType:
return 2;
case BoolType:
return 4;
case DWordType:
return 4;
case QWordType:
return 5;
case UnicodeType:
return static_cast<int>(d->data->stringValue.size() * 2 + 2);
case BytesType:
if (d->data->pictureValue.isValid())
return d->data->pictureValue.dataSize();
break;
case GuidType:
return static_cast<int>(d->data->byteVectorValue.size());
}
return 0;
}
ByteVector ASF::Attribute::render(const String &name, int kind) const {
ByteVector data;
switch (d->data->type) {
case WordType:
data.append(ByteVector::fromUInt16LE(toUShort()));
break;
case BoolType:
if (kind == 0) {
data.append(ByteVector::fromUInt32LE(toBool()));
}
else {
data.append(ByteVector::fromUInt16LE(toBool()));
}
break;
case DWordType:
data.append(ByteVector::fromUInt32LE(toUInt()));
break;
case QWordType:
data.append(ByteVector::fromUInt64LE(toULongLong()));
break;
case UnicodeType:
data.append(renderString(d->data->stringValue));
break;
case BytesType:
if (d->data->pictureValue.isValid()) {
data.append(d->data->pictureValue.render());
break;
}
break;
case GuidType:
data.append(d->data->byteVectorValue);
break;
}
if (kind == 0) {
data = renderString(name, true) +
ByteVector::fromUInt16LE((int)d->data->type) +
ByteVector::fromUInt16LE(data.size()) +
data;
}
else {
ByteVector nameData = renderString(name);
data = ByteVector::fromUInt16LE(kind == 2 ? d->data->language : 0) +
ByteVector::fromUInt16LE(d->data->stream) +
ByteVector::fromUInt16LE(nameData.size()) +
ByteVector::fromUInt16LE(static_cast<int>(d->data->type)) +
ByteVector::fromUInt32LE(data.size()) +
nameData +
data;
}
return data;
}
int ASF::Attribute::language() const {
return d->data->language;
}
void ASF::Attribute::setLanguage(int value) {
d->data->language = value;
}
int ASF::Attribute::stream() const {
return d->data->stream;
}
void ASF::Attribute::setStream(int value) {
d->data->stream = value;
}

View File

@@ -1,200 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_ASFATTRIBUTE_H
#define TAGLIB_ASFATTRIBUTE_H
#include "tstring.h"
#include "tbytevector.h"
#include "taglib_export.h"
#include "asfpicture.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace ASF {
class File;
class Picture;
class TAGLIB_EXPORT Attribute {
public:
/*!
* Enum of types an Attribute can have.
*/
enum AttributeTypes {
UnicodeType = 0,
BytesType = 1,
BoolType = 2,
DWordType = 3,
QWordType = 4,
WordType = 5,
GuidType = 6
};
/*!
* Constructs an empty attribute.
*/
Attribute();
/*!
* Constructs an attribute with \a key and a UnicodeType \a value.
*/
Attribute(const String &value);
/*!
* Constructs an attribute with \a key and a BytesType \a value.
*/
Attribute(const ByteVector &value);
/*!
* Constructs an attribute with \a key and a Picture \a value.
*
* This attribute is compatible with the ID3 frame, APIC. The ID3 specification for the APIC frame stipulates that,
* while there may be any number of APIC frames associated with a file,
* only one may be of type 1 and only one may be of type 2.
*
* The specification also states that the description of the picture can be no longer than 64 characters, but can be empty.
* WM/Picture attributes added with TagLib::ASF are not automatically validated to conform to ID3 specifications.
* You must add code in your application to perform validations if you want to maintain complete compatibility with ID3.
*/
Attribute(const Picture &value);
/*!
* Constructs an attribute with \a key and a DWordType \a value.
*/
Attribute(unsigned int value);
/*!
* Constructs an attribute with \a key and a QWordType \a value.
*/
Attribute(unsigned long long value);
/*!
* Constructs an attribute with \a key and a WordType \a value.
*/
Attribute(unsigned short value);
/*!
* Constructs an attribute with \a key and a BoolType \a value.
*/
Attribute(bool value);
/*!
* Construct an attribute as a copy of \a other.
*/
Attribute(const Attribute &other);
/*!
* Copies the contents of \a other into this item.
*/
Attribute &operator=(const Attribute &other);
/*!
* Exchanges the content of the Attribute by the content of \a other.
*/
void swap(Attribute &other);
/*!
* Destroys the attribute.
*/
virtual ~Attribute();
/*!
* Returns type of the value.
*/
AttributeTypes type() const;
/*!
* Returns the BoolType \a value.
*/
unsigned short toBool() const;
/*!
* Returns the WordType \a value.
*/
unsigned short toUShort() const;
/*!
* Returns the DWordType \a value.
*/
unsigned int toUInt() const;
/*!
* Returns the QWordType \a value.
*/
unsigned long long toULongLong() const;
/*!
* Returns the UnicodeType \a value.
*/
String toString() const;
/*!
* Returns the BytesType \a value.
*/
ByteVector toByteVector() const;
/*!
* Returns the Picture \a value.
*/
Picture toPicture() const;
/*!
* Returns the language number, or 0 is no stream number was set.
*/
int language() const;
/*!
* Sets the language number.
*/
void setLanguage(int value);
/*!
* Returns the stream number, or 0 is no stream number was set.
*/
int stream() const;
/*!
* Sets the stream number.
*/
void setStream(int value);
//! Returns the size of the stored data
int dataSize() const;
private:
friend class File;
String parse(ASF::File &file, int kind = 0);
ByteVector render(const String &name, int kind = 0) const;
class AttributePrivate;
AttributePrivate *d;
};
} // namespace ASF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,661 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "tdebug.h"
#include "tbytevectorlist.h"
#include "tpropertymap.h"
#include "tstring.h"
#include "tagutils.h"
#include "asffile.h"
#include "asftag.h"
#include "asfproperties.h"
#include "asfutils.h"
using namespace Strawberry_TagLib::TagLib;
class ASF::File::FilePrivate {
public:
class BaseObject;
class UnknownObject;
class FilePropertiesObject;
class StreamPropertiesObject;
class ContentDescriptionObject;
class ExtendedContentDescriptionObject;
class HeaderExtensionObject;
class CodecListObject;
class MetadataObject;
class MetadataLibraryObject;
typedef List<std::shared_ptr<BaseObject>> ObjectList;
typedef ObjectList::ConstIterator ObjectConstIterator;
FilePrivate() : headerSize(0) {}
unsigned long long headerSize;
std::unique_ptr<ASF::Tag> tag;
std::unique_ptr<ASF::AudioProperties> properties;
ObjectList objects;
std::shared_ptr<ContentDescriptionObject> contentDescriptionObject;
std::shared_ptr<ExtendedContentDescriptionObject> extendedContentDescriptionObject;
std::shared_ptr<HeaderExtensionObject> headerExtensionObject;
std::shared_ptr<MetadataObject> metadataObject;
std::shared_ptr<MetadataLibraryObject> metadataLibraryObject;
};
namespace {
const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16);
const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16);
const ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
const ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16);
const ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16);
const ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16);
const ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16);
const ByteVector codecListGuid("\x40\x52\xd1\x86\x1d\x31\xd0\x11\xa3\xa4\x00\xa0\xc9\x03\x48\xf6", 16);
const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16);
const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16);
const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16);
} // namespace
class ASF::File::FilePrivate::BaseObject {
public:
ByteVector data;
virtual ~BaseObject() {}
virtual ByteVector guid() const = 0;
virtual void parse(ASF::File *file, unsigned int size);
virtual ByteVector render(ASF::File *file);
};
class ASF::File::FilePrivate::UnknownObject : public ASF::File::FilePrivate::BaseObject {
ByteVector myGuid;
public:
explicit UnknownObject(const ByteVector &guid);
ByteVector guid() const override;
};
class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePrivate::BaseObject {
public:
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
};
class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject {
public:
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
};
class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject {
public:
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
ByteVector render(ASF::File *file) override;
};
class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::File::FilePrivate::BaseObject {
public:
ByteVectorList attributeData;
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
ByteVector render(ASF::File *file) override;
};
class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::BaseObject {
public:
ByteVectorList attributeData;
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
ByteVector render(ASF::File *file) override;
};
class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePrivate::BaseObject {
public:
ByteVectorList attributeData;
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
ByteVector render(ASF::File *file) override;
};
class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject {
public:
ObjectList objects;
HeaderExtensionObject();
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
ByteVector render(ASF::File *file) override;
};
class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::BaseObject {
public:
ByteVector guid() const override;
void parse(ASF::File *file, unsigned int size) override;
private:
enum CodecType {
Video = 0x0001,
Audio = 0x0002,
Unknown = 0xFFFF
};
};
void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) {
data.clear();
if (size > 24 && static_cast<long long>(size) <= file->length())
data = file->readBlock(size - 24);
else
data = ByteVector();
}
ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/) {
return guid() + ByteVector::fromUInt64LE(data.size() + 24) + data;
}
ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid) {}
ByteVector ASF::File::FilePrivate::UnknownObject::guid() const {
return myGuid;
}
ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const {
return filePropertiesGuid;
}
void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size) {
BaseObject::parse(file, size);
if (data.size() < 64) {
debug("ASF::File::FilePrivate::FilePropertiesObject::parse() -- data is too short.");
return;
}
const long long duration = data.toInt64LE(40);
const long long preroll = data.toInt64LE(56);
file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5));
}
ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const {
return streamPropertiesGuid;
}
void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size) {
BaseObject::parse(file, size);
if (data.size() < 70) {
debug("ASF::File::FilePrivate::StreamPropertiesObject::parse() -- data is too short.");
return;
}
file->d->properties->setCodec(data.toUInt16LE(54));
file->d->properties->setChannels(data.toUInt16LE(56));
file->d->properties->setSampleRate(data.toUInt32LE(58));
file->d->properties->setBitrate(static_cast<int>(data.toUInt32LE(62) * 8.0 / 1000.0 + 0.5));
file->d->properties->setBitsPerSample(data.toUInt16LE(68));
}
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const {
return contentDescriptionGuid;
}
void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) {
const int titleLength = readWORD(file);
const int artistLength = readWORD(file);
const int copyrightLength = readWORD(file);
const int commentLength = readWORD(file);
const int ratingLength = readWORD(file);
file->d->tag->setTitle(readString(file, titleLength));
file->d->tag->setArtist(readString(file, artistLength));
file->d->tag->setCopyright(readString(file, copyrightLength));
file->d->tag->setComment(readString(file, commentLength));
file->d->tag->setRating(readString(file, ratingLength));
}
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *file) {
const ByteVector v1 = renderString(file->d->tag->title());
const ByteVector v2 = renderString(file->d->tag->artist());
const ByteVector v3 = renderString(file->d->tag->copyright());
const ByteVector v4 = renderString(file->d->tag->comment());
const ByteVector v5 = renderString(file->d->tag->rating());
data.clear();
data.append(ByteVector::fromUInt16LE(v1.size()));
data.append(ByteVector::fromUInt16LE(v2.size()));
data.append(ByteVector::fromUInt16LE(v3.size()));
data.append(ByteVector::fromUInt16LE(v4.size()));
data.append(ByteVector::fromUInt16LE(v5.size()));
data.append(v1);
data.append(v2);
data.append(v3);
data.append(v4);
data.append(v5);
return BaseObject::render(file);
}
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() const {
return extendedContentDescriptionGuid;
}
void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) {
int count = readWORD(file);
while (count--) {
ASF::Attribute attribute;
String name = attribute.parse(*file);
file->d->tag->addAttribute(name, attribute);
}
}
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) {
data.clear();
data.append(ByteVector::fromUInt16LE(attributeData.size()));
data.append(attributeData.toByteVector(""));
return BaseObject::render(file);
}
ByteVector ASF::File::FilePrivate::MetadataObject::guid() const {
return metadataGuid;
}
void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/) {
int count = readWORD(file);
while (count--) {
ASF::Attribute attribute;
String name = attribute.parse(*file, 1);
file->d->tag->addAttribute(name, attribute);
}
}
ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) {
data.clear();
data.append(ByteVector::fromUInt16LE(attributeData.size()));
data.append(attributeData.toByteVector(""));
return BaseObject::render(file);
}
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const {
return metadataLibraryGuid;
}
void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/) {
int count = readWORD(file);
while (count--) {
ASF::Attribute attribute;
String name = attribute.parse(*file, 2);
file->d->tag->addAttribute(name, attribute);
}
}
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) {
data.clear();
data.append(ByteVector::fromUInt16LE(attributeData.size()));
data.append(attributeData.toByteVector(""));
return BaseObject::render(file);
}
ASF::File::FilePrivate::HeaderExtensionObject::HeaderExtensionObject() {
objects.setAutoDelete(true);
}
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const {
return headerExtensionGuid;
}
void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/) {
file->seek(18, File::Current);
long long dataSize = readDWORD(file);
long long dataPos = 0;
while (dataPos < dataSize) {
ByteVector guid = file->readBlock(16);
if (guid.size() != 16) {
file->setValid(false);
break;
}
bool ok;
long long size = readQWORD(file, &ok);
if (!ok) {
file->setValid(false);
break;
}
std::shared_ptr<BaseObject> obj;
if (guid == metadataGuid) {
file->d->metadataObject.reset(new MetadataObject());
obj = file->d->metadataObject;
}
else if (guid == metadataLibraryGuid) {
file->d->metadataLibraryObject.reset(new MetadataLibraryObject());
obj = file->d->metadataLibraryObject;
}
else {
obj.reset(new UnknownObject(guid));
}
obj->parse(file, static_cast<unsigned int>(size));
objects.append(obj);
dataPos += size;
}
}
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) {
data.clear();
for (ObjectConstIterator it = objects.begin(); it != objects.end(); ++it) {
data.append((*it)->render(file));
}
data = ByteVector("\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65\x06\x00", 18) + ByteVector::fromUInt32LE(data.size()) + data;
return BaseObject::render(file);
}
ByteVector ASF::File::FilePrivate::CodecListObject::guid() const {
return codecListGuid;
}
void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size) {
BaseObject::parse(file, size);
if (data.size() <= 20) {
debug("ASF::File::FilePrivate::CodecListObject::parse() -- data is too short.");
return;
}
unsigned int pos = 16;
const int count = data.toUInt32LE(pos);
pos += 4;
for (int i = 0; i < count; ++i) {
if (pos >= data.size())
break;
const CodecType type = static_cast<CodecType>(data.toUInt16LE(pos));
pos += 2;
int nameLength = data.toUInt16LE(pos);
pos += 2;
const unsigned int namePos = pos;
pos += nameLength * 2;
const int descLength = data.toUInt16LE(pos);
pos += 2;
const unsigned int descPos = pos;
pos += descLength * 2;
const int infoLength = data.toUInt16LE(pos);
pos += 2 + infoLength * 2;
if (type == CodecListObject::Audio) {
// First audio codec found.
const String name(data.mid(namePos, nameLength * 2), String::UTF16LE);
file->d->properties->setCodecName(name.stripWhiteSpace());
const String desc(data.mid(descPos, descLength * 2), String::UTF16LE);
file->d->properties->setCodecDescription(desc.stripWhiteSpace());
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
bool ASF::File::isSupported(IOStream *stream) {
// An ASF file has to start with the designated GUID.
const ByteVector id = Utils::readHeader(stream, 16, false);
return (id == headerGuid);
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
ASF::File::File(FileName file, bool, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
if (isOpen())
read();
}
ASF::File::File(IOStream *stream, bool, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
if (isOpen())
read();
}
ASF::File::~File() {
delete d;
}
ASF::Tag *ASF::File::tag() const {
return d->tag.get();
}
ASF::AudioProperties *ASF::File::audioProperties() const {
return d->properties.get();
}
bool ASF::File::save() {
if (readOnly()) {
debug("ASF::File::save() -- File is read only.");
return false;
}
if (!isValid()) {
debug("ASF::File::save() -- Trying to save invalid file.");
return false;
}
if (!d->contentDescriptionObject) {
d->contentDescriptionObject.reset(new FilePrivate::ContentDescriptionObject());
d->objects.append(d->contentDescriptionObject);
}
if (!d->extendedContentDescriptionObject) {
d->extendedContentDescriptionObject.reset(new FilePrivate::ExtendedContentDescriptionObject());
d->objects.append(d->extendedContentDescriptionObject);
}
if (!d->headerExtensionObject) {
d->headerExtensionObject.reset(new FilePrivate::HeaderExtensionObject());
d->objects.append(d->headerExtensionObject);
}
if (!d->metadataObject) {
d->metadataObject.reset(new FilePrivate::MetadataObject());
d->headerExtensionObject->objects.append(d->metadataObject);
}
if (!d->metadataLibraryObject) {
d->metadataLibraryObject.reset(new FilePrivate::MetadataLibraryObject());
d->headerExtensionObject->objects.append(d->metadataLibraryObject);
}
d->extendedContentDescriptionObject->attributeData.clear();
d->metadataObject->attributeData.clear();
d->metadataLibraryObject->attributeData.clear();
const AttributeListMap allAttributes = d->tag->attributeListMap();
for (AttributeListMap::ConstIterator it = allAttributes.begin(); it != allAttributes.end(); ++it) {
const String &name = it->first;
const AttributeList &attributes = it->second;
bool inExtendedContentDescriptionObject = false;
bool inMetadataObject = false;
for (AttributeList::ConstIterator jt = attributes.begin(); jt != attributes.end(); ++jt) {
const Attribute &attribute = *jt;
const bool largeValue = (attribute.dataSize() > 65535);
const bool guid = (attribute.type() == Attribute::GuidType);
if (!inExtendedContentDescriptionObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() == 0) {
d->extendedContentDescriptionObject->attributeData.append(attribute.render(name));
inExtendedContentDescriptionObject = true;
}
else if (!inMetadataObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() != 0) {
d->metadataObject->attributeData.append(attribute.render(name, 1));
inMetadataObject = true;
}
else {
d->metadataLibraryObject->attributeData.append(attribute.render(name, 2));
}
}
}
ByteVector data;
for (FilePrivate::ObjectConstIterator it = d->objects.begin(); it != d->objects.end(); ++it) {
data.append((*it)->render(this));
}
seek(16);
writeBlock(ByteVector::fromUInt64LE(data.size() + 30));
writeBlock(ByteVector::fromUInt32LE(d->objects.size()));
writeBlock(ByteVector("\x01\x02", 2));
insert(data, 30, static_cast<size_t>(d->headerSize - 30));
d->headerSize = data.size() + 30;
return true;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void ASF::File::read() {
if (!isValid())
return;
if (readBlock(16) != headerGuid) {
debug("ASF::File::read(): Not an ASF file.");
setValid(false);
return;
}
d->tag.reset(new ASF::Tag());
d->properties.reset(new ASF::AudioProperties());
bool ok;
d->headerSize = readQWORD(this, &ok);
if (!ok) {
setValid(false);
return;
}
int numObjects = readDWORD(this, &ok);
if (!ok) {
setValid(false);
return;
}
seek(2, Current);
std::shared_ptr<FilePrivate::FilePropertiesObject> filePropertiesObject;
std::shared_ptr<FilePrivate::StreamPropertiesObject> streamPropertiesObject;
for (int i = 0; i < numObjects; i++) {
const ByteVector guid = readBlock(16);
if (guid.size() != 16) {
setValid(false);
break;
}
long size = static_cast<long>(readQWORD(this, &ok));
if (!ok) {
setValid(false);
break;
}
std::shared_ptr<FilePrivate::BaseObject> obj;
if (guid == filePropertiesGuid) {
filePropertiesObject.reset(new FilePrivate::FilePropertiesObject());
obj = filePropertiesObject;
}
else if (guid == streamPropertiesGuid) {
streamPropertiesObject.reset(new FilePrivate::StreamPropertiesObject());
obj = streamPropertiesObject;
}
else if (guid == contentDescriptionGuid) {
d->contentDescriptionObject.reset(new FilePrivate::ContentDescriptionObject());
obj = d->contentDescriptionObject;
}
else if (guid == extendedContentDescriptionGuid) {
d->extendedContentDescriptionObject.reset(new FilePrivate::ExtendedContentDescriptionObject());
obj = d->extendedContentDescriptionObject;
}
else if (guid == headerExtensionGuid) {
d->headerExtensionObject.reset(new FilePrivate::HeaderExtensionObject());
obj = d->headerExtensionObject;
}
else if (guid == codecListGuid) {
obj.reset(new FilePrivate::CodecListObject());
}
else {
if (guid == contentEncryptionGuid ||
guid == extendedContentEncryptionGuid ||
guid == advancedContentEncryptionGuid) {
d->properties->setEncrypted(true);
}
obj.reset(new FilePrivate::UnknownObject(guid));
}
obj->parse(this, size);
d->objects.append(obj);
}
if (!filePropertiesObject || !streamPropertiesObject) {
debug("ASF::File::read(): Missing mandatory header objects.");
setValid(false);
return;
}
}

View File

@@ -1,118 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_ASFFILE_H
#define TAGLIB_ASFFILE_H
#include "tag.h"
#include "tfile.h"
#include "taglib_export.h"
#include "asfproperties.h"
#include "asftag.h"
namespace Strawberry_TagLib {
namespace TagLib {
//! An implementation of ASF (WMA) metadata
namespace ASF {
/*!
* This implements and provides an interface for ASF files to the
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
* the abstract TagLib::File API as well as providing some additional
* information specific to ASF files.
*/
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
public:
/*!
* Constructs an ASF file from \a file.
*
* \note In the current implementation, both \a readProperties and
* \a propertiesStyle are ignored. The audio properties are always
* read.
*/
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Constructs an ASF file from \a stream.
*
* \note In the current implementation, both \a readProperties and
* \a propertiesStyle are ignored. The audio properties are always
* read.
*
* \note TagLib will *not* take ownership of the stream, the caller is
* responsible for deleting it after the File object.
*/
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
~File() override;
/*!
* Returns a pointer to the ASF tag of the file.
*
* ASF::Tag implements the tag interface, so this serves as the
* reimplementation of TagLib::File::tag().
*
* \note The Tag <b>is still</b> owned by the ASF::File and should not be
* deleted by the user. It will be deleted when the file (object) is
* destroyed.
*/
Tag *tag() const override;
/*!
* Returns the ASF audio properties for this file.
*/
AudioProperties *audioProperties() const override;
/*!
* Save the file.
*
* This returns true if the save was successful.
*/
bool save() override;
/*!
* Returns whether or not the given \a stream can be opened as an ASF file.
*
* \note This method is designed to do a quick check. The result may not necessarily be correct.
*/
static bool isSupported(IOStream *stream);
private:
void read();
class FilePrivate;
FilePrivate *d;
};
} // namespace ASF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,168 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Anton Sergunov
email : setosha@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "taglib.h"
#include "tdebug.h"
#include "asfattribute.h"
#include "asffile.h"
#include "asfpicture.h"
#include "asfutils.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
struct PictureData {
bool valid;
ASF::Picture::Type type;
String mimeType;
String description;
ByteVector picture;
};
} // namespace
class ASF::Picture::PicturePrivate {
public:
explicit PicturePrivate() : data(new PictureData()) {}
std::shared_ptr<PictureData> data;
};
////////////////////////////////////////////////////////////////////////////////
// Picture class members
////////////////////////////////////////////////////////////////////////////////
ASF::Picture::Picture() : d(new PicturePrivate()) {
d->data->valid = true;
}
ASF::Picture::Picture(const Picture& other) : d(new PicturePrivate(*other.d)) {}
ASF::Picture::~Picture() {
delete d;
}
bool ASF::Picture::isValid() const {
return d->data->valid;
}
String ASF::Picture::mimeType() const {
return d->data->mimeType;
}
void ASF::Picture::setMimeType(const String& value) {
d->data->mimeType = value;
}
ASF::Picture::Type ASF::Picture::type() const {
return d->data->type;
}
void ASF::Picture::setType(const ASF::Picture::Type &t) {
d->data->type = t;
}
String ASF::Picture::description() const {
return d->data->description;
}
void ASF::Picture::setDescription(const String& desc) {
d->data->description = desc;
}
ByteVector ASF::Picture::picture() const {
return d->data->picture;
}
void ASF::Picture::setPicture(const ByteVector &p) {
d->data->picture = p;
}
int ASF::Picture::dataSize() const {
return 9 + (d->data->mimeType.length() + d->data->description.length()) * 2 + d->data->picture.size();
}
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) {
Picture(other).swap(*this);
return *this;
}
void ASF::Picture::swap(Picture& other) {
using std::swap;
swap(d, other.d);
}
ByteVector ASF::Picture::render() const {
if (!isValid())
return ByteVector();
return ByteVector(static_cast<char>(d->data->type)) + ByteVector::fromUInt32LE(d->data->picture.size()) + renderString(d->data->mimeType) + renderString(d->data->description) + d->data->picture;
}
void ASF::Picture::parse(const ByteVector &bytes) {
d->data->valid = false;
if (bytes.size() < 9)
return;
size_t pos = 0;
d->data->type = static_cast<Type>(bytes[0]);
++pos;
const unsigned int dataLen = bytes.toUInt32LE(pos);
pos += 4;
const ByteVector nullStringTerminator(2, 0);
size_t endPos = bytes.find(nullStringTerminator, pos, 2);
if (endPos == ByteVector::npos())
return;
d->data->mimeType = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
pos = endPos + 2;
endPos = bytes.find(nullStringTerminator, pos, 2);
if (endPos == ByteVector::npos())
return;
d->data->description = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
pos = endPos + 2;
if (dataLen + pos != bytes.size())
return;
d->data->picture = bytes.mid(pos, dataLen);
d->data->valid = true;
}
ASF::Picture ASF::Picture::fromInvalid() {
Picture ret;
ret.d->data->valid = false;
return ret;
}

View File

@@ -1,218 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Anton Sergunov
email : setosha@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef ASFPICTURE_H
#define ASFPICTURE_H
#include "tstring.h"
#include "tbytevector.h"
#include "taglib_export.h"
#include "attachedpictureframe.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace ASF {
class Attribute;
//! An ASF attached picture interface implementation
/*!
* This is an implementation of ASF attached pictures interface.
* Pictures may be included in attributes, one per WM/Picture attribute (but there may be multiple WM/Picture attribute in a single tag).
* These pictures are usually in either JPEG or PNG format.
* \see Attribute::toPicture()
* \see Attribute::Attribute(const Picture& picture)
*/
class TAGLIB_EXPORT Picture {
public:
/*!
* This describes the function or content of the picture.
*/
enum Type {
//! A type not enumerated below
Other = 0x00,
//! 32x32 PNG image that should be used as the file icon
FileIcon = 0x01,
//! File icon of a different size or format
OtherFileIcon = 0x02,
//! Front cover image of the album
FrontCover = 0x03,
//! Back cover image of the album
BackCover = 0x04,
//! Inside leaflet page of the album
LeafletPage = 0x05,
//! Image from the album itself
Media = 0x06,
//! Picture of the lead artist or soloist
LeadArtist = 0x07,
//! Picture of the artist or performer
Artist = 0x08,
//! Picture of the conductor
Conductor = 0x09,
//! Picture of the band or orchestra
Band = 0x0A,
//! Picture of the composer
Composer = 0x0B,
//! Picture of the lyricist or text writer
Lyricist = 0x0C,
//! Picture of the recording location or studio
RecordingLocation = 0x0D,
//! Picture of the artists during recording
DuringRecording = 0x0E,
//! Picture of the artists during performance
DuringPerformance = 0x0F,
//! Picture from a movie or video related to the track
MovieScreenCapture = 0x10,
//! Picture of a large, coloured fish
ColouredFish = 0x11,
//! Illustration related to the track
Illustration = 0x12,
//! Logo of the band or performer
BandLogo = 0x13,
//! Logo of the publisher (record company)
PublisherLogo = 0x14
};
/*!
* Constructs an empty picture.
*/
explicit Picture();
/*!
* Construct an picture as a copy of \a other.
*/
Picture(const Picture& other);
/*!
* Destroys the picture.
*/
virtual ~Picture();
/*!
* Copies the contents of \a other into this picture.
*/
Picture& operator=(const Picture& other);
/*!
* Exchanges the content of the Picture by the content of \a other.
*/
void swap(Picture& other);
/*!
* Returns true if Picture stores valid picture
*/
bool isValid() const;
/*!
* Returns the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
* \see setMimeType(const String &)
* \see picture()
* \see setPicture(const ByteArray&)
*/
String mimeType() const;
/*!
* Sets the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
* \see setMimeType(const String &)
* \see picture()
* \see setPicture(const ByteArray&)
*/
void setMimeType(const String& value);
/*!
* Returns the type of the image.
*
* \see Type
* \see setType()
*/
Type type() const;
/*!
* Sets the type for the image.
*
* \see Type
* \see type()
*/
void setType(const ASF::Picture::Type& t);
/*!
* Returns a text description of the image.
*
* \see setDescription()
*/
String description() const;
/*!
* Sets a textual description of the image to \a desc.
*
* \see description()
*/
void setDescription(const String& desc);
/*!
* Returns the image data as a ByteVector.
*
* \note ByteVector has a data() method that returns a const char * which should make it easy to export this data to external programs.
*
* \see setPicture()
* \see mimeType()
*/
ByteVector picture() const;
/*!
* Sets the image data to \a p.
* \a p should be of the type specified in this frame's mime-type specification.
*
* \see picture()
* \see mimeType()
* \see setMimeType()
*/
void setPicture(const ByteVector& p);
/*!
* Returns picture as binary raw data \a value
*/
ByteVector render() const;
/*!
* Returns picture as binary raw data \a value
*/
int dataSize() const;
private:
friend class Attribute;
void parse(const ByteVector&);
static Picture fromInvalid();
private:
class PicturePrivate;
PicturePrivate* d;
};
} // namespace ASF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif // ASFPICTURE_H

View File

@@ -1,160 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tdebug.h"
#include "tstring.h"
#include "asfproperties.h"
using namespace Strawberry_TagLib::TagLib;
class ASF::AudioProperties::AudioPropertiesPrivate {
public:
explicit AudioPropertiesPrivate() : length(0),
bitrate(0),
sampleRate(0),
channels(0),
bitsPerSample(0),
codec(ASF::AudioProperties::Unknown),
encrypted(false) {}
int length;
int bitrate;
int sampleRate;
int channels;
int bitsPerSample;
ASF::AudioProperties::Codec codec;
String codecName;
String codecDescription;
bool encrypted;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
ASF::AudioProperties::AudioProperties() : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
}
ASF::AudioProperties::~AudioProperties() {
delete d;
}
int ASF::AudioProperties::lengthInSeconds() const {
return d->length / 1000;
}
int ASF::AudioProperties::lengthInMilliseconds() const {
return d->length;
}
int ASF::AudioProperties::bitrate() const {
return d->bitrate;
}
int ASF::AudioProperties::sampleRate() const {
return d->sampleRate;
}
int ASF::AudioProperties::channels() const {
return d->channels;
}
int ASF::AudioProperties::bitsPerSample() const {
return d->bitsPerSample;
}
ASF::AudioProperties::Codec ASF::AudioProperties::codec() const {
return d->codec;
}
String ASF::AudioProperties::codecName() const {
return d->codecName;
}
String ASF::AudioProperties::codecDescription() const {
return d->codecDescription;
}
bool ASF::AudioProperties::isEncrypted() const {
return d->encrypted;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void ASF::AudioProperties::setLengthInMilliseconds(int value) {
d->length = value;
}
void ASF::AudioProperties::setBitrate(int value) {
d->bitrate = value;
}
void ASF::AudioProperties::setSampleRate(int value) {
d->sampleRate = value;
}
void ASF::AudioProperties::setChannels(int value) {
d->channels = value;
}
void ASF::AudioProperties::setBitsPerSample(int value) {
d->bitsPerSample = value;
}
void ASF::AudioProperties::setCodec(int value) {
switch (value) {
case 0x0160:
d->codec = WMA1;
break;
case 0x0161:
d->codec = WMA2;
break;
case 0x0162:
d->codec = WMA9Pro;
break;
case 0x0163:
d->codec = WMA9Lossless;
break;
default:
d->codec = Unknown;
break;
}
}
void ASF::AudioProperties::setCodecName(const String &value) {
d->codecName = value;
}
void ASF::AudioProperties::setCodecDescription(const String &value) {
d->codecDescription = value;
}
void ASF::AudioProperties::setEncrypted(bool value) {
d->encrypted = value;
}

View File

@@ -1,168 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_ASFPROPERTIES_H
#define TAGLIB_ASFPROPERTIES_H
#include "audioproperties.h"
#include "tstring.h"
#include "taglib_export.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace ASF {
//! An implementation of ASF audio properties
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
friend class File;
public:
/*!
* Audio codec types can be used in ASF file.
*/
enum Codec {
/*!
* Couldn't detect the codec.
*/
Unknown = 0,
/*!
* Windows Media Audio 1
*/
WMA1,
/*!
* Windows Media Audio 2 or above
*/
WMA2,
/*!
* Windows Media Audio 9 Professional
*/
WMA9Pro,
/*!
* Windows Media Audio 9 Lossless
*/
WMA9Lossless,
};
/*!
* Creates an instance of ASF::Properties.
*/
explicit AudioProperties();
/*!
* Destroys this ASF::AudioProperties instance.
*/
~AudioProperties() override;
/*!
* Returns the length of the file in seconds. The length is rounded down to
* the nearest whole second.
*
* \see lengthInMilliseconds()
*/
int lengthInSeconds() const override;
/*!
* Returns the length of the file in milliseconds.
*
* \see lengthInSeconds()
*/
int lengthInMilliseconds() const override;
/*!
* Returns the average bit rate of the file in kb/s.
*/
int bitrate() const override;
/*!
* Returns the sample rate in Hz.
*/
int sampleRate() const override;
/*!
* Returns the number of audio channels.
*/
int channels() const override;
/*!
* Returns the number of bits per audio sample.
*/
int bitsPerSample() const;
/*!
* Returns the codec used in the file.
*
* \see codecName()
* \see codecDescription()
*/
Codec codec() const;
/*!
* Returns the concrete codec name, for example "Windows Media Audio 9.1" used in the file if available, otherwise an empty string.
*
* \see codec()
* \see codecDescription()
*/
String codecName() const;
/*!
* Returns the codec description, typically contains the encoder settings,
* for example "VBR Quality 50, 44kHz, stereo 1-pass VBR" if available, otherwise an empty string.
*
* \see codec()
* \see codecName()
*/
String codecDescription() const;
/*!
* Returns whether or not the file is encrypted.
*/
bool isEncrypted() const;
private:
void setLengthInMilliseconds(int value);
void setBitrate(int value);
void setSampleRate(int value);
void setChannels(int value);
void setBitsPerSample(int value);
void setCodec(int value);
void setCodecName(const String &value);
void setCodecDescription(const String &value);
void setEncrypted(bool value);
private:
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace ASF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,522 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tpicturemap.h"
#include "tpropertymap.h"
#include "asftag.h"
using namespace Strawberry_TagLib::TagLib;
class ASF::Tag::TagPrivate {
public:
String title;
String artist;
String copyright;
String comment;
String rating;
AttributeListMap attributeListMap;
};
ASF::Tag::Tag() : d(new TagPrivate()) {}
ASF::Tag::~Tag() {
delete d;
}
String ASF::Tag::title() const {
return d->title;
}
String ASF::Tag::artist() const {
return d->artist;
}
String ASF::Tag::album() const {
if (d->attributeListMap.contains("WM/AlbumTitle"))
return d->attributeListMap["WM/AlbumTitle"][0].toString();
return String();
}
String ASF::Tag::copyright() const {
return d->copyright;
}
String ASF::Tag::comment() const {
return d->comment;
}
String ASF::Tag::rating() const {
return d->rating;
}
unsigned int ASF::Tag::year() const {
if (d->attributeListMap.contains("WM/Year"))
return d->attributeListMap["WM/Year"][0].toString().toInt();
return 0;
}
unsigned int ASF::Tag::track() const {
if (d->attributeListMap.contains("WM/TrackNumber")) {
const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
if (attr.type() == ASF::Attribute::DWordType)
return attr.toUInt();
else
return attr.toString().toInt();
}
if (d->attributeListMap.contains("WM/Track"))
return d->attributeListMap["WM/Track"][0].toUInt();
return 0;
}
String ASF::Tag::genre() const {
if (d->attributeListMap.contains("WM/Genre"))
return d->attributeListMap["WM/Genre"][0].toString();
return String();
}
PictureMap ASF::Tag::pictures() const {
PictureMap map;
if (d->attributeListMap.contains("WM/Picture")) {
AttributeList list = d->attributeListMap["WM/Picture"];
for (AttributeList::ConstIterator it = list.begin(); it != list.end(); ++it) {
ASF::Picture asfPicture = (*it).toPicture();
TagLib::Picture::Type type;
switch (asfPicture.type()) {
case ASF::Picture::FileIcon:
type = TagLib::Picture::FileIcon;
break;
case ASF::Picture::OtherFileIcon:
type = TagLib::Picture::OtherFileIcon;
break;
case ASF::Picture::FrontCover:
type = TagLib::Picture::FrontCover;
break;
case ASF::Picture::BackCover:
type = TagLib::Picture::BackCover;
break;
case ASF::Picture::LeafletPage:
type = TagLib::Picture::LeafletPage;
break;
case ASF::Picture::Media:
type = TagLib::Picture::Media;
break;
case ASF::Picture::LeadArtist:
type = TagLib::Picture::LeadArtist;
break;
case ASF::Picture::Artist:
type = TagLib::Picture::Artist;
break;
case ASF::Picture::Conductor:
type = TagLib::Picture::Conductor;
break;
case ASF::Picture::Band:
type = TagLib::Picture::Band;
break;
case ASF::Picture::Composer:
type = TagLib::Picture::Composer;
break;
case ASF::Picture::Lyricist:
type = TagLib::Picture::Lyricist;
break;
case ASF::Picture::RecordingLocation:
type = TagLib::Picture::RecordingLocation;
break;
case ASF::Picture::DuringRecording:
type = TagLib::Picture::DuringRecording;
break;
case ASF::Picture::DuringPerformance:
type = TagLib::Picture::DuringPerformance;
break;
case ASF::Picture::MovieScreenCapture:
type = TagLib::Picture::MovieScreenCapture;
break;
case ASF::Picture::ColouredFish:
type = TagLib::Picture::ColouredFish;
break;
case ASF::Picture::Illustration:
type = TagLib::Picture::Illustration;
break;
case ASF::Picture::BandLogo:
type = TagLib::Picture::BandLogo;
break;
case ASF::Picture::PublisherLogo:
type = TagLib::Picture::PublisherLogo;
break;
default:
type = TagLib::Picture::Other;
break;
}
TagLib::Picture picture(asfPicture.picture(), type, asfPicture.mimeType(), asfPicture.description());
map.insert(picture);
}
}
return PictureMap(map);
}
void ASF::Tag::setTitle(const String &value) {
d->title = value;
}
void ASF::Tag::setArtist(const String &value) {
d->artist = value;
}
void ASF::Tag::setCopyright(const String &value) {
d->copyright = value;
}
void ASF::Tag::setComment(const String &value) {
d->comment = value;
}
void ASF::Tag::setRating(const String &value) {
d->rating = value;
}
void ASF::Tag::setAlbum(const String &value) {
setAttribute("WM/AlbumTitle", value);
}
void ASF::Tag::setGenre(const String &value) {
setAttribute("WM/Genre", value);
}
void ASF::Tag::setYear(unsigned int value) {
setAttribute("WM/Year", String::number(value));
}
void ASF::Tag::setTrack(unsigned int value) {
setAttribute("WM/TrackNumber", String::number(value));
}
void ASF::Tag::setPictures(const PictureMap &l) {
removeItem("WM/Picture");
for (PictureMap::ConstIterator pictureMapIt = l.begin(); pictureMapIt != l.end(); ++pictureMapIt) {
PictureList list = pictureMapIt->second;
for (PictureList::ConstIterator pictureListIt = list.begin(); pictureListIt != list.end(); ++pictureListIt) {
const TagLib::Picture picture = (*pictureListIt);
ASF::Picture asfPicture;
asfPicture.setPicture(picture.data());
asfPicture.setMimeType(picture.mime());
asfPicture.setDescription(picture.description());
switch (picture.type()) {
case TagLib::Picture::Other:
asfPicture.setType(ASF::Picture::Other);
break;
case TagLib::Picture::FileIcon:
asfPicture.setType(ASF::Picture::FileIcon);
break;
case TagLib::Picture::OtherFileIcon:
asfPicture.setType(ASF::Picture::OtherFileIcon);
break;
case TagLib::Picture::FrontCover:
asfPicture.setType(ASF::Picture::FrontCover);
break;
case TagLib::Picture::BackCover:
asfPicture.setType(ASF::Picture::BackCover);
break;
case TagLib::Picture::LeafletPage:
asfPicture.setType(ASF::Picture::LeafletPage);
break;
case TagLib::Picture::Media:
asfPicture.setType(ASF::Picture::Media);
break;
case TagLib::Picture::LeadArtist:
asfPicture.setType(ASF::Picture::LeadArtist);
break;
case TagLib::Picture::Artist:
asfPicture.setType(ASF::Picture::Artist);
break;
case TagLib::Picture::Conductor:
asfPicture.setType(ASF::Picture::Conductor);
break;
case TagLib::Picture::Band:
asfPicture.setType(ASF::Picture::Band);
break;
case TagLib::Picture::Composer:
asfPicture.setType(ASF::Picture::Composer);
break;
case TagLib::Picture::Lyricist:
asfPicture.setType(ASF::Picture::Lyricist);
break;
case TagLib::Picture::RecordingLocation:
asfPicture.setType(ASF::Picture::RecordingLocation);
break;
case TagLib::Picture::DuringRecording:
asfPicture.setType(ASF::Picture::DuringRecording);
break;
case TagLib::Picture::DuringPerformance:
asfPicture.setType(ASF::Picture::DuringPerformance);
break;
case TagLib::Picture::MovieScreenCapture:
asfPicture.setType(ASF::Picture::MovieScreenCapture);
break;
case TagLib::Picture::ColouredFish:
asfPicture.setType(ASF::Picture::ColouredFish);
break;
case TagLib::Picture::Illustration:
asfPicture.setType(ASF::Picture::Illustration);
break;
case TagLib::Picture::BandLogo:
asfPicture.setType(ASF::Picture::BandLogo);
break;
case TagLib::Picture::PublisherLogo:
asfPicture.setType(ASF::Picture::PublisherLogo);
break;
}
addAttribute("WM/Picture", Attribute(asfPicture));
}
}
}
const ASF::AttributeListMap &ASF::Tag::attributeListMap() const {
return d->attributeListMap;
}
bool ASF::Tag::contains(const String &key) const {
return d->attributeListMap.contains(key);
}
void ASF::Tag::removeItem(const String &key) {
d->attributeListMap.erase(key);
}
ASF::AttributeList ASF::Tag::attribute(const String &name) const {
return d->attributeListMap[name];
}
void ASF::Tag::setAttribute(const String &name, const Attribute &attribute) {
AttributeList value;
value.append(attribute);
d->attributeListMap.insert(name, value);
}
void ASF::Tag::setAttribute(const String &name, const AttributeList &values) {
d->attributeListMap.insert(name, values);
}
void ASF::Tag::addAttribute(const String &name, const Attribute &attribute) {
if (d->attributeListMap.contains(name)) {
d->attributeListMap[name].append(attribute);
}
else {
setAttribute(name, attribute);
}
}
bool ASF::Tag::isEmpty() const {
return Strawberry_TagLib::TagLib::Tag::isEmpty() &&
copyright().isEmpty() &&
rating().isEmpty() &&
d->attributeListMap.isEmpty();
}
namespace {
const char *keyTranslation[][2] = {
{ "WM/AlbumTitle", "ALBUM" },
{ "WM/AlbumArtist", "ALBUMARTIST" },
{ "WM/Composer", "COMPOSER" },
{ "WM/Writer", "WRITER" },
{ "WM/Conductor", "CONDUCTOR" },
{ "WM/ModifiedBy", "REMIXER" },
{ "WM/Year", "DATE" },
{ "WM/OriginalReleaseYear", "ORIGINALDATE" },
{ "WM/Producer", "PRODUCER" },
{ "WM/ContentGroupDescription", "GROUPING" },
{ "WM/SubTitle", "SUBTITLE" },
{ "WM/SetSubTitle", "DISCSUBTITLE" },
{ "WM/TrackNumber", "TRACKNUMBER" },
{ "WM/PartOfSet", "DISCNUMBER" },
{ "WM/Genre", "GENRE" },
{ "WM/BeatsPerMinute", "BPM" },
{ "WM/Mood", "MOOD" },
{ "WM/ISRC", "ISRC" },
{ "WM/Lyrics", "LYRICS" },
{ "WM/Media", "MEDIA" },
{ "WM/Publisher", "LABEL" },
{ "WM/CatalogNo", "CATALOGNUMBER" },
{ "WM/Barcode", "BARCODE" },
{ "WM/EncodedBy", "ENCODEDBY" },
{ "WM/AlbumSortOrder", "ALBUMSORT" },
{ "WM/AlbumArtistSortOrder", "ALBUMARTISTSORT" },
{ "WM/ArtistSortOrder", "ARTISTSORT" },
{ "WM/TitleSortOrder", "TITLESORT" },
{ "WM/Script", "SCRIPT" },
{ "WM/Language", "LANGUAGE" },
{ "MusicBrainz/Track Id", "MUSICBRAINZ_TRACKID" },
{ "MusicBrainz/Artist Id", "MUSICBRAINZ_ARTISTID" },
{ "MusicBrainz/Album Id", "MUSICBRAINZ_ALBUMID" },
{ "MusicBrainz/Album Artist Id", "MUSICBRAINZ_ALBUMARTISTID" },
{ "MusicBrainz/Release Group Id", "MUSICBRAINZ_RELEASEGROUPID" },
{ "MusicBrainz/Work Id", "MUSICBRAINZ_WORKID" },
{ "MusicIP/PUID", "MUSICIP_PUID" },
{ "Acoustid/Id", "ACOUSTID_ID" },
{ "Acoustid/Fingerprint", "ACOUSTID_FINGERPRINT" },
};
const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
String translateKey(const String &key) {
for (size_t i = 0; i < keyTranslationSize; ++i) {
if (key == keyTranslation[i][0])
return keyTranslation[i][1];
}
return String();
}
} // namespace
PropertyMap ASF::Tag::properties() const {
PropertyMap props;
if (!d->title.isEmpty()) {
props["TITLE"] = d->title;
}
if (!d->artist.isEmpty()) {
props["ARTIST"] = d->artist;
}
if (!d->copyright.isEmpty()) {
props["COPYRIGHT"] = d->copyright;
}
if (!d->comment.isEmpty()) {
props["COMMENT"] = d->comment;
}
ASF::AttributeListMap::ConstIterator it = d->attributeListMap.begin();
for (; it != d->attributeListMap.end(); ++it) {
const String key = translateKey(it->first);
if (!key.isEmpty()) {
AttributeList::ConstIterator it2 = it->second.begin();
for (; it2 != it->second.end(); ++it2) {
if (key == "TRACKNUMBER") {
if (it2->type() == ASF::Attribute::DWordType)
props.insert(key, String::number(it2->toUInt()));
else
props.insert(key, it2->toString());
}
else {
props.insert(key, it2->toString());
}
}
}
else {
props.unsupportedData().append(it->first);
}
}
return props;
}
void ASF::Tag::removeUnsupportedProperties(const StringList &props) {
StringList::ConstIterator it = props.begin();
for (; it != props.end(); ++it)
d->attributeListMap.erase(*it);
}
PropertyMap ASF::Tag::setProperties(const PropertyMap &props) {
static Map<String, String> reverseKeyMap;
if (reverseKeyMap.isEmpty()) {
int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
for (int i = 0; i < numKeys; i++) {
reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0];
}
}
PropertyMap origProps = properties();
PropertyMap::ConstIterator it = origProps.begin();
for (; it != origProps.end(); ++it) {
if (!props.contains(it->first) || props[it->first].isEmpty()) {
if (it->first == "TITLE") {
d->title.clear();
}
else if (it->first == "ARTIST") {
d->artist.clear();
}
else if (it->first == "COMMENT") {
d->comment.clear();
}
else if (it->first == "COPYRIGHT") {
d->copyright.clear();
}
else {
d->attributeListMap.erase(reverseKeyMap[it->first]);
}
}
}
PropertyMap ignoredProps;
it = props.begin();
for (; it != props.end(); ++it) {
if (reverseKeyMap.contains(it->first)) {
String name = reverseKeyMap[it->first];
removeItem(name);
StringList::ConstIterator it2 = it->second.begin();
for (; it2 != it->second.end(); ++it2) {
addAttribute(name, *it2);
}
}
else if (it->first == "TITLE") {
d->title = it->second.toString();
}
else if (it->first == "ARTIST") {
d->artist = it->second.toString();
}
else if (it->first == "COMMENT") {
d->comment = it->second.toString();
}
else if (it->first == "COPYRIGHT") {
d->copyright = it->second.toString();
}
else {
ignoredProps.insert(it->first, it->second);
}
}
return ignoredProps;
}

View File

@@ -1,201 +0,0 @@
/**************************************************************************
copyright : (C) 2005-2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_ASFTAG_H
#define TAGLIB_ASFTAG_H
#include "tag.h"
#include "tlist.h"
#include "tmap.h"
#include "taglib_export.h"
#include "asfattribute.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace ASF {
typedef List<Attribute> AttributeList;
typedef Map<String, AttributeList> AttributeListMap;
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
friend class File;
public:
explicit Tag();
~Tag() override;
/*!
* Returns the track name.
*/
String title() const override;
/*!
* Returns the artist name.
*/
String artist() const override;
/*!
* Returns the album name; if no album name is present in the tag String::null will be returned.
*/
String album() const override;
/*!
* Returns the track comment.
*/
String comment() const override;
/*!
* Returns the genre name; if no genre is present in the tag String::null will be returned.
*/
String genre() const override;
/*!
* Returns the rating.
*/
virtual String rating() const;
/*!
* Returns the genre name; if no genre is present in the tag String::null will be returned.
*/
virtual String copyright() const;
/*!
* Returns the year; if there is no year set, this will return 0.
*/
unsigned int year() const override;
/*!
* Returns the track number; if there is no track number set, this will return 0.
*/
unsigned int track() const override;
PictureMap pictures() const override;
/*!
* Sets the title to \a s.
*/
void setTitle(const String &value) override;
/*!
* Sets the artist to \a s.
*/
void setArtist(const String &value) override;
/*!
* Sets the album to \a s. If \a s is String::null then this value will be cleared.
*/
void setAlbum(const String &value) override;
/*!
* Sets the comment to \a s.
*/
void setComment(const String &value) override;
/*!
* Sets the rating to \a s.
*/
virtual void setRating(const String &value);
/*!
* Sets the copyright to \a s.
*/
virtual void setCopyright(const String &value);
/*!
* Sets the genre to \a s.
*/
void setGenre(const String &value) override;
/*!
* Sets the year to \a i. If \a s is 0 then this value will be cleared.
*/
void setYear(unsigned int value) override;
/*!
* Sets the track to \a i. If \a s is 0 then this value will be cleared.
*/
void setTrack(unsigned int value) override;
void setPictures(const PictureMap&) override;
/*!
* Returns true if the tag does not contain any data.
* This should be reimplemented in subclasses that provide more than the basic tagging abilities in this class.
*/
bool isEmpty() const override;
/*!
* Returns a reference to the item list map. This is an AttributeListMap of all of the items in the tag.
*/
const AttributeListMap &attributeListMap() const;
/*!
* \return True if a value for \a attribute is currently set.
*/
bool contains(const String &key) const;
/*!
* Removes the \a key attribute from the tag
*/
void removeItem(const String &key);
/*!
* \return The list of values for the key \a name, or an empty list if no values have been set.
*/
AttributeList attribute(const String &name) const;
/*!
* Sets the \a key attribute to the value of \a attribute. If an attribute with the \a key is already present, it will be replaced.
*/
void setAttribute(const String &name, const Attribute &attribute);
/*!
* Sets multiple \a values to the key \a name.
*/
void setAttribute(const String &name, const AttributeList &values);
/*!
* Sets the \a key attribute to the value of \a attribute. If an attribute
* with the \a key is already present, it will be added to the list.
*/
void addAttribute(const String &name, const Attribute &attribute);
PropertyMap properties() const override;
void removeUnsupportedProperties(const StringList &props) override;
PropertyMap setProperties(const PropertyMap &props) override;
private:
class TagPrivate;
TagPrivate *d;
};
} // namespace ASF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,100 +0,0 @@
/***************************************************************************
copyright : (C) 2015 by Tsuda Kageyu
email : tsuda.kageyu@gmail.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_ASFUTILS_H
#define TAGLIB_ASFUTILS_H
// THIS FILE IS NOT A PART OF THE TAGLIB API
#ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header
namespace Strawberry_TagLib {
namespace TagLib {
namespace ASF {
namespace {
inline unsigned short readWORD(File *file, bool *ok = nullptr) {
const ByteVector v = file->readBlock(2);
if (v.size() != 2) {
if (ok) *ok = false;
return 0;
}
if (ok) *ok = true;
return v.toUInt16LE(0);
}
inline unsigned int readDWORD(File *file, bool *ok = nullptr) {
const ByteVector v = file->readBlock(4);
if (v.size() != 4) {
if (ok) *ok = false;
return 0;
}
if (ok) *ok = true;
return v.toUInt32LE(0);
}
inline long long readQWORD(File *file, bool *ok = nullptr) {
const ByteVector v = file->readBlock(8);
if (v.size() != 8) {
if (ok) *ok = false;
return 0;
}
if (ok) *ok = true;
return v.toInt64LE(0);
}
inline String readString(File *file, int length) {
ByteVector data = file->readBlock(length);
size_t size = data.size();
while (size >= 2) {
if (data[size - 1] != '\0' || data[size - 2] != '\0') {
break;
}
size -= 2;
}
if (size != data.size()) {
data.resize(size);
}
return String(data, String::UTF16LE);
}
inline ByteVector renderString(const String &str, bool includeLength = false) {
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromUInt16LE(0);
if (includeLength) {
data = ByteVector::fromUInt16LE(data.size()) + data;
}
return data;
}
} // namespace
} // namespace ASF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif
#endif

View File

@@ -1,53 +0,0 @@
/***************************************************************************
copyright : (C) 2002 - 2008 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tstringlist.h"
#include "audioproperties.h"
using namespace Strawberry_TagLib::TagLib;
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
AudioProperties::~AudioProperties() {}
String AudioProperties::toString() const {
StringList desc;
desc.append("Audio");
desc.append(String::number(lengthInSeconds()) + " seconds");
desc.append(String::number(bitrate()) + " kbps");
return desc.toString(", ");
}
////////////////////////////////////////////////////////////////////////////////
// protected methods
////////////////////////////////////////////////////////////////////////////////
AudioProperties::AudioProperties() : d(nullptr) {}

View File

@@ -1,120 +0,0 @@
/***************************************************************************
copyright : (C) 2002 - 2008 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_AUDIOPROPERTIES_H
#define TAGLIB_AUDIOPROPERTIES_H
#include "taglib_export.h"
#include "tstring.h"
namespace Strawberry_TagLib {
namespace TagLib {
//! A simple, abstract interface to common audio properties
/*!
* The values here are common to most audio formats.
* For more specific, codec dependent values, please see see the subclasses APIs.
* This is meant to compliment the TagLib::File and TagLib::Tag APIs in providing a simple
* interface that is sufficient for most applications.
*/
class TAGLIB_EXPORT AudioProperties {
public:
/*!
* Reading audio properties from a file can sometimes be very time consuming
* and for the most accurate results can often involve reading the entire file.
* Because in many situations speed is critical or the accuracy of the values
* is not particularly important this allows the level of desired accuracy to be set.
*/
enum ReadStyle {
//! Read as little of the file as possible
Fast,
//! Read more of the file and make better values guesses
Average,
//! Read as much of the file as needed to report accurate values
Accurate
};
/*!
* Destroys this AudioProperties instance.
*/
virtual ~AudioProperties();
/*!
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
*
* \see lengthInMilliseconds()
*/
virtual int lengthInSeconds() const = 0;
/*!
* Returns the length of the file in milliseconds.
*
* \see lengthInSeconds()
*/
virtual int lengthInMilliseconds() const = 0;
/*!
* Returns the most appropriate bit rate for the file in kb/s. For constant bitrate formats this is simply the bitrate of the file.
* For variable bitrate formats this is either the average or nominal bitrate.
*/
virtual int bitrate() const = 0;
/*!
* Returns the sample rate in Hz.
*/
virtual int sampleRate() const = 0;
/*!
* Returns the number of audio channels.
*/
virtual int channels() const = 0;
/*!
* Returns description of the audio file.
*/
virtual String toString() const;
protected:
/*!
* Construct an audio properties instance.
* This is protected as this class should not be instantiated directly,
* but should be instantiated via its subclasses and can be fetched from the FileRef or File APIs.
*/
explicit AudioProperties();
private:
AudioProperties(const AudioProperties&);
AudioProperties &operator=(const AudioProperties&);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,147 +0,0 @@
/***************************************************************************
copyright : (C) 2016 by Damien Plisson, Audirvana
email : damien78@audirvana.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "dsdiffdiintag.h"
#include "tstringlist.h"
#include "tpropertymap.h"
#include "tpicturemap.h"
using namespace Strawberry_TagLib::TagLib;
using namespace DSDIFF::DIIN;
class DSDIFF::DIIN::Tag::TagPrivate {
public:
TagPrivate() {
}
String title;
String artist;
};
DSDIFF::DIIN::Tag::Tag() {
d = new TagPrivate;
}
DSDIFF::DIIN::Tag::~Tag() {
delete d;
}
String DSDIFF::DIIN::Tag::title() const {
return d->title;
}
String DSDIFF::DIIN::Tag::artist() const {
return d->artist;
}
String DSDIFF::DIIN::Tag::album() const {
return String();
}
String DSDIFF::DIIN::Tag::comment() const {
return String();
}
String DSDIFF::DIIN::Tag::genre() const {
return String();
}
unsigned int DSDIFF::DIIN::Tag::year() const {
return 0;
}
unsigned int DSDIFF::DIIN::Tag::track() const {
return 0;
}
PictureMap DSDIFF::DIIN::Tag::pictures() const {
return PictureMap();
}
void DSDIFF::DIIN::Tag::setTitle(const String &title) {
d->title = title;
}
void DSDIFF::DIIN::Tag::setArtist(const String &artist) {
d->artist = artist;
}
void DSDIFF::DIIN::Tag::setAlbum(const String &) {}
void DSDIFF::DIIN::Tag::setComment(const String &) {}
void DSDIFF::DIIN::Tag::setGenre(const String &) {}
void DSDIFF::DIIN::Tag::setYear(unsigned int) {}
void DSDIFF::DIIN::Tag::setTrack(unsigned int) {}
void DSDIFF::DIIN::Tag::setPictures(const PictureMap&) {}
PropertyMap DSDIFF::DIIN::Tag::properties() const {
PropertyMap properties;
properties["TITLE"] = d->title;
properties["ARTIST"] = d->artist;
return properties;
}
PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) {
PropertyMap properties(origProps);
properties.removeEmpty();
StringList oneValueSet;
if (properties.contains("TITLE")) {
d->title = properties["TITLE"].front();
oneValueSet.append("TITLE");
}
else
d->title = String();
if (properties.contains("ARTIST")) {
d->artist = properties["ARTIST"].front();
oneValueSet.append("ARTIST");
}
else
d->artist = String();
// for each tag that has been set above, remove the first entry in the corresponding
// value list. The others will be returned as unsupported by this format.
for (StringList::Iterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) {
if (properties[*it].size() == 1)
properties.erase(*it);
else
properties[*it].erase(properties[*it].begin());
}
return properties;
}

View File

@@ -1,154 +0,0 @@
/***************************************************************************
copyright : (C) 2016 by Damien Plisson, Audirvana
email : damien78@audirvana.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_DSDIFFDIINTAG_H
#define TAGLIB_DSDIFFDIINTAG_H
#include "tag.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace DSDIFF {
namespace DIIN {
/*!
* Tags from the Edited Master Chunk Info
*
* Only Title and Artist tags are supported
*/
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
public:
explicit Tag();
~Tag() override;
/*!
* Returns the track name; if no track name is present in the tag String() will be returned.
*/
String title() const override;
/*!
* Returns the artist name; if no artist name is present in the tag String() will be returned.
*/
String artist() const override;
/*!
* Not supported. Therefore always returns String().
*/
String album() const override;
/*!
* Not supported. Therefore always returns String().
*/
String comment() const override;
/*!
* Not supported. Therefore always returns String().
*/
String genre() const override;
/*!
* Not supported. Therefore always returns 0.
*/
unsigned int year() const override;
/*!
* Not supported. Therefore always returns 0.
*/
unsigned int track() const override;
/*!
* Not supported. Therefore always returns an empty list.
*/
PictureMap pictures() const override;
/*!
* Sets the title to \a title. If \a title is String() then this value will be cleared.
*/
void setTitle(const String &title) override;
/*!
* Sets the artist to \a artist. If \a artist is String() then this value will be cleared.
*/
void setArtist(const String &artist) override;
/*!
* Not supported and therefore ignored.
*/
void setAlbum(const String &album) override;
/*!
* Not supported and therefore ignored.
*/
void setComment(const String &comment) override;
/*!
* Not supported and therefore ignored.
*/
void setGenre(const String &genre) override;
/*!
* Not supported and therefore ignored.
*/
void setYear(unsigned int year) override;
/*!
* Not supported and therefore ignored.
*/
void setTrack(unsigned int track) override;
/*!
* Not supported and therefore ignored.
*/
void setPictures(const PictureMap&) override;
/*!
* Implements the unified property interface -- export function.
* Since the DIIN tag is very limited, the exported map is as well.
*/
PropertyMap properties() const override;
/*!
* Implements the unified property interface -- import function.
* Because of the limitations of the DIIN file tag, any tags besides
* TITLE and ARTIST, will be returned.
* Additionally, if the map contains tags with multiple values,
* all but the first will be contained in the returned map of unsupported properties.
*/
PropertyMap setProperties(const PropertyMap &) override;
private:
Tag(const Tag &);
Tag &operator=(const Tag &);
class TagPrivate;
TagPrivate *d;
};
} // namespace DIIN
} // namespace DSDIFF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,919 +0,0 @@
/***************************************************************************
copyright : (C) 2016 by Damien Plisson, Audirvana
email : damien78@audirvana.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include <array>
#include "tstring.h"
#include "tbytevector.h"
#include "tdebug.h"
#include "id3v2tag.h"
#include "tstringlist.h"
#include "tpropertymap.h"
#include "tagutils.h"
#include "tagunion.h"
#include "dsdifffile.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
struct Chunk64 {
ByteVector name;
unsigned long long offset;
unsigned long long size;
char padding;
};
typedef std::vector<Chunk64> ChunkList;
int chunkIndex(const ChunkList &chunks, const ByteVector &id) {
for (unsigned long int i = 0; i < chunks.size(); i++) {
if (chunks[i].name == id)
return i;
}
return -1;
}
bool isValidChunkID(const ByteVector &name) {
if (name.size() != 4)
return false;
for (int i = 0; i < 4; i++) {
if (name[i] < 32)
return false;
}
return true;
}
enum {
ID3v2Index = 0,
DIINIndex = 1
};
enum {
PROPChunk = 0,
DIINChunk = 1
};
} // namespace
class DSDIFF::File::FilePrivate {
public:
FilePrivate() : endianness(BigEndian),
size(0),
isID3InPropChunk(false),
duplicateID3V2chunkIndex(-1),
id3v2TagChunkID("ID3 "),
hasID3v2(false),
hasDiin(false) {
childChunkIndex[ID3v2Index] = -1;
childChunkIndex[DIINIndex] = -1;
}
Endianness endianness;
ByteVector type;
unsigned long long size;
ByteVector format;
ChunkList chunks;
std::array<ChunkList, 2> childChunks;
std::array<int, 2> childChunkIndex;
/*
* Two possibilities can be found: ID3V2 chunk inside PROP chunk or at root level
*/
bool isID3InPropChunk;
/*
* ID3 chunks are present. This is then the index of the one in PROP chunk that
* will be removed upon next save to remove duplicates.
*/
int duplicateID3V2chunkIndex;
std::unique_ptr<AudioProperties> properties;
DoubleTagUnion tag;
ByteVector id3v2TagChunkID;
bool hasID3v2;
bool hasDiin;
};
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
bool DSDIFF::File::isSupported(IOStream *stream) {
// A DSDIFF file has to start with "FRM8????????DSD ".
const ByteVector id = Utils::readHeader(stream, 16, false);
return (id.startsWith("FRM8") && id.containsAt("DSD ", 12));
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
DSDIFF::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file) {
d = new FilePrivate;
d->endianness = BigEndian;
if (isOpen())
read(readProperties, propertiesStyle);
}
DSDIFF::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream) {
d = new FilePrivate;
d->endianness = BigEndian;
if (isOpen())
read(readProperties, propertiesStyle);
}
DSDIFF::File::~File() {
delete d;
}
Strawberry_TagLib::TagLib::Tag *DSDIFF::File::tag() const {
return &d->tag;
}
ID3v2::Tag *DSDIFF::File::ID3v2Tag(bool create) const {
return d->tag.access<ID3v2::Tag>(ID3v2Index, create);
}
bool DSDIFF::File::hasID3v2Tag() const {
return d->hasID3v2;
}
DSDIFF::DIIN::Tag *DSDIFF::File::DIINTag(bool create) const {
return d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, create);
}
bool DSDIFF::File::hasDIINTag() const {
return d->hasDiin;
}
PropertyMap DSDIFF::File::properties() const {
if (d->hasID3v2)
return d->tag.access<ID3v2::Tag>(ID3v2Index, false)->properties();
return PropertyMap();
}
void DSDIFF::File::removeUnsupportedProperties(const StringList &properties) {
if (d->hasID3v2)
d->tag.access<ID3v2::Tag>(ID3v2Index, false)->removeUnsupportedProperties(properties);
if (d->hasDiin)
d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false)->removeUnsupportedProperties(properties);
}
PropertyMap DSDIFF::File::setProperties(const PropertyMap &properties) {
return d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
}
DSDIFF::AudioProperties *DSDIFF::File::audioProperties() const {
return d->properties.get();
}
bool DSDIFF::File::save() {
return save(AllTags);
}
bool DSDIFF::File::save(TagTypes tags, StripTags, ID3v2::Version version) {
if (readOnly()) {
debug("DSDIFF::File::save() -- File is read only.");
return false;
}
if (!isValid()) {
debug("DSDIFF::File::save() -- Trying to save invalid file.");
return false;
}
//if(strip == StripOthers || strip == StripAll)
//File::strip(static_cast<TagTypes>(AllTags & ~tags));
// First: save ID3V2 chunk
ID3v2::Tag *id3v2Tag = d->tag.access<ID3v2::Tag>(ID3v2Index, false);
if (tags & ID3v2 && id3v2Tag) {
if (d->isID3InPropChunk) {
if (id3v2Tag && !id3v2Tag->isEmpty()) {
setChildChunkData(d->id3v2TagChunkID, id3v2Tag->render(version), PROPChunk);
d->hasID3v2 = true;
}
else {
// Empty tag: remove it
setChildChunkData(d->id3v2TagChunkID, ByteVector(), PROPChunk);
d->hasID3v2 = false;
}
}
else {
if (id3v2Tag && !id3v2Tag->isEmpty()) {
setRootChunkData(d->id3v2TagChunkID, id3v2Tag->render(version));
d->hasID3v2 = true;
}
else {
// Empty tag: remove it
setRootChunkData(d->id3v2TagChunkID, ByteVector());
d->hasID3v2 = false;
}
}
}
// Second: save the DIIN chunk
DSDIFF::DIIN::Tag *diinTag = d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false);
if (tags & DIIN && diinTag) {
if (!diinTag->title().isEmpty()) {
ByteVector diinTitle;
if (d->endianness == BigEndian)
diinTitle.append(ByteVector::fromUInt32BE(diinTag->title().size()));
else
diinTitle.append(ByteVector::fromUInt32LE(diinTag->title().size()));
diinTitle.append(ByteVector::fromCString(diinTag->title().toCString()));
setChildChunkData("DITI", diinTitle, DIINChunk);
}
else
setChildChunkData("DITI", ByteVector(), DIINChunk);
if (!diinTag->artist().isEmpty()) {
ByteVector diinArtist;
if (d->endianness == BigEndian)
diinArtist.append(ByteVector::fromUInt32BE(diinTag->artist().size()));
else
diinArtist.append(ByteVector::fromUInt32LE(diinTag->artist().size()));
diinArtist.append(ByteVector::fromCString(diinTag->artist().toCString()));
setChildChunkData("DIAR", diinArtist, DIINChunk);
}
else
setChildChunkData("DIAR", ByteVector(), DIINChunk);
}
// Third: remove the duplicate ID3V2 chunk (inside PROP chunk) if any
if (d->duplicateID3V2chunkIndex >= 0) {
setChildChunkData(d->duplicateID3V2chunkIndex, ByteVector(), PROPChunk);
d->duplicateID3V2chunkIndex = -1;
}
return true;
}
void DSDIFF::File::strip(TagTypes tags) {
if (tags & ID3v2) {
removeRootChunk("ID3 ");
removeRootChunk("id3 ");
d->hasID3v2 = false;
d->tag.set(ID3v2Index, new ID3v2::Tag);
/// TODO: needs to also account for ID3v2 tags under the PROP chunk
}
if (tags & DIIN) {
removeRootChunk("DITI");
removeRootChunk("DIAR");
d->hasDiin = false;
d->tag.set(DIINIndex, new DIIN::Tag);
}
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void DSDIFF::File::removeRootChunk(unsigned int i) {
unsigned long long chunkSize = d->chunks[i].size + d->chunks[i].padding + 12;
d->size -= chunkSize;
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
else
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
removeBlock(d->chunks[i].offset - 12, chunkSize);
// Update the internal offsets
for (unsigned long r = i + 1; r < d->chunks.size(); r++)
d->chunks[r].offset = d->chunks[r - 1].offset + 12 + d->chunks[r - 1].size + d->chunks[r - 1].padding;
d->chunks.erase(d->chunks.begin() + i);
}
void DSDIFF::File::removeRootChunk(const ByteVector &id) {
int i = chunkIndex(d->chunks, id);
if (i >= 0)
removeRootChunk(i);
}
void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) {
if (data.isEmpty()) {
removeRootChunk(i);
return;
}
// Non null data: update chunk
// First we update the global size
d->size += ((data.size() + 1) & ~1) - (d->chunks[i].size + d->chunks[i].padding);
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
else
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
// Now update the specific chunk
writeChunk(d->chunks[i].name, data, d->chunks[i].offset - 12, d->chunks[i].size + d->chunks[i].padding + 12);
d->chunks[i].size = data.size();
d->chunks[i].padding = (data.size() & 0x01) ? 1 : 0;
// Finally update the internal offsets
updateRootChunksStructure(i + 1);
}
void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &data) {
if (d->chunks.size() == 0) {
debug("DSDIFF::File::setPropChunkData - No valid chunks found.");
return;
}
int i = chunkIndex(d->chunks, name);
if (i >= 0) {
setRootChunkData(i, data);
return;
}
// Couldn't find an existing chunk, so let's create a new one.
i = d->chunks.size() - 1;
unsigned long offset = d->chunks[i].offset + d->chunks[i].size + d->chunks[i].padding;
// First we update the global size
d->size += (offset & 1) + ((data.size() + 1) & ~1) + 12;
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
else
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
// Now add the chunk to the file
writeChunk(name,
data,
offset,
std::max<unsigned long long>(0, length() - offset),
(offset & 1) ? 1 : 0);
Chunk64 chunk;
chunk.name = name;
chunk.size = data.size();
chunk.offset = offset + 12;
chunk.padding = (data.size() & 0x01) ? 1 : 0;
d->chunks.push_back(chunk);
}
void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum) {
ChunkList &childChunks = d->childChunks[childChunkNum];
// Update global size
unsigned long long removedChunkTotalSize = childChunks[i].size + childChunks[i].padding + 12;
d->size -= removedChunkTotalSize;
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
else
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
// Update child chunk size
d->chunks[d->childChunkIndex[childChunkNum]].size -= removedChunkTotalSize;
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
else
insert(ByteVector::fromUInt64LE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
// Remove the chunk
removeBlock(childChunks[i].offset - 12, removedChunkTotalSize);
// Update the internal offsets
// For child chunks
if ((i + 1) < childChunks.size()) {
childChunks[i + 1].offset = childChunks[i].offset;
i++;
for (i++; i < childChunks.size(); i++)
childChunks[i].offset = childChunks[i - 1].offset + 12 + childChunks[i - 1].size + childChunks[i - 1].padding;
}
// And for root chunks
for (i = d->childChunkIndex[childChunkNum] + 1; i < d->chunks.size(); i++)
d->chunks[i].offset = d->chunks[i - 1].offset + 12 + d->chunks[i - 1].size + d->chunks[i - 1].padding;
childChunks.erase(childChunks.begin() + i);
}
void DSDIFF::File::setChildChunkData(unsigned int i, const ByteVector &data, unsigned int childChunkNum) {
ChunkList &childChunks = d->childChunks[childChunkNum];
if (data.isEmpty()) {
removeChildChunk(i, childChunkNum);
return;
}
// Non null data: update chunk
// First we update the global size
d->size += ((data.size() + 1) & ~1) - (childChunks[i].size + childChunks[i].padding);
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
else
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
// And the PROP chunk size
d->chunks[d->childChunkIndex[childChunkNum]].size += ((data.size() + 1) & ~1) - (childChunks[i].size + childChunks[i].padding);
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
else
insert(ByteVector::fromUInt64LE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
// Now update the specific chunk
writeChunk(childChunks[i].name, data, childChunks[i].offset - 12, childChunks[i].size + childChunks[i].padding + 12);
childChunks[i].size = data.size();
childChunks[i].padding = (data.size() & 0x01) ? 1 : 0;
// Now update the internal offsets
// For child Chunks
for (i++; i < childChunks.size(); i++)
childChunks[i].offset = childChunks[i - 1].offset + 12 + childChunks[i - 1].size + childChunks[i - 1].padding;
// And for root chunks
updateRootChunksStructure(d->childChunkIndex[childChunkNum] + 1);
}
void DSDIFF::File::setChildChunkData(const ByteVector &name, const ByteVector &data, unsigned int childChunkNum) {
ChunkList &childChunks = d->childChunks[childChunkNum];
if (childChunks.size() == 0) {
debug("DSDIFF::File::setPropChunkData - No valid chunks found.");
return;
}
for (unsigned int i = 0; i < childChunks.size(); i++) {
if (childChunks[i].name == name) {
setChildChunkData(i, data, childChunkNum);
return;
}
}
// Do not attempt to remove a non existing chunk
if (data.isEmpty())
return;
// Couldn't find an existing chunk, so let's create a new one.
unsigned int i = childChunks.size() - 1;
unsigned long offset = childChunks[i].offset + childChunks[i].size + childChunks[i].padding;
// First we update the global size
d->size += (offset & 1) + ((data.size() + 1) & ~1) + 12;
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->size), 4, 8);
else
insert(ByteVector::fromUInt64LE(d->size), 4, 8);
// And the child chunk size
d->chunks[d->childChunkIndex[childChunkNum]].size += (offset & 1) + ((data.size() + 1) & ~1) + 12;
if (d->endianness == BigEndian)
insert(ByteVector::fromUInt64BE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
else
insert(ByteVector::fromUInt64LE(d->chunks[d->childChunkIndex[childChunkNum]].size), d->chunks[d->childChunkIndex[childChunkNum]].offset - 8, 8);
// Now add the chunk to the file
unsigned long long nextRootChunkIdx = length();
if ((d->childChunkIndex[childChunkNum] + 1) < static_cast<int>(d->chunks.size()))
nextRootChunkIdx = d->chunks[d->childChunkIndex[childChunkNum] + 1].offset - 12;
writeChunk(name, data, offset,
std::max<unsigned long long>(0, nextRootChunkIdx - offset),
(offset & 1) ? 1 : 0);
// For root chunks
updateRootChunksStructure(d->childChunkIndex[childChunkNum] + 1);
Chunk64 chunk;
chunk.name = name;
chunk.size = data.size();
chunk.offset = offset + 12;
chunk.padding = (data.size() & 0x01) ? 1 : 0;
childChunks.push_back(chunk);
}
void DSDIFF::File::updateRootChunksStructure(unsigned int startingChunk) {
for (unsigned int i = startingChunk; i < d->chunks.size(); i++)
d->chunks[i].offset = d->chunks[i - 1].offset + 12 + d->chunks[i - 1].size + d->chunks[i - 1].padding;
// Update childchunks structure as well
if (d->childChunkIndex[PROPChunk] >= static_cast<int>(startingChunk)) {
ChunkList &childChunksToUpdate = d->childChunks[PROPChunk];
if (childChunksToUpdate.size() > 0) {
childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[PROPChunk]].offset + 12;
for (unsigned int i = 1; i < childChunksToUpdate.size(); i++)
childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding;
}
}
if (d->childChunkIndex[DIINChunk] >= static_cast<int>(startingChunk)) {
ChunkList &childChunksToUpdate = d->childChunks[DIINChunk];
if (childChunksToUpdate.size() > 0) {
childChunksToUpdate[0].offset = d->chunks[d->childChunkIndex[DIINChunk]].offset + 12;
for (unsigned int i = 1; i < childChunksToUpdate.size(); i++)
childChunksToUpdate[i].offset = childChunksToUpdate[i - 1].offset + 12 + childChunksToUpdate[i - 1].size + childChunksToUpdate[i - 1].padding;
}
}
}
void DSDIFF::File::read(bool readProperties, AudioProperties::ReadStyle propertiesStyle) {
bool bigEndian = (d->endianness == BigEndian);
d->type = readBlock(4);
d->size = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
d->format = readBlock(4);
// + 12: chunk header at least, fix for additional junk bytes
while (tell() + 12 <= length()) {
ByteVector chunkName = readBlock(4);
unsigned long long chunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
if (!isValidChunkID(chunkName)) {
debug("DSDIFF::File::read() -- Chunk '" + chunkName + "' has invalid ID");
setValid(false);
break;
}
if (static_cast<unsigned long long>(tell()) + chunkSize >
static_cast<unsigned long long>(length())) {
debug("DSDIFF::File::read() -- Chunk '" + chunkName + "' has invalid size (larger than the file size)");
setValid(false);
break;
}
Chunk64 chunk;
chunk.name = chunkName;
chunk.size = chunkSize;
chunk.offset = tell();
seek(chunk.size, Current);
// Check padding
chunk.padding = 0;
long uPosNotPadded = tell();
if ((uPosNotPadded & 0x01) != 0) {
ByteVector iByte = readBlock(1);
if ((iByte.size() != 1) || (iByte[0] != 0))
// Not well formed, re-seek
seek(uPosNotPadded, Beginning);
else
chunk.padding = 1;
}
d->chunks.push_back(chunk);
}
// For DSD uncompressed
unsigned long long lengthDSDSamplesTimeChannels = 0;
// For computing bitrate
unsigned long long audioDataSizeinBytes = 0;
// For DST compressed frames
unsigned long dstNumFrames = 0;
// For DST compressed frames
unsigned short dstFrameRate = 0;
for (unsigned int i = 0; i < d->chunks.size(); i++) {
if (d->chunks[i].name == "DSD ") {
lengthDSDSamplesTimeChannels = d->chunks[i].size * 8;
audioDataSizeinBytes = d->chunks[i].size;
}
else if (d->chunks[i].name == "DST ") {
// Now decode the chunks inside the DST chunk to read the DST Frame Information one
long long dstChunkEnd = d->chunks[i].offset + d->chunks[i].size;
seek(d->chunks[i].offset);
audioDataSizeinBytes = d->chunks[i].size;
while (tell() + 12 <= dstChunkEnd) {
ByteVector dstChunkName = readBlock(4);
long long dstChunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
if (!isValidChunkID(dstChunkName)) {
debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName + "' has invalid ID");
setValid(false);
break;
}
if (static_cast<long long>(tell()) + dstChunkSize > dstChunkEnd) {
debug("DSDIFF::File::read() -- DST Chunk '" + dstChunkName + "' has invalid size (larger than the DST chunk)");
setValid(false);
break;
}
if (dstChunkName == "FRTE") {
// Found the DST frame information chunk
dstNumFrames = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
dstFrameRate = bigEndian ? readBlock(2).toUInt16BE(0) : readBlock(2).toUInt16LE(0);
// Found the wanted one, no need to look at the others
break;
}
seek(dstChunkSize, Current);
// Check padding
long uPosNotPadded = tell();
if ((uPosNotPadded & 0x01) != 0) {
ByteVector iByte = readBlock(1);
if ((iByte.size() != 1) || (iByte[0] != 0))
// Not well formed, re-seek
seek(uPosNotPadded, Beginning);
}
}
}
else if (d->chunks[i].name == "PROP") {
d->childChunkIndex[PROPChunk] = i;
// Now decodes the chunks inside the PROP chunk
long long propChunkEnd = d->chunks[i].offset + d->chunks[i].size;
// +4 to remove the 'SND ' marker at beginning of 'PROP' chunk
seek(d->chunks[i].offset + 4);
while (tell() + 12 <= propChunkEnd) {
ByteVector propChunkName = readBlock(4);
long long propChunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
if (!isValidChunkID(propChunkName)) {
debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName + "' has invalid ID");
setValid(false);
break;
}
if (static_cast<long long>(tell()) + propChunkSize > propChunkEnd) {
debug("DSDIFF::File::read() -- PROP Chunk '" + propChunkName + "' has invalid size (larger than the PROP chunk)");
setValid(false);
break;
}
Chunk64 chunk;
chunk.name = propChunkName;
chunk.size = propChunkSize;
chunk.offset = tell();
seek(chunk.size, Current);
// Check padding
chunk.padding = 0;
long uPosNotPadded = tell();
if ((uPosNotPadded & 0x01) != 0) {
ByteVector iByte = readBlock(1);
if ((iByte.size() != 1) || (iByte[0] != 0))
// Not well formed, re-seek
seek(uPosNotPadded, Beginning);
else
chunk.padding = 1;
}
d->childChunks[PROPChunk].push_back(chunk);
}
}
else if (d->chunks[i].name == "DIIN") {
d->childChunkIndex[DIINChunk] = i;
d->hasDiin = true;
// Now decode the chunks inside the DIIN chunk
long long diinChunkEnd = d->chunks[i].offset + d->chunks[i].size;
seek(d->chunks[i].offset);
while (tell() + 12 <= diinChunkEnd) {
ByteVector diinChunkName = readBlock(4);
long long diinChunkSize = bigEndian ? readBlock(8).toInt64BE(0) : readBlock(8).toInt64LE(0);
if (!isValidChunkID(diinChunkName)) {
debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName + "' has invalid ID");
setValid(false);
break;
}
if (static_cast<long long>(tell()) + diinChunkSize > diinChunkEnd) {
debug("DSDIFF::File::read() -- DIIN Chunk '" + diinChunkName + "' has invalid size (larger than the DIIN chunk)");
setValid(false);
break;
}
Chunk64 chunk;
chunk.name = diinChunkName;
chunk.size = diinChunkSize;
chunk.offset = tell();
seek(chunk.size, Current);
// Check padding
chunk.padding = 0;
long uPosNotPadded = tell();
if ((uPosNotPadded & 0x01) != 0) {
ByteVector iByte = readBlock(1);
if ((iByte.size() != 1) || (iByte[0] != 0))
// Not well formed, re-seek
seek(uPosNotPadded, Beginning);
else
chunk.padding = 1;
}
d->childChunks[DIINChunk].push_back(chunk);
}
}
else if (d->chunks[i].name == "ID3 " || d->chunks[i].name == "id3 ") {
d->id3v2TagChunkID = d->chunks[i].name;
d->tag.set(ID3v2Index, new ID3v2::Tag(this, d->chunks[i].offset));
d->isID3InPropChunk = false;
d->hasID3v2 = true;
}
}
if (!isValid())
return;
if (d->childChunkIndex[PROPChunk] < 0) {
debug("DSDIFF::File::read() -- no PROP chunk found");
setValid(false);
return;
}
// Read properties
unsigned int sampleRate = 0;
unsigned short channels = 0;
for (unsigned int i = 0; i < d->childChunks[PROPChunk].size(); i++) {
if (d->childChunks[PROPChunk][i].name == "ID3 " || d->childChunks[PROPChunk][i].name == "id3 ") {
if (d->hasID3v2) {
d->duplicateID3V2chunkIndex = i;
// ID3V2 tag has already been found at root level
continue;
}
d->id3v2TagChunkID = d->childChunks[PROPChunk][i].name;
d->tag.set(ID3v2Index, new ID3v2::Tag(this, d->childChunks[PROPChunk][i].offset));
d->isID3InPropChunk = true;
d->hasID3v2 = true;
}
else if (d->childChunks[PROPChunk][i].name == "FS ") {
// Sample rate
seek(d->childChunks[PROPChunk][i].offset);
sampleRate = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
}
else if (d->childChunks[PROPChunk][i].name == "CHNL") {
// Channels
seek(d->childChunks[PROPChunk][i].offset);
channels = bigEndian ? readBlock(2).toInt16BE(0) : readBlock(2).toInt16LE(0);
}
}
// Read title & artist from DIIN chunk
d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, true);
if (d->hasDiin) {
for (unsigned int i = 0; i < d->childChunks[DIINChunk].size(); i++) {
if (d->childChunks[DIINChunk][i].name == "DITI") {
seek(d->childChunks[DIINChunk][i].offset);
unsigned int titleStrLength = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
if (titleStrLength <= d->childChunks[DIINChunk][i].size) {
ByteVector titleStr = readBlock(titleStrLength);
d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false)->setTitle(titleStr);
}
}
else if (d->childChunks[DIINChunk][i].name == "DIAR") {
seek(d->childChunks[DIINChunk][i].offset);
unsigned int artistStrLength = bigEndian ? readBlock(4).toUInt32BE(0) : readBlock(4).toUInt32LE(0);
if (artistStrLength <= d->childChunks[DIINChunk][i].size) {
ByteVector artistStr = readBlock(artistStrLength);
d->tag.access<DSDIFF::DIIN::Tag>(DIINIndex, false)->setArtist(artistStr);
}
}
}
}
if (readProperties) {
if (lengthDSDSamplesTimeChannels == 0) {
// DST compressed signal : need to compute length of DSD uncompressed frames
if (dstFrameRate > 0)
lengthDSDSamplesTimeChannels = static_cast<unsigned long long>(dstNumFrames) * static_cast<unsigned long long>(sampleRate) / static_cast<unsigned long long>(dstFrameRate);
else
lengthDSDSamplesTimeChannels = 0;
}
else {
// In DSD uncompressed files, the read number of samples is the total for each channel
if (channels > 0)
lengthDSDSamplesTimeChannels /= channels;
}
int bitrate = 0;
if (lengthDSDSamplesTimeChannels > 0)
bitrate = (audioDataSizeinBytes * 8 * sampleRate) / lengthDSDSamplesTimeChannels / 1000;
d->properties.reset(new AudioProperties(sampleRate, channels, lengthDSDSamplesTimeChannels, bitrate, propertiesStyle));
}
if (!ID3v2Tag()) {
d->tag.access<ID3v2::Tag>(ID3v2Index, true);
// By default, ID3 chunk is at root level
d->isID3InPropChunk = false;
d->hasID3v2 = false;
}
}
void DSDIFF::File::writeChunk(const ByteVector &name, const ByteVector &data, unsigned long long offset, unsigned long replace, unsigned int leadingPadding) {
ByteVector combined;
if (leadingPadding)
combined.append(ByteVector(leadingPadding, '\x00'));
combined.append(name);
if (d->endianness == BigEndian)
combined.append(ByteVector::fromUInt64BE(data.size()));
else
combined.append(ByteVector::fromUInt64LE(data.size()));
combined.append(data);
if ((data.size() & 0x01) != 0)
combined.append('\x00');
insert(combined, offset, replace);
}

View File

@@ -1,265 +0,0 @@
/***************************************************************************
copyright : (C) 2016 by Damien Plisson, Audirvana
email : damien78@audirvana.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_DSDIFFFILE_H
#define TAGLIB_DSDIFFFILE_H
#include "rifffile.h"
#include "id3v2tag.h"
#include "dsdiffproperties.h"
#include "dsdiffdiintag.h"
namespace Strawberry_TagLib {
namespace TagLib {
//! An implementation of DSDIFF metadata
/*!
* This is implementation of DSDIFF metadata.
*
* This supports an ID3v2 tag as well as reading stream from the ID3 RIFF
* chunk as well as properties from the file.
* Description of the DSDIFF format is available at http://dsd-guide.com/sites/default/files/white-papers/DSDIFF_1.5_Spec.pdf
* DSDIFF standard does not explicitly specify the ID3V2 chunk
* It can be found at the root level, but also sometimes inside the PROP chunk.
* In addition, title and artist info are stored as part of the standard
*/
namespace DSDIFF {
//! An implementation of TagLib::File with DSDIFF specific methods
/*!
* This implements and provides an interface for DSDIFF files to the
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing the
* abstract TagLib::File API as well as providing some additional information specific to DSDIFF files.
*/
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
public:
/*!
* This set of flags is used for various operations and is suitable for
* being OR-ed together.
*/
enum TagTypes {
//! Empty set. Matches no tag types.
NoTags = 0x0000,
//! Matches DIIN tags.
DIIN = 0x0002,
//! Matches ID3v1 tags.
ID3v2 = 0x0002,
//! Matches all tag types.
AllTags = 0xffff
};
/*!
* Constructs an DSDIFF file from \a file.
* If \a readProperties is true the file's audio properties will also be read.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Constructs an DSDIFF file from \a stream.
* If \a readProperties is true the file's audio properties will also be read.
*
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
~File() override;
/*!
* Returns a pointer to a tag that is the union of the ID3v2 and DIIN tags.
* The ID3v2 tag is given priority in reading the information -- if requested information exists in both the ID3v2 tag and the ID3v1 tag,
* the information from the ID3v2 tag will be returned.
*
* If you would like more granular control over the content of the tags, with the concession of generality, use the tag-type specific calls.
*
* \note As this tag is not implemented as an ID3v2 tag or a DIIN tag,
* but a union of the two this pointer may not be cast to the specific tag types.
*
* \see ID3v2Tag()
* \see DIINTag()
*/
Tag *tag() const override;
/*!
* Returns the ID3V2 Tag for this file.
*
* \note This always returns a valid pointer regardless of whether or not the file on disk has an ID3v2 tag.
* Use hasID3v2Tag() to check if the file on disk actually has an ID3v2 tag.
*
* \see hasID3v2Tag()
*/
ID3v2::Tag *ID3v2Tag(bool create = false) const;
/*!
* Returns the DSDIFF DIIN Tag for this file
*
*/
DSDIFF::DIIN::Tag *DIINTag(bool create = false) const;
/*!
* Implements the unified property interface -- export function.
* This method forwards to ID3v2::Tag::properties().
*/
PropertyMap properties() const override;
void removeUnsupportedProperties(const StringList &properties) override;
/*!
* Implements the unified property interface -- import function.
* This method forwards to ID3v2::Tag::setProperties().
*/
PropertyMap setProperties(const PropertyMap &properties) override;
/*!
* Returns the AIFF::AudioProperties for this file.
* If no audio properties were read then this will return a null pointer.
*/
AudioProperties *audioProperties() const override;
/*!
* Save the file. If at least one tag -- ID3v1 or DIIN -- exists this will duplicate its content into the other tag.
* This returns true if saving was successful.
*
* If neither exists or if both tags are empty, this will strip the tags from the file.
*
* This is the same as calling save(AllTags);
*
* If you would like more granular control over the content of the tags,
* with the concession of generality, use paramaterized save call below.
*
* \see save(int tags)
*/
bool save() override;
/*!
* Save the file. If \a strip is specified,
* it is possible to choose if tags not specified in \a tags should be stripped from the file or retained.
* With \a version, it is possible to specify whether ID3v2.4 or ID3v2.3 should be used.
*/
bool save(TagTypes tags, StripTags strip = StripOthers, ID3v2::Version version = ID3v2::v4);
/*!
* This will strip the tags that match the OR-ed together TagTypes from the file.
* By default it strips all tags. It returns true if the tags are successfully stripped.
*
* \note This will update the file immediately.
*/
void strip(TagTypes tags = AllTags);
/*!
* Returns whether or not the file on disk actually has an ID3v2 tag.
*
* \see ID3v2Tag()
*/
bool hasID3v2Tag() const;
/*!
* Returns whether or not the file on disk actually has the DSDIFF title and artist tags.
*
* \see DIINTag()
*/
bool hasDIINTag() const;
/*!
* Returns whether or not the given \a stream can be opened as a DSDIFF file.
*
* \note This method is designed to do a quick check. The result may not necessarily be correct.
*/
static bool isSupported(IOStream *stream);
protected:
enum Endianness {
BigEndian,
LittleEndian
};
File(FileName file, Endianness endianness);
File(IOStream *stream, Endianness endianness);
private:
File(const File &);
File &operator=(const File &);
void removeRootChunk(const ByteVector &id);
void removeRootChunk(unsigned int i);
void removeChildChunk(unsigned int i, unsigned int childChunkNum);
/*!
* Sets the data for the the specified chunk at root level to \a data.
*
* \warning This will update the file immediately.
*/
void setRootChunkData(unsigned int i, const ByteVector &data);
/*!
* Sets the data for the root-level chunk \a name to \a data.
* If a root-level chunk with the given name already exists it will be overwritten, otherwise it will be created after the existing chunks.
*
* \warning This will update the file immediately.
*/
void setRootChunkData(const ByteVector &name, const ByteVector &data);
/*!
* Sets the data for the the specified child chunk to \a data.
*
* If data is null, then remove the chunk
*
* \warning This will update the file immediately.
*/
void setChildChunkData(unsigned int i, const ByteVector &data, unsigned int childChunkNum);
/*!
* Sets the data for the child chunk \a name to \a data.
* If a chunk with the given name already exists it will be overwritten, otherwise it will be created after the existing chunks inside child chunk.
*
* If data is null, then remove the chunks with \a name name
*
* \warning This will update the file immediately.
*/
void setChildChunkData(const ByteVector &name, const ByteVector &data, unsigned int childChunkNum);
void updateRootChunksStructure(unsigned int startingChunk);
void read(bool readProperties, AudioProperties::ReadStyle propertiesStyle);
void writeChunk(const ByteVector &name, const ByteVector &data, unsigned long long offset, unsigned long replace = 0, unsigned int leadingPadding = 0);
class FilePrivate;
FilePrivate *d;
};
} // namespace DSDIFF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,96 +0,0 @@
/***************************************************************************
copyright : (C) 2016 by Damien Plisson, Audirvana
email : damien78@audirvana.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tstring.h"
#include "tdebug.h"
#include "dsdiffproperties.h"
using namespace Strawberry_TagLib::TagLib;
class DSDIFF::AudioProperties::AudioPropertiesPrivate {
public:
explicit AudioPropertiesPrivate() : length(0),
bitrate(0),
sampleRate(0),
channels(0),
sampleWidth(0),
sampleCount(0) {
}
int length;
int bitrate;
int sampleRate;
int channels;
int sampleWidth;
unsigned long long sampleCount;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
DSDIFF::AudioProperties::AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate) {
d->channels = channels;
d->sampleCount = samplesCount;
d->sampleWidth = 1;
d->sampleRate = sampleRate;
d->bitrate = bitrate;
d->length = d->sampleRate > 0 ? static_cast<int>((d->sampleCount * 1000.0) / d->sampleRate + 0.5) : 0;
}
DSDIFF::AudioProperties::~AudioProperties() {
delete d;
}
int DSDIFF::AudioProperties::lengthInSeconds() const {
return d->length / 1000;
}
int DSDIFF::AudioProperties::lengthInMilliseconds() const {
return d->length;
}
int DSDIFF::AudioProperties::bitrate() const {
return d->bitrate;
}
int DSDIFF::AudioProperties::sampleRate() const {
return d->sampleRate;
}
int DSDIFF::AudioProperties::channels() const {
return d->channels;
}
int DSDIFF::AudioProperties::bitsPerSample() const {
return d->sampleWidth;
}
long long DSDIFF::AudioProperties::sampleCount() const {
return d->sampleCount;
}

View File

@@ -1,78 +0,0 @@
/***************************************************************************
copyright : (C) 2016 by Damien Plisson, Audirvana
email : damien78@audirvana.com
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_DSDIFFPROPERTIES_H
#define TAGLIB_DSDIFFPROPERTIES_H
#include "audioproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace DSDIFF {
class File;
//! An implementation of audio property reading for DSDIFF
/*!
* This reads the data from an DSDIFF stream found in the AudioProperties API.
*/
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
public:
/*!
* Create an instance of DSDIFF::AudioProperties with the data read from the ByteVector \a data.
*/
explicit AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle);
/*!
* Destroys this DSDIFF::AudioProperties instance.
*/
~AudioProperties() override;
// Reimplementations.
int lengthInSeconds() const override;
int lengthInMilliseconds() const override;
int bitrate() const override;
int sampleRate() const override;
int channels() const override;
int bitsPerSample() const;
long long sampleCount() const;
private:
AudioProperties(const AudioProperties &);
AudioProperties &operator=(const AudioProperties &);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace DSDIFF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,228 +0,0 @@
/***************************************************************************
copyright : (C) 2013 - 2018 by Stephen F. Booth
email : me@sbooth.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "tbytevector.h"
#include "tdebug.h"
#include "id3v2tag.h"
#include "tstringlist.h"
#include "tpropertymap.h"
#include "tagutils.h"
#include "dsffile.h"
using namespace Strawberry_TagLib::TagLib;
// The DSF specification is located at http://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
class DSF::File::FilePrivate {
public:
FilePrivate() : fileSize(0),
metadataOffset(0) {}
long long fileSize;
long long metadataOffset;
std::unique_ptr<AudioProperties> properties;
std::unique_ptr<ID3v2::Tag> tag;
};
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
bool DSF::File::isSupported(IOStream *stream) {
// A DSF file has to start with "DSD "
const ByteVector id = Utils::readHeader(stream, 4, false);
return id.startsWith("DSD ");
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
DSF::File::File(FileName file, bool readProperties,
AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
if (isOpen())
read(readProperties, propertiesStyle);
}
DSF::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
if (isOpen())
read(readProperties, propertiesStyle);
}
DSF::File::~File() {
delete d;
}
ID3v2::Tag *DSF::File::tag() const {
return d->tag.get();
}
DSF::AudioProperties *DSF::File::audioProperties() const {
return d->properties.get();
}
PropertyMap DSF::File::properties() const {
return d->tag->properties();
}
PropertyMap DSF::File::setProperties(const PropertyMap &properties) {
return d->tag->setProperties(properties);
}
bool DSF::File::save() {
if (readOnly()) {
debug("DSF::File::save() -- File is read only.");
return false;
}
if (!isValid()) {
debug("DSF::File::save() -- Trying to save invalid file.");
return false;
}
// Three things must be updated: the file size, the tag data, and the metadata offset
if (d->tag->isEmpty()) {
long long newFileSize = d->metadataOffset ? d->metadataOffset : d->fileSize;
// Update the file size
if (d->fileSize != newFileSize) {
insert(ByteVector::fromUInt64LE(newFileSize), 12, 8);
d->fileSize = newFileSize;
}
// Update the metadata offset to 0 since there is no longer a tag
if (d->metadataOffset) {
insert(ByteVector::fromUInt64LE(0ULL), 20, 8);
d->metadataOffset = 0;
}
// Delete the old tag
truncate(newFileSize);
}
else {
ByteVector tagData = d->tag->render();
long long newMetadataOffset = d->metadataOffset ? d->metadataOffset : d->fileSize;
long long newFileSize = newMetadataOffset + tagData.size();
long long oldTagSize = d->fileSize - newMetadataOffset;
// Update the file size
if (d->fileSize != newFileSize) {
insert(ByteVector::fromUInt64LE(newFileSize), 12, 8);
d->fileSize = newFileSize;
}
// Update the metadata offset
if (d->metadataOffset != newMetadataOffset) {
insert(ByteVector::fromUInt64LE(newMetadataOffset), 20, 8);
d->metadataOffset = newMetadataOffset;
}
// Delete the old tag and write the new one
insert(tagData, newMetadataOffset, static_cast<size_t>(oldTagSize));
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void DSF::File::read(bool, AudioProperties::ReadStyle propertiesStyle) {
// A DSF file consists of four chunks: DSD chunk, format chunk, data chunk, and metadata chunk
// The file format is not chunked in the sense of a RIFF File, though
// DSD chunk
ByteVector chunkName = readBlock(4);
if (chunkName != "DSD ") {
debug("DSF::File::read() -- Not a DSF file.");
setValid(false);
return;
}
long long chunkSize = readBlock(8).toInt64LE(0);
// Integrity check
if (28 != chunkSize) {
debug("DSF::File::read() -- File is corrupted, wrong chunk size");
setValid(false);
return;
}
d->fileSize = readBlock(8).toInt64LE(0);
// File is malformed or corrupted
if (d->fileSize != length()) {
debug("DSF::File::read() -- File is corrupted wrong length");
setValid(false);
return;
}
d->metadataOffset = readBlock(8).toInt64LE(0);
// File is malformed or corrupted
if (d->metadataOffset > d->fileSize) {
debug("DSF::File::read() -- Invalid metadata offset.");
setValid(false);
return;
}
// Format chunk
chunkName = readBlock(4);
if (chunkName != "fmt ") {
debug("DSF::File::read() -- Missing 'fmt ' chunk.");
setValid(false);
return;
}
chunkSize = readBlock(8).toInt64LE(0);
d->properties.reset(new AudioProperties(readBlock(chunkSize), propertiesStyle));
// Skip the data chunk
// A metadata offset of 0 indicates the absence of an ID3v2 tag
if (0 == d->metadataOffset)
d->tag.reset(new ID3v2::Tag());
else
d->tag.reset(new ID3v2::Tag(this, d->metadataOffset));
}

View File

@@ -1,125 +0,0 @@
/***************************************************************************
copyright : (C) 2013 - 2018 by Stephen F. Booth
email : me@sbooth.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_DSFFILE_H
#define TAGLIB_DSFFILE_H
#include "tfile.h"
#include "id3v2tag.h"
#include "dsfproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
//! An implementation of DSF metadata
/*!
* This is implementation of DSF metadata.
*
* This supports an ID3v2 tag as well as properties from the file.
*/
namespace DSF {
//! An implementation of Strawberry_TagLib::TagLib::File with DSF specific methods
/*!
* This implements and provides an interface for DSF files to the
* Strawberry_TagLib::TagLib::Tag and Strawberry_TagLib::TagLib::AudioProperties interfaces by way of implementing
* the abstract Strawberry_TagLib::TagLib::File API as well as providing some additional information specific to DSF files.
*
*/
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
public:
/*!
* Constructs an DSF file from \a file.
* If \a readProperties is true the file's audio properties will also be read using \a propertiesStyle.
* If false, \a propertiesStyle is ignored.
*/
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Constructs an DSF file from \a file.
* If \a readProperties is true the file's audio properties will also be read using \a propertiesStyle.
* If false, \a propertiesStyle is ignored.
*/
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
~File() override;
/*!
* Returns the Tag for this file.
*/
ID3v2::Tag *tag() const override;
/*!
* Implements the unified property interface -- export function.
* This method forwards to ID3v2::Tag::properties().
*/
PropertyMap properties() const override;
/*!
* Implements the unified property interface -- import function.
* This method forwards to ID3v2::Tag::setProperties().
*/
PropertyMap setProperties(const PropertyMap &) override;
/*!
* Returns the DSF::AudioProperties for this file.
* If no audio properties were read then this will return a null pointer.
*/
AudioProperties *audioProperties() const override;
/*!
* Saves the file.
*/
bool save() override;
/*!
* Returns whether or not the given \a stream can be opened as a DSF file.
*
* \note This method is designed to do a quick check.
* The result may not necessarily be correct.
*/
static bool isSupported(IOStream *stream);
private:
File(const File &);
File &operator=(const File &);
void read(bool readProperties, AudioProperties::ReadStyle propertiesStyle);
class FilePrivate;
FilePrivate *d;
};
} // namespace DSF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,135 +0,0 @@
/***************************************************************************
copyright : (C) 2013 by Stephen F. Booth
email : me@sbooth.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tstring.h"
#include "tdebug.h"
#include "dsfproperties.h"
using namespace Strawberry_TagLib::TagLib;
class DSF::AudioProperties::AudioPropertiesPrivate {
public:
explicit AudioPropertiesPrivate() : formatVersion(0),
formatID(0),
channelType(0),
channelNum(0),
samplingFrequency(0),
bitsPerSample(0),
sampleCount(0),
blockSizePerChannel(0),
bitrate(0),
length(0) {
}
// Nomenclature is from DSF file format specification
unsigned int formatVersion;
unsigned int formatID;
unsigned int channelType;
unsigned int channelNum;
unsigned int samplingFrequency;
unsigned int bitsPerSample;
long long sampleCount;
unsigned int blockSizePerChannel;
// Computed
int bitrate;
int length;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
DSF::AudioProperties::AudioProperties(const ByteVector &data, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
read(data);
}
DSF::AudioProperties::~AudioProperties() {
delete d;
}
int DSF::AudioProperties::lengthInSeconds() const {
return d->length / 1000;
}
int DSF::AudioProperties::lengthInMilliseconds() const {
return d->length;
}
int DSF::AudioProperties::bitrate() const {
return d->bitrate;
}
int DSF::AudioProperties::sampleRate() const {
return d->samplingFrequency;
}
int DSF::AudioProperties::channels() const {
return d->channelNum;
}
// DSF specific
int DSF::AudioProperties::formatVersion() const {
return d->formatVersion;
}
int DSF::AudioProperties::formatID() const {
return d->formatID;
}
int DSF::AudioProperties::channelType() const {
return d->channelType;
}
int DSF::AudioProperties::bitsPerSample() const {
return d->bitsPerSample;
}
long long DSF::AudioProperties::sampleCount() const {
return d->sampleCount;
}
int DSF::AudioProperties::blockSizePerChannel() const {
return d->blockSizePerChannel;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void DSF::AudioProperties::read(const ByteVector &data) {
d->formatVersion = data.toUInt32LE(0);
d->formatID = data.toUInt32LE(4);
d->channelType = data.toUInt32LE(8);
d->channelNum = data.toUInt32LE(12);
d->samplingFrequency = data.toUInt32LE(16);
d->bitsPerSample = data.toUInt32LE(20);
d->sampleCount = data.toInt64LE(24);
d->blockSizePerChannel = data.toUInt32LE(32);
d->bitrate = static_cast<int>((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5);
d->length = d->samplingFrequency > 0 ? static_cast<int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0;
}

View File

@@ -1,94 +0,0 @@
/***************************************************************************
copyright : (C) 2013 by Stephen F. Booth
email : me@sbooth.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_DSFPROPERTIES_H
#define TAGLIB_DSFPROPERTIES_H
#include "audioproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace DSF {
class File;
//! An implementation of audio property reading for DSF
/*!
* This reads the data from a DSF stream found in the AudioProperties API.
*/
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
public:
/*!
* Create an instance of DSF::AudioProperties with the data read from the ByteVector \a data.
*/
explicit AudioProperties(const ByteVector &data, ReadStyle);
/*!
* Destroys this DSF::AudioProperties instance.
*/
~AudioProperties() override;
// Reimplementations.
int lengthInSeconds() const override;
int lengthInMilliseconds() const override;
int bitrate() const override;
int sampleRate() const override;
int channels() const override;
int formatVersion() const;
int formatID() const;
/*!
* Channel type values:
* 1 = mono,
* 2 = stereo,
* 3 = 3 channels,
* 4 = quad,
* 5 = 4 channels,
* 6 = 5 channels,
* 7 = 5.1 channels
*/
int channelType() const;
int bitsPerSample() const;
long long sampleCount() const;
int blockSizePerChannel() const;
private:
AudioProperties(const AudioProperties&);
AudioProperties &operator=(const AudioProperties&);
void read(const ByteVector &data);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace DSF
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,424 +0,0 @@
/***************************************************************************
copyright : (C) 2002 - 2008 by Scott Wheeler
email : wheeler@kde.org
copyright : (C) 2010 by Alex Novichkov
email : novichko@atnet.ru
(added APE file support)
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "tfile.h"
#include "tfilestream.h"
#include "tstring.h"
#include "tdebug.h"
#include "fileref.h"
#include "asffile.h"
#include "mpegfile.h"
#include "vorbisfile.h"
#include "flacfile.h"
#include "oggflacfile.h"
#include "mpcfile.h"
#include "mp4file.h"
#include "wavpackfile.h"
#include "speexfile.h"
#include "opusfile.h"
#include "trueaudiofile.h"
#include "aifffile.h"
#include "wavfile.h"
#include "apefile.h"
#include "modfile.h"
#include "s3mfile.h"
#include "itfile.h"
#include "xmfile.h"
#include "dsffile.h"
#include "dsdifffile.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
typedef List<const FileRef::FileTypeResolver*> ResolverList;
ResolverList fileTypeResolvers;
// Detect the file type by user-defined resolvers.
File *detectByResolvers(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
ResolverList::ConstIterator it = fileTypeResolvers.begin();
for (; it != fileTypeResolvers.end(); ++it) {
File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle);
if (file)
return file;
}
return nullptr;
}
// Detect the file type based on the file extension.
File *detectByExtension(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
#ifdef _WIN32
const String s(stream->name().wstr());
#else
const String s(stream->name());
#endif
String ext;
const size_t pos = s.rfind(".");
if (pos != String::npos())
ext = s.substr(pos + 1).upper();
// If this list is updated, the method defaultFileExtensions() should also be
// updated. However at some point that list should be created at the same time
// that a default file type resolver is created.
if (ext.isEmpty())
return nullptr;
// .oga can be any audio in the Ogg container. So leave it to content-based detection.
if (ext == "MP3")
return new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
if (ext == "OGG")
return new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "FLAC")
return new FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "MPC")
return new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "WV")
return new WavPack::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "SPX")
return new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "OPUS")
return new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "TTA")
return new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V")
return new MP4::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "WMA" || ext == "ASF")
return new ASF::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC")
return new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "WAV")
return new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "APE")
return new APE::File(stream, readAudioProperties, audioPropertiesStyle);
// module, nst and wow are possible but uncommon extensions
if (ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW")
return new Mod::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "S3M")
return new S3M::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "IT")
return new IT::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "XM")
return new XM::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "DFF" || ext == "DSDIFF")
return new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle);
if (ext == "DSF")
return new DSF::File(stream, readAudioProperties, audioPropertiesStyle);
return nullptr;
}
// Detect the file type based on the actual content of the stream.
File *detectByContent(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
File *file = nullptr;
if (MPEG::File::isSupported(stream))
file = new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
else if (Ogg::Vorbis::File::isSupported(stream))
file = new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
else if (Ogg::FLAC::File::isSupported(stream))
file = new Ogg::FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
else if (FLAC::File::isSupported(stream))
file = new FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
else if (MPC::File::isSupported(stream))
file = new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
else if (WavPack::File::isSupported(stream))
file = new WavPack::File(stream, readAudioProperties, audioPropertiesStyle);
else if (Ogg::Speex::File::isSupported(stream))
file = new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle);
else if (Ogg::Opus::File::isSupported(stream))
file = new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle);
else if (TrueAudio::File::isSupported(stream))
file = new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle);
else if (MP4::File::isSupported(stream))
file = new MP4::File(stream, readAudioProperties, audioPropertiesStyle);
else if (ASF::File::isSupported(stream))
file = new ASF::File(stream, readAudioProperties, audioPropertiesStyle);
else if (RIFF::AIFF::File::isSupported(stream))
file = new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle);
else if (RIFF::WAV::File::isSupported(stream))
file = new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle);
else if (APE::File::isSupported(stream))
file = new APE::File(stream, readAudioProperties, audioPropertiesStyle);
else if (DSDIFF::File::isSupported(stream))
file = new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle);
else if (DSF::File::isSupported(stream))
file = new DSF::File(stream, readAudioProperties, audioPropertiesStyle);
// isSupported() only does a quick check, so double check the file here.
if (file) {
if (file->isValid())
return file;
else
delete file;
}
return nullptr;
}
struct FileRefData {
FileRefData() : file(nullptr), stream(nullptr) {}
~FileRefData() {
delete file;
delete stream;
}
File *file;
IOStream *stream;
};
} // namespace
class FileRef::FileRefPrivate {
public:
FileRefPrivate() : data(new FileRefData()) {}
std::shared_ptr<FileRefData> data;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
FileRef::FileRef() : d(new FileRefPrivate()) {}
FileRef::FileRef(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) {
parse(fileName, readAudioProperties, audioPropertiesStyle);
}
FileRef::FileRef(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) {
parse(stream, readAudioProperties, audioPropertiesStyle);
}
FileRef::FileRef(File *file) : d(new FileRefPrivate()) {
d->data->file = file;
}
FileRef::FileRef(const FileRef &ref) : d(new FileRefPrivate(*ref.d)) {}
FileRef::~FileRef() {
delete d;
}
Tag *FileRef::tag() const {
if (isNull()) {
debug("FileRef::tag() - Called without a valid file.");
return nullptr;
}
return d->data->file->tag();
}
PropertyMap FileRef::properties() const {
if (isNull()) {
debug("FileRef::properties() - Called without a valid file.");
return PropertyMap();
}
return d->data->file->properties();
}
void FileRef::removeUnsupportedProperties(const StringList &properties) {
if (isNull()) {
debug("FileRef::removeUnsupportedProperties() - Called without a valid file.");
return;
}
d->data->file->removeUnsupportedProperties(properties);
}
PropertyMap FileRef::setProperties(const PropertyMap &properties) {
if (isNull()) {
debug("FileRef::setProperties() - Called without a valid file.");
return PropertyMap();
}
return d->data->file->setProperties(properties);
}
AudioProperties *FileRef::audioProperties() const {
if (isNull()) {
debug("FileRef::audioProperties() - Called without a valid file.");
return nullptr;
}
return d->data->file->audioProperties();
}
File *FileRef::file() const {
return d->data->file;
}
bool FileRef::save() {
if (isNull()) {
debug("FileRef::save() - Called without a valid file.");
return false;
}
return d->data->file->save();
}
const FileRef::FileTypeResolver *FileRef::addFileTypeResolver(const FileRef::FileTypeResolver *resolver) { // static
fileTypeResolvers.prepend(resolver);
return resolver;
}
StringList FileRef::defaultFileExtensions() {
StringList l;
l.append("ogg");
l.append("flac");
l.append("oga");
l.append("mp3");
l.append("mpc");
l.append("wv");
l.append("spx");
l.append("tta");
l.append("m4a");
l.append("m4r");
l.append("m4b");
l.append("m4p");
l.append("3g2");
l.append("mp4");
l.append("m4v");
l.append("wma");
l.append("asf");
l.append("aif");
l.append("aiff");
l.append("wav");
l.append("ape");
l.append("mod");
l.append("module"); // alias for "mod"
l.append("nst"); // alias for "mod"
l.append("wow"); // alias for "mod"
l.append("s3m");
l.append("it");
l.append("xm");
l.append("dsf");
l.append("dff");
l.append("dsdiff"); // alias for "dff"
return l;
}
bool FileRef::isValid() const {
return (d->data->file && d->data->file->isValid());
}
bool FileRef::isNull() const {
return (!d->data->file || !d->data->file->isValid());
}
FileRef &FileRef::operator=(const FileRef &ref) {
FileRef(ref).swap(*this);
return *this;
}
void FileRef::swap(FileRef &ref) {
using std::swap;
swap(d, ref.d);
}
bool FileRef::operator==(const FileRef &ref) const {
return (ref.d->data == d->data);
}
bool FileRef::operator!=(const FileRef &ref) const {
return (ref.d->data != d->data);
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void FileRef::parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
// Try user-defined resolvers.
d->data->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
if (d->data->file)
return;
// Try to resolve file types based on the file extension.
d->data->stream = new FileStream(fileName);
d->data->file = detectByExtension(d->data->stream, readAudioProperties, audioPropertiesStyle);
if (d->data->file)
return;
// At last, try to resolve file types based on the actual content.
d->data->file = detectByContent(d->data->stream, readAudioProperties, audioPropertiesStyle);
if (d->data->file)
return;
// Stream have to be closed here if failed to resolve file types.
delete d->data->stream;
d->data->stream = nullptr;
}
void FileRef::parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
// User-defined resolvers won't work with a stream.
// Try to resolve file types based on the file extension.
d->data->file = detectByExtension(stream, readAudioProperties, audioPropertiesStyle);
if (d->data->file)
return;
// At last, try to resolve file types based on the actual content of the file.
d->data->file = detectByContent(stream, readAudioProperties, audioPropertiesStyle);
}

View File

@@ -1,283 +0,0 @@
/***************************************************************************
copyright : (C) 2002 - 2008 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_FILEREF_H
#define TAGLIB_FILEREF_H
#include "tfile.h"
#include "tstringlist.h"
#include "taglib_export.h"
#include "tpropertymap.h"
#include "audioproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
class Tag;
//! This class provides a simple abstraction for creating and handling files
/*!
* FileRef exists to provide a minimal, generic and value-based wrapper around a File.
* It is lightweight and implicitly shared, and as such suitable for pass-by-value use.
* This hides some of the uglier details of TagLib::File and the non-generic portions of the concrete file implementations.
*
* This class is useful in a "simple usage" situation where it is desirable
* to be able to get and set some of the tag information that is similar across file types.
*
* Also note that it is probably a good idea to plug this into your mime
* type system rather than using the constructor that accepts a file name using the FileTypeResolver.
*
* \see FileTypeResolver
* \see addFileTypeResolver()
*/
class TAGLIB_EXPORT FileRef {
public:
//! A class for pluggable file type resolution.
/*!
* This class is used to add extend TagLib's very basic file name based file type resolution.
*
* This can be accomplished with:
*
* \code
*
* class MyFileTypeResolver : FileTypeResolver
* {
* Strawberry_TagLib::TagLib::File *createFile(Strawberry_TagLib::TagLib::FileName *fileName, bool, AudioProperties::ReadStyle) const
* {
* if(someCheckForAnMP3File(fileName))
* return new Strawberry_TagLib::TagLib::MPEG::File(fileName);
* return 0;
* }
* }
*
* FileRef::addFileTypeResolver(new MyFileTypeResolver);
*
* \endcode
*
* Naturally a less contrived example would be slightly more complex.
* This can be used to plug in mime-type detection systems or to add new file types to TagLib.
*/
class TAGLIB_EXPORT FileTypeResolver {
public:
virtual ~FileTypeResolver() {}
/*!
* This method must be overridden to provide an additional file type resolver.
* If the resolver is able to determine the file type it should return a valid File object; if not it should return 0.
*
* \note The created file is then owned by the FileRef and should not be deleted.
* Deletion will happen automatically when the FileRef passes out of scope.
*/
virtual File *createFile(FileName fileName, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average) const = 0;
};
/*!
* Creates a null FileRef.
*/
explicit FileRef();
/*!
* Create a FileRef from \a fileName.
* If \a readAudioProperties is true then the audio properties will be read using \a audioPropertiesStyle.
* If \a readAudioProperties is false then \a audioPropertiesStyle will be ignored.
*
* Also see the note in the class documentation about why you may not want to
* use this method in your application.
*/
explicit FileRef(FileName fileName, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
/*!
* Construct a FileRef from an opened \a IOStream.
* If \a readAudioProperties is true then the audio properties will be read using \a audioPropertiesStyle.
* If \a readAudioProperties is false then \a audioPropertiesStyle will be ignored.
*
* Also see the note in the class documentation about why you may not want to use this method in your application.
*
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
*/
explicit FileRef(IOStream *stream, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
/*!
* Construct a FileRef using \a file.
* The FileRef now takes ownership of the pointer and will delete the File when it passes out of scope.
*/
explicit FileRef(File *file);
/*!
* Make a copy of \a ref.
*/
FileRef(const FileRef &ref);
/*!
* Destroys this FileRef instance.
*/
virtual ~FileRef();
/*!
* Returns a pointer to represented file's tag.
*
* \warning This pointer will become invalid when this FileRef and all
* copies pass out of scope.
*
* \warning Do not cast it to any subclasses of \class Tag.
* Use tag returning methods of appropriate subclasses of \class File instead.
*
* \see File::tag()
*/
Tag *tag() const;
/*!
* Exports the tags of the file as dictionary mapping (human readable) tag names (uppercase Strings) to StringLists of tag values.
* Calls the according specialization in the File subclasses.
* For each metadata object of the file that could not be parsed into the PropertyMap format,
* the returend map's unsupportedData() list will contain one entry identifying that object (e.g. the frame type for ID3v2 tags).
* Use removeUnsupportedProperties() to remove (a subset of) them.
* For files that contain more than one tag (e.g. an MP3 with both an ID3v1 and an ID3v2 tag) only the most "modern" one will be exported (ID3v2 in this case).
*/
PropertyMap properties() const;
/*!
* Removes unsupported properties, or a subset of them, from the file's metadata.
* The parameter \a properties must contain only entries from properties().unsupportedData().
*/
void removeUnsupportedProperties(const StringList &properties);
/*!
* Sets the tags of this File to those specified in \a properties.
* Calls the according specialization method in the subclasses of File to do the translation into the format-specific details.
* If some value(s) could not be written imported to the specific metadata format,
* the returned PropertyMap will contain those value(s). Otherwise it will be empty, indicating that no problems occured.
* With file types that support several tag formats (for instance, MP3 files can have ID3v1, ID3v2, and APEv2 tags),
* this function will create the most appropriate one (ID3v2 for MP3 files). Older formats will be updated as well,
* if they exist, but won't be taken into account for the return value of this function.
* See the documentation of the subclass implementations for detailed descriptions.
*/
PropertyMap setProperties(const PropertyMap &properties);
/*!
* Returns the audio properties for this FileRef.
* If no audio properties were read then this will returns a null pointer.
*/
AudioProperties *audioProperties() const;
/*!
* Returns a pointer to the file represented by this handler class.
*
* As a general rule this call should be avoided since if you need to work
* with file objects directly, you are probably better served instantiating
* the File subclasses (i.e. MPEG::File) manually and working with their APIs.
*
* This <i>handle</i> exists to provide a minimal, generic and value-based
* wrapper around a File. Accessing the file directly generally indicates
* a moving away from this simplicity (and into things beyond the scope of
* FileRef).
*
* \warning This pointer will become invalid when this FileRef and all
* copies pass out of scope.
*/
File *file() const;
/*!
* Saves the file. Returns true on success.
*/
bool save();
/*!
* Adds a FileTypeResolver to the list of those used by TagLib.
* Each additional FileTypeResolver is added to the front of a list of resolvers that are tried.
* If the FileTypeResolver returns zero the next resolver is tried.
*
* Returns a pointer to the added resolver (the same one that's passed in --
* this is mostly so that static initializers have something to use for assignment).
*
* \see FileTypeResolver
*/
static const FileTypeResolver *addFileTypeResolver(const FileTypeResolver *resolver);
/*!
* As is mentioned elsewhere in this class's documentation, the default file
* type resolution code provided by TagLib only works by comparing file extensions.
*
* This method returns the list of file extensions that are used by default.
*
* The extensions are all returned in lowercase, though the comparison used
* by TagLib for resolution is case-insensitive.
*
* \note This does not account for any additional file type resolvers that
* are plugged in. Also note that this is not intended to replace a proper
* mime-type resolution system, but is just here for reference.
*
* \see FileTypeResolver
*/
static StringList defaultFileExtensions();
/*!
* Returns true if the file is open and readable.
*
* \note Just a negative of isNull().
*/
bool isValid() const;
/*!
* Returns true if the file (and as such other pointers) are null.
*/
bool isNull() const;
/*!
* Assign the file pointed to by \a ref to this FileRef.
*/
FileRef &operator=(const FileRef &ref);
/*!
* Exchanges the content of the FileRef by the content of \a ref.
*/
void swap(FileRef &ref);
/*!
* Returns true if this FileRef and \a ref point to the same File object.
*/
bool operator==(const FileRef &ref) const;
/*!
* Returns true if this FileRef and \a ref do not point to the same File object.
*/
bool operator!=(const FileRef &ref) const;
private:
void parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
void parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
class FileRefPrivate;
FileRefPrivate *d;
};
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif // TAGLIB_FILEREF_H

View File

@@ -1,535 +0,0 @@
/***************************************************************************
copyright : (C) 2003-2004 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "tbytevector.h"
#include "tstring.h"
#include "tlist.h"
#include "tdebug.h"
#include "tagunion.h"
#include "tpropertymap.h"
#include "tagutils.h"
#include "id3v2header.h"
#include "id3v2tag.h"
#include "id3v1tag.h"
#include "xiphcomment.h"
#include "flacpicture.h"
#include "flacfile.h"
#include "flacmetadatablock.h"
#include "flacunknownmetadatablock.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
typedef List<std::shared_ptr<FLAC::MetadataBlock>> BlockList;
typedef BlockList::Iterator BlockIterator;
typedef BlockList::Iterator BlockConstIterator;
enum { FlacXiphIndex = 0,
FlacID3v2Index = 1,
FlacID3v1Index = 2 };
const long long MinPaddingLength = 4096;
const long long MaxPaddingLegnth = 1024 * 1024;
const char LastBlockFlag = '\x80';
} // namespace
namespace Strawberry_TagLib {
namespace TagLib {
namespace FLAC {
// Enables BlockList::find() to take raw pointers.
bool operator==(std::shared_ptr<MetadataBlock> lhs, MetadataBlock *rhs);
bool operator==(std::shared_ptr<MetadataBlock> lhs, MetadataBlock *rhs) {
return lhs.get() == rhs;
}
} // namespace FLAC
} // namespace TagLib
} // namespace Strawberry_TagLib
class FLAC::File::FilePrivate {
public:
explicit FilePrivate(const ID3v2::FrameFactory *frameFactory) : ID3v2FrameFactory(ID3v2::FrameFactory::instance()),
ID3v2Location(-1),
ID3v2OriginalSize(0),
ID3v1Location(-1),
flacStart(0),
streamStart(0),
scanned(false) {
if (frameFactory)
ID3v2FrameFactory = frameFactory;
}
const ID3v2::FrameFactory *ID3v2FrameFactory;
long long ID3v2Location;
long long ID3v2OriginalSize;
long long ID3v1Location;
TripleTagUnion tag;
std::unique_ptr<AudioProperties> properties;
ByteVector xiphCommentData;
BlockList blocks;
long long flacStart;
long long streamStart;
bool scanned;
};
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
bool FLAC::File::isSupported(IOStream *stream) {
// A FLAC file has an ID "fLaC" somewhere. An ID3v2 tag may precede.
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
return (buffer.find("fLaC") != ByteVector::npos());
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
FLAC::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle, ID3v2::FrameFactory *frameFactory) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate(frameFactory)) {
if (isOpen())
read(readProperties);
}
FLAC::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle, ID3v2::FrameFactory *frameFactory) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(frameFactory)) {
if (isOpen())
read(readProperties);
}
FLAC::File::~File() {
delete d;
}
Strawberry_TagLib::TagLib::Tag *FLAC::File::tag() const {
return &d->tag;
}
PropertyMap FLAC::File::setProperties(const PropertyMap &properties) {
return xiphComment(true)->setProperties(properties);
}
FLAC::AudioProperties *FLAC::File::audioProperties() const {
return d->properties.get();
}
bool FLAC::File::save() {
if (readOnly()) {
debug("FLAC::File::save() - Cannot save to a read only file.");
return false;
}
if (!isValid()) {
debug("FLAC::File::save() -- Trying to save invalid file.");
return false;
}
// Create new vorbis comments
if (!hasXiphComment())
Tag::duplicate(&d->tag, xiphComment(true), false);
d->xiphCommentData = xiphComment()->render(false);
// Replace metadata blocks
for (BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
if ((*it)->code() == MetadataBlock::VorbisComment) {
// Set the new Vorbis Comment block
d->blocks.erase(it);
break;
}
}
d->blocks.append(std::shared_ptr<MetadataBlock>(new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData)));
// Render data for the metadata blocks
ByteVector data;
for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
ByteVector blockData = (*it)->render();
ByteVector blockHeader = ByteVector::fromUInt32BE(blockData.size());
blockHeader[0] = (*it)->code();
data.append(blockHeader);
data.append(blockData);
}
// Compute the amount of padding, and append that to data.
long long originalLength = d->streamStart - d->flacStart;
long long paddingLength = originalLength - data.size() - 4;
if (paddingLength <= 0) {
paddingLength = MinPaddingLength;
}
else {
// Padding won't increase beyond 1% of the file size or 1MB.
long long threshold = length() / 100;
threshold = std::max(threshold, MinPaddingLength);
threshold = std::min(threshold, MaxPaddingLegnth);
if (paddingLength > threshold)
paddingLength = MinPaddingLength;
}
ByteVector paddingHeader = ByteVector::fromUInt32BE(paddingLength);
paddingHeader[0] = static_cast<char>(MetadataBlock::Padding | LastBlockFlag);
data.append(paddingHeader);
data.resize(static_cast<size_t>(data.size() + paddingLength));
// Write the data to the file
insert(data, d->flacStart, originalLength);
d->streamStart += (static_cast<long>(data.size()) - originalLength);
if (d->ID3v1Location >= 0)
d->ID3v1Location += (static_cast<long>(data.size()) - originalLength);
// Update ID3 tags
if (ID3v2Tag() && !ID3v2Tag()->isEmpty()) {
// ID3v2 tag is not empty. Update the old one or create a new one.
if (d->ID3v2Location < 0)
d->ID3v2Location = 0;
data = ID3v2Tag()->render();
insert(data, d->ID3v2Location, d->ID3v2OriginalSize);
d->flacStart += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
d->streamStart += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
if (d->ID3v1Location >= 0)
d->ID3v1Location += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
d->ID3v2OriginalSize = data.size();
}
else {
// ID3v2 tag is empty. Remove the old one.
if (d->ID3v2Location >= 0) {
removeBlock(d->ID3v2Location, d->ID3v2OriginalSize);
d->flacStart -= d->ID3v2OriginalSize;
d->streamStart -= d->ID3v2OriginalSize;
if (d->ID3v1Location >= 0)
d->ID3v1Location -= d->ID3v2OriginalSize;
d->ID3v2Location = -1;
d->ID3v2OriginalSize = 0;
}
}
if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
// ID3v1 tag is not empty. Update the old one or create a new one.
if (d->ID3v1Location >= 0) {
seek(d->ID3v1Location);
}
else {
seek(0, End);
d->ID3v1Location = tell();
}
writeBlock(ID3v1Tag()->render());
}
else {
// ID3v1 tag is empty. Remove the old one.
if (d->ID3v1Location >= 0) {
truncate(d->ID3v1Location);
d->ID3v1Location = -1;
}
}
return true;
}
ID3v2::Tag *FLAC::File::ID3v2Tag(bool create) {
return d->tag.access<ID3v2::Tag>(FlacID3v2Index, create);
}
ID3v1::Tag *FLAC::File::ID3v1Tag(bool create) {
return d->tag.access<ID3v1::Tag>(FlacID3v1Index, create);
}
Ogg::XiphComment *FLAC::File::xiphComment(bool create) {
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, create);
}
List<FLAC::Picture *> FLAC::File::pictureList() {
List<Picture *> pictures;
for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
Picture *picture = dynamic_cast<Picture *>(it->get());
if (picture) {
pictures.append(picture);
}
}
return pictures;
}
void FLAC::File::addPicture(Picture *picture) {
d->blocks.append(std::shared_ptr<Picture>(picture));
}
void FLAC::File::removePicture(Picture *picture) {
BlockIterator it = d->blocks.find(picture);
if (it != d->blocks.end())
d->blocks.erase(it);
}
void FLAC::File::removePictures() {
for (BlockIterator it = d->blocks.begin(); it != d->blocks.end();) {
if (dynamic_cast<Picture *>(it->get())) {
it = d->blocks.erase(it);
}
else {
++it;
}
}
}
void FLAC::File::strip(int tags) {
if (tags & ID3v1)
d->tag.set(FlacID3v1Index, nullptr);
if (tags & ID3v2)
d->tag.set(FlacID3v2Index, nullptr);
if (tags & XiphComment) {
xiphComment()->removeAllFields();
xiphComment()->removeAllPictures();
}
}
bool FLAC::File::hasXiphComment() const {
return !d->xiphCommentData.isEmpty();
}
bool FLAC::File::hasID3v1Tag() const {
return (d->ID3v1Location >= 0);
}
bool FLAC::File::hasID3v2Tag() const {
return (d->ID3v2Location >= 0);
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void FLAC::File::read(bool readProperties) {
// Look for an ID3v2 tag
d->ID3v2Location = Utils::findID3v2(this);
if (d->ID3v2Location >= 0) {
d->tag.set(FlacID3v2Index, new ID3v2::Tag(this, d->ID3v2Location, d->ID3v2FrameFactory));
d->ID3v2OriginalSize = ID3v2Tag()->header()->completeTagSize();
}
// Look for an ID3v1 tag
d->ID3v1Location = Utils::findID3v1(this);
if (d->ID3v1Location >= 0)
d->tag.set(FlacID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
// Look for FLAC metadata, including vorbis comments
scan();
if (!isValid())
return;
if (!d->xiphCommentData.isEmpty())
d->tag.set(FlacXiphIndex, new Ogg::XiphComment(d->xiphCommentData));
else
d->tag.set(FlacXiphIndex, new Ogg::XiphComment());
if (readProperties) {
// First block should be the stream_info metadata
const ByteVector infoData = d->blocks.front()->render();
long long streamLength;
if (d->ID3v1Location >= 0)
streamLength = d->ID3v1Location - d->streamStart;
else
streamLength = length() - d->streamStart;
d->properties.reset(new AudioProperties(infoData, streamLength));
}
}
void FLAC::File::scan() {
// Scan the metadata pages
if (d->scanned)
return;
if (!isValid())
return;
long long nextBlockOffset;
if (d->ID3v2Location >= 0)
nextBlockOffset = find("fLaC", d->ID3v2Location + d->ID3v2OriginalSize);
else
nextBlockOffset = find("fLaC");
if (nextBlockOffset < 0) {
debug("FLAC::File::scan() -- FLAC stream not found");
setValid(false);
return;
}
nextBlockOffset += 4;
d->flacStart = nextBlockOffset;
while (true) {
seek(nextBlockOffset);
const ByteVector header = readBlock(4);
// Header format (from spec):
// <1> Last-metadata-block flag
// <7> BLOCK_TYPE
// 0 : STREAMINFO
// 1 : PADDING
// ..
// 4 : VORBIS_COMMENT
// ..
// 6 : PICTURE
// ..
// <24> Length of metadata to follow
const char blockType = header[0] & ~LastBlockFlag;
const bool isLastBlock = (header[0] & LastBlockFlag) != 0;
const size_t blockLength = header.toUInt24BE(1);
// First block should be the stream_info metadata
if (d->blocks.isEmpty() && blockType != MetadataBlock::StreamInfo) {
debug("FLAC::File::scan() -- First block should be the stream_info metadata");
setValid(false);
return;
}
if (blockLength == 0 && blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable) {
debug("FLAC::File::scan() -- Zero-sized metadata block found");
setValid(false);
return;
}
const ByteVector data = readBlock(blockLength);
if (data.size() != blockLength) {
debug("FLAC::File::scan() -- Failed to read a metadata block");
setValid(false);
return;
}
std::shared_ptr<MetadataBlock> block;
// Found the vorbis-comment
if (blockType == MetadataBlock::VorbisComment) {
if (d->xiphCommentData.isEmpty()) {
d->xiphCommentData = data;
block.reset(new UnknownMetadataBlock(MetadataBlock::VorbisComment, data));
}
else {
debug("FLAC::File::scan() -- multiple Vorbis Comment blocks found, discarding");
}
}
else if (blockType == MetadataBlock::Picture) {
std::shared_ptr<FLAC::Picture> picture(new FLAC::Picture());
if (picture->parse(data)) {
block = picture;
}
else {
debug("FLAC::File::scan() -- invalid picture found, discarding");
}
}
else if (blockType == MetadataBlock::Padding) {
// Skip all padding blocks.
}
else {
block.reset(new UnknownMetadataBlock(blockType, data));
}
if (block)
d->blocks.append(block);
nextBlockOffset += blockLength + 4;
if (isLastBlock)
break;
}
// End of metadata, now comes the datastream
d->streamStart = nextBlockOffset;
d->scanned = true;
}

View File

@@ -1,278 +0,0 @@
/***************************************************************************
copyright : (C) 2003 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_FLACFILE_H
#define TAGLIB_FLACFILE_H
#include <memory>
#include "taglib_export.h"
#include "tfile.h"
#include "tlist.h"
#include "tag.h"
#include "flacpicture.h"
#include "flacproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
class Tag;
namespace ID3v2 {
class FrameFactory;
class Tag;
} // namespace ID3v2
namespace ID3v1 {
class Tag;
}
namespace Ogg {
class XiphComment;
}
//! An implementation of FLAC metadata
/*!
* This is implementation of FLAC metadata for non-Ogg FLAC files. At some
* point when Ogg / FLAC is more common there will be a similar implementation
* under the Ogg hierarchy.
*
* This supports ID3v1, ID3v2 and Xiph style comments as well as reading stream
* properties from the file.
*/
namespace FLAC {
//! An implementation of TagLib::File with FLAC specific methods
/*!
* This implements and provides an interface for FLAC files to the TagLib::Tag and TagLib::AudioProperties interfaces
* by way of implementing the abstract TagLib::File API as well as providing some additional information specific to FLAC files.
*
*/
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
public:
/*!
* This set of flags is used for various operations and is suitable for
* being OR-ed together.
*/
enum TagTypes {
//! Empty set. Matches no tag types.
NoTags = 0x0000,
//! Matches Vorbis comments.
XiphComment = 0x0001,
//! Matches ID3v1 tags.
ID3v1 = 0x0002,
//! Matches ID3v2 tags.
ID3v2 = 0x0004,
//! Matches all tag types.
AllTags = 0xffff
};
/*!
* Constructs an FLAC file from \a file.
* If \a readProperties is true the file's audio properties will also be read.
*
* If this file contains and ID3v2 tag the frames will be created using \a frameFactory.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average, ID3v2::FrameFactory *frameFactory = nullptr);
/*!
* Constructs a FLAC file from \a stream. If \a readProperties is true the file's audio properties will also be read.
*
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
*
* If this file contains and ID3v2 tag the frames will be created using \a frameFactory.
*
* \note In the current implementation, \a propertiesStyle is ignored.
*/
// BIC: merge with the above constructor
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average, ID3v2::FrameFactory *frameFactory = nullptr);
/*!
* Destroys this instance of the File.
*/
~File() override;
/*!
* Returns the Tag for this file. This will be a union of XiphComment, ID3v1 and ID3v2 tags.
*
* \see ID3v2Tag()
* \see ID3v1Tag()
* \see XiphComment()
*/
Strawberry_TagLib::TagLib::Tag *tag() const override;
/*!
* Implements the unified property interface -- import function.
* This always creates a Xiph comment, if none exists. The return value relates to the Xiph comment only.
* Ignores any changes to ID3v1 or ID3v2 comments since they are not allowed in the FLAC specification.
*/
PropertyMap setProperties(const PropertyMap &) override;
/*!
* Returns the FLAC::AudioProperties for this file. If no audio properties were read then this will return a null pointer.
*/
AudioProperties *audioProperties() const override;
/*!
* Save the file. This will primarily save the XiphComment, but will also keep any old ID3-tags up to date.
* If the file has no XiphComment, one will be constructed from the ID3-tags.
*
* This returns true if the save was successful.
*/
bool save() override;
/*!
* Returns a pointer to the ID3v2 tag of the file.
*
* If \a create is false (the default) this returns a null pointer
* if there is no valid ID3v2 tag.
* If \a create is true it will create an ID3v2 tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v2 tag.
* Use hasID3v2Tag() to check if the file on disk actually has an ID3v2 tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
* deleted by the user. It will be deleted when the file (object) is destroyed.
*
* \see hasID3v2Tag()
*/
ID3v2::Tag *ID3v2Tag(bool create = false);
/*!
* Returns a pointer to the ID3v1 tag of the file.
*
* If \a create is false (the default) this returns a null pointer if there is no valid APE tag.
* If \a create is true it will create an APE tag if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v1 tag.
* Use hasID3v1Tag() to check if the file on disk actually has an ID3v1 tag.
*
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
* It will be deleted when the file (object) is destroyed.
*
* \see hasID3v1Tag()
*/
ID3v1::Tag *ID3v1Tag(bool create = false);
/*!
* Returns a pointer to the XiphComment for the file.
*
* If \a create is false (the default) this returns a null pointer if there is no valid XiphComment.
* If \a create is true it will create a XiphComment if one does not exist and returns a valid pointer.
*
* \note This may return a valid pointer regardless of whether or not the file on disk has a XiphComment.
* Use hasXiphComment() to check if the file on disk actually has a XiphComment.
*
* \note The Tag <b>is still</b> owned by the FLAC::File and should not be deleted by the user.
* It will be deleted when the file (object) is destroyed.
*
* \see hasXiphComment()
*/
Ogg::XiphComment *xiphComment(bool create = false);
/*!
* Returns a list of pictures attached to the FLAC file.
*/
List<Picture *> pictureList();
/*!
* Removes an attached picture. The picture's memory will be freed.
*/
void removePicture(Picture *picture);
/*!
* Remove all attached images.
*/
void removePictures();
/*!
* Add a new picture to the file.
* The file takes ownership of the picture and will handle freeing its memory.
*
* \note The file will be saved only after calling save().
*/
void addPicture(Picture *picture);
/*!
* This will remove the tags that match the OR-ed together TagTypes from the file.
* By default it removes all tags.
*
* \warning This will also invalidate pointers to the tags as their memory will be freed.
*
* \note In order to make the removal permanent save() still needs to be called.
*
* \note This won't remove the Vorbis comment block completely.
* The vendor ID will be preserved.
*/
void strip(int tags = AllTags);
/*!
* Returns whether or not the file on disk actually has a XiphComment.
*
* \see xiphComment()
*/
bool hasXiphComment() const;
/*!
* Returns whether or not the file on disk actually has an ID3v1 tag.
*
* \see ID3v1Tag()
*/
bool hasID3v1Tag() const;
/*!
* Returns whether or not the file on disk actually has an ID3v2 tag.
*
* \see ID3v2Tag()
*/
bool hasID3v2Tag() const;
/*!
* Returns whether or not the given \a stream can be opened as a FLAC file.
*
* \note This method is designed to do a quick check.
* The result may not necessarily be correct.
*/
static bool isSupported(IOStream *stream);
private:
File(const File&);
File &operator=(const File&);
void read(bool readProperties);
void scan();
class FilePrivate;
FilePrivate *d;
};
} // namespace FLAC
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,39 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "taglib.h"
#include "tdebug.h"
#include "flacmetadatablock.h"
using namespace Strawberry_TagLib::TagLib;
class FLAC::MetadataBlock::MetadataBlockPrivate {
public:
MetadataBlockPrivate() {}
};
FLAC::MetadataBlock::MetadataBlock() : d(nullptr) {}
FLAC::MetadataBlock::~MetadataBlock() {}

View File

@@ -1,74 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_FLACMETADATABLOCK_H
#define TAGLIB_FLACMETADATABLOCK_H
#include "tlist.h"
#include "tbytevector.h"
#include "taglib_export.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace FLAC {
class TAGLIB_EXPORT MetadataBlock {
public:
explicit MetadataBlock();
virtual ~MetadataBlock();
enum BlockType {
StreamInfo = 0,
Padding,
Application,
SeekTable,
VorbisComment,
CueSheet,
Picture
};
/*!
* Returns the FLAC metadata block type.
*/
virtual int code() const = 0;
/*!
* Render the content of the block.
*/
virtual ByteVector render() const = 0;
private:
MetadataBlock(const MetadataBlock &item);
MetadataBlock &operator=(const MetadataBlock &item);
class MetadataBlockPrivate;
MetadataBlockPrivate *d;
};
} // namespace FLAC
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,194 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "taglib.h"
#include "tdebug.h"
#include "flacpicture.h"
using namespace Strawberry_TagLib::TagLib;
class FLAC::Picture::PicturePrivate {
public:
explicit PicturePrivate() : type(FLAC::Picture::Other),
width(0),
height(0),
colorDepth(0),
numColors(0) {
}
Type type;
String mimeType;
String description;
int width;
int height;
int colorDepth;
int numColors;
ByteVector data;
};
FLAC::Picture::Picture() : d(new PicturePrivate()) {
}
FLAC::Picture::Picture(const ByteVector &data) : d(new PicturePrivate()) {
parse(data);
}
FLAC::Picture::~Picture() {
delete d;
}
int FLAC::Picture::code() const {
return FLAC::MetadataBlock::Picture;
}
bool FLAC::Picture::parse(const ByteVector &data) {
if (data.size() < 32) {
debug("A picture block must contain at least 5 bytes.");
return false;
}
size_t pos = 0;
d->type = FLAC::Picture::Type(data.toUInt32BE(pos));
pos += 4;
const unsigned int mimeTypeLength = data.toUInt32BE(pos);
pos += 4;
if (pos + mimeTypeLength + 24 > data.size()) {
debug("Invalid picture block.");
return false;
}
d->mimeType = String(data.mid(pos, mimeTypeLength), String::UTF8);
pos += mimeTypeLength;
const unsigned int descriptionLength = data.toUInt32BE(pos);
pos += 4;
if (pos + descriptionLength + 20 > data.size()) {
debug("Invalid picture block.");
return false;
}
d->description = String(data.mid(pos, descriptionLength), String::UTF8);
pos += descriptionLength;
d->width = data.toUInt32BE(pos);
pos += 4;
d->height = data.toUInt32BE(pos);
pos += 4;
d->colorDepth = data.toUInt32BE(pos);
pos += 4;
d->numColors = data.toUInt32BE(pos);
pos += 4;
const unsigned int dataLength = data.toUInt32BE(pos);
pos += 4;
if (pos + dataLength > data.size()) {
debug("Invalid picture block.");
return false;
}
d->data = data.mid(pos, dataLength);
return true;
}
ByteVector FLAC::Picture::render() const {
ByteVector result;
result.append(ByteVector::fromUInt32BE(d->type));
ByteVector mimeTypeData = d->mimeType.data(String::UTF8);
result.append(ByteVector::fromUInt32BE(mimeTypeData.size()));
result.append(mimeTypeData);
ByteVector descriptionData = d->description.data(String::UTF8);
result.append(ByteVector::fromUInt32BE(descriptionData.size()));
result.append(descriptionData);
result.append(ByteVector::fromUInt32BE(d->width));
result.append(ByteVector::fromUInt32BE(d->height));
result.append(ByteVector::fromUInt32BE(d->colorDepth));
result.append(ByteVector::fromUInt32BE(d->numColors));
result.append(ByteVector::fromUInt32BE(d->data.size()));
result.append(d->data);
return result;
}
FLAC::Picture::Type FLAC::Picture::type() const {
return d->type;
}
void FLAC::Picture::setType(FLAC::Picture::Type type) {
d->type = type;
}
String FLAC::Picture::mimeType() const {
return d->mimeType;
}
void FLAC::Picture::setMimeType(const String &mimeType) {
d->mimeType = mimeType;
}
String FLAC::Picture::description() const {
return d->description;
}
void FLAC::Picture::setDescription(const String &description) {
d->description = description;
}
int FLAC::Picture::width() const {
return d->width;
}
void FLAC::Picture::setWidth(int width) {
d->width = width;
}
int FLAC::Picture::height() const {
return d->height;
}
void FLAC::Picture::setHeight(int height) {
d->height = height;
}
int FLAC::Picture::colorDepth() const {
return d->colorDepth;
}
void FLAC::Picture::setColorDepth(int colorDepth) {
d->colorDepth = colorDepth;
}
int FLAC::Picture::numColors() const {
return d->numColors;
}
void FLAC::Picture::setNumColors(int numColors) {
d->numColors = numColors;
}
ByteVector FLAC::Picture::data() const {
return d->data;
}
void FLAC::Picture::setData(const ByteVector &data) {
d->data = data;
}

View File

@@ -1,203 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_FLACPICTURE_H
#define TAGLIB_FLACPICTURE_H
#include "tlist.h"
#include "tstring.h"
#include "tbytevector.h"
#include "taglib_export.h"
#include "flacmetadatablock.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace FLAC {
class TAGLIB_EXPORT Picture : public MetadataBlock {
public:
/*!
* This describes the function or content of the picture.
*/
enum Type {
//! A type not enumerated below
Other = 0x00,
//! 32x32 PNG image that should be used as the file icon
FileIcon = 0x01,
//! File icon of a different size or format
OtherFileIcon = 0x02,
//! Front cover image of the album
FrontCover = 0x03,
//! Back cover image of the album
BackCover = 0x04,
//! Inside leaflet page of the album
LeafletPage = 0x05,
//! Image from the album itself
Media = 0x06,
//! Picture of the lead artist or soloist
LeadArtist = 0x07,
//! Picture of the artist or performer
Artist = 0x08,
//! Picture of the conductor
Conductor = 0x09,
//! Picture of the band or orchestra
Band = 0x0A,
//! Picture of the composer
Composer = 0x0B,
//! Picture of the lyricist or text writer
Lyricist = 0x0C,
//! Picture of the recording location or studio
RecordingLocation = 0x0D,
//! Picture of the artists during recording
DuringRecording = 0x0E,
//! Picture of the artists during performance
DuringPerformance = 0x0F,
//! Picture from a movie or video related to the track
MovieScreenCapture = 0x10,
//! Picture of a large, coloured fish
ColouredFish = 0x11,
//! Illustration related to the track
Illustration = 0x12,
//! Logo of the band or performer
BandLogo = 0x13,
//! Logo of the publisher (record company)
PublisherLogo = 0x14
};
explicit Picture();
explicit Picture(const ByteVector &data);
~Picture() override;
/*!
* Returns the type of the image.
*/
Type type() const;
/*!
* Sets the type of the image.
*/
void setType(Type type);
/*!
* Returns the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
*/
String mimeType() const;
/*!
* Sets the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
*/
void setMimeType(const String &m);
/*!
* Returns a text description of the image.
*/
String description() const;
/*!
* Sets a textual description of the image to \a desc.
*/
void setDescription(const String &desc);
/*!
* Returns the width of the image.
*/
int width() const;
/*!
* Sets the width of the image.
*/
void setWidth(int w);
/*!
* Returns the height of the image.
*/
int height() const;
/*!
* Sets the height of the image.
*/
void setHeight(int h);
/*!
* Returns the color depth (in bits-per-pixel) of the image.
*/
int colorDepth() const;
/*!
* Sets the color depth (in bits-per-pixel) of the image.
*/
void setColorDepth(int depth);
/*!
* Returns the number of colors used on the image..
*/
int numColors() const;
/*!
* Sets the number of colors used on the image (for indexed images).
*/
void setNumColors(int numColors);
/*!
* Returns the image data.
*/
ByteVector data() const;
/*!
* Sets the image data.
*/
void setData(const ByteVector &data);
/*!
* Returns the FLAC metadata block type.
*/
int code() const override;
/*!
* Render the content to the FLAC picture block format.
*/
ByteVector render() const override;
/*!
* Parse the picture data in the FLAC picture block format.
*/
bool parse(const ByteVector &rawData);
private:
Picture(const Picture &item);
Picture &operator=(const Picture &item);
class PicturePrivate;
PicturePrivate *d;
};
} // namespace FLAC
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,146 +0,0 @@
/***************************************************************************
copyright : (C) 2003 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tstring.h"
#include "tdebug.h"
#include "flacproperties.h"
#include "flacfile.h"
using namespace Strawberry_TagLib::TagLib;
class FLAC::AudioProperties::AudioPropertiesPrivate {
public:
explicit AudioPropertiesPrivate() : length(0),
bitrate(0),
sampleRate(0),
bitsPerSample(0),
channels(0),
sampleFrames(0) {}
int length;
int bitrate;
int sampleRate;
int bitsPerSample;
int channels;
unsigned long long sampleFrames;
ByteVector signature;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
FLAC::AudioProperties::AudioProperties(const ByteVector &data, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
read(data, streamLength);
}
FLAC::AudioProperties::~AudioProperties() {
delete d;
}
int FLAC::AudioProperties::lengthInSeconds() const {
return d->length / 1000;
}
int FLAC::AudioProperties::lengthInMilliseconds() const {
return d->length;
}
int FLAC::AudioProperties::bitrate() const {
return d->bitrate;
}
int FLAC::AudioProperties::sampleRate() const {
return d->sampleRate;
}
int FLAC::AudioProperties::bitsPerSample() const {
return d->bitsPerSample;
}
int FLAC::AudioProperties::channels() const {
return d->channels;
}
unsigned long long FLAC::AudioProperties::sampleFrames() const {
return d->sampleFrames;
}
ByteVector FLAC::AudioProperties::signature() const {
return d->signature;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void FLAC::AudioProperties::read(const ByteVector &data, long long streamLength) {
if (data.size() < 18) {
debug("FLAC::AudioProperties::read() - FLAC properties must contain at least 18 bytes.");
return;
}
size_t pos = 0;
// Minimum block size (in samples)
pos += 2;
// Maximum block size (in samples)
pos += 2;
// Minimum frame size (in bytes)
pos += 3;
// Maximum frame size (in bytes)
pos += 3;
const unsigned int flags = data.toUInt32BE(pos);
pos += 4;
d->sampleRate = flags >> 12;
d->channels = ((flags >> 9) & 7) + 1;
d->bitsPerSample = ((flags >> 4) & 31) + 1;
// The last 4 bits are the most significant 4 bits for the 36 bit
// stream length in samples. (Audio files measured in days)
const unsigned long long hi = flags & 0xf;
const unsigned long long lo = data.toUInt32BE(pos);
pos += 4;
d->sampleFrames = (hi << 32) | lo;
if (d->sampleFrames > 0 && d->sampleRate > 0) {
const double length = d->sampleFrames * 1000.0 / d->sampleRate;
d->length = static_cast<int>(length + 0.5);
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
}
if (data.size() >= pos + 16)
d->signature = data.mid(pos, 16);
}

View File

@@ -1,111 +0,0 @@
/***************************************************************************
copyright : (C) 2003 by Allan Sandfeld Jensen
email : kde@carewolf.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_FLACPROPERTIES_H
#define TAGLIB_FLACPROPERTIES_H
#include "taglib_export.h"
#include "audioproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace FLAC {
class File;
//! An implementation of audio property reading for FLAC
/*!
* This reads the data from an FLAC stream found in the AudioProperties API.
*/
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
public:
/*!
* Create an instance of FLAC::AudioProperties with the data read from the ByteVector \a data.
*/
explicit AudioProperties(const ByteVector &data, long long streamLength, ReadStyle style = Average);
/*!
* Destroys this FLAC::AudioProperties instance.
*/
~AudioProperties() override;
/*!
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
*
* \see lengthInMilliseconds()
*/
int lengthInSeconds() const override;
/*!
* Returns the length of the file in milliseconds.
*
* \see lengthInSeconds()
*/
int lengthInMilliseconds() const override;
/*!
* Returns the average bit rate of the file in kb/s.
*/
int bitrate() const override;
/*!
* Returns the sample rate in Hz.
*/
int sampleRate() const override;
/*!
* Returns the number of audio channels.
*/
int channels() const override;
/*!
* Returns the number of bits per audio sample as read from the FLAC identification header.
*/
int bitsPerSample() const;
/*!
* Return the number of sample frames.
*/
unsigned long long sampleFrames() const;
/*!
* Returns the MD5 signature of the uncompressed audio stream as read from the stream info header.
*/
ByteVector signature() const;
private:
void read(const ByteVector &data, long long streamLength);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace FLAC
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,68 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "taglib.h"
#include "tdebug.h"
#include "tstring.h"
#include "flacunknownmetadatablock.h"
using namespace Strawberry_TagLib::TagLib;
class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate {
public:
explicit UnknownMetadataBlockPrivate() : code(0) {}
int code;
ByteVector data;
};
FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) : d(new UnknownMetadataBlockPrivate()) {
d->code = code;
d->data = data;
}
FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() {
delete d;
}
int FLAC::UnknownMetadataBlock::code() const {
return d->code;
}
void FLAC::UnknownMetadataBlock::setCode(int code) {
d->code = code;
}
ByteVector FLAC::UnknownMetadataBlock::data() const {
return d->data;
}
void FLAC::UnknownMetadataBlock::setData(const ByteVector &data) {
d->data = data;
}
ByteVector FLAC::UnknownMetadataBlock::render() const {
return d->data;
}

View File

@@ -1,80 +0,0 @@
/**************************************************************************
copyright : (C) 2010 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_FLACUNKNOWNMETADATABLOCK_H
#define TAGLIB_FLACUNKNOWNMETADATABLOCK_H
#include "tlist.h"
#include "tbytevector.h"
#include "taglib_export.h"
#include "flacmetadatablock.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace FLAC {
class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock {
public:
explicit UnknownMetadataBlock(int code, const ByteVector &data);
~UnknownMetadataBlock() override;
/*!
* Returns the FLAC metadata block type.
*/
int code() const override;
/*!
* Sets the FLAC metadata block type.
*/
void setCode(int code);
/*!
* Returns the FLAC metadata block type.
*/
ByteVector data() const;
/*!
* Sets the FLAC metadata block type.
*/
void setData(const ByteVector &data);
/*!
* Render the content of the block.
*/
ByteVector render() const override;
private:
explicit UnknownMetadataBlock(const MetadataBlock &item);
UnknownMetadataBlock &operator=(const MetadataBlock &item);
class UnknownMetadataBlockPrivate;
UnknownMetadataBlockPrivate *d;
};
} // namespace FLAC
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,312 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tstringlist.h"
#include "itfile.h"
#include "tdebug.h"
#include "modfileprivate.h"
#include "tpropertymap.h"
using namespace Strawberry_TagLib::TagLib;
using namespace IT;
class IT::File::FilePrivate {
public:
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) : properties(propertiesStyle) {}
Mod::Tag tag;
IT::AudioProperties properties;
};
IT::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
}
IT::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
}
IT::File::~File() {
delete d;
}
Mod::Tag *IT::File::tag() const {
return &d->tag;
}
IT::AudioProperties *IT::File::audioProperties() const {
return &d->properties;
}
bool IT::File::save() {
if (readOnly()) {
debug("IT::File::save() - Cannot save to a read only file.");
return false;
}
seek(4);
writeString(d->tag.title(), 25);
writeByte(0);
seek(2, Current);
unsigned short length = 0;
unsigned short instrumentCount = 0;
unsigned short sampleCount = 0;
if (!readU16L(length) || !readU16L(instrumentCount) || !readU16L(sampleCount))
return false;
seek(15, Current);
// write comment as instrument and sample names:
StringList lines = d->tag.comment().split("\n");
for (unsigned short i = 0; i < instrumentCount; ++i) {
seek(192L + length + (static_cast<long>(i) << 2));
unsigned int instrumentOffset = 0;
if (!readU32L(instrumentOffset))
return false;
seek(instrumentOffset + 32);
if (i < lines.size())
writeString(lines[i], 25);
else
writeString(String(), 25);
writeByte(0);
}
for (unsigned short i = 0; i < sampleCount; ++i) {
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
unsigned int sampleOffset = 0;
if (!readU32L(sampleOffset))
return false;
seek(sampleOffset + 20);
if (static_cast<unsigned int>(i + instrumentCount) < lines.size())
writeString(lines[i + instrumentCount], 25);
else
writeString(String(), 25);
writeByte(0);
}
// write rest as message:
StringList messageLines;
for (unsigned int i = instrumentCount + sampleCount; i < lines.size(); ++i)
messageLines.append(lines[i]);
ByteVector message = messageLines.toString("\r").data(String::Latin1);
// it's actually not really stated if the message needs a
// terminating NUL but it does not hurt to add one:
if (message.size() > 7999)
message.resize(7999);
message.append(static_cast<char>(0));
unsigned short special = 0;
unsigned short messageLength = 0;
unsigned int messageOffset = 0;
seek(46);
if (!readU16L(special))
return false;
unsigned int fileSize = File::length();
if (special & AudioProperties::MessageAttached) {
seek(54);
if (!readU16L(messageLength) || !readU32L(messageOffset))
return false;
if (messageLength == 0)
messageOffset = fileSize;
}
else {
messageOffset = fileSize;
seek(46);
writeU16L(special | 0x1);
}
if (messageOffset + messageLength >= fileSize) {
// append new message
seek(54);
writeU16L(message.size());
writeU32L(messageOffset);
seek(messageOffset);
writeBlock(message);
truncate(messageOffset + message.size());
}
else {
// Only overwrite existing message.
// I'd need to parse (understand!) the whole file for more.
// Although I could just move the message to the end of file
// and let the existing one be, but that would waste space.
message.resize(messageLength, 0);
seek(messageOffset);
writeBlock(message);
}
return true;
}
void IT::File::read(bool) {
if (!isOpen())
return;
seek(0);
READ_ASSERT(readBlock(4) == "IMPM");
READ_STRING(d->tag.setTitle, 26);
seek(2, Current);
READ_U16L_AS(length);
READ_U16L_AS(instrumentCount);
READ_U16L_AS(sampleCount);
d->properties.setInstrumentCount(instrumentCount);
d->properties.setSampleCount(sampleCount);
READ_U16L(d->properties.setPatternCount);
READ_U16L(d->properties.setVersion);
READ_U16L(d->properties.setCompatibleVersion);
READ_U16L(d->properties.setFlags);
READ_U16L_AS(special);
d->properties.setSpecial(special);
READ_BYTE(d->properties.setGlobalVolume);
READ_BYTE(d->properties.setMixVolume);
READ_BYTE(d->properties.setBpmSpeed);
READ_BYTE(d->properties.setTempo);
READ_BYTE(d->properties.setPanningSeparation);
READ_BYTE(d->properties.setPitchWheelDepth);
// IT supports some kind of comment tag. Still, the
// sample/instrument names are abused as comments so
// I just add all together.
String message;
if (special & AudioProperties::MessageAttached) {
READ_U16L_AS(messageLength);
READ_U32L_AS(messageOffset);
seek(messageOffset);
ByteVector messageBytes = readBlock(messageLength);
READ_ASSERT(messageBytes.size() == messageLength);
const size_t index = messageBytes.find(static_cast<char>(0));
if (index != ByteVector::npos())
messageBytes.resize(index, 0);
messageBytes.replace('\r', '\n');
message = messageBytes;
}
seek(64);
ByteVector pannings = readBlock(64);
ByteVector volumes = readBlock(64);
READ_ASSERT(pannings.size() == 64 && volumes.size() == 64);
int channels = 0;
for (int i = 0; i < 64; ++i) {
// Strictly speaking an IT file has always 64 channels, but
// I don't count disabled and muted channels.
// But this always gives 64 channels for all my files anyway.
// Strangely VLC does report other values. I wonder how VLC
// gets it's values.
if (static_cast<unsigned char>(pannings[i]) < 128 && volumes[i] > 0)
++channels;
}
d->properties.setChannels(channels);
// real length might be shorter because of skips and terminator
unsigned short realLength = 0;
for (unsigned short i = 0; i < length; ++i) {
READ_BYTE_AS(order);
if (order == 255) break;
if (order != 254) ++realLength;
}
d->properties.setLengthInPatterns(realLength);
StringList comment;
// Note: I found files that have nil characters somewhere
// in the instrument/sample names and more characters
// afterwards. The spec does not mention such a case.
// Currently I just discard anything after a nil, but
// e.g. VLC seems to interpret a nil as a space. I
// don't know what is the proper behaviour.
for (unsigned short i = 0; i < instrumentCount; ++i) {
seek(192L + length + (static_cast<long>(i) << 2));
READ_U32L_AS(instrumentOffset);
seek(instrumentOffset);
ByteVector instrumentMagic = readBlock(4);
READ_ASSERT(instrumentMagic == "IMPI");
READ_STRING_AS(dosFileName, 13);
seek(15, Current);
READ_STRING_AS(instrumentName, 26);
comment.append(instrumentName);
}
for (unsigned short i = 0; i < sampleCount; ++i) {
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
READ_U32L_AS(sampleOffset);
seek(sampleOffset);
ByteVector sampleMagic = readBlock(4);
READ_ASSERT(sampleMagic == "IMPS");
READ_STRING_AS(dosFileName, 13);
READ_BYTE_AS(globalVolume);
READ_BYTE_AS(sampleFlags);
READ_BYTE_AS(sampleVolume);
READ_STRING_AS(sampleName, 26);
/*
READ_BYTE_AS(sampleCvt);
READ_BYTE_AS(samplePanning);
READ_U32L_AS(sampleLength);
READ_U32L_AS(loopStart);
READ_U32L_AS(loopStop);
READ_U32L_AS(c5speed);
READ_U32L_AS(sustainLoopStart);
READ_U32L_AS(sustainLoopEnd);
READ_U32L_AS(sampleDataOffset);
READ_BYTE_AS(vibratoSpeed);
READ_BYTE_AS(vibratoDepth);
READ_BYTE_AS(vibratoRate);
READ_BYTE_AS(vibratoType);
*/
comment.append(sampleName);
}
if (message.size() > 0)
comment.append(message);
d->tag.setComment(comment.toString("\n"));
d->tag.setTrackerName("Impulse Tracker");
}

View File

@@ -1,91 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#ifndef TAGLIB_ITFILE_H
#define TAGLIB_ITFILE_H
#include "tfile.h"
#include "audioproperties.h"
#include "taglib_export.h"
#include "modfilebase.h"
#include "modtag.h"
#include "itproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace IT {
class TAGLIB_EXPORT File : public Mod::FileBase {
public:
/*!
* Constructs a Impulse Tracker file from \a file.
*
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
* The audio properties are always read.
*/
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Constructs a Impulse Tracker file from \a stream.
*
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
* The audio properties are always read.
*
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
*/
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
~File() override;
Mod::Tag *tag() const override;
/*!
* Returns the IT::AudioProperties for this file. If no audio properties
* were read then this will return a null pointer.
*/
IT::AudioProperties *audioProperties() const override;
/*!
* Save the file.
* This is the same as calling save(AllTags);
*
* \note Saving Impulse Tracker tags is not supported.
*/
bool save() override;
private:
File(const File&);
File &operator=(const File&);
void read(bool readProperties);
class FilePrivate;
FilePrivate *d;
};
} // namespace IT
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,216 +0,0 @@
/***************************************************************************
copyright :(C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "itproperties.h"
using namespace Strawberry_TagLib::TagLib;
using namespace IT;
class IT::AudioProperties::AudioPropertiesPrivate {
public:
explicit AudioPropertiesPrivate() : channels(0),
lengthInPatterns(0),
instrumentCount(0),
sampleCount(0),
patternCount(0),
version(0),
compatibleVersion(0),
flags(0),
special(0),
globalVolume(0),
mixVolume(0),
tempo(0),
bpmSpeed(0),
panningSeparation(0),
pitchWheelDepth(0) {
}
int channels;
unsigned short lengthInPatterns;
unsigned short instrumentCount;
unsigned short sampleCount;
unsigned short patternCount;
unsigned short version;
unsigned short compatibleVersion;
unsigned short flags;
unsigned short special;
unsigned char globalVolume;
unsigned char mixVolume;
unsigned char tempo;
unsigned char bpmSpeed;
unsigned char panningSeparation;
unsigned char pitchWheelDepth;
};
IT::AudioProperties::AudioProperties(AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {}
IT::AudioProperties::~AudioProperties() {
delete d;
}
int IT::AudioProperties::lengthInSeconds() const {
return 0;
}
int IT::AudioProperties::lengthInMilliseconds() const {
return 0;
}
int IT::AudioProperties::bitrate() const {
return 0;
}
int IT::AudioProperties::sampleRate() const {
return 0;
}
int IT::AudioProperties::channels() const {
return d->channels;
}
unsigned short IT::AudioProperties::lengthInPatterns() const {
return d->lengthInPatterns;
}
bool IT::AudioProperties::stereo() const {
return d->flags & Stereo;
}
unsigned short IT::AudioProperties::instrumentCount() const {
return d->instrumentCount;
}
unsigned short IT::AudioProperties::sampleCount() const {
return d->sampleCount;
}
unsigned short IT::AudioProperties::patternCount() const {
return d->patternCount;
}
unsigned short IT::AudioProperties::version() const {
return d->version;
}
unsigned short IT::AudioProperties::compatibleVersion() const {
return d->compatibleVersion;
}
unsigned short IT::AudioProperties::flags() const {
return d->flags;
}
unsigned short IT::AudioProperties::special() const {
return d->special;
}
unsigned char IT::AudioProperties::globalVolume() const {
return d->globalVolume;
}
unsigned char IT::AudioProperties::mixVolume() const {
return d->mixVolume;
}
unsigned char IT::AudioProperties::tempo() const {
return d->tempo;
}
unsigned char IT::AudioProperties::bpmSpeed() const {
return d->bpmSpeed;
}
unsigned char IT::AudioProperties::panningSeparation() const {
return d->panningSeparation;
}
unsigned char IT::AudioProperties::pitchWheelDepth() const {
return d->pitchWheelDepth;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void IT::AudioProperties::setChannels(int channels) {
d->channels = channels;
}
void IT::AudioProperties::setLengthInPatterns(unsigned short lengthInPatterns) {
d->lengthInPatterns = lengthInPatterns;
}
void IT::AudioProperties::setInstrumentCount(unsigned short instrumentCount) {
d->instrumentCount = instrumentCount;
}
void IT::AudioProperties::setSampleCount(unsigned short sampleCount) {
d->sampleCount = sampleCount;
}
void IT::AudioProperties::setPatternCount(unsigned short patternCount) {
d->patternCount = patternCount;
}
void IT::AudioProperties::setFlags(unsigned short flags) {
d->flags = flags;
}
void IT::AudioProperties::setSpecial(unsigned short special) {
d->special = special;
}
void IT::AudioProperties::setCompatibleVersion(unsigned short compatibleVersion) {
d->compatibleVersion = compatibleVersion;
}
void IT::AudioProperties::setVersion(unsigned short version) {
d->version = version;
}
void IT::AudioProperties::setGlobalVolume(unsigned char globalVolume) {
d->globalVolume = globalVolume;
}
void IT::AudioProperties::setMixVolume(unsigned char mixVolume) {
d->mixVolume = mixVolume;
}
void IT::AudioProperties::setTempo(unsigned char tempo) {
d->tempo = tempo;
}
void IT::AudioProperties::setBpmSpeed(unsigned char bpmSpeed) {
d->bpmSpeed = bpmSpeed;
}
void IT::AudioProperties::setPanningSeparation(unsigned char panningSeparation) {
d->panningSeparation = panningSeparation;
}
void IT::AudioProperties::setPitchWheelDepth(unsigned char pitchWheelDepth) {
d->pitchWheelDepth = pitchWheelDepth;
}

View File

@@ -1,107 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_ITPROPERTIES_H
#define TAGLIB_ITPROPERTIES_H
#include "taglib.h"
#include "audioproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace IT {
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
friend class File;
public:
/*! Flag bits. */
enum {
Stereo = 1,
Vol0MixOptimizations = 2,
UseInstruments = 4,
LinearSlides = 8,
OldEffects = 16,
LinkEffects = 32,
UseMidiPitchController = 64,
RequestEmbeddedMidiConf = 128
};
/*! Special bits. */
enum {
MessageAttached = 1,
MidiConfEmbedded = 8
};
explicit AudioProperties(AudioProperties::ReadStyle);
~AudioProperties() override;
int lengthInSeconds() const override;
int lengthInMilliseconds() const override;
int bitrate() const override;
int sampleRate() const override;
int channels() const override;
unsigned short lengthInPatterns() const;
bool stereo() const;
unsigned short instrumentCount() const;
unsigned short sampleCount() const;
unsigned short patternCount() const;
unsigned short version() const;
unsigned short compatibleVersion() const;
unsigned short flags() const;
unsigned short special() const;
unsigned char globalVolume() const;
unsigned char mixVolume() const;
unsigned char tempo() const;
unsigned char bpmSpeed() const;
unsigned char panningSeparation() const;
unsigned char pitchWheelDepth() const;
private:
void setChannels(int channels);
void setLengthInPatterns(unsigned short lengthInPatterns);
void setInstrumentCount(unsigned short instrumentCount);
void setSampleCount(unsigned short sampleCount);
void setPatternCount(unsigned short patternCount);
void setVersion(unsigned short version);
void setCompatibleVersion(unsigned short compatibleVersion);
void setFlags(unsigned short flags);
void setSpecial(unsigned short special);
void setGlobalVolume(unsigned char globalVolume);
void setMixVolume(unsigned char mixVolume);
void setTempo(unsigned char tempo);
void setBpmSpeed(unsigned char bpmSpeed);
void setPanningSeparation(unsigned char panningSeparation);
void setPitchWheelDepth(unsigned char pitchWheelDepth);
private:
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace IT
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,173 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "modfile.h"
#include "tstringlist.h"
#include "tdebug.h"
#include "modfileprivate.h"
#include "tpropertymap.h"
using namespace Strawberry_TagLib::TagLib;
using namespace Mod;
class Mod::File::FilePrivate {
public:
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) : properties(propertiesStyle) {}
Mod::Tag tag;
Mod::AudioProperties properties;
};
Mod::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
}
Mod::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
if (isOpen())
read(readProperties);
}
Mod::File::~File() {
delete d;
}
Mod::Tag *Mod::File::tag() const {
return &d->tag;
}
Mod::AudioProperties *Mod::File::audioProperties() const {
return &d->properties;
}
bool Mod::File::save() {
if (readOnly()) {
debug("Mod::File::save() - Cannot save to a read only file.");
return false;
}
seek(0);
writeString(d->tag.title(), 20);
StringList lines = d->tag.comment().split("\n");
size_t n = std::min<size_t>(lines.size(), d->properties.instrumentCount());
for (size_t i = 0; i < n; ++i) {
writeString(lines[i], 22);
seek(8, Current);
}
for (size_t i = n; i < d->properties.instrumentCount(); ++i) {
writeString(String(), 22);
seek(8, Current);
}
return true;
}
void Mod::File::read(bool) {
if (!isOpen())
return;
seek(1080);
ByteVector modId = readBlock(4);
READ_ASSERT(modId.size() == 4);
int channels = 4;
unsigned int instruments = 31;
if (modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") {
d->tag.setTrackerName("ProTracker");
channels = 4;
}
else if (modId.startsWith("FLT") || modId.startsWith("TDZ")) {
d->tag.setTrackerName("StarTrekker");
char digit = modId[3];
READ_ASSERT(digit >= '0' && digit <= '9');
channels = digit - '0';
}
else if (modId.endsWith("CHN")) {
d->tag.setTrackerName("StarTrekker");
char digit = modId[0];
READ_ASSERT(digit >= '0' && digit <= '9');
channels = digit - '0';
}
else if (modId == "CD81" || modId == "OKTA") {
d->tag.setTrackerName("Atari Oktalyzer");
channels = 8;
}
else if (modId.endsWith("CH") || modId.endsWith("CN")) {
d->tag.setTrackerName("TakeTracker");
char digit = modId[0];
READ_ASSERT(digit >= '0' && digit <= '9');
channels = (digit - '0') * 10;
digit = modId[1];
READ_ASSERT(digit >= '0' && digit <= '9');
channels += digit - '0';
}
else {
// Not sure if this is correct. I'd need a file
// created with NoiseTracker to check this.
d->tag.setTrackerName("NoiseTracker"); // probably
channels = 4;
instruments = 15;
}
d->properties.setChannels(channels);
d->properties.setInstrumentCount(instruments);
seek(0);
READ_STRING(d->tag.setTitle, 20);
StringList comment;
for (unsigned int i = 0; i < instruments; ++i) {
READ_STRING_AS(instrumentName, 22);
// value in words, * 2 (<< 1) for bytes:
READ_U16B_AS(sampleLength);
READ_BYTE_AS(fineTuneByte);
int fineTune = fineTuneByte & 0xF;
// > 7 means negative value
if (fineTune > 7) fineTune -= 16;
READ_BYTE_AS(volume);
if (volume > 64) volume = 64;
// volume in decibels: 20 * log10(volume / 64)
// value in words, * 2 (<< 1) for bytes:
READ_U16B_AS(repeatStart);
// value in words, * 2 (<< 1) for bytes:
READ_U16B_AS(repatLength);
comment.append(instrumentName);
}
READ_BYTE(d->properties.setLengthInPatterns);
d->tag.setComment(comment.toString("\n"));
}

View File

@@ -1,95 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_MODFILE_H
#define TAGLIB_MODFILE_H
#include "tfile.h"
#include "audioproperties.h"
#include "taglib_export.h"
#include "modfilebase.h"
#include "modtag.h"
#include "modproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
public:
/*!
* Constructs a Protracker file from \a file.
*
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
* The audio properties are always read.
*/
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Constructs a Protracker file from \a stream.
*
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
* The audio properties are always read.
*
* \note TagLib will *not* take ownership of the stream, the caller is
* responsible for deleting it after the File object.
*/
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
/*!
* Destroys this instance of the File.
*/
~File() override;
Mod::Tag *tag() const override;
/*!
* Returns the Mod::AudioProperties for this file. If no audio properties were read then this will return a null pointer.
*/
Mod::AudioProperties *audioProperties() const override;
/*!
* Save the file.
* This is the same as calling save(AllTags);
*
* \note Saving Protracker tags is not supported.
*/
bool save() override;
private:
File(const File &);
File &operator=(const File &);
void read(bool readProperties);
class FilePrivate;
FilePrivate *d;
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,122 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tdebug.h"
#include "modfilebase.h"
using namespace Strawberry_TagLib::TagLib;
using namespace Mod;
Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) {}
Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) {}
void Mod::FileBase::writeString(const String &s, unsigned int size, char padding) {
ByteVector data(s.data(String::Latin1));
data.resize(size, padding);
writeBlock(data);
}
bool Mod::FileBase::readString(String &s, unsigned int size) {
ByteVector data(readBlock(size));
if (data.size() < size) return false;
const size_t index = data.find(static_cast<char>(0));
if (index != ByteVector::npos()) {
data.resize(index);
}
data.replace('\xff', ' ');
s = data;
return true;
}
void Mod::FileBase::writeByte(unsigned char _byte) {
ByteVector data(1, _byte);
writeBlock(data);
}
void Mod::FileBase::writeU16L(unsigned short number) {
writeBlock(ByteVector::fromUInt16LE(number));
}
void Mod::FileBase::writeU32L(unsigned int number) {
writeBlock(ByteVector::fromUInt32LE(number));
}
void Mod::FileBase::writeU16B(unsigned short number) {
writeBlock(ByteVector::fromUInt16BE(number));
}
void Mod::FileBase::writeU32B(unsigned int number) {
writeBlock(ByteVector::fromUInt32BE(number));
}
bool Mod::FileBase::readByte(unsigned char &_byte) {
ByteVector data(readBlock(1));
if (data.size() < 1) return false;
_byte = data[0];
return true;
}
bool Mod::FileBase::readU16L(unsigned short &number) {
ByteVector data(readBlock(2));
if (data.size() < 2) return false;
number = data.toUInt16LE(0);
return true;
}
bool Mod::FileBase::readU32L(unsigned int &number) {
ByteVector data(readBlock(4));
if (data.size() < 4) return false;
number = data.toUInt32LE(0);
return true;
}
bool Mod::FileBase::readU16B(unsigned short &number) {
ByteVector data(readBlock(2));
if (data.size() < 2) return false;
number = data.toUInt16BE(0);
return true;
}
bool Mod::FileBase::readU32B(unsigned int &number) {
ByteVector data(readBlock(4));
if (data.size() < 4) return false;
number = data.toUInt32BE(0);
return true;
}

View File

@@ -1,65 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_MODFILEBASE_H
#define TAGLIB_MODFILEBASE_H
#include "taglib.h"
#include "tfile.h"
#include "tstring.h"
#include "tlist.h"
#include "taglib_export.h"
#include <algorithm>
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File {
protected:
explicit FileBase(FileName file);
explicit FileBase(IOStream *stream);
void writeString(const String &s, unsigned int size, char padding = 0);
void writeByte(unsigned char byte);
void writeU16L(unsigned short number);
void writeU32L(unsigned int number);
void writeU16B(unsigned short number);
void writeU32B(unsigned int number);
bool readString(String &s, unsigned int size);
bool readByte(unsigned char &_byte);
bool readU16L(unsigned short &number);
bool readU32L(unsigned int &number);
bool readU16B(unsigned short &number);
bool readU32B(unsigned int &number);
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,66 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#ifndef TAGLIB_MODFILEPRIVATE_H
#define TAGLIB_MODFILEPRIVATE_H
// some helper-macros only used internally by (s3m|it|xm)file.cpp
#define READ_ASSERT(cond) \
if (!(cond)) { \
setValid(false); \
return; \
}
#define READ(setter, type, read) \
{ \
type number; \
READ_ASSERT(read(number)); \
setter(number); \
}
#define READ_BYTE(setter) READ(setter, unsigned char, readByte)
#define READ_U16L(setter) READ(setter, unsigned short, readU16L)
#define READ_U32L(setter) READ(setter, unsigned int, readU32L)
#define READ_U16B(setter) READ(setter, unsigned short, readU16B)
#define READ_U32B(setter) READ(setter, unsigned int, readU32B)
#define READ_STRING(setter, size) \
{ \
String s; \
READ_ASSERT(readString(s, size)); \
setter(s); \
}
#define READ_AS(type, name, read) \
type name = 0; \
READ_ASSERT(read(name));
#define READ_BYTE_AS(name) READ_AS(unsigned char, name, readByte)
#define READ_U16L_AS(name) READ_AS(unsigned short, name, readU16L)
#define READ_U32L_AS(name) READ_AS(unsigned int, name, readU32L)
#define READ_U16B_AS(name) READ_AS(unsigned short, name, readU16B)
#define READ_U32B_AS(name) READ_AS(unsigned int, name, readU32B)
#define READ_STRING_AS(name, size) \
String name; \
READ_ASSERT(readString(name, size));
#endif

View File

@@ -1,94 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "modproperties.h"
using namespace Strawberry_TagLib::TagLib;
using namespace Mod;
class Mod::AudioProperties::AudioPropertiesPrivate {
public:
explicit AudioPropertiesPrivate() : channels(0), instrumentCount(0), lengthInPatterns(0) {}
int channels;
unsigned int instrumentCount;
unsigned char lengthInPatterns;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
Mod::AudioProperties::AudioProperties(AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
}
Mod::AudioProperties::~AudioProperties() {
delete d;
}
int Mod::AudioProperties::lengthInSeconds() const {
return 0;
}
int Mod::AudioProperties::lengthInMilliseconds() const {
return 0;
}
int Mod::AudioProperties::bitrate() const {
return 0;
}
int Mod::AudioProperties::sampleRate() const {
return 0;
}
int Mod::AudioProperties::channels() const {
return d->channels;
}
unsigned int Mod::AudioProperties::instrumentCount() const {
return d->instrumentCount;
}
unsigned char Mod::AudioProperties::lengthInPatterns() const {
return d->lengthInPatterns;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void Mod::AudioProperties::setChannels(int channels) {
d->channels = channels;
}
void Mod::AudioProperties::setInstrumentCount(unsigned int instrumentCount) {
d->instrumentCount = instrumentCount;
}
void Mod::AudioProperties::setLengthInPatterns(unsigned char lengthInPatterns) {
d->lengthInPatterns = lengthInPatterns;
}

View File

@@ -1,66 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_MODPROPERTIES_H
#define TAGLIB_MODPROPERTIES_H
#include "taglib.h"
#include "audioproperties.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
friend class File;
public:
explicit AudioProperties(AudioProperties::ReadStyle propertiesStyle);
~AudioProperties() override;
int lengthInSeconds() const override;
int lengthInMilliseconds() const override;
int bitrate() const override;
int sampleRate() const override;
int channels() const override;
unsigned int instrumentCount() const;
unsigned char lengthInPatterns() const;
private:
void setChannels(int channels);
void setInstrumentCount(unsigned int instrumentCount);
void setLengthInPatterns(unsigned char lengthInPatterns);
class AudioPropertiesPrivate;
AudioPropertiesPrivate *d;
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,162 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "modtag.h"
#include "tstringlist.h"
#include "tpropertymap.h"
#include "tpicturemap.h"
using namespace Strawberry_TagLib::TagLib;
using namespace Mod;
class Mod::Tag::TagPrivate {
public:
explicit TagPrivate() {}
String title;
String comment;
String trackerName;
};
Mod::Tag::Tag() : d(new TagPrivate()) {}
Mod::Tag::~Tag() {
delete d;
}
String Mod::Tag::title() const {
return d->title;
}
String Mod::Tag::artist() const {
return String();
}
String Mod::Tag::album() const {
return String();
}
String Mod::Tag::comment() const {
return d->comment;
}
String Mod::Tag::genre() const {
return String();
}
unsigned int Mod::Tag::year() const {
return 0;
}
unsigned int Mod::Tag::track() const {
return 0;
}
Strawberry_TagLib::TagLib::PictureMap Mod::Tag::pictures() const {
return PictureMap();
}
String Mod::Tag::trackerName() const {
return d->trackerName;
}
void Mod::Tag::setTitle(const String &title) {
d->title = title;
}
void Mod::Tag::setArtist(const String &) {
}
void Mod::Tag::setAlbum(const String &) {
}
void Mod::Tag::setComment(const String &comment) {
d->comment = comment;
}
void Mod::Tag::setGenre(const String &) {
}
void Mod::Tag::setYear(unsigned int) {
}
void Mod::Tag::setTrack(unsigned int) {
}
void Mod::Tag::setPictures(const PictureMap&) {}
void Mod::Tag::setTrackerName(const String &trackerName) {
d->trackerName = trackerName;
}
PropertyMap Mod::Tag::properties() const {
PropertyMap properties;
properties["TITLE"] = d->title;
properties["COMMENT"] = d->comment;
if (!(d->trackerName.isEmpty()))
properties["TRACKERNAME"] = d->trackerName;
return properties;
}
PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) {
PropertyMap properties(origProps);
properties.removeEmpty();
StringList oneValueSet;
if (properties.contains("TITLE")) {
d->title = properties["TITLE"].front();
oneValueSet.append("TITLE");
}
else
d->title.clear();
if (properties.contains("COMMENT")) {
d->comment = properties["COMMENT"].front();
oneValueSet.append("COMMENT");
}
else
d->comment.clear();
if (properties.contains("TRACKERNAME")) {
d->trackerName = properties["TRACKERNAME"].front();
oneValueSet.append("TRACKERNAME");
}
else
d->trackerName.clear();
// for each tag that has been set above, remove the first entry in the corresponding
// value list. The others will be returned as unsupported by this format.
for (StringList::ConstIterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) {
if (properties[*it].size() == 1)
properties.erase(*it);
else
properties[*it].erase(properties[*it].begin());
}
return properties;
}

View File

@@ -1,186 +0,0 @@
/***************************************************************************
copyright : (C) 2011 by Mathias Panzenböck
email : grosser.meister.morti@gmx.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_MODTAG_H
#define TAGLIB_MODTAG_H
#include "tag.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace Mod {
/*!
* Tags for module files (Mod, S3M, IT, XM).
*
* Note that only the \a title is supported as such by most module file formats.
* Except for XM files the \a trackerName is derived from the file format or the flavour of the file format.
* For XM files it is stored in the file.
*
* The \a comment tag is not strictly supported by module files,
* but it is common practice to abuse instrument/sample/pattern names as multiline comments.
* TagLib does so as well.
*
*/
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
public:
explicit Tag();
~Tag() override;
/*!
* Returns the track name; if no track name is present in the tag String::null will be returned.
*/
String title() const override;
/*!
* Not supported by module files. Therefore always returns String::null.
*/
String artist() const override;
/*!
* Not supported by module files. Therefore always returns String::null.
*/
String album() const override;
/*!
* Returns the track comment derived from the instrument/sample/pattern
* names; if no comment is present in the tag String::null will be returned.
*/
String comment() const override;
/*!
* Not supported by module files. Therefore always returns String::null.
*/
String genre() const override;
/*!
* Not supported by module files. Therefore always returns 0.
*/
unsigned int year() const override;
/*!
* Not supported by module files. Therefore always returns 0.
*/
unsigned int track() const override;
PictureMap pictures() const override;
/*!
* Returns the name of the tracker used to create/edit the module file.
* Only XM files store this tag to the file as such, for other formats
* (Mod, S3M, IT) this is derived from the file type or the flavour of the file type.
* Therefore only XM files might have an empty (String::null) tracker name.
*/
String trackerName() const;
/*!
* Sets the title to \a title.
* If \a title is String::null then this value will be cleared.
*
* The length limits per file type are (1 character = 1 byte):
* Mod 20 characters, S3M 27 characters, IT 25 characters and XM 20 characters.
*/
void setTitle(const String &title) override;
/*!
* Not supported by module files and therefore ignored.
*/
void setArtist(const String &artist) override;
/*!
* Not supported by module files and therefore ignored.
*/
void setAlbum(const String &album) override;
/*!
* Sets the comment to \a comment.
* If \a comment is String::null then this value will be cleared.
*
* Note that module file formats don't actually support a comment tag.
* Instead the names of instruments/patterns/samples are abused as a multiline comment.
* Because of this the number of lines in a module file is fixed to the number of instruments/patterns/samples.
*
* Also note that the instrument/pattern/sample name length is limited an thus the line length in comments are limited.
* Too big comments will be truncated.
*
* The line length limits per file type are (1 character = 1 byte):
* Mod 22 characters, S3M 27 characters, IT 25 characters and XM 22 characters.
*/
void setComment(const String &comment) override;
/*!
* Not supported by module files and therefore ignored.
*/
void setGenre(const String &genre) override;
/*!
* Not supported by module files and therefore ignored.
*/
void setYear(unsigned int year) override;
/*!
* Not supported by module files and therefore ignored.
*/
void setTrack(unsigned int track) override;
void setPictures(const PictureMap &l) override;
/*!
* Sets the tracker name to \a trackerName.
* If \a trackerName is String::null then this value will be cleared.
*
* Note that only XM files support this tag.
* Setting the tracker name for other module file formats will be ignored.
*
* The length of this tag is limited to 20 characters (1 character = 1 byte).
*/
void setTrackerName(const String &trackerName);
/*!
* Implements the unified property interface -- export function.
* Since the module tag is very limited, the exported map is as well.
*/
PropertyMap properties() const override;
/*!
* Implements the unified property interface -- import function.
* Because of the limitations of the module file tag, any tags besides COMMENT, TITLE and, if it is an XM file, TRACKERNAME, will be returned.
* Additionally, if the map contains tags with multiple values, all but the first will be contained in the returned map of unsupported properties.
*/
PropertyMap setProperties(const PropertyMap &) override;
private:
Tag(const Tag&);
Tag &operator=(const Tag&);
class TagPrivate;
TagPrivate *d;
};
} // namespace Mod
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,181 +0,0 @@
/**************************************************************************
copyright : (C) 2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <climits>
#include "tdebug.h"
#include "tstring.h"
#include "mp4atom.h"
using namespace Strawberry_TagLib::TagLib;
const char *MP4::Atom::containers[11] = { "moov", "udta", "mdia", "meta", "ilst", "stbl", "minf", "moof", "traf", "trak", "stsd" };
MP4::Atom::Atom(File *file) {
children.setAutoDelete(true);
offset = file->tell();
ByteVector header = file->readBlock(8);
if (header.size() != 8) {
// The atom header must be 8 bytes long, otherwise there is either
// trailing garbage or the file is truncated
debug("MP4: Couldn't read 8 bytes of data for atom header");
length = 0;
file->seek(0, File::End);
return;
}
length = header.toUInt32BE(0);
if (length == 0) {
// The last atom which extends to the end of the file.
length = file->length() - offset;
}
else if (length == 1) {
// The atom has a 64-bit length.
length = file->readBlock(8).toInt64BE(0);
}
if (length < 8) {
debug("MP4: Invalid atom size");
length = 0;
file->seek(0, File::End);
return;
}
name = header.mid(4, 4);
for (int i = 0; i < numContainers; i++) {
if (name == containers[i]) {
if (name == "meta") {
file->seek(4, File::Current);
}
else if (name == "stsd") {
file->seek(8, File::Current);
}
while (file->tell() < offset + length) {
MP4::Atom *child = new MP4::Atom(file);
children.append(child);
if (child->length == 0)
return;
}
return;
}
}
file->seek(offset + length);
}
MP4::Atom::~Atom() {}
MP4::Atom *MP4::Atom::find(const char *name1, const char *name2, const char *name3, const char *name4) {
if (!name1) {
return this;
}
for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) {
if ((*it)->name == name1) {
return (*it)->find(name2, name3, name4);
}
}
return nullptr;
}
MP4::AtomList MP4::Atom::findall(const char *_name, bool recursive) {
MP4::AtomList result;
for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) {
if ((*it)->name == _name) {
result.append(*it);
}
if (recursive) {
result.append((*it)->findall(_name, recursive));
}
}
return result;
}
bool MP4::Atom::path(MP4::AtomList &path, const char *name1, const char *name2, const char *name3) {
path.append(this);
if (!name1) {
return true;
}
for (AtomList::ConstIterator it = children.begin(); it != children.end(); ++it) {
if ((*it)->name == name1) {
return (*it)->path(path, name2, name3);
}
}
return false;
}
MP4::Atoms::Atoms(File *file) {
atoms.setAutoDelete(true);
file->seek(0, File::End);
long long end = file->tell();
file->seek(0);
while (file->tell() + 8 <= end) {
MP4::Atom *atom = new MP4::Atom(file);
atoms.append(atom);
if (atom->length == 0)
break;
}
}
MP4::Atoms::~Atoms() {}
MP4::Atom *MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const char *name4) {
for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) {
if ((*it)->name == name1) {
return (*it)->find(name2, name3, name4);
}
}
return nullptr;
}
MP4::AtomList MP4::Atoms::path(const char *name1, const char *name2, const char *name3, const char *name4) {
MP4::AtomList path;
for (AtomList::ConstIterator it = atoms.begin(); it != atoms.end(); ++it) {
if ((*it)->name == name1) {
if (!(*it)->path(path, name2, name3, name4)) {
path.clear();
}
return path;
}
}
return path;
}

View File

@@ -1,111 +0,0 @@
/**************************************************************************
copyright : (C) 2007,2011 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
// This file is not part of the public API!
#ifndef DO_NOT_DOCUMENT
# ifndef TAGLIB_MP4ATOM_H
# define TAGLIB_MP4ATOM_H
# include "tfile.h"
# include "tlist.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace MP4 {
class Atom;
typedef Strawberry_TagLib::TagLib::List<Atom *> AtomList;
enum AtomDataType {
TypeImplicit = 0, // for use with tags for which no type needs to be indicated because only one type is allowed
TypeUTF8 = 1, // without any count or null terminator
TypeUTF16 = 2, // also known as UTF-16BE
TypeSJIS = 3, // deprecated unless it is needed for special Japanese characters
TypeHTML = 6, // the HTML file header specifies which HTML version
TypeXML = 7, // the XML header must identify the DTD or schemas
TypeUUID = 8, // also known as GUID; stored as 16 bytes in binary (valid as an ID)
TypeISRC = 9, // stored as UTF-8 text (valid as an ID)
TypeMI3P = 10, // stored as UTF-8 text (valid as an ID)
TypeGIF = 12, // (deprecated) a GIF image
TypeJPEG = 13, // a JPEG image
TypePNG = 14, // a PNG image
TypeURL = 15, // absolute, in UTF-8 characters
TypeDuration = 16, // in milliseconds, 32-bit integer
TypeDateTime = 17, // in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits
TypeGenred = 18, // a list of enumerated values
TypeInteger = 21, // a signed big-endian integer with length one of { 1,2,3,4,8 } bytes
TypeRIAAPA = 24, // RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit integer
TypeUPC = 25, // Universal Product Code, in text UTF-8 format (valid as an ID)
TypeBMP = 27, // Windows bitmap image
TypeUndefined = 255 // undefined
};
struct AtomData {
explicit AtomData(AtomDataType _type, ByteVector _data) : type(_type), locale(0), data(_data) {}
AtomDataType type;
int locale;
ByteVector data;
};
typedef Strawberry_TagLib::TagLib::List<AtomData> AtomDataList;
class Atom {
public:
explicit Atom(File *file);
~Atom();
Atom *find(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr);
bool path(AtomList &path, const char *name1, const char *name2 = nullptr, const char *name3 = nullptr);
AtomList findall(const char *name, bool recursive = false);
long long offset;
long long length;
Strawberry_TagLib::TagLib::ByteVector name;
AtomList children;
private:
static const int numContainers = 11;
static const char *containers[11];
};
//! Root-level atoms
class Atoms {
public:
explicit Atoms(File *file);
~Atoms();
Atom *find(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr);
AtomList path(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr);
AtomList atoms;
};
} // namespace MP4
} // namespace TagLib
} // namespace Strawberry_TagLib
# endif
#endif

View File

@@ -1,85 +0,0 @@
/**************************************************************************
copyright : (C) 2009 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <memory>
#include "taglib.h"
#include "tdebug.h"
#include "mp4coverart.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
struct CoverArtData {
MP4::CoverArt::Format format;
ByteVector data;
};
} // namespace
class MP4::CoverArt::CoverArtPrivate {
public:
explicit CoverArtPrivate(Format f, const ByteVector &v) : data(new CoverArtData()) {
data->format = f;
data->data = v;
}
std::shared_ptr<CoverArtData> data;
};
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
MP4::CoverArt::CoverArt(Format format, const ByteVector &data) : d(new CoverArtPrivate(format, data)) {}
MP4::CoverArt::CoverArt(const CoverArt &item) : d(new CoverArtPrivate(*item.d)) {}
MP4::CoverArt &
MP4::CoverArt::operator=(const CoverArt &item) {
CoverArt(item).swap(*this);
return *this;
}
void MP4::CoverArt::swap(CoverArt &item) {
using std::swap;
swap(d, item.d);
}
MP4::CoverArt::~CoverArt() {
delete d;
}
MP4::CoverArt::Format
MP4::CoverArt::format() const {
return d->data->format;
}
ByteVector
MP4::CoverArt::data() const {
return d->data->data;
}

View File

@@ -1,83 +0,0 @@
/**************************************************************************
copyright : (C) 2009 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_MP4COVERART_H
#define TAGLIB_MP4COVERART_H
#include "tlist.h"
#include "tbytevector.h"
#include "taglib_export.h"
#include "mp4atom.h"
namespace Strawberry_TagLib {
namespace TagLib {
namespace MP4 {
class TAGLIB_EXPORT CoverArt {
public:
/*!
* This describes the image type.
*/
enum Format {
JPEG = TypeJPEG,
PNG = TypePNG,
BMP = TypeBMP,
GIF = TypeGIF,
Unknown = TypeImplicit,
};
explicit CoverArt(Format format, const ByteVector &data);
~CoverArt();
CoverArt(const CoverArt &item);
/*!
* Copies the contents of \a item into this CoverArt.
*/
CoverArt &operator=(const CoverArt &item);
/*!
* Exchanges the content of the CoverArt by the content of \a item.
*/
void swap(CoverArt &item);
//! Format of the image
Format format() const;
//! The image data
ByteVector data() const;
private:
class CoverArtPrivate;
CoverArtPrivate *d;
};
typedef List<CoverArt> CoverArtList;
} // namespace MP4
} // namespace TagLib
} // namespace Strawberry_TagLib
#endif

View File

@@ -1,156 +0,0 @@
/**************************************************************************
copyright : (C) 2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include "tdebug.h"
#include "tstring.h"
#include "tpropertymap.h"
#include "tagutils.h"
#include "mp4atom.h"
#include "mp4tag.h"
#include "mp4file.h"
using namespace Strawberry_TagLib::TagLib;
namespace {
bool checkValid(const MP4::AtomList &list) {
for (MP4::AtomList::ConstIterator it = list.begin(); it != list.end(); ++it) {
if ((*it)->length == 0)
return false;
if (!checkValid((*it)->children))
return false;
}
return true;
}
} // namespace
class MP4::File::FilePrivate {
public:
explicit FilePrivate() : tag(nullptr), atoms(nullptr), properties(nullptr) {}
~FilePrivate() {
delete atoms;
delete tag;
delete properties;
}
MP4::Tag *tag;
MP4::Atoms *atoms;
MP4::AudioProperties *properties;
};
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
bool MP4::File::isSupported(IOStream *stream) {
// An MP4 file has to have an "ftyp" box first.
const ByteVector id = Utils::readHeader(stream, 8, false);
return id.containsAt("ftyp", 4);
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////
MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
if (isOpen())
read(readProperties);
}
MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
if (isOpen())
read(readProperties);
}
MP4::File::~File() {
delete d;
}
MP4::Tag *
MP4::File::tag() const {
return d->tag;
}
MP4::AudioProperties *
MP4::File::audioProperties() const {
return d->properties;
}
void MP4::File::read(bool readProperties) {
if (!isValid())
return;
d->atoms = new Atoms(this);
if (!checkValid(d->atoms->atoms)) {
setValid(false);
return;
}
// must have a moov atom, otherwise consider it invalid
if (!d->atoms->find("moov")) {
setValid(false);
return;
}
d->tag = new Tag(this, d->atoms);
if (readProperties) {
d->properties = new AudioProperties(this, d->atoms);
}
}
bool MP4::File::save() {
if (readOnly()) {
debug("MP4::File::save() -- File is read only.");
return false;
}
if (!isValid()) {
debug("MP4::File::save() -- Trying to save invalid file.");
return false;
}
return d->tag->save();
}
bool MP4::File::hasMP4Tag() const {
return (d->atoms->find("moov", "udta", "meta", "ilst") != nullptr);
}

Some files were not shown because too many files have changed in this diff Show More