diff options
-rw-r--r-- | src/browser.cpp | 54 | ||||
-rw-r--r-- | src/global.h | 2 | ||||
-rw-r--r-- | src/help.cpp | 2 | ||||
-rw-r--r-- | src/helpers.cpp | 39 | ||||
-rw-r--r-- | src/media_library.cpp | 88 | ||||
-rw-r--r-- | src/mpdpp.cpp | 2 | ||||
-rw-r--r-- | src/mpdpp.h | 2 | ||||
-rw-r--r-- | src/ncmpcpp.cpp | 224 | ||||
-rw-r--r-- | src/outputs.cpp | 6 | ||||
-rw-r--r-- | src/playlist.cpp | 18 | ||||
-rw-r--r-- | src/playlist_editor.cpp | 26 | ||||
-rw-r--r-- | src/search_engine.cpp | 16 | ||||
-rw-r--r-- | src/status.cpp | 64 | ||||
-rw-r--r-- | src/tag_editor.cpp | 34 |
14 files changed, 287 insertions, 290 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 8f7941bf..00f427df 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -117,7 +117,7 @@ void Browser::EnterPressed() { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Play(i); + Mpd.Play(i); found = 1; break; } @@ -126,10 +126,10 @@ void Browser::EnterPressed() break; } Song &s = *item.song; - int id = Mpd->AddSong(s); + int id = Mpd.AddSong(s); if (id >= 0) { - Mpd->PlayID(id); + Mpd.PlayID(id); ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str()); w->BoldOption(w->Choice(), 1); } @@ -138,20 +138,20 @@ void Browser::EnterPressed() case itPlaylist: { SongList list; - Mpd->GetPlaylistContent(locale_to_utf_cpy(item.name), list); - Mpd->StartCommandsList(); + Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list); + Mpd.StartCommandsList(); SongList::const_iterator it = list.begin(); for (; it != list.end(); it++) - if (Mpd->AddSong(**it) < 0) + if (Mpd.AddSong(**it) < 0) break; - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); if (it != list.begin()) { ShowMessage("Loading and playing playlist %s...", item.name.c_str()); Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size()); if (s->GetHash() == list[0]->GetHash()) - Mpd->PlayID(s->GetID()); + Mpd.PlayID(s->GetID()); else ShowMessage("%s", MPD::Message::PartOfSongsAdded); } @@ -189,29 +189,29 @@ void Browser::SpacePressed() ShowMessage("Scanning \"%s\"...", item.name.c_str()); myBrowser->GetLocalDirectory(list, item.name, 1); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (ItemList::const_iterator it = list.begin(); it != list.end(); ++it) { - if (everything_was_added && Mpd->AddSong(*it->song) < 0) + if (everything_was_added && Mpd.AddSong(*it->song) < 0) everything_was_added = 0; delete it->song; } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); } else { SongList list; - Mpd->GetDirectoryRecursive(locale_to_utf_cpy(item.name), list); - Mpd->StartCommandsList(); + Mpd.GetDirectoryRecursive(locale_to_utf_cpy(item.name), list); + Mpd.StartCommandsList(); for (SongList::const_iterator it = list.begin(); it != list.end(); it++) { - if (Mpd->AddSong(**it) < 0) + if (Mpd.AddSong(**it) < 0) { everything_was_added = 0; break; } } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); FreeSongList(list); } @@ -227,24 +227,24 @@ void Browser::SpacePressed() { Playlist::BlockUpdate = 1; long long hash = w->Current().song->GetHash(); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (size_t i = 0; i < myPlaylist->Main()->Size(); i++) { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Delete(i); + Mpd.Delete(i); myPlaylist->Main()->DeleteOption(i); i--; } } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); w->BoldOption(w->Choice(), 0); Playlist::BlockUpdate = 0; } else { Song &s = *item.song; - if (Mpd->AddSong(s) != -1) + if (Mpd.AddSong(s) != -1) { ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str()); w->BoldOption(w->Choice(), 1); @@ -255,13 +255,13 @@ void Browser::SpacePressed() case itPlaylist: { SongList list; - Mpd->GetPlaylistContent(locale_to_utf_cpy(item.name), list); - Mpd->StartCommandsList(); + Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), list); + Mpd.StartCommandsList(); SongList::const_iterator it = list.begin(); for (; it != list.end(); it++) - if (Mpd->AddSong(**it) < 0) + if (Mpd.AddSong(**it) < 0) break; - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); if (it != list.begin()) { @@ -347,7 +347,7 @@ void Browser::GetSelectedSongs(MPD::SongList &v) { case itDirectory: { - Mpd->GetDirectoryRecursive(locale_to_utf_cpy(item.name), v); + Mpd.GetDirectoryRecursive(locale_to_utf_cpy(item.name), v); break; } case itSong: @@ -357,7 +357,7 @@ void Browser::GetSelectedSongs(MPD::SongList &v) } case itPlaylist: { - Mpd->GetPlaylistContent(locale_to_utf_cpy(item.name), v); + Mpd.GetPlaylistContent(locale_to_utf_cpy(item.name), v); break; } } @@ -498,7 +498,7 @@ void Browser::GetDirectory(string dir, string subdir) } ItemList list; - Config.local_browser ? GetLocalDirectory(list) : Mpd->GetDirectory(dir, list); + Config.local_browser ? GetLocalDirectory(list) : Mpd.GetDirectory(dir, list); sort(list.begin(), list.end(), CaseInsensitiveSorting()); for (ItemList::iterator it = list.begin(); it != list.end(); it++) @@ -579,7 +579,7 @@ void Browser::ClearDirectory(const std::string &path) const void Browser::ChangeBrowseMode() { - if (Mpd->GetHostname()[0] != '/') + if (Mpd.GetHostname()[0] != '/') return; Config.local_browser = !Config.local_browser; diff --git a/src/global.h b/src/global.h index 2ecde78d..3e362c27 100644 --- a/src/global.h +++ b/src/global.h @@ -33,8 +33,6 @@ namespace Global extern Window *wHeader; extern Window *wFooter; - extern MPD::Connection *Mpd; - extern size_t MainStartY; extern size_t MainHeight; diff --git a/src/help.cpp b/src/help.cpp index ee292d5a..928797d2 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -224,7 +224,7 @@ void Help::GetKeybindings() # else *w << DisplayKeys(Key.EditTags) << "Rename playlist/directory\n"; # endif // HAVE_TAGLIB_H - if (Mpd->GetHostname()[0] == '/') // are we connected to unix socket? + if (Mpd.GetHostname()[0] == '/') // are we connected to unix socket? *w << DisplayKeys(Key.SwitchTagTypeList)<< "Browse MPD database/local filesystem\n"; *w << DisplayKeys(Key.GoToNowPlaying) << "Locate currently playing song\n"; *w << DisplayKeys(Key.GoToParentDir) << "Go to parent directory\n"; diff --git a/src/helpers.cpp b/src/helpers.cpp index f1f00d1e..d2fe46e5 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -30,15 +30,14 @@ #include "tag_editor.h" using namespace MPD; -using Global::Mpd; using Global::wFooter; using std::string; bool ConnectToMPD() { - if (!Mpd->Connect()) + if (!Mpd.Connect()) { - std::cout << "Cannot connect to mpd: " << Mpd->GetErrorMessage() << std::endl; + std::cout << "Cannot connect to mpd: " << Mpd.GetErrorMessage() << std::endl; return false; } return true; @@ -57,14 +56,14 @@ void ParseArgv(int argc, char **argv) { if (++i >= argc) exit(0); - Mpd->SetHostname(argv[i]); + Mpd.SetHostname(argv[i]); continue; } if (strcmp(argv[i], "-p") == 0) { if (++i >= argc) exit(0); - Mpd->SetPort(atoi(argv[i])); + Mpd.SetPort(atoi(argv[i])); continue; } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) @@ -107,25 +106,25 @@ void ParseArgv(int argc, char **argv) if (strcmp(argv[i], "play") == 0) { - Mpd->Play(); + Mpd.Play(); quit = 1; } else if (strcmp(argv[i], "pause") == 0) { - Mpd->Execute("pause \"1\"\n"); + Mpd.Execute("pause \"1\"\n"); quit = 1; } else if (strcmp(argv[i], "toggle") == 0) { - Mpd->UpdateStatus(); - switch (Mpd->GetState()) + Mpd.UpdateStatus(); + switch (Mpd.GetState()) { case psPause: case psPlay: - Mpd->Pause(); + Mpd.Pause(); break; case psStop: - Mpd->Play(); + Mpd.Play(); break; default: break; @@ -134,30 +133,30 @@ void ParseArgv(int argc, char **argv) } else if (strcmp(argv[i], "stop") == 0) { - Mpd->Stop(); + Mpd.Stop(); quit = 1; } else if (strcmp(argv[i], "next") == 0) { - Mpd->Next(); + Mpd.Next(); quit = 1; } else if (strcmp(argv[i], "prev") == 0) { - Mpd->Prev(); + Mpd.Prev(); quit = 1; } else if (strcmp(argv[i], "volume") == 0) { i++; - Mpd->UpdateStatus(); - if (!Mpd->GetErrorMessage().empty()) + Mpd.UpdateStatus(); + if (!Mpd.GetErrorMessage().empty()) { - cout << "Error: " << Mpd->GetErrorMessage() << endl; + cout << "Error: " << Mpd.GetErrorMessage() << endl; exit(0); } if (i != argc) - Mpd->SetVolume(Mpd->GetVolume()+atoi(argv[i])); + Mpd.SetVolume(Mpd.GetVolume()+atoi(argv[i])); quit = 1; } else @@ -165,9 +164,9 @@ void ParseArgv(int argc, char **argv) cout << "ncmpcpp: invalid option: " << argv[i] << endl; exit(0); } - if (!Mpd->GetErrorMessage().empty()) + if (!Mpd.GetErrorMessage().empty()) { - cout << "Error: " << Mpd->GetErrorMessage() << endl; + cout << "Error: " << Mpd.GetErrorMessage() << endl; exit(0); } } diff --git a/src/media_library.cpp b/src/media_library.cpp index b5a0e876..46af16b8 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -166,7 +166,7 @@ void MediaLibrary::Update() TagList list; Albums->Clear(0); Songs->Clear(0); - Mpd->GetList(list, Config.media_lib_primary_tag); + Mpd.GetList(list, Config.media_lib_primary_tag); sort(list.begin(), list.end(), CaseInsensitiveSorting()); for (TagList::iterator it = list.begin(); it != list.end(); it++) { @@ -186,22 +186,22 @@ void MediaLibrary::Update() TagList list; locale_to_utf(Artists->Current()); if (Config.media_lib_primary_tag == MPD_TAG_ITEM_ARTIST) - Mpd->GetAlbums(Artists->Current(), list); + Mpd.GetAlbums(Artists->Current(), list); else { - Mpd->StartFieldSearch(MPD_TAG_ITEM_ALBUM); - Mpd->AddSearch(Config.media_lib_primary_tag, Artists->Current()); - Mpd->CommitSearch(list); + Mpd.StartFieldSearch(MPD_TAG_ITEM_ALBUM); + Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current()); + Mpd.CommitSearch(list); } // <mpd-0.14 doesn't support searching for empty tag - if (Mpd->Version() > 13) + if (Mpd.Version() > 13) { TagList noalbum_list; - Mpd->StartFieldSearch(MPD_TAG_ITEM_FILENAME); - Mpd->AddSearch(Config.media_lib_primary_tag, Artists->Current()); - Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, ""); - Mpd->CommitSearch(noalbum_list); + Mpd.StartFieldSearch(MPD_TAG_ITEM_FILENAME); + Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current()); + Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, ""); + Mpd.CommitSearch(noalbum_list); if (!noalbum_list.empty()) Albums->AddOption(std::make_pair("<no album>", SearchConstraints("", ""))); } @@ -209,10 +209,10 @@ void MediaLibrary::Update() for (TagList::const_iterator it = list.begin(); it != list.end(); it++) { TagList l; - Mpd->StartFieldSearch(MPD_TAG_ITEM_DATE); - Mpd->AddSearch(Config.media_lib_primary_tag, Artists->Current()); - Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it); - Mpd->CommitSearch(l); + Mpd.StartFieldSearch(MPD_TAG_ITEM_DATE); + Mpd.AddSearch(Config.media_lib_primary_tag, Artists->Current()); + Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, *it); + Mpd.CommitSearch(l); if (l.empty()) { Albums->AddOption(std::make_pair(*it, SearchConstraints(*it, ""))); @@ -233,22 +233,22 @@ void MediaLibrary::Update() TagList artists; *Albums << XY(0, 0) << "Fetching albums..."; Albums->Window::Refresh(); - Mpd->GetList(artists, Config.media_lib_primary_tag); + Mpd.GetList(artists, Config.media_lib_primary_tag); for (TagList::const_iterator i = artists.begin(); i != artists.end(); i++) { TagList albums; - Mpd->StartFieldSearch(MPD_TAG_ITEM_ALBUM); - Mpd->AddSearch(Config.media_lib_primary_tag, *i); - Mpd->CommitSearch(albums); + Mpd.StartFieldSearch(MPD_TAG_ITEM_ALBUM); + Mpd.AddSearch(Config.media_lib_primary_tag, *i); + Mpd.CommitSearch(albums); for (TagList::const_iterator j = albums.begin(); j != albums.end(); j++) { if (Config.media_lib_primary_tag != MPD_TAG_ITEM_DATE) { TagList years; - Mpd->StartFieldSearch(MPD_TAG_ITEM_DATE); - Mpd->AddSearch(Config.media_lib_primary_tag, *i); - Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *j); - Mpd->CommitSearch(years); + Mpd.StartFieldSearch(MPD_TAG_ITEM_DATE); + Mpd.AddSearch(Config.media_lib_primary_tag, *i); + Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, *j); + Mpd.CommitSearch(years); if (!years.empty()) { for (TagList::const_iterator k = years.begin(); k != years.end(); k++) @@ -283,8 +283,8 @@ void MediaLibrary::Update() SongList list; Songs->Clear(0); - Mpd->StartSearch(1); - Mpd->AddSearch(Config.media_lib_primary_tag, hasTwoColumns ? Albums->Current().second.Artist : locale_to_utf_cpy(Artists->Current())); + Mpd.StartSearch(1); + Mpd.AddSearch(Config.media_lib_primary_tag, hasTwoColumns ? Albums->Current().second.Artist : locale_to_utf_cpy(Artists->Current())); if (Albums->Empty()) // left for compatibility with <mpd-0.14 { *Albums << XY(0, 0) << "No albums found."; @@ -292,11 +292,11 @@ void MediaLibrary::Update() } else { - Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, Albums->Current().second.Album); + Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, Albums->Current().second.Album); if (!Albums->Current().second.Album.empty()) // for <no album> - Mpd->AddSearch(MPD_TAG_ITEM_DATE, Albums->Current().second.Year); + Mpd.AddSearch(MPD_TAG_ITEM_DATE, Albums->Current().second.Year); } - Mpd->CommitSearch(list); + Mpd.CommitSearch(list); sort(list.begin(), list.end(), SortSongsByTrack); bool bold = 0; @@ -470,15 +470,15 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) if (!Artists->Empty() && w == Artists) { - Mpd->StartSearch(1); - Mpd->AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(Artists->Current())); - Mpd->CommitSearch(list); - Mpd->StartCommandsList(); + Mpd.StartSearch(1); + Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(Artists->Current())); + Mpd.CommitSearch(list); + Mpd.StartCommandsList(); SongList::const_iterator it = list.begin(); for (; it != list.end(); it++) - if (Mpd->AddSong(**it) < 0) + if (Mpd.AddSong(**it) < 0) break; - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); if (it != list.begin()) { @@ -489,7 +489,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) if (s->GetHash() == list[0]->GetHash()) { if (add_n_play) - Mpd->PlayID(s->GetID()); + Mpd.PlayID(s->GetID()); } else ShowMessage("%s", MPD::Message::PartOfSongsAdded); @@ -497,12 +497,12 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) } else if (w == Albums) { - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); size_t i = 0; for (; i < Songs->Size(); i++) - if (Mpd->AddSong(Songs->at(i)) < 0) + if (Mpd.AddSong(Songs->at(i)) < 0) break; - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); if (i) { @@ -511,7 +511,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) if (s->GetHash() == Songs->at(0).GetHash()) { if (add_n_play) - Mpd->PlayID(s->GetID()); + Mpd.PlayID(s->GetID()); } else ShowMessage("%s", MPD::Message::PartOfSongsAdded); @@ -531,7 +531,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Play(i); + Mpd.Play(i); break; } } @@ -539,17 +539,17 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) else { Playlist::BlockUpdate = 1; - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (size_t i = 0; i < myPlaylist->Main()->Size(); i++) { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Delete(i); + Mpd.Delete(i); myPlaylist->Main()->DeleteOption(i); i--; } } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); Songs->BoldOption(Songs->Choice(), 0); Playlist::BlockUpdate = 0; } @@ -557,12 +557,12 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) else { Song &s = Songs->Current(); - int id = Mpd->AddSong(s); + int id = Mpd.AddSong(s); if (id >= 0) { ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str()); if (add_n_play) - Mpd->PlayID(id); + Mpd.PlayID(id); Songs->BoldOption(Songs->Choice(), 1); } } diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 694eda1b..3a4247b9 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -28,6 +28,8 @@ using namespace MPD; using std::string; +MPD::Connection Mpd; + const char *MPD::Message::PartOfSongsAdded = "Only part of requested songs' list added to playlist!"; const char *MPD::Message::FullPlaylist = "Playlist is full!"; const char *MPD::Message::FunctionDisabledFilteringEnabled = "Function disabled due to enabled filtering in playlist"; diff --git a/src/mpdpp.h b/src/mpdpp.h index aaf77aac..b13412dc 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -214,5 +214,7 @@ namespace MPD }; } +extern MPD::Connection Mpd; + #endif diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 3b43f571..4585b71c 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -75,8 +75,6 @@ BasicScreen *Global::myOldScreen; Window *Global::wHeader; Window *Global::wFooter; -Connection *Global::Mpd; - size_t Global::MainStartY; size_t Global::MainHeight; @@ -93,19 +91,17 @@ int main(int argc, char *argv[]) ReadConfiguration(Config); ReadKeys(Key); - Mpd = new Connection; - if (getenv("MPD_HOST")) - Mpd->SetHostname(getenv("MPD_HOST")); + Mpd.SetHostname(getenv("MPD_HOST")); if (getenv("MPD_PORT")) - Mpd->SetPort(atoi(getenv("MPD_PORT"))); + Mpd.SetPort(atoi(getenv("MPD_PORT"))); if (Config.mpd_host != "localhost") - Mpd->SetHostname(Config.mpd_host); + Mpd.SetHostname(Config.mpd_host); if (Config.mpd_port != 6600) - Mpd->SetPort(Config.mpd_port); + Mpd.SetPort(Config.mpd_port); - Mpd->SetTimeout(Config.mpd_connection_timeout); + Mpd.SetTimeout(Config.mpd_connection_timeout); if (argc > 1) { @@ -151,8 +147,8 @@ int main(int argc, char *argv[]) myPlaylist->SwitchTo(); myPlaylist->UpdateTimer(); - Mpd->SetStatusUpdater(NcmpcppStatusChanged, NULL); - Mpd->SetErrorHandler(NcmpcppErrorCallback, NULL); + Mpd.SetStatusUpdater(NcmpcppStatusChanged, NULL); + Mpd.SetErrorHandler(NcmpcppErrorCallback, NULL); // local variables int input; @@ -178,12 +174,12 @@ int main(int argc, char *argv[]) while (!main_exit) { - if (!Mpd->Connected()) + if (!Mpd.Connected()) { ShowMessage("Attempting to reconnect..."); - if (Mpd->Connect()) + if (Mpd.Connect()) { - ShowMessage("Connected to %s!", Mpd->GetHostname().c_str()); + ShowMessage("Connected to %s!", Mpd.GetHostname().c_str()); MessagesAllowed = 0; UpdateStatusImmediately = 1; # ifdef ENABLE_OUTPUTS @@ -332,16 +328,16 @@ int main(int argc, char *argv[]) const Song *s = myPlaylist->NowPlayingSong(); if (!s) continue; - Mpd->Seek(s->GetTotalLength()*mouse_event.x/double(COLS)); + Mpd.Seek(s->GetTotalLength()*mouse_event.x/double(COLS)); UpdateStatusImmediately = 1; } else if (mouse_event.bstate & BUTTON1_PRESSED && Config.statusbar_visibility - && Mpd->GetState() > psStop + && Mpd.GetState() > psStop && mouse_event.y == LINES-1 && mouse_event.x < 9 ) // playing/paused { - Mpd->Pause(); + Mpd.Pause(); UpdateStatusImmediately = 1; } else if ((mouse_event.bstate & BUTTON2_PRESSED || mouse_event.bstate & BUTTON4_PRESSED) @@ -350,9 +346,9 @@ int main(int argc, char *argv[]) ) // volume { if (mouse_event.bstate & BUTTON2_PRESSED) - Mpd->SetVolume(Mpd->GetVolume()-2); + Mpd.SetVolume(Mpd.GetVolume()-2); else - Mpd->SetVolume(Mpd->GetVolume()+2); + Mpd.SetVolume(Mpd.GetVolume()+2); } else myScreen->MouseButtonPressed(mouse_event); @@ -409,10 +405,10 @@ int main(int argc, char *argv[]) myScreen->Refresh(); RedrawStatusbar = 1; StatusChanges changes; - if (Mpd->GetState() < psPlay) + if (Mpd.GetState() < psPlay) changes.PlayerState = 1; changes.StatusFlags = 1; // force status update - NcmpcppStatusChanged(Mpd, changes, NULL); + NcmpcppStatusChanged(&Mpd, changes, NULL); } else if (Keypressed(input, Key.GoToParentDir)) { @@ -447,7 +443,7 @@ int main(int argc, char *argv[]) } # endif // HAVE_TAGLIB_H else - Mpd->SetVolume(Mpd->GetVolume()+1); + Mpd.SetVolume(Mpd.GetVolume()+1); } else if (Keypressed(input, Key.VolumeDown)) { @@ -466,7 +462,7 @@ int main(int argc, char *argv[]) } # endif // HAVE_TAGLIB_H else - Mpd->SetVolume(Mpd->GetVolume()-1); + Mpd.SetVolume(Mpd.GetVolume()-1); } else if (Keypressed(input, Key.Delete)) { @@ -477,13 +473,13 @@ int main(int argc, char *argv[]) { vector<size_t> list; myPlaylist->Main()->GetSelected(list); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++) { - Mpd->DeleteID((*myPlaylist->Main())[*it].GetID()); + Mpd.DeleteID((*myPlaylist->Main())[*it].GetID()); myPlaylist->Main()->DeleteOption(*it); } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); myPlaylist->FixPositions(list.front()); ShowMessage("Selected items deleted!"); } @@ -501,7 +497,7 @@ int main(int argc, char *argv[]) // needed for keeping proper position of now playing song. if (myPlaylist->NowPlaying > myPlaylist->CurrentSong()->GetPosition()-del_counter) myPlaylist->NowPlaying--; - Mpd->DeleteID(myPlaylist->CurrentSong()->GetID()); + Mpd.DeleteID(myPlaylist->CurrentSong()->GetID()); myPlaylist->Main()->DeleteOption(id); myPlaylist->Main()->Refresh(); myPlaylist->Main()->ReadKey(input); @@ -530,7 +526,7 @@ int main(int argc, char *argv[]) while (in != 'y' && in != 'n'); if (in == 'y') { - Mpd->DeletePlaylist(locale_to_utf_cpy(name)); + Mpd.DeletePlaylist(locale_to_utf_cpy(name)); ShowMessage("Playlist \"%s\" deleted!", name.c_str()); if (!Config.local_browser && myBrowser->Main()) myBrowser->GetDirectory("/"); @@ -587,7 +583,7 @@ int main(int argc, char *argv[]) { ShowMessage("\"%s\" has been successfuly deleted!", name.c_str()); if (!Config.local_browser) - Mpd->UpdateDirectory(myBrowser->CurrentDir()); + Mpd.UpdateDirectory(myBrowser->CurrentDir()); else myBrowser->GetDirectory(myBrowser->CurrentDir()); } @@ -607,13 +603,13 @@ int main(int argc, char *argv[]) myPlaylistEditor->Content->GetSelected(list); string playlist = locale_to_utf_cpy(myPlaylistEditor->Playlists->Current()); ShowMessage("Deleting selected items..."); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++) { - Mpd->Delete(playlist, *it); + Mpd.Delete(playlist, *it); myPlaylistEditor->Content->DeleteOption(*it); } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); ShowMessage("Selected items deleted from playlist \"%s\"!", myPlaylistEditor->Playlists->Current().c_str()); } else @@ -624,7 +620,7 @@ int main(int argc, char *argv[]) { TraceMpdStatus(); myPlaylist->UpdateTimer(); - Mpd->Delete(myPlaylistEditor->Playlists->Current(), myPlaylistEditor->Content->Choice()); + Mpd.Delete(myPlaylistEditor->Playlists->Current(), myPlaylistEditor->Content->Choice()); myPlaylistEditor->Content->DeleteOption(myPlaylistEditor->Content->Choice()); myPlaylistEditor->Content->Refresh(); myPlaylistEditor->Content->ReadKey(input); @@ -636,17 +632,17 @@ int main(int argc, char *argv[]) } else if (Keypressed(input, Key.Prev)) { - Mpd->Prev(); + Mpd.Prev(); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.Next)) { - Mpd->Next(); + Mpd.Next(); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.Pause)) { - Mpd->Pause(); + Mpd.Pause(); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.SavePlaylist)) @@ -664,7 +660,7 @@ int main(int argc, char *argv[]) } if (!playlist_name.empty()) { - if (Mpd->SavePlaylist(real_playlist_name)) + if (Mpd.SavePlaylist(real_playlist_name)) { ShowMessage("Playlist saved as: %s", playlist_name.c_str()); if (myPlaylistEditor->Main()) // check if initialized @@ -686,8 +682,8 @@ int main(int argc, char *argv[]) if (in == 'y') { - Mpd->DeletePlaylist(real_playlist_name); - if (Mpd->SavePlaylist(real_playlist_name)) + Mpd.DeletePlaylist(real_playlist_name); + if (Mpd.SavePlaylist(real_playlist_name)) ShowMessage("Playlist overwritten!"); } else @@ -708,7 +704,7 @@ int main(int argc, char *argv[]) } else if (Keypressed(input, Key.Stop)) { - Mpd->Stop(); + Mpd.Stop(); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.MvSongUp)) @@ -744,10 +740,10 @@ int main(int argc, char *argv[]) myPlaylist->Main()->Refresh(); myPlaylist->Main()->ReadKey(input); } - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (size_t i = 0; i < list.size(); i++) - Mpd->Move(origs[i], list[i]); - Mpd->CommitCommandsList(); + Mpd.Move(origs[i], list[i]); + Mpd.CommitCommandsList(); } else { @@ -769,7 +765,7 @@ int main(int argc, char *argv[]) myPlaylist->Main()->Refresh(); myPlaylist->Main()->ReadKey(input); } - Mpd->Move(from, to); + Mpd.Move(from, to); UpdateStatusImmediately = 1; } myPlaylist->Main()->SetTimeout(ncmpcpp_window_timeout); @@ -797,11 +793,11 @@ int main(int argc, char *argv[]) myPlaylistEditor->Content->Refresh(); myPlaylistEditor->Content->ReadKey(input); } - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (size_t i = 0; i < list.size(); i++) if (origs[i] != list[i]) - Mpd->Move(myPlaylistEditor->Playlists->Current(), origs[i], list[i]); - Mpd->CommitCommandsList(); + Mpd.Move(myPlaylistEditor->Playlists->Current(), origs[i], list[i]); + Mpd.CommitCommandsList(); } else { @@ -818,7 +814,7 @@ int main(int argc, char *argv[]) myPlaylistEditor->Content->ReadKey(input); } if (from != to) - Mpd->Move(myPlaylistEditor->Playlists->Current(), from, to); + Mpd.Move(myPlaylistEditor->Playlists->Current(), from, to); } myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout); } @@ -856,10 +852,10 @@ int main(int argc, char *argv[]) myPlaylist->Main()->Refresh(); myPlaylist->Main()->ReadKey(input); } - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (int i = list.size()-1; i >= 0; i--) - Mpd->Move(origs[i], list[i]); - Mpd->CommitCommandsList(); + Mpd.Move(origs[i], list[i]); + Mpd.CommitCommandsList(); } else { @@ -881,7 +877,7 @@ int main(int argc, char *argv[]) myPlaylist->Main()->Refresh(); myPlaylist->Main()->ReadKey(input); } - Mpd->Move(from, to); + Mpd.Move(from, to); UpdateStatusImmediately = 1; } myPlaylist->Main()->SetTimeout(ncmpcpp_window_timeout); @@ -910,11 +906,11 @@ int main(int argc, char *argv[]) myPlaylistEditor->Content->Refresh(); myPlaylistEditor->Content->ReadKey(input); } - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (int i = list.size()-1; i >= 0; i--) if (origs[i] != list[i]) - Mpd->Move(myPlaylistEditor->Playlists->Current(), origs[i], list[i]); - Mpd->CommitCommandsList(); + Mpd.Move(myPlaylistEditor->Playlists->Current(), origs[i], list[i]); + Mpd.CommitCommandsList(); } else { @@ -931,7 +927,7 @@ int main(int argc, char *argv[]) myPlaylistEditor->Content->ReadKey(input); } if (from != to) - Mpd->Move(myPlaylistEditor->Playlists->Current(), from, to); + Mpd.Move(myPlaylistEditor->Playlists->Current(), from, to); } myPlaylistEditor->Content->SetTimeout(ncmpcpp_window_timeout); } @@ -954,14 +950,14 @@ int main(int argc, char *argv[]) if (pos >= list.front() && pos <= list.back()) continue; int diff = pos-list.front(); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); if (diff > 0) { pos -= list.size(); size_t i = list.size()-1; for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); it++, i--) { - Mpd->Move(*it, pos+i); + Mpd.Move(*it, pos+i); myPlaylist->Main()->Move(*it, pos+i); } } @@ -970,11 +966,11 @@ int main(int argc, char *argv[]) size_t i = 0; for (vector<size_t>::const_iterator it = list.begin(); it != list.end(); it++, i++) { - Mpd->Move(*it, pos+i); + Mpd.Move(*it, pos+i); myPlaylist->Main()->Move(*it, pos+i); } } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); myPlaylist->Main()->Highlight(pos); myPlaylist->FixPositions(); } @@ -989,23 +985,23 @@ int main(int argc, char *argv[]) if (!path.empty()) { SongList list; - Mpd->GetDirectoryRecursive(path, list); + Mpd.GetDirectoryRecursive(path, list); if (!list.empty()) { - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); SongList::const_iterator it = list.begin(); if (myScreen == myPlaylistEditor) { for (; it != list.end(); it++) - Mpd->AddToPlaylist(myPlaylistEditor->Playlists->Current(), **it); + Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), **it); } else { for (; it != list.end(); it++) - if (Mpd->AddSong(**it) < 0) + if (Mpd.AddSong(**it) < 0) break; } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); if (it != list.begin() && myScreen != myPlaylistEditor) { @@ -1018,11 +1014,11 @@ int main(int argc, char *argv[]) { if (myScreen == myPlaylistEditor) { - Mpd->AddToPlaylist(myPlaylistEditor->Playlists->Current(), path); + Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path); } else { - Mpd->AddSong(path); + Mpd.AddSong(path); } } if (myScreen == myPlaylistEditor) @@ -1048,7 +1044,7 @@ int main(int argc, char *argv[]) int songpos; time_t t = time(NULL); - songpos = Mpd->GetElapsedTime(); + songpos = Mpd.GetElapsedTime(); while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward)) { @@ -1083,7 +1079,7 @@ int main(int argc, char *argv[]) wFooter->Bold(0); wFooter->Refresh(); } - Mpd->Seek(songpos); + Mpd.Seek(songpos); UpdateStatusImmediately = 1; UnlockProgressbar(); @@ -1149,13 +1145,13 @@ int main(int argc, char *argv[]) else if (Keypressed(input, Key.UpdateDB)) { if (myScreen == myBrowser) - Mpd->UpdateDirectory(locale_to_utf_cpy(myBrowser->CurrentDir())); + Mpd.UpdateDirectory(locale_to_utf_cpy(myBrowser->CurrentDir())); # ifdef HAVE_TAGLIB_H else if (myScreen == myTagEditor && !Config.albums_in_tag_editor) - Mpd->UpdateDirectory(myTagEditor->CurrentDir()); + Mpd.UpdateDirectory(myTagEditor->CurrentDir()); # endif // HAVE_TAGLIB_H else - Mpd->UpdateDirectory("/"); + Mpd.UpdateDirectory("/"); } else if (Keypressed(input, Key.GoToNowPlaying)) { @@ -1173,17 +1169,17 @@ int main(int argc, char *argv[]) } else if (Keypressed(input, Key.ToggleRepeat)) { - Mpd->SetRepeat(!Mpd->GetRepeat()); + Mpd.SetRepeat(!Mpd.GetRepeat()); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.Shuffle)) { - Mpd->Shuffle(); + Mpd.Shuffle(); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.ToggleRandom)) { - Mpd->SetRandom(!Mpd->GetRandom()); + Mpd.SetRandom(!Mpd.GetRandom()); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.ToggleSingle)) @@ -1198,18 +1194,18 @@ int main(int argc, char *argv[]) } else { - Mpd->SetSingle(!Mpd->GetSingle()); + Mpd.SetSingle(!Mpd.GetSingle()); UpdateStatusImmediately = 1; } } else if (Keypressed(input, Key.ToggleConsume)) { - Mpd->SetConsume(!Mpd->GetConsume()); + Mpd.SetConsume(!Mpd.GetConsume()); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.ToggleCrossfade)) { - Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time); + Mpd.SetCrossfade(Mpd.GetCrossfade() ? 0 : Config.crossfade_time); UpdateStatusImmediately = 1; } else if (Keypressed(input, Key.SetCrossfade)) @@ -1222,7 +1218,7 @@ int main(int argc, char *argv[]) if (cf > 0) { Config.crossfade_time = cf; - Mpd->SetCrossfade(cf); + Mpd.SetCrossfade(cf); UpdateStatusImmediately = 1; } } @@ -1246,9 +1242,9 @@ int main(int argc, char *argv[]) bool success = 1; SongList list; ShowMessage("Updating tags..."); - Mpd->StartSearch(1); - Mpd->AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(myLibrary->Artists->Current())); - Mpd->CommitSearch(list); + Mpd.StartSearch(1); + Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(myLibrary->Artists->Current())); + Mpd.CommitSearch(list); Song::SetFunction set = IntoSetFunction(Config.media_lib_primary_tag); if (!set) continue; @@ -1267,7 +1263,7 @@ int main(int argc, char *argv[]) } if (success) { - Mpd->UpdateDirectory(locale_to_utf_cpy(FindSharedDir(list))); + Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(list))); ShowMessage("Tags updated succesfully!"); } FreeSongList(list); @@ -1305,7 +1301,7 @@ int main(int argc, char *argv[]) } if (success) { - Mpd->UpdateDirectory(locale_to_utf_cpy(FindSharedDir(myLibrary->Songs))); + Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(myLibrary->Songs))); ShowMessage("Tags updated succesfully!"); } } @@ -1323,7 +1319,7 @@ int main(int argc, char *argv[]) string full_new_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(new_dir); if (rename(full_old_dir.c_str(), full_new_dir.c_str()) == 0) { - Mpd->UpdateDirectory(myTagEditor->CurrentDir()); + Mpd.UpdateDirectory(myTagEditor->CurrentDir()); } else { @@ -1359,7 +1355,7 @@ int main(int argc, char *argv[]) { ShowMessage("\"%s\" renamed to \"%s\"", old_dir.c_str(), new_dir.c_str()); if (!Config.local_browser) - Mpd->UpdateDirectory(locale_to_utf_cpy(FindSharedDir(old_dir, new_dir))); + Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(old_dir, new_dir))); myBrowser->GetDirectory(myBrowser->CurrentDir()); } else @@ -1375,7 +1371,7 @@ int main(int argc, char *argv[]) UnlockStatusbar(); if (!new_name.empty() && new_name != old_name) { - Mpd->Rename(locale_to_utf_cpy(old_name), locale_to_utf_cpy(new_name)); + Mpd.Rename(locale_to_utf_cpy(old_name), locale_to_utf_cpy(new_name)); ShowMessage("Playlist \"%s\" renamed to \"%s\"", old_name.c_str(), new_name.c_str()); if (!Config.local_browser) myBrowser->GetDirectory("/"); @@ -1418,7 +1414,7 @@ int main(int argc, char *argv[]) } catch (std::out_of_range) { } if (newpos > 0 && newpos < s->GetTotalLength()) - Mpd->Seek(newpos); + Mpd.Seek(newpos); else ShowMessage("Out of bounds, 0:00-%s possible for mm:ss, %d given.", s->GetLength().c_str(), newpos); } @@ -1426,7 +1422,7 @@ int main(int argc, char *argv[]) { newpos = StrToInt(position); if (newpos > 0 && newpos < s->GetTotalLength()) - Mpd->Seek(newpos); + Mpd.Seek(newpos); else ShowMessage("Out of bounds, 1-%d possible for seconds, %d given.", s->GetTotalLength(), newpos); } @@ -1434,7 +1430,7 @@ int main(int argc, char *argv[]) { newpos = StrToInt(position); if (newpos > 0 && newpos < 100) - Mpd->Seek(s->GetTotalLength()*newpos/100.0); + Mpd.Seek(s->GetTotalLength()*newpos/100.0); else ShowMessage("Out of bounds, 1-99 possible for %%, %d given.", newpos); } @@ -1491,7 +1487,7 @@ int main(int argc, char *argv[]) mDialog.AddOption("Create new playlist", 0, playlists_not_active); mDialog.AddSeparator(); TagList playlists; - Mpd->GetPlaylists(playlists); + Mpd.GetPlaylists(playlists); for (TagList::iterator it = playlists.begin(); it != playlists.end(); it++) { utf_to_locale(*it); @@ -1530,12 +1526,12 @@ int main(int argc, char *argv[]) if (id == 0) { - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); SongList::const_iterator it = result.begin(); for (; it != result.end(); it++) - if (Mpd->AddSong(**it) < 0) + if (Mpd.AddSong(**it) < 0) break; - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); if (it != result.begin()) { @@ -1555,20 +1551,20 @@ int main(int argc, char *argv[]) UnlockStatusbar(); if (!playlist.empty()) { - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (SongList::const_iterator it = result.begin(); it != result.end(); it++) - Mpd->AddToPlaylist(real_playlist, **it); - Mpd->CommitCommandsList(); + Mpd.AddToPlaylist(real_playlist, **it); + Mpd.CommitCommandsList(); ShowMessage("Selected items added to playlist \"%s\"!", playlist.c_str()); } } else if (id > 1 && id < mDialog.Size()-1) { string playlist = locale_to_utf_cpy(mDialog.Current()); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (SongList::const_iterator it = result.begin(); it != result.end(); it++) - Mpd->AddToPlaylist(playlist, **it); - Mpd->CommitCommandsList(); + Mpd.AddToPlaylist(playlist, **it); + Mpd.CommitCommandsList(); ShowMessage("Selected items added to playlist \"%s\"!", mDialog.Current().c_str()); } @@ -1588,19 +1584,19 @@ int main(int argc, char *argv[]) CHECK_PLAYLIST_FOR_FILTERING; if (myPlaylist->Main()->hasSelected()) { - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (int i = myPlaylist->Main()->Size()-1; i >= 0; i--) { if (!myPlaylist->Main()->isSelected(i) && i != myPlaylist->NowPlaying) - Mpd->Delete(i); + Mpd.Delete(i); } // if mpd deletes now playing song deletion will be sluggishly slow // then so we have to assure it will be deleted at the very end. if (myPlaylist->isPlaying() && !myPlaylist->Main()->isSelected(myPlaylist->NowPlaying)) - Mpd->DeleteID(myPlaylist->NowPlayingSong()->GetID()); + Mpd.DeleteID(myPlaylist->NowPlayingSong()->GetID()); ShowMessage("Deleting all items but selected..."); - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); ShowMessage("Items deleted!"); } else @@ -1610,12 +1606,12 @@ int main(int argc, char *argv[]) ShowMessage("Nothing is playing now!"); continue; } - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (int i = myPlaylist->Main()->Size()-1; i >= 0; i--) if (i != myPlaylist->NowPlaying) - Mpd->Delete(i); + Mpd.Delete(i); ShowMessage("Deleting all items except now playing one..."); - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); ShowMessage("Items deleted!"); } } @@ -1624,10 +1620,10 @@ int main(int argc, char *argv[]) if (myPlaylist->Main()->isFiltered()) { ShowMessage("Deleting filtered items..."); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (int i = myPlaylist->Main()->Size()-1; i >= 0; i--) - Mpd->Delete((*myPlaylist->Main())[i].GetPosition()); - Mpd->CommitCommandsList(); + Mpd.Delete((*myPlaylist->Main())[i].GetPosition()); + Mpd.CommitCommandsList(); ShowMessage("Filtered items deleted!"); } else @@ -1651,7 +1647,7 @@ int main(int argc, char *argv[]) if (in == 'y') { - Mpd->ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current())); + Mpd.ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current())); myPlaylistEditor->Content->Clear(0); } else @@ -1660,7 +1656,7 @@ int main(int argc, char *argv[]) else { ShowMessage("Clearing playlist..."); - Mpd->ClearPlaylist(); + Mpd.ClearPlaylist(); } if (myScreen != myPlaylistEditor || in == 'y') ShowMessage("Playlist cleared!"); @@ -1788,7 +1784,7 @@ int main(int argc, char *argv[]) Statusbar() << "Number of random songs: "; size_t number = StrToLong(wFooter->GetString()); UnlockStatusbar(); - if (number && Mpd->AddRandomSongs(number)) + if (number && Mpd.AddRandomSongs(number)) ShowMessage(SIZE_T_FORMAT " random song%s added to playlist!", number, number == 1 ? "" : "s"); } else if (myScreen == myBrowser) @@ -1914,7 +1910,7 @@ int main(int argc, char *argv[]) // restore old cerr buffer std::cerr.rdbuf(cerr_buffer); errorlog.close(); - Mpd->Disconnect(); + Mpd.Disconnect(); DestroyScreen(); WindowTitle(""); return 0; diff --git a/src/outputs.cpp b/src/outputs.cpp index 902cac47..d6113361 100644 --- a/src/outputs.cpp +++ b/src/outputs.cpp @@ -73,7 +73,7 @@ void Outputs::EnterPressed() { if (w->Current().second) { - if (Mpd->DisableOutput(w->Choice())) + if (Mpd.DisableOutput(w->Choice())) { ShowMessage("Output \"%s\" disabled", w->Current().first.c_str()); w->Current().second = 0; @@ -82,7 +82,7 @@ void Outputs::EnterPressed() } else { - if (Mpd->EnableOutput(w->Choice())) + if (Mpd.EnableOutput(w->Choice())) { ShowMessage("Output \"%s\" enabled", w->Current().first.c_str()); w->Current().second = 1; @@ -109,7 +109,7 @@ void Outputs::MouseButtonPressed(MEVENT me) void Outputs::FetchList() { MPD::OutputList ol; - Mpd->GetOutputs(ol); + Mpd.GetOutputs(ol); w->Clear(); for (MPD::OutputList::const_iterator it = ol.begin(); it != ol.end(); it++) w->AddOption(*it, it->second); diff --git a/src/playlist.cpp b/src/playlist.cpp index 20366181..2c6b8887 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -127,7 +127,7 @@ void Playlist::EnterPressed() { if (!w->Empty()) { - Mpd->PlayID(w->Current().GetID()); + Mpd.PlayID(w->Current().GetID()); UpdateStatusImmediately = 1; } } @@ -147,7 +147,7 @@ void Playlist::MouseButtonPressed(MEVENT me) w->Goto(me.y); if (me.bstate & BUTTON3_PRESSED) { - Mpd->Play(w->Current().GetPosition()); + Mpd.Play(w->Current().GetPosition()); UpdateStatusImmediately = 1; } } @@ -249,13 +249,13 @@ void Playlist::Sort() { BlockUpdate = 1; ShowMessage("Reversing playlist order..."); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (size_t i = 0, j = w->Size()-1; i < w->Size()/2; i++, j--) { - Mpd->Swap(i, j); + Mpd.Swap(i, j); w->Swap(i, j); } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); ShowMessage("Playlist reversed!"); return; } @@ -290,14 +290,14 @@ void Playlist::Sort() BlockUpdate = 1; ShowMessage("Sorting playlist..."); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); do { for (size_t i = 0; i < playlist.size(); i++) { if (playlist[i]->GetPosition() > int(i)) { - Mpd->Swap(playlist[i]->GetPosition(), i); + Mpd.Swap(playlist[i]->GetPosition(), i); std::swap(cmp[playlist[i]->GetPosition()], cmp[i]); w->Swap(playlist[i]->GetPosition(), i); } @@ -305,7 +305,7 @@ void Playlist::Sort() } } while (playlist != cmp); - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); ShowMessage("Playlist sorted!"); } @@ -374,7 +374,7 @@ std::string Playlist::TotalLength() size_t real_size = w->Size(); w->ShowFiltered(); if (w->Size() != real_size) - result << " (out of " << Mpd->GetPlaylistLength() << ")"; + result << " (out of " << Mpd.GetPlaylistLength() << ")"; } if (itsTotalLength) diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index 4f231dfd..ab277bcf 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -116,7 +116,7 @@ void PlaylistEditor::Update() { Content->Clear(0); TagList list; - Mpd->GetPlaylists(list); + Mpd.GetPlaylists(list); sort(list.begin(), list.end(), CaseInsensitiveSorting()); for (TagList::iterator it = list.begin(); it != list.end(); it++) { @@ -131,7 +131,7 @@ void PlaylistEditor::Update() { Content->Reset(); SongList list; - Mpd->GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list); + Mpd.GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list); if (!list.empty()) Content->SetTitle("Playlist's content (" + IntoStr(list.size()) + " item" + (list.size() == 1 ? ")" : "s)")); else @@ -197,13 +197,13 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play) if (w == Playlists && !Playlists->Empty()) { - Mpd->GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list); - Mpd->StartCommandsList(); + Mpd.GetPlaylistContent(locale_to_utf_cpy(Playlists->Current()), list); + Mpd.StartCommandsList(); SongList::const_iterator it = list.begin(); for (; it != list.end(); it++) - if (Mpd->AddSong(**it) < 0) + if (Mpd.AddSong(**it) < 0) break; - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); if (it != list.begin()) { @@ -212,7 +212,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play) if (s.GetHash() == list[0]->GetHash()) { if (add_n_play) - Mpd->PlayID(s.GetID()); + Mpd.PlayID(s.GetID()); } else ShowMessage("%s", MPD::Message::PartOfSongsAdded); @@ -232,7 +232,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play) { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Play(i); + Mpd.Play(i); break; } } @@ -240,17 +240,17 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play) else { Playlist::BlockUpdate = 1; - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (size_t i = 0; i < myPlaylist->Main()->Size(); i++) { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Delete(i); + Mpd.Delete(i); myPlaylist->Main()->DeleteOption(i); i--; } } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); Content->BoldOption(Content->Choice(), 0); Playlist::BlockUpdate = 0; } @@ -258,12 +258,12 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play) else { const Song &s = Content->Current(); - int id = Mpd->AddSong(s); + int id = Mpd.AddSong(s); if (id >= 0) { ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str()); if (add_n_play) - Mpd->PlayID(id); + Mpd.PlayID(id); Content->BoldOption(Content->Choice(), 1); } } diff --git a/src/search_engine.cpp b/src/search_engine.cpp index ed41a117..e4829d5a 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -234,7 +234,7 @@ void SearchEngine::EnterPressed() { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Play(i); + Mpd.Play(i); break; } } @@ -242,10 +242,10 @@ void SearchEngine::EnterPressed() else { const Song &s = *w->Current().second; - int id = Mpd->AddSong(s); + int id = Mpd.AddSong(s); if (id >= 0) { - Mpd->PlayID(id); + Mpd.PlayID(id); ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str()); w->BoldOption(w->Choice(), 1); } @@ -273,24 +273,24 @@ void SearchEngine::SpacePressed() { Playlist::BlockUpdate = 1; long long hash = w->Current().second->GetHash(); - Mpd->StartCommandsList(); + Mpd.StartCommandsList(); for (size_t i = 0; i < myPlaylist->Main()->Size(); i++) { if (myPlaylist->Main()->at(i).GetHash() == hash) { - Mpd->Delete(i); + Mpd.Delete(i); myPlaylist->Main()->DeleteOption(i); i--; } } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); w->BoldOption(w->Choice(), 0); Playlist::BlockUpdate = 0; } else { const Song &s = *w->Current().second; - if (Mpd->AddSong(s) != -1) + if (Mpd.AddSong(s) != -1) { ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str()); w->BoldOption(w->Choice(), 1); @@ -421,7 +421,7 @@ void SearchEngine::Search() SongList list; if (Config.search_in_db) - Mpd->GetDirectoryRecursive("/", list); + Mpd.GetDirectoryRecursive("/", list); else { list.reserve(myPlaylist->Main()->Size()); diff --git a/src/status.cpp b/src/status.cpp index 4421db0f..b774a347 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -109,7 +109,7 @@ void UnlockStatusbar() else block_progressbar_update = 0; } - if (Mpd->GetState() < psPlay) + if (Mpd.GetState() < psPlay) Statusbar() << wclrtoeol; } @@ -118,12 +118,12 @@ void TraceMpdStatus() static timeval past, now; gettimeofday(&now, 0); - if ((Mpd->Connected() + if ((Mpd.Connected() && (/*(now.tv_sec == past.tv_sec && now.tv_usec >= past.tv_usec+500000) || */now.tv_sec > past.tv_sec)) || UpdateStatusImmediately ) { - Mpd->UpdateStatus(); + Mpd.UpdateStatus(); BlockItemListUpdate = 0; Playlist::BlockUpdate = 0; UpdateStatusImmediately = 0; @@ -145,29 +145,29 @@ void TraceMpdStatus() else block_progressbar_update = !allow_statusbar_unlock; - if (Mpd->GetState() < psPlay && !block_statusbar_update) + if (Mpd.GetState() < psPlay && !block_statusbar_update) Statusbar() << wclrtoeol; } } } -void NcmpcppErrorCallback(Connection *Mpd, int errorid, const char *msg, void *) +void NcmpcppErrorCallback(Connection *, int errorid, const char *msg, void *) { if (errorid == MPD_ACK_ERROR_PERMISSION) { wFooter->SetGetStringHelper(NULL); Statusbar() << "Password: "; string password = wFooter->GetString(-1, 0, 1); - Mpd->SetPassword(password); - Mpd->SendPassword(); - Mpd->UpdateStatus(); + Mpd.SetPassword(password); + Mpd.SendPassword(); + Mpd.UpdateStatus(); wFooter->SetGetStringHelper(StatusbarGetStringHelper); } else ShowMessage("%s", msg); } -void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) +void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *) { static size_t playing_song_scroll_begin = 0; static string player_state; @@ -178,10 +178,10 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) wFooter->Bold(1); wFooter->GetXY(sx, sy); - if ((myPlaylist->NowPlaying != Mpd->GetCurrentSongPos() || changed.SongID) && !Playlist::BlockNowPlayingUpdate) + if ((myPlaylist->NowPlaying != Mpd.GetCurrentSongPos() || changed.SongID) && !Playlist::BlockNowPlayingUpdate) { myPlaylist->OldPlaying = myPlaylist->NowPlaying; - myPlaylist->NowPlaying = Mpd->GetCurrentSongPos(); + myPlaylist->NowPlaying = Mpd.GetCurrentSongPos(); bool was_filtered = myPlaylist->Main()->isFiltered(); myPlaylist->Main()->ShowAll(); try @@ -202,19 +202,19 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) { if (!Playlist::BlockUpdate) { - np = Mpd->GetCurrentSong(); - if (Mpd->GetState() > psStop) + np = Mpd.GetCurrentSong(); + if (Mpd.GetState() > psStop) WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format))); bool was_filtered = myPlaylist->Main()->isFiltered(); myPlaylist->Main()->ShowAll(); SongList list; - size_t playlist_length = Mpd->GetPlaylistLength(); + size_t playlist_length = Mpd.GetPlaylistLength(); if (playlist_length < myPlaylist->Main()->Size()) myPlaylist->Main()->ResizeList(playlist_length); - Mpd->GetPlaylistChanges(Mpd->GetOldPlaylistID(), list); + Mpd.GetPlaylistChanges(Mpd.GetOldPlaylistID(), list); myPlaylist->Main()->Reserve(playlist_length); for (SongList::const_iterator it = list.begin(); it != list.end(); it++) { @@ -306,7 +306,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) } if (changed.PlayerState) { - PlayerState mpd_state = Mpd->GetState(); + PlayerState mpd_state = Mpd.GetState(); switch (mpd_state) { case psUnknown: @@ -352,45 +352,45 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) { if (myPlaylist->isPlaying()) { - np = Mpd->GetCurrentSong(); + np = Mpd.GetCurrentSong(); if (!Config.execute_on_song_change.empty()) system(np.toString(Config.execute_on_song_change).c_str()); - if (Mpd->GetState() > psStop) + if (Mpd.GetState() > psStop) WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format))); if (Config.autocenter_mode && !myPlaylist->Main()->isFiltered()) myPlaylist->Main()->Highlight(myPlaylist->NowPlaying); - if (!Mpd->GetElapsedTime()) + if (!Mpd.GetElapsedTime()) mvwhline(wFooter->Raw(), 0, 0, 0, wFooter->GetWidth()); - if (Config.now_playing_lyrics && !Mpd->GetSingle() && myScreen == myLyrics && myOldScreen == myPlaylist) + if (Config.now_playing_lyrics && !Mpd.GetSingle() && myScreen == myLyrics && myOldScreen == myPlaylist) Lyrics::Reload = 1; } Playlist::ReloadRemaining = 1; playing_song_scroll_begin = 0; - if (Mpd->GetState() == psPlay) + if (Mpd.GetState() == psPlay) { changed.ElapsedTime = 1; } } static time_t now, past = 0; time(&now); - if (((now > past || changed.SongID) && Mpd->GetState() > psStop) || RedrawStatusbar) + if (((now > past || changed.SongID) && Mpd.GetState() > psStop) || RedrawStatusbar) { time(&past); if (np.Empty()) { - np = Mpd->GetCurrentSong(); + np = Mpd.GetCurrentSong(); WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format))); } if (!np.Empty() && !player_state.empty()) { - int mpd_elapsed = Mpd->GetElapsedTime(); + int mpd_elapsed = Mpd.GetElapsedTime(); if (elapsed < mpd_elapsed-2 || elapsed+1 > mpd_elapsed) elapsed = mpd_elapsed; - else if (Mpd->GetState() == psPlay && !RedrawStatusbar) + else if (Mpd.GetState() == psPlay && !RedrawStatusbar) elapsed++; if (!block_statusbar_update && Config.statusbar_visibility) @@ -447,33 +447,33 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) if (changed.Repeat) { - mpd_repeat = Mpd->GetRepeat() ? 'r' : 0; + mpd_repeat = Mpd.GetRepeat() ? 'r' : 0; ShowMessage("Repeat mode is %s", !mpd_repeat ? "off" : "on"); } if (changed.Random) { - mpd_random = Mpd->GetRandom() ? 'z' : 0; + mpd_random = Mpd.GetRandom() ? 'z' : 0; ShowMessage("Random mode is %s", !mpd_random ? "off" : "on"); } if (changed.Single) { - mpd_single = Mpd->GetSingle() ? 's' : 0; + mpd_single = Mpd.GetSingle() ? 's' : 0; ShowMessage("Single mode is %s", !mpd_single ? "off" : "on"); } if (changed.Consume) { - mpd_consume = Mpd->GetConsume() ? 'c' : 0; + mpd_consume = Mpd.GetConsume() ? 'c' : 0; ShowMessage("Consume mode is %s", !mpd_consume ? "off" : "on"); } if (changed.Crossfade) { - int crossfade = Mpd->GetCrossfade(); + int crossfade = Mpd.GetCrossfade(); mpd_crossfade = crossfade ? 'x' : 0; ShowMessage("Crossfade set to %d seconds", crossfade); } if (changed.DBUpdating) { - mpd_db_updating = Mpd->GetDBIsUpdating() ? 'U' : 0; + mpd_db_updating = Mpd.GetDBIsUpdating() ? 'U' : 0; ShowMessage(!mpd_db_updating ? "Database update finished!" : "Database update started!"); } if (changed.StatusFlags && Config.header_visibility) @@ -512,7 +512,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) if (changed.Volume && Config.header_visibility) { VolumeState = " Volume: "; - int volume = Mpd->GetVolume(); + int volume = Mpd.GetVolume(); if (volume < 0) VolumeState += "n/a"; else diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 2bfe6880..def34f7b 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -193,7 +193,7 @@ void TinyTagEditor::EnterPressed() ShowMessage("Tags updated!"); if (s.IsFromDB()) { - Mpd->UpdateDirectory(locale_to_utf_cpy(s.GetDirectory())); + Mpd.UpdateDirectory(locale_to_utf_cpy(s.GetDirectory())); if (myOldScreen == mySearcher) *mySearcher->Main()->Current().second = s; } @@ -443,14 +443,14 @@ void TagEditor::Update() { *Albums << XY(0, 0) << "Fetching albums..."; Albums->Window::Refresh(); - Mpd->GetAlbums("", list); + Mpd.GetAlbums("", list); for (TagList::const_iterator it = list.begin(); it != list.end(); it++) { SongList l; - Mpd->StartSearch(1); - Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, *it); - Mpd->CommitSearch(l); + Mpd.StartSearch(1); + Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, *it); + Mpd.CommitSearch(l); if (!l.empty()) { l[0]->Localize(); @@ -463,7 +463,7 @@ void TagEditor::Update() else { int highlightme = -1; - Mpd->GetDirectories(itsBrowsedDir, list); + Mpd.GetDirectories(itsBrowsedDir, list); sort(list.begin(), list.end(), CaseInsensitiveSorting()); if (itsBrowsedDir != "/") { @@ -497,9 +497,9 @@ void TagEditor::Update() SongList list; if (Config.albums_in_tag_editor) { - Mpd->StartSearch(1); - Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, Albums->Current().second); - Mpd->CommitSearch(list); + Mpd.StartSearch(1); + Mpd.AddSearch(MPD_TAG_ITEM_ALBUM, Albums->Current().second); + Mpd.CommitSearch(list); sort(list.begin(), list.end(), CaseInsensitiveSorting()); for (SongList::iterator it = list.begin(); it != list.end(); it++) { @@ -509,7 +509,7 @@ void TagEditor::Update() } else { - Mpd->GetSongs(Dirs->Current().second, list); + Mpd.GetSongs(Dirs->Current().second, list); sort(list.begin(), list.end(), CaseInsensitiveSorting()); for (SongList::const_iterator it = list.begin(); it != list.end(); it++) { @@ -535,7 +535,7 @@ void TagEditor::EnterPressed() if (w == Dirs) { TagList test; - Mpd->GetDirectories(LeftColumn->Current().second, test); + Mpd.GetDirectories(LeftColumn->Current().second, test); if (!test.empty()) { itsHighlightedDir = itsBrowsedDir; @@ -686,7 +686,7 @@ void TagEditor::EnterPressed() w->Refresh(); w = LeftColumn; LeftColumn->HighlightColor(Config.active_column_color); - Mpd->UpdateDirectory(locale_to_utf_cpy(FindSharedDir(Tags))); + Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(Tags))); } else Tags->Clear(0); @@ -986,15 +986,15 @@ bool TagEditor::WriteTags(Song &s) // if we rename local file, it won't get updated // so just remove it from playlist and add again size_t pos = myPlaylist->Main()->Choice(); - Mpd->StartCommandsList(); - Mpd->Delete(pos); - int id = Mpd->AddSong("file://" + new_name); + Mpd.StartCommandsList(); + Mpd.Delete(pos); + int id = Mpd.AddSong("file://" + new_name); if (id >= 0) { s = myPlaylist->Main()->Back(); - Mpd->Move(s.GetPosition(), pos); + Mpd.Move(s.GetPosition(), pos); } - Mpd->CommitCommandsList(); + Mpd.CommitCommandsList(); } else // only myBrowser->Main() s.SetFile(new_name); |