diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2014-09-12 13:10:47 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2014-09-12 13:10:47 +0200 |
commit | 68a316258c68fe27c7e9d0003c41593a962aaa3c (patch) | |
tree | 5694e86109f4912badb2e2f96dd2271db54f5774 /src/ncmpcpp.cpp | |
parent | 27dc96bece41bf834c5ba7ac6789d887e436962b (diff) |
status: store status fields seperately
Diffstat (limited to 'src/ncmpcpp.cpp')
-rw-r--r-- | src/ncmpcpp.cpp | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 789a13fa..e3da219b 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -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) { |