Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / PartyModeManager.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include "utils/StdString.h"
23
24 #include <boost/shared_ptr.hpp>
25
26 class CFileItem; typedef boost::shared_ptr<CFileItem> CFileItemPtr;
27 class CFileItemList;
28 namespace PLAYLIST
29 {
30   class CPlayList;
31 }
32
33 typedef enum
34 {
35   PARTYMODECONTEXT_UNKNOWN,
36   PARTYMODECONTEXT_MUSIC,
37   PARTYMODECONTEXT_VIDEO
38 } PartyModeContext;
39
40 class CPartyModeManager
41 {
42 public:
43   CPartyModeManager(void);
44   virtual ~CPartyModeManager(void);
45
46   bool Enable(PartyModeContext context=PARTYMODECONTEXT_MUSIC, const CStdString& strXspPath = "");
47   void Disable();
48   void Play(int iPos);
49   void OnSongChange(bool bUpdatePlayed = false);
50   void AddUserSongs(PLAYLIST::CPlayList& tempList, bool bPlay = false);
51   void AddUserSongs(CFileItemList& tempList, bool bPlay = false);
52   bool IsEnabled(PartyModeContext context=PARTYMODECONTEXT_UNKNOWN) const;
53   int GetSongsPlayed();
54   int GetMatchingSongs();
55   int GetMatchingSongsPicked();
56   int GetMatchingSongsLeft();
57   int GetRelaxedSongs();
58   int GetRandomSongs();
59   PartyModeContext GetType() const;
60
61 private:
62   void Process();
63   bool AddRandomSongs(int iSongs = 0);
64   bool AddInitialSongs(std::vector< std::pair<int,int> > &songIDs);
65   void Add(CFileItemPtr &pItem);
66   bool ReapSongs();
67   bool MovePlaying();
68   void SendUpdateMessage();
69   void OnError(int iError, const CStdString& strLogMessage);
70   void ClearState();
71   void UpdateStats();
72   std::pair<CStdString,CStdString> GetWhereClauseWithHistory() const;
73   void AddToHistory(int type, int songID);
74   void GetRandomSelection(std::vector< std::pair<int,int> > &in, unsigned int number, std::vector< std::pair<int, int> > &out);
75   void Announce();
76
77   // state
78   bool m_bEnabled;
79   bool m_bIsVideo;
80   int m_iLastUserSong;
81   CStdString m_strCurrentFilterMusic;
82   CStdString m_strCurrentFilterVideo;
83   CStdString m_type;
84
85   // statistics
86   int m_iSongsPlayed;
87   int m_iMatchingSongs;
88   int m_iMatchingSongsPicked;
89   int m_iMatchingSongsLeft;
90   int m_iRelaxedSongs;
91   int m_iRandomSongs;
92
93   // history
94   unsigned int m_songsInHistory;
95   std::vector< std::pair<int,int> > m_history;
96 };
97
98 extern CPartyModeManager g_partyModeManager;