[Windows] Remove redundant DirectSound error codes
[xbmc.git] / xbmc / events / MediaLibraryEvent.cpp
blobc079f5d770d38fd67be16b200388704acb2bc4e3
1 /*
2 * Copyright (C) 2015-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "MediaLibraryEvent.h"
11 #include "ServiceBroker.h"
12 #include "guilib/GUIComponent.h"
13 #include "guilib/GUIWindowManager.h"
14 #include "guilib/LocalizeStrings.h"
15 #include "guilib/WindowIDs.h"
16 #include "utils/URIUtils.h"
18 CMediaLibraryEvent::CMediaLibraryEvent(const MediaType& mediaType, const std::string& mediaPath, const CVariant& label, const CVariant& description, EventLevel level /* = EventLevel::Information */)
19 : CUniqueEvent(label, description, level),
20 m_mediaType(mediaType),
21 m_mediaPath(mediaPath)
22 { }
24 CMediaLibraryEvent::CMediaLibraryEvent(const MediaType& mediaType, const std::string& mediaPath, const CVariant& label, const CVariant& description, const std::string& icon, EventLevel level /* = EventLevel::Information */)
25 : CUniqueEvent(label, description, icon, level),
26 m_mediaType(mediaType),
27 m_mediaPath(mediaPath)
28 { }
30 CMediaLibraryEvent::CMediaLibraryEvent(const MediaType& mediaType, const std::string& mediaPath, const CVariant& label, const CVariant& description, const std::string& icon, const CVariant& details, EventLevel level /* = EventLevel::Information */)
31 : CUniqueEvent(label, description, icon, details, level),
32 m_mediaType(mediaType),
33 m_mediaPath(mediaPath)
34 { }
36 CMediaLibraryEvent::CMediaLibraryEvent(const MediaType& mediaType, const std::string& mediaPath, const CVariant& label, const CVariant& description, const std::string& icon, const CVariant& details, const CVariant& executionLabel, EventLevel level /* = EventLevel::Information */)
37 : CUniqueEvent(label, description, icon, details, executionLabel, level),
38 m_mediaType(mediaType),
39 m_mediaPath(mediaPath)
40 { }
42 std::string CMediaLibraryEvent::GetExecutionLabel() const
44 std::string executionLabel = CUniqueEvent::GetExecutionLabel();
45 if (!executionLabel.empty())
46 return executionLabel;
48 return g_localizeStrings.Get(24140);
51 bool CMediaLibraryEvent::Execute() const
53 if (!CanExecute())
54 return false;
56 int windowId = -1;
57 std::string path = m_mediaPath;
58 if (m_mediaType == MediaTypeVideo || m_mediaType == MediaTypeMovie || m_mediaType == MediaTypeVideoCollection ||
59 m_mediaType == MediaTypeTvShow || m_mediaType == MediaTypeSeason || m_mediaType == MediaTypeEpisode ||
60 m_mediaType == MediaTypeMusicVideo)
62 if (path.empty())
64 if (m_mediaType == MediaTypeVideo)
65 path = "sources://video/";
66 else if (m_mediaType == MediaTypeMovie)
67 path = "videodb://movies/titles/";
68 else if (m_mediaType == MediaTypeVideoCollection)
69 path = "videodb://movies/sets/";
70 else if (m_mediaType == MediaTypeMusicVideo)
71 path = "videodb://musicvideos/titles/";
72 else if (m_mediaType == MediaTypeTvShow || m_mediaType == MediaTypeSeason || m_mediaType == MediaTypeEpisode)
73 path = "videodb://tvshows/titles/";
75 else
77 //! @todo remove the filename for now as CGUIMediaWindow::GetDirectory() can't handle it
78 if (m_mediaType == MediaTypeMovie || m_mediaType == MediaTypeMusicVideo || m_mediaType == MediaTypeEpisode)
79 path = URIUtils::GetDirectory(path);
82 windowId = WINDOW_VIDEO_NAV;
84 else if (m_mediaType == MediaTypeMusic || m_mediaType == MediaTypeArtist ||
85 m_mediaType == MediaTypeAlbum || m_mediaType == MediaTypeSong)
87 if (path.empty())
89 if (m_mediaType == MediaTypeMusic)
90 path = "sources://music/";
91 else if (m_mediaType == MediaTypeArtist)
92 path = "musicdb://artists/";
93 else if (m_mediaType == MediaTypeAlbum)
94 path = "musicdb://albums/";
95 else if (m_mediaType == MediaTypeSong)
96 path = "musicdb://songs/";
98 else
100 //! @todo remove the filename for now as CGUIMediaWindow::GetDirectory() can't handle it
101 if (m_mediaType == MediaTypeSong)
102 path = URIUtils::GetDirectory(path);
105 windowId = WINDOW_MUSIC_NAV;
108 if (windowId < 0)
109 return false;
111 std::vector<std::string> params;
112 params.push_back(path);
113 params.emplace_back("return");
114 CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(windowId, params);
115 return true;