diff --git a/src/Makefile.am b/src/Makefile.am index e09514d6..5507f6e3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,13 +40,14 @@ lms_SOURCES = \ $(srcdir)/transcode/InputMediaFile.cpp \ $(srcdir)/ui/LmsApplication.cpp \ $(srcdir)/ui/auth/LmsAuth.cpp \ - $(srcdir)/ui/audio/Audio.cpp \ - $(srcdir)/ui/audio/AudioMediaPlayer.cpp \ - $(srcdir)/ui/audio/FilterChain.cpp \ - $(srcdir)/ui/audio/KeywordSearchFilter.cpp \ - $(srcdir)/ui/audio/PlayQueue.cpp \ - $(srcdir)/ui/audio/TableFilter.cpp \ - $(srcdir)/ui/audio/TrackView.cpp \ + $(srcdir)/ui/audio/desktop/DesktopAudio.cpp \ + $(srcdir)/ui/audio/desktop/AudioMediaPlayer.cpp \ + $(srcdir)/ui/audio/desktop/FilterChain.cpp \ + $(srcdir)/ui/audio/desktop/KeywordSearchFilter.cpp \ + $(srcdir)/ui/audio/desktop/PlayQueue.cpp \ + $(srcdir)/ui/audio/desktop/TableFilter.cpp \ + $(srcdir)/ui/audio/desktop/TrackView.cpp \ + $(srcdir)/ui/audio/mobile/MobileAudio.cpp \ $(srcdir)/ui/common/DirectoryValidator.cpp \ $(srcdir)/ui/common/LineEdit.cpp \ $(srcdir)/ui/common/SessionData.cpp \ diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp index ba7cfc42..052a1908 100644 --- a/src/ui/LmsApplication.cpp +++ b/src/ui/LmsApplication.cpp @@ -17,17 +17,15 @@ * along with LMS. If not, see . */ +#include #include #include -#include #include #include #include #include #include -#include #include -#include #include #include "logger/Logger.hpp" @@ -36,7 +34,8 @@ #include "settings/SettingsFirstConnectionFormView.hpp" #include "auth/LmsAuth.hpp" -#include "audio/Audio.hpp" +#include "audio/desktop/DesktopAudio.hpp" +#include "audio/mobile/MobileAudio.hpp" #include "video/VideoWidget.hpp" #include "common/LineEdit.hpp" @@ -46,6 +45,16 @@ namespace skeletons { extern const char *AuthStrings_xml1; } +namespace { + +bool agentIsMobile() +{ + const Wt::WEnvironment& env = Wt::WApplication::instance()->environment(); + + return (env.agentIsIEMobile() || env.agentIsMobileWebKit()); +} +} + namespace UserInterface { @@ -150,7 +159,15 @@ LmsApplication::handleAuthEvent(void) Wt::WMenu *leftMenu = new Wt::WMenu(contentsStack); navigation->addMenu(leftMenu); - Audio *audio = new Audio(_sessionData); + const Wt::WEnvironment& env = Wt::WApplication::instance()->environment(); + + Audio *audio; + + if (agentIsMobile()) + audio = new Desktop::Audio(_sessionData); + else + audio = new Mobile::Audio(); + VideoWidget *videoWidget = new VideoWidget(_sessionData); leftMenu->addItem("Audio", audio); diff --git a/src/ui/audio/Audio.hpp b/src/ui/audio/Audio.hpp index c09fff4b..422b0cca 100644 --- a/src/ui/audio/Audio.hpp +++ b/src/ui/audio/Audio.hpp @@ -17,69 +17,25 @@ * along with LMS. If not, see . */ -#ifndef AUDIO_HPP -#define AUDIO_HPP +#ifndef UI_AUDIO_HPP +#define UI_AUDIO_HPP #include - -#include #include -#include "common/SessionData.hpp" - -#include "AudioMediaPlayer.hpp" -#include "TrackView.hpp" -#include "PlayQueue.hpp" - -#include "FilterChain.hpp" - namespace UserInterface { class Audio : public Wt::WContainerWidget { - public: - Audio(SessionData& sessionData, Wt::WContainerWidget* parent = 0); + Audio(Wt::WContainerWidget *parent) : Wt::WContainerWidget(parent) {} + virtual ~Audio() {} - void search(const std::string& searchText); + virtual void search(std::string text) = 0; - private: - - void playlistSaveFromPlayqueue(std::string name); - void playlistLoadToPlayqueue(std::string name); - void playlistShowSaveNewDialog(); - void playlistShowSaveDialog(std::string name); - void playlistShowDeleteDialog(std::string name); - void playlistRefreshMenus(); - - void playTrack(boost::filesystem::path p); - - enum PlayQueueAddType - { - PlayQueueAddAllTracks, - PlayQueueAddSelectedTracks, - }; - - void playSelectedTracks(PlayQueueAddType addType); - void addSelectedTracks(); - - void handlePlaylistSelected(Wt::WString name); - - Database::Handler& _db; - - AudioMediaPlayer* _mediaPlayer; - TrackView* _trackView; - PlayQueue* _playQueue; - - FilterChain _filterChain; - - Wt::WPopupMenu* _popupMenuSave; - Wt::WPopupMenu* _popupMenuLoad; - Wt::WPopupMenu* _popupMenuDelete; }; } // namespace UserInterface #endif - diff --git a/src/ui/audio/AudioMediaPlayer.cpp b/src/ui/audio/desktop/AudioMediaPlayer.cpp similarity index 99% rename from src/ui/audio/AudioMediaPlayer.cpp rename to src/ui/audio/desktop/AudioMediaPlayer.cpp index 55f1bcc6..e0ee418d 100644 --- a/src/ui/audio/AudioMediaPlayer.cpp +++ b/src/ui/audio/desktop/AudioMediaPlayer.cpp @@ -29,6 +29,7 @@ #include "AudioMediaPlayer.hpp" namespace UserInterface { +namespace Desktop { Wt::WMediaPlayer::Encoding AudioMediaPlayer::getEncoding() @@ -224,4 +225,5 @@ AudioMediaPlayer::handleVolumeSliderMoved(int value) _mediaPlayer->setVolume( value / 100. ); } +} // namespace Desktop } // namespace UserInterface diff --git a/src/ui/audio/AudioMediaPlayer.hpp b/src/ui/audio/desktop/AudioMediaPlayer.hpp similarity index 98% rename from src/ui/audio/AudioMediaPlayer.hpp rename to src/ui/audio/desktop/AudioMediaPlayer.hpp index fa7fa369..2f6a00fd 100644 --- a/src/ui/audio/AudioMediaPlayer.hpp +++ b/src/ui/audio/desktop/AudioMediaPlayer.hpp @@ -33,6 +33,7 @@ #include "resource/AvConvTranscodeStreamResource.hpp" namespace UserInterface { +namespace Desktop { class AudioMediaPlayer : public Wt::WContainerWidget { @@ -88,6 +89,7 @@ class AudioMediaPlayer : public Wt::WContainerWidget }; +} // namespace Desktop } // namespace UserInterface #endif diff --git a/src/ui/audio/Audio.cpp b/src/ui/audio/desktop/DesktopAudio.cpp similarity index 99% rename from src/ui/audio/Audio.cpp rename to src/ui/audio/desktop/DesktopAudio.cpp index 95be6280..b1e7d103 100644 --- a/src/ui/audio/Audio.cpp +++ b/src/ui/audio/desktop/DesktopAudio.cpp @@ -36,7 +36,7 @@ #include "TableFilter.hpp" #include "KeywordSearchFilter.hpp" -#include "Audio.hpp" +#include "DesktopAudio.hpp" namespace { @@ -49,9 +49,10 @@ void WPopupMenuClear(Wt::WPopupMenu* menu) } namespace UserInterface { +namespace Desktop { Audio::Audio(SessionData& sessionData, Wt::WContainerWidget* parent) -: Wt::WContainerWidget(parent), +: UserInterface::Audio(parent), _db(sessionData.getDatabaseHandler()), _mediaPlayer(nullptr), _trackView(nullptr), @@ -418,7 +419,7 @@ Audio::playlistRefreshMenus() } void -Audio::search(const std::string& searchText) +Audio::search(std::string searchText) { _filterChain.searchKeyword(searchText); } @@ -525,6 +526,6 @@ Audio::playTrack(boost::filesystem::path p) } } - +} // namespace Desktop } // namespace UserInterface diff --git a/src/ui/audio/desktop/DesktopAudio.hpp b/src/ui/audio/desktop/DesktopAudio.hpp new file mode 100644 index 00000000..19b70f5f --- /dev/null +++ b/src/ui/audio/desktop/DesktopAudio.hpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2013 Emeric Poupon + * + * This file is part of LMS. + * + * LMS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LMS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LMS. If not, see . + */ + +#ifndef UI_AUDIO_DESKTOP_HPP +#define UI_AUDIO_DESKTOP_HPP + +#include + +#include + +#include "common/SessionData.hpp" + +#include "AudioMediaPlayer.hpp" +#include "TrackView.hpp" +#include "PlayQueue.hpp" + +#include "FilterChain.hpp" + +#include "audio/Audio.hpp" + +namespace UserInterface { +namespace Desktop { + +class Audio : public UserInterface::Audio +{ + + public: + + Audio(SessionData& sessionData, Wt::WContainerWidget* parent = 0); + + void search(std::string searchText); + + private: + + void playlistSaveFromPlayqueue(std::string name); + void playlistLoadToPlayqueue(std::string name); + void playlistShowSaveNewDialog(); + void playlistShowSaveDialog(std::string name); + void playlistShowDeleteDialog(std::string name); + void playlistRefreshMenus(); + + void playTrack(boost::filesystem::path p); + + enum PlayQueueAddType + { + PlayQueueAddAllTracks, + PlayQueueAddSelectedTracks, + }; + + void playSelectedTracks(PlayQueueAddType addType); + void addSelectedTracks(); + + void handlePlaylistSelected(Wt::WString name); + + Database::Handler& _db; + + AudioMediaPlayer* _mediaPlayer; + TrackView* _trackView; + PlayQueue* _playQueue; + + FilterChain _filterChain; + + Wt::WPopupMenu* _popupMenuSave; + Wt::WPopupMenu* _popupMenuLoad; + Wt::WPopupMenu* _popupMenuDelete; +}; + +} // namespace Desktop +} // namespace UserInterface + +#endif + diff --git a/src/ui/audio/Filter.hpp b/src/ui/audio/desktop/Filter.hpp similarity index 97% rename from src/ui/audio/Filter.hpp rename to src/ui/audio/desktop/Filter.hpp index 09c19327..194f2867 100644 --- a/src/ui/audio/Filter.hpp +++ b/src/ui/audio/desktop/Filter.hpp @@ -25,6 +25,7 @@ #include "database/Types.hpp" namespace UserInterface { +namespace Desktop { class Filter { @@ -58,6 +59,7 @@ class Filter Wt::Signal _update; }; +} // namespace Dekstop } // namespace UserInterface #endif diff --git a/src/ui/audio/FilterChain.cpp b/src/ui/audio/desktop/FilterChain.cpp similarity index 97% rename from src/ui/audio/FilterChain.cpp rename to src/ui/audio/desktop/FilterChain.cpp index b3b0ab96..d94ddea5 100644 --- a/src/ui/audio/FilterChain.cpp +++ b/src/ui/audio/desktop/FilterChain.cpp @@ -20,6 +20,7 @@ #include "FilterChain.hpp" namespace UserInterface { +namespace Desktop { FilterChain::FilterChain() @@ -69,5 +70,6 @@ FilterChain::updateFilters(std::size_t startIdx) _refreshingFilters = false; } +} // namespace Desktop } // namespace UserInterface diff --git a/src/ui/audio/FilterChain.hpp b/src/ui/audio/desktop/FilterChain.hpp similarity index 96% rename from src/ui/audio/FilterChain.hpp rename to src/ui/audio/desktop/FilterChain.hpp index 8ffd157a..c9625941 100644 --- a/src/ui/audio/FilterChain.hpp +++ b/src/ui/audio/desktop/FilterChain.hpp @@ -26,6 +26,7 @@ #include "KeywordSearchFilter.hpp" namespace UserInterface { +namespace Desktop { // FilterChain class FilterChain @@ -52,6 +53,7 @@ class FilterChain bool _refreshingFilters; }; +} // namespace Desktop } // namespace UserInterface #endif diff --git a/src/ui/audio/KeywordSearchFilter.cpp b/src/ui/audio/desktop/KeywordSearchFilter.cpp similarity index 97% rename from src/ui/audio/KeywordSearchFilter.cpp rename to src/ui/audio/desktop/KeywordSearchFilter.cpp index 8f896939..ab39b9ed 100644 --- a/src/ui/audio/KeywordSearchFilter.cpp +++ b/src/ui/audio/desktop/KeywordSearchFilter.cpp @@ -24,6 +24,7 @@ #include "KeywordSearchFilter.hpp" namespace UserInterface { +namespace Desktop { KeywordSearchFilter::KeywordSearchFilter() { @@ -60,5 +61,6 @@ KeywordSearchFilter::getConstraint(Database::SearchFilter& filter) } } +} // namespace Desktop } // namespace UserInterface diff --git a/src/ui/audio/KeywordSearchFilter.hpp b/src/ui/audio/desktop/KeywordSearchFilter.hpp similarity index 96% rename from src/ui/audio/KeywordSearchFilter.hpp rename to src/ui/audio/desktop/KeywordSearchFilter.hpp index 5ff2df87..acf62b0b 100644 --- a/src/ui/audio/KeywordSearchFilter.hpp +++ b/src/ui/audio/desktop/KeywordSearchFilter.hpp @@ -25,6 +25,7 @@ #include "Filter.hpp" namespace UserInterface { +namespace Desktop { class KeywordSearchFilter : public Filter { @@ -46,6 +47,7 @@ class KeywordSearchFilter : public Filter std::string _lastEmittedText; }; +} // namespace Desktop } // namespace UserInterface #endif diff --git a/src/ui/audio/PlayQueue.cpp b/src/ui/audio/desktop/PlayQueue.cpp similarity index 99% rename from src/ui/audio/PlayQueue.cpp rename to src/ui/audio/desktop/PlayQueue.cpp index b854cc84..62552bee 100644 --- a/src/ui/audio/PlayQueue.cpp +++ b/src/ui/audio/desktop/PlayQueue.cpp @@ -58,6 +58,7 @@ namespace { } namespace UserInterface { +namespace Desktop { enum ColumnId { @@ -610,5 +611,6 @@ PlayQueue::getTracks(std::vector& trackIds) const } } +} // namespace Desktop } // namespace UserInterface diff --git a/src/ui/audio/PlayQueue.hpp b/src/ui/audio/desktop/PlayQueue.hpp similarity index 98% rename from src/ui/audio/PlayQueue.hpp rename to src/ui/audio/desktop/PlayQueue.hpp index 72ef106a..9d150a41 100644 --- a/src/ui/audio/PlayQueue.hpp +++ b/src/ui/audio/desktop/PlayQueue.hpp @@ -28,6 +28,7 @@ #include "resource/CoverResource.hpp" namespace UserInterface { +namespace Desktop { class PlayQueueItemDelegate; class TrackSelector; @@ -86,7 +87,7 @@ class PlayQueue : public Wt::WTableView }; - +} // namespace Desktop } // namespace UserInterface #endif diff --git a/src/ui/audio/TableFilter.cpp b/src/ui/audio/desktop/TableFilter.cpp similarity index 99% rename from src/ui/audio/TableFilter.cpp rename to src/ui/audio/desktop/TableFilter.cpp index 56f0c48b..6b8f1010 100644 --- a/src/ui/audio/TableFilter.cpp +++ b/src/ui/audio/desktop/TableFilter.cpp @@ -28,6 +28,7 @@ #include "TableFilter.hpp" namespace UserInterface { +namespace Desktop { using namespace Database; @@ -253,5 +254,6 @@ TableFilterRelease::getConstraint(SearchFilter& filter) } } +} // namespace Desktop } // namespace UserInterface diff --git a/src/ui/audio/TableFilter.hpp b/src/ui/audio/desktop/TableFilter.hpp similarity index 98% rename from src/ui/audio/TableFilter.hpp rename to src/ui/audio/desktop/TableFilter.hpp index afac6866..d5bc6024 100644 --- a/src/ui/audio/TableFilter.hpp +++ b/src/ui/audio/desktop/TableFilter.hpp @@ -28,6 +28,7 @@ #include "database/DatabaseHandler.hpp" namespace UserInterface { +namespace Desktop { class TableFilterGenre : public Wt::WTableView, public Filter { @@ -111,6 +112,7 @@ class TableFilterRelease : public Wt::WTableView, public Filter }; +} // namespace Desktop } // namespace UserInterface #endif diff --git a/src/ui/audio/TrackView.cpp b/src/ui/audio/desktop/TrackView.cpp similarity index 98% rename from src/ui/audio/TrackView.cpp rename to src/ui/audio/desktop/TrackView.cpp index 75bb62b4..63c611b6 100644 --- a/src/ui/audio/TrackView.cpp +++ b/src/ui/audio/desktop/TrackView.cpp @@ -28,6 +28,7 @@ #include "TrackView.hpp" namespace UserInterface { +namespace Desktop { TrackView::TrackView( Database::Handler& db, Wt::WContainerWidget* parent) : Wt::WTableView( parent ), @@ -169,5 +170,6 @@ TrackView::getTracks(std::vector& trackIds) LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting all tracks done!"; } +} // namespace Desktop } // namespace UserInterface diff --git a/src/ui/audio/TrackView.hpp b/src/ui/audio/desktop/TrackView.hpp similarity index 97% rename from src/ui/audio/TrackView.hpp rename to src/ui/audio/desktop/TrackView.hpp index cc8ae23f..77819bc8 100644 --- a/src/ui/audio/TrackView.hpp +++ b/src/ui/audio/desktop/TrackView.hpp @@ -28,6 +28,7 @@ #include "Filter.hpp" namespace UserInterface { +namespace Desktop { class TrackView : public Wt::WTableView, public Filter { @@ -69,6 +70,7 @@ class TrackView : public Wt::WTableView, public Filter }; +} // namespace Desktop } // namespace UserInterface #endif diff --git a/src/ui/audio/mobile/MobileAudio.cpp b/src/ui/audio/mobile/MobileAudio.cpp new file mode 100644 index 00000000..2431c8d5 --- /dev/null +++ b/src/ui/audio/mobile/MobileAudio.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 Emeric Poupon + * + * This file is part of LMS. + * + * LMS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LMS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LMS. If not, see . + */ + +#include +#include + +#include "MobileAudio.hpp" + +namespace UserInterface { +namespace Mobile { + +Audio::Audio(Wt::WContainerWidget *parent) +: UserInterface::Audio(parent) +{ + new Wt::WText("Mobile version not implemented", this); +} + +} // namespace Mobile +} // namespace UserInterface + diff --git a/src/ui/audio/mobile/MobileAudio.hpp b/src/ui/audio/mobile/MobileAudio.hpp new file mode 100644 index 00000000..a36753fc --- /dev/null +++ b/src/ui/audio/mobile/MobileAudio.hpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 Emeric Poupon + * + * This file is part of LMS. + * + * LMS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LMS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LMS. If not, see . + */ + +#ifndef UI_AUDIO_MOBILE_HPP +#define UI_AUDIO_MOBILE_HPP + +#include + +#include "audio/Audio.hpp" + +namespace UserInterface { +namespace Mobile { + +class Audio : public UserInterface::Audio +{ + public: + Audio(Wt::WContainerWidget *parent = 0); + + void search(std::string text) {}; + +}; + +} // namespace Mobile +} // namespace UserInterface + +#endif