status: store status fields seperately

This commit is contained in:
Andrzej Rybczak
2014-09-12 13:10:47 +02:00
parent 27dc96bece
commit 68a316258c
9 changed files with 274 additions and 203 deletions

View File

@@ -22,8 +22,6 @@
#include <clocale>
#include <csignal>
#include <cstring>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/locale.hpp>
@@ -160,49 +158,18 @@ int main(int argc, char **argv)
{
if (!Mpd.Connected())
{
// reset local status info
Status::clear();
// clear mpd callback
wFooter->clearFDCallbacksList();
try
{
Mpd.Connect();
if (Mpd.Version() < 16)
{
Mpd.Disconnect();
throw MPD::ClientError(MPD_ERROR_STATE, "MPD < 0.16.0 is not supported", false);
Mpd.Disconnect();
throw MPD::ClientError(MPD_ERROR_STATE, "MPD < 0.16.0 is not supported", false);
}
wFooter->addFDCallback(Mpd.GetFD(), Statusbar::Helpers::mpd);
Status::clear(); // reset local status info
Status::update(-1); // we need info about new connection
if (Config.jump_to_now_playing_song_at_start)
{
int curr_pos = Status::get().currentSongPosition();
if (curr_pos >= 0)
myPlaylist->main().highlight(curr_pos);
}
// Set TCP_NODELAY on the tcp socket as we are using write-write-read pattern
// a lot (idle - write, noidle - write, then read the result of noidle), which
// kills the performance.
int flag = 1;
setsockopt(Mpd.GetFD(), IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
// go to startup screen
if (Config.startup_screen_type != myScreen->type())
toScreen(Config.startup_screen_type)->switchTo();
myScreen->refresh();
myBrowser->fetchSupportedExtensions();
# ifdef ENABLE_OUTPUTS
myOutputs->FetchList();
# endif // ENABLE_OUTPUTS
# ifdef ENABLE_VISUALIZER
myVisualizer->ResetFD();
if (myScreen == myVisualizer)
myVisualizer->SetFD();
myVisualizer->FindOutputID();
# endif // ENABLE_VISUALIZER
Statusbar::printf("Connected to %1%", Mpd.GetHostname());
}
catch (MPD::ClientError &e)
{