Merge pull request #1431 from herrnst/pr-lcd-pvrmodes
[vuplus_xbmc] / xbmc / PartyModeManager.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2012 Team XBMC
4  *      http://www.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
76   // state
77   bool m_bEnabled;
78   bool m_bIsVideo;
79   int m_iLastUserSong;
80   CStdString m_strCurrentFilterMusic;
81   CStdString m_strCurrentFilterVideo;
82   CStdString m_type;
83
84   // statistics
85   int m_iSongsPlayed;
86   int m_iMatchingSongs;
87   int m_iMatchingSongsPicked;
88   int m_iMatchingSongsLeft;
89   int m_iRelaxedSongs;
90   int m_iRandomSongs;
91
92   // history
93   unsigned int m_songsInHistory;
94   std::vector< std::pair<int,int> > m_history;
95 };
96
97 extern CPartyModeManager g_partyModeManager;