1 /* 2 Vimpc 3 Copyright (C) 2010 - 2013 Nathan Sweetman 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 clientstate.hpp - current state of the client/server 19 */ 20 21 #ifndef __MPC__CLIENTSTATE 22 #define __MPC__CLIENTSTATE 23 24 #include <mpd/client.h> 25 26 #include "compiler.hpp" 27 #include "output.hpp" 28 #include "screen.hpp" 29 #include "buffers.hpp" 30 #include "buffer/library.hpp" 31 #include "buffer/list.hpp" 32 #include "window/debug.hpp" 33 34 namespace Main 35 { 36 class Settings; 37 class Vimpc; 38 } 39 40 namespace Ui 41 { 42 class Screen; 43 } 44 45 // \todo cache all the values that we can 46 namespace Mpc 47 { 48 class ClientState 49 { 50 public: 51 ClientState(Main::Vimpc * vimpc, Main::Settings & settings, Ui::Screen & screen); 52 ~ClientState(); 53 54 private: 55 ClientState(Client & client); 56 ClientState & operator=(ClientState & client); 57 58 public: 59 // Mpd Connections 60 std::string Hostname(); 61 uint16_t Port(); 62 bool Connected() const; 63 bool IsSocketFile() const; 64 65 public: 66 // Toggle settings 67 bool Random() const; 68 bool Single() const; 69 bool Consume() const; 70 bool Repeat() const; 71 int32_t Crossfade() const; 72 int32_t Volume() const; 73 bool Mute() const; 74 bool IsUpdating() const; 75 76 public: 77 // Mpd Status 78 std::string CurrentState() const ; 79 std::string GetCurrentSongURI() const; 80 81 uint32_t TotalNumberOfSongs(); 82 int32_t GetCurrentSongPos(); 83 84 85 public: 86 long TimeSinceUpdate(); 87 bool IsIdle(); 88 89 public: 90 void DisplaySongInformation(); 91 92 private: 93 Main::Vimpc * vimpc_; 94 Main::Settings & settings_; 95 Ui::Screen & screen_; 96 97 bool connected_; 98 std::string hostname_; 99 uint16_t port_; 100 long timeSinceUpdate_; 101 long timeSinceSong_; 102 103 uint32_t volume_; 104 bool mute_; 105 bool updating_; 106 bool random_; 107 bool repeat_; 108 bool single_; 109 bool consume_; 110 bool crossfade_; 111 bool running_; 112 bool newSong_; 113 bool scrollingStatus_; 114 uint32_t crossfadeTime_; 115 uint32_t elapsed_; 116 uint32_t titlePos_; 117 uint32_t waitTime_; 118 119 mpd_song * currentSong_; 120 int32_t currentSongId_; 121 uint32_t totalNumberOfSongs_; 122 std::string currentSongURI_; 123 std::string currentState_; 124 std::string lastTitleStr_; 125 std::thread updateThread_; 126 }; 127 } 128 129 #endif 130 /* vim: set sw=3 ts=3: */ 131